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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64/] [rtl/] [fpUnit/] [bench/] [fpDiv_tb.v] - Blame information for rev 54

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

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

powered by: WebSVN 2.1.0

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