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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [df128Toi_tb.sv] - Rev 60

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

module df128Toi_tb();

reg rst;
reg clk;
reg [15:0] adr;
reg [127:0] flt;
reg [7:0] count;

wire [127:0] bin;
wire vf;

integer outfile;

initial begin
        rst = 1'b0;
        clk = 1'b0;
        adr = 0;
        flt = $urandom(1);
        #20 rst = 1;
        #50 rst = 0;
        #10000000  $fclose(outfile);
        #10 $finish;
end

always #5
        clk = ~clk;

genvar g;
generate begin : gRand
        for (g = 0; g < 128; g = g + 4) begin
                always @(posedge clk) begin
                        if (count==2)
                                flt[g+3:g] <= $urandom() % 16;
                end
        end
end
endgenerate

always @(posedge clk)
if (rst) begin
        adr <= 0;
        count <= 0;
end
else
begin
  if (adr==0) begin
    outfile = $fopen("d:/cores2022/rf6809/rtl/dfpu/test_bench/df128Toi_tvo.txt", "wb");
    $fwrite(outfile, "s ------ flt ------  ------ bin ------  \n");
  end
        count <= count + 1;
        if (count > 140)
                count <= 1'd1;
        if (adr==2) begin
                flt <= 128'h44000000000000000000000000000000;
        end
        if (adr==3) begin
                flt <= 128'h44004000000000000000000000000000;
        end
        if (adr==5) begin
                flt <= 128'h48000000000000000000000000000000;
        end
        if (count==140) begin
        $fwrite(outfile, "%c %h\t%h%c\n", adr[11] ? "s" : "u", flt, bin, vf ? "v": " ");
                adr <= adr + 1;
        end
end

df128Toi u6 (
        .rst(rst),
  .clk(clk),
  .ce(1'b1),
  .op(adr[11]),
  .ld(count==3),
  .i(flt),
  .o(bin),
  .overflow(vf),
  .done()
);

endmodule

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

powered by: WebSVN 2.1.0

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