-
Notifications
You must be signed in to change notification settings - Fork 35
/
TestDiv.v
93 lines (78 loc) · 1.86 KB
/
TestDiv.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 18:48:08 12/29/2013
// Design Name: qdiv
// Module Name: G:/Tran3005/TestDiv.v
// Project Name: Trancendental
// Target Device:
// Tool versions:
// Description:
//
// Verilog Test Fixture created by ISE for module: qdiv
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
////////////////////////////////////////////////////////////////////////////////
module TestDiv;
// Inputs
reg [31:0] i_dividend;
reg [31:0] i_divisor;
reg i_start;
reg i_clk;
// Outputs
wire [31:0] o_quotient_out;
wire o_complete;
wire o_overflow;
// Instantiate the Unit Under Test (UUT)
qdiv uut (
.i_dividend(i_dividend),
.i_divisor(i_divisor),
.i_start(i_start),
.i_clk(i_clk),
.o_quotient_out(o_quotient_out),
.o_complete(o_complete),
.o_overflow(o_overflow)
);
reg [10:0] count;
initial begin
// Initialize Inputs
i_dividend = 1;
i_divisor = 1;
i_start = 0;
i_clk = 0;
count <= 0;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here
forever #2 i_clk = ~i_clk;
end
always @(posedge i_clk) begin
if (count == 47) begin
count <= 0;
i_start <= 1'b1;
end
else begin
count <= count + 1;
i_start <= 1'b0;
end
end
always @(count) begin
if (count == 47) begin
if ( i_divisor > 32'h1FFFFFFF ) begin
i_divisor <= 1;
i_dividend = (i_dividend << 1) + 3;
end
else
i_divisor = (i_divisor << 1) + 1;
end
end
always @(posedge o_complete)
$display ("%b,%b,%b, %b", i_dividend, i_divisor, o_quotient_out, o_overflow); // Monitor the stuff we care about
endmodule