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

Subversion Repositories ft816float

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

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

powered by: WebSVN 2.1.0

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