-
Notifications
You must be signed in to change notification settings - Fork 1
/
TestBenchMultiplier.vhdtst
69 lines (57 loc) · 1.98 KB
/
TestBenchMultiplier.vhdtst
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
-- Testbench for multilier
Library IEEE;
Use IEEE.std_logic_1164.all;
Use IEEE.std_logic_textio.all;
Use STD.textio.all;
USE ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
USE ieee.numeric_std.ALL;
entity TestBenchMultiplier is
end TestBenchMultiplier;
architecture stimulus of TestBenchMultiplier is
component generic_multiplier
GENERIC(
WIDTH : integer := 16
);
port(
multiplicant : IN std_logic_vector (WIDTH-1 DOWNTO 0);
multiplier : IN std_logic_vector (WIDTH-1 DOWNTO 0);
product : OUT std_logic_vector (WIDTH+WIDTH-1 DOWNTO 0);
twocomp : IN std_logic
);
end component;
signal multiplicant : std_logic_vector(15 downto 0);
signal multiplier : std_logic_vector(15 downto 0);
signal product : std_logic_vector(31 downto 0);
signal twocomp : std_logic;
begin
-- DUT is Device Under Test
DUT:generic_multiplier generic map(WIDTH => 16) port map(
multiplicant => multiplicant,
multiplier => multiplier,
product => product,
twocomp => twocomp
);
STIMULUS0:process
begin
-- insert stimulus here
multiplicant <= (others => '0');
multiplier <= (others => '0');
twocomp <= '0';
wait for 2 ns;
multiplicant <= conv_std_logic_vector(2, 16);
multiplier <= conv_std_logic_vector(8, 16);
twocomp <= '0';
wait for 2 ns;
-- Negative test (signed)
multiplicant <= conv_std_logic_vector(-2, 16);
multiplier <= conv_std_logic_vector(8, 16);
twocomp <= '1';
wait for 2 ns;
-- Negative test (signed)
multiplicant <= conv_std_logic_vector(-2, 16);
multiplier <= conv_std_logic_vector(-8, 16);
twocomp <= '1';
wait for 2 ns;
end process;
end architecture;