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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [posit_test_bench/] [intToPosit_tb.v] - Diff between revs 45 and 46

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 45 Rev 46
Line 53... Line 53...
parameter E=8;
parameter E=8;
parameter Bs=log2(N);
parameter Bs=log2(N);
parameter es = 2;
parameter es = 2;
 
 
reg clk;
reg clk;
reg [5:0] cnt;
reg [15:0] cnt;
 
 
wire [N-1:0] out, outi;
wire [N-1:0] out, outi;
 
 
reg [N-1:0] a, a1;
reg [N-1:0] a, a1;
 
 
 
reg [31:0] fa;
 
wire [31:0] f2po;
 
fpToPosit #(.FPWID(32)) ufp1 (.i(fa), .o(f2po));
 
 
 
wire [63:0] double = {fa[31], fa[30], {3{~fa[30]}}, fa[29:23], fa[22:0], {29{1'b0}}};
 
 
// Instantiate the Unit Under Test (UUT)
// Instantiate the Unit Under Test (UUT)
intToPosit #(.PSTWID(N), .es(es)) u2 (.i(a), .o(out));
intToPosit #(.PSTWID(N), .es(es)) u2 (.i(a), .o(out));
positToInt #(.PSTWID(N), .es(es)) u3 (.i(out), .o(outi));
positToInt #(.PSTWID(N), .es(es)) u3 (.i(f2po), .o(outi));
 
 
//FP_to_posit #(.N(32), .E(8), .es(es)) u3 (in, out3);
//FP_to_posit #(.N(32), .E(8), .es(es)) u3 (in, out3);
//Posit_to_FP #(.N(32), .E(8), .es(es)) u5 (out, out3);
//Posit_to_FP #(.N(32), .E(8), .es(es)) u5 (out, out3);
 
 
 
 
Line 82... Line 88...
 
 
always #5 clk=~clk;
always #5 clk=~clk;
always @(posedge clk) begin
always @(posedge clk) begin
  a <= $urandom();
  a <= $urandom();
  cnt <= cnt + 1;
  cnt <= cnt + 1;
 
  if (cnt > 1000) begin
 
    fa <= $urandom();
 
  end
 
  else
  case (cnt)
  case (cnt)
  1:  a <= 8192;
  2:  fa <= 32'h3f000001; // 0.5 + 1ulp
  2:  a <= 10;
  3:  fa <= 32'h3EFFFFFF; // 0.4999...
  3:  a <= -1;
  4:  a <= 32'h17cf4600;
  4:  a <= -10;
  5:  a <= 10;
  5:  a <= 100;
  6:  a <= -1;
 
  7:  a <= -10;
 
  8:  a <= 100;
  default:   a <= $urandom();
  default:   a <= $urandom();
  endcase
  endcase
end
end
 
 
integer outfile;
integer outfile;
initial outfile = $fopen("d:/cores2020/rtf64/v2/rtl/verilog/cpu/pau/test_bench/intToPosit_tvo32.txt", "wb");
initial outfile = $fopen("d:/cores2020/rtf64/v2/rtl/verilog/cpu/pau/test_bench/intToPosit_tvo32.txt", "wb");
  always @(posedge clk) begin
  always @(posedge clk) begin
     $fwrite(outfile, "%d\t%h\t%d\n",a,out,outi);
     $fwrite(outfile, "%h\t%d\t%h\t%d\t%e\n",f2po,a,out,outi,$bitstoreal(double));
  end
  end
 
 
endmodule
endmodule
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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