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

Subversion Repositories apbtoaes128

[/] [apbtoaes128/] [trunk/] [pli/] [bfm_ctr/] [aes_bfm_encryption_ctr.h] - Blame information for rev 12

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_ctr_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 == CTR_ENCRYPTION && 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
                                        vpi_put_value(PADDR, &v_ecb, &t_ecb, vpiTransportDelay);
176
 
177
                                        if(FIPS_ENABLE == FIPS)
178
                                        {
179
 
180
                                                if(vector_address[counter_write] == ADDR_AES_KEYR3)
181
                                                {
182
                                                        a = a | KEY_FIPS_CTR_NOT_DERIVATED[0];
183
                                                        a = a << 8;
184
                                                        a = a | KEY_FIPS_CTR_NOT_DERIVATED[1];
185
                                                        a = a << 8;
186
                                                        a = a | KEY_FIPS_CTR_NOT_DERIVATED[2];
187
                                                        a = a << 8;
188
                                                        a = a | KEY_FIPS_CTR_NOT_DERIVATED[3];
189
                                                        v_ecb.value.integer = a;
190
                                                }
191
 
192
 
193
                                                if(vector_address[counter_write] == ADDR_AES_KEYR2)
194
                                                {
195
                                                        b = b | KEY_FIPS_CTR_NOT_DERIVATED[4];
196
                                                        b = b << 8;
197
                                                        b = b | KEY_FIPS_CTR_NOT_DERIVATED[5];
198
                                                        b = b << 8;
199
                                                        b = b | KEY_FIPS_CTR_NOT_DERIVATED[6];
200
                                                        b = b << 8;
201
                                                        b = b | KEY_FIPS_CTR_NOT_DERIVATED[7];
202
                                                        v_ecb.value.integer = b;
203
                                                }
204
 
205
                                                if(vector_address[counter_write] == ADDR_AES_KEYR1)
206
                                                {
207
 
208
                                                        c = c | KEY_FIPS_CTR_NOT_DERIVATED[8];
209
                                                        c = c << 8;
210
                                                        c = c | KEY_FIPS_CTR_NOT_DERIVATED[9];
211
                                                        c = c << 8;
212
                                                        c = c | KEY_FIPS_CTR_NOT_DERIVATED[10];
213
                                                        c = c << 8;
214
                                                        c = c | KEY_FIPS_CTR_NOT_DERIVATED[11];
215
                                                        v_ecb.value.integer = c;
216
 
217
                                                }
218
 
219
                                                if(vector_address[counter_write] == ADDR_AES_KEYR0)
220
                                                {
221
                                                        d = d | KEY_FIPS_CTR_NOT_DERIVATED[12];
222
                                                        d = d << 8;
223
                                                        d = d | KEY_FIPS_CTR_NOT_DERIVATED[13];
224
                                                        d = d << 8;
225
                                                        d = d | KEY_FIPS_CTR_NOT_DERIVATED[14];
226
                                                        d = d << 8;
227
                                                        d = d | KEY_FIPS_CTR_NOT_DERIVATED[15];
228
                                                        v_ecb.value.integer = d;
229
                                                }
230
 
231
 
232
                                                if(vector_address[counter_write] == ADDR_AES_IVR3)
233
                                                {
234
                                                        a = a | IV_FIPS_CTR_NOT_DERIVATED[0];
235
                                                        a = a << 8;
236
                                                        a = a | IV_FIPS_CTR_NOT_DERIVATED[1];
237
                                                        a = a << 8;
238
                                                        a = a | IV_FIPS_CTR_NOT_DERIVATED[2];
239
                                                        a = a << 8;
240
                                                        a = a | IV_FIPS_CTR_NOT_DERIVATED[3];
241
                                                        v_ecb.value.integer = a;
242
                                                }
243
 
244
 
245
                                                if(vector_address[counter_write] == ADDR_AES_IVR2)
246
                                                {
247
                                                        b = b | IV_FIPS_CTR_NOT_DERIVATED[4];
248
                                                        b = b << 8;
249
                                                        b = b | IV_FIPS_CTR_NOT_DERIVATED[5];
250
                                                        b = b << 8;
251
                                                        b = b | IV_FIPS_CTR_NOT_DERIVATED[6];
252
                                                        b = b << 8;
253
                                                        b = b | IV_FIPS_CTR_NOT_DERIVATED[7];
254
                                                        v_ecb.value.integer = b;
255
                                                }
256
 
257
                                                if(vector_address[counter_write] == ADDR_AES_IVR1)
258
                                                {
259
 
260
                                                        c = c | IV_FIPS_CTR_NOT_DERIVATED[8];
261
                                                        c = c << 8;
262
                                                        c = c | IV_FIPS_CTR_NOT_DERIVATED[9];
263
                                                        c = c << 8;
264
                                                        c = c | IV_FIPS_CTR_NOT_DERIVATED[10];
265
                                                        c = c << 8;
266
                                                        c = c | IV_FIPS_CTR_NOT_DERIVATED[11];
267
                                                        v_ecb.value.integer = c;
268
 
269
                                                }
270
 
271
                                                if(vector_address[counter_write] == ADDR_AES_IVR0)
272
                                                {
273
                                                        d = d | IV_FIPS_CTR_NOT_DERIVATED[12];
274
                                                        d = d << 8;
275
                                                        d = d | IV_FIPS_CTR_NOT_DERIVATED[13];
276
                                                        d = d << 8;
277
                                                        d = d | IV_FIPS_CTR_NOT_DERIVATED[14];
278
                                                        d = d << 8;
279
                                                        d = d | IV_FIPS_CTR_NOT_DERIVATED[15];
280
                                                        v_ecb.value.integer = d;
281
                                                }
282
 
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, &t_ecb, vpiTransportDelay);
292
 
