3 // used to inject things to the vvp runtime...
4 // renumbering possible
6 #include "e_ivl_compile.h"
8 intptr_t ARG_E::offset
= 0;
9 intptr_t ARG_V::offset
= 0;
10 intptr_t ARG_T::offset
= 0;
11 intptr_t ARG_S::offset
= 0;
12 intptr_t ARG_P::offset
= 0;
13 intptr_t ARG_O::offset
= 0;
15 intptr_t ARG_E::top
= 0;
16 intptr_t ARG_V::top
= 0;
17 intptr_t ARG_T::top
= 0;
18 intptr_t ARG_S::top
= 0;
19 intptr_t ARG_P::top
= 0;
20 intptr_t ARG_O::top
= 0;
22 /*-----------------------------------------------*/
23 ARG_C4::operator string() const{
25 assert( type
>0); //for now...
26 x
<< "C4<" << s
<< ">";
29 /*-----------------------------------------------*/
30 ARG_S::operator string() const{
32 x
<< "S_0x" << hex
<< i
;
35 /*-----------------------------------------------*/
36 COMPILE_WRAP::COMPILE_WRAP():COMPILE()
38 /* param_offset = 0;// offset used internally
44 /*-----------------------------------------------*/
45 void COMPILE_WRAP::flush(){
46 // hmmm... probably unneeded.
48 param_offset
+= param_top
;
50 signal_offset
+= signal_top
;
53 /*-----------------------------------------------*/
54 void COMPILE_WRAP::param_logic(ARG_BASE
* label
, char* name
, char*value
, bool signed_flag
,
55 long file_idx
, long lineno
){
56 char* buf
= strdup(string(*label
).c_str());
57 trace0("COMPILE_WRAP::param_logic " + string(*label
));
58 COMPILE::param_logic(buf
, name
, value
, signed_flag
,
61 /*-----------------------------------------------*/
63 void COMPILE_WRAP::variable(intptr_t label
, int app
, char*name
,
64 int msb
, int lsb
, int vpi_type_code
,
65 bool signed_flag
, bool local_flag
){
67 signal_top
= max(signal_top
,label
);
69 char* buf
= (char*)malloc(64*sizeof(char));
70 snprintf(buf
, 64*sizeof(char), "v0x%lx_%i", label
+signal_offset
, app
);
71 trace3("COMPILE_WRAP::variable "+string(buf
), label
, signal_offset
, app
);
73 COMPILE::variable(buf
, name
, msb
, lsb
, vpi_type_code
, signed_flag
, local_flag
);
75 void COMPILE_WRAP::variable(ARG_BASE
* label
, char*name
,
76 int msb
, int lsb
, int vpi_type_code
,
77 bool signed_flag
, bool local_flag
){
79 char* buf
= strdup(string(*label
).c_str());
81 COMPILE::variable(buf
, name
, msb
, lsb
, vpi_type_code
, signed_flag
, local_flag
);
83 /*-----------------------------------------------*/
84 void COMPILE_WRAP::net( ARG_BASE
* l
, char*name
, int msb
, int lsb
,
85 int vpi_type_code
, bool signed_flag
, bool local_flag
,
90 char* buf
= strdup(string(*l
).c_str());
92 COMPILE::net( buf
, name
, msb
, lsb
,
93 vpi_type_code
, signed_flag
, local_flag
,
94 argc
, arg_symbols(argc
,args
) );
96 /*-----------------------------------------------*/
97 void COMPILE_WRAP::net( intptr_t label
, int app
, char*name
, int msb
, int lsb
,
98 int vpi_type_code
, bool signed_flag
, bool local_flag
,
100 trace1("COMPILE_WRAP::net old "+ string(name
), argc
);
102 assert(false); // old version.
105 va_start(args
, argc
);
107 char* buf
= (char*)malloc(64*sizeof(char));
108 snprintf(buf
, 64*sizeof(char), "v0x%lx_%i", label
+signal_offset
, app
);
110 COMPILE::net( buf
, name
, msb
, lsb
,
111 vpi_type_code
, signed_flag
, local_flag
,
112 argc
, arg_symbols(argc
,args
) );
114 /*-----------------------------------------------*/
115 void COMPILE_WRAP::codelabel( ARG_BASE
* label
) {
116 char* buf
= strdup(string(*label
).c_str());
117 COMPILE::codelabel(buf
);
119 /*-----------------------------------------------*/
120 // taken from compile.c
121 // FIXME: propagate *double instead of double ( not needed for now. )
122 void COMPILE_WRAP::param_real( ARG_BASE
* l
, char*name
, const double*dvp
,
123 long file_idx
, long lineno
)
125 char* label
= strdup(string(*l
).c_str());
126 // double dvalue = crstring_to_double(value);
127 vpiHandle obj
= vpip_make_real_param(name
, *dvp
, file_idx
, lineno
);
129 vpi_symbol(label
, obj
);
130 vpip_attach_to_current_scope(obj
);
136 symb_s
* arg_symbols( unsigned argc
, va_list argv
){
137 trace0("arg_symbols_va");
142 for(unsigned i
=0; i
<argc
; i
++){
144 ARG_BASE
* w
= va_arg ( argv
, ARG_BASE
* );
147 string sw
= string(*w
);
148 assert(string(*w
).c_str());
149 char* ww
= strdup(string(*w
).c_str());
150 trace0("wrapping" + string(*w
));
157 trace0("wrapped " + string(obj
.vect
[0].text
));
162 void compile_vpi_call(COMPILE
* c
, const char* label
, const char* cmd
, bool b0
, bool b1
, long l0
, long l1
, ... ){
163 unsigned i
=0; char* w
;
166 va_start ( arguments
, l1
);
169 w
= va_arg ( arguments
, char* );
177 cerr
<< "argument" << w
<< "\n";
187 w
= va_arg ( arguments
, char* );
190 // argv_sym_lookup(c, &$2);
193 c
->vpi_call(label
?sd(label
):0, sd(cmd
), b0
, b1
, l0
, l1
, i
, (vpiHandle
*)&argv
);
196 /*---------------------------------------------------------*/
197 void COMPILE_WRAP::notify( const ARG_BASE
*,
198 uint32_t delay_index
,
199 uint32_t bit
, COMPONENT
* daport
){
202 notify( delay_index
, bit
, daport
);
204 /*---------------------------------------------------------*/
205 void COMPILE_WRAP::notify_i( const ARG_BASE
*,
207 uint32_t bit
, COMPONENT
* daport
){
209 notify_i( delay
, bit
, daport
);