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

Subversion Repositories ft816float

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

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

powered by: WebSVN 2.1.0

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