-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsr_TB.vhd
104 lines (78 loc) · 1.98 KB
/
tsr_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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
library ieee;
use ieee.std_logic_1164.all;
entity tsr_TB is
end tsr_TB;
architecture testbench of tsr_TB is
signal reset_bar_tb, sh_ld_bar_tb : std_logic;
signal clk_tb : std_logic;
signal data_in_tb : std_logic_vector(7 downto 0);
signal data_out_tb : std_logic;
signal sim_end : boolean := false;
signal test_sig : std_logic := '1';
component tsr
port (
reset_bar, sh_ld_bar : in std_logic;
clk : in std_logic;
data_in : in std_logic_vector(7 downto 0);
data_out : out std_logic
);
end component;
constant period : time := 50 ns;
constant clk_per : time := 10 ns;
begin
DUT : tsr port map (
reset_bar => reset_bar_tb,
sh_ld_bar => sh_ld_bar_tb,
clk => clk_tb,
data_in => data_in_tb,
data_out => data_out_tb
);
clk_proc : process
begin
while(not sim_end) loop
clk_tb <= '1';
wait for clk_per / 2;
clk_tb <= '0';
wait for clk_per / 2;
end loop;
wait;
end process clk_proc;
stimulus : process
begin
test_sig <= '1';
data_in_tb <= "01110011";
sh_ld_bar_tb <= '0';
reset_bar_tb <= '1';
wait for clk_per * 2;
reset_bar_tb <= '0';
wait for clk_per * 2;
reset_bar_tb <= '1';
wait for clk_per * 2;
--sh_ld_bar_tb <= '0';
-- start shifting
sh_ld_bar_tb <= '1';
wait for clk_per * 12;
test_sig <= not test_sig;
data_in_tb <= "01011001";
wait for clk_per;
-- load the registers
sh_ld_bar_tb <= '0';
wait for clk_per;
-- start shifting
sh_ld_bar_tb <= '1';
wait for clk_per * 12;
test_sig <= not test_sig;
data_in_tb <= "01111001";
wait for clk_per;
-- load the registers
sh_ld_bar_tb <= '0';
wait for clk_per;
-- start shifting
sh_ld_bar_tb <= '1';
wait for clk_per * 12;
test_sig <= not test_sig;
wait for period * 5;
wait;
sim_end <= true;
end process stimulus;
end testbench;