##// END OF EJS Templates
For simulation :...
pellion -
r686:ea8efb0bdfd4 Simu-LFR-FM draft
parent child
Show More
@@ -0,0 +1,82
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 ENTITY spw_receiver IS
9 GENERIC(
10 FNAME : STRING := "output.txt"
11 );
12 PORT(
13 end_of_simu : IN STD_LOGIC;
14 timestamp : IN integer;
15
16 clk : IN STD_LOGIC;
17
18 rxread : out STD_LOGIC;
19 rxflag : in STD_LOGIC;
20 rxdata : in STD_LOGIC_VECTOR(7 DOWNTO 0);
21 rxvalid : in STD_LOGIC;
22 rxhalff : out STD_LOGIC
23 );
24 END spw_receiver;
25
26 ARCHITECTURE beh OF spw_receiver IS
27
28 FILE output_file : TEXT OPEN write_mode IS FNAME;
29
30 SIGNAL message_ongoing : STD_LOGIC := '0';
31 SIGNAL message_timestamp : INTEGER;
32
33 BEGIN
34 -----------------------------------------------------------------------------
35 -- Data orginization in the output file :
36 -----------------------------------------------------------------------------
37 -- Exemple of output.txt file :
38 -- Data_1
39 -- Data_2
40 -- ...
41 -- Data_N
42 -- TIME= TimeStamp_when_Data_1_was_received
43 -- Data_N+1
44 -- Data_N+2
45 -- ...
46 -- Data_M
47 -- TIME= TimeStamp_when_Data_N+1_was_received
48 -- Data_M+1
49 -- Data_M+2
50 -- ...
51 -- Data_K
52 -- TIME= TimeStamp_when_Data_M+1_was_received
53 -----------------------------------------------------------------------------
54 -- TimeStamp : integer. Waiting time (in ns) before to send the following message
55 -- Data : integer(0 to 255). A part of the message.
56 -----------------------------------------------------------------------------
57
58 PROCESS(clk,end_of_simu)
59 VARIABLE line_var : LINE;
60 BEGIN
61 IF end_of_simu = '1' THEN
62 file_close(output_file);
63 rxread <= '0';
64 ELSIF clk'EVENT AND clk = '1' THEN
65 rxread <= '1';
66 IF rxvalid = '1' THEN
67 IF rxflag = '1' THEN
68 write(line_var, "TIME= " & INTEGER'IMAGE(message_timestamp));
69 message_ongoing <= '0';
70 ELSE
71 IF message_ongoing = '0' THEN
72 message_ongoing <= '1';
73 message_timestamp <= TimeStamp;
74 END IF;
75 write(line_var, INTEGER'IMAGE(to_integer(UNSIGNED(rxdata))));
76 END IF;
77 writeline(output_file, line_var);
78 END IF;
79 END IF;
80 END PROCESS;
81
82 END beh;
@@ -0,0 +1,97
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 ENTITY spw_sender IS
9 GENERIC(
10 FNAME : STRING := "input.txt"
11 );
12 PORT(
13 end_of_simu : OUT STD_LOGIC;
14 start_of_simu : IN STD_LOGIC;
15
16 clk : IN STD_LOGIC;
17 txwrite : OUT STD_LOGIC;
18 txflag : OUT STD_LOGIC;
19 txdata : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
20 txrdy : IN STD_LOGIC;
21 txhalff : IN STD_LOGIC
22 );
23 END spw_sender;
24
25 ARCHITECTURE beh OF spw_sender IS
26 FILE input_file : TEXT OPEN read_mode IS FNAME;
27
28 BEGIN
29 -----------------------------------------------------------------------------
30 -- Data orginization in the input file :
31 -----------------------------------------------------------------------------
32 -- Exemple of input.txt file :
33 -- Time1 N1
34 -- Data_1
35 -- Data_2
36 -- ...
37 -- Data_N1
38 -- Time2 N2
39 -- Data_1
40 -- Data_2
41 -- ...
42 -- Data_N2
43 -- ...
44 -- TimeK NK
45 -- Data_1
46 -- Data_2
47 -- ...
48 -- Data_NK
49 -----------------------------------------------------------------------------
50 -- Time : integer. Waiting time (in ns) before to send the following message
51 -- N : integer. Length (in Byte) of the following message.
52 -- Data : integer(0 to 255). A part of the message.
53 -----------------------------------------------------------------------------
54
55 PROCESS IS
56 VARIABLE line_var : LINE;
57 VARIABLE waiting_time : INTEGER;
58 VARIABLE length_of_message : INTEGER;
59 VARIABLE value : INTEGER;
60 BEGIN -- PROCESS
61 txwrite <= '0';
62 txflag <= '0';
63 WAIT UNTIL clk = '1';
64 IF start_of_simu = '1' THEN
65
66 IF endfile(input_file) THEN
67 end_of_simu <= '1';
68 ELSE
69 end_of_simu <= '0';
70 readline(input_file, line_var);
71 read(line_var, waiting_time);
72 read(line_var, length_of_message);
73
74 WAIT FOR waiting_time * 1 ns;
75
76 FOR char_number IN 0 TO length_of_message-1 LOOP
77 WAIT UNTIL clk = '1' AND txrdy = '1';
78 readline(input_file, line_var);
79 read(line_var, value);
80 txwrite <= '1';
81 txflag <= '0';
82 txdata <= STD_LOGIC_VECTOR(to_unsigned(value, txdata'LENGTH));
83 END LOOP; -- char_number
84 WAIT UNTIL clk = '1' AND txrdy = '1';
85 txwrite <= '1';
86 txflag <= '1';
87 txdata <= (OTHERS => '0');
88 WAIT UNTIL clk = '1';
89 txwrite <= '0';
90 txflag <= '0';
91
92 END IF;
93 END IF;
94
95 END PROCESS;
96
97 END beh;
@@ -0,0 +1,53
1 VHDLIB=../..
2 SCRIPTSDIR=$(VHDLIB)/scripts/
3 GRLIB := $(shell sh $(VHDLIB)/scripts/lpp_relpath.sh)
4 TOP=testbench
5 BOARD=LFR-FM
6 include $(VHDLIB)/boards/$(BOARD)/Makefile_RTAX.inc
7 DEVICE=$(PART)-$(PACKAGE)$(SPEED)
8 UCF=
9 QSF=
10 EFFORT=high
11 XSTOPT=
12 SYNPOPT=
13 VHDLSYNFILES=
14 VHDLSIMFILES= $(VHDLIB)/designs/SOLO_LFR_LFR-FM/LFR-FM.vhd tb.vhd
15 SIMTOP=testbench
16 CLEAN=soft-clean
17
18 TECHLIBS = axcelerator
19
20
21 LIBSKIP = tmtc openchip hynix cypress ihp usbhc fmf gsi spansion eth micron
22
23 DIRSKIP = leon2 leon2ft crypto usb satcan ddr greth grusbhc \
24 leon4 leon4v0 l2cache iommu slink ascs pwm net spi can \
25 ./amba_lcd_16x2_ctrlr \
26 ./general_purpose/lpp_AMR \
27 ./general_purpose/lpp_balise \
28 ./general_purpose/lpp_delay \
29 ./lpp_bootloader \
30 ./lpp_uart \
31 ./lpp_usb \
32 ./lpp_debug_lfr \
33 ./dsp/lpp_fft
34
35 FILESKIP = i2cmst.vhd \
36 APB_MULTI_DIODE.vhd \
37 APB_MULTI_DIODE.vhd \
38 Top_MatrixSpec.vhd \
39 APB_FFT.vhd \
40 lpp_lfr_sim_pkg.vhd
41
42 include $(GRLIB)/bin/Makefile
43 include $(GRLIB)/software/leon3/Makefile
44 ################## project specific targets ##########################
45 distclean:myclean
46
47 myclean:
48 rm -f input.txt output_fx.txt *.log
49 rm -rf ./2016*
50
51 test: | ghdl ghdl-run archivate
52
53
@@ -0,0 +1,7
1 20 3
2 28
3 14
4 32
5 1500 2
6 18
7 200
@@ -0,0 +1,7
1 28
2 14
3 32
4 TIME= 45020
5 18
6 200
7 TIME= 47660
@@ -0,0 +1,213
1
2 LIBRARY ieee;
3 USE ieee.std_logic_1164.ALL;
4 USE ieee.numeric_std.ALL;
5 USE IEEE.std_logic_signed.ALL;
6 USE IEEE.MATH_real.ALL;
7
8 LIBRARY techmap;
9 USE techmap.gencomp.ALL;
10
11 LIBRARY std;
12 USE std.textio.ALL;
13
14 LIBRARY opencores;
15 USE opencores.spwpkg.ALL;
16 USE opencores.spwambapkg.ALL;
17
18 LIBRARY lpp;
19 USE lpp.lpp_sim_pkg.ALL;
20
21 ENTITY testbench IS
22 END;
23
24 ARCHITECTURE behav OF testbench IS
25
26 SIGNAL TSTAMP : INTEGER := 0;
27 SIGNAL clk : STD_LOGIC := '0';
28 SIGNAL rst : STD_LOGIC;
29
30 SIGNAL end_of_simu : STD_LOGIC := '0';
31
32 SIGNAL autostart : STD_LOGIC := '1';
33 SIGNAL linkstart : STD_LOGIC := '1';
34 SIGNAL linkdis : STD_LOGIC := '0';
35 SIGNAL ctrl_in : STD_LOGIC_VECTOR(1 DOWNTO 0) := (OTHERS => '0');
36 SIGNAL time_in : STD_LOGIC_VECTOR(5 DOWNTO 0) := (OTHERS => '0');
37 SIGNAL txwrite : STD_LOGIC := '0';
38 SIGNAL txflag : STD_LOGIC := '0';
39 SIGNAL txdata : STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '0');
40 SIGNAL txrdy : STD_LOGIC;
41 SIGNAL txhalff : STD_LOGIC;
42 SIGNAL tick_out : STD_LOGIC;
43 SIGNAL ctrl_out : STD_LOGIC_VECTOR(1 DOWNTO 0);
44 SIGNAL time_out : STD_LOGIC_VECTOR(5 DOWNTO 0);
45 SIGNAL rxvalid : STD_LOGIC;
46 SIGNAL rxhalff : STD_LOGIC;
47 SIGNAL rxflag : STD_LOGIC;
48 SIGNAL rxdata : STD_LOGIC_VECTOR(7 DOWNTO 0);
49 SIGNAL rxread : STD_LOGIC := '0';
50 SIGNAL started : STD_LOGIC;
51 SIGNAL connecting : STD_LOGIC;
52 SIGNAL running : STD_LOGIC;
53 SIGNAL errdisc : STD_LOGIC;
54 SIGNAL errpar : STD_LOGIC;
55 SIGNAL erresc : STD_LOGIC;
56 SIGNAL errcred : STD_LOGIC;
57
58 SIGNAL spw_di : std_logic;
59 SIGNAL spw_si : std_logic;
60 SIGNAL spw_do : std_logic;
61 SIGNAL spw_so : std_logic;
62
63 BEGIN
64
65 -----------------------------------------------------------------------------
66 -- CLOCK and RESET
67 -----------------------------------------------------------------------------
68 PROCESS
69 BEGIN -- PROCESS
70 WAIT UNTIL clk = '1';
71 rst <= '1';
72 WAIT UNTIL clk = '1';
73 WAIT UNTIL clk = '1';
74 WAIT UNTIL clk = '1';
75 rst <= '0';
76 WAIT UNTIL end_of_simu = '1';
77 WAIT FOR 10 ps;
78 ASSERT false REPORT "end of test" SEVERITY note;
79 -- Wait forever; this will finish the simulation.
80 WAIT;
81 END PROCESS;
82 -----------------------------------------------------------------------------
83
84 clk_50M_gen : PROCESS
85 BEGIN
86 IF end_of_simu /= '1' THEN
87 clk <= NOT clk;
88 TSTAMP <= TSTAMP+20;
89 WAIT FOR 10 ns;
90 ELSE
91 WAIT FOR 10 ps;
92 ASSERT false REPORT "end of test" SEVERITY note;
93 WAIT;
94 END IF;
95 END PROCESS;
96
97
98 SPW : spwstream
99
100 GENERIC MAP(
101 sysfreq => 50.0e6,
102 txclkfreq => 50.0e6,
103 rximpl => impl_generic,
104 rxchunk => 1,
105 tximpl => impl_generic,
106 rxfifosize_bits => 11,
107 txfifosize_bits => 11
108 )
109
110 PORT MAP(
111 -- System clock.
112 clk => clk,
113 rxclk => clk,
114 txclk => clk,
115 rst => rst,
116
117
118 autostart => autostart, -- Enables automatic link start on receipt of a NULL character.
119 linkstart => linkstart, -- Enables link start once the Ready state is reached. Without autostart or linkstart, the link remains in state Ready.
120 linkdis => linkdis, -- Do not start link (overrides linkstart and autostart) and/or disconnect a running link.
121
122 txdivcnt => X"00",
123
124
125 -------------------------------------------------------------------------
126 -- TimeCode transmission
127 tick_in => '0', -- High for one clock cycle to request transmission of a TimeCode. The request is registered inside the entity until it can be processed.
128 ctrl_in => ctrl_in, -- Control bits of the TimeCode to be sent. Must be valid while tick_in is high.
129 time_in => time_in, -- Counter value of the TimeCode to be sent. Must be valid while tick_in is high.
130 -------------------------------------------------------------------------
131
132 -------------------------------------------------------------------------
133 -- ### tx data ### tb -> SPW-light
134 txwrite => txwrite, -- Pulled high by the application to write an N-Char to the transmit queue.
135 -- If "txwrite" and "txrdy" are both high on the rising edge of "clk", a character is added to the transmit queue.
136 -- This signal has no effect if "txrdy" is low.
137 txflag => txflag, -- Control flag to be sent with the next N_Char. Must be valid while txwrite is high.
138 txdata => txdata, -- Byte to be sent, or "00000000" for EOP or "00000001" for EEP. Must be valid while txwrite is high.
139 txrdy => txrdy, -- High if the entity is ready to accept an N-Char for transmission.
140 txhalff => txhalff, -- High if the transmission queue is at least half full.
141 -------------------------------------------------------------------------
142
143 -------------------------------------------------------------------------
144 -- TimeCode reception
145 tick_out => tick_out, -- High for one clock cycle if a TimeCode was just received.
146 ctrl_out => ctrl_out, -- Control bits of the last received TimeCode.
147 time_out => time_out, -- Counter value of the last received TimeCode.
148 -------------------------------------------------------------------------
149
150
151 -------------------------------------------------------------------------
152 -- ### rx data ### tb <- SPW-light
153 rxvalid => rxvalid, -- High if "rxflag" and "rxdata" contain valid data. This signal is high unless the receive FIFO is empty.
154 rxhalff => rxhalff, -- High if the receive FIFO is at least half full.
155 rxflag => rxflag, -- High if the received character is EOP or EEP; low if the received character is a data byte. Valid if "rxvalid" is high.
156 rxdata => rxdata, -- Received byte, or "00000000" for EOP or "00000001" for EEP. Valid if "rxvalid" is high.
157 rxread => rxread, -- Pulled high by the application to accept a received character.
158 -- If "rxvalid" and "rxread" are both high on the rising edge of "clk",
159 -- a character is removed from the receive FIFO and "rxvalid", "rxflag" and "rxdata" are updated.
160 -- This signal has no effect if "rxvalid" is low.
161 -------------------------------------------------------------------------
162
163 -------------------------------------------------------------------------
164 -- STATUS
165 started => started, -- High if the link state machine is currently in the Started state.
166 connecting => connecting, -- High if the link state machine is currently in the Connecting state.
167 running => running, -- High if the link state machine is currently in the Run state, indicatin that the link is fully operational.
168 -- If none of started, connecting or running is high, the link is in an initial state and the transmitter is not yet enabled.
169
170 errdisc => errdisc, -- Disconnect detected in state Run. Triggers a reset and reconnect of the link. This indication is auto-clearing.
171 errpar => errpar, -- Parity error detected in state Run. Triggers a reset and reconnect of the link. This indication is auto-clearing.
172 erresc => erresc, -- Invalid escape sequence detected in state Run. Triggers a reset and reconnect of the link. This indication is auto-clearing.
173 errcred => errcred, -- Credit error detected. Triggers a reset and reconnect of the link. This indication is auto-clearing.
174 -------------------------------------------------------------------------
175
176 spw_di => spw_di, -- Data In signal from SpaceWire bus.
177 spw_si => spw_si, -- Strobe In signal from SpaceWire bus.
178 spw_do => spw_do, -- Data Out signal to SpaceWire bus.
179 spw_so => spw_so -- Strobe Out signal to SpaceWire bus.
180 );
181
182
183 spw_si <= spw_so;
184 spw_di <= spw_do;
185
186 spw_sender_1: spw_sender
187 GENERIC MAP (
188 FNAME => "spw_input.txt")
189 PORT MAP (
190 end_of_simu => OPEN,
191 start_of_simu => running,
192 clk => clk,
193
194 txwrite => txwrite,
195 txflag => txflag,
196 txdata => txdata,
197 txrdy => txrdy,
198 txhalff => txhalff);
199
200 spw_receiver_1: spw_receiver
201 GENERIC MAP (
202 FNAME => "spw_output.txt")
203 PORT MAP (
204 end_of_simu => '0',
205 timestamp => TSTAMP,
206 clk => clk,
207 rxread => rxread,
208 rxflag => rxflag,
209 rxdata => rxdata,
210 rxvalid => rxvalid,
211 rxhalff => rxhalff);
212
213 END;
@@ -1,16 +1,16
1 fft_components.vhd
1 fft_components.vhd
2 lpp_fft.vhd
2 lpp_fft.vhd
3 actar.vhd
3 actar.vhd
4 actram.vhd
4 actram.vhd
5 CoreFFT.vhd
5 CoreFFT.vhd
6 fftDp.vhd
6 fftDp.vhd
7 fftSm.vhd
7 fftSm.vhd
8 primitives.vhd
8 primitives.vhd
9 twiddle.vhd
9 twiddle.vhd
10 APB_FFT.vhd
10 APB_FFT.vhd
11 Driver_FFT.vhd
11 Driver_FFT.vhd
12 FFT.vhd
12 FFT.vhd
13 FFTamont.vhd
13 FFTamont.vhd
14 FFTaval.vhd
14 FFTaval.vhd
15 Flag_Extremum.vhd
15 Flag_Extremum.vhd
16 Linker_FFT.vhd
16 Linker_FFT.vhd
@@ -1,7 +1,7
1 lpp_cna.vhd
1 lpp_cna.vhd
2 APB_LFR_CAL.vhd
2 APB_LFR_CAL.vhd
3 RAM_READER.vhd
3 RAM_READER.vhd
4 RAM_WRITER.vhd
4 RAM_WRITER.vhd
5 SPI_DAC_DRIVER.vhd
5 SPI_DAC_DRIVER.vhd
6 dynamic_freq_div.vhd
6 dynamic_freq_div.vhd
7 lfr_cal_driver.vhd
7 lfr_cal_driver.vhd
@@ -89,6 +89,34 PACKAGE lpp_sim_pkg IS
89 );
89 );
90 END COMPONENT;
90 END COMPONENT;
91
91
92 COMPONENT spw_sender IS
93 GENERIC (
94 FNAME : STRING);
95 PORT (
96 end_of_simu : OUT STD_LOGIC;
97 start_of_simu : IN STD_LOGIC;
98 clk : IN STD_LOGIC;
99 txwrite : OUT STD_LOGIC;
100 txflag : OUT STD_LOGIC;
101 txdata : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
102 txrdy : IN STD_LOGIC;
103 txhalff : IN STD_LOGIC);
104 END COMPONENT spw_sender;
105
106 COMPONENT spw_receiver IS
107 GENERIC (
108 FNAME : STRING);
109 PORT (
110 end_of_simu : IN STD_LOGIC;
111 timestamp : IN integer;
112 clk : IN STD_LOGIC;
113 rxread : OUT STD_LOGIC;
114 rxflag : in STD_LOGIC;
115 rxdata : in STD_LOGIC_VECTOR(7 DOWNTO 0);
116 rxvalid : in STD_LOGIC;
117 rxhalff : out STD_LOGIC);
118 END COMPONENT spw_receiver;
119
92 END lpp_sim_pkg;
120 END lpp_sim_pkg;
93
121
94 PACKAGE BODY lpp_sim_pkg IS
122 PACKAGE BODY lpp_sim_pkg IS
@@ -3,3 +3,5 sig_reader.vhd
3 sig_recorder.vhd
3 sig_recorder.vhd
4 lpp_sim_pkg.vhd
4 lpp_sim_pkg.vhd
5 lpp_lfr_sim_pkg.vhd
5 lpp_lfr_sim_pkg.vhd
6 spw_sender.vhd
7 spw_receiver.vhd
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now