293
 
294
                                        a = 0;
295
                                        b = 0;
296
                                        c = 0;
297
                                        d = 0;
298
 
299
 
300
 
301
                                }else if(counter_write == 9)//ENABLE CR
302
                                {
303
 
304 12 redbear
                                        if(DATATYPE == TYPE_00)// NO DINR DOUTR SWAP DATA
305
                                        {
306
                                                v_ecb.value.integer = ADDR_AES_CR;
307
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
308 5 redbear
 
309 12 redbear
                                                v_ecb.value.integer = 65;
310
                                                vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
311
 
312
                                        }else if(DATATYPE == TYPE_01)// 16 BIT DINR DOUTR SWAP DATA
313
                                        {
314
                                                v_ecb.value.integer = ADDR_AES_CR;
315
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
316
 
317
                                                v_ecb.value.integer = 67;
318
                                                vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
319
 
320
                                        }else if(DATATYPE == TYPE_02)// 8 BIT DINR DOUTR SWAP DATA
321
                                        {
322
                                                v_ecb.value.integer = ADDR_AES_CR;
323
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
324
 
325
                                                v_ecb.value.integer = 69;
326
                                                vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
327
 
328
                                        }else if(DATATYPE == TYPE_03)// BIT DINR DOUTR SWAP DATA
329
                                        {
330
                                                v_ecb.value.integer = ADDR_AES_CR;
331
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
332
 
333
                                                v_ecb.value.integer = 71;
334
                                                vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
335
                                        }
336 5 redbear
 
337
                                }else if(counter_write > 9  &&  counter_write < 14) //WRITE DINR
