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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [DFPCompare128_tb.v] - Blame information for rev 71

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

Line No. Rev Author Line
1 69 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2006-2022  Robert Finch, Waterloo
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@finitron.ca
7
//       ||
8
//
9
//      DFPcompare128_tb.v
10
//              - decimal floating point addsub test bench
11
//
12
// BSD 3-Clause License
13
// Redistribution and use in source and binary forms, with or without
14
// modification, are permitted provided that the following conditions are met:
15
//
16
// 1. Redistributions of source code must retain the above copyright notice, this
17
//    list of conditions and the following disclaimer.
18
//
19
// 2. Redistributions in binary form must reproduce the above copyright notice,
20
//    this list of conditions and the following disclaimer in the documentation
21
//    and/or other materials provided with the distribution.
22
//
23
// 3. Neither the name of the copyright holder nor the names of its
24
//    contributors may be used to endorse or promote products derived from
25
//    this software without specific prior written permission.
26
//
27
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//                                                                          
38
// ============================================================================
39
 
40
module DFPCompare128_tb();
41
reg rst;
42
reg clk;
43
reg [15:0] adr;
44
reg [127:0] a,b;
45
wire [11:0] o;
46
reg [127:0] ad,bd;
47
reg [127:0] od;
48
reg [3:0] rm;
49
reg [15:0] rel;
50
 
51
integer n;
52
reg [127:0] a1, b1;
53
 
54
integer outfile;
55
 
56
initial begin
57
        rst = 1'b0;
58
        clk = 1'b0;
59
        adr = 0;
60
        a = $urandom(1);
61
        b = 1;
62
        #20 rst = 1;
63
        #50 rst = 0;
64
        #10000000  $fclose(outfile);
65
        #10 $finish;
66
end
67
 
68
always #5
69
        clk = ~clk;
70
 
71
genvar g;
72
generate begin : gRand
73
        for (g = 0; g < 128; g = g + 4) begin
74
                always @(posedge clk) begin
75
                        a1[g+3:g] <= $urandom() % 16;
76
                        b1[g+3:g] <= $urandom() % 16;
77
                end
78
        end
79
end
80
endgenerate
81
 
82
reg [7:0] count;
83
always @(posedge clk)
84
if (rst) begin
85
        adr <= 0;
86
        count <= 0;
87
end
88
else
89
begin
90
  if (adr==0) begin
91
    outfile = $fopen("d:/cores2022/rf6809/rtl/dfpu/test_bench/DFPCompare128_tvo.txt", "wb");
92
    $fwrite(outfile, " rm ------- A ------  ------- B ------  ------ sum -----  -- SIM Sum --\n");
93
  end
94
        count <= count + 1;
95
        if (count > 3)
96
                count <= 1'd1;
97
        if (count==2) begin
98
                a <= a1;
99
                b <= b1;
100
                a[127:124] <= 4'h5;
101
                b[127:124] <= 4'h5;
102
                rm <= adr[14:12];
103
                //ad <= memd[adr][63: 0];
104
                //bd <= memd[adr][127:64];
105
        end
106
        if (adr==1 && count==2) begin
107
                a <= 128'h50000700000000000000000000000000;
108
                b <= 128'h50000200000000000000000000000000;
109
        end
110
        if (adr==2 && count==2) begin
111
                a <= 128'h50000900000000000000000000000000;
112
                b <= 128'h50000200000000000000000000000000;
113
        end
114
        if (adr==3 && count==2) begin
115
                a <= 128'h50000000000000000000000000000000;
116
                b <= 128'h50000000000000000000000000000000;
117
        end
118
        if (adr==4 && count==2) begin
119
                a <= 128'h44000000000000000000000000000000;
120
                b <= 128'h44000000000000000000000000000000;
121
        end
122
        if (adr==5 && count==2) begin
123
                a <= 128'h44004000000000000000000000000000;
124
                b <= 128'h44004000000000000000000000000000;
125
        end
126
        if (adr==6 && count==2) begin
127
                a <= 128'h44000000000000000000000000000000;
128
                b <= 128'h44004000000000000000000000000000;
129
        end
130
        if (adr==7 && count==2) begin
131
                a <= 128'h44004000000000000000000000000000;
132
                b <= 128'h44000000000000000000000000000000;
133
        end
134
        if (count==3) begin
135
                casez(o)
136
                12'b???????1????:       rel = "un";
137
                12'b???????0??01:        rel = "eq";
138
                12'b???????0??10:        rel = "lt";
139
                12'b???????0?1??:        rel = "le";
140
                12'b?????1?0???1: rel = "ge";
141
                12'b????1??0???0: rel = "gt";
142
                default:        rel = "??";
143
                endcase
144
        $fwrite(outfile, "%h\t%h\t%h %s\n", a, b, o, rel);
145
                adr <= adr + 1;
146
        end
147
end
148
 
149
//fpMulnr #(64) u1 (clk, 1'b1, a, b, o, rm);//, sign_exe, inf, overflow, underflow);
150
DFPCompare128 u6 (
151
        .a(a),
152
        .b(b),
153
        .o(o)
154
);
155
 
156
endmodule

powered by: WebSVN 2.1.0

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