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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [rtl/] [verilog/] [t6507lp_alu_tb.v] - Blame information for rev 181

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

Line No. Rev Author Line
1 127 gabrielosh
`include "timescale.v"
2 136 gabrielosh
module t6507lp_alu_tb;
3 127 gabrielosh
 
4 136 gabrielosh
`include  "t6507lp_package.v"
5 127 gabrielosh
 
6 136 gabrielosh
reg         clk;
7 140 gabrielosh
reg         reset_n;
8 136 gabrielosh
reg         alu_enable;
9
wire [7:0]  alu_result;
10
wire [7:0]  alu_status;
11
reg  [7:0]  alu_opcode;
12
reg  [7:0]  alu_a;
13
wire [7:0]  alu_x;
14
wire [7:0]  alu_y;
15
reg  [31:0] i;
16 127 gabrielosh
 
17
reg [7:0] alu_result_expected;
18
reg [7:0] alu_status_expected;
19
reg [7:0] alu_x_expected;
20
reg [7:0] alu_y_expected;
21
 
22 164 gabrielosh
reg C_in;
23 181 gabrielosh
reg C_temp;
24
reg [7:0] temp1;
25
reg [7:0] temp2;
26 156 gabrielosh
reg sign;
27 164 gabrielosh
reg [3:0] AL;
28
reg [3:0] AH;
29
reg [3:0] BL;
30
reg [3:0] BH;
31
reg [7:0] alu_result_expected_temp;
32 127 gabrielosh
 
33 136 gabrielosh
t6507lp_alu DUT (
34
                        .clk            (clk),
35
                        .reset_n        (reset_n),
36 127 gabrielosh
                        .alu_enable     (alu_enable),
37
                        .alu_result     (alu_result),
38
                        .alu_status     (alu_status),
39
                        .alu_opcode     (alu_opcode),
40
                        .alu_a          (alu_a),
41
                        .alu_x          (alu_x),
42
                        .alu_y          (alu_y)
43
                );
44
 
45
 
46
localparam period = 10;
47
 
48
task check;
49
        begin
50
                $display("               RESULTS       EXPECTED");
51
                $display("alu_result       %h             %h   ", alu_result, alu_result_expected);
52
                $display("alu_status    %b       %b   ", alu_status, alu_status_expected);
53
                $display("alu_x            %h             %h   ", alu_x,      alu_x_expected     );
54
                $display("alu_y            %h             %h   ", alu_y,      alu_y_expected     );
55 150 gabrielosh
                if ((alu_result_expected == alu_result) && (alu_status_expected == alu_status) && (alu_x_expected == alu_x) && (alu_y_expected == alu_y))
56 127 gabrielosh
                begin
57 150 gabrielosh
                        $display("Instruction %h... OK!", alu_opcode);
58 127 gabrielosh
                end
59
                else
60
                begin
61 150 gabrielosh
                        $display("ERROR at instruction %h",alu_opcode);
62
                        $finish;
63 127 gabrielosh
                end
64
        end
65
endtask
66
 
67
 
68
always begin
69 136 gabrielosh
        #(period/2) clk = ~clk;
70 127 gabrielosh
end
71
 
72
initial
73
begin
74
        // Reset
75 136 gabrielosh
        clk = 0;
76
        reset_n = 0;
77 140 gabrielosh
        @(negedge clk);
78 150 gabrielosh
        //@(negedge clk);
79 148 gabrielosh
        reset_n = 1;
80 127 gabrielosh
        alu_enable = 1;
81
        alu_result_expected = 8'h00;
82
        alu_status_expected = 8'b00100010;
83
        alu_x_expected = 8'h00;
84
        alu_y_expected = 8'h00;
85
 
86
        // LDA
87
        alu_a = 0;
88
        alu_opcode = LDA_IMM;
89
        //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
90
        //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
91 140 gabrielosh
        @(negedge clk);
92 127 gabrielosh
        alu_result_expected = 8'h00;
93
        //                       NV1BDIZC
94 149 gabrielosh
    alu_status_expected = 8'b00100010;
95 173 gabrielosh
        check;
96 127 gabrielosh
 
97
        // ADC
98
        alu_opcode = ADC_IMM;
99
        alu_a = 1;
100
        for (i = 0; i < 1000; i = i + 1)
101
        begin
102 149 gabrielosh
                alu_a = $random;
103 140 gabrielosh
                @(negedge clk);
104 149 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
105
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
106
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], DUT.result);
107 156 gabrielosh
                sign = alu_result_expected[7];
108 127 gabrielosh
                {alu_status_expected[C], alu_result_expected} = alu_a + alu_result_expected + alu_status_expected[C];