338
                                {
339
 
340
                                        v_ecb.value.integer = ADDR_AES_DINR;
341
                                        vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
342
 
343
 
344
                                        if(FIPS_ENABLE == FIPS)
345
                                        {
346
 
347 12 redbear
                                                if(DATATYPE == TYPE_00)
348 5 redbear
                                                {
349
 
350 12 redbear
                                                        if(counter_write == 10)
351
                                                        {
352
                                                                a = a | TEXT_FIPS_CTR_NOT_DERIVATED[0];
353
                                                                a = a << 8;
354
                                                                a = a | TEXT_FIPS_CTR_NOT_DERIVATED[1];
355
                                                                a = a << 8;
356
                                                                a = a | TEXT_FIPS_CTR_NOT_DERIVATED[2];
357
                                                                a = a << 8;
358
                                                                a = a | TEXT_FIPS_CTR_NOT_DERIVATED[3];
359
                                                                v_ecb.value.integer = a;
360 5 redbear
 
361 12 redbear
                                                        }else if(counter_write == 11)
362
                                                        {
363
                                                                b = b | TEXT_FIPS_CTR_NOT_DERIVATED[4];
364
                                                                b = b << 8;
365
                                                                b = b | TEXT_FIPS_CTR_NOT_DERIVATED[5];
366
                                                                b = b << 8;
367
                                                                b = b | TEXT_FIPS_CTR_NOT_DERIVATED[6];
368
                                                                b = b << 8;
369
                                                                b = b | TEXT_FIPS_CTR_NOT_DERIVATED[7];
370
                                                                v_ecb.value.integer = b;
371 5 redbear
 
372 12 redbear
                                                        }else if(counter_write == 12 )
373
                                                        {
374 5 redbear
 
375 12 redbear
                                                                c = c | TEXT_FIPS_CTR_NOT_DERIVATED[8];
376
                                                                c = c << 8;
377
                                                                c = c | TEXT_FIPS_CTR_NOT_DERIVATED[9];
378
                                                                c = c << 8;
379
                                                                c = c | TEXT_FIPS_CTR_NOT_DERIVATED[10];
380
                                                                c = c << 8;
381
                                                                c = c | TEXT_FIPS_CTR_NOT_DERIVATED[11];
382
                                                                v_ecb.value.integer = c;
383
 
384
                                                        }else if(counter_write == 13 )
385
                                                        {
386
                                                                d = d | TEXT_FIPS_CTR_NOT_DERIVATED[12];
387
                                                                d = d << 8;
388
                                                                d = d | TEXT_FIPS_CTR_NOT_DERIVATED[13];
389
                                                                d = d << 8;
390
                                                                d = d | TEXT_FIPS_CTR_NOT_DERIVATED[14];
391
                                                                d = d << 8;
392
                                                                d = d | TEXT_FIPS_CTR_NOT_DERIVATED[15];
393
                                                                v_ecb.value.integer = d;
394
 
395
                                                        }
396
 
397
                                                }else if(DATATYPE > TYPE_00)
398 5 redbear
                                                {
399
 
400 12 redbear
 
401
                                                        if(counter_write == 10)
402
                                                        {
403
                                                                a = a | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[0];
404
                                                                a = a << 8;
405
                                                                a = a | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[1];
406
                                                                a = a << 8;
407
                                                                a = a | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[2];
408
                                                                a = a << 8;
409
                                                                a = a | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[3];
410
                                                                v_ecb.value.integer = a;
411
 
412
                                                        }else if(counter_write == 11)
413
                                                        {
414
                                                                b = b | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[4];
415
                                                                b = b << 8;
416
                                                                b = b | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[5];
417
                                                                b = b << 8;
418
                                                                b = b | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[6];
419
                                                                b = b << 8;
420
                                                                b = b | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[7];
421
                                                                v_ecb.value.integer = b;
422
 
423
                                                        }else if(counter_write == 12 )
424
                                                        {
425
 
426
                                                                c = c | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[8];
427
                                                                c = c << 8;
428
                                                                c = c | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[9];
429
                                                                c = c << 8;
430
                                                                c = c | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[10];
431
                                                                c = c << 8;
432
                                                                c = c | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[11];
433
                                                                v_ecb.value.integer = c;
434
 
435
                                                        }else if(counter_write == 13 )
436
                                                        {
437
                                                                d = d | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[12];
438
                                                                d = d << 8;
439
                                                                d = d | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[13];
440
                                                                d = d << 8;
441
                                                                d = d | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[14];
442
                                                                d = d << 8;
443
                                                                d = d | TEXT_FIPS_CTR_NOT_DATATYPE_DERIVATED[15];
444
                                                                v_ecb.value.integer = d;
445
 
446
                                                        }
447
 
448 5 redbear
                                                }
449
 
450
 
451
                                        }else if(FIPS_ENABLE == RANDOM_DATA)
452
                                        {
453
                                                v_ecb.value.integer = data_in(rd);
454
                                        }
455
 
456
                                        vpi_put_value(PWDATA, &v_ecb, &t_ecb, vpiTransportDelay);
457
 
458
                                        a = 0;
459
                                        b = 0;
460
                                        c = 0;
461
                                        d = 0;
462
 
463
 
464
                                }
465
                                        counter=0;
466
 
467
                        }
468
 
469
 
470
 
471
                                if(counter_write == 14)
472
                                {
473
                                        counter_write = 0;
474
                                        STATE = WAIT_SR;
475
                                }
476
 
477
                  break;
478
 
479
                  case WAIT_SR:
480
 
481
                                v_ecb.value.integer = ADDR_AES_SR;
482
                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
483
 
484
                                v_ecb.value.integer = 0;
485
                                vpi_put_value(PWRITE, &v_ecb, NULL, vpiNoDelay);
486
 
487
                                if(counter == 0)
488
                                {
489
 
490
                                        counter++;
491
 
492
                                        v_ecb.value.integer = 1;
493
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
494
 
495
 
496 9 redbear
 
497
                                        v_ecb.value.integer = 0;
498
                                        vpi_get_value(PRDATA,&v_ecb);
499
 
500
                                        if(v_ecb.value.integer == 1)
501
                                        {
502
                                                STATE = READ_DOUTR;
503
 
504
                                                //t_ecb.type = vpiScaledRealTime;
505
                                                //t_ecb.real = 10;
506
                                                //v_ecb.format=vpiIntVal;
507
                                                //v_ecb.value.integer = ADDR_AES_DOUTR;
508
                                                //vpi_put_value(PADDR, &v_ecb, &t_ecb, vpiTransportDelay);
509
                                        }
510
 
511
 
512 5 redbear
                                }else if(counter == 1)
