-
Notifications
You must be signed in to change notification settings - Fork 0
/
tdr_TB.vhd
118 lines (83 loc) · 2.15 KB
/
tdr_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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
library ieee;
use ieee.std_logic_1164.all;
entity tdr_TB is
end tdr_TB;
architecture testbench of tdr_TB is
signal reset_bar_tb, load_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_vector(7 downto 0);
signal sim_end : boolean := false;
signal test_sig : std_logic := '1';
component tdr
port(
reset_bar, load_bar : in std_logic;
clk : in std_logic;
data_in : in std_logic_vector(7 downto 0);
data_out : out std_logic_vector(7 downto 0)
);
end component;
constant period : time := 50 ns;
constant clk_per : time := 10 ns;
begin
DUT : tdr port map (
reset_bar => reset_bar_tb,
load_bar => load_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;
--clk_tb <= not clk_tb after period / 2;
stimulus : process
begin
test_sig <= '1';
data_in_tb <= "11110000";
load_bar_tb <= '1';
reset_bar_tb <= '1';
wait for period / 2;
reset_bar_tb <= '0';
wait for period;
reset_bar_tb <= '1';
wait for period / 2;
load_bar_tb <= '0';
wait for period /2 ;
load_bar_tb <= '1';
wait for period / 2;
wait for period;
data_in_tb <= "00001110";
wait for period / 2;
load_bar_tb <= '0';
wait for period / 2;
load_bar_tb <= '1';
wait for period;
data_in_tb <= "10101010";
wait for period / 2;
load_bar_tb <= '0';
wait for period / 2;
load_bar_tb <= '1';
wait for period;
data_in_tb <= "11001111";
wait for period / 2;
load_bar_tb <= '0';
wait for period / 2;
load_bar_tb <= '1';
wait for period;
data_in_tb <= "11111101";
wait for period / 2;
load_bar_tb <= '0';
wait for period / 2;
load_bar_tb <= '1';
wait;
sim_end <= true;
end process stimulus;
end testbench;