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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [mult128x128_tb.sv] - Blame information for rev 73

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 73 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2020  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch@finitron.ca
6
//       ||
7
//
8
//      mult128x128_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 mult128x128_tb();
39
reg clk;
40
reg [23:0] cnt;
41
 
42
reg [127:0] a, b;
43
wire [255:0] o;
44
wire [255:0] p = a * b;
45
 
46
integer outfile;
47
initial begin
48
  a = $urandom(1);
49
  b = $urandom(1);
50
        // Initialize Inputs
51
        clk = 1;
52
        cnt = 0;
53
        // Wait 100 ns for global reset to finish
54
        #100000000 $fclose(outfile);
55
        #100 $finish;
56
end
57
 
58
 
59
always #5 clk = ~clk;
60
 
61
//mult128x128 u1 (clk, 1'b1, a, b, o);
62
mult128x128seq u2 (clk, cnt[8:0]==9'd2, a, b, o);
63
 
64
always @(posedge clk)
65
begin
66
  cnt <= cnt + 1;
67
  case(cnt[23:9])
68
  0:
69
    begin
70
      a <= 128'h00a;
71
      b <= 128'h00a;
72
    end
73
  1:
74
    begin
75
      a <= 128'h00a786bb752275222b913c4e93db9923;
76
      b <= 128'h44f3a2773f6cd5714108b38cbf9ed32f;
77
    end
78
  2:
79
    begin
80
      a <= 128'd21;
81
      b <= 128'd1700000;
82
    end
83
  3:
84
    begin
85
      a <= 128'd215000;
86
      b <= 128'd11;
87
    end
88
  default:
89
    if (cnt[8:0]==5'd0) begin
90
      a[31:0] <= $urandom();
91
      b[31:0] <= $urandom();
92
      if (cnt[23:5] > 19'h200) begin
93
        a[63:32] <= $urandom();
94
        b[63:32] <= $urandom();
95
      end
96
      if (cnt[23:5] > 19'h400) begin
97
        a[63:32] <= $urandom();
98
        b[63:32] <= $urandom();
99
        a[95:64] <= $urandom();
100
        b[95:64] <= $urandom();
101
        a[127:96] <= $urandom();
102
        b[127:96] <= $urandom();
103
      end
104
    end
105
  endcase
106
end
107
 
108
initial outfile = $fopen("d:/cores2022/rf6809/rtl/fpu/test_bench/mult128x128_tvo.txt", "wb");
109
  always @(posedge clk) begin
110
    if (cnt[8:0]==9'h140)
111
     $fwrite(outfile, "%c%h\t%h\t%h\t%h\n",o!=p ? "*" : " ",a,b,o, p);
112
  end
113
 
114
endmodule

powered by: WebSVN 2.1.0

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