1 |
2 |
kavi |
----==============================================================----
|
2 |
|
|
---- ----
|
3 |
|
|
---- Filename: hw_loops5_top_tb.vhd ----
|
4 |
|
|
---- Module description: Simple testbench for the "hw_loops5_top" ----
|
5 |
|
|
---- top-level module ----
|
6 |
|
|
---- ----
|
7 |
|
|
---- Author: Nikolaos Kavvadias ----
|
8 |
|
|
---- nkavv@skiathos.physics.auth.gr ----
|
9 |
|
|
---- ----
|
10 |
|
|
---- ----
|
11 |
|
|
---- Downloaded from: http://wwww.opencores.org/cores/hwlu ----
|
12 |
|
|
---- ----
|
13 |
|
|
---- To Do: ----
|
14 |
|
|
---- 1. Should be improved. A more thorough testbench is ----
|
15 |
|
|
---- needed. ----
|
16 |
|
|
---- 2. The testbench file for the top-level module will ----
|
17 |
|
|
---- be generated by corresponding C tool. ----
|
18 |
|
|
---- ----
|
19 |
|
|
---- Author: Nikolaos Kavvadias ----
|
20 |
|
|
---- nkavv@skiathos.physics.auth.gr ----
|
21 |
|
|
---- ----
|
22 |
|
|
----==============================================================----
|
23 |
|
|
---- ----
|
24 |
|
|
---- Copyright (C) 2004 Nikolaos Kavvadias ----
|
25 |
|
|
---- nick-kavi.8m.com ----
|
26 |
|
|
---- nkavv@skiathos.physics.auth.gr ----
|
27 |
|
|
---- nick_ka_vi@hotmail.com ----
|
28 |
|
|
---- ----
|
29 |
|
|
---- This source file may be used and distributed without ----
|
30 |
|
|
---- restriction provided that this copyright statement is not ----
|
31 |
|
|
---- removed from the file and that any derivative work contains ----
|
32 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
33 |
|
|
---- ----
|
34 |
|
|
---- This source file is free software; you can redistribute it ----
|
35 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
36 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
37 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
38 |
|
|
---- later version. ----
|
39 |
|
|
---- ----
|
40 |
|
|
---- This source is distributed in the hope that it will be ----
|
41 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
42 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
43 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
44 |
|
|
---- details. ----
|
45 |
|
|
---- ----
|
46 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
47 |
|
|
---- Public License along with this source; if not, download it ----
|
48 |
|
|
---- from <http://www.opencores.org/lgpl.shtml> ----
|
49 |
|
|
---- ----
|
50 |
|
|
----==============================================================----
|
51 |
|
|
--
|
52 |
|
|
-- CVS Revision History
|
53 |
|
|
--
|
54 |
|
|
|
55 |
|
|
library IEEE;
|
56 |
|
|
use IEEE.std_logic_1164.all;
|
57 |
|
|
use IEEE.std_logic_arith.all;
|
58 |
|
|
use IEEE.std_logic_unsigned.all;
|
59 |
|
|
use IEEE.std_logic_textio.all;
|
60 |
|
|
use STD.textio.all;
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
entity hwloop_top_tb is
|
64 |
|
|
generic (
|
65 |
|
|
DW : integer := 8;
|
66 |
|
|
NLP : integer := 5
|
67 |
|
|
);
|
68 |
|
|
end hwloop_top_tb;
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
architecture tb_architecture of hwloop_top_tb is
|
72 |
|
|
--
|
73 |
|
|
-- Component declaration of the DUT
|
74 |
|
|
component hw_looping is
|
75 |
|
|
generic (
|
76 |
|
|
DW : integer := 8;
|
77 |
|
|
NLP : integer := 5
|
78 |
|
|
);
|
79 |
|
|
port (
|
80 |
|
|
clk : in std_logic;
|
81 |
|
|
reset : in std_logic;
|
82 |
|
|
task_loop5_end : in std_logic;
|
83 |
|
|
loop1_count : in std_logic_vector(DW-1 downto 0);
|
84 |
|
|
loop2_count : in std_logic_vector(DW-1 downto 0);
|
85 |
|
|
loop3_count : in std_logic_vector(DW-1 downto 0);
|
86 |
|
|
loop4_count : in std_logic_vector(DW-1 downto 0);
|
87 |
|
|
loop5_count : in std_logic_vector(DW-1 downto 0);
|
88 |
|
|
index1 : out std_logic_vector(DW-1 downto 0);
|
89 |
|
|
index2 : out std_logic_vector(DW-1 downto 0);
|
90 |
|
|
index3 : out std_logic_vector(DW-1 downto 0);
|
91 |
|
|
index4 : out std_logic_vector(DW-1 downto 0);
|
92 |
|
|
index5 : out std_logic_vector(DW-1 downto 0);
|
93 |
|
|
loops_end : out std_logic
|
94 |
|
|
);
|
95 |
|
|
end component;
|
96 |
|
|
--
|
97 |
|
|
-- Signal declarations
|
98 |
|
|
-- Stimulus signals - signals mapped to the I/IO ports of tested entity
|
99 |
|
|
signal clk : std_logic;
|
100 |
|
|
signal reset : std_logic;
|
101 |
|
|
signal task_loop5_end : std_logic;
|
102 |
|
|
signal loop1_count : std_logic_vector(DW-1 downto 0);
|
103 |
|
|
signal loop2_count : std_logic_vector(DW-1 downto 0);
|
104 |
|
|
signal loop3_count : std_logic_vector(DW-1 downto 0);
|
105 |
|
|
signal loop4_count : std_logic_vector(DW-1 downto 0);
|
106 |
|
|
signal loop5_count : std_logic_vector(DW-1 downto 0);
|
107 |
|
|
-- Signals mapped to the output ports of tested entity
|
108 |
|
|
signal index1 : std_logic_vector(DW-1 downto 0);
|
109 |
|
|
signal index2 : std_logic_vector(DW-1 downto 0);
|
110 |
|
|
signal index3 : std_logic_vector(DW-1 downto 0);
|
111 |
|
|
signal index4 : std_logic_vector(DW-1 downto 0);
|
112 |
|
|
signal index5 : std_logic_vector(DW-1 downto 0);
|
113 |
|
|
signal loops_end : std_logic;
|
114 |
|
|
--
|
115 |
|
|
-- Constant declarations
|
116 |
|
|
constant CLK_PERIOD : time := 10 ns;
|
117 |
|
|
|
118 |
|
|
begin
|
119 |
|
|
|
120 |
|
|
-- Unit Under Test port map
|
121 |
|
|
UUT : hw_looping
|
122 |
|
|
generic map (
|
123 |
|
|
DW => DW,
|
124 |
|
|
NLP => NLP
|
125 |
|
|
)
|
126 |
|
|
port map (
|
127 |
|
|
clk => clk,
|
128 |
|
|
reset => reset,
|
129 |
|
|
task_loop5_end => task_loop5_end,
|
130 |
|
|
loop1_count => loop1_count,
|
131 |
|
|
loop2_count => loop2_count,
|
132 |
|
|
loop3_count => loop3_count,
|
133 |
|
|
loop4_count => loop4_count,
|
134 |
|
|
loop5_count => loop5_count,
|
135 |
|
|
index1 => index1,
|
136 |
|
|
index2 => index2,
|
137 |
|
|
index3 => index3,
|
138 |
|
|
index4 => index4,
|
139 |
|
|
index5 => index5,
|
140 |
|
|
loops_end => loops_end
|
141 |
|
|
);
|
142 |
|
|
|
143 |
|
|
CLK_GEN_PROC: process(clk)
|
144 |
|
|
begin
|
145 |
|
|
if (clk = 'U') then
|
146 |
|
|
clk <= '1';
|
147 |
|
|
else
|
148 |
|
|
clk <= not clk after CLK_PERIOD/2;
|
149 |
|
|
end if;
|
150 |
|
|
end process CLK_GEN_PROC;
|
151 |
|
|
|
152 |
|
|
DATA_STIM: process
|
153 |
|
|
begin
|
154 |
|
|
reset <= '0';
|
155 |
|
|
task_loop5_end <= '0';
|
156 |
|
|
loop1_count <= X"00";
|
157 |
|
|
loop2_count <= X"00";
|
158 |
|
|
loop3_count <= X"00";
|
159 |
|
|
loop4_count <= X"00";
|
160 |
|
|
loop5_count <= X"00";
|
161 |
|
|
wait for CLK_PERIOD;
|
162 |
|
|
--
|
163 |
|
|
reset <= '1';
|
164 |
|
|
task_loop5_end <= '0';
|
165 |
|
|
loop1_count <= X"00";
|
166 |
|
|
loop2_count <= X"00";
|
167 |
|
|
loop3_count <= X"00";
|
168 |
|
|
loop4_count <= X"00";
|
169 |
|
|
loop5_count <= X"00";
|
170 |
|
|
wait for CLK_PERIOD;
|
171 |
|
|
--
|
172 |
|
|
reset <= '0';
|
173 |
|
|
task_loop5_end <= '1';
|
174 |
|
|
loop1_count <= X"04";
|
175 |
|
|
loop2_count <= X"06";
|
176 |
|
|
loop3_count <= X"02";
|
177 |
|
|
loop4_count <= X"04";
|
178 |
|
|
loop5_count <= X"03";
|
179 |
|
|
wait for CLK_PERIOD;
|
180 |
|
|
--
|
181 |
|
|
-- Apply same inputs (written in some kind of
|
182 |
|
|
-- configuration memory) for large amount of time,
|
183 |
|
|
-- e.g. 1000 clock periods
|
184 |
|
|
wait for 1000*CLK_PERIOD;
|
185 |
|
|
--
|
186 |
|
|
end process DATA_STIM;
|
187 |
|
|
|
188 |
|
|
end tb_architecture;
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
configuration TESTBENCH_FOR_hw_looping of hwloop_top_tb is
|
192 |
|
|
for tb_architecture
|
193 |
|
|
for UUT : hw_looping
|
194 |
|
|
use entity work.hw_looping(structural);
|
195 |
|
|
end for;
|
196 |
|
|
end for;
|
197 |
|
|
end TESTBENCH_FOR_hw_looping;
|