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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [fpTrunc_tb.v] - Blame information for rev 88

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

Line No. Rev Author Line
1 21 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
//      fpTrunc_tb.v
10
//              - floating point truncate 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 fpTrunc_tb();
38
reg rst;
39
reg clk;
40
reg [12:0] adr;
41
reg [63:0] mem [0:8191];
42
reg [63:0] memo [0:9000];
43
reg [127:0] memd [0:8191];
44
reg [127:0] memdo [0:9000];
45
reg [31:0] a,b,a6,b6;
46
reg [63:0] ad,bd;
47
wire [31:0] a5,b5;
48
wire [31:0] o;
49
wire [63:0] od;
50
reg ld;
51
wire done = 1'b1;
52
reg [3:0] state;
53
 
54
initial begin
55
        rst = 1'b0;
56
        clk = 1'b0;
57
        adr = 13'd0;
58
        //$readmemh("d:/cores6/rtfItanium/v1/rtl/fpUnit/test_bench/fpTrunc_tv.txt", mem);
59
        $readmemh("d:/cores6/rtfItanium/v1/rtl/fpUnit/test_bench/fpTrunc_tvd.txt", memd);
60
        #20 rst = 1'd1;
61
        #50 rst = 1'd0;
62
end
63
 
64
always #10
65
        clk = ~clk;
66
 
67
always @(posedge clk)
68
if (rst) begin
69
        adr = 13'd0;
70
        state <= 4'd4;
71
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
                ad <= memd[adr][63:0];
81
                bd <= memd[adr][127:64];
82
                ld <= 1'b1;
83
                state <= 4'd2;
84
        end
85
4'd2:
86
                state <= 4'd3;
87
4'd3:
88
        if (done) begin
89
                memo[adr] <= {o,a};
90
                memdo[adr] <= {od,ad};
91
                adr <= adr + 4'd1;
92
                if (adr==13'd8191) begin
93
//                      $writememh("d:/cores6/rtfItanium/v1/rtl/fpUnit/test_bench/fpTrunc_tvo.txt", memo);
94
                        $writememh("d:/cores6/rtfItanium/v1/rtl/fpUnit/test_bench/fpTrunc_tvdo.txt", memdo);
95
                        $finish;
96
                end
97
                state <= 4'd4;
98
        end
99
4'd4:   state <= 4'd5;
100
4'd5:   state <= 1;
101
endcase
102
end
103
 
104
fpTrunc #(64) u1 (clk, 1'b1, ad, od);
105
 
106
endmodule

powered by: WebSVN 2.1.0

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