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

Subversion Repositories apbtoaes128

[/] [apbtoaes128/] [trunk/] [pli/] [bfm_cbc/] [aes_bfm_encryption_dma_cbc.h] - Blame information for rev 16

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

Line No. Rev Author Line
1 5 redbear
//////////////////////////////////////////////////////////////////
2
////
3
////
4
////    AES CORE BLOCK
5
////
6
////
7
////
8
//// This file is part of the APB to AES128 project
9
////
10
//// http://www.opencores.org/cores/apbtoaes128/
11
////
12
////
13
////
14
//// Description
15
////
16
//// Implementation of APB IP core according to
17
////
18
//// aes128_spec IP core specification document.
19
////
20
////
21
////
22
//// To Do: Things are right here but always all block can suffer changes
23
////
24
////
25
////
26
////
27
////
28
//// Author(s): - Felipe Fernandes Da Costa, fefe2560@gmail.com
29
////
30
///////////////////////////////////////////////////////////////// 
31
////
32
////
33
//// Copyright (C) 2009 Authors and OPENCORES.ORG
34
////
35
////
36
////
37
//// This source file may be used and distributed without
38
////
39
//// restriction provided that this copyright statement is not
40
////
41
//// removed from the file and that any derivative work contains
42
//// the original copyright notice and the associated disclaimer.
43
////
44
////
45
//// This source file is free software; you can redistribute it
46
////
47
//// and/or modify it under the terms of the GNU Lesser General
48
////
49
//// Public License as published by the Free Software Foundation;
50
//// either version 2.1 of the License, or (at your option) any
51
////
52
//// later version.
53
////
54
////
55
////
56
//// This source is distributed in the hope that it will be
57
////
58
//// useful, but WITHOUT ANY WARRANTY; without even the implied
59
////
60
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
61
////
62
//// PURPOSE. See the GNU Lesser General Public License for more
63
//// details.
64
////
65
////
66
////
67
//// You should have received a copy of the GNU Lesser General
68
////
69
//// Public License along with this source; if not, download it
70
////
71
//// from http://www.opencores.org/lgpl.shtml
72
////
73
////
74
///////////////////////////////////////////////////////////////////
75
static int aes_bfm_encryption_cbc_dma_calltf(char*user_data)
76
{
77
 
78
        vpiHandle PRESETn = vpi_handle_by_name("AES_GLADIC_tb.PRESETn", NULL);
79
        vpiHandle PWDATA = vpi_handle_by_name("AES_GLADIC_tb.PWDATA", NULL);
80
        vpiHandle PENABLE = vpi_handle_by_name("AES_GLADIC_tb.PENABLE", NULL);
81
        vpiHandle PSEL = vpi_handle_by_name("AES_GLADIC_tb.PSEL", NULL);
82
        vpiHandle PWRITE = vpi_handle_by_name("AES_GLADIC_tb.PWRITE", NULL);
83
        vpiHandle PADDR = vpi_handle_by_name("AES_GLADIC_tb.PADDR", NULL);
84
        vpiHandle PRDATA = vpi_handle_by_name("AES_GLADIC_tb.PRDATA", NULL);
85
        vpiHandle PREADY = vpi_handle_by_name("AES_GLADIC_tb.PREADY", NULL);
86
        vpiHandle PSLVERR = vpi_handle_by_name("AES_GLADIC_tb.PSLVERR", NULL);
87
        vpiHandle int_ccf = vpi_handle_by_name("AES_GLADIC_tb.int_ccf", NULL);
88
        vpiHandle int_err = vpi_handle_by_name("AES_GLADIC_tb.int_err", NULL);
89
        vpiHandle dma_req_wr = vpi_handle_by_name("AES_GLADIC_tb.dma_req_wr", NULL);
90
        vpiHandle dma_req_rd = vpi_handle_by_name("AES_GLADIC_tb.dma_req_rd", NULL);
91
 
92
        std::random_device rd;
93
        std::uniform_int_distribution<long int> data_in(0,4294967295);
94
 
95
        v_ecb.format=vpiIntVal;
96
 
97
        vpi_get_value(PRESETn, &v_ecb);
98
 
99
 
100
        //printf("%i\n",STATE);
101
 
102
 
103
        if(type_bfm == CBC_ENCRYPTION_DMA && v_ecb.value.integer == 1)
104
        {
105
 
106
                switch(STATE)
107
                {
108
 
109
                  case IDLE:
110
 
111
                                if(PACKETS_GENERATED >= MAX_ITERATIONS)
112
                                {
113
 
114
                                        STATE = IDLE;
115
                                        type_bfm = 0;
116
 
117
                                }else
118
                                {
119
                                        STATE = WRITE;
120
 
121
                                        counter = 0;
122
 
123
 
124
                                        v_ecb.value.integer = 0;
125
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
126
 
127
                                        v_ecb.value.integer = vector_address[0];
128
                                        vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
129
 
130
                                        v_ecb.value.integer = 0;
131
                                        vpi_put_value(PWDATA, &v_ecb, NULL, vpiNoDelay);
132
 
133
                                        v_ecb.value.integer = 1;
134
                                        vpi_put_value(PWRITE, &v_ecb, NULL, vpiNoDelay);
135
 
136
                                        v_ecb.value.integer = 1;
137
                                        vpi_put_value(PSEL, &v_ecb, NULL, vpiNoDelay);
138
                                }
139
 
140
                  break;
141
 
142
                  case WRITE:
143
 
144
 
145
 
146
                        v_ecb.value.integer = 1;
147
                        vpi_put_value(PSEL, &v_ecb, NULL, vpiNoDelay);
148
 
149
                        if(counter == 0)
150
                        {
151
                                counter_write++;
152
                                counter++;
153
 
154
                                v_ecb.value.integer = 1;
155
                                vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
156
 
157
 
158
                        }else if(counter == 1)
159
                        {
160
 
161
 
162
 
163
                                t_ecb.type = vpiScaledRealTime;
164
                                t_ecb.real = 0;
165
                                v_ecb.format=vpiIntVal;
166
 
167
                                v_ecb.value.integer = 0;
168
                                vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
169
 
170
 
171
                                if(counter_write < 9)
172
                                {
173
 
174
                                        v_ecb.value.integer = vector_address[counter_write];
175
 
176
                                        vpi_put_value(PADDR, &v_ecb, &t_ecb, vpiTransportDelay);
177
                                        //vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
178
 
179
                                        if(FIPS_ENABLE == FIPS)
180
                                        {
181
 
182
                                                if(vector_address[counter_write] == ADDR_AES_KEYR3)
183
                                                {
184
                                                        a = a | KEY_FIPS_CBC_NOT_DERIVATED[0];
185
                                                        a = a << 8;
186
                                                        a = a | KEY_FIPS_CBC_NOT_DERIVATED[1];
187
                                                        a = a << 8;
188
                                                        a = a | KEY_FIPS_CBC_NOT_DERIVATED[2];
189
                                                        a = a << 8;
190
                                                        a = a | KEY_FIPS_CBC_NOT_DERIVATED[3];
191
                                                        v_ecb.value.integer = a;
192
                                                }
193
 
194
 
195
                                                if(vector_address[counter_write] == ADDR_AES_KEYR2)
196
                                                {
197
                                                        b = b | KEY_FIPS_CBC_NOT_DERIVATED[4];
198
                                                        b = b << 8;
199
                                                        b = b | KEY_FIPS_CBC_NOT_DERIVATED[5];
200
                                                        b = b << 8;
201
                                                        b = b | KEY_FIPS_CBC_NOT_DERIVATED[6];
202
                                                        b = b << 8;
203
                                                        b = b | KEY_FIPS_CBC_NOT_DERIVATED[7];
204
                                                        v_ecb.value.integer = b;
205
                                                }
206
 
207
                                                if(vector_address[counter_write] == ADDR_AES_KEYR1)
208
                                                {
209
 
210
                                                        c = c | KEY_FIPS_CBC_NOT_DERIVATED[8];
211
                                                        c = c << 8;
212
                                                        c = c | KEY_FIPS_CBC_NOT_DERIVATED[9];
213
                                                        c = c << 8;
214
                                                        c = c | KEY_FIPS_CBC_NOT_DERIVATED[10];
215
                                                        c = c << 8;
216
                                                        c = c | KEY_FIPS_CBC_NOT_DERIVATED[11];
217
                                                        v_ecb.value.integer = c;
218
 
219
                                                }
220
 
221
                                                if(vector_address[counter_write] == ADDR_AES_KEYR0)
222
                                                {
223
                                                        d = d | KEY_FIPS_CBC_NOT_DERIVATED[12];
224
                                                        d = d << 8;
225
                                                        d = d | KEY_FIPS_CBC_NOT_DERIVATED[13];
226
                                                        d = d << 8;
227
                                                        d = d | KEY_FIPS_CBC_NOT_DERIVATED[14];
228
                                                        d = d << 8;
229
                                                        d = d | KEY_FIPS_CBC_NOT_DERIVATED[15];
230
                                                        v_ecb.value.integer = d;
231
                                                }
232
 
233
 
234
                                                if(vector_address[counter_write] == ADDR_AES_IVR3)
235
                                                {
236
                                                        a = a | IV_FIPS_CBC_NOT_DERIVATED[0];
237
                                                        a = a << 8;
238
                                                        a = a | IV_FIPS_CBC_NOT_DERIVATED[1];
239
                                                        a = a << 8;
240
                                                        a = a | IV_FIPS_CBC_NOT_DERIVATED[2];
241
                                                        a = a << 8;
242
                                                        a = a | IV_FIPS_CBC_NOT_DERIVATED[3];
243
                                                        v_ecb.value.integer = a;
244
                                                }
245
 
246
 
247
                                                if(vector_address[counter_write] == ADDR_AES_IVR2)
248
                                                {
249
                                                        b = b | IV_FIPS_CBC_NOT_DERIVATED[4];
250
                                                        b = b << 8;
251
                                                        b = b | IV_FIPS_CBC_NOT_DERIVATED[5];
252
                                                        b = b << 8;
253
                                                        b = b | IV_FIPS_CBC_NOT_DERIVATED[6];
254
                                                        b = b << 8;
255
                                                        b = b | IV_FIPS_CBC_NOT_DERIVATED[7];
256
                                                        v_ecb.value.integer = b;
257
                                                }
258
 
259
                                                if(vector_address[counter_write] == ADDR_AES_IVR1)
260
                                                {
261
 
262
                                                        c = c | IV_FIPS_CBC_NOT_DERIVATED[8];
263
                                                        c = c << 8;
264
                                                        c = c | IV_FIPS_CBC_NOT_DERIVATED[9];
265
                                                        c = c << 8;
266
                                                        c = c | IV_FIPS_CBC_NOT_DERIVATED[10];
267
                                                        c = c << 8;
268
                                                        c = c | IV_FIPS_CBC_NOT_DERIVATED[11];
269
                                                        v_ecb.value.integer = c;
270
 
271
                                                }
272
 
273
                                                if(vector_address[counter_write] == ADDR_AES_IVR0)
274
                                                {
275
                                                        d = d | IV_FIPS_CBC_NOT_DERIVATED[12];
276
                                                        d = d << 8;
277
                                                        d = d | IV_FIPS_CBC_NOT_DERIVATED[13];
278
                                                        d = d << 8;
279
                                                        d = d | IV_FIPS_CBC_NOT_DERIVATED[14];
280
                                                        d = d << 8;
281
                                                        d = d | IV_FIPS_CBC_NOT_DERIVATED[15];
282
                                                        v_ecb.value.integer = d;
283
                                                }
284
 
285
 
286
                                        }else if(FIPS_ENABLE == RANDOM_DATA)
287
                                        {
288
                                                v_ecb.value.integer = data_in(rd);
289
                                        }
290
 
291
                                        //vpi_put_value(PWDATA, &v_ecb, NULL, vpiNoDelay);                                              
292
                                        vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
293
 
294
 
295
                                        a = 0;
296
                                        b = 0;
297
                                        c = 0;
298
                                        d = 0;
299
 
300
 
301
 
302
                                }else if(counter_write == 9)//ENABLE CR
303
                                {
304
 
305 12 redbear
                                        if(DATATYPE == TYPE_00)// NO DINR DOUTR SWAP DATA
306
                                        {
307
                                                v_ecb.value.integer = ADDR_AES_CR;
308
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
309 5 redbear
 
310 12 redbear
                                                v_ecb.value.integer = 6177;
311
                                                vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
312 5 redbear
 
313 12 redbear
                                        }else if(DATATYPE == TYPE_01)// 16 BIT DINR DOUTR SWAP DATA
314
                                        {
315
                                                v_ecb.value.integer = ADDR_AES_CR;
316
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
317
 
318
                                                v_ecb.value.integer = 6179;
319
                                                vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
320
 
321
                                        }else if(DATATYPE == TYPE_02)// 8 BIT DINR DOUTR SWAP DATA
322
                                        {
323
                                                v_ecb.value.integer = ADDR_AES_CR;
324
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
325
 
326
                                                v_ecb.value.integer = 6181;
327
                                                vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
328
 
329
                                        }else if(DATATYPE == TYPE_03)// BIT DINR DOUTR SWAP DATA
330
                                        {
331
                                                v_ecb.value.integer = ADDR_AES_CR;
332
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
333
 
334
                                                v_ecb.value.integer = 6183;
335
                                                vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
336
                                        }
337 5 redbear
 
338
                                }else if(counter_write > 9  &&  counter_write < 14) //WRITE DINR
339
                                {
340
 
341
                                        v_ecb.value.integer = ADDR_AES_DINR;
342
                                        vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
343
 
344
 
345
                                        if(FIPS_ENABLE == FIPS)
346
                                        {
347
 
348 12 redbear
                                                if(DATATYPE == TYPE_00)
349 5 redbear
                                                {
350
 
351 12 redbear
                                                        if(counter_write == 10)
352
                                                        {
353
                                                                a = a | TEXT_FIPS_CBC_NOT_DERIVATED[0];
354
                                                                a = a << 8;
355
                                                                a = a | TEXT_FIPS_CBC_NOT_DERIVATED[1];
356
                                                                a = a << 8;
357
                                                                a = a | TEXT_FIPS_CBC_NOT_DERIVATED[2];
358
                                                                a = a << 8;
359
                                                                a = a | TEXT_FIPS_CBC_NOT_DERIVATED[3];
360
                                                                v_ecb.value.integer = a;
361 5 redbear
 
362 12 redbear
                                                        }else if(counter_write == 11)
363
                                                        {
364
                                                                b = b | TEXT_FIPS_CBC_NOT_DERIVATED[4];
365
                                                                b = b << 8;
366
                                                                b = b | TEXT_FIPS_CBC_NOT_DERIVATED[5];
367
                                                                b = b << 8;
368
                                                                b = b | TEXT_FIPS_CBC_NOT_DERIVATED[6];
369
                                                                b = b << 8;
370
                                                                b = b | TEXT_FIPS_CBC_NOT_DERIVATED[7];
371
                                                                v_ecb.value.integer = b;
372 5 redbear
 
373 12 redbear
                                                        }else if(counter_write == 12 )
374
                                                        {
375 5 redbear
 
376 12 redbear
                                                                c = c | TEXT_FIPS_CBC_NOT_DERIVATED[8];
377
                                                                c = c << 8;
378
                                                                c = c | TEXT_FIPS_CBC_NOT_DERIVATED[9];
379
                                                                c = c << 8;
380
                                                                c = c | TEXT_FIPS_CBC_NOT_DERIVATED[10];
381
                                                                c = c << 8;
382
                                                                c = c | TEXT_FIPS_CBC_NOT_DERIVATED[11];
383
                                                                v_ecb.value.integer = c;
384
 
385
                                                        }else if(counter_write == 13 )
386
                                                        {
387
                                                                d = d | TEXT_FIPS_CBC_NOT_DERIVATED[12];
388
                                                                d = d << 8;
389
                                                                d = d | TEXT_FIPS_CBC_NOT_DERIVATED[13];
390
                                                                d = d << 8;
391
                                                                d = d | TEXT_FIPS_CBC_NOT_DERIVATED[14];
392
                                                                d = d << 8;
393
                                                                d = d | TEXT_FIPS_CBC_NOT_DERIVATED[15];
394
                                                                v_ecb.value.integer = d;
395
 
396
                                                        }
397
 
398
                                                }else if(DATATYPE > TYPE_00)
399 5 redbear
                                                {
400
 
401 12 redbear
 
402
                                                        if(counter_write == 10)
403
                                                        {
404
                                                                a = a | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[0];
405
                                                                a = a << 8;
406
                                                                a = a | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[1];
407
                                                                a = a << 8;
408
                                                                a = a | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[2];
409
                                                                a = a << 8;
410
                                                                a = a | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[3];
411
                                                                v_ecb.value.integer = a;
412
 
413
                                                        }else if(counter_write == 11)
414
                                                        {
415
                                                                b = b | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[4];
416
                                                                b = b << 8;
417
                                                                b = b | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[5];
418
                                                                b = b << 8;
419
                                                                b = b | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[6];
420
                                                                b = b << 8;
421
                                                                b = b | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[7];
422
                                                                v_ecb.value.integer = b;
423
 
424
                                                        }else if(counter_write == 12 )
425
                                                        {
426
 
427
                                                                c = c | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[8];
428
                                                                c = c << 8;
429
                                                                c = c | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[9];
430
                                                                c = c << 8;
431
                                                                c = c | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[10];
432
                                                                c = c << 8;
433
                                                                c = c | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[11];
434
                                                                v_ecb.value.integer = c;
435
 
436
                                                        }else if(counter_write == 13 )
437
                                                        {
438
                                                                d = d | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[12];
439
                                                                d = d << 8;
440
                                                                d = d | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[13];
441
                                                                d = d << 8;
442
                                                                d = d | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[14];
443
                                                                d = d << 8;
444
                                                                d = d | TEXT_FIPS_CBC_NOT_DATATYPE_DERIVATED[15];
445
                                                                v_ecb.value.integer = d;
446
 
447
                                                        }
448
 
449 5 redbear
                                                }
450
 
451
 
452
                                        }else if(FIPS_ENABLE == RANDOM_DATA)
453
                                        {
454
                                                v_ecb.value.integer = data_in(rd);
455
                                        }
456
 
457
                                        //vpi_put_value(PWDATA, &v_ecb, NULL, vpiNoDelay);
458
                                        vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
459
 
460
                                        a = 0;
461
                                        b = 0;
462
                                        c = 0;
463
                                        d = 0;
464
 
465
 
466
                                }
467
                                        counter=0;
468
 
469
                        }
470
 
471
 
472
 
473
                                if(counter_write == 14)
474
                                {
475
                                        counter_write = 0;
476
                                        STATE = WAIT_SR;
477
                                }
478
 
479
                  break;
480
 
481
                  case WAIT_SR:
482
 
483
                                v_ecb.value.integer = ADDR_AES_SR;
484
                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
485
 
486
                                v_ecb.value.integer = 0;
487
                                vpi_put_value(PWRITE, &v_ecb, NULL, vpiNoDelay);
488
                                //vpi_put_value(PWDATA, &v_ecb, NULL, vpiNoDelay);
489
 
490
 
491
                                if(counter == 0)
492
                                {
493
 
494
                                        counter++;
495
 
496
                                        v_ecb.value.integer = 1;
497
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
498
 
499
 
500 9 redbear
 
501
                                        v_ecb.value.integer = 0;
502
                                        vpi_get_value(PRDATA,&v_ecb);
503
 
504
                                        if(v_ecb.value.integer == 1)
505
                                        {
506
                                                STATE = READ_DOUTR;
507
 
508
                                                //t_ecb.type = vpiScaledRealTime;
509
                                                //t_ecb.real = 10;
510
                                                //v_ecb.format=vpiIntVal;
511
                                                //v_ecb.value.integer = ADDR_AES_DOUTR;
512
                                                //vpi_put_value(PADDR, &v_ecb, &t_ecb, vpiTransportDelay);
513
                                        }
514
 
515
 
516 5 redbear
                                }else if(counter == 1)
517
                                {
518
                                        v_ecb.value.integer = 0;
519
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
520
 
521
                                        counter=0;
522
                                }
523
 
524
 
525
 
526
                  break;
527
 
528
 
529
                 case READ_DOUTR:
530
 
531
 
532
 
533
                                if(counter == 0)
534
                                {
535
 
536
                                        v_ecb.value.integer = 1;
537
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
538
 
539
                                        counter_read++;
540
                                        counter++;
541
 
542
 
543
 
544
                                }else if(counter == 1)
545
                                {
546
                                        v_ecb.value.integer = 0;
547
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
548
 
549
 
550
                                        if(counter_read < 4)
551
                                        {
552
 
553
                                                v_ecb.value.integer = ADDR_AES_DOUTR;
554
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
555
 
556
                                        }
557
 
558
 
559
                                        if(counter_read == 4)
560
                                        {
561
 
562
                                                v_ecb.value.integer = ADDR_AES_KEYR3;
563
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
564
 
565
                                        }
566
 
567
 
568
                                        if(counter_read == 5)
569
                                        {
570
 
571
                                                v_ecb.value.integer = ADDR_AES_KEYR2;
572
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
573
 
574
                                        }
575
 
576
 
577
 
578
                                        if(counter_read == 6)
579
                                        {
580
 
581
                                                v_ecb.value.integer = ADDR_AES_KEYR1;
582
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
583
 
584
                                        }
585
 
586
 
587
                                        if(counter_read == 7)
588
                                        {
589
 
590
                                                v_ecb.value.integer = ADDR_AES_KEYR0;
591
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
592
 
593
                                        }
594
 
595
 
596
                                        if(counter_read == 8)
597
                                        {
598
 
599
                                                v_ecb.value.integer = ADDR_AES_IVR3;
600
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
601
 
602
                                        }
603
 
604
 
605
                                        if(counter_read == 9)
606
                                        {
607
 
608
                                                v_ecb.value.integer = ADDR_AES_IVR2;
609
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
610
 
611
                                        }
612
 
613
 
614
 
615
                                        if(counter_read == 10)
616
                                        {
617
 
618
                                                v_ecb.value.integer = ADDR_AES_IVR1;
619
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
620
 
621
                                        }
622
 
623
 
624
                                        if(counter_read == 11)
625
                                        {
626
 
627
                                                v_ecb.value.integer = ADDR_AES_IVR0;
628
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
629
 
630
                                        }
631
 
632
 
633
                                        counter = 0;
634
                                }
635
 
636
                                if(counter_read == 12)
637
                                {
638
                                        STATE = RESET_SR;
639
                                        counter_read = 0;
640
                                }
641
                 break;
642
 
643
                case RESET_SR:
644
 
645
                                v_ecb.value.integer = 1;
646
                                vpi_put_value(PWRITE, &v_ecb, NULL, vpiNoDelay);
647
 
648
                                v_ecb.value.integer = 1;
649
                                vpi_put_value(PSEL, &v_ecb, NULL, vpiNoDelay);
650
 
651
                                v_ecb.value.integer = 0;
652
                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
653
 
654
                                v_ecb.value.integer = 128;
655
                                vpi_put_value(PWDATA, &v_ecb, NULL, vpiNoDelay);
656
 
657
 
658
                                if(counter == 0)
659
                                {
660
 
661
                                        counter_write++;
662
                                        counter++;
663
 
664
                                        v_ecb.value.integer = 1;
665
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
666
 
667
                                }else if(counter == 1)
668
                                {
669
 
670
                                        v_ecb.value.integer = 0;
671
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
672
                                        counter=0;
673
 
674
                                }
675
 
676
                                if(counter_write == 1)
677
                                {
678
                                        STATE =IDLE;
679
                                        counter_write = 0;
680
                                        counter=0;
681
 
682
                                        PACKETS_GENERATED = PACKETS_GENERATED + 1;
683
                                }
684
 
685
 
686
 
687
                break;
688
 
689
                }
690
 
691
        }
692
 
693
        return 0;
694
}

powered by: WebSVN 2.1.0

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