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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [i2df128_tb.sv] - Blame information for rev 69

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

Line No. Rev Author Line
1 62 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2022  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch@finitron.ca
6
//       ||
7
//
8
//      iTodf128_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 60 robfinch
module i2df128_tb();
40
 
41
reg rst;
42
reg clk;
43
reg [15:0] adr;
44
wire [127:0] flt;
45
reg [7:0] count;
46
 
47
reg [127: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 < 128; 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("d:/cores2022/rf6809/rtl/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 62 robfinch
        if (adr==1) begin
91
                bin <= 128'h01;
92
        end
93 60 robfinch
        if (adr==2) begin
94
                bin <= 128'h0A;
95
        end
96
        if (adr==3) begin
97
                bin <= 128'd100;
98
        end
99 62 robfinch
        if (adr==4) begin
100
                bin <= 128'd1000;
101
        end
102 60 robfinch
        if (adr==5) begin
103
                bin <= 128'd12345678;
104
        end
105
        if (count==140) begin
106
        $fwrite(outfile, "%c %h\t%h\n", adr[11] ? "s" : "u", bin, flt);
107
                adr <= adr + 1;
108
        end
109
end
110
 
111
i2df128 u6 (
112
        .rst(rst),
113
  .clk(clk),
114
  .ce(1'b1),
115
  .op(adr[11]),
116
  .rm(3'd0),
117
  .ld(count==3),
118
  .i(bin),
119
  .o(flt),
120
  .done()
121
);
122
 
123
endmodule

powered by: WebSVN 2.1.0

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