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

Subversion Repositories ft816float

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

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

Line No. Rev Author Line
1 32 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2006-2019  Robert Finch, Waterloo
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@finitron.ca
7
//       ||
8
//
9
//      fpDiv_tb.v
10
//              - floating point divider 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 fpDiv_tb();
38
reg rst;
39
reg clk, clk4x;
40
reg [15:0] adr;
41
reg [95:0] mem [0:8191];
42
reg [95:0] memo [0:9000];
43
reg [191:0] memd [0:8191];
44
reg [191:0] memdo [0:9000];
45
reg [383:0] memq [0:8191];
46
reg [383:0] memqo [0:9000];
47
reg [31:0] a,b,a6,b6;
48
reg [127:0] aq, bq;
49
reg [63:0] ad,bd;
50
wire [31:0] a5,b5;
51
wire [31:0] o;
52
wire [63:0] od;
53
wire [127:0] oq;
54
reg ld;
55
wire done;
56
reg [3:0] state;
57
 
58
initial begin
59
        rst = 1'b0;
60
        clk = 1'b0;
61
        clk4x = 1'b0;
62
        adr = 13'd0;
63
        $readmemh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpDiv_tv.txt", mem);
64
        $readmemh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpDiv_tvd.txt", memd);
65
        $readmemh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpDiv_tvq.txt", memq);
66
        #20 rst = 1'd1;
67
        #50 rst = 1'd0;
68
end
69
 
70
always #8
71
        clk = ~clk;
72
always #2
73
        clk4x = ~clk4x;
74
 
75
always @(posedge clk)
76
if (rst) begin
77
        adr = 13'd0;
78
        state <= 4'd4;
79
end
80
else
81
begin
82
        ld <= 1'b0;
83
case(state)
84
4'd1:
85
        begin
86
                a <= mem[adr][31: 0];
87
                b <= mem[adr][63:32];
88
                ad <= memd[adr][63:0];
89
                bd <= memd[adr][127:64];
90
                aq <= memq[adr][127:0];
91
                bq <= memq[adr][255:128];
92
                ld <= 1'b1;
93
                state <= 4'd2;
94
        end
95
4'd2:
96
                state <= 4'd3;
97
4'd3:
98
        if (done) begin
99
                memo[adr] <= {o,b,a};
100
                memdo[adr] <= {od,bd,ad};
101
                memqo[adr] <= {oq,bq,aq};
102
                adr <= adr + 4'd1;
103
                if (adr==13'd8191) begin
104
                        $writememh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpDiv_tvo.txt", memo);
105
                        $writememh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpDiv_tvdo.txt", memdo);
106
                        $writememh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpDiv_tvqo.txt", memqo);
107
                        $finish;
108
                end
109
                state <= 4'd4;
110
        end
111
4'd4:   state <= 4'd5;
112
4'd5:   state <= 1;
113
endcase
114
end
115
 
116
fpDivnr #(32) u1 (rst, clk, clk4x, 1'b1, ld, 1'b0, a, b, o, 3'b000);//, sign_exe, inf, overflow, underflow);
117
fpDivnr #(64) u2 (rst, clk, clk4x, 1'b1, ld, 1'b0, ad, bd, od, 3'b000);//, sign_exe, inf, overflow, underflow);
118
fpDivnr #(128) u3 (rst, clk, clk4x, 1'b1, ld, 1'b0, aq, bq, oq, 3'b000, done);//, sign_exe, inf, overflow, underflow);
119
 
120
endmodule

powered by: WebSVN 2.1.0

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