109
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
110
                alu_status_expected[N] = alu_result_expected[7];
111 156 gabrielosh
                alu_status_expected[V] = ((alu_a[7] == sign) && (alu_a[7] != alu_result_expected[7]));
112 173 gabrielosh
                check;
113 127 gabrielosh
        end
114 169 gabrielosh
 
115 164 gabrielosh
        // BCD
116 161 gabrielosh
        // LDA
117
        alu_a = 0;
118
        alu_opcode = LDA_IMM;
119
        //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
120
        //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
121
        @(negedge clk);
122
        alu_result_expected = 8'h00;
123
        //                       NV1BDIZC
124 164 gabrielosh
        alu_status_expected[N] = 0;
125
        alu_status_expected[Z] = 1;
126 173 gabrielosh
        check;
127 164 gabrielosh
        // SED
128
        alu_opcode = SED_IMP;
129 181 gabrielosh
        //$display("A = %h B = %h X = %h Y = %h", alu_result, alu_a, alu_x, alu_y);
130 164 gabrielosh
        @(negedge clk);
131
        alu_status_expected[D] = 1;
132 173 gabrielosh
        check;
133 161 gabrielosh
 
134
        // ADC
135
        alu_opcode = ADC_IMM;
136
        for (i = 0; i < 1000; i = i + 1)
137
        begin
138
                alu_a = $random;
139 181 gabrielosh
                //$display("A = %h B = %h C = %b X = %h Y = %h", alu_result, alu_a, alu_status_expected[C], alu_x, alu_y);
140 161 gabrielosh
                @(negedge clk);
141 181 gabrielosh
                C_temp = 0;
142 161 gabrielosh
                sign = alu_result_expected[7];
143 164 gabrielosh
                AL = alu_a[3:0];
144
                AH = alu_a[7:4];
145
                BL = alu_result_expected[3:0];
146
                BH = alu_result_expected[7:4];
147 181 gabrielosh
                /*
148
                if (AL > 9) begin
149 164 gabrielosh
                        AL = AL - 10;
150
                        AH = AH + 1;
151
                end
152 181 gabrielosh
                if ( AH > 9 ) begin
153 164 gabrielosh
                        AH = AH - 10;
154 181 gabrielosh
                        C_temp = 1;
155 164 gabrielosh
                end
156 181 gabrielosh
                if (BL > 9) begin
157 164 gabrielosh
                        BL = BL - 10;
158
                        BH = BH + 1;
159
                end
160
                if ( BH > 9 ) begin
161
                        BH = BH - 10;
162 181 gabrielosh
                        C_temp = 1;
163 164 gabrielosh
                end
164 181 gabrielosh
                */
165
                //$display("AL = %h BL = %h", AL, BL, );
166
                temp1 = AL + BL + alu_status_expected[C];
167
                //AH = A[7:4] + alu_a[7:4];
168
                temp2 = AH + BH;
169
                //$display("temp1 = %h temp2 = %h", temp1, temp2);
170
                if (temp1 > 9) begin
171
                        temp2 = temp2 + (temp1 / 10);
172
                        temp1 = temp1 % 10;
173 164 gabrielosh
                end
174 181 gabrielosh
                if (temp2 > 9) begin
175 165 gabrielosh
                        alu_status_expected[C] = 1;
176 181 gabrielosh
                        temp2 = temp2 % 10;
177 164 gabrielosh
                end
178 181 gabrielosh
                else begin
179
                        alu_status_expected[C] = 0;
180
                end
181
                //$display("bcdh2 = %d", bcdh2);
182
                //$display("bcdl = %d", bcdl);
183
                alu_result_expected = {temp2[3:0],temp1[3:0]};
184
                //{C_in,alu_result_expected[3:0]} = AL + BL + alu_status_expected[C];
185
                //{alu_status_expected[C],alu_result_expected[7:4]} = AH + BH + C_in;
186
                //if ( alu_result_expected[3:0] > 9 ) begin
187
                //      alu_result_expected[3:0] = alu_result_expected[3:0] - 10;
188
        //              alu_result_expected[7:4] = alu_result_expected[7:4] + 1;
189
                //end
190
                //if ( alu_result_expected[7:4] > 9 ) begin
191
                //      alu_result_expected[7:4] = alu_result_expected[7:4] - 10;
192
        //              alu_status_expected[C] = 1;
193
                //end
194 161 gabrielosh
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
195
                alu_status_expected[N] = alu_result_expected[7];
196
                alu_status_expected[V] = ((alu_a[7] == sign) && (alu_a[7] != alu_result_expected[7]));
197 173 gabrielosh
                check;
198 179 gabrielosh
        end
