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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [posit_test_bench/] [positMul_tb.v] - Blame information for rev 45

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

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

powered by: WebSVN 2.1.0

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