-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTFF_tb.vhdl
67 lines (52 loc) · 1014 Bytes
/
TFF_tb.vhdl
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
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
ENTITY tff_tb IS END tff_tb;
ARCHITECTURE tff_arch_tb OF tff_tb IS
component tbc is
port (
t, clk : IN STD_LOGIC;
q : INOUT STD_LOGIC);
END COMPONENT;
CONSTANT period : TIME := 50 ns;
signal done : boolean := false;
signal t, clk, q : STD_LOGIC := '0';
begin
u1 : tbc
port map(
clk => clk,
t => t,
q => q
);
clkprocess: process(done, clk)
begin
if (not done) then
clk <= not clk after period / 2;
end if;
end process;
PROCESS (clk)
BEGIN
IF rising_edge(clk) THEN
IF t = '1' THEN
q <= NOT q;
END IF;
END IF;
END PROCESS;
testbench: process
begin
wait until (clk = '0');
t <= '0';
wait for period;
t <= '1';
wait for period;
t <= '0';
wait for period;
t <= '1';
wait for period;
t <= '1';
wait for period;
t <= '0';
wait for period;
done <= true;
wait;
end process;
end tff_arch_tb;