[18] | 1 | /* |
---|
| 2 | |
---|
| 3 | Copyright (c) 1992, 1993 |
---|
| 4 | Regents of the University of California |
---|
| 5 | All rights reserved. |
---|
| 6 | |
---|
| 7 | Use and copying of this software and preparation of derivative works |
---|
| 8 | based upon this software are permitted. However, any distribution of |
---|
| 9 | this software or derivative works must include the above copyright |
---|
| 10 | notice. |
---|
| 11 | |
---|
| 12 | This software is made available AS IS, and neither the Electronics |
---|
| 13 | Research Laboratory or the Universify of California make any |
---|
| 14 | warranty about the software, its performance or its conformity to |
---|
| 15 | any specification. |
---|
| 16 | |
---|
| 17 | Author: Szu-Tsung Cheng, stcheng@ic.Berkeley.EDU |
---|
| 18 | 10/92 |
---|
| 19 | 10/93 |
---|
| 20 | |
---|
| 21 | $Header: /projects/development/hsv/CVSRepository/vl2mv/src/parser/vl_create.c,v 1.3 2009/03/09 20:25:57 fabio Exp $ |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | #include "util.h" |
---|
| 28 | #include "list.h" |
---|
| 29 | #include "st.h" |
---|
| 30 | #include "set.h" |
---|
| 31 | #include "array.h" |
---|
| 32 | #include "vl_types.h" |
---|
| 33 | #include "vl_defs.h" |
---|
| 34 | #include "vlr_int.h" |
---|
| 35 | #include "vl_create.h" |
---|
| 36 | #include "vl_write.h" |
---|
| 37 | #include "vl_write_util.h" |
---|
| 38 | #include "verilog.h" |
---|
| 39 | |
---|
| 40 | extern int yylineno; |
---|
| 41 | extern int task_mode; |
---|
| 42 | extern int aliasSP; |
---|
| 43 | extern st_table *aliasStack[]; |
---|
| 44 | extern int use_libraryGate; |
---|
| 45 | |
---|
| 46 | vl_descPtr mod_list; |
---|
| 47 | static int CreTrace = 0; |
---|
| 48 | |
---|
| 49 | static int bstr_to_i ARGS((char *str)); |
---|
| 50 | |
---|
| 51 | vl_desc *vl_create_desc(char *filename) |
---|
| 52 | { |
---|
| 53 | vl_descPtr desc; |
---|
| 54 | |
---|
| 55 | CreTRACE("Creating Description\n"); |
---|
| 56 | desc = (vl_descPtr)chk_malloc(sizeof(vl_desc)); |
---|
| 57 | desc->filename = filename; |
---|
| 58 | desc->type_st = st_init_table(strcmp, st_strhash); |
---|
| 59 | desc->modules = lsCreate(); |
---|
| 60 | desc->mp_st = st_init_table(strcmp, st_strhash); |
---|
| 61 | desc->decl_st = st_init_table(ptrcmp, ptrhash); |
---|
| 62 | desc->lib_st = st_init_table(strcmp, st_strhash); |
---|
| 63 | desc->mp_undefined = set_empty(); |
---|
| 64 | desc->fg_vars_st = st_init_table(ptrcmp, ptrhash); |
---|
| 65 | desc->handle = (lsHandle)0; |
---|
| 66 | desc->mod_holes = st_init_table(strcmp, st_strhash); |
---|
| 67 | desc->synclock_st = st_init_table(strcmp, st_strhash); |
---|
| 68 | return desc; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | vl_type *vl_create_typedecl(char *type_name, struct vl_type_specifier *type_specifier) |
---|
| 72 | { |
---|
| 73 | vl_type *retval; |
---|
| 74 | |
---|
| 75 | retval = (vl_type*)chk_malloc(sizeof(vl_type)); |
---|
| 76 | retval->name = type_name; |
---|
| 77 | retval->specifier = type_specifier; |
---|
| 78 | st_insert(mod_list->type_st, type_name, (char*)retval); |
---|
| 79 | |
---|
| 80 | return retval; |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | vl_type_specifier *vl_create_type_specifier(short typeform, vl_enum_type *type_spc) |
---|
| 84 | { |
---|
| 85 | vl_type_specifier *retval; |
---|
| 86 | |
---|
| 87 | retval = (vl_type_specifier*)chk_malloc(sizeof(vl_type_specifier)); |
---|
| 88 | retval->typeform = typeform; |
---|
| 89 | switch(typeform) { |
---|
| 90 | case EnumType: retval->u.enum_type = type_spc; break; |
---|
| 91 | default: break; |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | return retval; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | vl_enum_type *vl_create_enum_type(char *name, lsList elts_list) |
---|
| 98 | { |
---|
| 99 | vl_enum_type *retval; |
---|
| 100 | vl_enumerator *enum_elt; |
---|
| 101 | lsGen gen; |
---|
| 102 | |
---|
| 103 | retval = (vl_enum_type*)chk_malloc(sizeof(vl_enum_type)); |
---|
| 104 | retval->name = name; |
---|
| 105 | retval->domain_list = elts_list; |
---|
| 106 | retval->domain_st = st_init_table(strcmp, st_strhash); |
---|
| 107 | for (gen=lsStart(elts_list); |
---|
| 108 | lsNext(gen, (lsGeneric*)&enum_elt, LS_NH)!=LS_NOMORE;) { |
---|
| 109 | st_insert(retval->domain_st, enum_elt->name, (char*)enum_elt); |
---|
| 110 | } |
---|
| 111 | lsFinish(gen); |
---|
| 112 | |
---|
| 113 | return retval; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | vl_enumerator *vl_create_enumerator(char *enum_name, int enum_val) |
---|
| 117 | { |
---|
| 118 | vl_enumerator *retval; |
---|
| 119 | |
---|
| 120 | retval = (vl_enumerator*)chk_malloc(sizeof(vl_enumerator)); |
---|
| 121 | retval->name = enum_name; |
---|
| 122 | retval->val = enum_val; |
---|
| 123 | |
---|
| 124 | return retval; |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | vl_module *vl_create_module(vl_id_range *mod_name, lsList ports, lsList mod_items) |
---|
| 128 | { |
---|
| 129 | vl_module *mod; |
---|
| 130 | vl_module *clash_module; |
---|
| 131 | |
---|
| 132 | CreTRACE("Creating module\n"); |
---|
| 133 | if (st_lookup(mod_list->mp_st, mod_name->name, (char**)&clash_module)) { |
---|
| 134 | clash_module->type = ModDecl; |
---|
| 135 | clash_module->flags = 0; |
---|
| 136 | clash_module->ports = ports; |
---|
| 137 | clash_module->mod_items = mod_items; |
---|
| 138 | if (clash_module->inst_st) { |
---|
| 139 | clash_module->inst_st = st_init_table(strcmp, st_strhash); |
---|
| 140 | } |
---|
| 141 | if (clash_module->param_st) { |
---|
| 142 | clash_module->param_st = st_init_table(strcmp, st_strhash); |
---|
| 143 | } |
---|
| 144 | if (clash_module->sig_st) { |
---|
| 145 | clash_module->sig_st = st_init_table(strcmp, st_strhash); |
---|
| 146 | } |
---|
| 147 | if (clash_module->latch_st) { |
---|
| 148 | clash_module->latch_st = st_init_table(strcmp, st_strhash); |
---|
| 149 | } |
---|
| 150 | if (clash_module->quasi_st) { |
---|
| 151 | clash_module->quasi_st = st_init_table(strcmp, st_strhash); |
---|
| 152 | } |
---|
| 153 | if (clash_module->func_st) { |
---|
| 154 | clash_module->func_st = st_init_table(strcmp, st_strhash); |
---|
| 155 | } |
---|
| 156 | if (clash_module->uninit_set) { |
---|
| 157 | clash_module->uninit_set = st_init_table(strcmp, st_strhash); |
---|
| 158 | } |
---|
| 159 | if (clash_module->combVar_st) { |
---|
| 160 | clash_module->combVar_st = st_init_table(strcmp, st_strhash); |
---|
| 161 | } |
---|
| 162 | if (clash_module->seqVar_st) { |
---|
| 163 | clash_module->seqVar_st = st_init_table(strcmp, st_strhash); |
---|
| 164 | } |
---|
| 165 | if (clash_module->task_st) { |
---|
| 166 | clash_module->task_st = st_init_table(strcmp, st_strhash); |
---|
| 167 | } |
---|
| 168 | return clash_module; |
---|
| 169 | } |
---|
| 170 | mod = (vl_module *)chk_malloc(MAX(sizeof(vl_module),sizeof(vl_primitive))); |
---|
| 171 | st_insert(mod_list->mp_st, mod_name->name, (char *)mod); |
---|
| 172 | lsNewEnd(mod_list->modules, (char *)mod, LS_NH); |
---|
| 173 | mod->type = ModDecl; |
---|
| 174 | mod->flags = 0; |
---|
| 175 | mod->name = mod_name; |
---|
| 176 | mod->ports = ports; |
---|
| 177 | mod->sig_st = st_init_table(strcmp, st_strhash); |
---|
| 178 | mod->param_st = st_init_table(strcmp, st_strhash); |
---|
| 179 | mod->param_list = lsCreate(); |
---|
| 180 | mod->inst_st = st_init_table(strcmp, st_strhash); |
---|
| 181 | mod->latch_st = st_init_table(strcmp, st_strhash); |
---|
| 182 | mod->quasi_st = st_init_table(strcmp, st_strhash); |
---|
| 183 | mod->func_st = st_init_table(strcmp, st_strhash); |
---|
| 184 | mod->uninit_set = st_init_table(strcmp, st_strhash); |
---|
| 185 | mod->combVar_st = st_init_table(strcmp, st_strhash); |
---|
| 186 | mod->seqVar_st = st_init_table(strcmp, st_strhash); |
---|
| 187 | mod->mod_items = mod_items; |
---|
| 188 | mod->clk = NIL(vl_event_expr); |
---|
| 189 | mod->syndrome_width = 0; |
---|
| 190 | mod->rst_syndrome_width = 0; |
---|
| 191 | mod->flow_graphs = lsCreate(); |
---|
| 192 | mod->task_st = st_init_table(strcmp, st_strhash); |
---|
| 193 | mod->dup_count = 0; |
---|
| 194 | mod->visited = 0; |
---|
| 195 | return(mod); |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | |
---|
| 199 | vl_primitive *vl_create_primitive(vl_id_range *prim_name, lsList ports,lsList prim_decls, lsList prim_entries) |
---|
| 200 | { |
---|
| 201 | vl_primitive *prim; |
---|
| 202 | vl_primitive *clash_prim; |
---|
| 203 | |
---|
| 204 | CreTRACE("Creating primitive\n"); |
---|
| 205 | if (st_lookup(mod_list->mp_st, prim_name->name, (char**)&clash_prim)) { |
---|
| 206 | clash_prim->type = CombPrimDecl; |
---|
| 207 | clash_prim->flags = 0; |
---|
| 208 | clash_prim->ports = ports; |
---|
| 209 | clash_prim->sig_st = st_init_table(strcmp, st_strhash); |
---|
| 210 | clash_prim->uninit_set = st_init_table(strcmp, st_strhash); |
---|
| 211 | clash_prim->decls = prim_decls; |
---|
| 212 | clash_prim->entries = prim_entries; |
---|
| 213 | clash_prim->handle = (lsHandle)0; |
---|
| 214 | return clash_prim; |
---|
| 215 | } |
---|
| 216 | prim = (vl_primitive *)chk_malloc(sizeof(vl_primitive)); |
---|
| 217 | st_insert(mod_list->mp_st, prim_name->name, (char *)prim); |
---|
| 218 | prim->type = CombPrimDecl; |
---|
| 219 | prim->flags = 0; |
---|
| 220 | prim->name = prim_name; |
---|
| 221 | prim->ports = ports; |
---|
| 222 | prim->sig_st = st_init_table(strcmp, st_strhash); |
---|
| 223 | prim->uninit_set = st_init_table(strcmp, st_strhash); |
---|
| 224 | prim->decls = prim_decls; |
---|
| 225 | prim->entries = prim_entries; |
---|
| 226 | prim->handle = (lsHandle)0; |
---|
| 227 | return(prim); |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | vl_port *vl_create_port(short type, vl_id_range *id, lsList exprs) |
---|
| 231 | { |
---|
| 232 | vl_port *port; |
---|
| 233 | |
---|
| 234 | CreTRACE("Creating Port\n"); |
---|
| 235 | port = (vl_port *)chk_malloc(sizeof(vl_port)); |
---|
| 236 | port->type = type; |
---|
| 237 | port->id = id; |
---|
| 238 | port->port_exp = exprs; |
---|
| 239 | return port; |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | vl_port_connect *vl_create_port_connect(short type, vl_id_range *id, vl_expr *expr) |
---|
| 243 | { |
---|
| 244 | vl_port_connect *port_connect; |
---|
| 245 | |
---|
| 246 | CreTRACE("Creating Port Connect\n"); |
---|
| 247 | port_connect = (vl_port_connect *)chk_malloc(sizeof(vl_port_connect)); |
---|
| 248 | port_connect->type = type; |
---|
| 249 | port_connect->id = id; |
---|
| 250 | port_connect->expr = expr; |
---|
| 251 | return port_connect; |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | vl_prim_entry *vl_create_prim_entry(lsList inputs, unsigned char state, |
---|
| 255 | unsigned char output) |
---|
| 256 | { |
---|
| 257 | vl_prim_entry *entry; |
---|
| 258 | lsGen gen; |
---|
| 259 | unsigned int insym; |
---|
| 260 | int i = 0; |
---|
| 261 | |
---|
| 262 | CreTRACE("Creating primitive entry"); |
---|
| 263 | entry = (vl_prim_entry *)chk_malloc(sizeof(vl_prim_entry)); |
---|
| 264 | entry->state = state; |
---|
| 265 | entry->next_state = output; |
---|
| 266 | for (gen = lsStart(inputs); |
---|
| 267 | i<MAXINLEN && lsNext(gen, &insym, LS_NH)!=LS_NOMORE; ) { |
---|
| 268 | entry->inputs[i++] = insym; |
---|
| 269 | } |
---|
| 270 | return entry; |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | |
---|
| 274 | vl_decl *vl_create_basicdecl(short type, lsList ids) |
---|
| 275 | { |
---|
| 276 | vl_decl *decl; |
---|
| 277 | |
---|
| 278 | CreTRACE("Creating Basic decl\n"); |
---|
| 279 | decl = (vl_decl *)chk_malloc(sizeof(vl_decl)); |
---|
| 280 | decl->type = type; |
---|
| 281 | decl->flags = 0; |
---|
| 282 | decl->ids = ids; |
---|
| 283 | decl->handle = (lsHandle)0; |
---|
| 284 | if (type == EventDecl) vl_create_rangedecl(NIL(vl_type), type, |
---|
| 285 | NIL(vl_range), ids, 0); |
---|
| 286 | |
---|
| 287 | return(decl); |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | vl_rangedecl *vl_create_rangedecl(vl_type *var_type, short type, vl_range |
---|
| 291 | *range, lsList ids, int mv) |
---|
| 292 | { |
---|
| 293 | vl_rangedecl *decl; |
---|
| 294 | lsGen gen; |
---|
| 295 | char *id, *dummy; |
---|
| 296 | char *idname; |
---|
| 297 | |
---|
| 298 | CreTRACE("Creating Range decl\n"); |
---|
| 299 | decl = (vl_rangedecl *)chk_malloc(sizeof(vl_rangedecl)); |
---|
| 300 | decl->type = type; |
---|
| 301 | decl->flags = (type==InputDecl)?InPort:(type==OutputDecl)?OutPort: |
---|
| 302 | (type==InoutDecl)?(InPort|OutPort):RegVar; |
---|
| 303 | decl->flags |= mv; |
---|
| 304 | decl->range = range; |
---|
| 305 | decl->ids = ids; |
---|
| 306 | decl->handle = (lsHandle)0; |
---|
| 307 | |
---|
| 308 | if (var_type) { |
---|
| 309 | switch(var_type->specifier->typeform) { |
---|
| 310 | case EnumType: decl->flags |= MVar; break; |
---|
| 311 | default: semantic_error("can not handle types other than enum"); |
---|
| 312 | } |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | |
---|
| 316 | if (task_mode && |
---|
| 317 | (type==InputDecl || type==OutputDecl || type==InoutDecl)) |
---|
| 318 | return decl; |
---|
| 319 | |
---|
| 320 | |
---|
| 321 | gen = lsStart(ids); |
---|
| 322 | while (lsNext(gen, &id, LS_NH) != LS_NOMORE) { |
---|
| 323 | if (var_type) ((vl_id_range *)id)->id_type = var_type; |
---|
| 324 | ((vl_id_range *)id)->mpg_master_exp = decl; |
---|
| 325 | ((vl_id_range *)id)->flags |= (mv | decl->flags); |
---|
| 326 | idname = ((vl_id_range *)id)->name; |
---|
| 327 | |
---|
| 328 | if (type==EventDecl) ((vl_id_range*)id)->flags |= EventVar; |
---|
| 329 | |
---|
| 330 | if (vl_currentModule != NIL(vl_module)) { |
---|
| 331 | if (!st_lookup(SIG_ST(vl_currentModule), idname, &dummy)) { |
---|
| 332 | st_insert(SIG_ST(vl_currentModule), idname, id); |
---|
| 333 | dummy = id; |
---|
| 334 | } else { |
---|
| 335 | ((vl_id_range*)dummy)->flags |= mv; |
---|
| 336 | ((vl_id_range*)dummy)->flags |= decl->flags; |
---|
| 337 | if (!(((vl_id_range*)dummy)->range)) |
---|
| 338 | ((vl_id_range*)dummy)->range = ((vl_id_range*)id)->range; |
---|
| 339 | if (!((vl_id_range*)dummy)->id_type) |
---|
| 340 | ((vl_id_range*)dummy)->id_type = |
---|
| 341 | ((vl_id_range*)id)->id_type; |
---|
| 342 | if (!get_decl_range(((vl_id_range*)dummy)->mpg_master_exp)) { |
---|
| 343 | void *new_decl; |
---|
| 344 | new_decl = chng_decl_range(((vl_id_range*)dummy)->mpg_master_exp, |
---|
| 345 | range); |
---|
| 346 | if (new_decl && range) { |
---|
| 347 | lsNewEnd(((vl_netdecl*)new_decl)->ids, dummy, 0); |
---|
| 348 | ((vl_id_range*)dummy)->mpg_master_exp = new_decl; |
---|
| 349 | } |
---|
| 350 | } |
---|
| 351 | } |
---|
| 352 | } else if (vl_currentPrimitive != NIL(vl_primitive)) { |
---|
| 353 | if (!st_lookup(vl_currentPrimitive->sig_st, idname, &dummy)) { |
---|
| 354 | st_insert(vl_currentPrimitive->sig_st, idname, id); |
---|
| 355 | dummy = id; |
---|
| 356 | } else { |
---|
| 357 | ((vl_id_range*)dummy)->flags |= mv; |
---|
| 358 | ((vl_id_range*)dummy)->flags |= decl->flags; |
---|
| 359 | if (!(((vl_id_range*)dummy)->range)) |
---|
| 360 | ((vl_id_range*)dummy)->range = ((vl_id_range*)id)->range; |
---|
| 361 | if (!((vl_id_range*)dummy)->id_type) |
---|
| 362 | ((vl_id_range*)dummy)->id_type = |
---|
| 363 | ((vl_id_range*)id)->id_type; |
---|
| 364 | } |
---|
| 365 | } else |
---|
| 366 | compile_error("declaring signal not within module/primitive"); |
---|
| 367 | |
---|
| 368 | |
---|
| 369 | |
---|
| 370 | if (vl_currentFunction) { |
---|
| 371 | if (type==OutputDecl) { |
---|
| 372 | char buf[MAXSTRLEN]; |
---|
| 373 | sprintf(buf, "function %s can not have output port %s", |
---|
| 374 | vl_currentFunction->name->name, idname); |
---|
| 375 | yylineno = -1; |
---|
| 376 | compile_error(buf); |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | if (type==InputDecl) { |
---|
| 380 | lsNewEnd(vl_currentFunction->ports, (lsGeneric)dummy, 0); |
---|
| 381 | } |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | lsFinish(gen); |
---|
| 385 | |
---|
| 386 | return(decl); |
---|
| 387 | } |
---|
| 388 | |
---|
| 389 | vl_paramdecl *vl_create_paramdecl(short type, lsList assigns) |
---|
| 390 | { |
---|
| 391 | vl_paramdecl *decl; |
---|
| 392 | lsGen gen; |
---|
| 393 | vl_bassign_stmt *assign; |
---|
| 394 | char *dummy; |
---|
| 395 | int val; |
---|
| 396 | |
---|
| 397 | CreTRACE("Creating Parameter decl\n"); |
---|
| 398 | decl = (vl_paramdecl *)chk_malloc(sizeof(vl_paramdecl)); |
---|
| 399 | decl->type = type; |
---|
| 400 | decl->flags = 0; |
---|
| 401 | decl->assigns = assigns; |
---|
| 402 | decl->handle = (lsHandle)0; |
---|
| 403 | |
---|
| 404 | for (gen=lsStart(assigns); lsNext(gen, &assign, LS_NH) != LS_NOMORE; ) { |
---|
| 405 | val = vl_eval_expr(assign->rhs); |
---|
| 406 | assign->lhs->name->mpg_master_exp = (void*) val; |
---|
| 407 | if (st_lookup(vl_currentModule->param_st, |
---|
| 408 | assign->lhs->name->name, &dummy)) { |
---|
| 409 | char buf[MAXSTRLEN]; |
---|
| 410 | sprintf(buf, "%s:duplicated parameter declaration - %s", |
---|
| 411 | vl_currentModule->name->name, assign->lhs->name->name); |
---|
| 412 | yylineno = -1; |
---|
| 413 | compile_error(buf); |
---|
| 414 | } |
---|
| 415 | lsNewEnd(vl_currentModule->param_list, assign->lhs->name->name, 0); |
---|
| 416 | st_insert(vl_currentModule->param_st, |
---|
| 417 | assign->lhs->name->name, assign->lhs->name); |
---|
| 418 | } |
---|
| 419 | lsFinish(gen); |
---|
| 420 | |
---|
| 421 | return(decl); |
---|
| 422 | } |
---|
| 423 | |
---|
| 424 | vl_netdecl *vl_create_netdecl(vl_type *var_type, short type, int strength, vl_range *range, vl_delay *delay, lsList ids) |
---|
| 425 | { |
---|
| 426 | vl_netdecl *decl; |
---|
| 427 | lsGen gen; |
---|
| 428 | vl_id_range *id; |
---|
| 429 | vl_id_range *id_sym; |
---|
| 430 | |
---|
| 431 | CreTRACE("Creating Net decl\n"); |
---|
| 432 | decl = (vl_netdecl *)chk_malloc(sizeof(vl_netdecl)); |
---|
| 433 | decl->type = type; |
---|
| 434 | decl->flags = 0; |
---|
| 435 | decl->strength = strength; |
---|
| 436 | decl->range = range; |
---|
| 437 | decl->delay = delay; |
---|
| 438 | decl->ids = ids; |
---|
| 439 | decl->handle = (lsHandle)0; |
---|
| 440 | |
---|
| 441 | if (var_type) { |
---|
| 442 | switch(var_type->specifier->typeform) { |
---|
| 443 | case EnumType: decl->flags |= MVar; break; |
---|
| 444 | default: semantic_error("can not handle types other than enum"); |
---|
| 445 | } |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | |
---|
| 449 | gen = lsStart(ids); |
---|
| 450 | while (lsNext(gen, &id, LS_NH) != LS_NOMORE) { |
---|
| 451 | id->mpg_master_exp = decl; |
---|
| 452 | id->flags |= decl->flags; |
---|
| 453 | if (var_type) id->id_type = var_type; |
---|
| 454 | |
---|
| 455 | if (vl_currentModule != NIL(vl_module)) { |
---|
| 456 | if (!st_lookup(SIG_ST(vl_currentModule), id->name, &id_sym)) |
---|
| 457 | st_insert(SIG_ST(vl_currentModule), id->name, id); |
---|
| 458 | else { |
---|
| 459 | id_sym->flags |= decl->flags; |
---|
| 460 | if (!id_sym->range) |
---|
| 461 | id_sym->range = id->range; |
---|
| 462 | if (!id_sym->id_type) |
---|
| 463 | id_sym->id_type = id->id_type; |
---|
| 464 | if (!get_decl_range(id_sym->mpg_master_exp)) { |
---|
| 465 | void *new_decl; |
---|
| 466 | new_decl = chng_decl_range(id_sym->mpg_master_exp, range); |
---|
| 467 | if (new_decl && range) { |
---|
| 468 | lsNewEnd(((vl_netdecl*)new_decl)->ids, id_sym, 0); |
---|
| 469 | id_sym->mpg_master_exp = new_decl; |
---|
| 470 | } |
---|
| 471 | } |
---|
| 472 | } |
---|
| 473 | } else if (vl_currentPrimitive != NIL(vl_primitive)) { |
---|
| 474 | if (!st_lookup(vl_currentPrimitive->sig_st, id->name, &id_sym)) |
---|
| 475 | st_insert(vl_currentPrimitive->sig_st, id->name, id); |
---|
| 476 | else { |
---|
| 477 | id_sym->flags |= decl->flags; |
---|
| 478 | if (!id_sym->range) |
---|
| 479 | id_sym->range = id->range; |
---|
| 480 | if (!id_sym->id_type) |
---|
| 481 | id_sym->id_type = id->id_type; |
---|
| 482 | } |
---|
| 483 | } else |
---|
| 484 | compile_error("declaring signal not within module/primitive"); |
---|
| 485 | } |
---|
| 486 | lsFinish(gen); |
---|
| 487 | |
---|
| 488 | return(decl); |
---|
| 489 | } |
---|
| 490 | |
---|
| 491 | vl_netdecl *vl_create_netdecl_assigned(vl_type *var_type, short type, int strength, vl_range *range, vl_delay *delay, lsList assignments) |
---|
| 492 | { |
---|
| 493 | vl_netdecl *decl; |
---|
| 494 | lsGen gen; |
---|
| 495 | vl_id_range *id; |
---|
| 496 | vl_id_range *id_sym; |
---|
| 497 | lsList ids; |
---|
| 498 | |
---|
| 499 | CreTRACE("Creating Net decl\n"); |
---|
| 500 | decl = (vl_netdecl *)chk_malloc(sizeof(vl_netdecl)); |
---|
| 501 | decl->type = type; |
---|
| 502 | decl->flags = 0; |
---|
| 503 | decl->strength = strength; |
---|
| 504 | decl->range = range; |
---|
| 505 | decl->delay = delay; |
---|
| 506 | decl->ids = assignments; |
---|
| 507 | decl->handle = (lsHandle)0; |
---|
| 508 | ids = get_lhs_ids(assignments); |
---|
| 509 | if (var_type) { |
---|
| 510 | switch(var_type->specifier->typeform) { |
---|
| 511 | case EnumType: decl->flags |= MVar; break; |
---|
| 512 | default: semantic_error("can not handle types other than enum"); |
---|
| 513 | } |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | |
---|
| 517 | gen = lsStart(ids); |
---|
| 518 | while (lsNext(gen, (lsGeneric*)&id, LS_NH) != LS_NOMORE) { |
---|
| 519 | id->mpg_master_exp = decl; |
---|
| 520 | id->flags |= decl->flags; |
---|
| 521 | if (var_type) id->id_type = var_type; |
---|
| 522 | |
---|
| 523 | if (vl_currentModule != NIL(vl_module)) { |
---|
| 524 | if (!st_lookup(SIG_ST(vl_currentModule), id->name, &id_sym)) |
---|
| 525 | st_insert(SIG_ST(vl_currentModule), id->name, id); |
---|
| 526 | else { |
---|
| 527 | id_sym->flags |= decl->flags; |
---|
| 528 | if (!id_sym->range) |
---|
| 529 | id_sym->range = id->range; |
---|
| 530 | if (!id_sym->id_type) |
---|
| 531 | id_sym->id_type = id->id_type; |
---|
| 532 | } |
---|
| 533 | } else if (vl_currentPrimitive != NIL(vl_primitive)) { |
---|
| 534 | if (!st_lookup(vl_currentPrimitive->sig_st, id->name, &id_sym)) |
---|
| 535 | st_insert(vl_currentPrimitive->sig_st, id->name, id); |
---|
| 536 | else { |
---|
| 537 | id_sym->flags |= decl->flags; |
---|
| 538 | if (!id_sym->range) |
---|
| 539 | id_sym->range = id->range; |
---|
| 540 | if (!id_sym->id_type) |
---|
| 541 | id_sym->id_type = id->id_type; |
---|
| 542 | } |
---|
| 543 | } else |
---|
| 544 | compile_error("declaring signal not within module/primitive"); |
---|
| 545 | } |
---|
| 546 | lsFinish(gen); |
---|
| 547 | |
---|
| 548 | return(decl); |
---|
| 549 | } |
---|
| 550 | |
---|
| 551 | |
---|
| 552 | vl_task *vl_create_task(vl_id_range *name, lsList decls, lsList stmts) |
---|
| 553 | { |
---|
| 554 | vl_task *task; |
---|
| 555 | lsGen gen, id_gen; |
---|
| 556 | vl_rangedecl *decl; |
---|
| 557 | vl_id_range *id; |
---|
| 558 | |
---|
| 559 | CreTRACE("Creating Task\n"); |
---|
| 560 | task = (vl_task *)chk_malloc(sizeof(vl_task)); |
---|
| 561 | task->type = TaskDecl; |
---|
| 562 | task->flags = 0; |
---|
| 563 | task->name = name; |
---|
| 564 | task->decls = decls; |
---|
| 565 | task->stmts = stmts; |
---|
| 566 | task->handle = (lsHandle)0; |
---|
| 567 | task->io_lst = lsCreate(); |
---|
| 568 | task->sig_st = st_init_table(strcmp, st_strhash); |
---|
| 569 | for (gen=lsStart(decls); |
---|
| 570 | lsNext(gen, &decl, LS_NH) != LS_NOMORE; ) { |
---|
| 571 | if (decl->ids) { |
---|
| 572 | for (id_gen=lsStart(decl->ids); |
---|
| 573 | lsNext(id_gen, &id, LS_NH) != LS_NOMORE; ) { |
---|
| 574 | |
---|
| 575 | st_insert(task->sig_st, id->name, id->name); |
---|
| 576 | if (decl->type == InputDecl || decl->type == OutputDecl) |
---|
| 577 | lsNewEnd(task->io_lst, id->name, 0); |
---|
| 578 | } |
---|
| 579 | lsFinish(id_gen); |
---|
| 580 | } |
---|
| 581 | } |
---|
| 582 | lsFinish(gen); |
---|
| 583 | st_insert(vl_currentModule->task_st, name->name, task); |
---|
| 584 | return(task); |
---|
| 585 | } |
---|
| 586 | |
---|
| 587 | vl_function *vl_create_function(short type, vl_range *range, vl_id_range *name, lsList decls, lsList stmts) |
---|
| 588 | { |
---|
| 589 | vl_function *func; |
---|
| 590 | |
---|
| 591 | CreTRACE("Creating Function\n"); |
---|
| 592 | func = (vl_function *)chk_malloc(sizeof(vl_function)); |
---|
| 593 | func->type = type; |
---|
| 594 | func->flags = 0; |
---|
| 595 | func->range = range; |
---|
| 596 | func->name = name; |
---|
| 597 | func->decls = decls; |
---|
| 598 | func->stmts = stmts; |
---|
| 599 | func->ports = lsCreate(); |
---|
| 600 | func->sig_st = st_init_table(strcmp, st_strhash); |
---|
| 601 | func->uninit_set = st_init_table(strcmp, st_strhash); |
---|
| 602 | func->handle = (lsHandle)0; |
---|
| 603 | func->param_st = st_init_table(strcmp, st_strhash); |
---|
| 604 | return(func); |
---|
| 605 | } |
---|
| 606 | |
---|
| 607 | vl_gate_inst_list *vl_create_gate_inst_list(short type, int strength, vl_delay *delays, lsList gates) |
---|
| 608 | { |
---|
| 609 | vl_gate_inst_list *gatelist; |
---|
| 610 | |
---|
| 611 | CreTRACE("Creating Gate Instance List\n"); |
---|
| 612 | gatelist = (vl_gate_inst_list *)chk_malloc(sizeof(vl_gate_inst_list)); |
---|
| 613 | gatelist->type = type; |
---|
| 614 | gatelist->flags = 0; |
---|
| 615 | gatelist->strength = strength; |
---|
| 616 | gatelist->delays = delays; |
---|
| 617 | gatelist->gates = gates; |
---|
| 618 | gatelist->handle = (lsHandle)0; |
---|
| 619 | return(gatelist); |
---|
| 620 | } |
---|
| 621 | |
---|
| 622 | vl_gate_inst *vl_create_gate_inst(vl_id_range *name, lsList terms) |
---|
| 623 | { |
---|
| 624 | vl_gate_inst *gate; |
---|
| 625 | |
---|
| 626 | use_libraryGate = 1; |
---|
| 627 | |
---|
| 628 | CreTRACE("Creating Gate Instance\n"); |
---|
| 629 | gate = (vl_gate_inst *)chk_malloc(sizeof(vl_gate_inst)); |
---|
| 630 | gate->name = name; |
---|
| 631 | gate->terms = terms; |
---|
| 632 | gate->handle = (lsHandle)0; |
---|
| 633 | return(gate); |
---|
| 634 | } |
---|
| 635 | |
---|
| 636 | typestruct *vl_add_find_mod_prim_instances(vl_id_range *mp_name, vl_delay *delay, int strength, lsList instances) |
---|
| 637 | { |
---|
| 638 | char *mod_pri; |
---|
| 639 | typestructPtr retval=NULL; |
---|
| 640 | int still_unknown=0; |
---|
| 641 | |
---|
| 642 | if (!st_lookup(vl_description->mp_st, mp_name->name, &mod_pri)) { |
---|
| 643 | still_unknown = 1; |
---|
| 644 | } else if (mod_pri == NIL(char)) { |
---|
| 645 | still_unknown = 1; |
---|
| 646 | } |
---|
| 647 | |
---|
| 648 | if (still_unknown) { |
---|
| 649 | |
---|
| 650 | |
---|
| 651 | |
---|
| 652 | mod_pri = (char*)vl_create_module(mp_name, LS_NIL, LS_NIL); |
---|
| 653 | st_insert(mod_list->mp_st, mp_name->name, mod_pri); |
---|
| 654 | retval = (typestructPtr)vl_create_mod_prim_inst_list(mp_name, |
---|
| 655 | strength, delay, instances); |
---|
| 656 | set_add(mp_name->name, mod_list->mp_undefined); |
---|
| 657 | return retval; |
---|
| 658 | } else { |
---|
| 659 | if (((typestructPtr)mod_pri)->type == ModDecl) { |
---|
| 660 | if (strength!=0) |
---|
| 661 | compile_error("redundant strength for module instance"); |
---|
| 662 | retval = (typestructPtr)vl_create_mod_prim_inst_list(mp_name, |
---|
| 663 | strength, delay, instances); |
---|
| 664 | ((vl_mod_prim_inst_listPtr)retval)->type = ModInst; |
---|
| 665 | } else if (((typestructPtr)mod_pri)->type == CombPrimDecl || |
---|
| 666 | ((typestructPtr)mod_pri)->type == SeqPrimDecl) { |
---|
| 667 | retval = (typestructPtr)vl_create_mod_prim_inst_list(mp_name, |
---|
| 668 | strength, delay, instances); |
---|
| 669 | ((vl_mod_prim_inst_listPtr)retval)->type = PrimInst; |
---|
| 670 | } else { |
---|
| 671 | compile_error("unknown module/primitive"); |
---|
| 672 | } |
---|
| 673 | } |
---|
| 674 | |
---|
| 675 | return retval; |
---|
| 676 | } |
---|
| 677 | |
---|
| 678 | |
---|
| 679 | vl_mod_prim_inst_list *vl_create_mod_prim_inst_list(vl_id_range *name, int strength, vl_delay *delays, lsList mps) |
---|
| 680 | { |
---|
| 681 | vl_mod_prim_inst_list *mplist; |
---|
| 682 | |
---|
| 683 | CreTRACE("Creating Module/Primitive Instance List\n"); |
---|
| 684 | mplist = (vl_mod_prim_inst_list *)chk_malloc(sizeof(vl_mod_prim_inst_list)); |
---|
| 685 | mplist->type = ModInst; |
---|
| 686 | mplist->flags = 0; |
---|
| 687 | mplist->name = name; |
---|
| 688 | mplist->strength = strength; |
---|
| 689 | mplist->delays = delays; |
---|
| 690 | mplist->mps = mps; |
---|
| 691 | mplist->handle = (lsHandle)0; |
---|
| 692 | return(mplist); |
---|
| 693 | } |
---|
| 694 | |
---|
| 695 | vl_mod_prim_inst *vl_create_mod_prim_inst(vl_id_range *name, |
---|
| 696 | lsList ports) |
---|
| 697 | { |
---|
| 698 | vl_mod_prim_inst *mp; |
---|
| 699 | |
---|
| 700 | CreTRACE("Creating Primitive Instance\n"); |
---|
| 701 | mp = (vl_mod_prim_inst *)chk_malloc(sizeof(vl_mod_prim_inst)); |
---|
| 702 | mp->name = name; |
---|
| 703 | mp->ports = ports; |
---|
| 704 | mp->handle = (lsHandle)0; |
---|
| 705 | return(mp); |
---|
| 706 | } |
---|
| 707 | |
---|
| 708 | |
---|
| 709 | vl_procstmt *vl_create_procstmt(short type, void *stmt) |
---|
| 710 | { |
---|
| 711 | vl_procstmt *pstmt; |
---|
| 712 | |
---|
| 713 | CreTRACE("Creating Process stmt\n"); |
---|
| 714 | pstmt = (vl_procstmt *)chk_malloc(sizeof(vl_procstmt)); |
---|
| 715 | pstmt->type = type; |
---|
| 716 | pstmt->flags = 0; |
---|
| 717 | pstmt->stmt = stmt; |
---|
| 718 | pstmt->pc = vl_create_symbolic_var(vlStrdup(new_pc())); |
---|
| 719 | pstmt->fg_info = NIL(char); |
---|
| 720 | return(pstmt); |
---|
| 721 | } |
---|
| 722 | |
---|
| 723 | vl_begin_end_stmt *vl_create_begin_end_stmt(vl_id_range *name, void *decls, void *stmts) |
---|
| 724 | { |
---|
| 725 | vl_begin_end_stmt *bestmt; |
---|
| 726 | |
---|
| 727 | CreTRACE("Creating beginend\n"); |
---|
| 728 | bestmt = (vl_begin_end_stmt *)chk_malloc(sizeof(vl_begin_end_stmt)); |
---|
| 729 | bestmt->type = BeginEndStmt; |
---|
| 730 | bestmt->flags = 0; |
---|
| 731 | bestmt->name = name; |
---|
| 732 | bestmt->decls = decls; |
---|
| 733 | bestmt->stmts = stmts; |
---|
| 734 | bestmt->handle = (lsHandle)0; |
---|
| 735 | return(bestmt); |
---|
| 736 | } |
---|
| 737 | |
---|
| 738 | vl_if_else_stmt *vl_create_if_else_stmt(vl_expr *cond, void *if_stmt, void *else_stmt) |
---|
| 739 | { |
---|
| 740 | vl_if_else_stmt *stmt; |
---|
| 741 | |
---|
| 742 | CreTRACE("Creating if_else_stmt\n"); |
---|
| 743 | stmt = (vl_if_else_stmt *)chk_malloc(sizeof(vl_if_else_stmt)); |
---|
| 744 | stmt->type = IfElseStmt; |
---|
| 745 | stmt->flags = 0; |
---|
| 746 | stmt->cond = cond; |
---|
| 747 | stmt->if_stmt = if_stmt; |
---|
| 748 | stmt->else_stmt = else_stmt; |
---|
| 749 | stmt->handle = (lsHandle)0; |
---|
| 750 | return(stmt); |
---|
| 751 | } |
---|
| 752 | |
---|
| 753 | vl_case_stmt *vl_create_case_stmt(short type, vl_expr *cond, lsList case_items) |
---|
| 754 | { |
---|
| 755 | vl_case_stmt *stmt; |
---|
| 756 | |
---|
| 757 | CreTRACE("Creating case_stmt\n"); |
---|
| 758 | stmt = (vl_case_stmt *)chk_malloc(sizeof(vl_case_stmt)); |
---|
| 759 | stmt->type = type; |
---|
| 760 | stmt->flags = 0; |
---|
| 761 | stmt->cond = cond; |
---|
| 762 | stmt->case_items = case_items; |
---|
| 763 | stmt->handle = (lsHandle)0; |
---|
| 764 | return(stmt); |
---|
| 765 | } |
---|
| 766 | |
---|
| 767 | vl_forever_stmt *vl_create_forever_stmt(void *stmt) |
---|
| 768 | { |
---|
| 769 | vl_forever_stmt *fstmt; |
---|
| 770 | |
---|
| 771 | CreTRACE("Creating forever_stmt\n"); |
---|
| 772 | fstmt = (vl_forever_stmt *)chk_malloc(sizeof(vl_forever_stmt)); |
---|
| 773 | fstmt->type = ForeverStmt; |
---|
| 774 | fstmt->flags = 0; |
---|
| 775 | fstmt->stmt = stmt; |
---|
| 776 | fstmt->handle = (lsHandle)0; |
---|
| 777 | return(fstmt); |
---|
| 778 | } |
---|
| 779 | |
---|
| 780 | vl_repeat_stmt *vl_create_repeat_stmt( vl_expr *count, void *stmt) |
---|
| 781 | { |
---|
| 782 | vl_repeat_stmt *rstmt; |
---|
| 783 | |
---|
| 784 | CreTRACE("Creating repeat_stmt\n"); |
---|
| 785 | rstmt = (vl_repeat_stmt *)chk_malloc(sizeof(vl_repeat_stmt)); |
---|
| 786 | rstmt->type = RepeatStmt; |
---|
| 787 | rstmt->flags = 0; |
---|
| 788 | rstmt->count = count; |
---|
| 789 | rstmt->stmt = stmt; |
---|
| 790 | rstmt->handle = (lsHandle)0; |
---|
| 791 | return(rstmt); |
---|
| 792 | } |
---|
| 793 | |
---|
| 794 | vl_while_stmt *vl_create_while_stmt(vl_expr *cond, void *stmt) |
---|
| 795 | { |
---|
| 796 | vl_while_stmt *wstmt; |
---|
| 797 | |
---|
| 798 | CreTRACE("Creating while_stmt\n"); |
---|
| 799 | wstmt = (vl_while_stmt *)chk_malloc(sizeof(vl_while_stmt)); |
---|
| 800 | wstmt->type = WhileStmt; |
---|
| 801 | wstmt->flags = 0; |
---|
| 802 | wstmt->cond = cond; |
---|
| 803 | wstmt->stmt = stmt; |
---|
| 804 | wstmt->handle = (lsHandle)0; |
---|
| 805 | return(wstmt); |
---|
| 806 | } |
---|
| 807 | |
---|
| 808 | vl_for_stmt *vl_create_for_stmt(vl_bassign_stmt *init, vl_expr *cond, vl_bassign_stmt *end, void *stmt) |
---|
| 809 | { |
---|
| 810 | vl_for_stmt *fstmt; |
---|
| 811 | |
---|
| 812 | CreTRACE("Creating for_stmt\n"); |
---|
| 813 | fstmt = (vl_for_stmt *)chk_malloc(sizeof(vl_for_stmt)); |
---|
| 814 | fstmt->type = ForStmt; |
---|
| 815 | fstmt->flags = 0; |
---|
| 816 | fstmt->init = init; |
---|
| 817 | fstmt->cond = cond; |
---|
| 818 | fstmt->end = end; |
---|
| 819 | fstmt->stmt = stmt; |
---|
| 820 | fstmt->handle = (lsHandle)0; |
---|
| 821 | return(fstmt); |
---|
| 822 | } |
---|
| 823 | |
---|
| 824 | vl_delay_control_stmt *vl_create_delay_control_stmt(vl_delay *delay, void *stmt) |
---|
| 825 | { |
---|
| 826 | vl_delay_control_stmt *dcstmt; |
---|
| 827 | |
---|
| 828 | CreTRACE("Creating delay_control_stmt\n"); |
---|
| 829 | dcstmt = (vl_delay_control_stmt *)chk_malloc(sizeof(vl_delay_control_stmt)); |
---|
| 830 | dcstmt->type = DelayControlStmt; |
---|
| 831 | dcstmt->flags = 0; |
---|
| 832 | dcstmt->delay = delay; |
---|
| 833 | dcstmt->stmt = stmt; |
---|
| 834 | dcstmt->fg_info = NIL(char); |
---|
| 835 | return(dcstmt); |
---|
| 836 | } |
---|
| 837 | |
---|
| 838 | vl_event_control_stmt *vl_create_event_control_stmt(vl_event_expr *event, void *stmt) |
---|
| 839 | { |
---|
| 840 | vl_event_control_stmt *ecstmt; |
---|
| 841 | |
---|
| 842 | CreTRACE("Creating event_control_stmt\n"); |
---|
| 843 | ecstmt = (vl_event_control_stmt *)chk_malloc(sizeof(vl_event_control_stmt)); |
---|
| 844 | ecstmt->type = EventControlStmt; |
---|
| 845 | ecstmt->flags = 0; |
---|
| 846 | ecstmt->event = event; |
---|
| 847 | ecstmt->stmt = stmt; |
---|
| 848 | ecstmt->fg_info = NIL(char); |
---|
| 849 | return(ecstmt); |
---|
| 850 | } |
---|
| 851 | |
---|
| 852 | |
---|
| 853 | vl_bassign_stmt *vl_create_bassign_stmt(short type, vl_lval *lhs, void *control, vl_expr *rhs) |
---|
| 854 | { |
---|
| 855 | vl_bassign_stmt *bassign; |
---|
| 856 | |
---|
| 857 | CreTRACE("Creating bassign_stmt\n"); |
---|
| 858 | bassign = (vl_bassign_stmt *)chk_malloc(sizeof(vl_bassign_stmt)); |
---|
| 859 | bassign->type = type; |
---|
| 860 | bassign->flags = 0; |
---|
| 861 | bassign->lhs = lhs; |
---|
| 862 | bassign->control = control; |
---|
| 863 | bassign->rhs = rhs; |
---|
| 864 | bassign->lineno = yylineno; |
---|
| 865 | bassign->fg_info = NIL(char); |
---|
| 866 | return(bassign); |
---|
| 867 | } |
---|
| 868 | |
---|
| 869 | vl_cont_assign *vl_create_cont_assign_stmt(int strength, vl_delay *delay, lsList assigns) |
---|
| 870 | { |
---|
| 871 | vl_cont_assign *cassign; |
---|
| 872 | |
---|
| 873 | CreTRACE("Creating cont_assign"); |
---|
| 874 | cassign = (vl_cont_assign *)chk_malloc(sizeof(vl_cont_assign)); |
---|
| 875 | cassign->type = ContAssign; |
---|
| 876 | cassign->flags = 0; |
---|
| 877 | cassign->strength = strength; |
---|
| 878 | cassign->delay = delay; |
---|
| 879 | cassign->assigns = assigns; |
---|
| 880 | return cassign; |
---|
| 881 | } |
---|
| 882 | |
---|
| 883 | vl_wait_stmt *vl_create_wait_stmt(vl_expr *cond, void *stmt) |
---|
| 884 | { |
---|
| 885 | vl_wait_stmt *wstmt; |
---|
| 886 | |
---|
| 887 | CreTRACE("Creating wait_stmt\n"); |
---|
| 888 | wstmt = (vl_wait_stmt *)chk_malloc(sizeof(vl_wait_stmt)); |
---|
| 889 | wstmt->type = WaitStmt; |
---|
| 890 | wstmt->flags = 0; |
---|
| 891 | wstmt->cond = cond; |
---|
| 892 | wstmt->stmt = stmt; |
---|
| 893 | wstmt->handle = (lsHandle)0; |
---|
| 894 | return(wstmt); |
---|
| 895 | } |
---|
| 896 | |
---|
| 897 | vl_send_event_stmt *vl_create_send_event_stmt(vl_id_range *name) |
---|
| 898 | { |
---|
| 899 | vl_send_event_stmt *send_event; |
---|
| 900 | |
---|
| 901 | CreTRACE("creating send_event_stmt\n"); |
---|
| 902 | send_event = (vl_send_event_stmt*)chk_malloc(sizeof(vl_send_event_stmt)); |
---|
| 903 | send_event->type = SendEventStmt; |
---|
| 904 | send_event->name = name; |
---|
| 905 | send_event->fg_info = NIL(char); |
---|
| 906 | return send_event; |
---|
| 907 | } |
---|
| 908 | |
---|
| 909 | vl_fork_join_stmt *vl_create_fork_join_stmt(vl_id_range *name, void *decls, void *stmts) |
---|
| 910 | { |
---|
| 911 | vl_fork_join_stmt *fjstmt; |
---|
| 912 | |
---|
| 913 | CreTRACE("Creating fork_join_stmt\n"); |
---|
| 914 | fjstmt = (vl_fork_join_stmt *)chk_malloc(sizeof(vl_fork_join_stmt)); |
---|
| 915 | fjstmt->type = ForkJoinStmt; |
---|
| 916 | fjstmt->flags = 0; |
---|
| 917 | fjstmt->name = name; |
---|
| 918 | fjstmt->decls = decls; |
---|
| 919 | fjstmt->stmts = stmts; |
---|
| 920 | fjstmt->handle = (lsHandle)0; |
---|
| 921 | return(fjstmt); |
---|
| 922 | } |
---|
| 923 | |
---|
| 924 | |
---|
| 925 | vl_task_enable_stmt *vl_create_task_enable_stmt(short type, vl_id_range *name, lsList args) |
---|
| 926 | { |
---|
| 927 | vl_task_enable_stmt *testmt; |
---|
| 928 | |
---|
| 929 | CreTRACE("Creating task_enable_stmt\n"); |
---|
| 930 | testmt = (vl_task_enable_stmt *)chk_malloc(sizeof(vl_task_enable_stmt)); |
---|
| 931 | testmt->type = type; |
---|
| 932 | testmt->flags = 0; |
---|
| 933 | testmt->name = name; |
---|
| 934 | testmt->args = args; |
---|
| 935 | testmt->handle = (lsHandle)0; |
---|
| 936 | return(testmt); |
---|
| 937 | } |
---|
| 938 | |
---|
| 939 | vl_disable_stmt *vl_create_disable_stmt(vl_id_range *name) |
---|
| 940 | { |
---|
| 941 | vl_disable_stmt *dstmt; |
---|
| 942 | |
---|
| 943 | CreTRACE("Creating disable_stmt\n"); |
---|
| 944 | dstmt = (vl_disable_stmt *)chk_malloc(sizeof(vl_disable_stmt)); |
---|
| 945 | dstmt->type = DisableStmt; |
---|
| 946 | dstmt->flags = 0; |
---|
| 947 | dstmt->name = name; |
---|
| 948 | dstmt->handle = (lsHandle)0; |
---|
| 949 | return(dstmt); |
---|
| 950 | } |
---|
| 951 | |
---|
| 952 | vl_deassign_stmt *vl_create_deassign_stmt(vl_lval *lhs) |
---|
| 953 | { |
---|
| 954 | vl_deassign_stmt *dstmt; |
---|
| 955 | |
---|
| 956 | CreTRACE("Creating deassign_stmt\n"); |
---|
| 957 | dstmt = (vl_deassign_stmt *)chk_malloc(sizeof(vl_deassign_stmt)); |
---|
| 958 | dstmt->type = DeassignStmt; |
---|
| 959 | dstmt->flags = 0; |
---|
| 960 | dstmt->lhs = lhs; |
---|
| 961 | dstmt->handle = (lsHandle)0; |
---|
| 962 | return(dstmt); |
---|
| 963 | } |
---|
| 964 | |
---|
| 965 | vl_case_item *vl_create_case_item(short type, lsList expr, void *stmt) |
---|
| 966 | { |
---|
| 967 | vl_case_item *item; |
---|
| 968 | |
---|
| 969 | CreTRACE("Creating case_item\n"); |
---|
| 970 | item = (vl_case_item *)chk_malloc(sizeof(vl_case_item)); |
---|
| 971 | item->type = type; |
---|
| 972 | item->flags = 0; |
---|
| 973 | item->exprs = expr; |
---|
| 974 | item->stmt = stmt; |
---|
| 975 | item->handle = (lsHandle)0; |
---|
| 976 | item->fg_info = NIL(char); |
---|
| 977 | return(item); |
---|
| 978 | } |
---|
| 979 | |
---|
| 980 | vl_event_expr *vl_create_event_expr(short type, struct vl_expr *expr) |
---|
| 981 | { |
---|
| 982 | vl_event_expr *event; |
---|
| 983 | |
---|
| 984 | CreTRACE("Creating event_expr\n"); |
---|
| 985 | event = (vl_event_expr *)chk_malloc(sizeof(vl_event_expr)); |
---|
| 986 | event->type = type; |
---|
| 987 | event->flags = 0; |
---|
| 988 | event->expr = expr; |
---|
| 989 | event->list = (lsList)0; |
---|
| 990 | return(event); |
---|
| 991 | } |
---|
| 992 | |
---|
| 993 | vl_lval *vl_create_lval(short type, vl_id_range *name, vl_range *range, |
---|
| 994 | lsList concat) |
---|
| 995 | { |
---|
| 996 | vl_lval *lval; |
---|
| 997 | |
---|
| 998 | CreTRACE("Creating lval\n"); |
---|
| 999 | lval = (vl_lval *)chk_malloc(sizeof(vl_lval)); |
---|
| 1000 | lval->type = type; |
---|
| 1001 | lval->flags = 0; |
---|
| 1002 | lval->name = name; |
---|
| 1003 | lval->range = range; |
---|
| 1004 | lval->concat = concat; |
---|
| 1005 | return(lval); |
---|
| 1006 | } |
---|
| 1007 | |
---|
| 1008 | vl_expr *vl_create_expr(short type, int intval, double realval, void *p1, void |
---|
| 1009 | *p2, void *p3) |
---|
| 1010 | { |
---|
| 1011 | vl_expr *expr; |
---|
| 1012 | |
---|
| 1013 | CreTRACE("Creating expr\n"); |
---|
| 1014 | expr = (vl_expr *)chk_malloc(sizeof(vl_expr)); |
---|
| 1015 | expr->type = type; |
---|
| 1016 | expr->flags = 0; |
---|
| 1017 | expr->fg_info1 = expr->fg_info2 = NIL(char); |
---|
| 1018 | expr->fg_aux1 = expr->fg_aux2 = NIL(char); |
---|
| 1019 | switch (type) { |
---|
| 1020 | case BitExpr: |
---|
| 1021 | expr->u.bexpr.part1 = (int)p1; |
---|
| 1022 | expr->u.bexpr.part0 = (int)p2; |
---|
| 1023 | expr->u.exprs.e3 = (vl_expr*)p3; |
---|
| 1024 | expr->u.intval = bstr_to_i(p3); |
---|
| 1025 | break; |
---|
| 1026 | case IntExpr: |
---|
| 1027 | expr->u.intval = intval; |
---|
| 1028 | break; |
---|
| 1029 | case RealExpr: |
---|
| 1030 | expr->u.realval = realval; |
---|
| 1031 | break; |
---|
| 1032 | case IDExpr: |
---|
| 1033 | expr->u.name = (vl_id_range *)p1; |
---|
| 1034 | break; |
---|
| 1035 | case BitSelExpr: case PartSelExpr: |
---|
| 1036 | expr->u.idrng = (vl_id_range *)p1; |
---|
| 1037 | break; |
---|
| 1038 | case ConcatExpr: |
---|
| 1039 | expr->u.exprs.e1 = (vl_expr*)p1; |
---|
| 1040 | expr->u.exprs.e2 = (vl_expr*)p2; |
---|
| 1041 | expr->u.exprs.e3 = NIL(vl_expr); |
---|
| 1042 | break; |
---|
| 1043 | case MinTypMaxExpr: |
---|
| 1044 | expr->u.exprs.e1 = (vl_expr*)p1; |
---|
| 1045 | expr->u.exprs.e2 = (vl_expr*)p2; |
---|
| 1046 | expr->u.exprs.e3 = (vl_expr*)p3; |
---|
| 1047 | break; |
---|
| 1048 | case StringExpr: |
---|
| 1049 | expr->u.string = (char *)p1; |
---|
| 1050 | break; |
---|
| 1051 | case FuncExpr: |
---|
| 1052 | expr->u.func_call.name = (vl_id_range *)p1; |
---|
| 1053 | expr->u.func_call.args = (lsList)p2; |
---|
| 1054 | break; |
---|
| 1055 | case UplusExpr: case UminusExpr: |
---|
| 1056 | case UnotExpr: case UcomplExpr: |
---|
| 1057 | |
---|
| 1058 | case UandExpr: case UnandExpr: |
---|
| 1059 | case UorExpr: case UnorExpr: |
---|
| 1060 | case UxorExpr: case UxnorExpr: |
---|
| 1061 | expr->u.exprs.e1 = (vl_expr *)p1; |
---|
| 1062 | expr->u.exprs.e2 = NIL(vl_expr); |
---|
| 1063 | expr->u.exprs.e3 = NIL(vl_expr); |
---|
| 1064 | break; |
---|
| 1065 | |
---|
| 1066 | case BplusExpr: case BminusExpr: |
---|
| 1067 | case BtimesExpr: case BdivExpr: |
---|
| 1068 | case BremExpr: case Beq2Expr: |
---|
| 1069 | case Bneq2Expr: case Beq3Expr: |
---|
| 1070 | case Bneq3Expr: case BlandExpr: |
---|
| 1071 | case BlorExpr: case BltExpr: |
---|
| 1072 | case BleExpr: case BgtExpr: |
---|
| 1073 | case BgeExpr: case BandExpr: |
---|
| 1074 | case BorExpr: case BxorExpr: |
---|
| 1075 | case BxnorExpr: case BlshiftExpr: |
---|
| 1076 | case BrshiftExpr: |
---|
| 1077 | expr->u.exprs.e1 = (vl_expr *)p1; |
---|
| 1078 | expr->u.exprs.e2 = (vl_expr *)p2; |
---|
| 1079 | expr->u.exprs.e3 = NIL(vl_expr); |
---|
| 1080 | break; |
---|
| 1081 | |
---|
| 1082 | case TcondExpr: |
---|
| 1083 | expr->u.exprs.e1 = (vl_expr *)p1; |
---|
| 1084 | expr->u.exprs.e2 = (vl_expr *)p2; |
---|
| 1085 | expr->u.exprs.e3 = (vl_expr *)p3; |
---|
| 1086 | break; |
---|
| 1087 | case NondExpr: { |
---|
| 1088 | int i; |
---|
| 1089 | lsGen gen; |
---|
| 1090 | vl_expr *sexp; |
---|
| 1091 | |
---|
| 1092 | for (gen=lsStart(p1), i=0; |
---|
| 1093 | lsNext(gen, &sexp, LS_NH) != LS_NOMORE; i++) { |
---|
| 1094 | } |
---|
| 1095 | (void)lsFinish(gen); |
---|
| 1096 | |
---|
| 1097 | expr->type = type; |
---|
| 1098 | expr->u.expr_list = (lsList)p1; |
---|
| 1099 | |
---|
| 1100 | break; |
---|
| 1101 | } |
---|
| 1102 | } |
---|
| 1103 | return(expr); |
---|
| 1104 | } |
---|
| 1105 | |
---|
| 1106 | |
---|
| 1107 | vl_range *vl_create_range(vl_expr *left, vl_expr *right) |
---|
| 1108 | { |
---|
| 1109 | vl_range *range; |
---|
| 1110 | |
---|
| 1111 | CreTRACE("Creating range\n"); |
---|
| 1112 | range = (vl_range *)chk_malloc(sizeof(vl_range)); |
---|
| 1113 | range->left = left; |
---|
| 1114 | range->right = right; |
---|
| 1115 | return(range); |
---|
| 1116 | } |
---|
| 1117 | |
---|
| 1118 | vl_delay *vl_create_delay(vl_expr *delay1, vl_expr *delay2, vl_expr *delay3) |
---|
| 1119 | { |
---|
| 1120 | vl_delay *delay; |
---|
| 1121 | |
---|
| 1122 | CreTRACE("Creating delay\n"); |
---|
| 1123 | delay = (vl_delay *)chk_malloc(sizeof(vl_delay)); |
---|
| 1124 | delay->delay1 = delay1; |
---|
| 1125 | delay->delay2 = delay2; |
---|
| 1126 | delay->delay3 = delay3; |
---|
| 1127 | return(delay); |
---|
| 1128 | } |
---|
| 1129 | |
---|
| 1130 | |
---|
| 1131 | |
---|
| 1132 | vl_range_or_typePtr vl_create_range_or_type(short type, vl_rangePtr range) |
---|
| 1133 | { |
---|
| 1134 | vl_range_or_typePtr rng_typ; |
---|
| 1135 | |
---|
| 1136 | rng_typ = (vl_range_or_typePtr)chk_malloc(sizeof(vl_range_or_type)); |
---|
| 1137 | rng_typ->type = type; |
---|
| 1138 | rng_typ->range = range; |
---|
| 1139 | return rng_typ; |
---|
| 1140 | } |
---|
| 1141 | |
---|
| 1142 | |
---|
| 1143 | vl_id_range *vl_create_id_range(char *name, vl_range *range) |
---|
| 1144 | { |
---|
| 1145 | vl_id_range *id_range; |
---|
| 1146 | |
---|
| 1147 | CreTRACE("Creating id_range\n"); |
---|
| 1148 | id_range = (vl_id_range *)chk_malloc(sizeof(vl_id_range)); |
---|
| 1149 | id_range->dummy_type = None; |
---|
| 1150 | id_range->name = name; |
---|
| 1151 | id_range->range = range; |
---|
| 1152 | id_range->flags = 0; |
---|
| 1153 | id_range->initial = lsCreate(); |
---|
| 1154 | id_range->syndrome_expr_list = lsCreate(); |
---|
| 1155 | id_range->rst_syndrome_expr_list = lsCreate(); |
---|
| 1156 | id_range->symbolic_values = st_init_table(strcmp, st_strhash); |
---|
| 1157 | id_range->mpg_master_exp = NIL(void); |
---|
| 1158 | id_range->id_type = NIL(vl_type); |
---|
| 1159 | id_range->edge_trigger = NIL(vl_term); |
---|
| 1160 | id_range->sensitiveList = NIL(st_table); |
---|
| 1161 | id_range->unintType = NIL(char); |
---|
| 1162 | return(id_range); |
---|
| 1163 | } |
---|
| 1164 | |
---|
| 1165 | vl_term *vl_create_term(vl_id_range *name, int lo, int hi) |
---|
| 1166 | { |
---|
| 1167 | vl_term *term; |
---|
| 1168 | |
---|
| 1169 | CreTRACE("Creating term\n"); |
---|
| 1170 | term = (vl_term *)chk_malloc(sizeof(vl_term)); |
---|
| 1171 | term->name = name; |
---|
| 1172 | term->flag = 0; |
---|
| 1173 | term->lo = lo; |
---|
| 1174 | term->hi = hi; |
---|
| 1175 | term->term_type = name->id_type; |
---|
| 1176 | return term; |
---|
| 1177 | } |
---|
| 1178 | |
---|
| 1179 | |
---|
| 1180 | vl_id_range *vl_copy_id_range(vl_id_range *id_range) |
---|
| 1181 | { |
---|
| 1182 | vl_id_range *retval; |
---|
| 1183 | int i; |
---|
| 1184 | char *alias, *dummy; |
---|
| 1185 | |
---|
| 1186 | CreTRACE("Copying id_range\n"); |
---|
| 1187 | retval = (vl_id_range *)chk_malloc(sizeof(vl_id_range)); |
---|
| 1188 | |
---|
| 1189 | alias=id_range->name; |
---|
| 1190 | for (i=aliasSP-1; i>=0; i--) { |
---|
| 1191 | if (st_lookup(aliasStack[i], id_range->name, &dummy)) { |
---|
| 1192 | alias = dummy; |
---|
| 1193 | break; |
---|
| 1194 | } |
---|
| 1195 | } |
---|
| 1196 | retval->name = vlStrdup(alias); |
---|
| 1197 | retval->flags = id_range->flags; |
---|
| 1198 | retval->range = id_range->range; |
---|
| 1199 | retval->initial = lsCreate(); |
---|
| 1200 | retval->syndrome_expr_list = id_range->syndrome_expr_list; |
---|
| 1201 | retval->rst_syndrome_expr_list = id_range->rst_syndrome_expr_list; |
---|
| 1202 | retval->mpg_master_exp = id_range->mpg_master_exp; |
---|
| 1203 | retval->id_type = id_range->id_type; |
---|
| 1204 | retval->unintType = id_range->unintType; |
---|
| 1205 | return(retval); |
---|
| 1206 | } |
---|
| 1207 | |
---|
| 1208 | vl_term *vl_copy_term(vl_term *term) |
---|
| 1209 | { |
---|
| 1210 | vl_term *retval; |
---|
| 1211 | |
---|
| 1212 | CreTRACE("Copying term\n"); |
---|
| 1213 | retval = (vl_term*)chk_malloc(sizeof(vl_term)); |
---|
| 1214 | retval->name = vl_copy_id_range(term->name); |
---|
| 1215 | retval->flag = term->flag; |
---|
| 1216 | retval->lo = term->lo; |
---|
| 1217 | retval->hi = term->hi; |
---|
| 1218 | retval->term_type = term->term_type; |
---|
| 1219 | return retval; |
---|
| 1220 | } |
---|
| 1221 | |
---|
| 1222 | var_info *copy_var_info(var_info *var) |
---|
| 1223 | { |
---|
| 1224 | var_info *retval; |
---|
| 1225 | |
---|
| 1226 | retval = (var_info*)chk_malloc(sizeof(var_info)); |
---|
| 1227 | retval->id = vl_copy_id_range(var->id); |
---|
| 1228 | retval->current_terminal = vl_copy_term(var->current_terminal); |
---|
| 1229 | retval->cond_list = lsCopy(var->cond_list,0); |
---|
| 1230 | retval->extra = NIL(void); |
---|
| 1231 | return retval; |
---|
| 1232 | } |
---|
| 1233 | |
---|
| 1234 | |
---|
| 1235 | vl_term *create_rename_term(vl_id_range *id_range, char *newname, int lo, int hi) |
---|
| 1236 | |
---|
| 1237 | { |
---|
| 1238 | vl_id_range *new_id; |
---|
| 1239 | vl_term *new_term; |
---|
| 1240 | |
---|
| 1241 | new_id = vl_copy_id_range(id_range); |
---|
| 1242 | |
---|
| 1243 | new_id->name = vlStrdup(newname); |
---|
| 1244 | new_term = vl_create_term(new_id, lo, hi); |
---|
| 1245 | new_term->flag = get_decl_flags(id_range->mpg_master_exp); |
---|
| 1246 | return new_term; |
---|
| 1247 | } |
---|
| 1248 | |
---|
| 1249 | var_info *create_var_info(vl_id_range *id, vl_term *term) |
---|
| 1250 | { |
---|
| 1251 | var_info *retval; |
---|
| 1252 | |
---|
| 1253 | retval = (var_info*)chk_malloc(sizeof(var_info)); |
---|
| 1254 | retval->id = id; |
---|
| 1255 | retval->current_terminal = term; |
---|
| 1256 | retval->cond_list = lsCreate(); |
---|
| 1257 | return retval; |
---|
| 1258 | } |
---|
| 1259 | |
---|
| 1260 | |
---|
| 1261 | |
---|
| 1262 | void vl_free_id(vl_id_range * id) |
---|
| 1263 | { |
---|
| 1264 | /* #ifndef __linux__ */ |
---|
| 1265 | if (id->name) vl_chk_free(id->name); |
---|
| 1266 | /* #endif */ |
---|
| 1267 | vl_chk_free((char*)id); |
---|
| 1268 | } |
---|
| 1269 | |
---|
| 1270 | void vl_free_term(vl_term * term) |
---|
| 1271 | { |
---|
| 1272 | if (term->name) vl_free_id(term->name); |
---|
| 1273 | vl_chk_free((char*)term); |
---|
| 1274 | } |
---|
| 1275 | |
---|
| 1276 | void free_var_info(var_info *vinfo) |
---|
| 1277 | { |
---|
| 1278 | if (vinfo->id) vl_free_id(vinfo->id); |
---|
| 1279 | if (vinfo->current_terminal) vl_free_term(vinfo->current_terminal); |
---|
| 1280 | vl_chk_free((char*)vinfo); |
---|
| 1281 | } |
---|
| 1282 | |
---|
| 1283 | blif_latch *create_latch(vl_id_range *name, vl_term *input, vl_term *output) |
---|
| 1284 | { |
---|
| 1285 | blif_latch *retval; |
---|
| 1286 | |
---|
| 1287 | retval = (blif_latch*)chk_malloc(sizeof(blif_latch)); |
---|
| 1288 | retval->name = name; |
---|
| 1289 | retval->inport = input; |
---|
| 1290 | retval->outport = output; |
---|
| 1291 | return retval; |
---|
| 1292 | } |
---|
| 1293 | |
---|
| 1294 | syndrome_expr *create_syndrome_expr(char *synd, vl_term *expr, st_table *pre_cond, int fg_id) |
---|
| 1295 | { |
---|
| 1296 | syndrome_expr *retval; |
---|
| 1297 | |
---|
| 1298 | retval = (syndrome_expr*)chk_malloc(sizeof(syndrome_expr)); |
---|
| 1299 | retval->syndrome = synd; |
---|
| 1300 | retval->expr = expr; |
---|
| 1301 | retval->pre_cond = pre_cond; |
---|
| 1302 | retval->fg_id = fg_id; |
---|
| 1303 | return retval; |
---|
| 1304 | } |
---|
| 1305 | |
---|
| 1306 | const_term *create_const_term(vl_expr *const_expr, vl_term *term) |
---|
| 1307 | { |
---|
| 1308 | const_term *retval; |
---|
| 1309 | |
---|
| 1310 | retval = (const_term*)chk_malloc(sizeof(const_term)); |
---|
| 1311 | retval->const_expr = const_expr; |
---|
| 1312 | retval->term = term; |
---|
| 1313 | return retval; |
---|
| 1314 | } |
---|
| 1315 | |
---|
| 1316 | vl_term *typed_new_term(vl_type *type, vl_range *range, int lo, int hi) |
---|
| 1317 | { |
---|
| 1318 | vl_term *retval; |
---|
| 1319 | |
---|
| 1320 | retval = (vl_term*)chk_malloc(sizeof(vl_term)); |
---|
| 1321 | retval = vl_create_term(vl_create_id_range(vlStrdup(new_termname()),range), |
---|
| 1322 | lo, hi); |
---|
| 1323 | retval->name->id_type = type; |
---|
| 1324 | retval->term_type = type; |
---|
| 1325 | return retval; |
---|
| 1326 | } |
---|
| 1327 | |
---|
| 1328 | vl_term *new_term(vl_range *range, int lo, int hi) |
---|
| 1329 | { |
---|
| 1330 | vl_term *retval; |
---|
| 1331 | |
---|
| 1332 | retval = (vl_term*)chk_malloc(sizeof(vl_term)); |
---|
| 1333 | retval = vl_create_term(vl_create_id_range(vlStrdup(new_termname()),range), |
---|
| 1334 | lo, hi); |
---|
| 1335 | return retval; |
---|
| 1336 | } |
---|
| 1337 | |
---|
| 1338 | symbolic_var *vl_create_symbolic_var(char *var_name) |
---|
| 1339 | { |
---|
| 1340 | symbolic_var *retval; |
---|
| 1341 | |
---|
| 1342 | retval = (symbolic_var*)chk_malloc(sizeof(symbolic_var)); |
---|
| 1343 | retval->name = var_name; |
---|
| 1344 | retval->values = set_empty(); |
---|
| 1345 | |
---|
| 1346 | return retval; |
---|
| 1347 | } |
---|
| 1348 | |
---|
| 1349 | char *new_pc() |
---|
| 1350 | { |
---|
| 1351 | static int pc_number = 0; |
---|
| 1352 | static char buf[MAXSTRLEN]; |
---|
| 1353 | |
---|
| 1354 | sprintf(buf, "%s%d", PC, pc_number++); |
---|
| 1355 | return buf; |
---|
| 1356 | } |
---|
| 1357 | |
---|
| 1358 | lsList get_lhs_ids(lsList assignments) |
---|
| 1359 | { |
---|
| 1360 | lsGen gen; |
---|
| 1361 | lsList retval; |
---|
| 1362 | vl_bassign_stmt *assignment; |
---|
| 1363 | |
---|
| 1364 | retval = lsCreate(); |
---|
| 1365 | |
---|
| 1366 | gen = lsStart(assignments); |
---|
| 1367 | while (lsNext(gen, &assignment, LS_NH) != LS_NOMORE) { |
---|
| 1368 | lsNewEnd(retval, assignment->lhs->name, 0); |
---|
| 1369 | } |
---|
| 1370 | lsFinish(gen); |
---|
| 1371 | |
---|
| 1372 | return retval; |
---|
| 1373 | } |
---|
| 1374 | |
---|
| 1375 | static int bstr_to_i(char *str) |
---|
| 1376 | { |
---|
| 1377 | int i, l; |
---|
| 1378 | int retval = 0; |
---|
| 1379 | |
---|
| 1380 | l = strlen(str)-1; |
---|
| 1381 | for (i=0; i<=MIN(l,31); i++) |
---|
| 1382 | retval = (retval << 1) | ((str[i]=='1') || (str[i]=='?')); |
---|
| 1383 | |
---|
| 1384 | return retval; |
---|
| 1385 | } |
---|
| 1386 | |
---|
| 1387 | multi_concat *vl_create_mconcat(vl_expr *rep, lsList concat) |
---|
| 1388 | { |
---|
| 1389 | multi_concat *retval; |
---|
| 1390 | |
---|
| 1391 | retval = (multi_concat*)chk_malloc(sizeof(multi_concat)); |
---|
| 1392 | retval->rep = rep; |
---|
| 1393 | retval->concat = concat; |
---|
| 1394 | |
---|
| 1395 | return retval; |
---|
| 1396 | } |
---|