-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoplevel-testbench-multiplier.vhd
67 lines (59 loc) · 1.63 KB
/
toplevel-testbench-multiplier.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
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD_UNSIGNED.all;
entity testbenchMultiplier is
end;
architecture test of testbenchMultiplier is
component multiplier
port(
multiplier, multiplicand: in STD_LOGIC_VECTOR(31 downto 0);
result: out STD_LOGIC_VECTOR(31 downto 0)
);
end component;
signal sResult: STD_LOGIC_VECTOR(31 downto 0);
signal clk: STD_LOGIC;
begin
multiplier1: multiplier port map(
"00000000000000000001000011000000",
"00000000000000000001000011000000",
sResult
);
process begin
clk <= '1';
wait for 5 ns;
clk <= '0';
wait for 5 ns;
end process;
process(clk) begin
if(rising_edge(clk)) then
if(
sResult = "00000000000000000000000000000000"
) then
report "NO ERRORS: Simulation succeeded" severity failure;
else
report "Simulation failed" severity failure;
end if;
end if;
end process;
end;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.fixed_float_types.all;
use work.fixed_pkg.all;
entity multiplier is
port (
multiplier, multiplicand: in STD_LOGIC_VECTOR(31 downto 0);
result: out STD_LOGIC_VECTOR(31 downto 0)
);
end multiplier;
architecture multiplier of multiplier is
signal multiplier_fixed: sfixed(19 downto -12);
signal multiplicand_fixed: sfixed(19 downto -12);
signal sResult: sfixed(39 downto -24);
begin
multiplier_fixed <= to_sfixed(multiplier, multiplier_fixed);
multiplicand_fixed <= to_sfixed(multiplicand, multiplicand_fixed);
sResult <= multiplier_fixed * multiplicand_fixed;
result <= to_slv(sResult(19 downto -12));
end;