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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [posit_test_bench/] [positDiv_tb.v] - Blame information for rev 89

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

Line No. Rev Author Line
1 43 robfinch
`timescale 1ns / 1ps
2
module positDiv_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=64;
14
parameter E=8;
15
parameter Bs=log2(N);
16
parameter es = 3;
17
 
18
reg [N-1:0] in;
19
reg clk;
20
reg [31:0] cnt = 0;
21
 
22
wire [N-1:0] out, out2, out3;
23
 
24
reg [N-1:0] a1, b1;
25
wire [N-1:0] a, b;
26
wire [N-1:0] p, fsum, fa, fb, ad, bd, psumd, out2d, p1;
27
wire i,z,d,i1,z1,d1;
28
wire done;
29
reg start;
30
 
31
// Instantiate the Unit Under Test (UUT)
32
 
33
intToPosit #(.PSTWID(N), .es(es)) u1a (.i(a1), .o(a));
34
intToPosit #(.PSTWID(N), .es(es)) u1b (.i(b1), .o(b));
35
 
36
positDivide #(.PSTWID(N), .es(es)) udiv1 (clk, 1'b1, a, b, p, start, d, z, i);
37
posit_div #(.N(N),.es(es)) udiv2 (a, b, start, p1, i1, z1, d1);
38
 
39
delay2 #(N) ud1 (.clk(clk), .ce(1'b1), .i(a), .o(ad));
40
delay2 #(N) ud2 (.clk(clk), .ce(1'b1), .i(a), .o(bd));
41
delay2 #(N) ud3 (.clk(clk), .ce(1'b1), .i(psum), .o(psumd));
42
delay2 #(N) ud4 (.clk(clk), .ce(1'b1), .i(out2), .o(out2d));
43
 
44
        initial begin
45
          a1 = $urandom(1);
46
          b1 = $urandom(2);
47
          cnt = 0;
48
                // Initialize Inputs
49
                clk = 1;
50
                // Wait 100 ns for global reset to finish
51
                #101 in = 32'h0080ffff;
52
                #325150
53
                $fclose(outfile);
54
                $finish;
55
        end
56
 
57
always #5 clk=~clk;
58
always @(posedge clk) begin
59
start <= 0;
60
  cnt = cnt + 1;
61
  case(cnt)
62
  0:
63
    begin
64
    start <= 1;
65
      a1 = 0;
66
      b1 = 0;
67
    end
68
  1:
69
    begin
70
      a1 = 0;
71
      b1 = 10;
72
    end
73
  2:
74
    begin
75
      a1 = 10;
76
      b1 = 10;
77
    end
78
  10: start <= 1;
79
  default:
80
    begin
81
      if (d) begin
82
       start <= 1;
83
        cnt <= cnt + 1;
84
        a1 = $urandom();
85
        b1 = $urandom();
86
      end
87
      else
88
        cnt <= cnt;
89
    end
90
  endcase
91
end
92
 
93
integer outfile;
94
initial outfile = $fopen("d:/cores2020/rtf64/v2/rtl/verilog/cpu/pau/test_bench/positDiv_tvo64.txt", "wb");
95
  always @(negedge clk) begin
96
    if (p!=p1 && d)
97
     $fwrite(outfile, "*%h\t%h\t%h\t%h\n",a,b,p,p1);
98
    else if (d)
99
     $fwrite(outfile, " %h\t%h\t%h\t%h\n",a,b,p,p1);
100
  end
101
 
102
endmodule
103
 

powered by: WebSVN 2.1.0

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