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

Subversion Repositories apbtoaes128

[/] [apbtoaes128/] [trunk/] [testbench/] [tb_aes_ip.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 redbear
module tb_aes_ip();
2
 
3
localparam AES_CR    = 4'd00;
4
localparam AES_SR    = 4'd01;
5
localparam AES_DINR  = 4'd02;
6
localparam AES_DOUTR = 4'd03;
7
localparam AES_KEYR0 = 4'd04;
8
localparam AES_KEYR1 = 4'd05;
9
localparam AES_KEYR2 = 4'd06;
10
localparam AES_KEYR3 = 4'd07;
11
localparam AES_IVR0  = 4'd08;
12
localparam AES_IVR1  = 4'd09;
13
localparam AES_IVR2  = 4'd10;
14
localparam AES_IVR3  = 4'd11;
15
 
16
// Configuratin Bits
17
localparam DMAOUTEN    = 32'h00000001 << 12;
18
localparam DMAINEN     = 32'h00000001 << 11;
19
localparam ERRIE       = 32'h00000001 << 10;
20
localparam CCFIE       = 32'h00000001 << 9;
21
localparam ERRC        = 32'h00000001 << 8;
22
localparam CCFC        = 32'h00000001 << 7;
23
localparam EBC         = 32'h00000000;
24
localparam CBC         = 32'h00000001 << 5;
25
localparam CTR         = 32'h00000001 << 6;
26
localparam ENCRYPTION  = 32'h00000000;
27
localparam KEY_DERIV   = 32'h00000001 << 3;
28
localparam DECRYPTION  = 32'h00000001 << 4;
29
localparam KEY_DECRYP  = KEY_DERIV | DECRYPTION;
30
localparam ENABLE      = 32'h00000001;
31
localparam DISABLE     = 32'h00000000;
32
 
33
wire int_ccf, int_err;
34
wire dma_req_wr, dma_req_rd;
35
wire [31:0] PRDATA;
36
 
37
reg [31:0] PWDATA;
38
reg [3:0] PADDR;
39
reg PCLK, PRESETn;
40
reg PSEL, PENABLE, PWRITE;
41
 
42
reg [31:0] data_rd;
43
 
44
reg [127:0] data_in;
45
reg [127:0] key_in;
46
reg [127:0] iv_in;
47
reg [127:0] result;
48
reg [127:0] golden;
49
reg [127:0] result_rd;
50
reg [127:0] iv_rd;
51
reg [127:0] key_rd;
52
reg error_chk;
53
 
54
aes_ip AES_IP
55
(
56
        .int_ccf    ( int_ccf    ),
57
        .int_err    ( int_err    ),
58
        .dma_req_wr ( dma_req_wr ),
59
        .dma_req_rd ( dma_req_rd ),
60
        .PRDATA     ( PRDATA     ),
61
        .PREADY     ( PREADY     ),
62
  .PSLVERR    ( PSLVERR    ),
63
  .PWDATA     ( PWDATA     ),
64
  .PADDR      ( PADDR      ),
65
  .PSEL       ( PSEL       ),
66
  .PENABLE    ( PENABLE    ),
67
  .PWRITE     ( PWRITE     ),
68
  .PCLK       ( PCLK       ),
69
  .PRESETn    ( PRESETn    )
70
);
71
initial
72
 begin
73
    $dumpfile("tb_aes_ip.vcd");
74
    $dumpvars(0,tb_aes_ip);
75
 end
76
task reset;
77
        begin
78
                PCLK = 0;
79
                PSEL = 0;
80
                PENABLE = 0;
81
                PWDATA = 0;
82
                PWRITE = 0;
83
                PADDR = 0;
84
                PRESETn = 0;
85
                @(posedge PCLK);
86
                PRESETn = 1;
87
        end
88
endtask
89
 
90
task apb_write;
91
        input [31:0] addr;
92
        input [31:0] data_in;
93
        begin
94
                PSEL <= 1;
95
                PWRITE <= 1;
96
                PENABLE <= 0;
97
                PADDR <= addr;
98
                PWDATA <= data_in;
99
                @(posedge PCLK);
100
                PENABLE <= 1;
101
                @(posedge PCLK);
102
                PSEL <= 0;
103
                PENABLE <= 0;
104
        end
105
endtask
106
 
107
task apb_read;
108
        input  [31:0] addr;
109
        output [31:0] data_out;
110
        begin
111
                PSEL <= 1;
112
                PENABLE <= 0;
113
                PWRITE <= 0;
114
                PADDR <= addr;
115
                @(posedge PCLK);
116
                PENABLE <= 1;
117
                @(posedge PCLK);
118
                data_out = PRDATA;
119
                PENABLE <= 0;
120
                PSEL <= 0;
121
        end
122
endtask
123
 
124
task write_iv;
125
        input [127:0] iv_in;
126
        begin
127
                apb_write(AES_IVR0, iv_in[ 31:0]);
128
                apb_write(AES_IVR1, iv_in[ 63:32]);
129
                apb_write(AES_IVR2, iv_in[ 95:64]);
130
                apb_write(AES_IVR3, iv_in[127:96]);
131
        end
132
endtask
133
 
134
task read_iv;
135
        output [127:0] iv_out;
136
        begin
137
                apb_read(AES_IVR0, iv_out[ 31:0]);
138
                apb_read(AES_IVR1, iv_out[ 63:32]);
139
                apb_read(AES_IVR2, iv_out[ 95:64]);
140
                apb_read(AES_IVR3, iv_out[127:96]);
141
        end
142
endtask
143
 
144
task write_key;
145
        input [127:0] key_in;
146
        begin
147
                apb_write(AES_KEYR0, key_in[ 31:0]);
148
                apb_write(AES_KEYR1, key_in[ 63:32]);
149
                apb_write(AES_KEYR2, key_in[ 95:64]);
150
                apb_write(AES_KEYR3, key_in[127:96]);
151
        end
152
endtask
153
 
154
task read_key;
155
        output [127:0] key_out;
156
        begin
157
                apb_read(AES_KEYR0, key_out[ 31:0]);
158
                apb_read(AES_KEYR1, key_out[ 63:32]);
159
                apb_read(AES_KEYR2, key_out[ 95:64]);
160
                apb_read(AES_KEYR3, key_out[127:96]);
161
        end
162
endtask
163
 
164
task write_data;
165
        input [127:0] data_in;
166
        begin
167
                apb_write(AES_DINR, data_in[127:96]);
168
                apb_write(AES_DINR, data_in[ 95:64]);
169
                apb_write(AES_DINR, data_in[ 63:32]);
170
                apb_write(AES_DINR, data_in[ 31: 0]);
171
        end
172
endtask
173
 
174
task write_data_dma;
175
        input [127:0] data_in;
176
        begin
177
                @(posedge dma_req_wr);
178
                apb_write(AES_DINR, data_in[127:96]);
179
                @(posedge dma_req_wr);
180
                apb_write(AES_DINR, data_in[ 95:64]);
181
                @(posedge dma_req_wr);
182
                apb_write(AES_DINR, data_in[ 63:32]);
183
                @(posedge dma_req_wr);
184
                apb_write(AES_DINR, data_in[ 31: 0]);
185
        end
186
endtask
187
 
188
task read_data;
189
        output [127:0] data_rd;
190
        begin
191
                apb_read(AES_DOUTR, data_rd[127:96]);
192
                apb_read(AES_DOUTR, data_rd[ 95:64]);
193
                apb_read(AES_DOUTR, data_rd[ 63:32]);
194
                apb_read(AES_DOUTR, data_rd[ 31: 0]);
195
        end
196
endtask
197
 
198
task read_data_dma;
199
        output [127:0] data_rd;
200
        begin
201
                @(posedge dma_req_rd);
202
                apb_read(AES_DOUTR, data_rd[127:96]);
203
                @(posedge dma_req_rd);
204
                apb_read(AES_DOUTR, data_rd[ 95:64]);
205
                @(posedge dma_req_rd);
206
                apb_read(AES_DOUTR, data_rd[ 63:32]);
207
                @(posedge dma_req_rd);
208
                apb_read(AES_DOUTR, data_rd[ 31: 0]);
209
        end
210
endtask
211
 
212
task check_result;
213
        input [127:0] result;
214
        input [127:0] golden;
215
        output error;
216
        begin
217
                error = 0;
218
                if(result != golden)
219
                        begin
220
                                $display("TEST FAILED!");
221
                                $display("Expected %x, obtained %x", golden, result);
222
                                error = 1;
223
                        end
224
        end
225
endtask
226
 
227
integer i, error;
228
 
229
initial
230
        begin
231
                reset;
232
                iv_in  = 128'h2b7e151628aed2a6abf7158809cf4f3c;
233
                key_in = 128'h00112233445566778899aabbccddeeff;
234
                write_iv(iv_in);
235
                read_iv(iv_rd);
236
                if(iv_rd != iv_in)
237
                        begin
238
                                $display("Access to IV register failed!");
239
                                $display("Expected %x, obtained %x", iv_in, iv_rd);
240
                                $stop;
241
                        end
242
                write_key(key_in);
243
                read_key(key_rd);
244
                if(key_rd != key_in)
245
                        begin
246
                                $display("Access to KEY register failed!");
247
                                $display("Expected %x, obtained %x", key_in, key_rd);
248
                                $stop;
249
                        end
250
                apb_write(AES_CR, ENABLE);
251
                write_key(128'd50);
252
                read_iv(data_rd);
253
                read_data(result);
254
                apb_write(AES_CR, DISABLE);
255
                apb_read(AES_SR, data_rd);
256
                apb_write(AES_CR, ERRC);
257
 
258
                //ECB TESTS
259
                //ENCRYPTION
260
                error = 0;
261
                data_in = 128'h00112233445566778899aabbccddeeff;
262
                key_in  = 128'h000102030405060708090a0b0c0d0e0f;
263
                golden  = 128'h69c4e0d86a7b0430d8cdb78070b4c55a;
264
                write_key(key_in);
265
                apb_write(AES_CR, ENABLE | CCFIE);
266
                write_data(data_in);
267
                @(posedge int_ccf);
268
                read_data(result);
269
                check_result(result, golden, error_chk);
270
                error = error + error_chk;
271
 
272
                data_in = 128'h3243f6a8885a308d313198a2e0370734;
273
                key_in  = 128'h2b7e151628aed2a6abf7158809cf4f3c;
274
                golden  = 128'h3925841d02dc09fbdc118597196a0b32;
275
                apb_write(AES_CR, DISABLE);
276
                write_key(key_in);
277
                apb_write(AES_CR, ENABLE | CCFIE);
278
                write_data(data_in);
279
                @(posedge int_ccf);
280
                read_data(result);
281
                check_result(result, golden, error_chk);
282
                error = error + error_chk;
283
 
284
                // KEY DERIVATION
285
                key_in  = 128'h2b7e151628aed2a6abf7158809cf4f3c;
286
                golden  = 128'hd014f9a8c9ee2589e13f0cc8b6630ca6;
287
                apb_write(AES_CR, DISABLE);
288
                write_key(key_in);
289
                apb_write(AES_CR, KEY_DERIV | ENABLE | CCFIE);
290
                @(posedge int_ccf);
291
                @(posedge PCLK);
292
                read_key(result);
293
                check_result(result, golden, error_chk);
294
                error = error + error_chk;
295
 
296
                // DECRYPTION
297
                data_in = 128'h69c4e0d86a7b0430d8cdb78070b4c55a;
298
                key_in  = 128'h13111d7fe3944a17f307a78b4d2b30c5;
299
                golden  = 128'h00112233445566778899aabbccddeeff;
300
                apb_write(AES_CR, DISABLE);
301
                write_key(key_in);
302
                apb_write(AES_CR, DECRYPTION | ENABLE | CCFIE);
303
                write_data(data_in);
304
                @(posedge int_ccf);
305
                read_data(result);
306
                check_result(result, golden, error_chk);
307
                error = error + error_chk;
308
 
309
                // DECCYPTION WITH DERIVATION
310
                data_in = 128'h69c4e0d86a7b0430d8cdb78070b4c55a;
311
                key_in  = 128'h000102030405060708090a0b0c0d0e0f;
312
                golden  = 128'h00112233445566778899aabbccddeeff;
313
                apb_write(AES_CR, DISABLE);
314
                write_key(key_in);
315
                apb_write(AES_CR, KEY_DECRYP | ENABLE | CCFIE);
316
                write_data(data_in);
317
                @(posedge int_ccf);
318
                read_data(result);
319
                check_result(result, golden, error_chk);
320
                error = error + error_chk;
321
 
322
                key_in  = 128'h000102030405060708090a0b0c0d0e0f;
323
                apb_write(AES_CR, DISABLE);
324
                write_key(key_in);
325
                apb_write(AES_CR, KEY_DERIV | ENABLE | CCFIE);
326
                @(posedge int_ccf);
327
                data_in = 128'h69c4e0d86a7b0430d8cdb78070b4c55a;
328
                golden  = 128'h00112233445566778899aabbccddeeff;
329
                apb_write(AES_CR, DISABLE);
330
                apb_write(AES_CR, DECRYPTION | ENABLE | CCFIE);
331
                write_data(data_in);
332
                @(posedge int_ccf);
333
                read_data(result);
334
                check_result(result, golden, error_chk);
335
                error = error + error_chk;
336
                if(!error)
337
                        $display("ECB TEST PASSED!");
338
                else
339
                        $display("ECB TEST FAILED!\n Founded %d errors", error);
340
 
341
                // CBC Encryption
342
                error = 0;
343
                apb_write(AES_CR, DISABLE);
344
                key_in  = 128'h2b7e151628aed2a6abf7158809cf4f3c;
345
                iv_in   = 128'h000102030405060708090a0b0c0d0e0f;
346
 
347
                //BLOCK 1
348
                data_in = 128'h6bc1bee22e409f96e93d7e117393172a;
349
                golden  = 128'h7649abac8119b246cee98e9b12e9197d;
350
                write_key(key_in);
351
                write_iv(iv_in);
352
                apb_write(AES_CR, CBC | ENABLE | CCFIE);
353
                write_data(data_in);
354
                @(posedge int_ccf);
355
                read_data(result);
356
                check_result(result, golden, error_chk);
357
                error = error + error_chk;
358
 
359
                // BLOCK 2
360
                data_in = 128'hae2d8a571e03ac9c9eb76fac45af8e51;
361
                golden = 128'h5086cb9b507219ee95db113a917678b2;
362
                write_data(data_in);
363
                @(posedge int_ccf);
364
                read_data(result);
365
                check_result(result, golden, error_chk);
366
                error = error + error_chk;
367
 
368
                // BLOCK 3
369
                data_in = 128'h30c81c46a35ce411e5fbc1191a0a52ef;
370
                golden = 128'h73bed6b8e3c1743b7116e69e22229516;
371
                write_data(data_in);
372
                @(posedge int_ccf);
373
                read_data(result);
374
                check_result(result, golden, error_chk);
375
                error = error + error_chk;
376
 
377
                // BLOCK 4
378
                data_in = 128'hf69f2445df4f9b17ad2b417be66c3710;
379
                golden = 128'h3ff1caa1681fac09120eca307586e1a7;
380
                write_data(data_in);
381
                @(posedge int_ccf);
382
                read_data(result);
383
                check_result(result, golden, error_chk);
384
                error = error + error_chk;
385
 
386
                // CBC DECRYPTION
387
                apb_write(AES_CR, DISABLE);
388
                key_in  = 128'h2b7e151628aed2a6abf7158809cf4f3c;
389
                iv_in   = 128'h000102030405060708090a0b0c0d0e0f;
390
 
391
                //BLOCK 1
392
                data_in = 128'h7649abac8119b246cee98e9b12e9197d;
393
                golden  = 128'h6bc1bee22e409f96e93d7e117393172a;
394
                write_key(key_in);
395
                write_iv(iv_in);
396
                apb_write(AES_CR, CBC | KEY_DECRYP | ENABLE | CCFIE);
397
                write_data(data_in);
398
                @(posedge int_ccf);
399
                read_data(result);
400
                check_result(result, golden, error_chk);
401
                error = error + error_chk;
402
 
403
                // BLOCK 2
404
                data_in = 128'h5086cb9b507219ee95db113a917678b2;
405
                golden = 128'hae2d8a571e03ac9c9eb76fac45af8e51 ;
406
                write_data(data_in);
407
                @(posedge int_ccf);
408
                read_data(result);
409
                check_result(result, golden, error_chk);
410
                error = error + error_chk;
411
 
412
                // BLOCK 3
413
                data_in = 128'h73bed6b8e3c1743b7116e69e22229516;
414
                golden = 128'h30c81c46a35ce411e5fbc1191a0a52ef ;
415
                write_data(data_in);
416
                @(posedge int_ccf);
417
                read_data(result);
418
                check_result(result, golden, error_chk);
419
                error = error + error_chk;
420
 
421
                // BLOCK 4
422
                data_in = 128'h3ff1caa1681fac09120eca307586e1a7;
423
                golden  = 128'hf69f2445df4f9b17ad2b417be66c3710;
424
                write_data(data_in);
425
                @(posedge int_ccf);
426
                read_data(result);
427
                check_result(result, golden, error_chk);
428
                error = error + error_chk;
429
                if(!error)
430
                        $display("CBC TEST PASSED!");
431
                else
432
                        $display("CBC TEST FAILED!\n Founded %d errors", error);
433
 
434
                // CTR Encryption
435
                error = 0;
436
                apb_write(AES_CR, DISABLE);
437
                key_in  = 128'h2b7e151628aed2a6abf7158809cf4f3c;
438
                iv_in   = 128'hf0f1f2f3f4f5f6f7f8f9fafbfcfdfeff;
439
 
440
                //BLOCK 1
441
                data_in = 128'h6bc1bee22e409f96e93d7e117393172a;
442
                golden  = 128'h874d6191b620e3261bef6864990db6ce ;
443
                write_key(key_in);
444
                write_iv(iv_in);
445
                apb_write(AES_CR, CTR | ENABLE | CCFIE);
446
                write_data(data_in);
447
                @(posedge int_ccf);
448
                read_data(result);
449
                check_result(result, golden, error_chk);
450
                error = error + error_chk;
451
 
452
                // BLOCK 2
453
                data_in = 128'hae2d8a571e03ac9c9eb76fac45af8e51;
454
                golden = 128'h9806f66b7970fdff8617187bb9fffdff;
455
                write_data(data_in);
456
                @(posedge int_ccf);
457
                read_data(result);
458
                check_result(result, golden, error_chk);
459
                error = error + error_chk;
460
 
461
                // BLOCK 3
462
                data_in = 128'h30c81c46a35ce411e5fbc1191a0a52ef;
463
                golden = 128'h5ae4df3edbd5d35e5b4f09020db03eab;
464
                write_data(data_in);
465
                @(posedge int_ccf);
466
                read_data(result);
467
                check_result(result, golden, error_chk);
468
                error = error + error_chk;
469
 
470
                // BLOCK 4
471
                data_in = 128'hf69f2445df4f9b17ad2b417be66c3710;
472
                golden = 128'h1e031dda2fbe03d1792170a0f3009cee ;
473
                write_data(data_in);
474
                @(posedge int_ccf);
475
                read_data(result);
476
                check_result(result, golden, error_chk);
477
                error = error + error_chk;
478
 
479
                // CTR DECRYPTION
480
                apb_write(AES_CR, DISABLE);
481
                iv_in   = 128'hf0f1f2f3f4f5f6f7f8f9fafbfcfdfeff;
482
                //BLOCK 1
483
                data_in = 128'h874d6191b620e3261bef6864990db6ce;
484
                golden  = 128'h6bc1bee22e409f96e93d7e117393172a;
485
                write_iv(iv_in);
486
                apb_write(AES_CR, CTR | KEY_DECRYP | ENABLE | CCFIE);
487
                write_data(data_in);
488
                @(posedge int_ccf);
489
                read_data(result);
490
                check_result(result, golden, error_chk);
491
                error = error + error_chk;
492
 
493
                // BLOCK 2
494
                data_in = 128'h9806f66b7970fdff8617187bb9fffdff;
495
                golden  = 128'hae2d8a571e03ac9c9eb76fac45af8e51;
496
                write_data(data_in);
497
                @(posedge int_ccf);
498
                read_data(result);
499
                check_result(result, golden, error_chk);
500
                error = error + error_chk;
501
 
502
                // BLOCK 3
503
                data_in = 128'h5ae4df3edbd5d35e5b4f09020db03eab;
504
                golden  = 128'h30c81c46a35ce411e5fbc1191a0a52ef;
505
                write_data(data_in);
506
                @(posedge int_ccf);
507
                read_data(result);
508
                check_result(result, golden, error_chk);
509
                error = error + error_chk;
510
 
511
                // BLOCK 4
512
                data_in = 128'h1e031dda2fbe03d1792170a0f3009cee;
513
                golden  = 128'hf69f2445df4f9b17ad2b417be66c3710;
514
                write_data(data_in);
515
                @(posedge int_ccf);
516
                read_data(result);
517
                check_result(result, golden, error_chk);
518
                error = error + error_chk;
519
                if(!error)
520
                        $display("CTR TEST PASSED!");
521
                else
522
                        $display("CTR TEST FAILED!\n Founded %d errors", error);
523
 
524
                error = 0;
525
                data_in = 128'h00112233445566778899aabbccddeeff;
526
                key_in  = 128'h000102030405060708090a0b0c0d0e0f;
527
                golden  = 128'h69c4e0d86a7b0430d8cdb78070b4c55a;
528
                write_key(key_in);
529
                apb_write(AES_CR, ENABLE | CCFIE);
530
                write_data(data_in);
531
                repeat(30)
532
                        @(posedge PCLK);
533
                apb_write(AES_CR, DISABLE);
534
                // KEY DERIVATION
535
                key_in  = 128'h2b7e151628aed2a6abf7158809cf4f3c;
536
                golden  = 128'hd014f9a8c9ee2589e13f0cc8b6630ca6;
537
                write_key(key_in);
538
                apb_write(AES_CR, KEY_DERIV | ENABLE | CCFIE);
539
                @(posedge int_ccf);
540
                @(posedge PCLK); // A LEITURA DA CHAVE DEVE SER INICIADA UM CLOCK AP\D2S A SUBIDA DE CCF
541
                read_key(result);
542
                check_result(result, golden, error_chk);
543
 
544
                // TEST SUSPEND FUNCTIONALITY
545
                key_in  = 128'h2b7e151628aed2a6abf7158809cf4f3c;
546
                iv_in   = 128'h000102030405060708090a0b0c0d0e0f;
547
 
548
                //BLOCK 1
549
                data_in = 128'h6bc1bee22e409f96e93d7e117393172a;
550
                golden  = 128'h7649abac8119b246cee98e9b12e9197d;
551
                write_key(key_in);
552
                write_iv(iv_in);
553
                apb_write(AES_CR, CBC | ENABLE | CCFIE);
554
                write_data(data_in);
555
                @(posedge int_ccf);
556
                read_data(result);
557
                check_result(result, golden, error_chk);
558
                error = error + error_chk;
559
 
560
                // BLOCK 2
561
                data_in = 128'hae2d8a571e03ac9c9eb76fac45af8e51;
562
                golden = 128'h5086cb9b507219ee95db113a917678b2;
563
                write_data(data_in);
564
                @(posedge int_ccf);
565
                read_data(result);
566
                check_result(result, golden, error_chk);
567
                error = error + error_chk;
568
 
569
                //suspend processing
570
                apb_write(AES_CR, DISABLE);
571
                result_rd = result;
572
                read_iv(iv_rd);
573
                read_key(key_rd);
574
 
575
                //begin new processing          
576
                key_in  = 128'h2b7e151628aed2a6abf7158809cf4f3c;
577
                golden  = 128'hd014f9a8c9ee2589e13f0cc8b6630ca6;
578
                write_key(key_in);
579
                apb_write(AES_CR, KEY_DERIV | ENABLE | CCFIE);
580
                @(posedge int_ccf);
581
                @(posedge PCLK); // A LEITURA DA CHAVE DEVE SER INICIADA UM CLOCK AP\D2S A SUBIDA DE CCF
582
                read_key(result);
583
                check_result(result, golden, error_chk);
584
                error = error + error_chk;
585
 
586
                //continues processing
587
                // BLOCK 3
588
                key_in  = 128'h2b7e151628aed2a6abf7158809cf4f3c;
589
                apb_write(AES_CR, DISABLE);
590
                write_key(key_in);
591
                write_iv(result_rd);
592
                data_in = 128'h30c81c46a35ce411e5fbc1191a0a52ef;
593
                golden = 128'h73bed6b8e3c1743b7116e69e22229516;
594
                apb_write(AES_CR, CBC | ENABLE | CCFIE);
595
                write_data(data_in);
596
                @(posedge int_ccf);
597
                read_data(result);
598
                check_result(result, golden, error_chk);
599
                error = error + error_chk;
600
 
601
                // BLOCK 4
602
                data_in = 128'hf69f2445df4f9b17ad2b417be66c3710;
603
                golden = 128'h3ff1caa1681fac09120eca307586e1a7;
604
                write_data(data_in);
605
                @(posedge int_ccf);
606
                read_data(result);
607
                check_result(result, golden, error_chk);
608
                error = error + error_chk;
609
                if(!error)
610
                        $display("SUSPEND MODE TEST PASSED!");
611
                else
612
                        $display("SUSPEND MODE TEST FAILED!\n Founded %d errors", error);
613
 
614
                //DMA TEST
615
                error = 0;
616
                apb_write(AES_CR, DISABLE);
617
                data_in = 128'h00112233445566778899aabbccddeeff;
618
                key_in  = 128'h000102030405060708090a0b0c0d0e0f;
619
                golden  = 128'h69c4e0d86a7b0430d8cdb78070b4c55a;
620
                write_key(key_in);
621
                apb_write(AES_CR, DMAINEN | DMAOUTEN | ENABLE | CCFIE);
622
                write_data_dma(data_in);
623
                @(posedge int_ccf);
624
                read_data_dma(result);
625
                check_result(result, golden, error_chk);
626
                error = error + error_chk;
627
                if(!error)
628
                        $display("DMA TEST PASSED!");
629
                else
630
                        $display("DMA TEST FAILED!\n Founded %d errors", error);
631
                $stop;
632
        end
633
 
634
always #10
635
        PCLK = !PCLK;
636
endmodule

powered by: WebSVN 2.1.0

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