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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [DFPMultiply_tb.v] - Blame information for rev 87

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

Line No. Rev Author Line
1 54 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
//      DFPMultiply_tb.v
10
//              - decimal floating point multiplier test bench
11
//
12
// This source file is free software: you can redistribute it and/or modify 
13
// it under the terms of the GNU Lesser General Public License as published 
14
// by the Free Software Foundation, either version 3 of the License, or     
15
// (at your option) any later version.                                      
16
//                                                                          
17
// This source file is distributed in the hope that it will be useful,      
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
20
// GNU General Public License for more details.                             
21
//                                                                          
22
// You should have received a copy of the GNU General Public License        
23
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
24
//                                                                          
25
//      Floating Point Multiplier / Divider
26
//
27
//      This multiplier/divider handles denormalized numbers.
28
//      The output format is of an internal expanded representation
29
//      in preparation to be fed into a normalization unit, then
30
//      rounding. Basically, it's the same as the regular format
31
//      except the mantissa is doubled in size, the leading two
32
//      bits of which are assumed to be whole bits.
33
//
34
//
35
// ============================================================================
36
 
37
module DFPMultiply_tb();
38 55 robfinch
parameter N=33;
39 54 robfinch
reg rst;
40
reg clk;
41
reg [15:0] adr;
42 55 robfinch
reg [N*4+16+4-1:0] a,b;
43
wire [N*4+16+4-1:0] o;
44
reg [N*4+16+4-1:0] ad,bd;
45
wire [N*4+16+4-1:0] od;
46 54 robfinch
reg [3:0] rm;
47
 
48
integer n;
49
reg [127:0] a1, b1;
50
wire [63:0] doubleA = {a[31], a[30], {3{~a[30]}}, a[29:23], a[22:0], {29{1'b0}}};
51
wire [63:0] doubleB = {b[31], b[30], {3{~b[30]}}, b[29:23], b[22:0], {29{1'b0}}};
52
wire done;
53
reg ld;
54
 
55
integer outfile;
56
 
57
initial begin
58
        rst = 1'b0;
59
        clk = 1'b0;
60
        adr = 0;
61
        a = $urandom(1);
62
        #20 rst = 1;
63
        #50 rst = 0;
64 55 robfinch
        #2000000  $fclose(outfile);
65 54 robfinch
        #10 $finish;
66
end
67
 
68
always #5
69
        clk = ~clk;
70
 
71
genvar g;
72
generate begin : gRand
73 55 robfinch
        for (g = 0; g < N*4+16+4; g = g + 4) begin
74 54 robfinch
                always @(posedge clk) begin
75
                        a1[g+3:g] <= $urandom() % 10;
76
                        b1[g+3:g] <= $urandom() % 10;
77
                end
78
        end
79
end
80
endgenerate
81
 
82
reg [9:0] count;
83
always @(posedge clk)
84
if (rst) begin
85
        adr <= 0;
86
        count <= 0;
87
end
88
else
89
begin
90
        ld <= 1'b0;
91
  if (adr==0) begin
92
    outfile = $fopen("d:/cores2020/rtf64/v2/rtl/verilog/cpu/fpu/test_bench/DFPMultiply_tvo.txt", "wb");
93
    $fwrite(outfile, "rm ------ A ------  ------- B ------  - DUT Product -  - SIM Product -\n");
94
  end
95
        count <= count + 1;
96 55 robfinch
        if (count > 750)
97 54 robfinch
                count <= 1'd1;
98
        if (count==2) begin
99 55 robfinch
                a[N*4+16+4-1:0] <= a1;
100
                b[N*4+16+4-1:0] <= b1;
101
                a[N*4+16+4-1:N*4+16+4-4] <= 4'h5;
102
                b[N*4+16+4-1:N*4+16+4-4] <= 4'h5;
103
                a[N*4+16+4-2] <= adr[7];
104
                a[N*4+16+4-3] <= adr[6];
105
                b[N*4+16+4-1] <= adr[5];
106
                b[N*4+16+4-4] <= adr[4];
107 54 robfinch
                ld <= 1'b1;
108
                rm <= adr[15:13];
109
                //ad <= memd[adr][63: 0];
110
                //bd <= memd[adr][127:64];
111
        end
112
        if (adr==1 && count==2) begin
113 55 robfinch
                a <= 152'h50000700000000000000000000000000000000;
114
                b <= 152'h50000200000000000000000000000000000000;
115 54 robfinch
        end
116
        if (adr==1 && count==2) begin
117 55 robfinch
                a <= 152'h40001333333333333333333333333333333333;
118
                b <= 152'h50000300000000000000000000000000000000;
119 54 robfinch
        end
120
        if (adr==2 && count==2) begin
121 55 robfinch
                a <= 152'h50000900000000000000000000000000000000;
122
                b <= 152'h50000200000000000000000000000000000000;
123 54 robfinch
        end
124
        if (adr==3 && count==2) begin
125 55 robfinch
                a <= 152'h50000000000000000000000000000000000000;
126
                b <= 152'h50000000000000000000000000000000000000;
127 54 robfinch
        end
128
        if (adr==4 && count==2) begin
129 55 robfinch
                a <= 152'h50001100000000000000000000000000000000;
130
                b <= 152'h50001100000000000000000000000000000000;
131 54 robfinch
        end
132 55 robfinch
        if (count==750) begin
133 54 robfinch
          $fwrite(outfile, "%h\t%h\t%h\t%h\n", rm, a, b, o);
134
                adr <= adr + 1;
135
        end
136
end
137
 
138
//fpMulnr #(64) u1 (clk, 1'b1, a, b, o, rm);//, sign_exe, inf, overflow, underflow);
139
DFPMultiplynr u6 (clk, 1'b1, ld, a, b, o, rm, done);//, sign_exe, inf, overflow, underflow);
140
 
141
endmodule

powered by: WebSVN 2.1.0

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