@@ -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 |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 |
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -0,0 +1,62 | |||||
|
1 | import numpy as np | |||
|
2 | ||||
|
3 | def getWaveFromRecord( cwf, bufferSize, offset, column ): | |||
|
4 | yVector = cwf[(0+offset):(bufferSize+offset), column] | |||
|
5 | return yVector | |||
|
6 | ||||
|
7 | def sineWave( bufferSize, nbPeriod, amplitude): | |||
|
8 | deltaX = nbPeriod * 2 * np.pi / bufferSize | |||
|
9 | xVector = np.arange( bufferSize ) * deltaX | |||
|
10 | yVector = np.int16( amplitude * np.sin( xVector ) ) | |||
|
11 | return yVector | |||
|
12 | ||||
|
13 | def continuous( bufferSize, value ): | |||
|
14 | tmpVector = np.empty( bufferSize ) | |||
|
15 | tmpVector.fill( value ) | |||
|
16 | yVector = np.int16( tmpVector ) | |||
|
17 | return yVector | |||
|
18 | ||||
|
19 | def step( bufferSize, value ): | |||
|
20 | tmpVector = np.zeros( bufferSize ) | |||
|
21 | for k in range( bufferSize / 2 ): | |||
|
22 | tmpVector[ bufferSize / 2 + k ] = value | |||
|
23 | yVector = np.int16( tmpVector ) | |||
|
24 | return yVector | |||
|
25 | ||||
|
26 | def dirac( bufferSize, value, position=0 ): | |||
|
27 | tmpVector = np.zeros( bufferSize ) | |||
|
28 | if position < bufferSize: | |||
|
29 | tmpVector[position] = value | |||
|
30 | yVector = np.int16( tmpVector ) | |||
|
31 | return yVector | |||
|
32 | ||||
|
33 | def generateDataToWrite( bufferSize, wfrm0, wfrm1 ): | |||
|
34 | dataVector = [] | |||
|
35 | for k in range(bufferSize): | |||
|
36 | dataVector.append( | |||
|
37 | ( (np.int16(wfrm1[k]) & 0xffff ) << 16) | |||
|
38 | | (np.int16(wfrm0[k]) & 0xffff ) | |||
|
39 | ) | |||
|
40 | return dataVector | |||
|
41 | ||||
|
42 | def convertToSigned16Bits( dataToConvert ): | |||
|
43 | dataInInt16 = np.int16( dataToConvert ) | |||
|
44 | if dataInInt16 < 32768: | |||
|
45 | val = dataInInt16 | |||
|
46 | else: | |||
|
47 | val = dataInInt16 - 65536 | |||
|
48 | return val | |||
|
49 | ||||
|
50 | def convertVectorToSigned16Bits( bufferSize, dataBuffer ): | |||
|
51 | dataBufferConverted = np.zeros( bufferSize ) | |||
|
52 | for k in range( bufferSize ): | |||
|
53 | dataBufferConverted[k] = convertToSigned16Bits( dataBuffer[k] ) | |||
|
54 | return dataBufferConverted | |||
|
55 | ||||
|
56 | def convertToSigned8Bits( dataToConvert ): | |||
|
57 | dataInInt16 = np.int8( dataToConvert ) | |||
|
58 | if dataInInt16 < 8: | |||
|
59 | val = dataInInt16 | |||
|
60 | else: | |||
|
61 | val = dataInInt16 - 16 | |||
|
62 | return val |
@@ -0,0 +1,13 | |||||
|
1 | import numpy as np | |||
|
2 | import matplotlib.pyplot as plt | |||
|
3 | ||||
|
4 | def sineWave( bufferSize, nbPeriod): | |||
|
5 | deltaX = nbPeriod * 2 * np.pi / bufferSize | |||
|
6 | xVector = np.arange( bufferSize ) * deltaX | |||
|
7 | yVector = np.sin( xVector ) | |||
|
8 | return yVector | |||
|
9 | ||||
|
10 | if __name__ == '__main__': | |||
|
11 | waveform = sineWave( 256, 3 ) | |||
|
12 | plt.plot(waveform) | |||
|
13 | plt.show() |
@@ -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,56 | |||||
|
1 | from __main__ import RMAPPlugin0 | |||
|
2 | ||||
|
3 | def print_custom( value ): | |||
|
4 | print value | |||
|
5 | RMAPPlugin0.ProcessPendingEvents() | |||
|
6 | ||||
|
7 | def print_reg_fft( address ): | |||
|
8 | fft_reg = RMAPPlugin0.Read( address, 1) | |||
|
9 | out_ren = (fft_reg[0] & 0x0000001f) | |||
|
10 | out_reuse = (fft_reg[0] & 0x000003e0) >> 5 | |||
|
11 | out_locked = (fft_reg[0] & 0x00007c00) >> 10 | |||
|
12 | MEM_IN_SM_Full = (fft_reg[0] & 0x000f8000) >> 15 | |||
|
13 | MEM_IN_SM_Empty = (fft_reg[0] & 0x01f00000) >> 20 | |||
|
14 | print "out_ren = " + bin( out_ren ) \ | |||
|
15 | + ", out_reuse = " + bin( out_reuse ) \ | |||
|
16 | + ", out_locked = " + bin( out_locked ) \ | |||
|
17 | + ", MEM_IN_SM_Full = " + bin( MEM_IN_SM_Full ) \ | |||
|
18 | + ", MEM_IN_SM_Empty = " + bin( MEM_IN_SM_Empty ) | |||
|
19 | RMAPPlugin0.ProcessPendingEvents() | |||
|
20 | ||||
|
21 | def print_reg_sm( address ): | |||
|
22 | sm_reg = RMAPPlugin0.Read( address, 1) | |||
|
23 | out_ren = (sm_reg[0] & 0x00000003) | |||
|
24 | MEM_OUT_SM_Full = (sm_reg[0] & 0x0000000c) >> 2 | |||
|
25 | MEM_OUT_SM_Empty = (sm_reg[0] & 0x00000030) >> 4 | |||
|
26 | MEM_OUT_SM_Full_s= (sm_reg[0] & 0x00000040) >> 6 | |||
|
27 | print "sm_reg = " + bin( sm_reg[0] & 0x7f ) \ | |||
|
28 | + ", MEM_OUT_SM_Full_s = " + bin( MEM_OUT_SM_Full_s ) \ | |||
|
29 | + ", MEM_OUT_SM_Empty = " + bin( MEM_OUT_SM_Empty ) \ | |||
|
30 | + ", MEM_OUT_SM_Full = " + bin( MEM_OUT_SM_Full ) \ | |||
|
31 | + ", out_ren = " + bin( out_ren ) | |||
|
32 | RMAPPlugin0.ProcessPendingEvents() | |||
|
33 | ||||
|
34 | def print_reg_sm_only_MEM_IN_CTRL( address ): | |||
|
35 | sm_reg = RMAPPlugin0.Read( address, 1) | |||
|
36 | out_wen = (sm_reg[0] & 0x0000001f) | |||
|
37 | MEM_IN_SM_Full = (sm_reg[0] & 0x000003e0) >> 5 | |||
|
38 | MEM_IN_SM_Empty = (sm_reg[0] & 0x00007c00) >> 10 | |||
|
39 | MEM_IN_SM_Locked = (sm_reg[0] & 0x000f8000) >> 15 | |||
|
40 | print "MEM_IN_SM = " + bin( sm_reg[0] & 0xfffff ) \ | |||
|
41 | + ", Locked = " + bin( MEM_IN_SM_Locked ) \ | |||
|
42 | + ", Empty = " + bin( MEM_IN_SM_Empty ) \ | |||
|
43 | + ", Full = " + bin( MEM_IN_SM_Full ) \ | |||
|
44 | + ", wen = " + bin( out_wen ) | |||
|
45 | RMAPPlugin0.ProcessPendingEvents() | |||
|
46 | ||||
|
47 | def print_reg_sm_only_MEM_OUT_CTRL( address ): | |||
|
48 | sm_reg = RMAPPlugin0.Read( address, 1) | |||
|
49 | MEM_IN_SM_Empty = (sm_reg[0] & 0x00000030) >> 4 | |||
|
50 | MEM_IN_SM_Full = (sm_reg[0] & 0x0000000c) >> 2 | |||
|
51 | out_ren = (sm_reg[0] & 0x00000003) | |||
|
52 | print "MEM_OUT_SM = " + bin( sm_reg[0] & 0x3f ) \ | |||
|
53 | + ", Empty = " + bin( MEM_IN_SM_Empty ) \ | |||
|
54 | + ", Full = " + bin( MEM_IN_SM_Full ) \ | |||
|
55 | + ", ren = " + bin( out_ren ) | |||
|
56 | RMAPPlugin0.ProcessPendingEvents() |
@@ -0,0 +1,80 | |||||
|
1 | import numpy as np | |||
|
2 | ||||
|
3 | from __main__ import RMAPPlugin0 | |||
|
4 | ||||
|
5 | from test_fft.register_addresses import * | |||
|
6 | import test_fft.print_custom as prnt | |||
|
7 | ||||
|
8 | def read_SM_Re( nbFrequencyBins, address_MEM_OUT_SM ): | |||
|
9 | currentComp_re = np.zeros( nbFrequencyBins ) | |||
|
10 | if address_MEM_OUT_SM == FFT_SM_MEM_OUT_SM_0: | |||
|
11 | mask_REN = mask_REN_FIFO_0 | |||
|
12 | elif address_MEM_OUT_SM == FFT_SM_MEM_OUT_SM_1: | |||
|
13 | mask_REN = mask_REN_FIFO_1 | |||
|
14 | else: | |||
|
15 | prnt.print_custom( "ERR *** read_SM_Re *** unexpected address_MEM_OUT_SM" ) | |||
|
16 | for frequencyBin in range(nbFrequencyBins): | |||
|
17 | # read Re | |||
|
18 | RMAPPlugin0.Write( FFT_SM_MEM_OUT_SM_CTRL, [mask_REN] ) | |||
|
19 | val = RMAPPlugin0.Read( address_MEM_OUT_SM, 1) | |||
|
20 | currentComp_re[frequencyBin] = val[0] | |||
|
21 | RMAPPlugin0.ProcessPendingEvents() | |||
|
22 | return currentComp_re | |||
|
23 | ||||
|
24 | def read_SM_Re_Im( nbFrequencyBins, address_MEM_OUT_SM ): | |||
|
25 | currentComp_re = np.zeros( nbFrequencyBins ) | |||
|
26 | currentComp_im = np.zeros( nbFrequencyBins ) | |||
|
27 | if address_MEM_OUT_SM == FFT_SM_MEM_OUT_SM_0: | |||
|
28 | mask_REN = mask_REN_FIFO_0 | |||
|
29 | elif address_MEM_OUT_SM == FFT_SM_MEM_OUT_SM_1: | |||
|
30 | mask_REN = mask_REN_FIFO_1 | |||
|
31 | else: | |||
|
32 | prnt.print_custom( "ERR *** read_SM_Re_Im *** unexpected address_MEM_OUT_SM" ) | |||
|
33 | for frequencyBin in range(nbFrequencyBins): | |||
|
34 | # read Re | |||
|
35 | RMAPPlugin0.Write( FFT_SM_MEM_OUT_SM_CTRL, [mask_REN] ) | |||
|
36 | val = RMAPPlugin0.Read( address_MEM_OUT_SM, 1) | |||
|
37 | currentComp_re[frequencyBin] = val[0] | |||
|
38 | # read Im | |||
|
39 | RMAPPlugin0.Write( FFT_SM_MEM_OUT_SM_CTRL, [mask_REN] ) | |||
|
40 | val = RMAPPlugin0.Read( address_MEM_OUT_SM, 1) | |||
|
41 | currentComp_im[frequencyBin] = val[0] | |||
|
42 | RMAPPlugin0.ProcessPendingEvents() | |||
|
43 | return (currentComp_re, currentComp_im) | |||
|
44 | ||||
|
45 | def read_SM_ONLY_Re( nbFrequencyBins, address_MEM_OUT_SM ): | |||
|
46 | currentComp_re = np.zeros( nbFrequencyBins ) | |||
|
47 | if address_MEM_OUT_SM == SM_ONLY_MEM_OUT_SM_0: | |||
|
48 | mask_REN = mask_REN_FIFO_0 | |||
|
49 | elif address_MEM_OUT_SM == SM_ONLY_MEM_OUT_SM_1: | |||
|
50 | mask_REN = mask_REN_FIFO_1 | |||
|
51 | else: | |||
|
52 | prnt.print_custom( "ERR *** read_SM_ONLY_Re *** unexpected address_MEM_OUT_SM" ) | |||
|
53 | for frequencyBin in range(nbFrequencyBins): | |||
|
54 | # read Re | |||
|
55 | RMAPPlugin0.Write( SM_ONLY_MEM_OUT_CTRL, [mask_REN] ) | |||
|
56 | val = RMAPPlugin0.Read( address_MEM_OUT_SM, 1) | |||
|
57 | currentComp_re[frequencyBin] = val[0] | |||
|
58 | RMAPPlugin0.ProcessPendingEvents() | |||
|
59 | return currentComp_re | |||
|
60 | ||||
|
61 | def read_SM_ONLY_Re_Im( nbFrequencyBins, address_MEM_OUT_SM ): | |||
|
62 | currentComp_re = np.zeros( nbFrequencyBins ) | |||
|
63 | currentComp_im = np.zeros( nbFrequencyBins ) | |||
|
64 | if address_MEM_OUT_SM == SM_ONLY_MEM_OUT_SM_0: | |||
|
65 | mask_REN = mask_REN_FIFO_0 | |||
|
66 | elif address_MEM_OUT_SM == SM_ONLY_MEM_OUT_SM_1: | |||
|
67 | mask_REN = mask_REN_FIFO_1 | |||
|
68 | else: | |||
|
69 | prnt.print_custom( "ERR *** read_SM_ONLY_Re_Im *** unexpected address_MEM_OUT_SM" ) | |||
|
70 | for frequencyBin in range(nbFrequencyBins): | |||
|
71 | # read Re | |||
|
72 | RMAPPlugin0.Write( SM_ONLY_MEM_OUT_CTRL, [mask_REN] ) | |||
|
73 | val = RMAPPlugin0.Read( address_MEM_OUT_SM, 1) | |||
|
74 | currentComp_re[frequencyBin] = val[0] | |||
|
75 | # read Im | |||
|
76 | RMAPPlugin0.Write( SM_ONLY_MEM_OUT_CTRL, [mask_REN] ) | |||
|
77 | val = RMAPPlugin0.Read( address_MEM_OUT_SM, 1) | |||
|
78 | currentComp_im[frequencyBin] = val[0] | |||
|
79 | RMAPPlugin0.ProcessPendingEvents() | |||
|
80 | return (currentComp_re, currentComp_im) |
@@ -0,0 +1,90 | |||||
|
1 | import numpy as np | |||
|
2 | ||||
|
3 | from __main__ import RMAPPlugin0 | |||
|
4 | ||||
|
5 | from test_fft.register_addresses import * | |||
|
6 | import test_fft.print_custom as prnt | |||
|
7 | ||||
|
8 | def is_MEM_IN_SM_Emty( address ): | |||
|
9 | ret = 0 | |||
|
10 | fft_reg = RMAPPlugin0.Read( address, 1) | |||
|
11 | MEM_IN_SM_Empty = (fft_reg[0] & 0x01f00000) >> 20 | |||
|
12 | if MEM_IN_SM_Empty == 0x1f: | |||
|
13 | ret = 1 | |||
|
14 | return ret | |||
|
15 | ||||
|
16 | def out_locked_AND_out_reuse_AND_out_ren( address ): | |||
|
17 | # reuse => 0111 1111 1111 1111 | |||
|
18 | RMAPPlugin0.Write( address, [0x00007fff] ) | |||
|
19 | ||||
|
20 | #================================== | |||
|
21 | #================================== | |||
|
22 | ||||
|
23 | def is_MEM_OUT_SM_Empty( address ): | |||
|
24 | ret = 0 | |||
|
25 | sm_reg = RMAPPlugin0.Read( address, 1) | |||
|
26 | MEM_OUT_SM_Empty = (sm_reg[0] & 0x00000030) >> 4 | |||
|
27 | if MEM_OUT_SM_Empty == 0x3: | |||
|
28 | ret = 1 | |||
|
29 | return ret | |||
|
30 | ||||
|
31 | def is_MEM_OUT_SM_Full( address ): | |||
|
32 | ret = 0 | |||
|
33 | sm_reg = RMAPPlugin0.Read( address, 1) | |||
|
34 | MEM_OUT_SM_Full = (sm_reg[0] & 0x0000000c) >> 2 | |||
|
35 | if MEM_OUT_SM_Full != 0x0: | |||
|
36 | ret = 1 | |||
|
37 | return ret | |||
|
38 | ||||
|
39 | def is_MEM_OUT_SM_Full_FIFO_0( address ): | |||
|
40 | ret = 0 | |||
|
41 | sm_reg = RMAPPlugin0.Read( address, 1) | |||
|
42 | MEM_OUT_SM_Full = (sm_reg[0] & 0x00000004) >> 2 | |||
|
43 | if MEM_OUT_SM_Full == 0x01: | |||
|
44 | ret = 1 | |||
|
45 | return ret | |||
|
46 | ||||
|
47 | def is_MEM_OUT_SM_Full_FIFO_1( address ): | |||
|
48 | ret = 0 | |||
|
49 | sm_reg = RMAPPlugin0.Read( address, 1) | |||
|
50 | MEM_OUT_SM_Full = (sm_reg[0] & 0x00000008) >> 3 | |||
|
51 | if MEM_OUT_SM_Full == 0x01: | |||
|
52 | ret = 1 | |||
|
53 | return ret | |||
|
54 | ||||
|
55 | def wait_for_FIFO_0_Full( address ): | |||
|
56 | counter = 0 | |||
|
57 | while ( is_MEM_OUT_SM_Full_FIFO_0( address ) == 0 ): | |||
|
58 | prnt.print_custom( "FIFO_0 not full " + str(counter) ) | |||
|
59 | counter = counter + 1 | |||
|
60 | if counter == 10: | |||
|
61 | break | |||
|
62 | ||||
|
63 | def wait_for_FIFO_1_Full( address ): | |||
|
64 | counter = 0 | |||
|
65 | while ( is_MEM_OUT_SM_Full_FIFO_1( address ) == 0 ): | |||
|
66 | prnt.print_custom( "FIFO_1 not full " + str(counter)) | |||
|
67 | counter = counter + 1 | |||
|
68 | if counter == 10: | |||
|
69 | break | |||
|
70 | ||||
|
71 | def wait_for_FIFO_Full( fifo, address ): | |||
|
72 | if fifo == 0: | |||
|
73 | wait_for_FIFO_0_Full( address ) | |||
|
74 | elif fifo == 1: | |||
|
75 | wait_for_FIFO_1_Full( address ) | |||
|
76 | else: | |||
|
77 | prnt.print_custom( "ERR *** wait_for_FIFO_Full *** unexpted value for parameter [fifo]" ) | |||
|
78 | ||||
|
79 | def wait_for_FIFO_0_or_1_Full( address ): | |||
|
80 | counter = 0 | |||
|
81 | sm_reg = RMAPPlugin0.Read( address, 1) | |||
|
82 | MEM_OUT_SM_Full = (sm_reg[0] & 0x0000000c) >> 2 | |||
|
83 | while ( MEM_OUT_SM_Full == 0 ): | |||
|
84 | prnt.print_custom( "FIFO 0 or 1 not full " + str(counter)) | |||
|
85 | counter = counter + 1 | |||
|
86 | if counter == 10: | |||
|
87 | break | |||
|
88 | sm_reg = RMAPPlugin0.Read( address, 1) | |||
|
89 | MEM_OUT_SM_Full = (sm_reg[0] & 0x0000000c) >> 2 | |||
|
90 | RMAPPlugin0.ProcessPendingEvents() |
@@ -0,0 +1,58 | |||||
|
1 | #============================ | |||
|
2 | # ADRESSES FOR THE FFT MODULE | |||
|
3 | # FIFO F0 | |||
|
4 | FFT_FIFO_F0_1_0 = 0x80000f00 | |||
|
5 | FFT_FIFO_F0_3_2 = 0x80000f04 | |||
|
6 | FFT_FIFO_F0_4 = 0x80000f08 | |||
|
7 | FFT_FIFO_F0_WEN = 0x80000f0c | |||
|
8 | # FIFO F1 | |||
|
9 | FFT_FIFO_F1_1_0 = 0x80000f10 | |||
|
10 | FFT_FIFO_F1_3_2 = 0x80000f14 | |||
|
11 | FFT_FIFO_F1_4 = 0x80000f18 | |||
|
12 | FFT_FIFO_F1_WEN = 0x80000f1c | |||
|
13 | # FIFO F2 | |||
|
14 | FFT_FIFO_F2_1_0 = 0x80000f20 | |||
|
15 | FFT_FIFO_F2_3_2 = 0x80000f24 | |||
|
16 | FFT_FIFO_F2_4 = 0x80000f28 | |||
|
17 | FFT_FIFO_F2_WEN = 0x80000f2c | |||
|
18 | ||||
|
19 | FFT_MEM_IN_SM_0 = 0x80000f30 | |||
|
20 | FFT_MEM_IN_SM_1 = 0x80000f34 | |||
|
21 | FFT_MEM_IN_SM_2 = 0x80000f38 | |||
|
22 | FFT_MEM_IN_SM_3 = 0x80000f3c | |||
|
23 | FFT_MEM_IN_SM_4 = 0x80000f40 | |||
|
24 | ||||
|
25 | FFT_CTRL = 0x80000f44 | |||
|
26 | ||||
|
27 | #================================ | |||
|
28 | # ADDRESSES FOR THE FFT_SM DESIGN | |||
|
29 | FFT_SM_MEM_OUT_SM_0 = 0x80000f30 | |||
|
30 | FFT_SM_MEM_OUT_SM_1 = 0x80000f34 | |||
|
31 | FFT_SM_MEM_OUT_SM_CTRL = 0x80000f38 | |||
|
32 | ||||
|
33 | #================================= | |||
|
34 | # ADDRESSES FOR THE SM_ONLY DESIGN | |||
|
35 | SM_ONLY_MEM_IN_SM_0 = 0x80000f00 | |||
|
36 | SM_ONLY_MEM_IN_SM_1 = 0x80000f04 | |||
|
37 | SM_ONLY_MEM_IN_SM_2 = 0x80000f08 | |||
|
38 | SM_ONLY_MEM_IN_SM_3 = 0x80000f0c | |||
|
39 | SM_ONLY_MEM_IN_SM_4 = 0x80000f10 | |||
|
40 | ||||
|
41 | SM_ONLY_MEM_IN_SM_CTRL = 0x80000f14 | |||
|
42 | ||||
|
43 | SM_ONLY_MEM_OUT_SM_0 = 0x80000f18 | |||
|
44 | SM_ONLY_MEM_OUT_SM_1 = 0x80000f1c | |||
|
45 | ||||
|
46 | SM_ONLY_MEM_OUT_CTRL = 0x80000f20 | |||
|
47 | ||||
|
48 | #====================== | |||
|
49 | # GENERAL USE CONSTANTS | |||
|
50 | mask_REN_FIFO_0 = 0xfffffffe # 1110 | |||
|
51 | mask_REN_FIFO_1 = 0xfffffffd # 1101 | |||
|
52 | # | |||
|
53 | columnV = 1 | |||
|
54 | columnE1 = 2 | |||
|
55 | columnE2 = 3 | |||
|
56 | columnB1 = 4 | |||
|
57 | columnB2 = 5 | |||
|
58 | columnB3 = 6 No newline at end of file |
@@ -0,0 +1,241 | |||||
|
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 import * | |||
|
8 | ||||
|
9 | import test_fft.read_flags as flg | |||
|
10 | import test_fft.data_generator as dtgn | |||
|
11 | import test_fft.print_custom as prnt | |||
|
12 | import test_fft.read_data as rdata | |||
|
13 | ||||
|
14 | prnt.print_custom( '*' ) | |||
|
15 | prnt.print_custom( '*' ) | |||
|
16 | prnt.print_custom( '*' ) | |||
|
17 | prnt.print_custom( '*' ) | |||
|
18 | prnt.print_custom( '*' ) | |||
|
19 | ||||
|
20 | ###################### | |||
|
21 | # GET DATA FROM RECORD | |||
|
22 | #storageDirectory = '/home/paul/data/2014_06_24/' | |||
|
23 | #day = '2014_6_24-' | |||
|
24 | #hour = '9_0_3' | |||
|
25 | #suffix = '.data' | |||
|
26 | ||||
|
27 | #typeOfData = '_SBM1_CWF_' | |||
|
28 | #cwf_f1 = np.genfromtxt( storageDirectory + day + hour + typeOfData + 'F1' + suffix, | |||
|
29 | # skip_header = 1) | |||
|
30 | cwf_f1 = np.zeros( 1000 ) | |||
|
31 | ||||
|
32 | ################# | |||
|
33 | # BUILD WAVEFORMS | |||
|
34 | nbSamples = 256 | |||
|
35 | #wfrm0 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnV ) | |||
|
36 | #wfrm1 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnE1 ) | |||
|
37 | #wfrm2 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnE2 ) | |||
|
38 | #wfrm3 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnB1 ) | |||
|
39 | #wfrm4 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnB2 ) | |||
|
40 | wfrm0 = dtgn.sineWave( nbSamples, 10, 1000 ) | |||
|
41 | wfrm1 = dtgn.dirac( nbSamples, 1000 ) | |||
|
42 | wfrm2 = dtgn.step( nbSamples, 1000 ) | |||
|
43 | wfrm3 = dtgn.continuous( nbSamples, 100 ) | |||
|
44 | wfrm4 = dtgn.continuous( nbSamples, 1000 ) | |||
|
45 | ||||
|
46 | ################ | |||
|
47 | # BUILD THE DATA | |||
|
48 | dataToWrite0 = dtgn.generateDataToWrite( nbSamples, wfrm0, wfrm1 ) | |||
|
49 | dataToWrite1 = dtgn.generateDataToWrite( nbSamples, wfrm2, wfrm3 ) | |||
|
50 | dataToWrite2 = dtgn.generateDataToWrite( nbSamples, wfrm4, np.zeros( nbSamples ) ) | |||
|
51 | ||||
|
52 | ######################## | |||
|
53 | # WRITE WAVEFORM IN FIFO | |||
|
54 | prnt.print_reg_fft( FFT_CTRL ) | |||
|
55 | ||||
|
56 | prnt.print_custom( "1) write waveforms in FIFOs: " + str(len(dataToWrite0)) + " samples" ) | |||
|
57 | ||||
|
58 | for k in range(nbSamples): | |||
|
59 | RMAPPlugin0.Write( FFT_FIFO_F2_1_0, [dataToWrite0[k]] ) | |||
|
60 | RMAPPlugin0.Write( FFT_FIFO_F2_3_2, [dataToWrite1[k]] ) | |||
|
61 | RMAPPlugin0.Write( FFT_FIFO_F2_4, [dataToWrite2[k]] ) | |||
|
62 | # write only the FIFO F2 | |||
|
63 | RMAPPlugin0.Write( FFT_FIFO_F2_WEN, [0xffffffe0] ) | |||
|
64 | ||||
|
65 | prnt.print_custom( "1) data written in FIFOs" ) | |||
|
66 | ||||
|
67 | prnt.print_reg_fft( FFT_CTRL ) | |||
|
68 | ||||
|
69 | # LOCK FIFOs => 0111 1100 0001 1111 | |||
|
70 | RMAPPlugin0.Write( FFT_CTRL, [0x00007c1f] ) | |||
|
71 | ||||
|
72 | # wait for SM_Full | |||
|
73 | fft_reg = RMAPPlugin0.Read( FFT_CTRL, 1) | |||
|
74 | counter = 0 | |||
|
75 | while (fft_reg[0] & 0x000f8000) == 0: | |||
|
76 | prnt.print_custom( "SM not full" ) | |||
|
77 | counter = counter + 1 | |||
|
78 | if counter == 10: | |||
|
79 | break | |||
|
80 | fft_reg = RMAPPlugin0.Read( FFT_CTRL, 1) | |||
|
81 | ||||
|
82 | prnt.print_reg_fft( FFT_CTRL ) | |||
|
83 | ||||
|
84 | ################ | |||
|
85 | # FFT FIRST READ | |||
|
86 | prnt.print_custom( "======= FIRST READ" ) | |||
|
87 | fft0_re = np.zeros( nbSamples ) | |||
|
88 | fft0_im = np.zeros( nbSamples ) | |||
|
89 | fft1_re = np.zeros( nbSamples ) | |||
|
90 | fft1_im = np.zeros( nbSamples ) | |||
|
91 | fft2_re = np.zeros( nbSamples ) | |||
|
92 | fft2_im = np.zeros( nbSamples ) | |||
|
93 | fft3_re = np.zeros( nbSamples ) | |||
|
94 | fft3_im = np.zeros( nbSamples ) | |||
|
95 | fft4_re = np.zeros( nbSamples ) | |||
|
96 | fft4_im = np.zeros( nbSamples ) | |||
|
97 | ||||
|
98 | for k in range(128): | |||
|
99 | # read enable => 0111 1100 0000 0000 | |||
|
100 | RMAPPlugin0.Write( FFT_CTRL, [0x00007c00] ) | |||
|
101 | val = RMAPPlugin0.Read( FFT_MEM_IN_SM_0, 1) | |||
|
102 | fft0_re[k] = dtgn.convertToSigned16Bits( val[0] & 0x0000ffff ) | |||
|
103 | fft0_im[k] = dtgn.convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) | |||
|
104 | val = RMAPPlugin0.Read( FFT_MEM_IN_SM_1, 1) | |||
|
105 | fft1_re[k] = dtgn.convertToSigned16Bits( val[0] & 0x0000ffff ) | |||
|
106 | fft1_im[k] = dtgn.convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) | |||
|
107 | val = RMAPPlugin0.Read( FFT_MEM_IN_SM_2, 1) | |||
|
108 | fft2_re[k] = dtgn.convertToSigned16Bits( val[0] & 0x0000ffff ) | |||
|
109 | fft2_im[k] = dtgn.convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) | |||
|
110 | val = RMAPPlugin0.Read( FFT_MEM_IN_SM_3, 1) | |||
|
111 | fft3_re[k] = dtgn.convertToSigned16Bits( val[0] & 0x0000ffff ) | |||
|
112 | fft3_im[k] = dtgn.convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) | |||
|
113 | val = RMAPPlugin0.Read( FFT_MEM_IN_SM_4, 1) | |||
|
114 | fft4_re[k] = dtgn.convertToSigned16Bits( val[0] & 0x0000ffff ) | |||
|
115 | fft4_im[k] = dtgn.convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) | |||
|
116 | if flg.is_MEM_IN_SM_Emty( FFT_CTRL ) == 1: | |||
|
117 | prnt.print_custom( "k = " + str( k ) ) | |||
|
118 | ||||
|
119 | fft0 = fft0_re * fft0_re + fft0_im * fft0_im | |||
|
120 | fft1 = fft1_re * fft1_re + fft1_im * fft1_im | |||
|
121 | fft2 = fft2_re * fft2_re + fft2_im * fft2_im | |||
|
122 | fft3 = fft3_re * fft3_re + fft3_im * fft3_im | |||
|
123 | fft4 = fft4_re * fft4_re + fft4_im * fft4_im | |||
|
124 | ||||
|
125 | ####### | |||
|
126 | # REUSE | |||
|
127 | prnt.print_custom( "======= REUSE" ) | |||
|
128 | flg.out_locked_AND_out_reuse_AND_out_ren( FFT_CTRL ) | |||
|
129 | prnt.print_reg_fft( FFT_CTRL ) | |||
|
130 | ||||
|
131 | prnt.print_custom( "read data in fft FIFOs" ) | |||
|
132 | fft0_re = np.zeros( nbSamples ) | |||
|
133 | fft0_im = np.zeros( nbSamples ) | |||
|
134 | fft1_re = np.zeros( nbSamples ) | |||
|
135 | fft1_im = np.zeros( nbSamples ) | |||
|
136 | fft2_re = np.zeros( nbSamples ) | |||
|
137 | fft2_im = np.zeros( nbSamples ) | |||
|
138 | fft3_re = np.zeros( nbSamples ) | |||
|
139 | fft3_im = np.zeros( nbSamples ) | |||
|
140 | fft4_re = np.zeros( nbSamples ) | |||
|
141 | fft4_im = np.zeros( nbSamples ) | |||
|
142 | ||||
|
143 | for k in range(128): | |||
|
144 | # read enable => 0111 1100 0000 0000 | |||
|
145 | val = RMAPPlugin0.Read( FFT_MEM_IN_SM_0, 1) | |||
|
146 | fft0_re[k] = dtgn.convertToSigned16Bits( val[0] & 0x0000ffff ) | |||
|
147 | fft0_im[k] = dtgn.convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) | |||
|
148 | val = RMAPPlugin0.Read( FFT_MEM_IN_SM_1, 1) | |||
|
149 | fft1_re[k] = dtgn.convertToSigned16Bits( val[0] & 0x0000ffff ) | |||
|
150 | fft1_im[k] = dtgn.convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) | |||
|
151 | val = RMAPPlugin0.Read( FFT_MEM_IN_SM_2, 1) | |||
|
152 | fft2_re[k] = dtgn.convertToSigned16Bits( val[0] & 0x0000ffff ) | |||
|
153 | fft2_im[k] = dtgn.convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) | |||
|
154 | val = RMAPPlugin0.Read( FFT_MEM_IN_SM_3, 1) | |||
|
155 | fft3_re[k] = dtgn.convertToSigned16Bits( val[0] & 0x0000ffff ) | |||
|
156 | fft3_im[k] = dtgn.convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) | |||
|
157 | val = RMAPPlugin0.Read( FFT_MEM_IN_SM_4, 1) | |||
|
158 | fft4_re[k] = dtgn.convertToSigned16Bits( val[0] & 0x0000ffff ) | |||
|
159 | fft4_im[k] = dtgn.convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) | |||
|
160 | RMAPPlugin0.Write( FFT_CTRL, [0x00007c00] ) | |||
|
161 | if flg.is_MEM_IN_SM_Emty( FFT_CTRL ) == 1: | |||
|
162 | prnt.print_custom( "k = " + str( k ) ) | |||
|
163 | ||||
|
164 | fft0_b = fft0_re * fft0_re + fft0_im * fft0_im | |||
|
165 | fft1_b = fft1_re * fft1_re + fft1_im * fft1_im | |||
|
166 | fft2_b = fft2_re * fft2_re + fft2_im * fft2_im | |||
|
167 | fft3_b = fft3_re * fft3_re + fft3_im * fft3_im | |||
|
168 | fft4_b = fft4_re * fft4_re + fft4_im * fft4_im | |||
|
169 | ||||
|
170 | prnt.print_custom( "data read in fft FIFOs" ) | |||
|
171 | ||||
|
172 | prnt.print_reg_fft( FFT_CTRL ) | |||
|
173 | ||||
|
174 | #unlock FIFOs => 0000 0000 0001 1111 | |||
|
175 | RMAPPlugin0.Write( FFT_CTRL, [0x0000001f] ) | |||
|
176 | ||||
|
177 | prnt.print_reg_fft( FFT_CTRL ) | |||
|
178 | ||||
|
179 | # PLOT FFT | |||
|
180 | ||||
|
181 | plt.figure( 1 ) | |||
|
182 | plt.subplot(231) | |||
|
183 | plt.plot(wfrm0, 'b') | |||
|
184 | plt.subplot(232) | |||
|
185 | plt.plot(wfrm1, 'g') | |||
|
186 | plt.plot(wfrm1, '.') | |||
|
187 | plt.subplot(233) | |||
|
188 | plt.plot(wfrm2, 'r') | |||
|
189 | plt.plot(wfrm2, '.') | |||
|
190 | plt.subplot(234) | |||
|
191 | plt.plot(wfrm3, 'c') | |||
|
192 | plt.subplot(235) | |||
|
193 | plt.plot(wfrm4, 'm') | |||
|
194 | ||||
|
195 | plt.figure( 2 ) | |||
|
196 | plt.subplot(311) | |||
|
197 | plt.plot(fft0_re) | |||
|
198 | plt.plot(fft1_re) | |||
|
199 | plt.plot(fft2_re) | |||
|
200 | plt.plot(fft3_re) | |||
|
201 | plt.plot(fft4_re) | |||
|
202 | ||||
|
203 | plt.subplot(312) | |||
|
204 | plt.plot(fft0_im) | |||
|
205 | plt.plot(fft1_im) | |||
|
206 | plt.plot(fft2_im) | |||
|
207 | plt.plot(fft3_im) | |||
|
208 | plt.plot(fft4_im) | |||
|
209 | ||||
|
210 | plt.subplot(313) | |||
|
211 | plt.plot(fft0_re * fft0_re + fft0_im * fft0_im, 'b') | |||
|
212 | plt.plot(fft1_re * fft1_re + fft1_im * fft1_im, 'g') | |||
|
213 | plt.plot(fft2_re * fft2_re + fft2_im * fft2_im, 'r') | |||
|
214 | plt.plot(fft3_re * fft3_re + fft3_im * fft3_im, 'c') | |||
|
215 | plt.plot(fft4_re * fft4_re + fft4_im * fft4_im, 'm') | |||
|
216 | ||||
|
217 | plt.figure( 3 ) | |||
|
218 | plt.subplot(231) | |||
|
219 | plt.plot(fft0[0:255], 'b') | |||
|
220 | plt.subplot(232) | |||
|
221 | plt.plot(fft1[0:255], 'g') | |||
|
222 | plt.subplot(233) | |||
|
223 | plt.plot(fft2[0:255], 'r') | |||
|
224 | plt.subplot(234) | |||
|
225 | plt.plot(fft3[0:255], 'c') | |||
|
226 | plt.subplot(235) | |||
|
227 | plt.plot(fft4[0:255], 'm') | |||
|
228 | ||||
|
229 | plt.figure( 4 ) | |||
|
230 | plt.subplot(231) | |||
|
231 | plt.plot(fft0_b[0:255], 'b') | |||
|
232 | plt.subplot(232) | |||
|
233 | plt.plot(fft1_b[0:255], 'g') | |||
|
234 | plt.subplot(233) | |||
|
235 | plt.plot(fft2_b[0:255], 'r') | |||
|
236 | plt.subplot(234) | |||
|
237 | plt.plot(fft3_b[0:255], 'c') | |||
|
238 | plt.subplot(235) | |||
|
239 | plt.plot(fft4_b[0:255], 'm') | |||
|
240 | ||||
|
241 | plt.show() No newline at end of file |
@@ -0,0 +1,193 | |||||
|
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 import * | |||
|
8 | ||||
|
9 | import test_fft.read_flags as flg | |||
|
10 | import test_fft.data_generator as dtgn | |||
|
11 | import test_fft.print_custom as prnt | |||
|
12 | import test_fft.read_data as rdata | |||
|
13 | ||||
|
14 | prnt.print_custom( '*' ) | |||
|
15 | prnt.print_custom( '*' ) | |||
|
16 | prnt.print_custom( '*' ) | |||
|
17 | prnt.print_custom( '*' ) | |||
|
18 | prnt.print_custom( '*' ) | |||
|
19 | ||||
|
20 | ###################### | |||
|
21 | # GET DATA FROM RECORD | |||
|
22 | #storageDirectory = '/home/paul/data/2014_06_24/' | |||
|
23 | #day = '2014_6_24-' | |||
|
24 | #hour = '9_0_3' | |||
|
25 | #suffix = '.data' | |||
|
26 | ||||
|
27 | #typeOfData = '_SBM1_CWF_' | |||
|
28 | #cwf_f1 = np.genfromtxt( storageDirectory + day + hour + typeOfData + 'F1' + suffix, | |||
|
29 | # skip_header = 1) | |||
|
30 | cwf_f1 = np.zeros( 1000 ) | |||
|
31 | ||||
|
32 | ################# | |||
|
33 | # BUILD WAVEFORMS | |||
|
34 | nbSamples = 256 | |||
|
35 | nbComponentsPerMatrix = 15 | |||
|
36 | nbFrequencyBins = 128 | |||
|
37 | #wfrm0 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnV ) | |||
|
38 | #wfrm1 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnE1 ) | |||
|
39 | #wfrm2 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnE2 ) | |||
|
40 | #wfrm3 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnB1 ) | |||
|
41 | #wfrm4 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnB2 ) | |||
|
42 | wfrm0 = dtgn.sineWave( 256, 10, 1000 ) | |||
|
43 | wfrm1 = dtgn.sineWave( 256, 10, 1000 ) | |||
|
44 | wfrm2 = dtgn.sineWave( 256, 20, 1000 ) | |||
|
45 | wfrm3 = dtgn.sineWave( 256, 20, 1000 ) | |||
|
46 | wfrm4 = dtgn.sineWave( 256, 50, 1000 ) | |||
|
47 | ||||
|
48 | ################ | |||
|
49 | # BUILD THE DATA | |||
|
50 | dataToWrite0 = dtgn.generateDataToWrite( nbSamples, wfrm0, wfrm1 ) | |||
|
51 | dataToWrite1 = dtgn.generateDataToWrite( nbSamples, wfrm2, wfrm3 ) | |||
|
52 | dataToWrite2 = dtgn.generateDataToWrite( nbSamples, wfrm4, np.zeros( nbSamples ) ) | |||
|
53 | ||||
|
54 | ######################## | |||
|
55 | # WRITE WAVEFORM IN FIFO | |||
|
56 | prnt.print_custom( "1) write waveforms in FIFOs: " + str(len(dataToWrite0)) + " samples" ) | |||
|
57 | prnt.print_reg_sm( FFT_SM_MEM_OUT_SM_CTRL ) | |||
|
58 | ||||
|
59 | for k in range(nbSamples): | |||
|
60 | RMAPPlugin0.Write( FFT_FIFO_F2_1_0, [dataToWrite0[k]] ) | |||
|
61 | RMAPPlugin0.Write( FFT_FIFO_F2_3_2, [dataToWrite1[k]] ) | |||
|
62 | RMAPPlugin0.Write( FFT_FIFO_F2_4, [dataToWrite2[k]] ) | |||
|
63 | # write only the FIFO F2 | |||
|
64 | RMAPPlugin0.Write( FFT_FIFO_F2_WEN, [0xffffffe0] ) | |||
|
65 | ||||
|
66 | prnt.print_custom( "1) data written in FIFOs" ) | |||
|
67 | ||||
|
68 | ################ | |||
|
69 | # SM FIRST READ | |||
|
70 | prnt.print_custom( "======= SM FIRST READ" ) | |||
|
71 | ||||
|
72 | components = [] | |||
|
73 | ||||
|
74 | flg.wait_for_FIFO_0_or_1_Full( FFT_SM_MEM_OUT_SM_CTRL ) | |||
|
75 | ||||
|
76 | if flg.is_MEM_OUT_SM_Full_FIFO_0( FFT_SM_MEM_OUT_SM_CTRL ): | |||
|
77 | address_MEM_OUT_SM = FFT_SM_MEM_OUT_SM_1 | |||
|
78 | fifo_to_wait_for = 0 | |||
|
79 | elif flg.is_MEM_OUT_SM_Full_FIFO_1( FFT_SM_MEM_OUT_SM_CTRL ): | |||
|
80 | address_MEM_OUT_SM = FFT_SM_MEM_OUT_SM_0 | |||
|
81 | fifo_to_wait_for = 1 | |||
|
82 | ||||
|
83 | for component in range(nbComponentsPerMatrix): | |||
|
84 | prnt.print_custom( "==== component = " + str( component ) | |||
|
85 | + ", read @ " + hex(address_MEM_OUT_SM & 0xffffffff) ) | |||
|
86 | prnt.print_reg_sm( FFT_SM_MEM_OUT_SM_CTRL ) | |||
|
87 | currentComp_re = np.zeros( nbFrequencyBins ) | |||
|
88 | currentComp_im = np.zeros( nbFrequencyBins ) | |||
|
89 | if (component == 0) | (component == 12): | |||
|
90 | flg.wait_for_FIFO_Full( fifo_to_wait_for, FFT_SM_MEM_OUT_SM_CTRL ) | |||
|
91 | currentComp_re = rdata.read_SM_Re( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
92 | components.append( currentComp_re ) | |||
|
93 | elif (component == 5) | (component == 9): | |||
|
94 | flg.wait_for_FIFO_Full( fifo_to_wait_for, FFT_SM_MEM_OUT_SM_CTRL ) | |||
|
95 | currentComp_re = rdata.read_SM_Re( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
96 | components.append( currentComp_re ) | |||
|
97 | elif (component == 1) | (component == 3) | (component == 7): | |||
|
98 | currentComp_re, currentComp_im = rdata.read_SM_Re_Im( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
99 | components.append( currentComp_re ) | |||
|
100 | components.append( currentComp_im ) | |||
|
101 | flg.wait_for_FIFO_Full( fifo_to_wait_for, FFT_SM_MEM_OUT_SM_CTRL ) | |||
|
102 | elif (component == 2) | (component == 6) | (component == 10): | |||
|
103 | currentComp_re, currentComp_im = rdata.read_SM_Re_Im( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
104 | components.append( currentComp_re ) | |||
|
105 | components.append( currentComp_im ) | |||
|
106 | flg.wait_for_FIFO_Full( fifo_to_wait_for, FFT_SM_MEM_OUT_SM_CTRL ) | |||
|
107 | elif (component == 4) | (component == 8): | |||
|
108 | currentComp_re, currentComp_im = rdata.read_SM_Re_Im( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
109 | components.append( currentComp_re ) | |||
|
110 | components.append( currentComp_im ) | |||
|
111 | elif (component == 11) | (component == 13): | |||
|
112 | currentComp_re, currentComp_im = rdata.read_SM_Re_Im( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
113 | components.append( currentComp_re ) | |||
|
114 | components.append( currentComp_im ) | |||
|
115 | elif (component == 14): | |||
|
116 | currentComp_re = rdata.read_SM_Re( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
117 | components.append( currentComp_re ) | |||
|
118 | else: | |||
|
119 | prnt.print_custom( "unexpected value for component" ) | |||
|
120 | # change FIFO | |||
|
121 | if address_MEM_OUT_SM == FFT_SM_MEM_OUT_SM_0: | |||
|
122 | address_MEM_OUT_SM = FFT_SM_MEM_OUT_SM_1 | |||
|
123 | fifo_to_wait_for = 0 | |||
|
124 | elif address_MEM_OUT_SM == FFT_SM_MEM_OUT_SM_1: | |||
|
125 | address_MEM_OUT_SM = FFT_SM_MEM_OUT_SM_0 | |||
|
126 | fifo_to_wait_for = 1 | |||
|
127 | ||||
|
128 | prnt.print_custom( "======= READ COMPLETE" ) | |||
|
129 | ||||
|
130 | prnt.print_reg_sm( FFT_SM_MEM_OUT_SM_CTRL ) | |||
|
131 | ||||
|
132 | # PLOT SM | |||
|
133 | ||||
|
134 | plt.figure( 1 ) | |||
|
135 | plt.subplot(231) | |||
|
136 | plt.plot(wfrm0, 'b') | |||
|
137 | plt.subplot(232) | |||
|
138 | plt.plot(wfrm1, 'g') | |||
|
139 | plt.plot(wfrm1, '.') | |||
|
140 | plt.subplot(233) | |||
|
141 | plt.plot(wfrm2, 'r') | |||
|
142 | plt.plot(wfrm2, '.') | |||
|
143 | plt.subplot(234) | |||
|
144 | plt.plot(wfrm3, 'c') | |||
|
145 | plt.subplot(235) | |||
|
146 | plt.plot(wfrm4, 'm') | |||
|
147 | ||||
|
148 | plt.figure( 2 ) | |||
|
149 | ||||
|
150 | plt.subplot(231) | |||
|
151 | plt.plot(components[0], label='0') | |||
|
152 | plt.plot(components[1], label='1') | |||
|
153 | plt.plot(components[2], label='2') | |||
|
154 | plt.plot(components[3], label='3') | |||
|
155 | plt.legend(loc='upper right') | |||
|
156 | ||||
|
157 | plt.subplot(232) | |||
|
158 | plt.plot(components[4], label='4') | |||
|
159 | plt.plot(components[5], label='5') | |||
|
160 | plt.plot(components[6], label='6') | |||
|
161 | plt.plot(components[7], label='7') | |||
|
162 | plt.legend(loc='upper right') | |||
|
163 | ||||
|
164 | plt.subplot(233) | |||
|
165 | plt.plot(components[8], label='8') | |||
|
166 | plt.plot(components[9], label='9') | |||
|
167 | plt.plot(components[10], label='10') | |||
|
168 | plt.plot(components[11], label='11') | |||
|
169 | plt.legend(loc='upper right') | |||
|
170 | ||||
|
171 | plt.subplot(234) | |||
|
172 | plt.plot(components[12], label='12') | |||
|
173 | plt.plot(components[13], label='13') | |||
|
174 | plt.plot(components[14], label='14') | |||
|
175 | plt.plot(components[15], label='15') | |||
|
176 | plt.legend(loc='upper right') | |||
|
177 | ||||
|
178 | plt.subplot(235) | |||
|
179 | plt.plot(components[16], label='16') | |||
|
180 | plt.plot(components[17], label='17') | |||
|
181 | plt.plot(components[18], label='18') | |||
|
182 | plt.plot(components[19], label='19') | |||
|
183 | plt.legend(loc='upper right') | |||
|
184 | ||||
|
185 | plt.subplot(236) | |||
|
186 | plt.plot(components[20], label='20') | |||
|
187 | plt.plot(components[21], label='21') | |||
|
188 | plt.plot(components[22], label='22') | |||
|
189 | plt.plot(components[23], label='23') | |||
|
190 | plt.plot(components[24], label='24') | |||
|
191 | plt.legend(loc='upper right') | |||
|
192 | ||||
|
193 | plt.show() No newline at end of file |
@@ -0,0 +1,218 | |||||
|
1 | import numpy as np | |||
|
2 | import matplotlib.pyplot as plt | |||
|
3 | ||||
|
4 | from test_fft.register_addresses import * | |||
|
5 | ||||
|
6 | import test_fft.read_flags as flg | |||
|
7 | import test_fft.data_generator as dtgn | |||
|
8 | import test_fft.print_custom as prnt | |||
|
9 | import test_fft.read_data as rdata | |||
|
10 | ||||
|
11 | prnt.print_custom( '*' ) | |||
|
12 | prnt.print_custom( '*' ) | |||
|
13 | prnt.print_custom( '*' ) | |||
|
14 | prnt.print_custom( '*' ) | |||
|
15 | prnt.print_custom( '*' ) | |||
|
16 | ||||
|
17 | ############ | |||
|
18 | # BUILD DATA | |||
|
19 | nbSamples = 256 | |||
|
20 | nbComponentsPerMatrix = 15 | |||
|
21 | nbFrequencyBins = 128 | |||
|
22 | re_0 = dtgn.sineWave( nbFrequencyBins, 10, 10 ) | |||
|
23 | im_0 = dtgn.sineWave( nbFrequencyBins, 10, 10 ) | |||
|
24 | dataToWrite_0 = dtgn.generateDataToWrite( nbFrequencyBins, re_0, im_0 ) | |||
|
25 | re_1 = dtgn.sineWave( nbFrequencyBins, 10, 20 ) | |||
|
26 | im_1 = dtgn.sineWave( nbFrequencyBins, 10, 20 ) | |||
|
27 | dataToWrite_1 = dtgn.generateDataToWrite( nbFrequencyBins, re_1, im_1 ) | |||
|
28 | re_2 = dtgn.sineWave( nbFrequencyBins, 10, 30 ) | |||
|
29 | im_2 = dtgn.sineWave( nbFrequencyBins, 10, 30 ) | |||
|
30 | dataToWrite_2 = dtgn.generateDataToWrite( nbFrequencyBins, re_2, im_2 ) | |||
|
31 | re_3 = dtgn.sineWave( nbFrequencyBins, 10, 40 ) | |||
|
32 | im_3 = dtgn.sineWave( nbFrequencyBins, 10, 40 ) | |||
|
33 | dataToWrite_3 = dtgn.generateDataToWrite( nbFrequencyBins, re_3, im_3 ) | |||
|
34 | re_4 = dtgn.sineWave( nbFrequencyBins, 10, 50 ) | |||
|
35 | im_4 = dtgn.sineWave( nbFrequencyBins, 10, 50 ) | |||
|
36 | dataToWrite_4 = dtgn.generateDataToWrite( nbFrequencyBins, re_4, im_4 ) | |||
|
37 | ||||
|
38 | re_0 = dtgn.step( nbFrequencyBins, 10 ) | |||
|
39 | im_0 = dtgn.continuous( nbFrequencyBins, 10 ) | |||
|
40 | dataToWrite_0 = dtgn.generateDataToWrite( nbFrequencyBins, re_0, im_0 ) | |||
|
41 | re_1 = dtgn.step( nbFrequencyBins, 20 ) | |||
|
42 | im_1 = dtgn.continuous( nbFrequencyBins, 20 ) | |||
|
43 | dataToWrite_1 = dtgn.generateDataToWrite( nbFrequencyBins, re_1, im_1 ) | |||
|
44 | re_2 = dtgn.step( nbFrequencyBins, 30 ) | |||
|
45 | im_2 = dtgn.continuous( nbFrequencyBins, 30 ) | |||
|
46 | dataToWrite_2 = dtgn.generateDataToWrite( nbFrequencyBins, re_2, im_2 ) | |||
|
47 | re_3 = dtgn.step( nbFrequencyBins, 40 ) | |||
|
48 | im_3 = dtgn.continuous( nbFrequencyBins, 40 ) | |||
|
49 | dataToWrite_3 = dtgn.generateDataToWrite( nbFrequencyBins, re_3, im_3 ) | |||
|
50 | re_4 = dtgn.step( nbFrequencyBins, 50 ) | |||
|
51 | im_4 = dtgn.continuous( nbFrequencyBins, 50 ) | |||
|
52 | dataToWrite_4 = dtgn.generateDataToWrite( nbFrequencyBins, re_4, im_4 ) | |||
|
53 | ||||
|
54 | diracPosition = 60 | |||
|
55 | re_0 = dtgn.dirac( nbFrequencyBins, 10, diracPosition ) | |||
|
56 | im_0 = dtgn.dirac( nbFrequencyBins, 10, diracPosition ) | |||
|
57 | dataToWrite_0 = dtgn.generateDataToWrite( nbFrequencyBins, re_0, im_0 ) | |||
|
58 | re_1 = dtgn.dirac( nbFrequencyBins, 20, diracPosition ) | |||
|
59 | im_1 = dtgn.dirac( nbFrequencyBins, 20, diracPosition ) | |||
|
60 | dataToWrite_1 = dtgn.generateDataToWrite( nbFrequencyBins, re_1, im_1 ) | |||
|
61 | re_2 = dtgn.dirac( nbFrequencyBins, 30, diracPosition ) | |||
|
62 | im_2 = dtgn.dirac( nbFrequencyBins, 30, diracPosition ) | |||
|
63 | dataToWrite_2 = dtgn.generateDataToWrite( nbFrequencyBins, re_2, im_2 ) | |||
|
64 | re_3 = dtgn.dirac( nbFrequencyBins, 40, diracPosition ) | |||
|
65 | im_3 = dtgn.dirac( nbFrequencyBins, 40, diracPosition ) | |||
|
66 | dataToWrite_3 = dtgn.generateDataToWrite( nbFrequencyBins, re_3, im_3 ) | |||
|
67 | re_4 = dtgn.dirac( nbFrequencyBins, 50, diracPosition ) | |||
|
68 | im_4 = dtgn.dirac( nbFrequencyBins, 50, diracPosition ) | |||
|
69 | dataToWrite_4 = dtgn.generateDataToWrite( nbFrequencyBins, re_4, im_4 ) | |||
|
70 | ||||
|
71 | ######################## | |||
|
72 | # WRITE WAVEFORM IN FIFO | |||
|
73 | prnt.print_reg_sm_only_MEM_IN_CTRL( SM_ONLY_MEM_IN_SM_CTRL ) | |||
|
74 | prnt.print_reg_sm_only_MEM_OUT_CTRL( SM_ONLY_MEM_OUT_CTRL ) | |||
|
75 | prnt.print_custom( "1) write data in SM_MEM_IN: " + str(len(dataToWrite_0)) + " bins" ) | |||
|
76 | ||||
|
77 | for k in range(nbFrequencyBins): | |||
|
78 | RMAPPlugin0.Write( SM_ONLY_MEM_IN_SM_0, [dataToWrite_0[k]] ) | |||
|
79 | RMAPPlugin0.Write( SM_ONLY_MEM_IN_SM_1, [dataToWrite_1[k]] ) | |||
|
80 | RMAPPlugin0.Write( SM_ONLY_MEM_IN_SM_2, [dataToWrite_2[k]] ) | |||
|
81 | RMAPPlugin0.Write( SM_ONLY_MEM_IN_SM_3, [dataToWrite_3[k]] ) | |||
|
82 | RMAPPlugin0.Write( SM_ONLY_MEM_IN_SM_4, [dataToWrite_4[k]] ) | |||
|
83 | RMAPPlugin0.Write( SM_ONLY_MEM_IN_SM_CTRL, [0xffffffe0] ) | |||
|
84 | ||||
|
85 | prnt.print_custom( "1) data written in SM_MEM_IN" ) | |||
|
86 | prnt.print_reg_sm_only_MEM_IN_CTRL( SM_ONLY_MEM_IN_SM_CTRL ) | |||
|
87 | prnt.print_reg_sm_only_MEM_OUT_CTRL( SM_ONLY_MEM_OUT_CTRL ) | |||
|
88 | ||||
|
89 | ################ | |||
|
90 | # SM FIRST READ | |||
|
91 | prnt.print_custom( "======= SM FIRST READ" ) | |||
|
92 | ||||
|
93 | components = [] | |||
|
94 | ||||
|
95 | flg.wait_for_FIFO_0_or_1_Full( SM_ONLY_MEM_OUT_CTRL ) | |||
|
96 | ||||
|
97 | if flg.is_MEM_OUT_SM_Full_FIFO_0( SM_ONLY_MEM_OUT_CTRL ): | |||
|
98 | address_MEM_OUT_SM = SM_ONLY_MEM_OUT_SM_1 | |||
|
99 | fifo_to_wait_for = 0 | |||
|
100 | elif flg.is_MEM_OUT_SM_Full_FIFO_1( SM_ONLY_MEM_OUT_CTRL ): | |||
|
101 | address_MEM_OUT_SM = SM_ONLY_MEM_OUT_SM_0 | |||
|
102 | fifo_to_wait_for = 1 | |||
|
103 | else: | |||
|
104 | prnt.print_custom("oups, FIFO_0 and FIFO_1 are not full, this is unexpected") | |||
|
105 | ||||
|
106 | for component in range(nbComponentsPerMatrix): | |||
|
107 | prnt.print_custom( "==== component = " + str( component ) | |||
|
108 | + ", read @ " + hex(address_MEM_OUT_SM & 0xffffffff) ) | |||
|
109 | prnt.print_reg_sm_only_MEM_IN_CTRL( SM_ONLY_MEM_IN_SM_CTRL ) | |||
|
110 | prnt.print_reg_sm_only_MEM_OUT_CTRL( SM_ONLY_MEM_OUT_CTRL ) | |||
|
111 | currentComp_re = np.zeros( nbFrequencyBins ) | |||
|
112 | currentComp_im = np.zeros( nbFrequencyBins ) | |||
|
113 | if (component == 0) | (component == 12): | |||
|
114 | flg.wait_for_FIFO_Full( fifo_to_wait_for, SM_ONLY_MEM_OUT_CTRL ) | |||
|
115 | currentComp_re = rdata.read_SM_ONLY_Re( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
116 | components.append( currentComp_re ) | |||
|
117 | elif (component == 5) | (component == 9): | |||
|
118 | flg.wait_for_FIFO_Full( fifo_to_wait_for, SM_ONLY_MEM_OUT_CTRL ) | |||
|
119 | currentComp_re = rdata.read_SM_ONLY_Re( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
120 | components.append( currentComp_re ) | |||
|
121 | elif (component == 1) | (component == 3) | (component == 7): | |||
|
122 | currentComp_re, currentComp_im = rdata.read_SM_ONLY_Re_Im( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
123 | components.append( currentComp_re ) | |||
|
124 | components.append( currentComp_im ) | |||
|
125 | flg.wait_for_FIFO_Full( fifo_to_wait_for, SM_ONLY_MEM_OUT_CTRL ) | |||
|
126 | elif (component == 2) | (component == 6) | (component == 10): | |||
|
127 | currentComp_re, currentComp_im = rdata.read_SM_ONLY_Re_Im( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
128 | components.append( currentComp_re ) | |||
|
129 | components.append( currentComp_im ) | |||
|
130 | flg.wait_for_FIFO_Full( fifo_to_wait_for, SM_ONLY_MEM_OUT_CTRL ) | |||
|
131 | elif (component == 4) | (component == 8): | |||
|
132 | currentComp_re, currentComp_im = rdata.read_SM_ONLY_Re_Im( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
133 | components.append( currentComp_re ) | |||
|
134 | components.append( currentComp_im ) | |||
|
135 | elif (component == 11) | (component == 13): | |||
|
136 | currentComp_re, currentComp_im = rdata.read_SM_ONLY_Re_Im( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
137 | components.append( currentComp_re ) | |||
|
138 | components.append( currentComp_im ) | |||
|
139 | elif (component == 14): | |||
|
140 | currentComp_re = rdata.read_SM_ONLY_Re( nbFrequencyBins, address_MEM_OUT_SM ) | |||
|
141 | components.append( currentComp_re ) | |||
|
142 | else: | |||
|
143 | prnt.print_custom( "unexpected value for component" ) | |||
|
144 | # change FIFO | |||
|
145 | if address_MEM_OUT_SM == SM_ONLY_MEM_OUT_SM_0: | |||
|
146 | address_MEM_OUT_SM = SM_ONLY_MEM_OUT_SM_1 | |||
|
147 | fifo_to_wait_for = 0 | |||
|
148 | elif address_MEM_OUT_SM == SM_ONLY_MEM_OUT_SM_1: | |||
|
149 | address_MEM_OUT_SM = SM_ONLY_MEM_OUT_SM_0 | |||
|
150 | fifo_to_wait_for = 1 | |||
|
151 | ||||
|
152 | prnt.print_custom( "======= READ COMPLETE" ) | |||
|
153 | ||||
|
154 | prnt.print_reg_sm_only_MEM_IN_CTRL( SM_ONLY_MEM_IN_SM_CTRL ) | |||
|
155 | prnt.print_reg_sm_only_MEM_OUT_CTRL( SM_ONLY_MEM_OUT_CTRL ) | |||
|
156 | ||||
|
157 | # PLOT SM | |||
|
158 | ||||
|
159 | plt.figure( 1 ) | |||
|
160 | plt.subplot(231) | |||
|
161 | plt.plot(re_0, 'b') | |||
|
162 | plt.subplot(232) | |||
|
163 | plt.plot(re_1, 'g') | |||
|
164 | plt.plot(re_1, '.') | |||
|
165 | plt.subplot(233) | |||
|
166 | plt.plot(re_2, 'r') | |||
|
167 | plt.plot(re_2, '.') | |||
|
168 | plt.subplot(234) | |||
|
169 | plt.plot(re_3, 'c') | |||
|
170 | plt.subplot(235) | |||
|
171 | plt.plot(re_4, 'm') | |||
|
172 | ||||
|
173 | plt.figure( 2 ) | |||
|
174 | ||||
|
175 | plt.subplot(231) | |||
|
176 | plt.plot(components[0], label='0') | |||
|
177 | plt.plot(components[1], '.', label='1') | |||
|
178 | plt.plot(components[2], label='2') | |||
|
179 | plt.plot(components[3], '.', label='3') | |||
|
180 | plt.legend(loc='upper right') | |||
|
181 | ||||
|
182 | plt.subplot(232) | |||
|
183 | plt.plot(components[4], label='4') | |||
|
184 | plt.plot(components[5], '.', label='5') | |||
|
185 | plt.plot(components[6], label='6') | |||
|
186 | plt.plot(components[7], '.', label='7') | |||
|
187 | plt.legend(loc='upper right') | |||
|
188 | ||||
|
189 | plt.subplot(233) | |||
|
190 | plt.plot(components[8], label='8') | |||
|
191 | plt.plot(components[9], label='9') | |||
|
192 | plt.plot(components[10], '.', label='10') | |||
|
193 | plt.plot(components[11], label='11') | |||
|
194 | plt.legend(loc='upper right') | |||
|
195 | ||||
|
196 | plt.subplot(234) | |||
|
197 | plt.plot(components[12], label='12') | |||
|
198 | plt.plot(components[13], label='13') | |||
|
199 | plt.plot(components[14], label='14') | |||
|
200 | plt.plot(components[15], label='15') | |||
|
201 | plt.legend(loc='upper right') | |||
|
202 | ||||
|
203 | plt.subplot(235) | |||
|
204 | plt.plot(components[16], label='16') | |||
|
205 | plt.plot(components[17], label='17') | |||
|
206 | plt.plot(components[18], label='18') | |||
|
207 | plt.plot(components[19], label='19') | |||
|
208 | plt.legend(loc='upper right') | |||
|
209 | ||||
|
210 | plt.subplot(236) | |||
|
211 | plt.plot(components[20], label='20') | |||
|
212 | plt.plot(components[21], label='21') | |||
|
213 | plt.plot(components[22], label='22') | |||
|
214 | plt.plot(components[23], label='23') | |||
|
215 | plt.plot(components[24], label='24') | |||
|
216 | plt.legend(loc='upper right') | |||
|
217 | ||||
|
218 | plt.show() No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now