199 181 gabrielosh
        //$stop;
200 179 gabrielosh
        // CLD
201
        alu_opcode = CLD_IMP;
202
        @(negedge clk);
203
        alu_status_expected[D] = 0;
204
        check;
205
 
206 181 gabrielosh
        // SBC BCD
207
        // LDA
208
        alu_a = 0;
209
        alu_opcode = LDA_IMM;
210
        //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
211
        //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
212
        @(negedge clk);
213
        alu_result_expected = 8'h00;
214
        //                       NV1BDIZC
215
        alu_status_expected[N] = 0;
216
        alu_status_expected[Z] = 1;
217
        check;
218
        // SED
219
        alu_opcode = SED_IMP;
220
        $display("A = %h B = %h X = %h Y = %h", alu_result, alu_a, alu_x, alu_y);
221
        @(negedge clk);
222
        alu_status_expected[D] = 1;
223
        check;
224
 
225
        // ADC
226
        alu_opcode = SBC_IMM;
227
        for (i = 0; i < 1000; i = i + 1)
228
        begin
229
                alu_a = $random;
230
                $display("A = %h B = %h C = %b X = %h Y = %h", alu_result, alu_a, alu_status_expected[C], alu_x, alu_y);
231
                @(negedge clk);
232
                C_temp = 0;
233
                sign   = alu_a[7];
234
                AL     = alu_a[3:0];
235
                AH     = alu_a[7:4];
236
                BL     = ~alu_result_expected[3:0];
237
                BH     = ~alu_result_expected[7:4];
238
                /*
239
                if (AL > 9) begin
240
                        AL = AL - 10;
241
                        AH = AH + 1;
242
                end
243
                if ( AH > 9 ) begin
244
                        AH = AH - 10;
245
                        C_temp = 1;
246
                end
247
                if (BL > 9) begin
248
                        BL = BL - 10;
249
                        BH = BH + 1;
250
                end
251
                if ( BH > 9 ) begin
252
                        BH = BH - 10;
253
                        C_temp = 1;
254
                end
255
                */
256
 
257
                //$display("AL = %h BL = %h", AL, BL, );
258
                temp1 = AL + BL + alu_status_expected[C];
259
                //AH = A[7:4] + alu_a[7:4];
260
                temp2 = AH + BH;
261
                //$display("temp1 = %h temp2 = %h", temp1, temp2);
262
                if (temp1 > 9) begin
263
                        temp2 = temp2 + (temp1 / 10);
264
                        temp1 = temp1 % 10;
265
                end
266
                if (temp2 > 9) begin
267
                        alu_status_expected[C] = 1;
268
                        temp2 = temp2 % 10;
269
                end
270
                else begin
271
                        alu_status_expected[C] = 0;
272
                end
273
                //$display("bcdh2 = %d", bcdh2);
274
                //$display("bcdl = %d", bcdl);
275
                alu_result_expected = {temp2[3:0],temp1[3:0]};
276
                //{C_in,alu_result_expected[3:0]} = AL + BL + alu_status_expected[C];
277
                //{alu_status_expected[C],alu_result_expected[7:4]} = AH + BH + C_in;
278
                //if ( alu_result_expected[3:0] > 9 ) begin
279
                //      alu_result_expected[3:0] = alu_result_expected[3:0] - 10;
280
        //              alu_result_expected[7:4] = alu_result_expected[7:4] + 1;
281
                //end
282
                //if ( alu_result_expected[7:4] > 9 ) begin
283
                //      alu_result_expected[7:4] = alu_result_expected[7:4] - 10;
284
        //              alu_status_expected[C] = 1;
285
                //end
286
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
287
                alu_status_expected[N] = alu_result_expected[7];
288
                alu_status_expected[V] = ((alu_a[7] == sign) && (alu_a[7] != alu_result_expected[7]));
289
                check;
290
        end
291
        $stop;
292
        // CLD
293
        alu_opcode = CLD_IMP;
294
        @(negedge clk);
295
        alu_status_expected[D] = 0;
296
        check;
297
 
298 148 gabrielosh
        // ASL
299 145 gabrielosh
        alu_opcode = ASL_ABS;
300
        for (i = 0; i < 1000; i = i + 1)
301
        begin
302
                alu_a = i;
303
                @(negedge clk);
