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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [posit_test_bench/] [intToPosit_tb.v] - Blame information for rev 38

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

Line No. Rev Author Line
1 36 robfinch
`timescale 1ns / 1ps
2
module intToPosit_tb_v;
3
 
4
function [31:0] log2;
5
input reg [31:0] value;
6
        begin
7
        value = value-1;
8
        for (log2=0; value>0; log2=log2+1)
9
                value = value>>1;
10
        end
11
endfunction
12
 
13
parameter N=32;
14
parameter E=8;
15
parameter Bs=log2(N);
16
parameter es = 4;
17
 
18
reg clk;
19
reg [5:0] cnt;
20
 
21
wire [N-1:0] out;
22
 
23
reg [N-1:0] a;
24
 
25
// Instantiate the Unit Under Test (UUT)
26
intToPosit #(.PSTWID(N), .es(es)) u2 (.i(a), .o(out));
27
 
28
//FP_to_posit #(.N(32), .E(8), .es(es)) u3 (in, out3);
29
//Posit_to_FP #(.N(32), .E(8), .es(es)) u5 (out, out3);
30
 
31
 
32
        initial begin
33
          a = $urandom(1);
34
                // Initialize Inputs
35
                clk = 1;
36
                cnt = 0;
37
                // Wait 100 ns for global reset to finish
38
                #325150
39
                $fclose(outfile);
40
                $finish;
41
        end
42
 
43
always #5 clk=~clk;
44
always @(posedge clk) begin
45
  a = $urandom();
46
  cnt = cnt + 1;
47
  case (cnt)
48
  1:  a = 8192;
49
  2:  a = 10;
50
  3:  a = -1;
51
  4:  a = -10;
52
  default:   a = $urandom();
53
  endcase
54
end
55
 
56
integer outfile;
57
initial outfile = $fopen("d:/cores5/Gambit/v5/rtl/cpu/fpu/test_bench/intToPosit_tvo32.txt", "wb");
58
  always @(negedge clk) begin
59
     $fwrite(outfile, "%d\t%h\n",a,out);
60
  end
61
 
62
endmodule
63
 

powered by: WebSVN 2.1.0

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