##// END OF EJS Templates
Added a few files to the repository
paul -
r101:30ac019d302a VHDLib206
parent child
Show More
@@ -0,0 +1,83
1 def ieee(f, word=32):
2 """Generate the binary string representing a floating-point value in IEEE754 code."""
3 f = float(f)
4 if word not in (16, 32, 64, 128):
5 raise ValueError("IEEE754 is defined for 16, 32, 64 and 128 bit words.")
6 exp_bin = range({16:5, 32:8, 64:11, 128:15}[word])
7 frac_bin = range(word - len(exp_bin) - 1)
8
9 # Sign.
10 sign_bin = [int(f < 0)]
11 f = abs(f)
12
13 # Find exponent (adding the bias).
14 bias = 2**(len(exp_bin)-1) -1
15 exponent = bias
16 while f >= 2:
17 exponent += 1
18 f /= 2
19 while f < 1 and exponent > 0:
20 exponent -= 1
21 f *= 2
22 if not 0 <= exponent < 2*(bias+1):
23 raise ValueError("Exponent overflow: Absolute exponent must be smaller than %d." % (bias + 1))
24
25 # Encode exponent in binary.
26 for i in exp_bin[::-1]:
27 exp_bin[i] = int(exponent % 2)
28 exponent /= 2
29
30 # Remove the leading 1 bit.
31 f -= 1
32 for i in frac_bin:
33 f *= 2
34 frac_bin[i] = int(f >= 1)
35 f -= frac_bin[i]
36
37 # Join the binary string components together.
38 return "".join(map(str, sign_bin + exp_bin + frac_bin))
39
40 def ieee_decode(binary):
41 """Decode a binary string representing a floating-point value in IEEE754 code."""
42
43 # Determine the word size of the binary.
44 word = len(binary)
45 if word not in (16, 32, 64, 128):
46 raise ValueError("IEEE754 is defined for 16, 32, 64 and 128 bit words.")
47
48 # Determine the length of the exponent.
49 e = {16:5, 32:8, 64:11, 128:15}[word]
50
51 # Turn the binary string into a bit-list.
52 binary = [int(c) for c in binary]
53
54 # Split the components.
55 sign = -2 * binary[0] + 1
56 exp_bin = binary[1:1+e]
57 frac_bin = binary[1+e:]
58
59 # Decode the exponent.
60 bias = 2**(e-1) - 1
61 exponent = -bias
62 c = 1
63 for i in exp_bin[::-1]:
64 exponent += i * c
65 c *= 2
66
67 # Decode the fraction.
68 f = float(2**exponent)
69 power = f
70 for i in frac_bin:
71 power *= 0.5
72 f += i * power
73
74 return sign * f
75
76 if __name__ == "__main__":
77 val = ieee(24.)
78 val
79 print val[:16]
80 print val[0], val[1], val[2]
81 val_in_int = int(val[:16], 2)
82 print val_in_int
83 print hex( val_in_int ) No newline at end of file
@@ -0,0 +1,12
1 target extended-remote :3333
2
3 # Reset to known state
4 monitor reset halt
5 load
6 monitor reset init
7
8 # Set a breakpoint at main().
9 break set_apbuart_scaler_reload_register
10
11 # Run to the breakpoint.
12 continue
@@ -0,0 +1,14
1 # -*- coding: utf-8 *-*
2
3 # setting up LPPMON plugins
4 from __main__ import proxy
5 if not(proxy.instanceExists("RMAPPlugin0")):
6 proxy.loadSysDriver("RMAPPlugin", "RMAPPlugin0")
7 proxy.loadSysDriverToParent("dsu3plugin", "RMAPPlugin0")
8
9 dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw")
10 dsu3plugin0.loadFile()
11 dsu3plugin0.run()
12
13 from __main__ import RMAPPlugin0
14
@@ -0,0 +1,16
1 #!/usr/bin/lppmon -e
2
3 address_to_read = 0x80000f08
4 val = RMAPPlugin0.Read( address_to_read, 1)
5 matrixF0_Address0 = val[0]
6 print hex(matrixF0_Address0)
7
8 # BUILD THE DATA
9 dataToWrite = []
10 for frequencyBin in range(128):
11 for component in range (25):
12 dataToWrite.append( component )
13
14 # WRITE THE DATA
15 print len(dataToWrite)
16 RMAPPlugin0.Write( matrixF0_Address0, dataToWrite )
General Comments 0
You need to be logged in to leave comments. Login now