-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgray_counter_tb.vhd
66 lines (50 loc) · 1.17 KB
/
gray_counter_tb.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity gray_counter_tb is
end entity gray_counter_tb;
architecture RTL of gray_counter_tb is
constant COUNTER_WIDTH : natural := 4;
signal clk : std_logic;
signal rst : std_logic;
signal en_i : std_logic;
signal gray_count_o : std_logic_vector (COUNTER_WIDTH-1 downto 0);
constant clk_period : time := 20 ns;
constant nr_stages : natural := 3;
signal stop : boolean := false;
begin
gray_counter_inst : entity work.gray_counter
generic map(
COUNTER_WIDTH => COUNTER_WIDTH
)
port map(
clk => clk,
rst => rst,
en_i => en_i,
gray_count_o => gray_count_o
);
clk_stim : process is
begin
clk <= '0';
while stop=false loop
wait for clk_period/2;
clk <= not clk;
end loop;
wait;
end process clk_stim;
stim_proc : process is
begin
rst <= '1';
en_i <= '0';
wait for clk_period;
rst <= '0';
wait for clk_period;
for i in 1 to 2**COUNTER_WIDTH loop
en_i <= '1';
wait for clk_period;
end loop;
en_i <= '0';
stop <= true;
wait;
end process stim_proc;
end architecture RTL;