513
                                {
514
                                        v_ecb.value.integer = 0;
515
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
516
 
517
                                        counter=0;
518
                                }
519
 
520
 
521
 
522
                  break;
523
 
524
 
525
                 case READ_DOUTR:
526
 
527
 
528
 
529
                                if(counter == 0)
530
                                {
531
 
532
                                        v_ecb.value.integer = 1;
533
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
534
 
535
                                        counter_read++;
536
                                        counter++;
537
 
538
 
539
 
540
                                }else if(counter == 1)
541
                                {
542
                                        v_ecb.value.integer = 0;
543
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
544
 
545
 
546
                                        if(counter_read < 4)
547
                                        {
548
 
549
                                                v_ecb.value.integer = ADDR_AES_DOUTR;
550
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
551
 
552
                                        }
553
 
554
 
555
                                        if(counter_read == 4)
556
                                        {
557
 
558
                                                v_ecb.value.integer = ADDR_AES_KEYR3;
559
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
560
 
561
                                        }
562
 
563
 
564
                                        if(counter_read == 5)
565
                                        {
566
 
567
                                                v_ecb.value.integer = ADDR_AES_KEYR2;
568
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
569
 
570
                                        }
571
 
572
 
573
 
574
                                        if(counter_read == 6)
575
                                        {
576
 
577
                                                v_ecb.value.integer = ADDR_AES_KEYR1;
578
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
579
 
580
                                        }
581
 
582
 
583
                                        if(counter_read == 7)
584
                                        {
585
 
586
                                                v_ecb.value.integer = ADDR_AES_KEYR0;
587
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
588
 
589
                                        }
590
 
591
 
592
                                        if(counter_read == 8)
593
                                        {
594
 
595
                                                v_ecb.value.integer = ADDR_AES_IVR3;
596
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
597
 
598
                                        }
599
 
600
 
601
                                        if(counter_read == 9)
602
                                        {
603
 
604
                                                v_ecb.value.integer = ADDR_AES_IVR2;
605
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
606
 
607
                                        }
608
 
609
 
610
 
611
                                        if(counter_read == 10)
612
                                        {
613
 
614
                                                v_ecb.value.integer = ADDR_AES_IVR1;
615
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
616
 
617
                                        }
618
 
619
 
620
                                        if(counter_read == 11)
621
                                        {
622
 
623
                                                v_ecb.value.integer = ADDR_AES_IVR0;
624
                                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
625
 
626
                                        }
627
 
628
 
629
                                        counter = 0;
630
                                }
631
 
632
                                if(counter_read == 12)
633
                                {
634
                                        STATE = RESET_SR;
635
                                        counter_read = 0;
636
                                }
637
 
638
                 break;
639
 
640
                case RESET_SR:
641
 
642
                                v_ecb.value.integer = 1;
643
                                vpi_put_value(PWRITE, &v_ecb, NULL, vpiNoDelay);
644
 
645
                                v_ecb.value.integer = 1;
646
                                vpi_put_value(PSEL, &v_ecb, NULL, vpiNoDelay);
647
 
648
                                v_ecb.value.integer = 0;
649
                                vpi_put_value(PADDR, &v_ecb, NULL, vpiNoDelay);
650
 
651
                                v_ecb.value.integer = 128;
652
                                vpi_put_value(PWDATA, &v_ecb, NULL, vpiNoDelay);
653
 
654
 
655
                                if(counter == 0)
656
                                {
657
 
658
                                        counter_write++;
659
                                        counter++;
660
 
661
                                        v_ecb.value.integer = 1;
662
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
663
 
664
                                }else if(counter == 1)
665
                                {
666
 
667
                                        v_ecb.value.integer = 0;
668
                                        vpi_put_value(PENABLE, &v_ecb, NULL, vpiNoDelay);
669
                                        counter=0;
670
 
671
                                }
672
 
673
                                if(counter_write == 1)
674
                                {
675
                                        STATE =IDLE;
676
                                        counter_write = 0;
677
                                        counter=0;
678
 
679
                                        PACKETS_GENERATED = PACKETS_GENERATED + 1;
680
                                }
681
 
682
 
683
 
684
                break;
685
 
686
                }
687
 
688
        }
689
 
690
        return 0;
691
}

powered by: WebSVN 2.1.0

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