1 |
67 |
olivier.gi |
/*===========================================================================*/
|
2 |
|
|
/* Copyright (C) 2001 Authors */
|
3 |
|
|
/* */
|
4 |
|
|
/* This source file may be used and distributed without restriction provided */
|
5 |
|
|
/* that this copyright statement is not removed from the file and that any */
|
6 |
|
|
/* derivative work contains the original copyright notice and the associated */
|
7 |
|
|
/* disclaimer. */
|
8 |
|
|
/* */
|
9 |
|
|
/* This source file is free software; you can redistribute it and/or modify */
|
10 |
|
|
/* it under the terms of the GNU Lesser General Public License as published */
|
11 |
|
|
/* by the Free Software Foundation; either version 2.1 of the License, or */
|
12 |
|
|
/* (at your option) any later version. */
|
13 |
|
|
/* */
|
14 |
|
|
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
|
15 |
|
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
16 |
|
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
|
17 |
|
|
/* License for more details. */
|
18 |
|
|
/* */
|
19 |
|
|
/* You should have received a copy of the GNU Lesser General Public License */
|
20 |
|
|
/* along with this source; if not, write to the Free Software Foundation, */
|
21 |
|
|
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
22 |
|
|
/* */
|
23 |
|
|
/*===========================================================================*/
|
24 |
|
|
/* HARDWARE MULTIPLIER */
|
25 |
|
|
/*---------------------------------------------------------------------------*/
|
26 |
|
|
/* Test the hardware multiplier: */
|
27 |
|
|
/* - MACS mode. */
|
28 |
|
|
/* */
|
29 |
|
|
/* Author(s): */
|
30 |
|
|
/* - Olivier Girard, olgirard@gmail.com */
|
31 |
|
|
/* */
|
32 |
|
|
/*---------------------------------------------------------------------------*/
|
33 |
|
|
/* $Rev: 18 $ */
|
34 |
|
|
/* $LastChangedBy: olivier.girard $ */
|
35 |
|
|
/* $LastChangedDate: 2009-08-04 23:44:12 +0200 (Tue, 04 Aug 2009) $ */
|
36 |
|
|
/*===========================================================================*/
|
37 |
|
|
|
38 |
|
|
`define NO_TIMEOUT
|
39 |
|
|
|
40 |
|
|
integer i;
|
41 |
|
|
reg signed [31:0] result;
|
42 |
|
|
wire signed [15:0] r8_s = r8;
|
43 |
|
|
wire signed [15:0] r9_s = r9;
|
44 |
|
|
|
45 |
|
|
initial
|
46 |
|
|
begin
|
47 |
|
|
$display(" ===============================================");
|
48 |
|
|
$display("| START SIMULATION |");
|
49 |
|
|
$display(" ===============================================");
|
50 |
|
|
repeat(5) @(posedge mclk);
|
51 |
|
|
stimulus_done = 0;
|
52 |
|
|
i = 0;
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
for ( i=0; i < 'h10000; i=i+1)
|
56 |
|
|
begin
|
57 |
|
|
@(r15);
|
58 |
|
|
result = r8_s*r9_s;
|
59 |
|
|
result = 32'hC000_0000 + result;
|
60 |
|
|
if (r10 !== result[15:0])
|
61 |
|
|
begin
|
62 |
|
|
$display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
|
63 |
|
|
$display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
|
64 |
|
|
$display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
|
65 |
|
|
tb_error("====== SIGNED MULTIPLY ACCUMULATE: RESLO =====");
|
66 |
|
|
end
|
67 |
|
|
if (r11 !== result[31:16])
|
68 |
|
|
begin
|
69 |
|
|
$display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
|
70 |
|
|
$display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
|
71 |
|
|
$display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
|
72 |
|
|
tb_error("====== SIGNED MULTIPLY ACCUMULATE: RESHI =====");
|
73 |
|
|
end
|
74 |
|
|
if (r12 !== {16{result[31]}})
|
75 |
|
|
begin
|
76 |
|
|
$display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
|
77 |
|
|
$display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
|
78 |
|
|
$display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
|
79 |
|
|
tb_error("====== SIGNED MULTIPLY ACCUMULATE: SUMEXT =====");
|
80 |
|
|
end
|
81 |
|
|
|
82 |
|
|
if (r15[7:0]==8'h00)
|
83 |
|
|
$display("OP2 = 0x%h done", r9);
|
84 |
|
|
end
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
stimulus_done = 1;
|
89 |
|
|
end
|
90 |
|
|
|