1
|
|
2
|
-- Copyright (C) 1996 Morgan Kaufmann Publishers, Inc
|
3
|
|
4
|
-- This file is part of VESTs (Vhdl tESTs).
|
5
|
|
6
|
-- VESTs is free software; you can redistribute it and/or modify it
|
7
|
-- under the terms of the GNU General Public License as published by the
|
8
|
-- Free Software Foundation; either version 2 of the License, or (at
|
9
|
-- your option) any later version.
|
10
|
|
11
|
-- VESTs is distributed in the hope that it will be useful, but WITHOUT
|
12
|
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
13
|
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
14
|
-- for more details.
|
15
|
|
16
|
-- You should have received a copy of the GNU General Public License
|
17
|
-- along with VESTs; if not, write to the Free Software Foundation,
|
18
|
-- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
|
20
|
-- ---------------------------------------------------------------------
|
21
|
--
|
22
|
-- $Id: ch_06_mact-bv.vhd,v 1.3 2001-11-03 23:19:37 paw Exp $
|
23
|
-- $Revision: 1.3 $
|
24
|
--
|
25
|
-- ---------------------------------------------------------------------
|
26
|
|
27
|
library ieee;
|
28
|
use ieee.std_logic_1164.all;
|
29
|
|
30
|
architecture bench_verify of mac_test is
|
31
|
|
32
|
signal clk, clr, behavioral_ovf, rtl_ovf : std_ulogic := '0';
|
33
|
signal x_real, x_imag,
|
34
|
y_real, y_imag,
|
35
|
behavioral_s_real, behavioral_s_imag,
|
36
|
rtl_s_real, rtl_s_imag : std_ulogic_vector(15 downto 0);
|
37
|
|
38
|
type complex is record
|
39
|
re, im : real;
|
40
|
end record;
|
41
|
|
42
|
signal x, y, behavioral_s, rtl_s : complex := (0.0, 0.0);
|
43
|
|
44
|
constant Tpw_clk : time := 50 ns;
|
45
|
|
46
|
begin
|
47
|
|
48
|
x_real_converter : entity work.to_vector(behavioral) port map (x.re, x_real);
|
49
|
x_imag_converter : entity work.to_vector(behavioral) port map (x.im, x_imag);
|
50
|
y_real_converter : entity work.to_vector(behavioral) port map (y.re, y_real);
|
51
|
y_imag_converter : entity work.to_vector(behavioral) port map (y.im, y_imag);
|
52
|
|
53
|
dut_behavioral : entity work.mac(behavioral)
|
54
|
port map ( clk, clr,
|
55
|
x_real, x_imag, y_real, y_imag,
|
56
|
behavioral_s_real, behavioral_s_imag, behavioral_ovf );
|
57
|
|
58
|
dut_rtl : entity work.mac(rtl)
|
59
|
port map ( clk, clr,
|
60
|
x_real, x_imag, y_real, y_imag,
|
61
|
rtl_s_real, rtl_s_imag, rtl_ovf );
|
62
|
|
63
|
behavioral_s_real_converter :
|
64
|
entity work.to_fp(behavioral) port map (behavioral_s_real, behavioral_s.re);
|
65
|
behavioral_s_imag_converter :
|
66
|
entity work.to_fp(behavioral) port map (behavioral_s_imag, behavioral_s.im);
|
67
|
|
68
|
rtl_s_real_converter :
|
69
|
entity work.to_fp(behavioral) port map (rtl_s_real, rtl_s.re);
|
70
|
rtl_s_imag_converter :
|
71
|
entity work.to_fp(behavioral) port map (rtl_s_imag, rtl_s.im);
|
72
|
|
73
|
|
74
|
clock_gen : process is
|
75
|
begin
|
76
|
clk <= '1' after Tpw_clk, '0' after 2 * Tpw_clk;
|
77
|
wait for 2 * Tpw_clk;
|
78
|
end process clock_gen;
|
79
|
|
80
|
|
81
|
stimulus : process is
|
82
|
begin
|
83
|
-- first sequence
|
84
|
clr <= '1'; wait until clk = '0';
|
85
|
x <= (+0.5, +0.5); y <= (+0.5, +0.5); clr <= '1'; wait until clk = '0';
|
86
|
x <= (+0.2, +0.2); y <= (+0.2, +0.2); clr <= '1'; wait until clk = '0';
|
87
|
x <= (+0.1, -0.1); y <= (+0.1, +0.1); clr <= '1'; wait until clk = '0';
|
88
|
x <= (+0.1, -0.1); y <= (+0.1, +0.1); clr <= '0'; wait until clk = '0';
|
89
|
|
90
|
-- should be (0.4, 0.58) when it falls out the other end
|
91
|
|
92
|
clr <= '0'; wait until clk = '0';
|
93
|
x <= (+0.5, +0.5); y <= (+0.5, +0.5); clr <= '0'; wait until clk = '0';
|
94
|
x <= (+0.5, +0.5); y <= (+0.1, +0.1); clr <= '0'; wait until clk = '0';
|
95
|
x <= (+0.5, +0.5); y <= (+0.5, +0.5); clr <= '1'; wait until clk = '0';
|
96
|
x <= (-0.5, +0.5); y <= (-0.5, +0.5); clr <= '0'; wait until clk = '0';
|
97
|
clr <= '0'; wait until clk = '0';
|
98
|
clr <= '0'; wait until clk = '0';
|
99
|
clr <= '0'; wait until clk = '0';
|
100
|
clr <= '1'; wait until clk = '0';
|
101
|
|
102
|
wait;
|
103
|
end process stimulus;
|
104
|
|
105
|
|
106
|
verifier : process
|
107
|
|
108
|
constant epsilon : real := 4.0E-5; -- 1-bit error in 15-bit mantissa
|
109
|
|
110
|
begin
|
111
|
wait until clk = '0';
|
112
|
assert behavioral_ovf = rtl_ovf
|
113
|
report "Overflow flags differ" severity error;
|
114
|
if behavioral_ovf = '0' and rtl_ovf = '0' then
|
115
|
assert abs (behavioral_s.re - rtl_s.re) < epsilon
|
116
|
report "Real sums differ" severity error;
|
117
|
assert abs (behavioral_s.im - rtl_s.im) < epsilon
|
118
|
report "Imag sums differ" severity error;
|
119
|
end if;
|
120
|
end process verifier;
|
121
|
|
122
|
end architecture bench_verify;
|