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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [fpFMA_tb.v] - Blame information for rev 33

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

Line No. Rev Author Line
1 22 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2019  Robert Finch, Waterloo
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@finitron.ca
7
//       ||
8
//
9
//      fpFMA_tb.v
10
//              - floating point multiplier - adder 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 fpFMA_tb();
38
reg rst;
39
reg clk;
40 32 robfinch
reg [15:0] adr;
41
reg [131:0] mems [0:24000];
42
reg [131:0] memso [0:24000];
43
reg [259:0] memd [0:24000];
44
reg [259:0] memdo [0:24000];
45
reg [515:0] memq [0:24000];
46
reg [515:0] memqo [0:24000];
47 22 robfinch
reg [31:0] a,b,c;
48 32 robfinch
reg [3:0] rm, rmd, rmq;
49 22 robfinch
wire [31:0] o;
50
reg [63:0] ad,bd,cd;
51
wire [63:0] od;
52 32 robfinch
reg [127:0] aq,bq,cq;
53
wire [127:0] oq;
54
reg [7:0] cnt;
55 22 robfinch
 
56
initial begin
57
        rst = 1'b0;
58
        clk = 1'b0;
59
        adr = 0;
60
        cnt = 0;
61 32 robfinch
        $readmemh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvs.txt", mems);
62
        $readmemh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvd.txt", memd);
63
        $readmemh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvq.txt", memq);
64 22 robfinch
        #20 rst = 1;
65
        #50 rst = 0;
66
end
67
 
68
always #5
69
        clk = ~clk;
70
 
71
always @(posedge clk)
72 32 robfinch
if (rst) begin
73
        adr <= 0;
74
        cnt <= 0;
75
end else
76
begin
77 22 robfinch
        cnt <= cnt + 1;
78 32 robfinch
        if (cnt==54)
79
                cnt <= 0;
80
        if (cnt==4)
81 22 robfinch
        begin
82 32 robfinch
                a <= mems[adr][31: 0];
83
                b <= mems[adr][63:32];
84
                c <= mems[adr][95:64];
85
                rm <= mems[adr][131:128];
86 22 robfinch
                ad <= memd[adr][63: 0];
87
                bd <= memd[adr][127:64];
88
                cd <= memd[adr][191:128];
89 32 robfinch
                rmd <= memd[adr][259:256];
90
                aq <= memq[adr][127: 0];
91
                bq <= memq[adr][255:128];
92
                cq <= memq[adr][383:256];
93
                rmq <= memq[adr][515:512];
94 22 robfinch
        end
95 32 robfinch
        if (cnt==53)
96 22 robfinch
        begin
97
                adr <= adr + 1;
98 32 robfinch
                memso[adr] <= {rm,o,c,b,a};
99
                memdo[adr] <= {rmd,od,cd,bd,ad};
100
                memqo[adr] <= {rmq,oq,cq,bq,aq};
101
                //memdo[adr] <= {rmd,od,cdx,bdx,adx};
102 22 robfinch
                if (adr==8191) begin
103 32 robfinch
                        $writememh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvso.txt", memso);
104
                        $writememh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvdo.txt", memdo);
105
                        $writememh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvqo.txt", memqo);
106 22 robfinch
                        $finish;
107
                end
108
        end
109
end
110
 
111 32 robfinch
fpFMAnr #(32) u1 (clk, 1'b1, 1'b0, rm[2:0], c, b, a, o);//, sign_exe, inf, overflow, underflow);
112
fpFMAnr #(64) u16 (clk, 1'b1, 1'b0, rmd[2:0], ad, bd, cd, od);//, sign_exe, inf, overflow, underflow);
113
fpFMAnr #(128) u17 (clk, 1'b1, 1'b0, rmq[2:0], cq, bq, aq, oq);//, sign_exe, inf, overflow, underflow);
114
//fpFMAnr #(64) u15 (clk, 1'b1, 1'b0, rmd[2:0], ad, bd, cd, od);//, inf, overflow, underflow, inexact);
115 22 robfinch
 
116
endmodule

powered by: WebSVN 2.1.0

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