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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog/] [fpSqrt_tb.v] - Blame information for rev 36

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

Line No. Rev Author Line
1 12 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2018  Robert Finch, Waterloo
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@finitron.ca
7
//       ||
8
//
9
//      fpSqrt_tb.v
10
//              - floating point square root 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
// ============================================================================
26
 
27
module fpSqrt_tb();
28
reg rst;
29
reg clk;
30
reg clk4x;
31
reg [12:0] adr;
32
reg [63:0] mem [0:8191];
33
reg [63:0] memo [0:9000];
34
reg [127:0] memd [0:8191];
35
reg [127:0] memdo [0:9000];
36
reg [31:0] a,a6;
37
reg [63:0] ad;
38
wire [31:0] a5;
39
wire [31:0] o;
40
wire [63:0] od;
41
reg ld;
42
wire done;
43
reg [3:0] state;
44
 
45
initial begin
46
        rst = 1'b0;
47
        clk = 1'b0;
48
        clk4x = 0;
49
        adr = 0;
50
        $readmemh("c:/cores5/ft64/trunk/rtl/fpUnit/fpSqrt_tv.txt", mem);
51
        $readmemh("c:/cores5/ft64/trunk/rtl/fpUnit/fpSqrt_tvd.txt", memd);
52
        #20 rst = 1;
53
        #50 rst = 0;
54
end
55
 
56
always #8
57
        clk = ~clk;
58
 
59
always @(posedge clk)
60
if (rst) begin
61
        adr = 0;
62
        state <= 1;
63
end
64
else
65
begin
66
        ld <= 1'b0;
67
case(state)
68
4'd1:
69
        begin
70
                a <= mem[adr][31: 0];
71
                ad <= memd[adr][63:0];
72
                ld <= 1'b1;
73
                state <= 2;
74
        end
75
4'd2:
76
        if (done) begin
77
                memo[adr] <= {o,a};
78
                memdo[adr] <= {od,ad};
79
                adr <= adr + 1;
80
                if (adr==8191) begin
81
                        $writememh("c:/cores5/ft64/trunk/rtl/fpUnit/fpSqrt_tvo.txt", memo);
82
                        $writememh("c:/cores5/ft64/trunk/rtl/fpUnit/fpSqrt_tvdo.txt", memdo);
83
                        $finish;
84
                end
85
                state <= 3;
86
        end
87
4'd3:   state <= 4;
88
4'd4:   state <= 5;
89
4'd5:   state <= 1;
90
endcase
91
end
92
 
93
fpSqrtnr #(32) u1 (rst, clk, 1'b1, ld, a, o, 3'b000);//, sign_exe, inf, overflow, underflow);
94
fpSqrtnr #(64) u2 (rst, clk, 1'b1, ld, ad, od, 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.