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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [posit_test_bench/] [positMultiply_tb.v] - Blame information for rev 64

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

Line No. Rev Author Line
1 47 robfinch
`timescale 1ns / 1ps
2
module positMultiply_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 = 2;
17
 
18
reg [N-1:0] in;
19
reg clk;
20
reg [25: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
 
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
wire [N-1:0] a2 = cnt[11] ? a1 : a;
35
wire [N-1:0] b2 = cnt[11] ? b1 : b;
36
wire [N-1:0] p2, a3, b3;
37
 
38
positMultiply #(.PSTWID(N), .es(es)) umul1 (clk,1'b1,a2,b2,p,z,i);
39
posit_mult #(.N(N),.es(es)) umul3 (a2, b2, 1'b1, p2, i1, z1, d1);
40
delay #(.WID(N), .DEP(13)) udly1 (.clk(clk), .ce(1'b1), .i(p2), .o(p1));
41
delay #(.WID(N), .DEP(13)) udly2 (.clk(clk), .ce(1'b1), .i(a2), .o(a3));
42
delay #(.WID(N), .DEP(13)) udly3 (.clk(clk), .ce(1'b1), .i(b2), .o(b3));
43
 
44
delay2 #(N) ud1 (.i(a), .o(ad));
45
delay2 #(N) ud2 (.i(a), .o(bd));
46
delay2 #(N) ud3 (.i(psum), .o(psumd));
47
delay2 #(N) ud4 (.i(out2), .o(out2d));
48
 
49
        initial begin
50
          a1 = $urandom(1);
51
          b1 = $urandom(2);
52
          cnt = 0;
53
                // Initialize Inputs
54
                clk = 1;
55
                // Wait 100 ns for global reset to finish
56
                #101 in = 32'h0080ffff;
57
                #700000
58
                $fclose(outfile);
59
                $finish;
60
        end
61
 
62
always #5 clk=~clk;
63
always @(posedge clk) begin
64
  cnt <= cnt + 1;
65
  case(cnt)
66
  0:
67
    begin
68
      a1 = 0;
69
      b1 = 0;
70
    end
71
  1:
72
    begin
73
      a1 = 0;
74
      b1 = 10;
75
    end
76
  2:
77
    begin
78
      a1 = 10;
79
      b1 = 10;
80
    end
81
 
82
  default:
83
    begin
84
      if (cnt[0]) begin
85
        a1 = $urandom();
86
        b1 = $urandom();
87
      end
88
    end
89
  endcase
90
end
91
 
92
integer outfile;
93
initial outfile = $fopen("d:/cores2020/rtf64/v2/rtl/verilog/cpu/pau/test_bench/positMultiply_tvo32.txt", "wb");
94
  always @(posedge clk) begin
95
    if (cnt[11:0]==12'h001)
96
      $fwrite(outfile, "--------------integers-------------\n");
97
    if (cnt[11:0]==12'h800)
98
      $fwrite(outfile, "---------------reals---------------\n");
99
    if (cnt[0]) begin
100
      if (p!=p1)
101
        $fwrite(outfile, "*%h\t%h\t%h\t%h\n",a3,b3,p,p1);
102
      else
103
        $fwrite(outfile, " %h\t%h\t%h\t%h\n",a3,b3,p,p1);
104
    end
105
  end
106
 
107
endmodule
108
 

powered by: WebSVN 2.1.0

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