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

Subversion Repositories ft816float

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

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
//      fpMultiply_tb.v
10
//              - 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 fpMultiply_tb();
38
reg rst;
39
reg clk;
40
reg [15:0] adr;
41
reg [63:0] a,b;
42
wire [63:0] o;
43
reg [63:0] ad,bd;
44
wire [63:0] od;
45
reg [3:0] rm;
46
 
47
wire [63:0] doubleA = {a[31], a[30], {3{~a[30]}}, a[29:23], a[22:0], {29{1'b0}}};
48
wire [63:0] doubleB = {b[31], b[30], {3{~b[30]}}, b[29:23], b[22:0], {29{1'b0}}};
49
 
50
integer outfile;
51
 
52
initial begin
53
        rst = 1'b0;
54
        clk = 1'b0;
55
        adr = 0;
56
        a = $urandom(1);
57
        #20 rst = 1;
58
        #50 rst = 0;
59
        #1000000  $fclose(outfile);
60
        #10 $finish;
61
end
62
 
63
always #5
64
        clk = ~clk;
65
 
66
reg [7:0] count;
67
always @(posedge clk)
68
if (rst) begin
69
        adr <= 0;
70
        count <= 0;
71
end
72
else
73
begin
74
  if (adr==0) begin
75
    outfile = $fopen("d:/cores2020/rtf64/v2/rtl/verilog/cpu/fpu/test_bench/fpMultiply_tvo.txt", "wb");
76
    $fwrite(outfile, "rm ------ A ------  ------- B ------  - DUT Product -  - SIM Product -\n");
77
  end
78
        count <= count + 1;
79
        if (count > 48)
80
                count <= 1'd1;
81
        if (count==2) begin
82
                a[31:0] <= $urandom();
83
                b[31:0] <= $urandom();
84
                a[63:32] <= $urandom();
85
                b[63:32] <= $urandom();
86
                rm <= adr[15:13];
87
                //ad <= memd[adr][63: 0];
88
                //bd <= memd[adr][127:64];
89
        end
90
        if (count==47) begin
91
          $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 ? "*":" ");
92
                adr <= adr + 1;
93
        end
94
end
95
 
96
//fpMulnr #(64) u1 (clk, 1'b1, a, b, o, rm);//, sign_exe, inf, overflow, underflow);
97
fpMultiplynr u6 (clk, 1'b1, a, b, o, rm);//, sign_exe, inf, overflow, underflow);
98
 
99
endmodule

powered by: WebSVN 2.1.0

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