304
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
305
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
306
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
307
                {alu_status_expected[C], alu_result_expected} = {alu_a,1'b0};
308
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
309
                alu_status_expected[N] = alu_result_expected[7];
310 173 gabrielosh
                check;
311 145 gabrielosh
        end
312
 
313
        // LDA
314 156 gabrielosh
        alu_a = 137;
315
        alu_opcode = LDA_IMM;
316
    //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
317
        //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
318
        @(negedge clk);
319
        alu_result_expected = 8'd137;
320
        //                       NV1BDIZC
321
        alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
322
        alu_status_expected[N] = alu_result_expected[7];
323 173 gabrielosh
        check;
324 156 gabrielosh
 
325
        // EOR
326
        alu_opcode = EOR_IMM;
327
        for (i = 0; i < 1000; i = i + 1)
328
        begin
329
                alu_a = i;
330
                @(negedge clk);
331
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
332
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
333
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
334 179 gabrielosh
                //$display("result_expected = %d",alu_result_expected);
335 156 gabrielosh
                alu_result_expected = alu_a ^ alu_result_expected;
336
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
337
                alu_status_expected[N] = alu_result_expected[7];
338 179 gabrielosh
                //$display("result_expected = %d", alu_result_expected);
339 173 gabrielosh
                check;
340 156 gabrielosh
        end
341
 
342
        // LDA
343 145 gabrielosh
        alu_a = 0;
344
        alu_opcode = LDA_IMM;
345
    //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
346
        //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
347
        @(negedge clk);
348
        alu_result_expected = 8'h00;
349
        //                       NV1BDIZC
350
        alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
351
        alu_status_expected[N] = alu_result_expected[7];
352 173 gabrielosh
        check;
353 145 gabrielosh
 
354 127 gabrielosh
        // SBC
355
        alu_opcode = SBC_IMM;
356
        for (i = 0; i < 1000; i = i + 1)
357
        begin
358 145 gabrielosh
                alu_a = 1;
359 140 gabrielosh
                @(negedge clk);
360 174 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
361
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
362
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
363 156 gabrielosh
                sign = alu_result_expected[7];
364 174 gabrielosh
                alu_result_expected = alu_result_expected - alu_a - ( 1 - alu_status_expected[C]);
365
                alu_status_expected[C] = ~alu_result_expected[7];
366 127 gabrielosh
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
367
                alu_status_expected[N] = alu_result_expected[7];
368 174 gabrielosh
                //$display("alu_a[7] = %b == sign = %b && alu_a[7] = %b != alu_result_expected[7] = %b", alu_a[7], sign, alu_a[7], alu_result_expected[7]);
369 156 gabrielosh
                alu_status_expected[V] = ((alu_a[7] == sign) && (alu_a[7] != alu_result_expected[7]));
370 173 gabrielosh
                check;
371 127 gabrielosh
        end
372
 
373
        // LDA
374
        alu_opcode = LDA_IMM;
375
        for (i = 0; i < 1000; i = i + 1)
376
        begin
377
                alu_a = i;
378 140 gabrielosh
                @(negedge clk);
379 127 gabrielosh
                alu_result_expected = i;
380
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
381
                alu_status_expected[N] = alu_result_expected[7];
382
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
383
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
384
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
385 173 gabrielosh
                check;
386 127 gabrielosh
        end
387
 
388
        // LDX
389
        alu_opcode = LDX_IMM;
390
        for (i = 0; i < 1000; i = i + 1)
391
        begin
392
                alu_a = i;
393 140 gabrielosh
                @(negedge clk);
394 178 gabrielosh
                alu_x_expected = alu_a;
395 179 gabrielosh
                //$display("alu_x_expected = %h", alu_x_expected);
396 127 gabrielosh
                //alu_result_expected = i;
397
                alu_status_expected[Z] = (alu_x_expected == 0) ? 1 : 0;
398
                alu_status_expected[N] = alu_x_expected[7];
399
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
400
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
401
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
402 173 gabrielosh
                check;
403 127 gabrielosh
        end
404
 
405
        // LDY
406
        alu_opcode = LDY_IMM;
407
        for (i = 0; i < 1001; i = i + 1)
408
        begin
409
                alu_a = i;
410 140 gabrielosh
                @(negedge clk);
411 178 gabrielosh
                alu_y_expected = alu_a;
412 179 gabrielosh
                //$display("alu_y_expected = %h", alu_y_expected);
413 127 gabrielosh
                //alu_result_expected = i;
414
                alu_status_expected[Z] = (alu_y_expected == 0) ? 1 : 0;
415
                alu_status_expected[N] = alu_y_expected[7];
416
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
417
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
418
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
419 173 gabrielosh
                check;
420 127 gabrielosh
        end
421
 
422
        // STA
423
        alu_opcode = STA_ABS;
424
        for (i = 0; i < 1000; i = i + 1)
425
        begin
426
                alu_a = i;
427 140 gabrielosh
                @(negedge clk);
428 127 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
429
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
430
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
431 178 gabrielosh
                //alu_result_expected = alu_a;
432
                //alu_result_expected = DUT.A;
433 173 gabrielosh
                check;
434 127 gabrielosh
        end
435
 
436
        // STX
437
        alu_opcode = STX_ABS;
438
        for (i = 0; i < 1000; i = i + 1)
439
        begin
440
                alu_a = i;
441 140 gabrielosh
                @(negedge clk);
442 179 gabrielosh
                //$display("alu_x_expected = %h", alu_x_expected);
443 127 gabrielosh
                //alu_result_expected = i;
444 178 gabrielosh
                //alu_x_expected = alu_a;
445 127 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
446
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
447
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
448 173 gabrielosh
                check;
449 127 gabrielosh
        end
450
 
451
        // STY
452
        alu_opcode = STY_ABS;
453
        for (i = 0; i < 1000; i = i + 1)
454
        begin
455
                alu_a = i;
456 140 gabrielosh
                @(negedge clk);
457 179 gabrielosh
                //$display("alu_y_expected = %h", alu_y_expected);
458 127 gabrielosh
                //alu_result_expected = i;
459 178 gabrielosh
                //alu_y_expected = alu_a;
460 127 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
461
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
462
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
463 173 gabrielosh
                check;
464 127 gabrielosh
        end
465
 
466
        // CMP
467
        alu_opcode = CMP_IMM;
468
        for (i = 0; i < 1000; i = i + 1)
469
        begin
470
                alu_a = i;
471 140 gabrielosh
                @(negedge clk);
472 181 gabrielosh
                temp1 = alu_result_expected - alu_a;
473
                alu_status_expected[Z] = (temp1 == 0) ? 1 : 0;
474
                alu_status_expected[N] = temp1[7];
475 127 gabrielosh
                alu_status_expected[C] = (alu_result_expected >= alu_a) ? 1 : 0;
476
                //alu_result_expected = i;
477
                //alu_y_expected = i;
478
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
479
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
480
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
481 173 gabrielosh
                check;
482 127 gabrielosh
        end
483
 
484
        // CPX
485
        alu_opcode = CPX_IMM;
486
        for (i = 0; i < 1000; i = i + 1)
487
        begin
488
                alu_a = i;
489 140 gabrielosh
                @(negedge clk);
490 181 gabrielosh
                temp1 = alu_x_expected - alu_a;
491
                alu_status_expected[Z] = (temp1 == 0) ? 1 : 0;
492
                alu_status_expected[N] = temp1[7];
493 127 gabrielosh
                alu_status_expected[C] = (alu_x_expected >= alu_a) ? 1 : 0;
494
                //alu_result_expected = i;
495
                //alu_y_expected = i;
496
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
497
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
498
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
499 173 gabrielosh
                check;
500 127 gabrielosh
        end
501
 
502
        // CPY
503
        alu_opcode = CPY_IMM;
504
        for (i = 0; i < 1000; i = i + 1)
505
        begin
506
                alu_a = i;
507 140 gabrielosh
                @(negedge clk);
508 181 gabrielosh
                temp1 = alu_y_expected - alu_a;
509
                alu_status_expected[Z] = (temp1 == 0) ? 1 : 0;
510
                alu_status_expected[N] = temp1[7];
511 127 gabrielosh
                alu_status_expected[C] = (alu_y_expected >= alu_a) ? 1 : 0;
512
                //alu_result_expected = i;
513
                //alu_y_expected = i;
514
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
515
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
516
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
517 173 gabrielosh
                check;
518 127 gabrielosh
        end
519
 
520
 
521
        // AND
522
        alu_opcode = AND_IMM;
523
        for (i = 0; i < 1000; i = i + 1)
524
        begin
525
                alu_a = i;
526 140 gabrielosh
                @(negedge clk);
527 156 gabrielosh
                alu_result_expected = alu_a & alu_result_expected;
528 127 gabrielosh
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
529
                alu_status_expected[N] = alu_result_expected[7];
530
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
531
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
532
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
533 173 gabrielosh
                check;
534 127 gabrielosh
        end
535
 
536
        // ASL
537
        alu_opcode = ASL_ACC;
538
        for (i = 0; i < 1000; i = i + 1)
539
        begin
540
                alu_a = i;
541 140 gabrielosh
                @(negedge clk);
542 127 gabrielosh
                alu_status_expected[C] = alu_result_expected[7];
543
                alu_result_expected[7:0] = alu_result_expected << 1;
544
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
545
                alu_status_expected[N] = alu_result_expected[7];
546
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
547
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
548
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
549 173 gabrielosh
                check;
550 127 gabrielosh
        end
551
 
552
        // INC
553
        alu_opcode = INC_ZPG;
554
        for (i = 0; i < 1000; i = i + 1)
555
        begin
556
                alu_a = i;
557 140 gabrielosh
                @(negedge clk);
558 127 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
559
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
560
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
561
                alu_result_expected = alu_a + 1;
562
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
563
                alu_status_expected[N] = alu_result_expected[7];
564 173 gabrielosh
                check;
565 127 gabrielosh
        end
566
 
567
        // INX
568
        alu_opcode = INX_IMP;
569
        for (i = 0; i < 1000; i = i + 1)
570
        begin
571
                alu_a = i;
572 140 gabrielosh
                @(negedge clk);
573 127 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
574
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
575
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
576
                alu_x_expected = alu_x_expected + 1;
577
                alu_status_expected[Z] = (alu_x_expected == 0) ? 1 : 0;
578
                alu_status_expected[N] = alu_x_expected[7];
579 173 gabrielosh
                check;
580 127 gabrielosh
        end
581
 
582
        // INY
583
        alu_opcode = INY_IMP;
584
        for (i = 0; i < 1000; i = i + 1)
585
        begin
586
                alu_a = i;
587 140 gabrielosh
                @(negedge clk);
588 127 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
589
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
590
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
591
                alu_y_expected = alu_y_expected + 1;
592
                alu_status_expected[Z] = (alu_y_expected == 0) ? 1 : 0;
593
                alu_status_expected[N] = alu_y_expected[7];
594 173 gabrielosh
                check;
595 127 gabrielosh
        end
596
 
597
        // DEC
598
        alu_opcode = DEC_ZPG;
599
        for (i = 0; i < 1000; i = i + 1)
600
        begin
601
                alu_a = i;
602 140 gabrielosh
                @(negedge clk);
603 127 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
604
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
605
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
606
                alu_result_expected = alu_a - 1;
607
                alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
608
                alu_status_expected[N] = alu_result_expected[7];
609 173 gabrielosh
                check;
610 127 gabrielosh
        end
611
 
612
        // DEX
613
        alu_opcode = DEX_IMP;
614
        for (i = 0; i < 1000; i = i + 1)
615
        begin
616
                alu_a = i;
617 140 gabrielosh
                @(negedge clk);
618 127 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
619
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
620
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
621
                alu_x_expected = alu_x_expected - 1;
622
                alu_status_expected[Z] = (alu_x_expected == 0) ? 1 : 0;
623
                alu_status_expected[N] = alu_x_expected[7];
624 173 gabrielosh
                check;
625 127 gabrielosh
        end
626
 
627
        // DEY
628
        alu_opcode = DEY_IMP;
629
        for (i = 0; i < 1000; i = i + 1)
630
        begin
631
                alu_a = i;
632 140 gabrielosh
                @(negedge clk);
633 127 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
634
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
635
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
636
                alu_y_expected = alu_y_expected - 1;
637
                alu_status_expected[Z] = (alu_y_expected == 0) ? 1 : 0;
638
                alu_status_expected[N] = alu_y_expected[7];
639 173 gabrielosh
                check;
640 127 gabrielosh
        end
641
 
642
 
643
        // LDA
644
        alu_a = 0;
645
        alu_opcode = LDA_IMM;
646
        //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
647
        //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
648 140 gabrielosh
        @(negedge clk);
649 127 gabrielosh
        alu_result_expected = 8'h00;
650
        //                       NV1BDIZC
651
        alu_status_expected = 8'b00100010;
652 173 gabrielosh
        check;
653 127 gabrielosh
 
654
        // BIT
655
        alu_opcode = BIT_ZPG;
656
        for (i = 0; i < 1000; i = i + 1)
657
        begin
658
                alu_a = i;
659 140 gabrielosh
                @(negedge clk);
660 149 gabrielosh
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
661
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
662
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
663 127 gabrielosh
                alu_status_expected[Z] = ((alu_a & alu_result_expected) == 0) ? 1 : 0;
664
                alu_status_expected[V] = alu_a[6];
665
                alu_status_expected[N] = alu_a[7];
666 173 gabrielosh
                check;
667 127 gabrielosh
        end
668 158 gabrielosh
 
669 176 gabrielosh
        // RTI
670
        alu_opcode = RTI_IMP;
671
        for (i = 0; i < 1000; i = i + 1)
672
        begin
673
                alu_a = i;
674
                @(negedge clk);
675
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
676
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
677
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
678
                alu_status_expected[C] = alu_a[C];
679
                alu_status_expected[Z] = alu_a[Z];
680
                alu_status_expected[N] = alu_a[N];
681
                alu_status_expected[V] = alu_a[V];
682
                alu_status_expected[B] = alu_a[B];
683
                alu_status_expected[D] = alu_a[D];
684
                alu_status_expected[I] = alu_a[I];
685
                check;
686
        end
687 178 gabrielosh
 
688
        // PLP
689
        alu_opcode = PLP_IMP;
690
        for (i = 0; i < 1000; i = i + 1)
691
        begin
692
                alu_a = i;
693
                @(negedge clk);
694
                //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
695
                //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
696
                //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
697
                alu_status_expected[C] = alu_a[C];
698
                alu_status_expected[Z] = alu_a[Z];
699
                alu_status_expected[N] = alu_a[N];
700
                alu_status_expected[V] = alu_a[V];
701
                alu_status_expected[B] = alu_a[B];
702
                alu_status_expected[D] = alu_a[D];
703
                alu_status_expected[I] = alu_a[I];
704
                check;
705
        end
706
 
707 158 gabrielosh
        // PHA
708
        alu_opcode = PHA_IMP;
709
        @(negedge clk);
710
        //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
711
        //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
712
        //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
713 178 gabrielosh
        //alu_result_expected = DUT.A;
714 181 gabrielosh
        //alu_result_expected = alu_a;
715 173 gabrielosh
        check;
716 158 gabrielosh
 
717
        // PHP
718
        alu_opcode = PHP_IMP;
719
        @(negedge clk);
720
        //$display("i = %d alu_opcode = %h alu_enable = %d", i, alu_opcode, alu_enable);
721
        //$display("DUT.A = %h DUT.X = %h DUT.Y = %h", DUT.A, DUT.X, DUT.Y);
722
        //$display("op1 = %d op2 = %d  c = %d d = %d n = %d v = %d result = %d", alu_a, DUT.A, alu_status[C], alu_status[D], alu_status[N], alu_status[V], alu_result);
723 173 gabrielosh
        //alu_status_expected = DUT.STATUS;
724
        check;
725 158 gabrielosh
 
726
        // BRK
727
        alu_opcode = BRK_IMP;
728
        @(negedge clk);
729
        alu_status_expected[B] = 1;
730 173 gabrielosh
        check;
731 158 gabrielosh
 
732 127 gabrielosh
        // SEC
733
        alu_opcode = SEC_IMP;
734 140 gabrielosh
        @(negedge clk);
735 127 gabrielosh
        alu_status_expected[C] = 1;
736 173 gabrielosh
        check;
737 127 gabrielosh
 
738
        // SED
739
        alu_opcode = SED_IMP;
740 140 gabrielosh
        @(negedge clk);
741 127 gabrielosh
        alu_status_expected[D] = 1;
742 173 gabrielosh
        check;
743 127 gabrielosh
 
744
        // SEI
745
        alu_opcode = SEI_IMP;
746 140 gabrielosh
        @(negedge clk);
747 127 gabrielosh
        alu_status_expected[I] = 1;
748 173 gabrielosh
        check;
749 127 gabrielosh
 
750
        // CLC
751
        alu_opcode = CLC_IMP;
752 140 gabrielosh
        @(negedge clk);
753 127 gabrielosh
        alu_status_expected[C] = 0;
754 173 gabrielosh
        check;
755 127 gabrielosh
 
756
        // CLD
757
        alu_opcode = CLD_IMP;
758 140 gabrielosh
        @(negedge clk);
759 127 gabrielosh
        alu_status_expected[D] = 0;
760 173 gabrielosh
        check;
761 127 gabrielosh
 
762
        // CLI
763
        alu_opcode = CLI_IMP;
764 140 gabrielosh
        @(negedge clk);
765 127 gabrielosh
        alu_status_expected[I] = 0;
766 173 gabrielosh
        check;
767 127 gabrielosh
 
768
        // CLV
769
        alu_opcode = CLV_IMP;
770 140 gabrielosh
        @(negedge clk);
771 127 gabrielosh
        alu_status_expected[V] = 0;
772 173 gabrielosh
        check;
773 127 gabrielosh
 
774
        // LDA
775
        alu_opcode = LDA_IMM;
776
        alu_a = 8'h76;
777 140 gabrielosh
        @(negedge clk);
778 127 gabrielosh
        alu_result_expected = alu_a;
779
        alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
780
        alu_status_expected[N] = alu_result_expected[7];
781 173 gabrielosh
        check;
782 127 gabrielosh
 
783
        // TAX
784
        alu_opcode = TAX_IMP;
785 140 gabrielosh
        @(negedge clk);
786 127 gabrielosh
        alu_x_expected = alu_result_expected;
787
        alu_status_expected[Z] = (alu_x_expected == 0) ? 1 : 0;
788
        alu_status_expected[N] = alu_x_expected[7];
789 173 gabrielosh
        check;
790 127 gabrielosh
 
791
        // TAY
792
        alu_opcode = TAY_IMP;
793 140 gabrielosh
        @(negedge clk);
794 127 gabrielosh
        alu_y_expected = alu_result_expected;
795
        alu_status_expected[Z] = (alu_y_expected == 0) ? 1 : 0;
796
        alu_status_expected[N] = alu_y_expected[7];
797 173 gabrielosh
        check;
798 127 gabrielosh
 
799
        // TSX
800
        alu_opcode = TSX_IMP;
801 140 gabrielosh
        @(negedge clk);
802 127 gabrielosh
        alu_x_expected = alu_a;
803
        //alu_result_expected = alu_a;
804
        alu_status_expected[Z] = (alu_x_expected == 0) ? 1 : 0;
805
        alu_status_expected[N] = alu_x_expected[7];
806 173 gabrielosh
        check;
807 127 gabrielosh
 
808
        // TXA
809
        alu_opcode = TXA_IMP;
810 140 gabrielosh
        @(negedge clk);
811 127 gabrielosh
        alu_result_expected = alu_x_expected;
812
        alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
813
        alu_status_expected[N] = alu_result_expected[7];
814 173 gabrielosh
        check;
815 127 gabrielosh
 
816
        // TXS
817
        alu_opcode = TXS_IMP;
818 140 gabrielosh
        @(negedge clk);
819 127 gabrielosh
        alu_result_expected = alu_x_expected;
820 173 gabrielosh
        check;
821 127 gabrielosh
 
822
        // TYA
823
        alu_opcode = TYA_IMP;
824 140 gabrielosh
        @(negedge clk);
825 127 gabrielosh
        alu_result_expected = alu_y_expected;
826
        alu_status_expected[Z] = (alu_result_expected == 0) ? 1 : 0;
827
        alu_status_expected[N] = alu_result_expected[7];
828 173 gabrielosh
        check;
829 127 gabrielosh
 
830
        // Nothing should happen
831
        // BCC
832
        alu_opcode = BCC_REL;
833 140 gabrielosh
        @(negedge clk);
834 173 gabrielosh
        check;
835 127 gabrielosh
 
836
        // BCS
837
        alu_opcode = BCS_REL;
838 140 gabrielosh
        @(negedge clk);
839 173 gabrielosh
        check;
840 127 gabrielosh
 
841
        // BEQ
842
        alu_opcode = BEQ_REL;
843 140 gabrielosh
        @(negedge clk);
844 173 gabrielosh
        check;
845 127 gabrielosh
 
846
        // BMI
847
        alu_opcode = BMI_REL;
848 140 gabrielosh
        @(negedge clk);
849 173 gabrielosh
        check;
850 127 gabrielosh
 
851
        // BNE
852
        alu_opcode = BNE_REL;
853 140 gabrielosh
        @(negedge clk);
854 173 gabrielosh
        check;
855 127 gabrielosh
 
856
        // BPL
857
        alu_opcode = BPL_REL;
858 140 gabrielosh
        @(negedge clk);
859 173 gabrielosh
        check;
860 127 gabrielosh
 
861
        // BVC
862
        alu_opcode = BVC_REL;
863 140 gabrielosh
        @(negedge clk);
864 173 gabrielosh
        check;
865 127 gabrielosh
 
866
        // BVS
867
        alu_opcode = BVS_REL;
868 140 gabrielosh
        @(negedge clk);
869 173 gabrielosh
        check;
870 127 gabrielosh
 
871
        // JMP
872
        alu_opcode = JMP_ABS;
873 140 gabrielosh
        @(negedge clk);
874 173 gabrielosh
        check;
875 127 gabrielosh
 
876
        // JMP
877
        alu_opcode = JMP_IND;
878 140 gabrielosh
        @(negedge clk);
879 173 gabrielosh
        check;
880 127 gabrielosh
 
881
        // JSR
882
        alu_opcode = JSR_ABS;
883 140 gabrielosh
        @(negedge clk);
884 173 gabrielosh
        check;
885 127 gabrielosh
 
886
        // NOP
887
        alu_opcode = NOP_IMP;
888 140 gabrielosh
        @(negedge clk);
889 173 gabrielosh
        check;
890 127 gabrielosh
 
891
        // RTS
892
        alu_opcode = RTS_IMP;
893 140 gabrielosh
        @(negedge clk);
894 173 gabrielosh
        check;
895 127 gabrielosh
 
896
        $display("TEST PASSED");
897
        $finish;
898
end
899
 
900
endmodule
901
 

powered by: WebSVN 2.1.0

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