-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathALU_TB.vhd
63 lines (57 loc) · 1.48 KB
/
ALU_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
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ALU_TB is
end ALU_TB;
architecture testbench of ALU_TB is
-- entity under test
component ALU
port(
A: in STD_LOGIC_VECTOR(15 downto 0);
B: in STD_LOGIC_VECTOR(15 downto 0);
LOAD: in STD_LOGIC;
CLEAR: in STD_LOGIC;
CLOCK: in STD_LOGIC;
END_FLAG: out STD_LOGIC;
Z: out STD_LOGIC_VECTOR(31 downto 0)
);
end component;
-- signals
signal P, Q: STD_LOGIC_VECTOR(15 downto 0):= (others => '0');
signal R: STD_LOGIC_VECTOR(31 downto 0):= (others => '0');
signal flag: STD_LOGIC:= '0';
signal en, clk: STD_LOGIC:= '0';
signal clr: STD_LOGIC:= '1';
constant clk_period: TIME:= 10 ns;
begin
ALU1: ALU
port map(A => P, B => Q, LOAD => en, CLEAR => clr, CLOCK => clk, END_FLAG => flag, Z => R);
-- Clock
clk <= not clk after clk_period/2;
en <= '1';
clr <= '0';
-- Test Bits
process
begin
P <= "0000000000000000";
Q <= "0000000000000000";
wait for 2*clk_period;
P <= "0001001001011000";
Q <= "0000101001001001";
wait for 2*clk_period;
P <= "0100010101010101";
Q <= "0010100100100000";
wait for 2*clk_period;
P <= "0001110000110000";
Q <= "0000000111110000";
wait for 2*clk_period;
P <= "1000111110000000";
Q <= "0011100000000010";
wait for 2*clk_period;
P <= "0111100001000000";
Q <= "0000000001111110";
wait for 2*clk_period;
P <= "1111111111111111";
Q <= "1111111111111111";
wait for 2*clk_period;
end process;
end testbench;