##// END OF EJS Templates
Improved testbench for LFR's F0 IIR Filter, now processed input is read from...
Jeandet Alexis -
r642:d1feb5a41a44 default draft
parent child
Show More
@@ -0,0 +1,60
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 8,
6 "metadata": {
7 "collapsed": true
8 },
9 "outputs": [],
10 "source": [
11 "import numpy as np\n",
12 "import matplotlib.pyplot as plt\n",
13 "import random"
14 ]
15 },
16 {
17 "cell_type": "code",
18 "execution_count": 32,
19 "metadata": {
20 "collapsed": false
21 },
22 "outputs": [],
23 "source": [
24 "W,H=8,1000\n",
25 "test = np.ones((H,W))*[(random.random()*65535)-32768 for col in range(W)]\n",
26 "np.savetxt(\"input.txt\", test,fmt=\"%d\", delimiter=\" \")"
27 ]
28 },
29 {
30 "cell_type": "code",
31 "execution_count": 28,
32 "metadata": {
33 "collapsed": false
34 },
35 "outputs": [],
36 "source": []
37 }
38 ],
39 "metadata": {
40 "kernelspec": {
41 "display_name": "Python 3",
42 "language": "python",
43 "name": "python3"
44 },
45 "language_info": {
46 "codemirror_mode": {
47 "name": "ipython",
48 "version": 3
49 },
50 "file_extension": ".py",
51 "mimetype": "text/x-python",
52 "name": "python",
53 "nbconvert_exporter": "python",
54 "pygments_lexer": "ipython3",
55 "version": "3.5.2"
56 }
57 },
58 "nbformat": 4,
59 "nbformat_minor": 1
60 }
@@ -0,0 +1,53
1 LIBRARY ieee;
2 USE ieee.std_logic_1164.ALL;
3 USE ieee.numeric_std.ALL;
4
5 LIBRARY std;
6 USE std.textio.ALL;
7
8 LIBRARY lpp;
9 USE lpp.data_type_pkg.ALL;
10
11 ENTITY sig_reader IS
12 GENERIC(
13 FNAME : STRING := "input.txt";
14 WIDTH : INTEGER := 1;
15 RESOLUTION : INTEGER := 8;
16 GAIN : REAL := 1.0
17 );
18 PORT(
19 clk : IN std_logic;
20 end_of_simu : out std_logic;
21 out_signal : out sample_vector(0 to WIDTH-1,RESOLUTION-1 downto 0)
22 );
23 END sig_reader;
24
25 ARCHITECTURE beh OF sig_reader IS
26 FILE input_file : TEXT OPEN read_mode IS FNAME;
27 SIGNAL out_signal_reg : sample_vector(0 to WIDTH-1,RESOLUTION-1 downto 0):=(others=>(others=>'0'));
28 SIGNAL end_of_simu_reg : std_logic:='0';
29 BEGIN
30 out_signal <= out_signal_reg;
31 end_of_simu <= end_of_simu_reg;
32 PROCESS
33 VARIABLE line_var : LINE;
34 VARIABLE value : INTEGER;
35 VARIABLE cell : STD_LOGIC_VECTOR(RESOLUTION-1 downto 0);
36 BEGIN
37 WAIT UNTIL clk = '1';
38 IF endfile(input_file) THEN
39 end_of_simu_reg <= '1';
40 ELSE
41 end_of_simu_reg <= '0';
42 readline(input_file,line_var);
43 FOR COL IN 0 TO WIDTH-1 LOOP
44 read(line_var, value);
45 cell := std_logic_vector(to_signed(INTEGER(GAIN*REAL(value)) , RESOLUTION));
46 FOR bit_idx IN RESOLUTION-1 downto 0 LOOP
47 out_signal_reg(COL,bit_idx) <= cell(bit_idx);
48 END LOOP;
49 END LOOP;
50 END IF;
51 END PROCESS;
52
53 END beh;
@@ -1,61 +1,61
1 #GRLIB=../..
1 #GRLIB=../..
2 VHDLIB=../..
2 VHDLIB=../..
3 SCRIPTSDIR=$(VHDLIB)/scripts/
3 SCRIPTSDIR=$(VHDLIB)/scripts/
4 GRLIB := $(shell sh $(VHDLIB)/scripts/lpp_relpath.sh)
4 GRLIB := $(shell sh $(VHDLIB)/scripts/lpp_relpath.sh)
5 TOP=testbench
5 TOP=testbench
6 BOARD=LFR-EQM
6 BOARD=LFR-EQM
7 include $(VHDLIB)/boards/$(BOARD)/Makefile_RTAX.inc
7 include $(VHDLIB)/boards/$(BOARD)/Makefile_RTAX.inc
8 DEVICE=$(PART)-$(PACKAGE)$(SPEED)
8 DEVICE=$(PART)-$(PACKAGE)$(SPEED)
9 UCF=$(GRLIB)/boards/$(BOARD)/$(TOP).ucf
9 UCF=$(GRLIB)/boards/$(BOARD)/$(TOP).ucf
10 QSF=$(GRLIB)/boards/$(BOARD)/$(TOP).qsf
10 QSF=$(GRLIB)/boards/$(BOARD)/$(TOP).qsf
11 EFFORT=high
11 EFFORT=high
12 XSTOPT=
12 XSTOPT=
13 SYNPOPT="set_option -pipe 0; set_option -retiming 0; set_option -write_apr_constraint 0"
13 SYNPOPT="set_option -pipe 0; set_option -retiming 0; set_option -write_apr_constraint 0"
14 #VHDLSYNFILES=config.vhd ahbrom.vhd leon3mp.vhd
14 #VHDLSYNFILES=config.vhd ahbrom.vhd leon3mp.vhd
15 VHDLSYNFILES= IIR_CEL_TEST.vhd tb.vhd IIR_CEL_TEST_v3.vhd generator.vhd
15 VHDLSYNFILES= IIR_CEL_TEST.vhd tb.vhd IIR_CEL_TEST_v3.vhd generator.vhd sig_reader.vhd
16 VHDLSIMFILES= tb.vhd
16 VHDLSIMFILES= tb.vhd sig_reader.vhd
17 SIMTOP=testbench
17 SIMTOP=testbench
18 #SDCFILE=$(GRLIB)/boards/$(BOARD)/synplify.sdc
18 #SDCFILE=$(GRLIB)/boards/$(BOARD)/synplify.sdc
19 PDC=$(VHDLIB)/boards/$(BOARD)/LFR_EQM_RTAX.pdc
19 PDC=$(VHDLIB)/boards/$(BOARD)/LFR_EQM_RTAX.pdc
20 SDC=$(VHDLIB)/boards/$(BOARD)/LFR_EQM_altran_syn_fanout.sdc
20 SDC=$(VHDLIB)/boards/$(BOARD)/LFR_EQM_altran_syn_fanout.sdc
21 BITGEN=$(GRLIB)/boards/$(BOARD)/default.ut
21 BITGEN=$(GRLIB)/boards/$(BOARD)/default.ut
22 CLEAN=soft-clean
22 CLEAN=soft-clean
23
23
24 TECHLIBS = axcelerator
24 TECHLIBS = axcelerator
25
25
26 LIBSKIP = core1553bbc core1553brm core1553brt gr1553 corePCIF \
26 LIBSKIP = core1553bbc core1553brm core1553brt gr1553 corePCIF \
27 tmtc openchip hynix ihp gleichmann micron usbhc opencores
27 tmtc openchip hynix ihp gleichmann micron usbhc opencores
28
28
29 DIRSKIP = b1553 pcif leon2 leon3v3 leon2ft crypto satcan ddr usb ata i2c \
29 DIRSKIP = b1553 pcif leon2 leon3v3 leon2ft crypto satcan ddr usb ata i2c \
30 pci grusbhc haps slink ascs can pwm greth coremp7 spi ac97 \
30 pci grusbhc haps slink ascs can pwm greth coremp7 spi ac97 \
31 ./dsp/lpp_fft_rtax \
31 ./dsp/lpp_fft_rtax \
32 ./amba_lcd_16x2_ctrlr \
32 ./amba_lcd_16x2_ctrlr \
33 ./general_purpose/lpp_AMR \
33 ./general_purpose/lpp_AMR \
34 ./general_purpose/lpp_balise \
34 ./general_purpose/lpp_balise \
35 ./general_purpose/lpp_delay \
35 ./general_purpose/lpp_delay \
36 ./lpp_bootloader \
36 ./lpp_bootloader \
37 ./lfr_management \
37 ./lfr_management \
38 ./lpp_sim \
38 ./lpp_sim \
39 ./lpp_sim/CY7C1061DV33 \
39 ./lpp_sim/CY7C1061DV33 \
40 ./lpp_cna \
40 ./lpp_cna \
41 ./lpp_uart \
41 ./lpp_uart \
42 ./lpp_usb \
42 ./lpp_usb \
43 ./dsp/lpp_fft \
43 ./dsp/lpp_fft \
44 ./lpp_leon3_soc \
44 ./lpp_leon3_soc \
45 ./lpp_debug_lfr
45 ./lpp_debug_lfr
46
46
47 FILESKIP = i2cmst.vhd \
47 FILESKIP = i2cmst.vhd \
48 APB_MULTI_DIODE.vhd \
48 APB_MULTI_DIODE.vhd \
49 APB_MULTI_DIODE.vhd \
49 APB_MULTI_DIODE.vhd \
50 Top_MatrixSpec.vhd \
50 Top_MatrixSpec.vhd \
51 APB_FFT.vhd \
51 APB_FFT.vhd \
52 lpp_lfr_ms_FFT.vhd \
52 lpp_lfr_ms_FFT.vhd \
53 lpp_lfr_apbreg.vhd \
53 lpp_lfr_apbreg.vhd \
54 CoreFFT.vhd \
54 CoreFFT.vhd \
55 lpp_lfr_ms.vhd
55 lpp_lfr_ms.vhd
56
56
57 include $(GRLIB)/bin/Makefile
57 include $(GRLIB)/bin/Makefile
58 include $(GRLIB)/software/leon3/Makefile
58 include $(GRLIB)/software/leon3/Makefile
59
59
60 ################## project specific targets ##########################
60 ################## project specific targets ##########################
61
61
@@ -1,74 +1,74
1 ------------------------------------------------------------------------------
1 ------------------------------------------------------------------------------
2 -- This file is a part of the LPP VHDL IP LIBRARY
2 -- This file is a part of the LPP VHDL IP LIBRARY
3 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
18 -------------------------------------------------------------------------------
19 -- Author : Jean-christophe Pellion
19 -- Author : Jean-christophe Pellion
20 -- Mail : jean-christophe.pellion@lpp.polytechnique.fr
20 -- Mail : jean-christophe.pellion@lpp.polytechnique.fr
21 -- jean-christophe.pellion@easii-ic.com
21 -- jean-christophe.pellion@easii-ic.com
22 ----------------------------------------------------------------------------
22 ----------------------------------------------------------------------------
23
23
24 LIBRARY ieee;
24 LIBRARY ieee;
25 USE ieee.std_logic_1164.ALL;
25 USE ieee.std_logic_1164.ALL;
26 use ieee.numeric_std.all;
26 use ieee.numeric_std.all;
27 USE IEEE.std_logic_signed.ALL;
27 USE IEEE.std_logic_signed.ALL;
28 USE IEEE.MATH_real.ALL;
28 USE IEEE.MATH_real.ALL;
29
29
30 ENTITY generator IS
30 ENTITY generator IS
31
31
32 GENERIC (
32 GENERIC (
33 AMPLITUDE : INTEGER := 100;
33 AMPLITUDE : INTEGER := 100;
34 NB_BITS : INTEGER := 16);
34 NB_BITS : INTEGER := 16
35 );
35
36
36 PORT (
37 PORT (
37 clk : IN STD_LOGIC;
38 clk : IN STD_LOGIC;
38 rstn : IN STD_LOGIC;
39 rstn : IN STD_LOGIC;
39 run : IN STD_LOGIC;
40 run : IN STD_LOGIC;
40
41
41 data_ack : IN STD_LOGIC;
42 data_ack : IN STD_LOGIC;
42 offset : IN STD_LOGIC_VECTOR(NB_BITS-1 DOWNTO 0);
43 offset : IN STD_LOGIC_VECTOR(NB_BITS-1 DOWNTO 0);
43 data : OUT STD_LOGIC_VECTOR(NB_BITS-1 DOWNTO 0)
44 data : OUT STD_LOGIC_VECTOR(NB_BITS-1 DOWNTO 0)
44 );
45 );
45
46
46 END generator;
47 END generator;
47
48
48 ARCHITECTURE beh OF generator IS
49 ARCHITECTURE beh OF generator IS
49
50
50 SIGNAL reg : STD_LOGIC_VECTOR(NB_BITS-1 DOWNTO 0);
51 SIGNAL reg : STD_LOGIC_VECTOR(NB_BITS-1 DOWNTO 0);
51 BEGIN -- beh
52 BEGIN -- beh
52
53
53
54 PROCESS (clk, rstn)
54 PROCESS (clk, rstn)
55 variable seed1, seed2: positive; -- seed values for random generator
55 variable seed1, seed2: positive; -- seed values for random generator
56 variable rand: real; -- random real-number value in range 0 to 1.0
56 variable rand: real; -- random real-number value in range 0 to 1.0
57 BEGIN -- PROCESS
57 BEGIN -- PROCESS
58 uniform(seed1, seed2, rand);--more entropy by skipping values
58 uniform(seed1, seed2, rand);--more entropy by skipping values
59 IF rstn = '0' THEN -- asynchronous reset (active low)
59 IF rstn = '0' THEN -- asynchronous reset (active low)
60 reg <= (OTHERS => '0');
60 reg <= (OTHERS => '0');
61 ELSIF clk'event AND clk = '1' THEN -- rising clock edge
61 ELSIF clk'event AND clk = '1' THEN -- rising clock edge
62 IF run = '0' THEN
62 IF run = '0' THEN
63 reg <= (OTHERS => '0');
63 reg <= (OTHERS => '0');
64 ELSE
64 ELSE
65 IF data_ack = '1' THEN
65 IF data_ack = '1' THEN
66 reg <= std_logic_vector(to_signed(INTEGER( (REAL(AMPLITUDE) * rand) + REAL(to_integer(SIGNED(offset))) ),NB_BITS));
66 reg <= std_logic_vector(to_signed(INTEGER( (REAL(AMPLITUDE) * rand) + REAL(to_integer(SIGNED(offset))) ),NB_BITS));
67 END IF;
67 END IF;
68 END IF;
68 END IF;
69 END IF;
69 END IF;
70 END PROCESS;
70 END PROCESS;
71
71
72 data <= reg;
72 data <= reg;
73
73
74 END beh;
74 END beh;
@@ -1,232 +1,233
1
1
2 LIBRARY ieee;
2 LIBRARY ieee;
3 USE ieee.std_logic_1164.ALL;
3 USE ieee.std_logic_1164.ALL;
4 USE ieee.numeric_std.ALL;
4 USE ieee.numeric_std.ALL;
5 USE IEEE.std_logic_signed.ALL;
5 USE IEEE.std_logic_signed.ALL;
6 USE IEEE.MATH_real.ALL;
6 USE IEEE.MATH_real.ALL;
7
7
8 LIBRARY techmap;
8 LIBRARY techmap;
9 USE techmap.gencomp.ALL;
9 USE techmap.gencomp.ALL;
10
10
11 LIBRARY std;
11 LIBRARY std;
12 USE std.textio.ALL;
12 USE std.textio.ALL;
13
13
14 LIBRARY lpp;
14 LIBRARY lpp;
15 USE lpp.iir_filter.ALL;
15 USE lpp.iir_filter.ALL;
16 USE lpp.lpp_ad_conv.ALL;
16 USE lpp.lpp_ad_conv.ALL;
17 USE lpp.FILTERcfg.ALL;
17 USE lpp.FILTERcfg.ALL;
18 USE lpp.lpp_lfr_filter_coeff.ALL;
18 USE lpp.lpp_lfr_filter_coeff.ALL;
19 USE lpp.general_purpose.ALL;
19 USE lpp.general_purpose.ALL;
20 USE lpp.data_type_pkg.ALL;
20 USE lpp.data_type_pkg.ALL;
21 USE lpp.lpp_lfr_pkg.ALL;
21 USE lpp.lpp_lfr_pkg.ALL;
22 USE lpp.general_purpose.ALL;
22 USE lpp.general_purpose.ALL;
23
23
24 ENTITY testbench IS
24 ENTITY testbench IS
25 GENERIC(
25 GENERIC(
26 tech : INTEGER := 0; --axcel,
26 tech : INTEGER := 0; --axcel,0
27 Mem_use : INTEGER := use_CEL --use_RAM
27 Mem_use : INTEGER := use_CEL --use_RAM,use_CEL
28 );
28 );
29 END;
29 END;
30
30
31 ARCHITECTURE behav OF testbench IS
31 ARCHITECTURE behav OF testbench IS
32 CONSTANT ChanelCount : INTEGER := 8;
32 CONSTANT ChanelCount : INTEGER := 8;
33 CONSTANT Coef_SZ : INTEGER := 9;
33 CONSTANT Coef_SZ : INTEGER := 9;
34 CONSTANT CoefCntPerCel : INTEGER := 6;
34 CONSTANT CoefCntPerCel : INTEGER := 6;
35 CONSTANT CoefPerCel : INTEGER := 5;
35 CONSTANT CoefPerCel : INTEGER := 5;
36 CONSTANT Cels_count : INTEGER := 5;
36 CONSTANT Cels_count : INTEGER := 5;
37
37
38 SIGNAL sample : samplT(ChanelCount-1 DOWNTO 0, 17 DOWNTO 0);
38 SIGNAL sample : samplT(ChanelCount-1 DOWNTO 0, 17 DOWNTO 0);
39 SIGNAL sample_val : STD_LOGIC;
39 SIGNAL sample_val : STD_LOGIC;
40
40
41 SIGNAL sample_fx : samplT(ChanelCount-1 DOWNTO 0, 17 DOWNTO 0);
41 SIGNAL sample_fx : samplT(ChanelCount-1 DOWNTO 0, 17 DOWNTO 0);
42 SIGNAL sample_fx_val : STD_LOGIC;
42 SIGNAL sample_fx_val : STD_LOGIC;
43
43
44
44
45
45
46
46
47
47
48
48
49 SIGNAL TSTAMP : INTEGER := 0;
49 SIGNAL TSTAMP : INTEGER := 0;
50 SIGNAL clk : STD_LOGIC := '0';
50 SIGNAL clk : STD_LOGIC := '0';
51 SIGNAL clk_24k : STD_LOGIC := '0';
51 SIGNAL clk_24k : STD_LOGIC := '0';
52 SIGNAL clk_24k_r : STD_LOGIC := '0';
52 SIGNAL clk_24k_r : STD_LOGIC := '0';
53 SIGNAL rstn : STD_LOGIC;
53 SIGNAL rstn : STD_LOGIC;
54
54
55 SIGNAL signal_gen : Samples(7 DOWNTO 0);
55 SIGNAL signal_gen : sample_vector(0 to ChanelCount-1,17 downto 0);
56 SIGNAL offset_gen : Samples(7 DOWNTO 0);
57
56
58 --SIGNAL sample_fx_wdata : STD_LOGIC_VECTOR((6*16)-1 DOWNTO 0);
57 --SIGNAL sample_fx_wdata : STD_LOGIC_VECTOR((6*16)-1 DOWNTO 0);
59
58
60 SIGNAL sample_fx_wdata : Samples(ChanelCount-1 DOWNTO 0);
59 SIGNAL sample_fx_wdata : Samples(ChanelCount-1 DOWNTO 0);
61
60
62
61
63 COMPONENT generator IS
62 COMPONENT generator IS
64 GENERIC (
63 GENERIC (
65 AMPLITUDE : INTEGER := 100;
64 AMPLITUDE : INTEGER := 100;
66 NB_BITS : INTEGER := 16);
65 NB_BITS : INTEGER := 16);
67
66
68 PORT (
67 PORT (
69 clk : IN STD_LOGIC;
68 clk : IN STD_LOGIC;
70 rstn : IN STD_LOGIC;
69 rstn : IN STD_LOGIC;
71 run : IN STD_LOGIC;
70 run : IN STD_LOGIC;
72
71
73 data_ack : IN STD_LOGIC;
72 data_ack : IN STD_LOGIC;
74 offset : IN STD_LOGIC_VECTOR(NB_BITS-1 DOWNTO 0);
73 offset : IN STD_LOGIC_VECTOR(NB_BITS-1 DOWNTO 0);
75 data : OUT STD_LOGIC_VECTOR(NB_BITS-1 DOWNTO 0)
74 data : OUT STD_LOGIC_VECTOR(NB_BITS-1 DOWNTO 0)
76 );
75 );
77 END COMPONENT;
76 END COMPONENT;
78
77
78 COMPONENT sig_reader IS
79 GENERIC(
80 FNAME : STRING := "input.txt";
81 WIDTH : INTEGER := 1;
82 RESOLUTION : INTEGER := 8;
83 GAIN : REAL := 1.0
84 );
85 PORT(
86 clk : IN std_logic;
87 end_of_simu : out std_logic;
88 out_signal : out sample_vector(0 to WIDTH-1,RESOLUTION-1 downto 0)
89 );
90 END COMPONENT;
79
91
80 FILE log_input : TEXT OPEN write_mode IS "log_input.txt";
92
81 FILE log_output_fx : TEXT OPEN write_mode IS "log_output_fx.txt";
93 FILE input : TEXT OPEN read_mode IS "input.txt";
94 FILE output_fx : TEXT OPEN write_mode IS "output_fx.txt";
82
95
83 SIGNAL end_of_simu : STD_LOGIC := '0';
96 SIGNAL end_of_simu : STD_LOGIC := '0';
84
97
85 BEGIN
98 BEGIN
86
99
87 -----------------------------------------------------------------------------
100 -----------------------------------------------------------------------------
88 -- CLOCK and RESET
101 -- CLOCK and RESET
89 -----------------------------------------------------------------------------
102 -----------------------------------------------------------------------------
90 clk <= NOT clk AFTER 5 ns;
103 clk <= NOT clk AFTER 20 ns;
91 PROCESS
104 PROCESS
92 BEGIN -- PROCESS
105 BEGIN -- PROCESS
93 end_of_simu <= '0';
94 WAIT UNTIL clk = '1';
106 WAIT UNTIL clk = '1';
95 rstn <= '0';
107 rstn <= '0';
96 WAIT UNTIL clk = '1';
108 WAIT UNTIL clk = '1';
97 WAIT UNTIL clk = '1';
109 WAIT UNTIL clk = '1';
98 WAIT UNTIL clk = '1';
110 WAIT UNTIL clk = '1';
99 rstn <= '1';
111 rstn <= '1';
100 WAIT FOR 2000 ms;
112 WAIT UNTIL end_of_simu = '1';
101 end_of_simu <= '1';
102 WAIT UNTIL clk = '1';
113 WAIT UNTIL clk = '1';
103 REPORT "*** END simulation ***" SEVERITY failure;
114 REPORT "*** END simulation ***" SEVERITY failure;
104 WAIT;
115 WAIT;
105 END PROCESS;
116 END PROCESS;
106 -----------------------------------------------------------------------------
117 -----------------------------------------------------------------------------
107
118
108
119
109 -----------------------------------------------------------------------------
120 -----------------------------------------------------------------------------
110 -- COMMON TIMESTAMPS
121 -- COMMON TIMESTAMPS
111 -----------------------------------------------------------------------------
122 -----------------------------------------------------------------------------
112
123
113 PROCESS(clk)
124 PROCESS(clk)
114 BEGIN
125 BEGIN
115 IF clk'EVENT AND clk = '1' THEN
126 IF clk'EVENT AND clk = '1' THEN
116 TSTAMP <= TSTAMP+1;
127 TSTAMP <= TSTAMP+1;
117 END IF;
128 END IF;
118 END PROCESS;
129 END PROCESS;
119 -----------------------------------------------------------------------------
130 -----------------------------------------------------------------------------
120
131
121
132
122 -----------------------------------------------------------------------------
133 -----------------------------------------------------------------------------
123 -- LPP_LFR_FILTER f0
134 -- LPP_LFR_FILTER f0
124 -----------------------------------------------------------------------------
135 -----------------------------------------------------------------------------
125
136
126 IIR_CEL_CTRLR_v2_1 : IIR_CEL_CTRLR_v2
137 IIR_CEL_CTRLR_v2_1 : IIR_CEL_CTRLR_v2
127 GENERIC MAP (
138 GENERIC MAP (
128 tech => tech,
139 tech => tech,
129 Mem_use => use_RAM,
140 Mem_use => use_RAM,
130 Sample_SZ => 18,
141 Sample_SZ => 18,
131 Coef_SZ => Coef_SZ,
142 Coef_SZ => Coef_SZ,
132 Coef_Nb => 25,
143 Coef_Nb => 25,
133 Coef_sel_SZ => 5,
144 Coef_sel_SZ => 5,
134 Cels_count => Cels_count,
145 Cels_count => Cels_count,
135 ChanelsCount => ChanelCount,
146 ChanelsCount => ChanelCount,
136 FILENAME => "RAM.txt")
147 FILENAME => "")
137 PORT MAP (
148 PORT MAP (
138 rstn => rstn,
149 rstn => rstn,
139 clk => clk,
150 clk => clk,
140 virg_pos => 7,
151 virg_pos => 7,
141 coefs => CoefsInitValCst_v2,
152 coefs => CoefsInitValCst_v2,
142
153
143 sample_in_val => sample_val,
154 sample_in_val => sample_val,
144 sample_in => sample,
155 sample_in => sample,
145 sample_out_val => sample_fx_val,
156 sample_out_val => sample_fx_val,
146 sample_out => sample_fx);
157 sample_out => sample_fx);
147 -----------------------------------------------------------------------------
158 -----------------------------------------------------------------------------
148
159
149
160
150 -----------------------------------------------------------------------------
161 -----------------------------------------------------------------------------
151 -- SAMPLE GENERATION
162 -- SAMPLE GENERATION
152 -----------------------------------------------------------------------------
163 -----------------------------------------------------------------------------
153 clk_24k <= NOT clk_24k AFTER 20345 ns;
164 clk_24k <= NOT clk_24k AFTER 20345 ns;
154
165
155 PROCESS (clk, rstn)
166 PROCESS (clk, rstn)
156 BEGIN -- PROCESS
167 BEGIN -- PROCESS
157 IF rstn = '0' THEN -- asynchronous reset (active low)
168 IF rstn = '0' THEN -- asynchronous reset (active low)
158 sample_val <= '0';
169 sample_val <= '0';
159 clk_24k_r <= '0';
170 clk_24k_r <= '0';
160 ELSIF clk'EVENT AND clk = '1' THEN -- rising clock edge
171 ELSIF clk'EVENT AND clk = '1' THEN -- rising clock edge
161 clk_24k_r <= clk_24k;
172 clk_24k_r <= clk_24k;
162 IF clk_24k = '1' AND clk_24k_r = '0' THEN
173 IF clk_24k = '1' AND clk_24k_r = '0' THEN
163 sample_val <= '1';
174 sample_val <= '1';
164 ELSE
175 ELSE
165 sample_val <= '0';
176 sample_val <= '0';
166 END IF;
177 END IF;
167 END IF;
178 END IF;
168 END PROCESS;
179 END PROCESS;
169 -----------------------------------------------------------------------------
180 -----------------------------------------------------------------------------
170 generators : FOR I IN 0 TO 7 GENERATE
171 gen1 : generator
172 GENERIC MAP (
173 AMPLITUDE => 100,
174 NB_BITS => 16)
175 PORT MAP (
176 clk => clk,
177 rstn => rstn,
178 run => '1',
179 data_ack => sample_val,
180 offset => offset_gen(I),
181 data => signal_gen(I)
182 );
183 offset_gen(I) <= STD_LOGIC_VECTOR(to_signed((I*200), 16));
184 END GENERATE generators;
185
181
186 ChanelLoop : FOR i IN 0 TO ChanelCount-1 GENERATE
182 ChanelLoop : FOR i IN 0 TO ChanelCount-1 GENERATE
187 SampleLoop : FOR j IN 0 TO 15 GENERATE
183 SampleLoop : FOR j IN 0 TO 15 GENERATE
188 sample(i,j) <= signal_gen(i)(j);
189 sample_fx_wdata(i)(j) <= sample_fx(i,j);
184 sample_fx_wdata(i)(j) <= sample_fx(i,j);
185 sample(i,j) <= signal_gen(i,j);
190 END GENERATE;
186 END GENERATE;
191
187 sample(i,16) <= signal_gen(i,16);
192 sample(i, 16) <= signal_gen(i)(15);
188 sample(i,17) <= signal_gen(i,17);
193 sample(i, 17) <= signal_gen(i)(15);
194 END GENERATE;
189 END GENERATE;
195
190
196
191
197
192
198 -----------------------------------------------------------------------------
193 -----------------------------------------------------------------------------
199 -- RECORD SIGNALS
194 -- READ INPUT SIGNALS
200 -----------------------------------------------------------------------------
195 -----------------------------------------------------------------------------
201
196
202 -- PROCESS(sample_val)
197 gen: sig_reader
203 -- VARIABLE line_var : LINE;
198 GENERIC MAP(
204 -- BEGIN
199 FNAME => "input.txt",
205 -- IF sample_val'EVENT AND sample_val = '1' THEN
200 WIDTH => ChanelCount,
206 -- write(line_var, INTEGER'IMAGE(TSTAMP));
201 RESOLUTION => 18,
207 -- FOR I IN 0 TO 7 LOOP
202 GAIN => 1.0
208 -- write(line_var, " " & INTEGER'IMAGE(to_integer(SIGNED(signal_gen(I)))));
203 )
209 -- END LOOP;
204 PORT MAP(
210 -- writeline(log_input, line_var);
205 clk => sample_val,
211 -- END IF;
206 end_of_simu => end_of_simu,
212 -- END PROCESS;
207 out_signal => signal_gen
208 );
209
210
211 -----------------------------------------------------------------------------
212 -- RECORD OUTPUT SIGNALS
213 -----------------------------------------------------------------------------
213
214
214 PROCESS(sample_fx_val,end_of_simu)
215 PROCESS(sample_fx_val,end_of_simu)
215 VARIABLE line_var : LINE;
216 VARIABLE line_var : LINE;
216 BEGIN
217 BEGIN
217 IF sample_fx_val'EVENT AND sample_fx_val = '1' THEN
218 IF sample_fx_val'EVENT AND sample_fx_val = '1' THEN
218 write(line_var, INTEGER'IMAGE(TSTAMP));
219 write(line_var, INTEGER'IMAGE(TSTAMP));
219 FOR I IN 0 TO 5 LOOP
220 FOR I IN 0 TO 5 LOOP
220 write(line_var, " " & INTEGER'IMAGE(to_integer(SIGNED(sample_fx_wdata(I)))));
221 write(line_var, " " & INTEGER'IMAGE(to_integer(SIGNED(sample_fx_wdata(I)))));
221 END LOOP;
222 END LOOP;
222 writeline(log_output_fx, line_var);
223 writeline(output_fx, line_var);
223 END IF;
224 END IF;
224 IF end_of_simu = '1' THEN
225 IF end_of_simu = '1' THEN
225 file_close(log_output_fx);
226 file_close(output_fx);
226 END IF;
227 END IF;
227 END PROCESS;
228 END PROCESS;
228
229
229
230
230
231
231
232
232 END;
233 END;
@@ -1,140 +1,142
1 ------------------------------------------------------------------------------
1 ------------------------------------------------------------------------------
2 -- This file is a part of the LPP VHDL IP LIBRARY
2 -- This file is a part of the LPP VHDL IP LIBRARY
3 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ------------------------------------------------------------------------------
18 ------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ------------------------------------------------------------------------------
21 ------------------------------------------------------------------------------
22 LIBRARY ieee;
22 LIBRARY ieee;
23 USE ieee.std_logic_1164.ALL;
23 USE ieee.std_logic_1164.ALL;
24 USE ieee.std_logic_textio.ALL;
24 USE ieee.std_logic_textio.ALL;
25 USE IEEE.numeric_std.ALL;
25 USE IEEE.numeric_std.ALL;
26 LIBRARY std;
26 LIBRARY std;
27 USE std.textio.ALL;
27 USE std.textio.ALL;
28
28
29
29
30 ENTITY RAM_CEL IS
30 ENTITY RAM_CEL IS
31 GENERIC(
31 GENERIC(
32 DataSz : INTEGER RANGE 1 TO 32 := 8;
32 DataSz : INTEGER RANGE 1 TO 32 := 8;
33 abits : INTEGER RANGE 2 TO 12 := 8;
33 abits : INTEGER RANGE 2 TO 12 := 8;
34 FILENAME : string:= ""
34 FILENAME : string:= ""
35 );
35 );
36 PORT(
36 PORT(
37 WD : IN STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0);
37 WD : IN STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0);
38 RD : OUT STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0);
38 RD : OUT STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0);
39 WEN, REN : IN STD_LOGIC;
39 WEN, REN : IN STD_LOGIC;
40 WADDR : IN STD_LOGIC_VECTOR(abits-1 DOWNTO 0);
40 WADDR : IN STD_LOGIC_VECTOR(abits-1 DOWNTO 0);
41 RADDR : IN STD_LOGIC_VECTOR(abits-1 DOWNTO 0);
41 RADDR : IN STD_LOGIC_VECTOR(abits-1 DOWNTO 0);
42 RWCLK, RESET : IN STD_LOGIC
42 RWCLK, RESET : IN STD_LOGIC
43 ) ;
43 ) ;
44 END RAM_CEL;
44 END RAM_CEL;
45
45
46
46
47
47
48 ARCHITECTURE ar_RAM_CEL OF RAM_CEL IS
48 ARCHITECTURE ar_RAM_CEL OF RAM_CEL IS
49
49
50 CONSTANT VectInit : STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0) := (OTHERS => '0');
50 CONSTANT VectInit : STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0) := (OTHERS => '0');
51 CONSTANT MAX : INTEGER := 2**(abits);
51 CONSTANT MAX : INTEGER := 2**(abits);
52
52
53 TYPE RAMarrayT IS ARRAY (0 TO MAX-1) OF STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0);
53 TYPE RAMarrayT IS ARRAY (0 TO MAX-1) OF STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0);
54
54
55 SIGNAL RD_int : STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0);
55 SIGNAL RD_int : STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0);
56
56
57 SIGNAL RADDR_reg : STD_LOGIC_VECTOR(abits-1 DOWNTO 0);
57 SIGNAL RADDR_reg : STD_LOGIC_VECTOR(abits-1 DOWNTO 0);
58
58
59
59
60 -- Read a *.hex file
60 -- Read a *.hex file
61 impure function ReadMemFile(FileName : STRING) return RAMarrayT is
61 impure function ReadMemFile(FileName : STRING) return RAMarrayT is
62 file FileHandle : TEXT open READ_MODE is FileName;
62 file FileHandle : TEXT open READ_MODE is FileName;
63 variable CurrentLine : LINE;
63 variable CurrentLine : LINE;
64 variable TempWord : STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0);
64 variable TempWord : STD_LOGIC_VECTOR(DataSz-1 DOWNTO 0);
65 variable Result : RAMarrayT := (others => (others => '0'));
65 variable Result : RAMarrayT := (others => (others => '0'));
66
66
67 begin
67 begin
68 for i in 0 to MAX - 1 loop
68 for i in 0 to MAX - 1 loop
69 exit when endfile(FileHandle);
69 exit when endfile(FileHandle);
70 readline(FileHandle, CurrentLine);
70 readline(FileHandle, CurrentLine);
71 hread(CurrentLine, TempWord);
71 hread(CurrentLine, TempWord);
72 Result(i) := TempWord;
72 Result(i) := TempWord;
73 end loop;
73 end loop;
74
74
75 return Result;
75 return Result;
76 end function;
76 end function;
77
77
78 impure function InitMem(FileName : STRING) return RAMarrayT is
78 impure function InitMem(FileName : STRING) return RAMarrayT is
79 variable Result : RAMarrayT := (others => (others => '0'));
79 variable Result : RAMarrayT := (others => (others => '0'));
80 begin
80 begin
81 if FileName'length /= 0 then
81 if FileName'length /= 0 then
82 report "initialysing RAM CEL From file "& FileName;
82 Result := ReadMemFile(FileName);
83 Result := ReadMemFile(FileName);
83 end if;
84 end if;
85 report "initialysing RAM CEL To 0";
84 return Result;
86 return Result;
85 end function;
87 end function;
86
88
87 SIGNAL RAMarray : RAMarrayT := InitMem(FILENAME);
89 SIGNAL RAMarray : RAMarrayT := InitMem(FILENAME);
88 BEGIN
90 BEGIN
89
91
90 RD_int <= RAMarray(to_integer(UNSIGNED(RADDR)));
92 RD_int <= RAMarray(to_integer(UNSIGNED(RADDR)));
91
93
92 PROCESS(RWclk, reset)
94 PROCESS(RWclk, reset)
93 BEGIN
95 BEGIN
94 IF reset = '0' THEN
96 IF reset = '0' THEN
95 RD <= VectInit;
97 RD <= VectInit;
96 -- rst : FOR i IN 0 TO MAX-1 LOOP
98 -- rst : FOR i IN 0 TO MAX-1 LOOP
97 -- RAMarray(i) <= (OTHERS => '0');
99 -- RAMarray(i) <= (OTHERS => '0');
98 -- END LOOP;
100 -- END LOOP;
99
101
100 ELSIF RWclk'EVENT AND RWclk = '1' THEN
102 ELSIF RWclk'EVENT AND RWclk = '1' THEN
101 RD <= RD_int;
103 RD <= RD_int;
102 IF REN = '0' THEN
104 IF REN = '0' THEN
103 RADDR_reg <= RADDR;
105 RADDR_reg <= RADDR;
104 END IF;
106 END IF;
105
107
106 IF WEN = '0' THEN
108 IF WEN = '0' THEN
107 RAMarray(to_integer(UNSIGNED(WADDR))) <= WD;
109 RAMarray(to_integer(UNSIGNED(WADDR))) <= WD;
108 END IF;
110 END IF;
109
111
110 END IF;
112 END IF;
111 END PROCESS;
113 END PROCESS;
112 END ar_RAM_CEL;
114 END ar_RAM_CEL;
113
115
114
116
115
117
116
118
117
119
118
120
119
121
120
122
121
123
122
124
123
125
124
126
125
127
126
128
127
129
128
130
129
131
130
132
131
133
132
134
133
135
134
136
135
137
136
138
137
139
138
140
139
141
140
142
General Comments 0
You need to be logged in to leave comments. Login now