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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [fpSqrt_tb.v] - Blame information for rev 57

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

Line No. Rev Author Line
1 28 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 [159:0] memdx [0:8191];
37
reg [159:0] memdxo [0:8191];
38
reg [31:0] a,a6;
39
reg [63:0] ad;
40
wire [31:0] a5;
41
wire [31:0] o;
42
wire [63:0] od;
43
reg [79:0] adx;
44
wire [79:0] odx;
45
reg ld;
46
wire done;
47
reg [3:0] state;
48
reg [7:0] count;
49
 
50
initial begin
51
        rst = 1'b0;
52
        clk = 1'b0;
53
        clk4x = 0;
54
        adr = 0;
55
        $readmemh("d:/cores6/cs01/rtl/fp/test_bench/fpSqrt_tv.txt", mem);
56
        $readmemh("d:/cores6/cs01/rtl/fp/test_bench/fpSqrt_tvd.txt", memd);
57
        $readmemh("d:/cores6/cs01/rtl/fp/test_bench/fpSqrt_tvdx.txt", memdx);
58
        #20 rst = 1;
59
        #50 rst = 0;
60
end
61
 
62
always #8
63
        clk = ~clk;
64
 
65
always @(posedge clk)
66
if (rst) begin
67
        adr = 0;
68
        state <= 1;
69
        count <= 0;
70
end
71
else
72
begin
73
        ld <= 1'b0;
74
case(state)
75
4'd1:
76
        begin
77
                count <= 8'd0;
78
                a <= mem[adr][31: 0];
79
                ad <= memd[adr][63:0];
80
                adx <= memdx[adr][79:0];
81
                ld <= 1'b1;
82
                state <= 2;
83
        end
84
4'd2:
85
        begin
86
                count <= count + 2'd1;
87
                if (count==8'd160) begin
88
                        memo[adr] <= {o,a};
89
                        memdo[adr] <= {od,ad};
90
                        memdxo[adr] <= {odx,adx};
91
                        adr <= adr + 1;
92
                        if (adr==8191) begin
93
                                $writememh("d:/cores6/cs01/rtl/fp/test_bench/fpSqrt_tvo.txt", memo);
94
                                $writememh("d:/cores6/cs01/rtl/fp/test_bench/fpSqrt_tvdo.txt", memdo);
95
                                $writememh("d:/cores6/cs01/rtl/fp/test_bench/fpSqrt_tvdxo.txt", memdxo);
96
                                $finish;
97
                        end
98
                        state <= 3;
99
                end
100
        end
101
4'd3:   state <= 4;
102
4'd4:   state <= 5;
103
4'd5:   state <= 1;
104
endcase
105
end
106
 
107
fpSqrtnr #(32) u1 (rst, clk, 1'b1, ld, a, o, 3'b000);//, sign_exe, inf, overflow, underflow);
108
fpSqrtnr #(64) u2 (rst, clk, 1'b1, ld, ad, od, 3'b000, done);//, sign_exe, inf, overflow, underflow);
109
fpSqrtnr #(80) u3 (rst, clk, 1'b1, ld, adx, odx, 3'b000, done);//, sign_exe, inf, overflow, underflow);
110
 
111
endmodule

powered by: WebSVN 2.1.0

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