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

Subversion Repositories apbtoaes128

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

powered by: WebSVN 2.1.0

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