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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [posit_test_bench/] [positAddsub_tb.v] - Blame information for rev 44

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 robfinch
`timescale 1ns / 1ps
2
module positAddsub_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 44 robfinch
parameter N=32;
14 36 robfinch
parameter E=8;
15
parameter Bs=log2(N);
16 44 robfinch
parameter es = 2;
17 36 robfinch
 
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] psum, fsum, fa, fb, ad, bd, psumd, out2d, psum1;
27
 
28
// Instantiate the Unit Under Test (UUT)
29
 
30
intToPosit #(.PSTWID(N), .es(es)) u1a (.i(a1), .o(a));
31
intToPosit #(.PSTWID(N), .es(es)) u1b (.i(b1), .o(b));
32 44 robfinch
/*
33 36 robfinch
positToFp #(.FPWID(N), .PSTWID(N), .es(es)) u2
34
(
35
  .i(a),
36
        .o(fa)
37
);
38
 
39
positToFp #(.FPWID(N), .PSTWID(N), .es(es)) u3
40
(
41
  .i(b),
42
        .o(fb)
43
);
44 44 robfinch
*/
45
positAddsub #(.PSTWID(N), .es(es)) uadd1 (1'b0,a1,b1,psum);
46
//fpAddsub #(.FPWID(N)) uadd2 (clk,1'b1,3'd0,1'b0,fa,fb,fsum);
47
posit_add #(.N(N),.es(es)) uadd3 (a1, b1, 1'b1, psum1);
48
/*
49 36 robfinch
positToFp #(.FPWID(N), .PSTWID(N), .es(es)) u4
50
(
51
  .i(psum),
52
        .o(out2)
53
);
54 44 robfinch
*/
55 36 robfinch
 
56
delay2 #(N) ud1 (.i(a), .o(ad));
57
delay2 #(N) ud2 (.i(a), .o(bd));
58
delay2 #(N) ud3 (.i(psum), .o(psumd));
59
delay2 #(N) ud4 (.i(out2), .o(out2d));
60
 
61
 
62
//FP_to_posit #(.N(32), .E(8), .es(es)) u3 (in, out3);
63
//Posit_to_FP #(.N(32), .E(8), .es(es)) u5 (out, out3);
64
 
65
 
66
        initial begin
67
          a1 = $urandom(1);
68
          b1 = $urandom(2);
69
          cnt = 0;
70
                // Initialize Inputs
71
                clk = 1;
72
                // Wait 100 ns for global reset to finish
73
                #101 in = 32'h0080ffff;
74
                #325150
75
                $fclose(outfile);
76
                $finish;
77
        end
78 44 robfinch
 
79
// 23acc3ec     2d37240c        230d8602        630d8602*
80
// 343b2e06     6c4e8633        6c5194ff        6c5194fe*
81 36 robfinch
always #5 clk=~clk;
82
always @(posedge clk) begin
83
  cnt = cnt + 1;
84
  case(cnt)
85
  0:
86
    begin
87
      a1 = 0;
88
      b1 = 0;
89
    end
90
  1:
91
    begin
92
      a1 = 0;
93
      b1 = 10;
94
    end
95
  2:
96
    begin
97 44 robfinch
      a1 = 32'h23acc3ec;
98
      b1 = 32'h2d37240c;
99 36 robfinch
    end
100
 
101 44 robfinch
  3:
102
    begin
103
      a1 = 32'h343b2e06;
104
      b1 = 32'h6c4e8633;
105
    end
106
 
107 36 robfinch
  default:
108
    begin
109
      a1 = $urandom();
110
      b1 = $urandom();
111
    end
112
  endcase
113
end
114
 
115
integer outfile;
116 44 robfinch
initial outfile = $fopen("d:/cores2020/rtf64/v2/rtl/verilog/cpu/pau/test_bench/positAddsub_tvo32.txt", "wb");
117 36 robfinch
  always @(negedge clk) begin
118 44 robfinch
     $fwrite(outfile, "%h\t%h\t%h\t%h%c\n",a1,b1,psum,psum1,psum!=psum1?"*":" ");
119 36 robfinch
  end
120
 
121
endmodule
122
 

powered by: WebSVN 2.1.0

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