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 |
|
|
/* - MPY 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 [31:0] result;
|
42 |
|
|
|
43 |
|
|
initial
|
44 |
|
|
begin
|
45 |
|
|
$display(" ===============================================");
|
46 |
|
|
$display("| START SIMULATION |");
|
47 |
|
|
$display(" ===============================================");
|
48 |
111 |
olivier.gi |
`ifdef MULTIPLIER
|
49 |
67 |
olivier.gi |
repeat(5) @(posedge mclk);
|
50 |
|
|
stimulus_done = 0;
|
51 |
|
|
i = 0;
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
for ( i=0; i < 'h10000; i=i+1)
|
55 |
|
|
begin
|
56 |
|
|
@(r15);
|
57 |
|
|
result = r8*r9;
|
58 |
|
|
if (r10 !== result[15:0])
|
59 |
|
|
begin
|
60 |
|
|
$display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
|
61 |
|
|
$display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
|
62 |
|
|
$display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", 0, result[31:16], result[15:0]);
|
63 |
|
|
tb_error("====== UNSIGNED MULTIPLICATION: RESLO =====");
|
64 |
|
|
end
|
65 |
|
|
if (r11 !== result[31:16])
|
66 |
|
|
begin
|
67 |
|
|
$display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
|
68 |
|
|
$display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
|
69 |
|
|
$display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", 0, result[31:16], result[15:0]);
|
70 |
|
|
tb_error("====== UNSIGNED MULTIPLICATION: RESHI =====");
|
71 |
|
|
end
|
72 |
|
|
if (r12 !== 16'h0000)
|
73 |
|
|
begin
|
74 |
|
|
$display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
|
75 |
|
|
$display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
|
76 |
|
|
$display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", 0, result[31:16], result[15:0]);
|
77 |
|
|
tb_error("====== UNSIGNED MULTIPLICATION: SUMEXT =====");
|
78 |
|
|
end
|
79 |
|
|
|
80 |
|
|
if (r15[7:0]==8'h00)
|
81 |
|
|
$display("OP2 = 0x%h done", r9);
|
82 |
|
|
end
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
stimulus_done = 1;
|
87 |
111 |
olivier.gi |
`else
|
88 |
|
|
|
89 |
|
|
$display(" ===============================================");
|
90 |
|
|
$display("| SIMULATION SKIPPED |");
|
91 |
|
|
$display("| (hardware multiplier not included) |");
|
92 |
|
|
$display(" ===============================================");
|
93 |
|
|
$finish;
|
94 |
|
|
`endif
|
95 |
67 |
olivier.gi |
end
|
96 |
|
|
|