-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_flags.vhd
93 lines (70 loc) · 2.14 KB
/
test_flags.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
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY alu_test IS
END alu_test;
ARCHITECTURE testbench OF alu_test IS
signal A,B : std_logic_vector(7 DOWNTO 0);
signal Cin : std_logic;
signal Sel : std_logic_vector(3 DOWNTO 0);
signal Cout,Zout,Vout,Nout : std_logic;
signal F : std_logic_vector(7 DOWNTO 0);
BEGIN
alu_new : entity work.ALU GENERIC MAP (reg_size => 8)
PORT MAP (A=>A, B=>B, Cin=>Cin, sel=>sel, F=>F, Cout=>Cout,Zout=>Zout,Vout=>Vout,Nout=>Nout);
PROCESS
BEGIN
--------------------------------------------ZERO FLAG----------------------------------------------------------
A <= "00000000";
B <= "00000000";
Cin <= '0';
sel <= "0000";
ASSERT(Zout = '1')
REPORT "Error in Zero flag - partA"
SEVERITY ERROR;
A <= "00000000";
B <= "00000000";
Cin <= '0';
sel <= "0100";
ASSERT(Zout = '1')
REPORT "Error in Zero flag - partB"
SEVERITY ERROR;
A <= "00000000";
B <= "00000000";
Cin <= '0';
sel <= "1000";
ASSERT(Zout = '1')
REPORT "Error in Zero flag - partC"
SEVERITY ERROR;
A <= "00000000";
B <= "00000000";
Cin <= '0';
sel <= "1100";
ASSERT(Zout = '1')
REPORT "Error in Zero flag - partD"
SEVERITY ERROR;
---------------------------------------------OVERFLOW FLAG---------------------------------------------------------------
A <= "01111111";
B <= "01111111";
Cin <= '0';
sel <= "0001";
ASSERT(Vout = '1')
REPORT "Error in overflow flag at adding"
SEVERITY ERROR;
A <= "01111111";
B <= "10001111";
Cin <= '0';
sel <= "0010";
ASSERT(Vout = '1')
REPORT "Error in overflow flag at subtracting"
SEVERITY ERROR;
WAIT;
END PROCESS;
process
begin
--clock <= not clock;
--WAIT FOR 0.5 ns;
--clock <= not clock;
--wait FOR 0.5 ns;
end process ; -- switch_clock
END ARCHITECTURE;