| 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 |
|
|
/* - MPYS 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 |
|
|
if (r10 !== result[15:0])
|
| 60 |
|
|
begin
|
| 61 |
|
|
$display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
|
| 62 |
|
|
$display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
|
| 63 |
|
|
$display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
|
| 64 |
|
|
tb_error("====== SIGNED MULTIPLICATION: RESLO =====");
|
| 65 |
|
|
end
|
| 66 |
|
|
if (r11 !== result[31:16])
|
| 67 |
|
|
begin
|
| 68 |
|
|
$display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
|
| 69 |
|
|
$display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
|
| 70 |
|
|
$display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
|
| 71 |
|
|
tb_error("====== SIGNED MULTIPLICATION: RESHI =====");
|
| 72 |
|
|
end
|
| 73 |
|
|
if (r12 !== {16{result[31]}})
|
| 74 |
|
|
begin
|
| 75 |
|
|
$display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
|
| 76 |
|
|
$display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
|
| 77 |
|
|
$display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
|
| 78 |
|
|
tb_error("====== SIGNED MULTIPLICATION: SUMEXT =====");
|
| 79 |
|
|
end
|
| 80 |
|
|
|
| 81 |
|
|
if (r15[7:0]==8'h00)
|
| 82 |
|
|
$display("OP2 = 0x%h done", r9);
|
| 83 |
|
|
end
|
| 84 |
|
|
|
| 85 |
|
|
|
| 86 |
|
|
|
| 87 |
|
|
stimulus_done = 1;
|
| 88 |
|
|
end
|
| 89 |
|
|
|