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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog/] [fpDiv_tb.v] - Blame information for rev 49

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

Line No. Rev Author Line
1 10 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2006-2018  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;
40
reg [12:0] adr;
41
reg [95:0] mem [0:8191];
42
reg [95:0] memo [0:9000];
43 11 robfinch
reg [191:0] memd [0:8191];
44
reg [191:0] memdo [0:9000];
45 10 robfinch
reg [31:0] a,b,a6,b6;
46 11 robfinch
reg [63:0] ad,bd;
47 10 robfinch
wire [31:0] a5,b5;
48
wire [31:0] o;
49 11 robfinch
wire [63:0] od;
50 10 robfinch
reg ld;
51
wire done;
52
reg [3:0] state;
53
 
54
initial begin
55
        rst = 1'b0;
56
        clk = 1'b0;
57 14 robfinch
        adr = 13'd0;
58
        $readmemh("d:/cores5/ft64/v5/rtl/fpUnit/fpDiv_tv.txt", mem);
59
        $readmemh("d:/cores5/ft64/v5/rtl/fpUnit/fpDiv_tvd.txt", memd);
60
        #20 rst = 1'd1;
61
        #50 rst = 1'd0;
62 10 robfinch
end
63
 
64 14 robfinch
always #10
65 10 robfinch
        clk = ~clk;
66
 
67
always @(posedge clk)
68
if (rst) begin
69 14 robfinch
        adr = 13'd0;
70
        state <= 4'd4;
71 10 robfinch
end
72
else
73
begin
74
        ld <= 1'b0;
75
case(state)
76
4'd1:
77
        begin
78
                a <= mem[adr][31: 0];
79
                b <= mem[adr][63:32];
80 11 robfinch
                ad <= memd[adr][63:0];
81
                bd <= memd[adr][127:64];
82 10 robfinch
                ld <= 1'b1;
83 14 robfinch
                state <= 4'd2;
84 10 robfinch
        end
85
4'd2:
86 14 robfinch
                state <= 4'd3;
87
4'd3:
88 10 robfinch
        if (done) begin
89
                memo[adr] <= {o,b,a};
90 11 robfinch
                memdo[adr] <= {od,bd,ad};
91 14 robfinch
                adr <= adr + 4'd1;
92
                if (adr==13'd8191) begin
93
                        $writememh("d:/cores5/ft64/v5/rtl/fpUnit/fpDiv_tvo.txt", memo);
94
                        $writememh("d:/cores5/ft64/v5/rtl/fpUnit/fpDiv_tvdo.txt", memdo);
95 10 robfinch
                        $finish;
96
                end
97 14 robfinch
                state <= 4'd4;
98 10 robfinch
        end
99 14 robfinch
4'd4:   state <= 4'd5;
100 10 robfinch
4'd5:   state <= 1;
101
endcase
102
end
103
 
104 14 robfinch
fpDivnr #(32) u1 (rst, clk, 1'b1, ld, 1'b0, a, b, o, 3'b000);//, sign_exe, inf, overflow, underflow);
105
fpDivnr #(64) u2 (rst, clk, 1'b1, ld, 1'b0, ad, bd, od, 3'b000, done);//, sign_exe, inf, overflow, underflow);
106 10 robfinch
 
107
endmodule

powered by: WebSVN 2.1.0

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