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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [mult32x32_tb.sv] - Blame information for rev 77

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

Line No. Rev Author Line
1 72 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2020-2022  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch@finitron.ca
6
//       ||
7
//
8
//      mult32x32_tb.sv
9
//
10
// BSD 3-Clause License
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are met:
13
//
14
// 1. Redistributions of source code must retain the above copyright notice, this
15
//    list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright notice,
18
//    this list of conditions and the following disclaimer in the documentation
19
//    and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the copyright holder nor the names of its
22
//    contributors may be used to endorse or promote products derived from
23
//    this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
//
36
// ============================================================================
37
 
38
module mult32x32_tb();
39
reg clk;
40
reg [23:0] count;
41
reg [31:0] adr;
42
 
43
reg rst;
44
reg [31:0] a, b;
45
wire [63:0] o;
46
wire [63:0] p = a * b;
47
 
48
always #5 clk = ~clk;
49
 
50
mult32x32 u1 (clk, 1'b1, a, b, o);
51
 
52
integer outfile;
53
 
54
initial begin
55
        rst = 1'b0;
56
        clk = 1'b0;
57
        #20 rst = 1;
58
        #50 rst = 0;
59 73 robfinch
        #10000000  $fclose(outfile);
60 72 robfinch
        #10 $finish;
61
end
62
 
63
always #5
64
        clk = ~clk;
65 73 robfinch
//a25e46ad      a76da76d        6a320c6f94e7f2a9        6a310c6f94e7f2a9*
66
//147c147c      67589e7f        08460393acd2b184        08450393acd2b184*
67 72 robfinch
 
68
always_ff @(posedge clk)
69
if (rst) begin
70
        adr <= 0;
71
        count <= 0;
72
        a <= $urandom(1);
73
end
74
else
75
begin
76
  if (adr==0) begin
77
    outfile = $fopen("d:/cores2022/rf6809/rtl/fpu/test_bench/mult32x32_tvo.txt", "wb");
78
    $fwrite(outfile, "--- A ---  ---- B ----  - DUT Product -  - SIM Product -\n");
79
  end
80
        count <= count + 1;
81
        if (count > 12)
82
                count <= 1'd1;
83
        if (count==2) begin
84
                case (adr)
85
          1:
86
            begin
87 73 robfinch
              a <= 32'ha25e46ad;
88
              b <= 32'ha76da76d;
89 72 robfinch
            end
90
          2:
91
            begin
92 73 robfinch
              a <= 32'h147c147c;
93
              b <= 32'h67589e7f;
94 72 robfinch
            end
95
          3:
96
            begin
97
              a <= 32'd215000;
98
              b <= 32'd11;
99
            end
100
          default:
101
                begin
102
                                a[31:0] <= $urandom();
103
                                b[31:0] <= $urandom();
104
                        end
105
          endcase
106
        end
107
        if (count==12) begin
108
          $fwrite(outfile, "%h\t%h\t%h\t%h%c\n", a, b, o, p,p!=o ? "*":" ");
109
                adr <= adr + 1;
110
        end
111
end
112
 
113
endmodule

powered by: WebSVN 2.1.0

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