-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_posit16_adder.vhd
79 lines (62 loc) · 2.01 KB
/
test_posit16_adder.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
68
69
70
71
72
73
74
75
76
77
78
79
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use STD.textio.all;
use ieee.std_logic_textio.all;
use work.all;
entity test_posit16_adder is
end test_posit16_adder;
architecture test of test_posit16_adder is
component posit16_adder
port (
x : in std_logic_vector(15 downto 0);
y : in std_logic_vector(15 downto 0);
r : out std_logic_vector(15 downto 0)
);
end component;
file file_in : text;
file file_out : text;
signal x : std_logic_vector(15 downto 0);
signal y : std_logic_vector(15 downto 0);
signal r : std_logic_vector(15 downto 0);
begin
DUT: posit16_adder
port map(
x => x,
y => y,
r => r
);
process
variable TEST_CASE : integer := 1; -- Change this to select automatic
-- test '1' or custom test '0'
variable line_in : line;
variable line_out : line;
variable add1 : std_logic_vector(15 downto 0);
variable add2 : std_logic_vector(15 downto 0);
begin
if TEST_CASE = 1 then
file_open(file_in, "posit_input.txt", read_mode);
file_open(file_out, "posit_output.txt", write_mode);
while not endfile(file_in) loop
readline(file_in, line_in);
read(line_in, add1);
readline(file_in, line_in);
read(line_in, add2);
x <= add1;
y <= add2;
wait for 1 ns;
write(line_out, r, right, 16);
writeline(file_out, line_out);
end loop;
file_close(file_in);
file_close(file_out);
else
x <= "1000011100010110";
y <= "0000000000000010";
wait for 1 ns;
end if;
assert(false)
report "Simulation finished"
severity failure;
end process;
end test;