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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [DDBinToBCD_tb.sv] - Blame information for rev 59

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 59 robfinch
module DDBinToBCD_tb();
2
 
3
reg rst;
4
reg clk;
5
reg [15:0] adr;
6
wire [171:0] bcd;
7
reg [7:0] count;
8
 
9
reg [127:0] bin;
10
 
11
integer outfile;
12
 
13
initial begin
14
        rst = 1'b0;
15
        clk = 1'b0;
16
        adr = 0;
17
        bin = $urandom(1);
18
        #20 rst = 1;
19
        #50 rst = 0;
20
        #10000000  $fclose(outfile);
21
        #10 $finish;
22
end
23
 
24
always #5
25
        clk = ~clk;
26
 
27
genvar g;
28
generate begin : gRand
29
        for (g = 0; g < 128; g = g + 4) begin
30
                always @(posedge clk) begin
31
                        if (count==2)
32
                                bin[g+3:g] <= $urandom() % 16;
33
                end
34
        end
35
end
36
endgenerate
37
 
38
always @(posedge clk)
39
if (rst) begin
40
        adr <= 0;
41
        count <= 0;
42
end
43
else
44
begin
45
  if (adr==0) begin
46
    outfile = $fopen("d:/cores2022/rf6809/rtl/dfpu/test_bench/DDBinToBCD_tvo.txt", "wb");
47
    $fwrite(outfile, " ------ bin ------  ------ bcd ------  \n");
48
  end
49
        count <= count + 1;
50
        if (count > 140)
51
                count <= 1'd1;
52
        if (adr==2) begin
53
                bin <= 128'h0A;
54
        end
55
        if (adr==3) begin
56
                bin <= 128'd12345678;
57
        end
58
        if (count==140) begin
59
        $fwrite(outfile, "%h\t%h\n", bin, bcd);
60
                adr <= adr + 1;
61
        end
62
end
63
 
64
//fpMulnr #(64) u1 (clk, 1'b1, a, b, o, rm);//, sign_exe, inf, overflow, underflow);
65
DDBinToBCD #(128) u6 (
66
        .rst(rst),
67
  .clk(clk),
68
  .ld(count==3),
69
  .bin(bin),
70
  .bcd(bcd)
71
);
72
 
73
endmodule

powered by: WebSVN 2.1.0

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