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

Subversion Repositories verilog_fixed_point_math_library

[/] [verilog_fixed_point_math_library/] [trunk/] [TestDiv1.v] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 tomburkeii
`timescale 1ns / 1ps
2
 
3
////////////////////////////////////////////////////////////////////////////////
4
// Company: 
5
// Engineer:
6
//
7
// Create Date:   15:06:24 05/25/2014
8
// Design Name:   qdiv
9
// Module Name:   D:/temp/TestDiv1/TestDiv.v
10
// Project Name:  TestDiv1
11
// Target Device:  
12
// Tool versions:  
13
// Description: 
14
//
15
// Verilog Test Fixture created by ISE for module: qdiv
16
//
17
// Dependencies:
18
// 
19
// Revision:
20
// Revision 0.01 - File Created
21
// Additional Comments:
22
// 
23
////////////////////////////////////////////////////////////////////////////////
24
 
25
module TestDiv;
26
 
27
        // Inputs
28
        reg [63:0] i_dividend;
29
        reg [63:0] i_divisor;
30
        reg i_start;
31
        reg i_clk;
32
 
33
        reg     [13:0]   count;
34
        reg     [8:0]            temp_divisor;
35
        reg     [8:0]            temp_dividend;
36
 
37
        // Outputs
38
        wire [63:0] o_quotient_out;
39
        wire o_complete;
40
        wire o_overflow;
41
 
42
        // Instantiate the Unit Under Test (UUT)
43
        qdiv #(32,64) uut (
44
                .i_dividend(i_dividend),
45
                .i_divisor(i_divisor),
46
                .i_start(i_start),
47
                .i_clk(i_clk),
48
                .o_quotient_out(o_quotient_out),
49
                .o_complete(o_complete),
50
                .o_overflow(o_overflow)
51
        );
52
 
53
        initial begin
54
                // Initialize Inputs
55
                i_dividend = 0;
56
                i_divisor = 0;
57
                i_start = 0;
58
                i_clk = 0;
59
 
60
                count = 0;
61
                temp_divisor = 0;
62
                temp_dividend = 0;
63
 
64
 
65
                // Wait 100 ns for global reset to finish
66
                #100;
67
 
68
                // Add stimulus here
69
 
70
                forever begin
71
                        #1              i_clk = ~i_clk;
72
                        end
73
                end
74
 
75
                always @(posedge i_clk) begin
76
                        if (count == 1) begin
77
                                i_start <= 1;
78
                                end
79
 
80
                        if (count == 3) begin
81
                                i_start <= 0;
82
                                end
83
 
84
                        if (count == 220) begin
85
                                count = 0;                                       //      reset the count
86
 
87
                                if (temp_divisor > 255) begin                                   //      if divisor maxed;
88
                                        temp_divisor <= 0;                                                       //              reset to zero
89
                                        temp_dividend <= temp_dividend + 1;             //              and increment dividend
90
                                        end
91
                                else begin
92
                                        temp_divisor <= temp_divisor + 1;               //      otherwise, increment divisor
93
                                        end
94
 
95
                                i_dividend <= temp_dividend << 32;                      //              Set i_dividend
96
                                i_divisor <= temp_divisor  << 32;                       //              Set i_dividor
97
 
98
                                end
99
 
100
                        count <= count + 1;                                                             //      Update count
101
                        end
102
 
103
                always @(posedge o_complete) begin
104
                        $display ("%b,%b,%b,%b", i_dividend, i_divisor, o_quotient_out, o_overflow);
105
                        end
106
 
107
endmodule
108
 

powered by: WebSVN 2.1.0

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