# HG changeset patch # User paul # Date 2014-07-04 11:28:00 # Node ID 565b8186dcb8b94dd05c68ec1bb0aa3192b6444b # Parent 67ac51a395405ede8af77afec5ee3a2bff25f05a Sync diff --git a/SRC/fft_integerVsfloat_sine_wave.py b/SRC/fft_integerVsfloat_sine_wave.py new file mode 100644 --- /dev/null +++ b/SRC/fft_integerVsfloat_sine_wave.py @@ -0,0 +1,45 @@ +import math +import numpy as np +from bin16 import * +from fft import * +import matplotlib.pyplot as plt + +nb_points = 256 +nb_periods = 10 +amplitude = 1000 + +time_vec = np.arange(0, nb_points, 1) +teta = nb_periods * time_vec * 2 * np.pi/ nb_points + +Afloat = 10000 * np.sin( teta ) + +Aint = np.zeros(len(time_vec)) +for i in range(len(time_vec)): + Aint[i] = quant16( Afloat[i], -pow(2,16)/2, +pow(2,16)/2 ) + +plt.figure(1) +plt.plot(time_vec,Afloat,'b.') +plt.plot(time_vec,Aint,'r.') +plt.show() + +Afloat_FFT = np.fft.fft(Afloat)/len(time_vec) + +# plt.figure(2) +# plt.plot(abs(Afloat_FFT[0:100]),'g') +# plt.show() + +# plt.figure(3) +# plt.plot(time_vec,Aint,'r') +# plt.show() + +Aint_FFT = fft_CT(Aint) + +plt.figure(4) +plt.plot(abs(Afloat_FFT[0:100]),'g') +plt.scatter(range(100),1.0 * abs(Aint_FFT[0:100])/16384) +plt.title("Comparing the FFT's") +plt.show() + + + + diff --git a/lfr_emulator.sublime-workspace b/lfr_emulator.sublime-workspace --- a/lfr_emulator.sublime-workspace +++ b/lfr_emulator.sublime-workspace @@ -4,6 +4,34 @@ "selected_items": [ [ + "c", + "c" + ], + [ + "g", + "g" + ], + [ + "compo", + "components_re" + ], + [ + "cur", + "currentComp_im" + ], + [ + "current", + "currentComp_im" + ], + [ + "curre", + "currentComp_re" + ], + [ + "nb", + "nbComponentsPerMatrix" + ], + [ "MEM", "MEM_IN_SM_Empty" ], @@ -100,10 +128,6 @@ "groupbox_tc_lfr_load_common_par" ], [ - "c", - "common" - ], - [ "laben", "label_UNKNOWN_nb" ], @@ -116,10 +140,26 @@ "buffers": [ { - "file": "test_fft/test_fft_mini_lfr.py", + "file": "test_fft/test_sm_mini_lfr.py", "settings": { - "buffer_size": 4505, + "buffer_size": 4053, + "line_ending": "Unix" + } + }, + { + "file": "test_fft/fft_test_functions.py", + "settings": + { + "buffer_size": 3885, + "line_ending": "Unix" + } + }, + { + "file": "test_fft/register_addresses_fft_test.py", + "settings": + { + "buffer_size": 798, "line_ending": "Unix" } } @@ -148,6 +188,7 @@ }, "file_history": [ + "/opt/LFR_EMULATOR/test_fft/test_fft_mini_lfr.py", "/opt/LFR_EMULATOR/test_fft/functions_evaluations.py", "/opt/LFR_EMULATOR/SRC/processing_chain.py", "/opt/LFR_EMULATOR/main.py", @@ -225,18 +266,18 @@ [ { "buffer": 0, - "file": "test_fft/test_fft_mini_lfr.py", + "file": "test_fft/test_sm_mini_lfr.py", "settings": { - "buffer_size": 4505, + "buffer_size": 4053, "regions": { }, "selection": [ [ - 1524, - 1524 + 2731, + 2731 ] ], "settings": @@ -245,7 +286,60 @@ "translate_tabs_to_spaces": false }, "translation.x": 0.0, - "translation.y": 1998.0, + "translation.y": 1295.0, + "zoom_level": 1.0 + }, + "type": "text" + }, + { + "buffer": 1, + "file": "test_fft/fft_test_functions.py", + "settings": + { + "buffer_size": 3885, + "regions": + { + }, + "selection": + [ + [ + 2140, + 2140 + ] + ], + "settings": + { + "syntax": "Packages/Python/Python.tmLanguage", + "translate_tabs_to_spaces": false + }, + "translation.x": 0.0, + "translation.y": 1081.0, + "zoom_level": 1.0 + }, + "type": "text" + }, + { + "buffer": 2, + "file": "test_fft/register_addresses_fft_test.py", + "settings": + { + "buffer_size": 798, + "regions": + { + }, + "selection": + [ + [ + 717, + 717 + ] + ], + "settings": + { + "syntax": "Packages/Python/Python.tmLanguage" + }, + "translation.x": 0.0, + "translation.y": 0.0, "zoom_level": 1.0 }, "type": "text" @@ -317,6 +411,6 @@ "show_open_files": false, "show_tabs": true, "side_bar_visible": true, - "side_bar_width": 289.0, + "side_bar_width": 255.0, "status_bar_visible": true } diff --git a/test_fft/__init__.pyc b/test_fft/__init__.pyc index bf7bfa406c3ae8657db0af3aec5509e6eeb24847..8287a957a4929184982e5038fd81add5eebec5a6 GIT binary patch literal 125 zc${PY%*(|pw>dbO0SXv_*a3)(S%5?e14FO|NW@PAB!@;6s{sl9{DKmFAGe@*SKm+{ u#}NM@{gTw;lK8Z=68-r2%)HE!_;|g7$`THsQk&fTl+v73JCK3JAOirJ+7}7{ diff --git a/test_fft/fft_test_functions.py b/test_fft/fft_test_functions.py --- a/test_fft/fft_test_functions.py +++ b/test_fft/fft_test_functions.py @@ -21,7 +21,7 @@ def continuous( bufferSize, value ): return yVector def step( bufferSize, value ): - tmpVector = np.empty( bufferSize ) + tmpVector = np.zeros( bufferSize ) for k in range( bufferSize / 2 ): tmpVector[ bufferSize / 2 + k ] = value yVector = np.int16( tmpVector ) @@ -56,6 +56,65 @@ def print_reg_fft( ): + ", MEM_IN_SM_Empty = " + bin( MEM_IN_SM_Empty ) RMAPPlugin0.ProcessPendingEvents() +def print_custom( value ): + print value + RMAPPlugin0.ProcessPendingEvents() + +def is_MEM_IN_SM_Emty( ): + ret = 0 + fft_reg = RMAPPlugin0.Read( address_CTRL, 1) + MEM_IN_SM_Empty = (fft_reg[0] & 0x01f00000) >> 20 + if MEM_IN_SM_Empty == 0x1f: + ret = 1 + return ret + +def print_reg_sm( ): + sm_reg = RMAPPlugin0.Read( address_CTRL_SM, 1) + out_ren = (sm_reg[0] & 0x00000003) + MEM_OUT_SM_Full = (sm_reg[0] & 0x0000000c) >> 2 + MEM_OUT_SM_Empty = (sm_reg[0] & 0x00000030) >> 4 + print "sm_reg = " + bin( sm_reg[0] & 0x3f ) \ + + ", out_ren = " + bin( out_ren ) \ + + ", MEM_OUT_SM_Full = " + bin( MEM_OUT_SM_Full ) \ + + ", MEM_OUT_SM_Empty = " + bin( MEM_OUT_SM_Empty ) + RMAPPlugin0.ProcessPendingEvents() + +def is_MEM_OUT_SM_Empty( ): + ret = 0 + sm_reg = RMAPPlugin0.Read( address_CTRL_SM, 1) + MEM_OUT_SM_Empty = (sm_reg[0] & 0x00000030) >> 4 + if MEM_OUT_SM_Empty == 0x3: + ret = 1 + return ret + +def is_MEM_OUT_SM_Full( ): + ret = 0 + sm_reg = RMAPPlugin0.Read( address_CTRL_SM, 1) + MEM_OUT_SM_Full = (sm_reg[0] & 0x0000000c) >> 2 + if MEM_OUT_SM_Full != 0x0: + ret = 1 + return ret + +def is_MEM_OUT_SM_Full_FIFO_0( ): + ret = 0 + sm_reg = RMAPPlugin0.Read( address_CTRL_SM, 1) + MEM_OUT_SM_Full = (sm_reg[0] & 0x00000004) >> 3 + if MEM_OUT_SM_Full == 0x01: + ret = 1 + return ret + +def is_MEM_OUT_SM_Full_FIFO_1( ): + ret = 0 + sm_reg = RMAPPlugin0.Read( address_CTRL_SM, 1) + MEM_OUT_SM_Full = (sm_reg[0] & 0x00000008) >> 3 + if MEM_OUT_SM_Full == 0x01: + ret = 1 + return ret + +def out_locked_AND_out_reuse_AND_out_ren( ): + # reuse => 0111 1111 1111 1111 + RMAPPlugin0.Write( address_CTRL, [0x00007fff] ) + def convertToSigned16Bits( dataToConvert ): dataInInt16 = np.int16( dataToConvert ) if dataInInt16 < 32768: diff --git a/test_fft/fft_test_functions.pyc b/test_fft/fft_test_functions.pyc index cceafb0e92dcfd656006e12109459644148d6193..0c852343acd8873c1e77b5e2e5a420adb14dbe28 GIT binary patch literal 5786 zc%02x{chV-6u-8UG)cdkbZy5NWegOJv9<%ofNuR*+pS{#kkip=(qyH%H5<5?2=8Sf`yfbjtm1{ohDVTkb|5{4NcCSio}5fVljA0=Uo@i7u|jOR$m zGoB}5obhoI&LN0m;T!<6PvLK~pn)iHxT3^<7|e~O?d@t~-*#rp379A0!0$Uq#w8ez ziHu{NO&qJQ?{s!-u!_#6nhAECfJY#Cn>Nx|paJh84H(MLDl!Y-dyPs(ct!h#kSUnD zm5MJUiDkFis5!C^#G|i8S-M^!x{p5#!;D*(Gxyg_Yjxwn{iU5Pb4ChZT9t~Nfx}Xh zhEtZd>-g8|M{*Q?v@hgt=}@eBZp{>B*W-A9A7L@=qE^PGrQ$g6Ax;f(<|SiK;0sWX zHw}g}9Vs}`5Of|8qsl-cP#^-}Tpo^Qk{u@_HuQ)Hl$<(!)olV@@=6XY5zpF=oV!6> z`L2Wzt3G-twSJr=p25U zC>z&u+6Aqw2bAd{Z8Nx1;!82q)R7k?Ov9-bQHAFWB(O-1w^_j3n0Rv{LDcHU$?Y2?U7Cw4}I^yMp@LZoHau`KSG9<>#<1ik^^g&Mu!3FqI z)F<#e8&EN!oeRmp^F~O<)z{dcPy^)oAavS{A4?QQh}6VKb=bTGttX(6GH!dN^2NA; zvxvzEjGGEEJ;e0EaK+ERLU0P%%HvyPE(5`WwUrIQdQ&HqHWr~q+z#|wT)&KQ@HEGE z3BN)3PfsE4M^>)BFV#v2Y0Z7E0vDQ!}FTc^^Qio3&4kvm9offJoIRsDck0i|=XsYSB{P?ls1 zO+C`2K+^{rBhsWnlL1X4(quu?51J$vO=$#qW&#T5gbbr<0;(s?3^f~8vxJ(Bs9BO` zckihjegeRtx)%$hWFL$sa#H&p9DW6WHsxwuhn*$qmP-ogMQ&)ssCaEqIe{&n?4=ZE!8y*rj`XR}Q1w7R@WejJ!Qv^+M(dU# zEVX2bu-aEEhuc)N(6c(?ApEHA0RmhcUiT5+YJ^;HOdEoOKFPaU8L0>lazkVk45f^# zwT!DOj~>!zqF0lWvdvjnJP@t8-0-Da`;tXFj-*DhV#H$w2MCd7JYsZ;7%kX|P{cr- zEU2mq(Q=?OZviiZUpa)aNQP7yHFVp+9m#i9mL-hu;&3U{k%xFfn(w3fN)Pa3=-9p$ z_XByf5KkOvu>mck$Vjl*_Uro|B@W0KvXwqEY>`4ft3p0V75#0gVj!L>y3)a5M>;^# zY=lF_+D4viDwr5CehqyUBGishhvDzE2lUp1op_{=cb@1Db+R7CSv<_)TJycglW`$b zM$|&g55k{xJW`Id>v|HeE$_#8^=o%qh7ZCuvGgxSL1Y;+S!Wc?L^{kWCSGh_??DLU zS|JeU)_h|SoRJHS9T?qQBs;i>{PoY!FxLYb#=2-gw|n$Yv7o=!BRX05OU}>>7N%ay zg0;53wq?!k{kLSK|4(GhJ$WM;EKUZt3GpJaPjx~iYSmYqej7(bJ7wCws%IA@yvlZ;a~w?M?=ui7o_9G&Ni2vHwy<8)`H5QpfbtY5wU2=%n=S*9fYK#7@e* z#oFE;gk91yy@H|~-I@k03Eq?L>8%ziswZow<{K7kK6B7R_1HBis;RAvT!UH!sLD50 zSbTv4ZcNSj9>C3a`@l`a`KsFm3KL;KI*nTWNUaTnDSX5=*f!X{6rL4qaD;D#Po=j~ zmQ^d+j%BH2h24sYJ5CedZkp$DK=#dP96rPW-%Xg;aQGO9PjL7YhZ{J2hQsHfyO@hO uEcYr);Ckn4E^k!DZCtL8_ZrZ%`iP!MWK!_ygCmm}f>}D#4~P2TEcFMnOGz65 diff --git a/test_fft/pdb matrices spectrales.vhd b/test_fft/pdb matrices spectrales.vhd new file mode 100644 --- /dev/null +++ b/test_fft/pdb matrices spectrales.vhd @@ -0,0 +1,52 @@ +IF apbi.psel(pindex) = '1' THEN + -- APB DMA READ -- + CASE paddr(7 DOWNTO 2) IS + --0 +0x00 WHEN "000000" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f0(31 DOWNTO 0); +0x04 WHEN "000001" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f0(63 DOWNTO 32); +0x08 WHEN "000010" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f0(79 DOWNTO 64); +0XC0 WHEN "000011" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f0; + +0x10 WHEN "000100" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f1(31 DOWNTO 0); +0x14 WHEN "000101" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f1(63 DOWNTO 32); +0x18 WHEN "000110" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f1(79 DOWNTO 64); +0x1C WHEN "000111" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f1; + +0x20 WHEN "001000" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f2(31 DOWNTO 0); +0x24 WHEN "001001" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f2(63 DOWNTO 32); +0x28 WHEN "001010" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f2(79 DOWNTO 64); +0x2C WHEN "001011" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f2; + +0x30 WHEN "001100" => prdata(31 DOWNTO 0) <= MEM_OUT_SM_Data_out(32*1-1 DOWNTO 32*0); +0x34 WHEN "001101" => prdata(31 DOWNTO 0) <= MEM_OUT_SM_Data_out(32*2-1 DOWNTO 32*1); + +0x38 WHEN "001110" => prdata(1 DOWNTO 0) <= reg_ftt.out_ren; + prdata(3 DOWNTO 2) <= MEM_OUT_SM_Full; + prdata(5 DOWNTO 4) <= MEM_OUT_SM_Empty; + WHEN OTHERS => NULL; + + END CASE; + IF (apbi.pwrite AND apbi.penable) = '1' THEN + -- APB DMA WRITE -- + CASE paddr(7 DOWNTO 2) IS +0x00 WHEN "000000" => reg_ftt.in_data_f0(31 DOWNTO 0) <= apbi.pwdata; +0x04 WHEN "000001" => reg_ftt.in_data_f0(63 DOWNTO 32) <= apbi.pwdata; +0x08 WHEN "000010" => reg_ftt.in_data_f0(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0); +0x0c WHEN "000011" => reg_ftt.in_wen_f0 <= apbi.pwdata(4 DOWNTO 0); + +0x10 WHEN "000100" => reg_ftt.in_data_f1(31 DOWNTO 0) <= apbi.pwdata; +0x14 WHEN "000101" => reg_ftt.in_data_f1(63 DOWNTO 32) <= apbi.pwdata; +0x18 WHEN "000110" => reg_ftt.in_data_f1(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0); +0x1c WHEN "000111" => reg_ftt.in_wen_f1 <= apbi.pwdata(4 DOWNTO 0); + +0x20 WHEN "001000" => reg_ftt.in_data_f2(31 DOWNTO 0) <= apbi.pwdata; +0x24 WHEN "001001" => reg_ftt.in_data_f2(63 DOWNTO 32) <= apbi.pwdata; +0x28 WHEN "001010" => reg_ftt.in_data_f2(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0); +0x2C WHEN "001011" => reg_ftt.in_wen_f2 <= apbi.pwdata(4 DOWNTO 0); + +0x38 WHEN "001110" => reg_ftt.out_ren <= apbi.pwdata(1 DOWNTO 0); + + WHEN OTHERS => NULL; + END CASE; + END IF; + END IF; diff --git a/test_fft/pdb matrices spectrales.vhd~ b/test_fft/pdb matrices spectrales.vhd~ new file mode 100644 --- /dev/null +++ b/test_fft/pdb matrices spectrales.vhd~ @@ -0,0 +1,52 @@ +IF apbi.psel(pindex) = '1' THEN + -- APB DMA READ -- + CASE paddr(7 DOWNTO 2) IS + --0 + WHEN "000000" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f0(31 DOWNTO 0); + WHEN "000001" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f0(63 DOWNTO 32); + WHEN "000010" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f0(79 DOWNTO 64); + WHEN "000011" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f0; + + WHEN "000100" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f1(31 DOWNTO 0); + WHEN "000101" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f1(63 DOWNTO 32); + WHEN "000110" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f1(79 DOWNTO 64); + WHEN "000111" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f1; + + WHEN "001000" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f2(31 DOWNTO 0); + WHEN "001001" => prdata(31 DOWNTO 0) <= reg_ftt.in_data_f2(63 DOWNTO 32); + WHEN "001010" => prdata(15 DOWNTO 0) <= reg_ftt.in_data_f2(79 DOWNTO 64); + WHEN "001011" => prdata(4 DOWNTO 0) <= reg_ftt.in_wen_f2; + + WHEN "001100" => prdata(31 DOWNTO 0) <= MEM_OUT_SM_Data_out(32*1-1 DOWNTO 32*0); + WHEN "001101" => prdata(31 DOWNTO 0) <= MEM_OUT_SM_Data_out(32*2-1 DOWNTO 32*1); + + WHEN "001110" => prdata(1 DOWNTO 0) <= reg_ftt.out_ren; + prdata(3 DOWNTO 2) <= MEM_OUT_SM_Full; + prdata(5 DOWNTO 4) <= MEM_OUT_SM_Empty; + WHEN OTHERS => NULL; + + END CASE; + IF (apbi.pwrite AND apbi.penable) = '1' THEN + -- APB DMA WRITE -- + CASE paddr(7 DOWNTO 2) IS + WHEN "000000" => reg_ftt.in_data_f0(31 DOWNTO 0) <= apbi.pwdata; + WHEN "000001" => reg_ftt.in_data_f0(63 DOWNTO 32) <= apbi.pwdata; + WHEN "000010" => reg_ftt.in_data_f0(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0); + WHEN "000011" => reg_ftt.in_wen_f0 <= apbi.pwdata(4 DOWNTO 0); + + WHEN "000100" => reg_ftt.in_data_f1(31 DOWNTO 0) <= apbi.pwdata; + WHEN "000101" => reg_ftt.in_data_f1(63 DOWNTO 32) <= apbi.pwdata; + WHEN "000110" => reg_ftt.in_data_f1(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0); + WHEN "000111" => reg_ftt.in_wen_f1 <= apbi.pwdata(4 DOWNTO 0); + + WHEN "001000" => reg_ftt.in_data_f2(31 DOWNTO 0) <= apbi.pwdata; + WHEN "001001" => reg_ftt.in_data_f2(63 DOWNTO 32) <= apbi.pwdata; + WHEN "001010" => reg_ftt.in_data_f2(79 DOWNTO 64) <= apbi.pwdata(15 DOWNTO 0); + WHEN "001011" => reg_ftt.in_wen_f2 <= apbi.pwdata(4 DOWNTO 0); + + WHEN "001110" => reg_ftt.out_ren <= apbi.pwdata(1 DOWNTO 0); + + WHEN OTHERS => NULL; + END CASE; + END IF; + END IF; diff --git a/test_fft/register_addresses_fft_test.py b/test_fft/register_addresses_fft_test.py --- a/test_fft/register_addresses_fft_test.py +++ b/test_fft/register_addresses_fft_test.py @@ -22,6 +22,11 @@ address_MEM_IN_SM_4 = 0x80000f40 address_CTRL = 0x80000f44 +address_MEM_OUT_SM_0= 0x80000f30 +address_MEM_OUT_SM_1= 0x80000f34 + +address_CTRL_SM = 0x80000f38 + # columnV = 1 columnE1 = 2 diff --git a/test_fft/register_addresses_fft_test.pyc b/test_fft/register_addresses_fft_test.pyc index 880af461873bc9f496d6b1a4d47776d5e954c07a..c8195fb0a098bc7ed166488ee63aa2d3087bd002 GIT binary patch literal 1116 zc${^T%}(1u6orrN{1Fn8kN|;p(M1|E< zc$IGY20U3`pfhd;Lh7+KXTCZ2>gd`U?@uxR>*;BFh1KJzb)r`ETL}ZC)B!nQ7vzFH zkOxkIQs6Ww4bFfv;4CN$&Vh2^EzlM?56XkLLEGR0r~od4ir^j44!8s=fy^Ne?XPL1KFFU;3~+6#bEy z4mZ+YeBa^+7Qb!rJF>9mf1OPRvbNDUzL@=+#8U8OX(K|pGON6+#m)Wg&u=pK%w2!| z5Ud@})+=YPD(!~8UM~`TR?=MD$>yLp5#8a%;B+>gG-Vh`aeXbD%kalMlHpRUW(p&1 k3tj(s_Yfx^-!Az6Cj6prYt&JaapKpt?3&zIy=TYy3vqt&i2wiq diff --git a/test_fft/test_fft_mini_lfr.py b/test_fft/test_fft_mini_lfr.py --- a/test_fft/test_fft_mini_lfr.py +++ b/test_fft/test_fft_mini_lfr.py @@ -7,22 +7,23 @@ import matplotlib.pyplot as plt from test_fft.register_addresses_fft_test import * from test_fft.fft_test_functions import * -print '*' -print '*' -print '*' -print '*' -print '*' +print_custom( '*' ) +print_custom( '*' ) +print_custom( '*' ) +print_custom( '*' ) +print_custom( '*' ) ###################### # GET DATA FROM RECORD -storageDirectory = '/home/paul/data/2014_06_24/' -day = '2014_6_24-' -hour = '9_0_3' -suffix = '.data' +#storageDirectory = '/home/paul/data/2014_06_24/' +#day = '2014_6_24-' +#hour = '9_0_3' +#suffix = '.data' -typeOfData = '_SBM1_CWF_' -cwf_f1 = np.genfromtxt( storageDirectory + day + hour + typeOfData + 'F1' + suffix, - skip_header = 1) +#typeOfData = '_SBM1_CWF_' +#cwf_f1 = np.genfromtxt( storageDirectory + day + hour + typeOfData + 'F1' + suffix, +# skip_header = 1) +cwf_f1 = np.zeros( 1000 ) ################# # BUILD WAVEFORMS @@ -35,8 +36,8 @@ nbSamples = 256 wfrm0 = sineWave( 256, 10, 1000 ) wfrm1 = dirac( 256, 1000 ) wfrm2 = step( 256, 1000 ) -wfrm3 = np.zeros( 256 ) -wfrm4 = np.zeros( 256 ) +wfrm3 = continuous( 256, 100 ) +wfrm4 = continuous( 256, 1000 ) ################ # BUILD THE DATA @@ -44,11 +45,11 @@ dataToWrite0 = generateDataToWrite( nbSa dataToWrite1 = generateDataToWrite( nbSamples, wfrm2, wfrm3 ) dataToWrite2 = generateDataToWrite( nbSamples, wfrm4, np.zeros( nbSamples ) ) +######################## +# WRITE WAVEFORM IN FIFO +print_custom( "1) write waveforms in FIFOs: " + str(len(dataToWrite0)) + " samples" ) print_reg_fft( ) -# WRITE WAVEFORM IN FIFO -print "write waveforms in FIFOs: " + str(len(dataToWrite0)) + " samples" - for k in range(nbSamples): RMAPPlugin0.Write( address_FIFO_F2_1_0, [dataToWrite0[k]] ) RMAPPlugin0.Write( address_FIFO_F2_3_2, [dataToWrite1[k]] ) @@ -56,7 +57,7 @@ for k in range(nbSamples): # write only the FIFO F2 RMAPPlugin0.Write( address_FIFO_F2_WEN, [0xffffffe0] ) -print "data written in FIFOs" +print_custom( "1) data written in FIFOs" ) print_reg_fft( ) @@ -66,13 +67,14 @@ RMAPPlugin0.Write( address_CTRL, [0x0000 # wait for SM_Full fft_reg = RMAPPlugin0.Read( address_CTRL, 1) while (fft_reg[0] & 0x000f8000) == 0: - print "SM not full" + print_custom( "SM not full" ) fft_reg = RMAPPlugin0.Read( address_CTRL, 1) print_reg_fft( ) -# READ FFT -print "read data in fft FIFOs" +################ +# FFT FIRST READ +print_custom( "======= FIRST READ" ) fft0_re = np.zeros( nbSamples ) fft0_im = np.zeros( nbSamples ) fft1_re = np.zeros( nbSamples ) @@ -85,6 +87,8 @@ fft4_re = np.zeros( nbSamples ) fft4_im = np.zeros( nbSamples ) for k in range(128): + # read enable => 0111 1100 0000 0000 + RMAPPlugin0.Write( address_CTRL, [0x00007c00] ) val = RMAPPlugin0.Read( address_MEM_IN_SM_0, 1) fft0_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff ) fft0_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) @@ -100,8 +104,8 @@ for k in range(128): val = RMAPPlugin0.Read( address_MEM_IN_SM_4, 1) fft4_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff ) fft4_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) - # read enable => 0111 1100 0000 0000 - RMAPPlugin0.Write( address_CTRL, [0x00007c00] ) + if is_MEM_IN_SM_Emty( ) == 1: + print_custom( "k = " + str( k ) ) fft0 = fft0_re * fft0_re + fft0_im * fft0_im fft1 = fft1_re * fft1_re + fft1_im * fft1_im @@ -109,7 +113,52 @@ fft2 = fft2_re * fft2_re + fft2_im * fft fft3 = fft3_re * fft3_re + fft3_im * fft3_im fft4 = fft4_re * fft4_re + fft4_im * fft4_im -print "data read in fft FIFOs" +####### +# REUSE +print_custom( "======= REUSE" ) +out_locked_AND_out_reuse_AND_out_ren() +print_reg_fft( ) + +print_custom( "read data in fft FIFOs" ) +fft0_re = np.zeros( nbSamples ) +fft0_im = np.zeros( nbSamples ) +fft1_re = np.zeros( nbSamples ) +fft1_im = np.zeros( nbSamples ) +fft2_re = np.zeros( nbSamples ) +fft2_im = np.zeros( nbSamples ) +fft3_re = np.zeros( nbSamples ) +fft3_im = np.zeros( nbSamples ) +fft4_re = np.zeros( nbSamples ) +fft4_im = np.zeros( nbSamples ) + +for k in range(128): + # read enable => 0111 1100 0000 0000 + val = RMAPPlugin0.Read( address_MEM_IN_SM_0, 1) + fft0_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff ) + fft0_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) + val = RMAPPlugin0.Read( address_MEM_IN_SM_1, 1) + fft1_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff ) + fft1_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) + val = RMAPPlugin0.Read( address_MEM_IN_SM_2, 1) + fft2_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff ) + fft2_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) + val = RMAPPlugin0.Read( address_MEM_IN_SM_3, 1) + fft3_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff ) + fft3_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) + val = RMAPPlugin0.Read( address_MEM_IN_SM_4, 1) + fft4_re[k] = convertToSigned16Bits( val[0] & 0x0000ffff ) + fft4_im[k] = convertToSigned16Bits( ( (val[0] & 0xffff0000) >> 16 ) ) + RMAPPlugin0.Write( address_CTRL, [0x00007c00] ) + if is_MEM_IN_SM_Emty( ) == 1: + print_custom( "k = " + str( k ) ) + +fft0_b = fft0_re * fft0_re + fft0_im * fft0_im +fft1_b = fft1_re * fft1_re + fft1_im * fft1_im +fft2_b = fft2_re * fft2_re + fft2_im * fft2_im +fft3_b = fft3_re * fft3_re + fft3_im * fft3_im +fft4_b = fft4_re * fft4_re + fft4_im * fft4_im + +print_custom( "data read in fft FIFOs" ) print_reg_fft( ) @@ -168,5 +217,16 @@ plt.plot(fft3[0:255], 'c') plt.subplot(235) plt.plot(fft4[0:255], 'm') +plt.figure( 4 ) +plt.subplot(231) +plt.plot(fft0_b[0:255], 'b') +plt.subplot(232) +plt.plot(fft1_b[0:255], 'g') +plt.subplot(233) +plt.plot(fft2_b[0:255], 'r') +plt.subplot(234) +plt.plot(fft3_b[0:255], 'c') +plt.subplot(235) +plt.plot(fft4_b[0:255], 'm') plt.show() \ No newline at end of file diff --git a/test_fft/test_sm_mini_lfr.py b/test_fft/test_sm_mini_lfr.py new file mode 100644 --- /dev/null +++ b/test_fft/test_sm_mini_lfr.py @@ -0,0 +1,150 @@ +import os +os.system('clear') # on linux / os x + +import numpy as np +import matplotlib.pyplot as plt + +from test_fft.register_addresses_fft_test import * +from test_fft.fft_test_functions import * + +print_custom( '*' ) +print_custom( '*' ) +print_custom( '*' ) +print_custom( '*' ) +print_custom( '*' ) + +###################### +# GET DATA FROM RECORD +#storageDirectory = '/home/paul/data/2014_06_24/' +#day = '2014_6_24-' +#hour = '9_0_3' +#suffix = '.data' + +#typeOfData = '_SBM1_CWF_' +#cwf_f1 = np.genfromtxt( storageDirectory + day + hour + typeOfData + 'F1' + suffix, +# skip_header = 1) +cwf_f1 = np.zeros( 1000 ) + +################# +# BUILD WAVEFORMS +nbSamples = 256 +nbComponentsPerMatrix = 25 +nbFrequencyBins = 128 +#wfrm0 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnV ) +#wfrm1 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnE1 ) +#wfrm2 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnE2 ) +#wfrm3 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnB1 ) +#wfrm4 = getWaveFromRecord( cwf_f1, nbSamples, 0, columnB2 ) +wfrm0 = sineWave( 256, 10, 1000 ) +wfrm1 = sineWave( 256, 20, 1000 ) +wfrm2 = sineWave( 256, 30, 1000 ) +wfrm3 = sineWave( 256, 40, 1000 ) +wfrm4 = sineWave( 256, 50, 1000 ) + +################ +# BUILD THE DATA +dataToWrite0 = generateDataToWrite( nbSamples, wfrm0, wfrm1 ) +dataToWrite1 = generateDataToWrite( nbSamples, wfrm2, wfrm3 ) +dataToWrite2 = generateDataToWrite( nbSamples, wfrm4, np.zeros( nbSamples ) ) + +######################## +# WRITE WAVEFORM IN FIFO +print_custom( "1) write waveforms in FIFOs: " + str(len(dataToWrite0)) + " samples" ) +print_reg_sm( ) + +for k in range(nbSamples): + RMAPPlugin0.Write( address_FIFO_F2_1_0, [dataToWrite0[k]] ) + RMAPPlugin0.Write( address_FIFO_F2_3_2, [dataToWrite1[k]] ) + RMAPPlugin0.Write( address_FIFO_F2_4, [dataToWrite2[k]] ) + # write only the FIFO F2 + RMAPPlugin0.Write( address_FIFO_F2_WEN, [0xffffffe0] ) + +print_custom( "1) data written in FIFOs" ) + +print_reg_sm( ) + +# wait for SM_OUT_Full +while ( is_MEM_OUT_SM_Full() ) == 0: + print_custom( "SM not full" ) + +print_reg_sm( ) + +################ +# SM FIRST READ +print_custom( "======= SM FIRST READ" ) + +components = [] + +if is_MEM_OUT_SM_Full_FIFO_0(): + print_custom( "FIFO_0 is full" ) + address_MEM_OUT_SM = address_MEM_OUT_SM_0 +elif is_MEM_OUT_SM_Full_FIFO_1(): + print_custom( "FIFO_1 is full") + address_MEM_OUT_SM = address_MEM_OUT_SM_1 +else: + print_custom( "/!\ no MEM_OUT_SM FIFO full /!\ " ) + +for component in range(nbComponentsPerMatrix): + print_custom( "component = " + str( component ) ) + currentComp = np.zeros( nbFrequencyBins ) + for frequencyBin in range(nbFrequencyBins): + # read enable => 0000 0000 0000 0000 + if is_MEM_OUT_SM_Empty( ) == 1: + print_custom( "component = " + str( component ) \ + + " bin = " + str( frequencyBin ) ) + val = RMAPPlugin0.Read( address_MEM_OUT_SM, 1) + RMAPPlugin0.Write( address_CTRL_SM, [0x00000000] ) + currentComp[frequencyBin] = val[0] + RMAPPlugin0.ProcessPendingEvents() + components.append( currentComp ) + +# PLOT SM + +plt.figure( 1 ) +plt.subplot(231) +plt.plot(wfrm0, 'b') +plt.subplot(232) +plt.plot(wfrm1, 'g') +plt.plot(wfrm1, '.') +plt.subplot(233) +plt.plot(wfrm2, 'r') +plt.plot(wfrm2, '.') +plt.subplot(234) +plt.plot(wfrm3, 'c') +plt.subplot(235) +plt.plot(wfrm4, 'm') + +plt.figure( 2 ) +plt.subplot(231) +plt.plot(components[0][:]) +plt.plot(components[1][:]) +plt.plot(components[2][:]) +plt.plot(components[3][:]) +plt.subplot(232) +plt.plot(components[4][:]) +plt.plot(components[5][:]) +plt.plot(components[6][:]) +plt.plot(components[7][:]) +plt.subplot(233) +plt.plot(components[8][:]) +plt.plot(components[9][:]) +plt.plot(components[10][:]) +plt.plot(components[11][:]) +plt.subplot(234) +plt.plot(components[12][:]) +plt.plot(components[13][:]) +plt.plot(components[14][:]) +plt.plot(components[15][:]) +plt.subplot(235) +plt.plot(components[16][:]) +plt.plot(components[17][:]) +plt.plot(components[18][:]) +plt.plot(components[19][:]) +plt.subplot(236) +plt.plot(components[20][:]) +plt.plot(components[21][:]) +plt.plot(components[22][:]) +plt.plot(components[23][:]) +plt.plot(components[24][:]) + +plt.show() \ No newline at end of file