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

Subversion Repositories apbtoaes128

[/] [apbtoaes128/] [trunk/] [pli/] [aes_bfm_reset.h] - Blame information for rev 9

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

Line No. Rev Author Line
1 4 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_reset_calltf(char*user_data)
76
{
77
 
78
        vpiHandle PRESETn = vpi_handle_by_name("AES_GLADIC_tb.PRESETn", NULL);
79
 
80
        std::random_device rd_counter;
81
        std::uniform_int_distribution<int> counter(1,50);
82
 
83
        std::mt19937 rd;
84
        std::uniform_real_distribution<> time(0,50);
85
 
86
 
87
        v_reset.format=vpiIntVal;
88
 
89
        //printf("STATE_RESET : %i\n",STATE_RESET);
90
        //printf("MAX_RESET_TIMES : %i\n",MAX_RESET_TIMES);
91
        //printf("RESET_GENERATED : %i\n",RESET_GENERATED);
92
 
93
                switch(STATE_RESET)
94
                {
95
 
96
                        case IDLE:
97
 
98
                                if(RESET_GENERATED > MAX_RESET_TIMES)
99
                                {
100
                                                STATE_RESET = IDLE;
101
                                }else
102
                                {
103
 
104
                                                STATE_RESET = ENTER_RESET;
105
 
106
                                                v_reset.value.integer = 0;
107
                                                t_reset.type = vpiScaledRealTime;
108
                                                t_reset.real = time(rd);
109
                                                v_wr.format=vpiIntVal;
110
                                                v_reset.value.integer = 0;
111
                                                vpi_put_value(PRESETn, &v_reset, &t_reset, vpiTransportDelay);
112
 
113
                                                counter_reset_wait = counter(rd_counter);
114
 
115
                                }
116
 
117
                                                counter_reset_enter=0;
118
                                                counter_reset_wait=0;
119
 
120
 
121
                        break;
122
 
123
                        case ENTER_RESET:
124
 
125
                                if(counter_reset_enter >= counter_reset_wait)
126
                                {
127
                                        v_reset.value.integer = 0;
128
                                        t_reset.type = vpiScaledRealTime;
129
                                        t_reset.real = time(rd);
130
                                        v_wr.format=vpiIntVal;
131
                                        v_reset.value.integer = 1;
132
                                        vpi_put_value(PRESETn,&v_reset, &t_reset, vpiTransportDelay);
133
 
134
                                        STATE_RESET = GET_OUT_RESET;
135
                                }
136
 
137
                                counter_reset_enter++;
138
 
139
                        break;
140
 
141
                        case GET_OUT_RESET:
142
 
143
                                counter_reset_wait=0;
144
                                counter_reset_enter=0;
145
 
146
                                STATE_RESET = WAIT_RESET;
147
 
148
                                counter_reset_wait = counter(rd_counter);
149
 
150
                        break;
151
 
152
                        case WAIT_RESET:
153
 
154
                                if(counter_reset_enter >= counter_reset_wait)
155
                                {
156
                                        STATE_RESET = IDLE;
157
                                        counter_reset_wait=0;
158
                                        counter_reset_enter=0;
159
                                        RESET_GENERATED++;
160
 
161
                                }
162
                                counter_reset_enter++;
163
 
164
 
165
                        break;
166
 
167
                }
168
 
169
        return 0;
170
}
171
 

powered by: WebSVN 2.1.0

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