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

Subversion Repositories ecg

[/] [ecg/] [trunk/] [testbench/] [test_point_add.v] - Blame information for rev 9

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

Line No. Rev Author Line
1 4 homer.xing
`timescale 1ns / 1ps
2
`include "../rtl/inc.v"
3
 
4
module test_point_add;
5
 
6
        // Inputs
7
        reg clk;
8
        reg reset;
9
        reg [`WIDTH:0] x1, y1, x2, y2;
10
        reg zero1;
11
        reg zero2;
12
 
13
        // Outputs
14
        wire done;
15
        wire zero3;
16
    wire [`WIDTH:0] x3, y3;
17
 
18
    // Const
19
    reg [`WIDTH:0] p1x, p1y, np1y, p2x, p2y, np2y;
20
 
21
        // Instantiate the Unit Under Test (UUT)
22
        point_add uut (
23
                .clk(clk),
24
                .reset(reset),
25
                .x1(x1),
26
                .y1(y1),
27
                .zero1(zero1),
28
                .x2(x2),
29
                .y2(y2),
30
                .zero2(zero2),
31
                .done(done),
32
                .x3(x3),
33
                .y3(y3),
34
                .zero3(zero3)
35
        );
36
 
37
        initial begin
38
                // Initialize Inputs
39
                clk = 0;
40
                reset = 0;
41
                x1 = 0;
42
                y1 = 0;
43
                zero1 = 0;
44
                x2 = 0;
45
                y2 = 0;
46
                zero2 = 0;
47
 
48
                // Wait 100 ns for global reset to finish
49
                #100;
50
 
51
                // Add stimulus here
52
        p1x=194'h154594219a60a610649861a602548666509898492a8049;
53
        p1y=194'h9a5a89a26aa5a1189680a6a64080a519a5054a11a9208094;
54
        np1y=194'h65a54651955a52246940595980405a265a0a852256104068;
55
        p2x=194'h109489806019280a602169554246868a518a6102854294968;
56
        p2y=194'h94995581208995898a04995a50901a6a60421902a21a966a;
57
        np2y=194'h6866aa4210466a46450866a5a06025959081260151256995;
58
 
59
        // Two points are both inf points
60
        x1 = p1x; y1 = p1y; zero1 = 1;
61
        x2 = p2x; y2 = p2y; zero2 = 1;
62
        go;
63
 
64
        #5 if(zero3 !== 1) begin $display("E"); $finish; end
65
 
66
        // One point is the inf point, the other is not. test case 1
67
        x1 = p1x; y1 = p1y; zero1 = 0;
68
        x2 = p2x; y2 = p2y; zero2 = 1;
69
        go;
70
 
71
        #5 if(zero3 !== 0 || x3 !== p1x || y3 !== p1y) begin $display("E"); $finish; end
72
 
73
        // One point is the inf point, the other is not. test case 2
74
        x1 = p1x; y1 = p1y; zero1 = 1;
75
        x2 = p2x; y2 = p2y; zero2 = 0;
76
        go;
77
 
78
        #5 if(zero3 !== 0 || x3 !== p2x || y3 !== p2y) begin $display("E"); $finish; end
79
 
80
        // If P1==-P2, then P3==the inf point. test case 1
81
        x1 = p1x; y1 = p1y; zero1 = 0;
82
        x2 = p1x; y2 = np1y; zero2 = 0;
83
        go;
84
 
85
        #5 if(zero3 !== 1) begin $display("E"); $finish; end
86
 
87
        // If P1==-P2, then P3==the inf point. test case 2
88
        x1 = p2x; y1 = p2y; zero1 = 0;
89
        x2 = p2x; y2 = np2y; zero2 = 0;
90
        go;
91
 
92
        #5 if(zero3 !== 1) begin $display("E"); $finish; end
93
 
94
        // If P1==P2. test case 1
95
        x1 = p1x; y1 = p1y; zero1 = 0;
96
        x2 = p1x; y2 = p1y; zero2 = 0;
97
        go;
98
 
99
        #5 if(zero3 !== 0 ||
100
              x3 !== 194'h51a80aa6548495816a6015424a209489998160946485920a ||
101
              y3 !== 194'h18828584561659888a26269240125594996068145915145
102
              ) begin $display("E"); $finish; end
103
 
104
        // If P1==P2. test case 2
105
        x1 = p2x; y1 = p2y; zero1 = 0;
106
        x2 = p2x; y2 = p2y; zero2 = 0;
107
        go;
108
 
109
        #5 if(zero3 !== 0 ||
110
              x3 !== 194'h2805051564005642629524a84a6159a605024615a90a62042 ||
111
              y3 !== 194'h2502568a5aa504152460984aa699616901895100a595862a8
112
              ) begin $display("E"); $finish; end
113
 
114
        // If P1 != +- P2, test case 1
115
        x1 = p1x; y1 = p1y; zero1 = 0;
116
        x2 = p2x; y2 = p2y; zero2 = 0;
117
        go;
118
 
119
        #5 if(zero3 !== 0 ||
120
              x3 !== 194'ha629964882665246a929a19808a94825948aa499250110a ||
121
              y3 !== 194'h920546a8540695a10010a95485a848684a51a864656a82
122
              ) begin $display("E"); $finish; end
123
 
124
        // If P1 != +- P2, test case 2
125
        x1 = 194'h2405a1946a466242911520254a852988898292a4069969259;
126
        y1 = 194'ha4568a88466646a4a86925162822a6621aa88aa85916089a;
127
        zero1 = 0;
128
        x2 = 194'h10545a2861a44529a24458448958295561a012412846a9259;
129
        y2 = 194'h2066580628a590a248451a6994956a142a42a5a010840229a;
130
        zero2 = 0;
131
        go;
132
 
133
        #5 if(zero3 !== 0 ||
134
              x3 !== 194'h5820222101a8668a69a4492258246242545104498588a4a8 ||
135
              y3 !== 194'h9892492664444861200a582a998010901105a90556429005
136
              ) begin $display("E"); $finish; end
137
 
138
        // good work, buddy
139
        $display("nice!");
140
        $finish;
141
        end
142
 
143
        always #5 clk = ~clk;
144
 
145
        task go;
146
      begin
147
        @ (negedge clk); reset = 1; @ (negedge clk); reset = 0;
148
        @ (posedge done);
149
      end
150
        endtask
151
endmodule
152
 

powered by: WebSVN 2.1.0

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