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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [DFPAddsub96_tb.v] - Blame information for rev 80

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

Line No. Rev Author Line
1 77 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
//      DFPAddsub96_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 DFPAddsub96_tb();
41
reg rst;
42
reg clk;
43
reg [15:0] adr;
44
reg [95:0] a,b;
45
wire [95:0] o;
46
reg [95:0] ad,bd;
47
reg [95:0] od;
48
reg [3:0] rm;
49
 
50
integer n;
51
reg [95:0] a1, b1;
52
wire [63:0] doubleA = {a[31], a[30], {3{~a[30]}}, a[29:23], a[22:0], {29{1'b0}}};
53
wire [63:0] doubleB = {b[31], b[30], {3{~b[30]}}, b[29:23], b[22:0], {29{1'b0}}};
54
 
55
integer outfile;
56
 
57
initial begin
58
        rst = 1'b0;
59
        clk = 1'b0;
60
        adr = 0;
61
        a = $urandom(1);
62
        b = 1;
63
        #20 rst = 1;
64
        #50 rst = 0;
65
        #10000000  $fclose(outfile);
66
        #10 $finish;
67
end
68
 
69
always #5
70
        clk = ~clk;
71
 
72
genvar g;
73
generate begin : gRand
74
        for (g = 0; g < 96; g = g + 4) begin
75
                always @(posedge clk) begin
76
                        a1[g+3:g] <= $urandom() % 10;
77
                        b1[g+3:g] <= $urandom() % 10;
78
                end
79
        end
80
end
81
endgenerate
82
 
83 78 robfinch
reg [15:0] count;
84 77 robfinch
always @(posedge clk)
85
if (rst) begin
86
        adr <= 0;
87
        count <= 0;
88
end
89
else
90
begin
91
  if (adr==0) begin
92
    outfile = $fopen("f:/cores2022/Float/dfpu/test_bench/DFPAddsub96_tvo.txt", "wb");
93
    $fwrite(outfile, " rm ------- A ------  ------- B ------  ------ sum -----  -- SIM Sum --\n");
94
  end
95
        count <= count + 1;
96 78 robfinch
        if (count > 50)
97 77 robfinch
                count <= 1'd1;
98
        if (count==2) begin
99
                a <= a1;
100
                b <= b1;
101
                a[95:92] <= 4'h5;
102
                b[95:92] <= 4'h5;
103
                rm <= adr[14:12];
104
                //ad <= memd[adr][63: 0];
105
                //bd <= memd[adr][127:64];
106
        end
107 78 robfinch
 
108
//-0    543771554911558566002677        581816070341546924523033        543771554911558566002677
109
 
110
        if (adr==3 && count==2) begin
111
                a <= 96'h543771554911558566002677;
112
                b <= 96'h543716070341546924523033;
113
                //a <= 96'h25ff00000000000000000000;    // 1
114
                //b <= 96'h25ff00000000000000000000;    // 1
115 77 robfinch
        end
116
        if (adr==2 && count==2) begin
117
                a <= 96'h260000000000000000000000;      // 10
118 78 robfinch
                b <= 96'h25ff00000000000000000000;      // 1
119 77 robfinch
        end
120 78 robfinch
        if (adr==1 && count==2) begin
121 77 robfinch
                a <= 96'h260100000000000000000000;      // 100
122 78 robfinch
                b <= 96'h25ff00000000000000000000;      // 1
123 77 robfinch
        end
124
        if (adr==4 && count==2) begin
125
                a <= 96'h260200000000000000000000;      // 1000
126 78 robfinch
                b <= 96'h25ff00000000000000000000;      // 1
127 77 robfinch
        end
128
        if (adr==5 && count==2) begin
129
                a <= 96'h26064D2E7030000000000000;      // 12345678
130
                b <= 96'h260000000000000000000000;      // 10
131
        end
132
        if (adr==6 && count==2) begin
133
                a <= 96'h440000000000000000000000;
134
                b <= 96'h440000000000000000000000;
135
        end
136
        if (adr==7 && count==2) begin
137
                a <= 96'h440040000000000000000000;
138
                b <= 96'h440040000000000000000000;
139
        end
140 78 robfinch
        if (count==50) begin
141
                if (~adr[11]) begin
142 77 robfinch
                $fwrite(outfile, "%c%h\t%h\t%h\t%h\n", "-",rm, a, b, o);
143
          end
144
          else begin
145
                $fwrite(outfile, "%c%h\t%h\t%h\t%h\n", "+",rm, a, b, o);
146
          end
147
                adr <= adr + 1;
148
        end
149
end
150
 
151
//fpMulnr #(64) u1 (clk, 1'b1, a, b, o, rm);//, sign_exe, inf, overflow, underflow);
152
DFPAddsub96nr u6 (
153
  .clk(clk),
154
  .ce(1'b1),
155 78 robfinch
  .op(~adr[11]),
156 77 robfinch
  .a(a),
157
  .b(b),
158
  .o(o),
159
  .rm(rm)
160
  );
161
 
162
endmodule

powered by: WebSVN 2.1.0

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