-
Notifications
You must be signed in to change notification settings - Fork 4
/
tb_popcount.vhd
53 lines (41 loc) · 1.06 KB
/
tb_popcount.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity tb_popcount_4 is
end tb_popcount_4;
architecture Behavioral of tb_popcount_4 is
component Popcount_4
port ( input_vector : in STD_LOGIC_VECTOR(3 downto 0);
count : out STD_LOGIC_VECTOR(2 downto 0)
);
end component;
--Inputs
signal CLK : std_logic := '0';
signal input_vector : STD_LOGIC_VECTOR(3 downto 0);
--Outputs
signal count : STD_LOGIC_VECTOR(2 downto 0);
--Testbench Related
constant period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: Popcount_4 PORT MAP (
input_vector => input_vector,
count => count
);
-- Clock process definitions
process1 :process
variable i : integer := 0;
begin
input_vector <= "0000";
for i in 0 to 15 loop
wait for period;
input_vector <= std_logic_vector(unsigned(input_vector) + 1);
end loop;
end process;
-- Stimulus process
stim_proc: process
begin
wait for period/2;
CLK <= not CLK;
end process;
end Behavioral;