OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [mpy_mpys.v] - Diff between revs 111 and 202

Only display areas with differences | Details | Blame | View Log

Rev 111 Rev 202
/*===========================================================================*/
/*===========================================================================*/
/* Copyright (C) 2001 Authors                                                */
/* Copyright (C) 2001 Authors                                                */
/*                                                                           */
/*                                                                           */
/* This source file may be used and distributed without restriction provided */
/* This source file may be used and distributed without restriction provided */
/* that this copyright statement is not removed from the file and that any   */
/* that this copyright statement is not removed from the file and that any   */
/* derivative work contains the original copyright notice and the associated */
/* derivative work contains the original copyright notice and the associated */
/* disclaimer.                                                               */
/* disclaimer.                                                               */
/*                                                                           */
/*                                                                           */
/* This source file is free software; you can redistribute it and/or modify  */
/* This source file is free software; you can redistribute it and/or modify  */
/* it under the terms of the GNU Lesser General Public License as published  */
/* it under the terms of the GNU Lesser General Public License as published  */
/* by the Free Software Foundation; either version 2.1 of the License, or    */
/* by the Free Software Foundation; either version 2.1 of the License, or    */
/* (at your option) any later version.                                       */
/* (at your option) any later version.                                       */
/*                                                                           */
/*                                                                           */
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public       */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public       */
/* License for more details.                                                 */
/* License for more details.                                                 */
/*                                                                           */
/*                                                                           */
/* You should have received a copy of the GNU Lesser General Public License  */
/* You should have received a copy of the GNU Lesser General Public License  */
/* along with this source; if not, write to the Free Software Foundation,    */
/* along with this source; if not, write to the Free Software Foundation,    */
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA        */
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA        */
/*                                                                           */
/*                                                                           */
/*===========================================================================*/
/*===========================================================================*/
/*                          HARDWARE MULTIPLIER                              */
/*                          HARDWARE MULTIPLIER                              */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Test the hardware multiplier:                                             */
/* Test the hardware multiplier:                                             */
/*                                - MPYS mode.                               */
/*                                - MPYS mode.                               */
/*                                                                           */
/*                                                                           */
/* Author(s):                                                                */
/* Author(s):                                                                */
/*             - Olivier Girard,    olgirard@gmail.com                       */
/*             - Olivier Girard,    olgirard@gmail.com                       */
/*                                                                           */
/*                                                                           */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* $Rev: 18 $                                                                */
/* $Rev: 18 $                                                                */
/* $LastChangedBy: olivier.girard $                                          */
/* $LastChangedBy: olivier.girard $                                          */
/* $LastChangedDate: 2009-08-04 23:44:12 +0200 (Tue, 04 Aug 2009) $          */
/* $LastChangedDate: 2009-08-04 23:44:12 +0200 (Tue, 04 Aug 2009) $          */
/*===========================================================================*/
/*===========================================================================*/
 
 
`define NO_TIMEOUT
`define NO_TIMEOUT
 
 
integer     i;
integer     i;
reg  signed [31:0] result;
reg  signed [31:0] result;
wire signed [15:0] r8_s = r8;
wire signed [15:0] r8_s = r8;
wire signed [15:0] r9_s = r9;
wire signed [15:0] r9_s = r9;
 
 
initial
initial
   begin
   begin
      $display(" ===============================================");
      $display(" ===============================================");
      $display("|                 START SIMULATION              |");
      $display("|                 START SIMULATION              |");
      $display(" ===============================================");
      $display(" ===============================================");
`ifdef MULTIPLIER
`ifdef MULTIPLIER
      repeat(5) @(posedge mclk);
      repeat(5) @(posedge mclk);
      stimulus_done = 0;
      stimulus_done = 0;
      i = 0;
      i = 0;
 
 
 
 
      for ( i=0; i < 'h10000; i=i+1)
      for ( i=0; i < 'h10000; i=i+1)
        begin
        begin
           @(r15);
           @(r15);
           result = r8_s*r9_s;
           result = r8_s*r9_s;
           if (r10 !== result[15:0])
           if (r10 !== result[15:0])
             begin
             begin
                $display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
                $display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
                $display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
                $display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
                $display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
                $display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
                tb_error("====== SIGNED MULTIPLICATION: RESLO =====");
                tb_error("====== SIGNED MULTIPLICATION: RESLO =====");
             end
             end
           if (r11 !== result[31:16])
           if (r11 !== result[31:16])
             begin
             begin
                $display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
                $display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
                $display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
                $display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
                $display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
                $display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
                tb_error("====== SIGNED MULTIPLICATION: RESHI =====");
                tb_error("====== SIGNED MULTIPLICATION: RESHI =====");
             end
             end
           if (r12 !== {16{result[31]}})
           if (r12 !== {16{result[31]}})
             begin
             begin
                $display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
                $display("ERROR: OP1 = 0x%h / OP2 = 0x%h", r8, r9);
                $display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
                $display("ERROR: Result is: SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", r12, r11, r10);
                $display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
                $display("ERROR: Expected : SUMEXT = 0x%h / RESHI = 0x%h / RESLO = 0x%h", {16{result[31]}}, result[31:16], result[15:0]);
                tb_error("====== SIGNED MULTIPLICATION: SUMEXT =====");
                tb_error("====== SIGNED MULTIPLICATION: SUMEXT =====");
             end
             end
 
 
           if (r15[7:0]==8'h00)
           if (r15[7:0]==8'h00)
             $display("OP2 = 0x%h done", r9);
             $display("OP2 = 0x%h done", r9);
        end
        end
 
 
 
 
 
 
      stimulus_done = 1;
      stimulus_done = 1;
`else
`else
 
 
       $display(" ===============================================");
       tb_skip_finish("|      (hardware multiplier not included)       |");
       $display("|               SIMULATION SKIPPED              |");
 
       $display("|      (hardware multiplier not included)       |");
 
       $display(" ===============================================");
 
       $finish;
 
`endif
`endif
   end
   end
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.