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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [posit_test_bench/] [positSqrt_tb.v] - Blame information for rev 43

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

Line No. Rev Author Line
1 39 robfinch
`timescale 1ns / 1ps
2
module positSqrt_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 42 robfinch
parameter es = 2;
17 39 robfinch
 
18
reg [N-1:0] in;
19
reg clk;
20
reg [7:0] cnt;
21
reg start;
22
wire done;
23
reg done1;
24
 
25
wire [N-1:0] out, out2, out3;
26
 
27
reg [N-1:0] a1, a2;
28
wire [N-1:0] a, sqrt, sqr, sqr2;
29
wire i,z,d,i1,z1,d1;
30
 
31
// Instantiate the Unit Under Test (UUT)
32
 
33 42 robfinch
//intToPosit #(.PSTWID(N), .es(es)) u1a (.i(a1), .o(a));
34
assign a = a1;
35 39 robfinch
positSqrt #(.PSTWID(N), .es(es)) usqrt1 (.clk(clk), .ce(1'b1), .i(a), .o(sqrt), .start(start), .done(done), .zero(), .inf());
36
positMul #(.PSTWID(N), .es(es)) umul1 (sqrt,sqrt,sqr,z,i);
37
posit_mult #(.N(N), .es(es)) umul2 (sqrt,sqrt,1'b1,sqr2,i1,z1,d1);
38
 
39
        initial begin
40
          start = 0;
41
          a1 = $urandom(1);
42
          cnt = 0;
43
                // Initialize Inputs
44
                clk = 1;
45
                // Wait 100 ns for global reset to finish
46
                #101 in = 32'h0080ffff;
47
                #325150
48
                $fclose(outfile);
49
                $finish;
50
        end
51
 
52
always #5 clk=~clk;
53
always @(posedge clk) begin
54
  done1 = done;
55
  casez(cnt)
56
  8'b00000000:
57
    begin
58
      start = 1;
59
      a1 = 16;
60
      a2 = a;
61
      cnt = cnt + 1;
62
    end
63
  8'b???????0:
64
    begin
65
      start = 1;
66
      a2 = a;
67
      cnt = cnt + 1;
68
    end
69
  8'b???????1:
70
    begin
71
      start = 0;
72
      if (done) begin
73
        a1 = $urandom();
74
        cnt = cnt + 1;
75
      end
76
    end
77
  default:
78
    begin
79
      a1 = $urandom();
80
      cnt = cnt + 1;
81
    end
82
  endcase
83
end
84
 
85
integer outfile;
86
initial outfile = $fopen("d:/cores6/Thor2020/v3/rtl/fpu/test_bench/positSqrt_tvo32.txt", "wb");
87
  always @(negedge clk) begin
88
    if (done & !done1) begin
89
      if (a2!=sqr)
90
       $fwrite(outfile, "*%h\t%h\t%h\t%h\n",a2,sqr,sqr2,sqrt);
91
      else
92
       $fwrite(outfile, " %h\t%h\t%h\t%h\n",a2,sqr,sqr2,sqrt);
93
    end
94
  end
95
 
96
endmodule
97
 

powered by: WebSVN 2.1.0

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