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

Subversion Repositories ft816float

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

Go to most recent revision | 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
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] 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
positToFp #(.FPWID(N), .PSTWID(N), .es(es)) u2
33
(
34
  .i(a),
35
        .o(fa)
36
);
37
 
38
positToFp #(.FPWID(N), .PSTWID(N), .es(es)) u3
39
(
40
  .i(b),
41
        .o(fb)
42
);
43
 
44
positAddsub #(.PSTWID(N), .es(es)) uadd1 (1'b0,a,b,psum);
45
fpAddsub #(.FPWID(N)) uadd2 (clk,1'b1,3'd0,1'b0,fa,fb,fsum);
46
posit_add #(.N(N),.es(es)) uadd3 (a, b, 1'b1, psum1);
47
 
48
positToFp #(.FPWID(N), .PSTWID(N), .es(es)) u4
49
(
50
  .i(psum),
51
        .o(out2)
52
);
53
 
54
 
55
delay2 #(N) ud1 (.i(a), .o(ad));
56
delay2 #(N) ud2 (.i(a), .o(bd));
57
delay2 #(N) ud3 (.i(psum), .o(psumd));
58
delay2 #(N) ud4 (.i(out2), .o(out2d));
59
 
60
 
61
//FP_to_posit #(.N(32), .E(8), .es(es)) u3 (in, out3);
62
//Posit_to_FP #(.N(32), .E(8), .es(es)) u5 (out, out3);
63
 
64
 
65
        initial begin
66
          a1 = $urandom(1);
67
          b1 = $urandom(2);
68
          cnt = 0;
69
                // Initialize Inputs
70
                clk = 1;
71
                // Wait 100 ns for global reset to finish
72
                #101 in = 32'h0080ffff;
73
                #325150
74
                $fclose(outfile);
75
                $finish;
76
        end
77
 
78
always #5 clk=~clk;
79
always @(posedge clk) begin
80
  cnt = cnt + 1;
81
  case(cnt)
82
  0:
83
    begin
84
      a1 = 0;
85
      b1 = 0;
86
    end
87
  1:
88
    begin
89
      a1 = 0;
90
      b1 = 10;
91
    end
92
  2:
93
    begin
94
      a1 = 10;
95
      b1 = 10;
96
    end
97
 
98
  default:
99
    begin
100
      a1 = $urandom();
101
      b1 = $urandom();
102
    end
103
  endcase
104
end
105
 
106
integer outfile;
107
initial outfile = $fopen("d:/cores5/Gambit/v5/rtl/cpu/fpu/test_bench/positAddsub_tvo32.txt", "wb");
108
  always @(negedge clk) begin
109
     $fwrite(outfile, "%h\t%h\t%h\t%h\n",a,b,psum,psum1);
110
  end
111
 
112
endmodule
113
 

powered by: WebSVN 2.1.0

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