1 |
2 |
habicht |
--/**************************************************************************************************************
|
2 |
|
|
--*
|
3 |
|
|
--* L Z R W 1 E N C O D E R C O R E
|
4 |
|
|
--*
|
5 |
|
|
--* A high throughput loss less data compression core.
|
6 |
|
|
--*
|
7 |
|
|
--* Copyright 2012-2013 Lukas Schrittwieser (LS)
|
8 |
|
|
--*
|
9 |
|
|
--* This program is free software: you can redistribute it and/or modify
|
10 |
|
|
--* it under the terms of the GNU General Public License as published by
|
11 |
|
|
--* the Free Software Foundation, either version 2 of the License, or
|
12 |
|
|
--* (at your option) any later version.
|
13 |
|
|
--*
|
14 |
|
|
--* This program is distributed in the hope that it will be useful,
|
15 |
|
|
--* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
|
|
--* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
|
|
--* GNU General Public License for more details.
|
18 |
|
|
--*
|
19 |
|
|
--* You should have received a copy of the GNU General Public License
|
20 |
|
|
--* along with this program; if not, write to the Free Software
|
21 |
|
|
--* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
22 |
|
|
--* Or see <http://www.gnu.org/licenses/>
|
23 |
|
|
--*
|
24 |
|
|
--***************************************************************************************************************
|
25 |
|
|
--*
|
26 |
|
|
--* Change Log:
|
27 |
|
|
--*
|
28 |
|
|
--* Version 1.0 - 2012/8/12 - LS
|
29 |
|
|
--* started file
|
30 |
|
|
--*
|
31 |
|
|
--* Version 1.0 - 2013/4/5 - LS
|
32 |
|
|
--* release
|
33 |
|
|
--*
|
34 |
|
|
--***************************************************************************************************************
|
35 |
|
|
--*
|
36 |
|
|
--* Naming convention: http://dz.ee.ethz.ch/en/information/hdl-help/vhdl-naming-conventions.html
|
37 |
|
|
--*
|
38 |
|
|
--***************************************************************************************************************
|
39 |
|
|
--*
|
40 |
|
|
--* Test bench for outputFIFO.vhd
|
41 |
|
|
--*
|
42 |
|
|
--***************************************************************************************************************
|
43 |
|
|
|
44 |
|
|
library ieee;
|
45 |
|
|
use ieee.std_logic_1164.all;
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
entity outputFIFO_tb is
|
49 |
|
|
|
50 |
|
|
end outputFIFO_tb;
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
architecture tb of outputFIFO_tb is
|
54 |
|
|
|
55 |
|
|
component outputFIFO
|
56 |
|
|
generic (
|
57 |
|
|
frameSize : integer);
|
58 |
|
|
port (
|
59 |
|
|
ClkxCI : in std_logic;
|
60 |
|
|
RstxRI : in std_logic;
|
61 |
|
|
BodyDataxDI : in std_logic_vector(7 downto 0);
|
62 |
|
|
BodyStrobexSI : in std_logic;
|
63 |
|
|
HeaderDataxDI : in std_logic_vector(frameSize-1 downto 0);
|
64 |
|
|
HeaderStrobexSI : in std_logic;
|
65 |
|
|
BuffersEmptyxSO : out std_logic;
|
66 |
|
|
BufOutxDO : out std_logic_vector(7 downto 0);
|
67 |
|
|
OutputValidxSO : out std_logic;
|
68 |
|
|
RdStrobexSI : in std_logic;
|
69 |
|
|
LengthxDO : out integer range 0 to 1024);
|
70 |
|
|
end component;
|
71 |
|
|
|
72 |
|
|
-- component generics
|
73 |
|
|
constant frameSize : integer := 8;
|
74 |
|
|
|
75 |
|
|
-- component ports
|
76 |
|
|
signal ClkxCI : std_logic;
|
77 |
|
|
signal RstxRI : std_logic := '1';
|
78 |
|
|
signal BodyDataxDI : std_logic_vector(7 downto 0) := (others => '0');
|
79 |
|
|
signal BodyStrobexSI : std_logic := '0';
|
80 |
|
|
signal HeaderDataxDI : std_logic_vector(frameSize-1 downto 0) := (others => '0');
|
81 |
|
|
signal HeaderStrobexSI : std_logic := '0';
|
82 |
|
|
signal BuffersEmptyxSO : std_logic;
|
83 |
|
|
signal BufOutxDO : std_logic_vector(7 downto 0);
|
84 |
|
|
signal OutputValidxSO : std_logic;
|
85 |
|
|
signal RdStrobexSI : std_logic := '0';
|
86 |
|
|
signal LengthxDO : integer range 0 to 1024;
|
87 |
|
|
|
88 |
|
|
-- clock
|
89 |
|
|
signal Clk : std_logic := '1';
|
90 |
|
|
|
91 |
|
|
constant PERIOD : time := 20ns;
|
92 |
|
|
|
93 |
|
|
begin -- tb
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
-- component instantiation
|
97 |
|
|
DUT : outputFIFO
|
98 |
|
|
generic map (
|
99 |
|
|
frameSize => frameSize)
|
100 |
|
|
port map (
|
101 |
|
|
ClkxCI => ClkxCI,
|
102 |
|
|
RstxRI => RstxRI,
|
103 |
|
|
BodyDataxDI => BodyDataxDI,
|
104 |
|
|
BodyStrobexSI => BodyStrobexSI,
|
105 |
|
|
HeaderDataxDI => HeaderDataxDI,
|
106 |
|
|
HeaderStrobexSI => HeaderStrobexSI,
|
107 |
|
|
BuffersEmptyxSO => BuffersEmptyxSO,
|
108 |
|
|
BufOutxDO => BufOutxDO,
|
109 |
|
|
OutputValidxSO => OutputValidxSO,
|
110 |
|
|
RdStrobexSI => RdStrobexSI,
|
111 |
|
|
LengthxDO => LengthxDO);
|
112 |
|
|
|
113 |
|
|
-- clock generation
|
114 |
|
|
Clk <= not Clk after PERIOD/2;
|
115 |
|
|
ClkxCI <= Clk;
|
116 |
|
|
|
117 |
|
|
-- waveform generation
|
118 |
|
|
WaveGen_Proc : process
|
119 |
|
|
begin
|
120 |
|
|
wait for 20 ns;
|
121 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
122 |
|
|
RstxRI <= '0';
|
123 |
|
|
-- send a data frame with an odd number of bytes (header and body)
|
124 |
|
|
BodyDataxDI <= x"00";
|
125 |
|
|
BodyStrobexSI <= '1';
|
126 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
127 |
|
|
BodyDataxDI <= x"01";
|
128 |
|
|
BodyStrobexSI <= '1';
|
129 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
130 |
|
|
BodyDataxDI <= x"00";
|
131 |
|
|
BodyStrobexSI <= '0';
|
132 |
|
|
HeaderDataxDI <= x"0f";
|
133 |
|
|
HeaderStrobexSI <= '1';
|
134 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
135 |
|
|
BodyDataxDI <= x"00";
|
136 |
|
|
BodyStrobexSI <= '0';
|
137 |
|
|
HeaderDataxDI <= x"00";
|
138 |
|
|
HeaderStrobexSI <= '0';
|
139 |
|
|
|
140 |
|
|
-- send a data frame to the input buffer
|
141 |
|
|
BodyDataxDI <= x"10";
|
142 |
|
|
BodyStrobexSI <= '1';
|
143 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
144 |
|
|
BodyDataxDI <= x"11";
|
145 |
|
|
BodyStrobexSI <= '1';
|
146 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
147 |
|
|
BodyDataxDI <= x"12";
|
148 |
|
|
BodyStrobexSI <= '1';
|
149 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
150 |
|
|
BodyDataxDI <= x"13";
|
151 |
|
|
BodyStrobexSI <= '1';
|
152 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
153 |
|
|
BodyDataxDI <= x"14";
|
154 |
|
|
BodyStrobexSI <= '1';
|
155 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
156 |
|
|
BodyStrobexSI <= '0';
|
157 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
158 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
159 |
|
|
BodyDataxDI <= x"15";
|
160 |
|
|
BodyStrobexSI <= '1';
|
161 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
162 |
|
|
BodyDataxDI <= x"16";
|
163 |
|
|
BodyStrobexSI <= '1';
|
164 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
165 |
|
|
BodyStrobexSI <= '0';
|
166 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
167 |
|
|
BodyDataxDI <= x"17";
|
168 |
|
|
BodyStrobexSI <= '1';
|
169 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
170 |
|
|
BodyDataxDI <= x"18";
|
171 |
|
|
HeaderDataxDI <= x"1f";
|
172 |
|
|
HeaderStrobexSI <= '1';
|
173 |
|
|
BodyStrobexSI <= '1';
|
174 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
175 |
|
|
BodyStrobexSI <= '0';
|
176 |
|
|
HeaderStrobexSI <= '0';
|
177 |
|
|
HeaderDataxDI <= x"00";
|
178 |
|
|
BodyDataxDI <= x"00";
|
179 |
|
|
|
180 |
|
|
-- send a short frame (this is allowed for the last frame only)
|
181 |
|
|
BodyDataxDI <= x"ff";
|
182 |
|
|
BodyStrobexSI <= '1';
|
183 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
184 |
|
|
BodyStrobexSI <= '1';
|
185 |
|
|
HeaderStrobexSI <= '1';
|
186 |
|
|
HeaderDataxDI <= x"ff";
|
187 |
|
|
BodyDataxDI <= x"ff";
|
188 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
189 |
|
|
BodyStrobexSI <= '0';
|
190 |
|
|
HeaderStrobexSI <= '0';
|
191 |
|
|
HeaderDataxDI <= x"00";
|
192 |
|
|
BodyDataxDI <= x"00";
|
193 |
|
|
|
194 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
195 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
196 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
197 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
198 |
|
|
|
199 |
|
|
RdStrobexSI <= '1';
|
200 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
201 |
|
|
RdStrobexSI <= '0';
|
202 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
203 |
|
|
RdStrobexSI <= '1';
|
204 |
|
|
wait for 15 * PERIOD;
|
205 |
|
|
RdStrobexSI <= '0';
|
206 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
207 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
208 |
|
|
|
209 |
|
|
-- try illegal read
|
210 |
|
|
RdStrobexSI <= '1';
|
211 |
|
|
wait until ClkxCI'event and ClkxCI = '1';
|
212 |
|
|
RdStrobexSI <= '0';
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
wait;
|
217 |
|
|
end process WaveGen_Proc;
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
end tb;
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
configuration outputFIFO_tb_tb_cfg of outputFIFO_tb is
|
226 |
|
|
for tb
|
227 |
|
|
end for;
|
228 |
|
|
end outputFIFO_tb_tb_cfg;
|
229 |
|
|
|