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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [mpy_macs.v] - Blame information for rev 200

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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