-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTBMultiplierController.vhdl
90 lines (72 loc) · 2.21 KB
/
TBMultiplierController.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY TBMultiplierController IS
END ENTITY TBMultiplierController;
ARCHITECTURE Behavioral OF TBMultiplierController IS
COMPONENT MultiplierController IS PORT (
operand0, operand1 : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
multiply : IN STD_LOGIC;
clk : IN STD_LOGIC;
product : OUT STD_LOGIC_VECTOR (15 DOWNTO 0);
done : OUT STD_LOGIC
);
END COMPONENT MultiplierController;
SIGNAL s_operand0 : STD_LOGIC_VECTOR (7 DOWNTO 0) := (OTHERS => '0');
SIGNAL s_operand1 : STD_LOGIC_VECTOR (7 DOWNTO 0) := (OTHERS => '0');
SIGNAL s_multiply : STD_LOGIC := '0';
SIGNAL s_clk : STD_LOGIC := '0';
SIGNAL s_product : STD_LOGIC_VECTOR (15 DOWNTO 0);
SIGNAL s_done : STD_LOGIC;
CONSTANT PERIOD: TIME := 10 NS;
BEGIN
-- uut
UUT: MultiplierController PORT MAP (s_operand0, s_operand1, s_multiply, s_clk, s_product, s_done);
-- process to simulate the clk
PROCESS
BEGIN
WAIT FOR PERIOD / 2;
s_clk <= NOT s_clk;
END PROCESS;
-- process to do calculation
PROCESS
BEGIN
WAIT FOR PERIOD / 2;
s_operand0 <= x"0B";
s_operand1 <= x"07";
s_multiply <= '1';
WAIT FOR PERIOD;
s_multiply <= '0';
WAIT FOR PERIOD * 10;
s_operand0 <= x"5A";
s_operand1 <= x"A5";
s_multiply <= '1';
WAIT FOR PERIOD;
s_multiply <= '0';
WAIT FOR PERIOD * 10;
s_operand0 <= x"10";
s_operand1 <= x"10";
s_multiply <= '1';
WAIT FOR PERIOD;
s_multiply <= '0';
WAIT FOR PERIOD * 10;
s_operand0 <= x"FF";
s_operand1 <= x"FF";
s_multiply <= '1';
WAIT FOR PERIOD;
s_multiply <= '0';
WAIT FOR PERIOD * 10;
s_operand0 <= x"01";
s_operand1 <= x"F1";
s_multiply <= '1';
WAIT FOR PERIOD;
s_multiply <= '0';
WAIT FOR PERIOD * 10;
s_operand0 <= x"00";
s_operand1 <= x"F1";
s_multiply <= '1';
WAIT FOR PERIOD;
s_multiply <= '0';
WAIT FOR PERIOD * 9;
WAIT FOR PERIOD / 2;
END PROCESS;
END ARCHITECTURE Behavioral;