blob: 0feff6fff68634b06f50718636aea634d8e3cda1 (
plain)
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
|
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity testbench is
end testbench;
architecture test of testbench is
constant clkPeriod : time := 100 ns;
signal simulationFinished : std_logic := '0';
component Function_Z3fooi is
port
(
clk : in std_logic;
reset : in std_logic;
input1 : in signed(31 downto 0);
output : out signed(31 downto 0);
ready : out std_logic
);
end component;
signal clk : std_logic;
signal reset : std_logic;
signal input1 : signed(31 downto 0);
signal output : signed(31 downto 0);
signal ready : std_logic;
begin
uut : Function_Z3fooi port map
(
clk => clk,
reset => reset,
input1 => input1,
output => output,
ready => ready
);
clkGeneration : process
begin
if not simulationFinished
then
clk <= '1';
wait for clkPeriod / 2;
clk <= '0';
wait for clkPeriod / 2;
else
wait;
end if;
end process clkGeneration;
simulation : process
procedure check
(
constant in1 : in integer;
constant outputExpected : in integer
) is
variable result : integer;
begin
input1 <= to_signed(in1, input1'length);
reset <= '1';
wait until rising_edge(clk);
reset <= '0';
wait until rising_edge(clk) and ready = '1';
result := to_integer(output);
assert result = outputExpected
report
"Unexpected result: " &
"intput1 = " & integer'image(in1) & "; " &
"output = " & integer'image(result) & "; " &
"outputExpected = " & integer'image(outputExpected)
severity failure;
end procedure check;
begin
check(10, 59);
check(0, 49);
simulationFinished <= '1';
wait;
end process simulation;
end architecture test;
|