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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [DFPDivide128_tb.v] - Blame information for rev 67

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 67 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2006-2022  Robert Finch, Waterloo
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@finitron.ca
7
//       ||
8
//
9
//      DFPDivide128_tb.v
10
//              - decimal floating point divider test bench
11
//
12
// BSD 3-Clause License
13
// Redistribution and use in source and binary forms, with or without
14
// modification, are permitted provided that the following conditions are met:
15
//
16
// 1. Redistributions of source code must retain the above copyright notice, this
17
//    list of conditions and the following disclaimer.
18
//
19
// 2. Redistributions in binary form must reproduce the above copyright notice,
20
//    this list of conditions and the following disclaimer in the documentation
21
//    and/or other materials provided with the distribution.
22
//
23
// 3. Neither the name of the copyright holder nor the names of its
24
//    contributors may be used to endorse or promote products derived from
25
//    this software without specific prior written permission.
26
//
27
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//
38
//                                                                          
39
// ============================================================================
40
 
41
module DFPDivide128_tb();
42
parameter N=34;
43
reg rst;
44
reg clk;
45
reg [15:0] adr;
46
reg [127:0] a,b;
47
wire [127:0] o, sqrto;
48
reg [3:0] rm;
49
wire done;
50
 
51
integer n;
52
reg [127:0] a1, b1;
53
reg [39:0] sum_cc;
54
 
55
integer outfile;
56
 
57
initial begin
58
        rst = 1'b0;
59
        clk = 1'b0;
60
        adr = 0;
61
        a = $urandom(1);
62
        b = 1;
63
        #20 rst = 1;
64
        #50 rst = 0;
65
        #5000000  $fclose(outfile);
66
        #10 $finish;
67
end
68
 
69
always #5
70
        clk = ~clk;
71
 
72
genvar g;
73
generate begin : gRand
74
        for (g = 0; g < 128; g = g + 4) begin
75
                always @(posedge clk) begin
76
                        a1[g+3:g] <= $urandom() % 16;
77
                        b1[g+3:g] <= $urandom() % 16;
78
                end
79
        end
80
end
81
endgenerate
82
 
83
reg [15:0] count;
84
always @(posedge clk)
85
if (rst) begin
86
        adr <= 0;
87
        count <= 0;
88
        sum_cc = 0;
89
end
90
else
91
begin
92
  if (adr==0) begin
93
    outfile = $fopen("d:/cores2022/rf6809/rtl/dfpu/test_bench/DFPDivide128_tvo.txt", "wb");
94
    $fwrite(outfile, "rm ------ A ------  ------- B ------  - DUT Quotient - - Square root -\n");
95
    sum_cc = 0;
96
  end
97
        count <= count + 1;
98
        if (count > 2000)
99
                count <= 1'd1;
100
        if (count==2) begin
101
                a <= a1;
102
                b <= b1;
103
                rm <= adr[15:13];
104
                //ad <= memd[adr][63: 0];
105
                //bd <= memd[adr][127:64];
106
        end
107
        if (adr==1 && count==2) begin
108
                a <= 128'h25ffc000000000000000000000000000;     // 1
109
                b <= 128'h25ffc000000000000000000000000000;     // 1
110
        end
111
        if (adr==2 && count==2) begin
112
                a <= 128'h26000000000000000000000000000000;     // 10
113
                b <= 128'h26000000000000000000000000000000;     // 10
114
        end
115
        if (adr==3 && count==2) begin
116
                a <= 128'h26004000000000000000000000000000;     // 100
117
                b <= 128'h26000000000000000000000000000000;     // 10
118
        end
119
        if (adr==4 && count==2) begin
120
                a <= 128'h26008000000000000000000000000000;     // 1000
121
                a <= 128'h26004000000000000000000000000000;     // 100
122
        end
123
        if (adr==5 && count==2) begin
124
                a <= 128'h2601934B9C0C00000000000000000000;     // 12345678
125
                b <= 128'h26000000000000000000000000000000;     // 10
126
        end
127
        if (count > 2000) begin
128
                sum_cc = sum_cc + u6.u1.u2.clkcnt;
129
          $fwrite(outfile, "%h\t%h\t%h\t%h\t%h\t%d\t%f\n", rm, a, b, o, sqrto, u6.u1.u2.clkcnt, $itor(sum_cc) / $itor(adr));
130
                adr <= adr + 1;
131
        end
132
end
133
 
134
//fpMulnr #(64) u1 (clk, 1'b1, a, b, o, rm);//, sign_exe, inf, overflow, underflow);
135
DFPDivide128nr #(.N(N)) u6 (
136
  .rst(rst),
137
  .clk(clk),
138
  .ce(1'b1),
139
  .ld(count==3),
140
  .op(1'b0),
141
  .a(a),
142
  .b(b),
143
  .o(o),
144
  .rm(rm),
145
  .done(done),
146
  .sign_exe(),
147
  .inf(),
148
  .overflow(),
149
  .underflow()
150
);
151
 
152
//DFPSqrt128nr #(.N(N)) u1 (rst, clk, 1'b1, count==3, a, sqrto, rm);//, sign_exe, inf, overflow, underflow);
153
 
154
endmodule

powered by: WebSVN 2.1.0

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