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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [i2df96_tb.sv] - Blame information for rev 87

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

Line No. Rev Author Line
1 77 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2022  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch@finitron.ca
6
//       ||
7
//
8
//      iTodf96_tb.sv
9
//  - test convert integer to decimal floating point
10
//
11
// BSD 3-Clause License
12
// Redistribution and use in source and binary forms, with or without
13
// modification, are permitted provided that the following conditions are met:
14
//
15
// 1. Redistributions of source code must retain the above copyright notice, this
16
//    list of conditions and the following disclaimer.
17
//
18
// 2. Redistributions in binary form must reproduce the above copyright notice,
19
//    this list of conditions and the following disclaimer in the documentation
20
//    and/or other materials provided with the distribution.
21
//
22
// 3. Neither the name of the copyright holder nor the names of its
23
//    contributors may be used to endorse or promote products derived from
24
//    this software without specific prior written permission.
25
//
26
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
30
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// ============================================================================
38
 
39
module i2df96_tb();
40
 
41
reg rst;
42
reg clk;
43
reg [15:0] adr;
44
wire [95:0] flt;
45
reg [7:0] count;
46
 
47
reg [95:0] bin;
48
 
49
integer outfile;
50
 
51
initial begin
52
        rst = 1'b0;
53
        clk = 1'b0;
54
        adr = 0;
55
        bin = $urandom(1);
56
        #20 rst = 1;
57
        #50 rst = 0;
58
        #10000000  $fclose(outfile);
59
        #10 $finish;
60
end
61
 
62
always #5
63
        clk = ~clk;
64
 
65
genvar g;
66
generate begin : gRand
67
        for (g = 0; g < 96; g = g + 4) begin
68
                always @(posedge clk) begin
69
                        if (count==2)
70
                                bin[g+3:g] <= $urandom() % 16;
71
                end
72
        end
73
end
74
endgenerate
75
 
76
always @(posedge clk)
77
if (rst) begin
78
        adr <= 0;
79
        count <= 0;
80
end
81
else
82
begin
83
  if (adr==0) begin
84
    outfile = $fopen("f:/cores2022/float/dfpu/test_bench/i2df128_tvo.txt", "wb");
85
    $fwrite(outfile, "s ------ bin ------  ------ flt ------  \n");
86
  end
87
        count <= count + 1;
88
        if (count > 140)
89
                count <= 1'd1;
90
        if (adr==1) begin
91
                bin <= 96'h01;
92
        end
93
        if (adr==2) begin
94
                bin <= 96'h0A;
95
        end
96
        if (adr==3) begin
97
                bin <= 96'd100;
98
        end
99
        if (adr==4) begin
100
                bin <= 96'd1000;
101
        end
102
        if (adr==5) begin
103
                bin <= 96'd1000000;
104
        end
105
        if (adr==6) begin
106
                bin <= 96'd12345678;
107
        end
108
        if (count==140) begin
109
        $fwrite(outfile, "%c %h\t%h\n", adr[11] ? "s" : "u", bin, flt);
110
                adr <= adr + 1;
111
        end
112
end
113
 
114
i2df96 u6 (
115
        .rst(rst),
116
  .clk(clk),
117
  .ce(1'b1),
118
  .op(adr[11]),
119
  .rm(3'd0),
120
  .ld(count==3),
121
  .i(bin),
122
  .o(flt),
123
  .done()
124
);
125
 
126
endmodule

powered by: WebSVN 2.1.0

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