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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [fpDivide_tb.v] - Blame information for rev 53

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

Line No. Rev Author Line
1 49 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2006-2020  Robert Finch, Waterloo
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@finitron.ca
7
//       ||
8
//
9
//      fpDivider_tb.v
10
//              - 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
//      Floating Point Multiplier / Divider
40
//
41
//      This multiplier/divider handles denormalized numbers.
42
//      The output format is of an internal expanded representation
43
//      in preparation to be fed into a normalization unit, then
44
//      rounding. Basically, it's the same as the regular format
45
//      except the mantissa is doubled in size, the leading two
46
//      bits of which are assumed to be whole bits.
47
//
48
//
49
// ============================================================================
50
 
51
module fpDivide_tb();
52
reg rst;
53
reg clk;
54
reg [15:0] adr;
55
reg [63:0] a,b;
56
wire [63:0] o;
57
reg [63:0] ad,bd;
58
wire [63:0] od;
59
reg [3:0] rm;
60
 
61
wire [63:0] doubleA = {a[31], a[30], {3{~a[30]}}, a[29:23], a[22:0], {29{1'b0}}};
62
wire [63:0] doubleB = {b[31], b[30], {3{~b[30]}}, b[29:23], b[22:0], {29{1'b0}}};
63
 
64
integer outfile;
65
 
66
initial begin
67
        rst = 1'b0;
68
        clk = 1'b0;
69
        adr = 0;
70
        a = $urandom(1);
71
        b = 1;
72
        #20 rst = 1;
73
        #50 rst = 0;
74
        #1000000  $fclose(outfile);
75
        #10 $finish;
76
end
77
 
78
always #5
79
        clk = ~clk;
80
 
81
reg [7:0] count;
82
always @(posedge clk)
83
if (rst) begin
84
        adr <= 0;
85
        count <= 0;
86
end
87
else
88
begin
89
  if (adr==0) begin
90
    outfile = $fopen("d:/cores2020/rtf64/v2/rtl/verilog/cpu/fpu/test_bench/fpDivide_tvo.txt", "wb");
91
    $fwrite(outfile, "rm ------ A ------  ------- B ------  - DUT Quotient - - SIM Quotient -\n");
92
  end
93
        count <= count + 1;
94
        if (count > 52)
95
                count <= 1'd1;
96
        if (count==2) begin
97
                a[31:0] <= $urandom();
98
                b[31:0] <= $urandom();
99
                a[63:32] <= $urandom();
100
                b[63:32] <= $urandom();
101
                rm <= adr[15:13];
102
                //ad <= memd[adr][63: 0];
103
                //bd <= memd[adr][127:64];
104
        end
105
        if (count==51) begin
106
          $fwrite(outfile, "%h\t%h\t%h\t%h\t%h%c\n", rm, a, b, o, $realtobits($bitstoreal(a) / $bitstoreal(b)),$realtobits($bitstoreal(a) / $bitstoreal(b))!=o ? "*":" ");
107
                adr <= adr + 1;
108
        end
109
end
110
 
111
//fpMulnr #(64) u1 (clk, 1'b1, a, b, o, rm);//, sign_exe, inf, overflow, underflow);
112
fpDividenr u6 (
113
  .rst(rst),
114
  .clk(clk),
115
  .clk4x(1'b0),
116
  .ce(1'b1),
117
  .ld(count==3),
118
  .op(1'b0),
119
  .a(a),
120
  .b(b),
121
  .o(o),
122
  .rm(rm),
123
  .done(),
124
  .sign_exe(),
125
  .inf(),
126
  .overflow(),
127
  .underflow()
128
  );
129
 
130
endmodule

powered by: WebSVN 2.1.0

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