-
Notifications
You must be signed in to change notification settings - Fork 1
/
C2C_TB.vhd
70 lines (49 loc) · 1.2 KB
/
C2C_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
library ieee;
use ieee.std_logic_1164.ALL;
entity C2C_TB is
end C2C_TB;
architecture behavior OF C2C_TB IS
component C2C
generic(width: integer); -- using a 8 bit C2C
port(
N : in std_logic_vector(7 downto 0);
S : in std_logic;
Z : out std_logic_vector(7 downto 0);
COUT : out std_logic
);
end component;
--Inputs
signal N : std_logic_vector(7 downto 0);
signal S : std_logic;
--Outputs
signal Z : std_logic_vector(7 downto 0);
signal COUT : std_logic;
begin
-- Instantiate the Unit Under Test (UUT)
UUT: C2C
generic map(width => 8)
port map(
N => N,
S => S,
Z => Z,
COUT => COUT
);
process
begin
N <= "00000000";
S <= '0';
wait for 100 ns;
N <= "01010101"; -- should not change
S <= '0';
wait for 20 ns;
N <= "01010101"; -- should return 2's complement: 10101011
S <= '1';
wait for 20 ns;
N <= "00000000"; -- should return 0
S <= '1';
wait for 20 ns;
N <= "00000000"; -- should return 0
S <= '0';
wait;
end process;
end;