##// END OF EJS Templates
Sync
paul -
r7:565b8186dcb8 default
parent child
Show More
@@ -0,0 +1,45
1 import math
2 import numpy as np
3 from bin16 import *
4 from fft import *
5 import matplotlib.pyplot as plt
6
7 nb_points = 256
8 nb_periods = 10
9 amplitude = 1000
10
11 time_vec = np.arange(0, nb_points, 1)
12 teta = nb_periods * time_vec * 2 * np.pi/ nb_points
13
14 Afloat = 10000 * np.sin( teta )
15
16 Aint = np.zeros(len(time_vec))
17 for i in range(len(time_vec)):
18 Aint[i] = quant16( Afloat[i], -pow(2,16)/2, +pow(2,16)/2 )
19
20 plt.figure(1)
21 plt.plot(time_vec,Afloat,'b.')
22 plt.plot(time_vec,Aint,'r.')
23 plt.show()
24
25 Afloat_FFT = np.fft.fft(Afloat)/len(time_vec)
26
27 # plt.figure(2)
28 # plt.plot(abs(Afloat_FFT[0:100]),'g')
29 # plt.show()
30
31 # plt.figure(3)
32 # plt.plot(time_vec,Aint,'r')
33 # plt.show()
34
35 Aint_FFT = fft_CT(Aint)
36
37 plt.figure(4)
38 plt.plot(abs(Afloat_FFT[0:100]),'g')
39 plt.scatter(range(100),1.0 * abs(Aint_FFT[0:100])/16384)
40 plt.title("Comparing the FFT's")
41 plt.show()
42
43
44
45
@@ -0,0 +1,52
1 IF apbi.psel(pindex) = '1' THEN
2 -- APB DMA READ --
3 CASE paddr(7 DOWNTO 2) IS
4 --0
5 0x00 WHEN "000000" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f0(31 DOWNTO 0);
6 0x04 WHEN "000001" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f0(63 DOWNTO 32);
7 0x08 WHEN "000010" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f0(79 DOWNTO 64);
8 0XC0 WHEN "000011" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f0;
9
10 0x10 WHEN "000100" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f1(31 DOWNTO 0);
11 0x14 WHEN "000101" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f1(63 DOWNTO 32);
12 0x18 WHEN "000110" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f1(79 DOWNTO 64);
13 0x1C WHEN "000111" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f1;
14
15 0x20 WHEN "001000" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f2(31 DOWNTO 0);
16 0x24 WHEN "001001" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f2(63 DOWNTO 32);
17 0x28 WHEN "001010" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f2(79 DOWNTO 64);
18 0x2C WHEN "001011" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f2;
19
20 0x30 WHEN "001100" => prdata(31 DOWNTO 0) <= MEM_OUT_SM_Data_out(32*1-1 DOWNTO 32*0);
21 0x34 WHEN "001101" => prdata(31 DOWNTO 0) <= MEM_OUT_SM_Data_out(32*2-1 DOWNTO 32*1);
22
23 0x38 WHEN "001110" => prdata(1 DOWNTO 0) <= reg_ftt.out_ren;
24 prdata(3 DOWNTO 2) <= MEM_OUT_SM_Full;
25 prdata(5 DOWNTO 4) <= MEM_OUT_SM_Empty;
26 WHEN OTHERS => NULL;
27
28 END CASE;
29 IF (apbi.pwrite AND apbi.penable) = '1' THEN
30 -- APB DMA WRITE --
31 CASE paddr(7 DOWNTO 2) IS
32 0x00 WHEN "000000" => reg_ftt.in_data_f0(31 DOWNTO 0) <= apbi.pwdata;
33 0x04 WHEN "000001" => reg_ftt.in_data_f0(63 DOWNTO 32) <= apbi.pwdata;
34 0x08 WHEN "000010" => reg_ftt.in_data_f0(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0);
35 0x0c WHEN "000011" => reg_ftt.in_wen_f0 <= apbi.pwdata(4 DOWNTO 0);
36
37 0x10 WHEN "000100" => reg_ftt.in_data_f1(31 DOWNTO 0) <= apbi.pwdata;
38 0x14 WHEN "000101" => reg_ftt.in_data_f1(63 DOWNTO 32) <= apbi.pwdata;
39 0x18 WHEN "000110" => reg_ftt.in_data_f1(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0);
40 0x1c WHEN "000111" => reg_ftt.in_wen_f1 <= apbi.pwdata(4 DOWNTO 0);
41
42 0x20 WHEN "001000" => reg_ftt.in_data_f2(31 DOWNTO 0) <= apbi.pwdata;
43 0x24 WHEN "001001" => reg_ftt.in_data_f2(63 DOWNTO 32) <= apbi.pwdata;
44 0x28 WHEN "001010" => reg_ftt.in_data_f2(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0);
45 0x2C WHEN "001011" => reg_ftt.in_wen_f2 <= apbi.pwdata(4 DOWNTO 0);
46
47 0x38 WHEN "001110" => reg_ftt.out_ren <= apbi.pwdata(1 DOWNTO 0);
48
49 WHEN OTHERS => NULL;
50 END CASE;
51 END IF;
52 END IF;
@@ -0,0 +1,52
1 IF apbi.psel(pindex) = '1' THEN
2 -- APB DMA READ --
3 CASE paddr(7 DOWNTO 2) IS
4 --0
5 WHEN "000000" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f0(31 DOWNTO 0);
6 WHEN "000001" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f0(63 DOWNTO 32);
7 WHEN "000010" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f0(79 DOWNTO 64);
8 WHEN "000011" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f0;
9
10 WHEN "000100" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f1(31 DOWNTO 0);
11 WHEN "000101" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f1(63 DOWNTO 32);
12 WHEN "000110" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f1(79 DOWNTO 64);
13 WHEN "000111" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f1;
14
15 WHEN "001000" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f2(31 DOWNTO 0);
16 WHEN "001001" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f2(63 DOWNTO 32);
17 WHEN "001010" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f2(79 DOWNTO 64);
18 WHEN "001011" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f2;
19
20 WHEN "001100" => prdata(31 DOWNTO 0) <= MEM_OUT_SM_Data_out(32*1-1 DOWNTO 32*0);
21 WHEN "001101" => prdata(31 DOWNTO 0) <= MEM_OUT_SM_Data_out(32*2-1 DOWNTO 32*1);
22
23 WHEN "001110" => prdata(1 DOWNTO 0) <= reg_ftt.out_ren;
24 prdata(3 DOWNTO 2) <= MEM_OUT_SM_Full;
25 prdata(5 DOWNTO 4) <= MEM_OUT_SM_Empty;
26 WHEN OTHERS => NULL;
27
28 END CASE;
29 IF (apbi.pwrite AND apbi.penable) = '1' THEN
30 -- APB DMA WRITE --
31 CASE paddr(7 DOWNTO 2) IS
32 WHEN "000000" => reg_ftt.in_data_f0(31 DOWNTO 0) <= apbi.pwdata;
33 WHEN "000001" => reg_ftt.in_data_f0(63 DOWNTO 32) <= apbi.pwdata;
34 WHEN "000010" => reg_ftt.in_data_f0(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0);
35 WHEN "000011" => reg_ftt.in_wen_f0 <= apbi.pwdata(4 DOWNTO 0);
36
37 WHEN "000100" => reg_ftt.in_data_f1(31 DOWNTO 0) <= apbi.pwdata;
38 WHEN "000101" => reg_ftt.in_data_f1(63 DOWNTO 32) <= apbi.pwdata;
39 WHEN "000110" => reg_ftt.in_data_f1(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0);
40 WHEN "000111" => reg_ftt.in_wen_f1 <= apbi.pwdata(4 DOWNTO 0);
41
42 WHEN "001000" => reg_ftt.in_data_f2(31 DOWNTO 0) <= apbi.pwdata;
43 WHEN "001001" => reg_ftt.in_data_f2(63 DOWNTO 32) <= apbi.pwdata;
44 WHEN "001010" => reg_ftt.in_data_f2(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0);
45 WHEN "001011" => reg_ftt.in_wen_f2 <= apbi.pwdata(4 DOWNTO 0);
46
47 WHEN "001110" => reg_ftt.out_ren <= apbi.pwdata(1 DOWNTO 0);
48
49 WHEN OTHERS => NULL;
50 END CASE;
51 END IF;
52 END IF;
@@ -0,0 +1,150
1 import os
2 os.system('clear') # on linux / os x
3
4 import numpy as np
5 import matplotlib.pyplot as plt
6
7 from test_fft.register_addresses_fft_test import *
8 from test_fft.fft_test_functions import *
9
10 print_custom( '*' )
11 print_custom( '*' )
12 print_custom( '*' )
13 print_custom( '*' )
14 print_custom( '*' )
15
16 ######################
17 # GET DATA FROM RECORD
18 #storageDirectory = '/home/paul/data/2014_06_24/'
19 #day = '2014_6_24-'
20 #hour = '9_0_3'
21 #suffix = '.data'
22
23 #typeOfData = '_SBM1_CWF_'
24 #cwf_f1 = np.genfromtxt( storageDirectory + day + hour + typeOfData + 'F1' + suffix,
25 # skip_header = 1)
26 cwf_f1 = np.zeros( 1000 )
27
28 #################
29 # BUILD WAVEFORMS
30 nbSamples = 256
31 nbComponentsPerMatrix = 25
32 nbFrequencyBins = 128
33 #wfrm0 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnV )
34 #wfrm1 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnE1 )
35 #wfrm2 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnE2 )
36 #wfrm3 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnB1 )
37 #wfrm4 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnB2 )
38 wfrm0 = sineWave( 256, 10, 1000 )
39 wfrm1 = sineWave( 256, 20, 1000 )
40 wfrm2 = sineWave( 256, 30, 1000 )
41 wfrm3 = sineWave( 256, 40, 1000 )
42 wfrm4 = sineWave( 256, 50, 1000 )
43
44 ################
45 # BUILD THE DATA
46 dataToWrite0 = generateDataToWrite( nbSamples, wfrm0, wfrm1 )
47 dataToWrite1 = generateDataToWrite( nbSamples, wfrm2, wfrm3 )
48 dataToWrite2 = generateDataToWrite( nbSamples, wfrm4, np.zeros( nbSamples ) )
49
50 ########################
51 # WRITE WAVEFORM IN FIFO
52 print_custom( "1) write waveforms in FIFOs: " + str(len(dataToWrite0)) + " samples" )
53 print_reg_sm( )
54
55 for k in range(nbSamples):
56 RMAPPlugin0.Write( address_FIFO_F2_1_0, [dataToWrite0[k]] )
57 RMAPPlugin0.Write( address_FIFO_F2_3_2, [dataToWrite1[k]] )
58 RMAPPlugin0.Write( address_FIFO_F2_4, [dataToWrite2[k]] )
59 # write only the FIFO F2
60 RMAPPlugin0.Write( address_FIFO_F2_WEN, [0xffffffe0] )
61
62 print_custom( "1) data written in FIFOs" )
63
64 print_reg_sm( )
65
66 # wait for SM_OUT_Full
67 while ( is_MEM_OUT_SM_Full() ) == 0:
68 print_custom( "SM not full" )
69
70 print_reg_sm( )
71
72 ################
73 # SM FIRST READ
74 print_custom( "======= SM FIRST READ" )
75
76 components = []
77
78 if is_MEM_OUT_SM_Full_FIFO_0():
79 print_custom( "FIFO_0 is full" )
80 address_MEM_OUT_SM = address_MEM_OUT_SM_0
81 elif is_MEM_OUT_SM_Full_FIFO_1():
82 print_custom( "FIFO_1 is full")
83 address_MEM_OUT_SM = address_MEM_OUT_SM_1
84 else:
85 print_custom( "/!\ no MEM_OUT_SM FIFO full /!\ " )
86
87 for component in range(nbComponentsPerMatrix):
88 print_custom( "component = " + str( component ) )
89 currentComp = np.zeros( nbFrequencyBins )
90 for frequencyBin in range(nbFrequencyBins):
91 # read enable => 0000 0000 0000 0000
92 if is_MEM_OUT_SM_Empty( ) == 1:
93 print_custom( "component = " + str( component ) \
94 + " bin = " + str( frequencyBin ) )
95 val = RMAPPlugin0.Read( address_MEM_OUT_SM, 1)
96 RMAPPlugin0.Write( address_CTRL_SM, [0x00000000] )
97 currentComp[frequencyBin] = val[0]
98 RMAPPlugin0.ProcessPendingEvents()
99 components.append( currentComp )
100
101 # PLOT SM
102
103 plt.figure( 1 )
104 plt.subplot(231)
105 plt.plot(wfrm0, 'b')
106 plt.subplot(232)
107 plt.plot(wfrm1, 'g')
108 plt.plot(wfrm1, '.')
109 plt.subplot(233)
110 plt.plot(wfrm2, 'r')
111 plt.plot(wfrm2, '.')
112 plt.subplot(234)
113 plt.plot(wfrm3, 'c')
114 plt.subplot(235)
115 plt.plot(wfrm4, 'm')
116
117 plt.figure( 2 )
118 plt.subplot(231)
119 plt.plot(components[0][:])
120 plt.plot(components[1][:])
121 plt.plot(components[2][:])
122 plt.plot(components[3][:])
123 plt.subplot(232)
124 plt.plot(components[4][:])
125 plt.plot(components[5][:])
126 plt.plot(components[6][:])
127 plt.plot(components[7][:])
128 plt.subplot(233)
129 plt.plot(components[8][:])
130 plt.plot(components[9][:])
131 plt.plot(components[10][:])
132 plt.plot(components[11][:])
133 plt.subplot(234)
134 plt.plot(components[12][:])
135 plt.plot(components[13][:])
136 plt.plot(components[14][:])
137 plt.plot(components[15][:])
138 plt.subplot(235)
139 plt.plot(components[16][:])
140 plt.plot(components[17][:])
141 plt.plot(components[18][:])
142 plt.plot(components[19][:])
143 plt.subplot(236)
144 plt.plot(components[20][:])
145 plt.plot(components[21][:])
146 plt.plot(components[22][:])
147 plt.plot(components[23][:])
148 plt.plot(components[24][:])
149
150 plt.show() No newline at end of file
@@ -4,6 +4,34
4 "selected_items":
4 "selected_items":
5 [
5 [
6 [
6 [
7 "c",
8 "c"
9 ],
10 [
11 "g",
12 "g"
13 ],
14 [
15 "compo",
16 "components_re"
17 ],
18 [
19 "cur",
20 "currentComp_im"
21 ],
22 [
23 "current",
24 "currentComp_im"
25 ],
26 [
27 "curre",
28 "currentComp_re"
29 ],
30 [
31 "nb",
32 "nbComponentsPerMatrix"
33 ],
34 [
7 "MEM",
35 "MEM",
8 "MEM_IN_SM_Empty"
36 "MEM_IN_SM_Empty"
9 ],
37 ],
@@ -100,10 +128,6
100 "groupbox_tc_lfr_load_common_par"
128 "groupbox_tc_lfr_load_common_par"
101 ],
129 ],
102 [
130 [
103 "c",
104 "common"
105 ],
106 [
107 "laben",
131 "laben",
108 "label_UNKNOWN_nb"
132 "label_UNKNOWN_nb"
109 ],
133 ],
@@ -116,10 +140,26
116 "buffers":
140 "buffers":
117 [
141 [
118 {
142 {
119 "file": "test_fft/test_fft_mini_lfr.py",
143 "file": "test_fft/test_sm_mini_lfr.py",
120 "settings":
144 "settings":
121 {
145 {
122 "buffer_size": 4505,
146 "buffer_size": 4053,
147 "line_ending": "Unix"
148 }
149 },
150 {
151 "file": "test_fft/fft_test_functions.py",
152 "settings":
153 {
154 "buffer_size": 3885,
155 "line_ending": "Unix"
156 }
157 },
158 {
159 "file": "test_fft/register_addresses_fft_test.py",
160 "settings":
161 {
162 "buffer_size": 798,
123 "line_ending": "Unix"
163 "line_ending": "Unix"
124 }
164 }
125 }
165 }
@@ -148,6 +188,7
148 },
188 },
149 "file_history":
189 "file_history":
150 [
190 [
191 "/opt/LFR_EMULATOR/test_fft/test_fft_mini_lfr.py",
151 "/opt/LFR_EMULATOR/test_fft/functions_evaluations.py",
192 "/opt/LFR_EMULATOR/test_fft/functions_evaluations.py",
152 "/opt/LFR_EMULATOR/SRC/processing_chain.py",
193 "/opt/LFR_EMULATOR/SRC/processing_chain.py",
153 "/opt/LFR_EMULATOR/main.py",
194 "/opt/LFR_EMULATOR/main.py",
@@ -225,18 +266,18
225 [
266 [
226 {
267 {
227 "buffer": 0,
268 "buffer": 0,
228 "file": "test_fft/test_fft_mini_lfr.py",
269 "file": "test_fft/test_sm_mini_lfr.py",
229 "settings":
270 "settings":
230 {
271 {
231 "buffer_size": 4505,
272 "buffer_size": 4053,
232 "regions":
273 "regions":
233 {
274 {
234 },
275 },
235 "selection":
276 "selection":
236 [
277 [
237 [
278 [
238 1524,
279 2731,
239 1524
280 2731
240 ]
281 ]
241 ],
282 ],
242 "settings":
283 "settings":
@@ -245,7 +286,60
245 "translate_tabs_to_spaces": false
286 "translate_tabs_to_spaces": false
246 },
287 },
247 "translation.x": 0.0,
288 "translation.x": 0.0,
248 "translation.y": 1998.0,
289 "translation.y": 1295.0,
290 "zoom_level": 1.0
291 },
292 "type": "text"
293 },
294 {
295 "buffer": 1,
296 "file": "test_fft/fft_test_functions.py",
297 "settings":
298 {
299 "buffer_size": 3885,
300 "regions":
301 {
302 },
303 "selection":
304 [
305 [
306 2140,
307 2140
308 ]
309 ],
310 "settings":
311 {
312 "syntax": "Packages/Python/Python.tmLanguage",
313 "translate_tabs_to_spaces": false
314 },
315 "translation.x": 0.0,
316 "translation.y": 1081.0,
317 "zoom_level": 1.0
318 },
319 "type": "text"
320 },
321 {
322 "buffer": 2,
323 "file": "test_fft/register_addresses_fft_test.py",
324 "settings":
325 {
326 "buffer_size": 798,
327 "regions":
328 {
329 },
330 "selection":
331 [
332 [
333 717,
334 717
335 ]
336 ],
337 "settings":
338 {
339 "syntax": "Packages/Python/Python.tmLanguage"
340 },
341 "translation.x": 0.0,
342 "translation.y": 0.0,
249 "zoom_level": 1.0
343 "zoom_level": 1.0
250 },
344 },
251 "type": "text"
345 "type": "text"
@@ -317,6 +411,6
317 "show_open_files": false,
411 "show_open_files": false,
318 "show_tabs": true,
412 "show_tabs": true,
319 "side_bar_visible": true,
413 "side_bar_visible": true,
320 "side_bar_width": 289.0,
414 "side_bar_width": 255.0,
321 "status_bar_visible": true
415 "status_bar_visible": true
322 }
416 }
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -21,7 +21,7 def continuous( bufferSize, value ):
21 return yVector
21 return yVector
22
22
23 def step( bufferSize, value ):
23 def step( bufferSize, value ):
24 tmpVector = np.empty( bufferSize )
24 tmpVector = np.zeros( bufferSize )
25 for k in range( bufferSize / 2 ):
25 for k in range( bufferSize / 2 ):
26 tmpVector[ bufferSize / 2 + k ] = value
26 tmpVector[ bufferSize / 2 + k ] = value
27 yVector = np.int16( tmpVector )
27 yVector = np.int16( tmpVector )
@@ -56,6 +56,65 def print_reg_fft( ):
56 + ", MEM_IN_SM_Empty = " + bin( MEM_IN_SM_Empty )
56 + ", MEM_IN_SM_Empty = " + bin( MEM_IN_SM_Empty )
57 RMAPPlugin0.ProcessPendingEvents()
57 RMAPPlugin0.ProcessPendingEvents()
58
58
59 def print_custom( value ):
60 print value
61 RMAPPlugin0.ProcessPendingEvents()
62
63 def is_MEM_IN_SM_Emty( ):
64 ret = 0
65 fft_reg = RMAPPlugin0.Read( address_CTRL, 1)
66 MEM_IN_SM_Empty = (fft_reg[0] & 0x01f00000) >> 20
67 if MEM_IN_SM_Empty == 0x1f:
68 ret = 1
69 return ret
70
71 def print_reg_sm( ):
72 sm_reg = RMAPPlugin0.Read( address_CTRL_SM, 1)
73 out_ren = (sm_reg[0] & 0x00000003)
74 MEM_OUT_SM_Full = (sm_reg[0] & 0x0000000c) >> 2
75 MEM_OUT_SM_Empty = (sm_reg[0] & 0x00000030) >> 4
76 print "sm_reg = " + bin( sm_reg[0] & 0x3f ) \
77 + ", out_ren = " + bin( out_ren ) \
78 + ", MEM_OUT_SM_Full = " + bin( MEM_OUT_SM_Full ) \
79 + ", MEM_OUT_SM_Empty = " + bin( MEM_OUT_SM_Empty )
80 RMAPPlugin0.ProcessPendingEvents()
81
82 def is_MEM_OUT_SM_Empty( ):
83 ret = 0
84 sm_reg = RMAPPlugin0.Read( address_CTRL_SM, 1)
85 MEM_OUT_SM_Empty = (sm_reg[0] & 0x00000030) >> 4
86 if MEM_OUT_SM_Empty == 0x3:
87 ret = 1
88 return ret
89
90 def is_MEM_OUT_SM_Full( ):
91 ret = 0
92 sm_reg = RMAPPlugin0.Read( address_CTRL_SM, 1)
93 MEM_OUT_SM_Full = (sm_reg[0] & 0x0000000c) >> 2
94 if MEM_OUT_SM_Full != 0x0:
95 ret = 1
96 return ret
97
98 def is_MEM_OUT_SM_Full_FIFO_0( ):
99 ret = 0
100 sm_reg = RMAPPlugin0.Read( address_CTRL_SM, 1)
101 MEM_OUT_SM_Full = (sm_reg[0] & 0x00000004) >> 3
102 if MEM_OUT_SM_Full == 0x01:
103 ret = 1
104 return ret
105
106 def is_MEM_OUT_SM_Full_FIFO_1( ):
107 ret = 0
108 sm_reg = RMAPPlugin0.Read( address_CTRL_SM, 1)
109 MEM_OUT_SM_Full = (sm_reg[0] & 0x00000008) >> 3
110 if MEM_OUT_SM_Full == 0x01:
111 ret = 1
112 return ret
113
114 def out_locked_AND_out_reuse_AND_out_ren( ):
115 # reuse => 0111 1111 1111 1111
116 RMAPPlugin0.Write( address_CTRL, [0x00007fff] )
117
59 def convertToSigned16Bits( dataToConvert ):
118 def convertToSigned16Bits( dataToConvert ):
60 dataInInt16 = np.int16( dataToConvert )
119 dataInInt16 = np.int16( dataToConvert )
61 if dataInInt16 < 32768:
120 if dataInInt16 < 32768:
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -22,6 +22,11 address_MEM_IN_SM_4 = 0x80000f40
22
22
23 address_CTRL = 0x80000f44
23 address_CTRL = 0x80000f44
24
24
25 address_MEM_OUT_SM_0= 0x80000f30
26 address_MEM_OUT_SM_1= 0x80000f34
27
28 address_CTRL_SM = 0x80000f38
29
25 #
30 #
26 columnV = 1
31 columnV = 1
27 columnE1 = 2
32 columnE1 = 2
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -7,22 +7,23 import matplotlib.pyplot as plt
7 from test_fft.register_addresses_fft_test import *
7 from test_fft.register_addresses_fft_test import *
8 from test_fft.fft_test_functions import *
8 from test_fft.fft_test_functions import *
9
9
10 print '*'
10 print_custom( '*' )
11 print '*'
11 print_custom( '*' )
12 print '*'
12 print_custom( '*' )
13 print '*'
13 print_custom( '*' )
14 print '*'
14 print_custom( '*' )
15
15
16 ######################
16 ######################
17 # GET DATA FROM RECORD
17 # GET DATA FROM RECORD
18 storageDirectory = '/home/paul/data/2014_06_24/'
18 #storageDirectory = '/home/paul/data/2014_06_24/'
19 day = '2014_6_24-'
19 #day = '2014_6_24-'
20 hour = '9_0_3'
20 #hour = '9_0_3'
21 suffix = '.data'
21 #suffix = '.data'
22
22
23 typeOfData = '_SBM1_CWF_'
23 #typeOfData = '_SBM1_CWF_'
24 cwf_f1 = np.genfromtxt( storageDirectory + day + hour + typeOfData + 'F1' + suffix,
24 #cwf_f1 = np.genfromtxt( storageDirectory + day + hour + typeOfData + 'F1' + suffix,
25 skip_header = 1)
25 # skip_header = 1)
26 cwf_f1 = np.zeros( 1000 )
26
27
27 #################
28 #################
28 # BUILD WAVEFORMS
29 # BUILD WAVEFORMS
@@ -35,8 +36,8 nbSamples = 256
35 wfrm0 = sineWave( 256, 10, 1000 )
36 wfrm0 = sineWave( 256, 10, 1000 )
36 wfrm1 = dirac( 256, 1000 )
37 wfrm1 = dirac( 256, 1000 )
37 wfrm2 = step( 256, 1000 )
38 wfrm2 = step( 256, 1000 )
38 wfrm3 = np.zeros( 256 )
39 wfrm3 = continuous( 256, 100 )
39 wfrm4 = np.zeros( 256 )
40 wfrm4 = continuous( 256, 1000 )
40
41
41 ################
42 ################
42 # BUILD THE DATA
43 # BUILD THE DATA
@@ -44,11 +45,11 dataToWrite0 = generateDataToWrite( nbSa
44 dataToWrite1 = generateDataToWrite( nbSamples, wfrm2, wfrm3 )
45 dataToWrite1 = generateDataToWrite( nbSamples, wfrm2, wfrm3 )
45 dataToWrite2 = generateDataToWrite( nbSamples, wfrm4, np.zeros( nbSamples ) )
46 dataToWrite2 = generateDataToWrite( nbSamples, wfrm4, np.zeros( nbSamples ) )
46
47
48 ########################
49 # WRITE WAVEFORM IN FIFO
50 print_custom( "1) write waveforms in FIFOs: " + str(len(dataToWrite0)) + " samples" )
47 print_reg_fft( )
51 print_reg_fft( )
48
52
49 # WRITE WAVEFORM IN FIFO
50 print "write waveforms in FIFOs: " + str(len(dataToWrite0)) + " samples"
51
52 for k in range(nbSamples):
53 for k in range(nbSamples):
53 RMAPPlugin0.Write( address_FIFO_F2_1_0, [dataToWrite0[k]] )
54 RMAPPlugin0.Write( address_FIFO_F2_1_0, [dataToWrite0[k]] )
54 RMAPPlugin0.Write( address_FIFO_F2_3_2, [dataToWrite1[k]] )
55 RMAPPlugin0.Write( address_FIFO_F2_3_2, [dataToWrite1[k]] )
@@ -56,7 +57,7 for k in range(nbSamples):
56 # write only the FIFO F2
57 # write only the FIFO F2
57 RMAPPlugin0.Write( address_FIFO_F2_WEN, [0xffffffe0] )
58 RMAPPlugin0.Write( address_FIFO_F2_WEN, [0xffffffe0] )
58
59
59 print "data written in FIFOs"
60 print_custom( "1) data written in FIFOs" )
60
61
61 print_reg_fft( )
62 print_reg_fft( )
62
63
@@ -66,13 +67,14 RMAPPlugin0.Write( address_CTRL, [0x0000
66 # wait for SM_Full
67 # wait for SM_Full
67 fft_reg = RMAPPlugin0.Read( address_CTRL, 1)
68 fft_reg = RMAPPlugin0.Read( address_CTRL, 1)
68 while (fft_reg[0] & 0x000f8000) == 0:
69 while (fft_reg[0] & 0x000f8000) == 0:
69 print "SM not full"
70 print_custom( "SM not full" )
70 fft_reg = RMAPPlugin0.Read( address_CTRL, 1)
71 fft_reg = RMAPPlugin0.Read( address_CTRL, 1)
71
72
72 print_reg_fft( )
73 print_reg_fft( )
73
74
74 # READ FFT
75 ################
75 print "read data in fft FIFOs"
76 # FFT FIRST READ
77 print_custom( "======= FIRST READ" )
76 fft0_re = np.zeros( nbSamples )
78 fft0_re = np.zeros( nbSamples )
77 fft0_im = np.zeros( nbSamples )
79 fft0_im = np.zeros( nbSamples )
78 fft1_re = np.zeros( nbSamples )
80 fft1_re = np.zeros( nbSamples )
@@ -85,6 +87,8 fft4_re = np.zeros( nbSamples )
85 fft4_im = np.zeros( nbSamples )
87 fft4_im = np.zeros( nbSamples )
86
88
87 for k in range(128):
89 for k in range(128):
90 # read enable => 0111 1100 0000 0000
91 RMAPPlugin0.Write( address_CTRL, [0x00007c00] )
88 val = RMAPPlugin0.Read( address_MEM_IN_SM_0, 1)
92 val = RMAPPlugin0.Read( address_MEM_IN_SM_0, 1)
89 fft0_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff )
93 fft0_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff )
90 fft0_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) )
94 fft0_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) )
@@ -100,8 +104,8 for k in range(128):
100 val = RMAPPlugin0.Read( address_MEM_IN_SM_4, 1)
104 val = RMAPPlugin0.Read( address_MEM_IN_SM_4, 1)
101 fft4_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff )
105 fft4_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff )
102 fft4_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) )
106 fft4_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) )
103 # read enable => 0111 1100 0000 0000
107 if is_MEM_IN_SM_Emty( ) == 1:
104 RMAPPlugin0.Write( address_CTRL, [0x00007c00] )
108 print_custom( "k = " + str( k ) )
105
109
106 fft0 = fft0_re * fft0_re + fft0_im * fft0_im
110 fft0 = fft0_re * fft0_re + fft0_im * fft0_im
107 fft1 = fft1_re * fft1_re + fft1_im * fft1_im
111 fft1 = fft1_re * fft1_re + fft1_im * fft1_im
@@ -109,7 +113,52 fft2 = fft2_re * fft2_re + fft2_im * fft
109 fft3 = fft3_re * fft3_re + fft3_im * fft3_im
113 fft3 = fft3_re * fft3_re + fft3_im * fft3_im
110 fft4 = fft4_re * fft4_re + fft4_im * fft4_im
114 fft4 = fft4_re * fft4_re + fft4_im * fft4_im
111
115
112 print "data read in fft FIFOs"
116 #######
117 # REUSE
118 print_custom( "======= REUSE" )
119 out_locked_AND_out_reuse_AND_out_ren()
120 print_reg_fft( )
121
122 print_custom( "read data in fft FIFOs" )
123 fft0_re = np.zeros( nbSamples )
124 fft0_im = np.zeros( nbSamples )
125 fft1_re = np.zeros( nbSamples )
126 fft1_im = np.zeros( nbSamples )
127 fft2_re = np.zeros( nbSamples )
128 fft2_im = np.zeros( nbSamples )
129 fft3_re = np.zeros( nbSamples )
130 fft3_im = np.zeros( nbSamples )
131 fft4_re = np.zeros( nbSamples )
132 fft4_im = np.zeros( nbSamples )
133
134 for k in range(128):
135 # read enable => 0111 1100 0000 0000
136 val = RMAPPlugin0.Read( address_MEM_IN_SM_0, 1)
137 fft0_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff )
138 fft0_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) )
139 val = RMAPPlugin0.Read( address_MEM_IN_SM_1, 1)
140 fft1_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff )
141 fft1_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) )
142 val = RMAPPlugin0.Read( address_MEM_IN_SM_2, 1)
143 fft2_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff )
144 fft2_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) )
145 val = RMAPPlugin0.Read( address_MEM_IN_SM_3, 1)
146 fft3_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff )
147 fft3_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) )
148 val = RMAPPlugin0.Read( address_MEM_IN_SM_4, 1)
149 fft4_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff )
150 fft4_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) )
151 RMAPPlugin0.Write( address_CTRL, [0x00007c00] )
152 if is_MEM_IN_SM_Emty( ) == 1:
153 print_custom( "k = " + str( k ) )
154
155 fft0_b = fft0_re * fft0_re + fft0_im * fft0_im
156 fft1_b = fft1_re * fft1_re + fft1_im * fft1_im
157 fft2_b = fft2_re * fft2_re + fft2_im * fft2_im
158 fft3_b = fft3_re * fft3_re + fft3_im * fft3_im
159 fft4_b = fft4_re * fft4_re + fft4_im * fft4_im
160
161 print_custom( "data read in fft FIFOs" )
113
162
114 print_reg_fft( )
163 print_reg_fft( )
115
164
@@ -168,5 +217,16 plt.plot(fft3[0:255], 'c')
168 plt.subplot(235)
217 plt.subplot(235)
169 plt.plot(fft4[0:255], 'm')
218 plt.plot(fft4[0:255], 'm')
170
219
220 plt.figure( 4 )
221 plt.subplot(231)
222 plt.plot(fft0_b[0:255], 'b')
223 plt.subplot(232)
224 plt.plot(fft1_b[0:255], 'g')
225 plt.subplot(233)
226 plt.plot(fft2_b[0:255], 'r')
227 plt.subplot(234)
228 plt.plot(fft3_b[0:255], 'c')
229 plt.subplot(235)
230 plt.plot(fft4_b[0:255], 'm')
171
231
172 plt.show() No newline at end of file
232 plt.show()
General Comments 0
You need to be logged in to leave comments. Login now