1 /*------------------------------------------------------------\ 2 | | 3 | This file is part of the Alliance CAD System Copyright | 4 | (C) Laboratoire LIP6 - D�partement ASIM Universite P&M Curie| 5 | | 6 | Home page : http://www-asim.lip6.fr/alliance/ | 7 | E-mail : mailto:alliance-users@asim.lip6.fr | 8 | | 9 | This progam is free software; you can redistribute it | 10 | and/or modify it under the terms of the GNU Library General| 11 | Public License as published by the Free Software Foundation | 12 | either version 2 of the License, or (at your option) any | 13 | later version. | 14 | | 15 | Alliance VLSI CAD System is distributed in the hope that | 16 | it will be useful, but WITHOUT ANY WARRANTY; | 17 | without even the implied warranty of MERCHANTABILITY or | 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 19 | Public License for more details. | 20 | | 21 | You should have received a copy of the GNU General Public | 22 | License along with the GNU C Library; see the file COPYING. | 23 | If not, write to the Free Software Foundation, Inc., | 24 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 25 | | 26 \------------------------------------------------------------*/ 27 28 /* ###--------------------------------------------------------------### */ 29 /* */ 30 /* file : vbh.h */ 31 /* date : Apr 13 1993 */ 32 /* version : 104 */ 33 /* */ 34 /* ###--------------------------------------------------------------### */ 35 36 #ifndef VBH_DEFINE_H 37 #define VBH_DEFINE_H 38 39 /* ###------------------------------------------------------### */ 40 /* defines */ 41 /* ###------------------------------------------------------### */ 42 43 #define VBH_BEIFS 0 /* if statement ptype code */ 44 #define VBH_BECAS 1 /* case statement ptype code */ 45 #define VBH_BEASG 2 /* assign statement ptype code */ 46 #define VBH_BEVAR 3 /* var assign statement ptype code */ 47 #define VBH_BEFOR 4 /* for statement ptype code */ 48 #define VBH_BENXT 5 /* next statement ptype code */ 49 #define VBH_BEEXT 6 /* exit statement ptype code */ 50 #define VBH_BEWAS 7 /* exit statement ptype code */ 51 #define VBH_BEWHI 8 /* while statement ptype code */ 52 #define VBH_BERET 9 /* return statement ptype code */ 53 #define VBH_BECAL 10 /* call statement ptype code */ 54 #define VBH_BELOP 11 /* loop statement ptype code */ 55 #define VBH_BEAGR 12 /* agregate statement ptype code */ 56 57 # define VBH_TIME_UNIT_UNKNOWN 0 58 # define VBH_TIME_UNIT_FS 1 59 # define VBH_TIME_UNIT_PS 2 60 # define VBH_TIME_UNIT_NS 3 61 # define VBH_TIME_UNIT_MS 4 62 # define VBH_MAX_TIME_UNIT 5 63 64 65 #define VBH_ATTR_ENTITY 0 66 #define VBH_ATTR_ARCHITECTURE 1 67 #define VBH_ATTR_PACKAGE 2 68 #define VBH_ATTR_FUNCTION 3 69 #define VBH_ATTR_PROCEDURE 4 70 #define VBH_ATTR_SUBTYPE 5 71 #define VBH_ATTR_CONSTANT 6 72 #define VBH_ATTR_VARIABLE 7 73 #define VBH_ATTR_SIGNAL 8 74 #define VBH_ATTR_LABEL 9 75 #define VBH_ATTR_TYPE 10 76 #define VBH_ATTR_CONFIGURATION 11 77 #define VBH_ATTR_COMPONENT 12 78 79 # define VBH_TYPE_SEVERITY VEX_TYPE_SEVERITY 80 # define VBH_TYPE_BOOLEAN VEX_TYPE_BOOLEAN 81 # define VBH_TYPE_CHARACTER VEX_TYPE_CHARACTER 82 # define VBH_TYPE_STRING VEX_TYPE_STRING 83 # define VBH_TYPE_BIT VEX_TYPE_BIT 84 # define VBH_TYPE_INTEGER VEX_TYPE_INTEGER 85 # define VBH_TYPE_NATURAL VEX_TYPE_NATURAL 86 # define VBH_TYPE_BIT_VECTOR VEX_TYPE_BIT_VECTOR 87 # define VBH_TYPE_STD_ULOGIC VEX_TYPE_STD_ULOGIC 88 # define VBH_TYPE_STD_LOGIC VEX_TYPE_STD_LOGIC 89 # define VBH_TYPE_STD_ULOGIC_VECTOR VEX_TYPE_STD_ULOGIC_VECTOR 90 # define VBH_TYPE_STD_LOGIC_VECTOR VEX_TYPE_STD_LOGIC_VECTOR 91 # define VBH_TYPE_X01 VEX_TYPE_X01 92 # define VBH_TYPE_X01Z VEX_TYPE_X01Z 93 # define VBH_TYPE_UX01 VEX_TYPE_UX01 94 # define VBH_TYPE_UX01Z VEX_TYPE_UX01Z 95 # define VBH_TYPE_UNSIGNED VEX_TYPE_UNSIGNED 96 # define VBH_TYPE_SIGNED VEX_TYPE_SIGNED 97 # define VBH_TYPE_SMALL_INT VEX_TYPE_SMALL_INT 98 # define VBH_TYPE_REG_BIT VEX_TYPE_REG_BIT 99 # define VBH_TYPE_REG_VECTOR VEX_TYPE_REG_VECTOR 100 # define VBH_TYPE_MUX_BIT VEX_TYPE_MUX_BIT 101 # define VBH_TYPE_MUX_VECTOR VEX_TYPE_MUX_VECTOR 102 # define VBH_TYPE_WOR_BIT VEX_TYPE_WOR_BIT 103 # define VBH_TYPE_WOR_VECTOR VEX_TYPE_WOR_VECTOR 104 # define VBH_MAX_TYPE VEX_TYPE_ENUMERATE 105 106 # define VBH_KIND_NONE 0 107 # define VBH_KIND_BUS 1 108 # define VBH_KIND_REGISTER 2 109 # define VBH_MAX_KIND 3 110 111 # define VBH_CLASS_NONE 0 112 # define VBH_CLASS_CONSTANT 1 113 # define VBH_CLASS_VARIABLE 2 114 # define VBH_CLASS_SIGNAL 3 115 # define VBH_MAX_CLASS 4 116 117 # define VBH_PROCESS_SEQUENTIAL_MASK 0x01 118 # define VBH_PROCESS_WITHSELECT_MASK 0x02 119 # define VBH_PROCESS_GUARDED_MASK 0x04 120 # define VBH_PROCESS_CONDITIONNAL_MASK 0x08 121 122 # define VBH_GENERATE_IF 0x00 123 # define VBH_GENERATE_FOR 0x01 124 125 # define VBH_DYNAMIC_TO 0x1 126 # define VBH_DYNAMIC_DOWNTO 0x2 127 128 # define IsVbhProcSequential( P ) ( (P)->TYPE & VBH_PROCESS_SEQUENTIAL_MASK ) 129 # define IsVbhProcWithSelect( P ) ( (P)->TYPE & VBH_PROCESS_WITHSELECT_MASK ) 130 # define IsVbhProcConditionnal( P ) ( (P)->TYPE & VBH_PROCESS_CONDITIONNAL_MASK ) 131 # define IsVbhProcGuarded( P ) ( (P)->TYPE & VBH_PROCESS_GUARDED_MASK ) 132 133 # define SetVbhProcSequential( P ) ( (P)->TYPE |= VBH_PROCESS_SEQUENTIAL_MASK ) 134 # define SetVbhProcWithSelect( P ) ( (P)->TYPE |= VBH_PROCESS_WITHSELECT_MASK ) 135 # define SetVbhProcConditionnal( P ) ( (P)->TYPE |= VBH_PROCESS_CONDITIONNAL_MASK ) 136 # define SetVbhProcGuarded( P ) ( (P)->TYPE |= VBH_PROCESS_GUARDED_MASK ) 137 138 # define ClearVbhProcSequential( P ) ( (P)->TYPE &= ~VBH_PROCESS_SEQUENTIAL_MASK ) 139 # define ClearVbhProcWithSelect( P ) ( (P)->TYPE &= ~VBH_PROCESS_WITHSELECT_MASK ) 140 # define ClearVbhProcConditionnal( P ) ( (P)->TYPE &= ~VBH_PROCESS_CONDITIONNAL_MASK ) 141 # define ClearVbhProcGuarded( P ) ( (P)->TYPE &= ~VBH_PROCESS_GUARDED_MASK ) 142 143 /* ###------------------------------------------------------### */ 144 /* structure definitions */ 145 /* ###------------------------------------------------------### */ 146 147 typedef struct vbtyp /* type or subtype */ 148 { 149 struct vbtyp *NEXT; /* next vbtyp */ 150 char *NAME; /* type's name */ 151 long LEFT; /* left bound */ 152 long RIGHT; /* right bound */ 153 char **VALUE; /* list of values */ 154 unsigned int SIZE; /* number of values */ 155 unsigned int BYTE; /* number of bytes needed to code values*/ 156 char CLASS; /* type's class (E, I, A, S) */ 157 unsigned char INDEX; /* the type id number */ 158 struct vbtyp *BASE; /* the base type or element's type */ 159 struct vbfun *RESOLV; /* resolution function */ 160 unsigned char DYNAMIC; 161 vexexpr *DYNAMIC_LEFT; 162 vexexpr *DYNAMIC_RIGHT; 163 long FLAGS; 164 long LINE; 165 } 166 vbtyp_list; 167 168 typedef struct vbfig /* behaviour figure */ 169 { 170 struct vbfig *NEXT; /* next figure */ 171 char *NAME; /* model or package's name */ 172 struct vbaux *BEAUX; /* internal signals */ 173 struct vbcst *BECST; /* internal constants */ 174 struct vbpor *BEPOR; /* ports (reverse order of declaration) */ 175 struct vbgen *BEGEN; /* generics declarations */ 176 struct vbpcs *BEPCS; /* list of processes */ 177 struct vbfun *BEFUN; /* list of functions */ 178 struct vbtyp *BETYP; /* list of declared types */ 179 struct vbatr *BEATR; /* list of declared attributes */ 180 struct vbgnr *BEGNR; /* list of generates */ 181 authtable *HASH_TYPE; /* hash table for types */ 182 struct vbmod *BEMOD; /* list of declared model */ 183 struct vbins *BEINS; /* list of instance */ 184 struct ptype *USER; /* reserved for user's applications */ 185 chain_list *PACK_LIST; /* list of used packages */ 186 unsigned char IS_PACKAGE; /* package figure ? */ 187 char FLAG; /* error flags */ 188 } 189 vbfig_list; 190 191 typedef struct vbgnr /* generate statements */ 192 { 193 struct vbgnr *NEXT; /* next figure */ 194 char *LABEL; /* generate's label */ 195 char TYPE; /* generate's type (FOR/IF) */ 196 197 vexexpr *FOR_VARIABLE; /* for variable */ 198 vexexpr *FOR_LEFT; /* for left bound */ 199 vexexpr *FOR_RIGHT; /* for right bound */ 200 char FOR_UP; /* for to or downto */ 201 vexexpr *IF_COND; /* if condition */ 202 203 struct vbpcs *BEPCS; /* list of processes */ 204 struct vbins *BEINS; /* list of instance */ 205 struct vbgnr *BEGNR; /* list of generates */ 206 long LINE; 207 } 208 vbgnr_list; 209 210 typedef struct vbmod 211 { 212 struct vbmod *NEXT; 213 char *NAME; /* Name of the model */ 214 struct vbpor *BEPOR; /* Ports of the model */ 215 struct vbgen *BEGEN; /* Generic declarations */ 216 long LINE; 217 } 218 vbmod_list; 219 220 typedef struct vbins 221 { 222 struct vbins *NEXT; 223 char *NAME; /* Name of instance */ 224 char *MODEL; /* Name of the model */ 225 struct vbmap *PORT_MAP; /* List of port association */ 226 struct vbmap *GEN_MAP; /* List of generics association */ 227 long LINE; 228 } 229 vbins_list; 230 231 typedef struct vbmap 232 { 233 struct vbmap *NEXT; 234 vexexpr *FORMAL; 235 vexexpr *ACTUAL; 236 long LINE; 237 } 238 vbmap_list; 239 240 typedef struct vbgen /* generic */ 241 { 242 struct vbgen *NEXT; /* next constant */ 243 vexexpr *TARGET; /* generic name */ 244 vexexpr *VEX; /* generic init (VEX) */ 245 vbtyp_list *TYPE; /* generic type */ 246 long LINE; 247 } 248 vbgen_list; 249 250 typedef struct vbatr 251 { 252 struct vbatr *NEXT; 253 char *NAME; 254 char *ENTITY; 255 unsigned int TYPE; 256 char *VALUE; 257 long LINE; 258 } 259 vbatr_list; 260 261 typedef struct vbaux /* auxiliary signal */ 262 { 263 struct vbaux *NEXT; /* next signal */ 264 vexexpr *TARGET; /* signal's name */ 265 vexexpr *VEX; /* signal's init (VEX) */ 266 unsigned char KIND; /* signal's kind */ 267 vbtyp_list *TYPE; /* signal's type */ 268 long LINE; 269 } 270 vbaux_list; 271 272 typedef struct vbcst /* constant */ 273 { 274 struct vbcst *NEXT; /* next constant */ 275 vexexpr *TARGET; /* constant name */ 276 vexexpr *VEX; /* constant init (VEX) */ 277 vbtyp_list *TYPE; /* constant type */ 278 long LINE; 279 } 280 vbcst_list; 281 282 typedef struct vbpor /* port */ 283 { 284 struct vbpor *NEXT; /* next port */ 285 vexexpr *TARGET; /* port's name */ 286 vexexpr *VEX; /* port's init (VEX) */ 287 unsigned char DIR; /* port's mode (same as LOCON) */ 288 unsigned char KIND; /* port's kind */ 289 vbtyp_list *TYPE; /* port's type (B, M or W) */ 290 long LINE; 291 } 292 vbpor_list; 293 294 typedef struct vbpcs /* process */ 295 { 296 struct vbpcs *NEXT; /* next process */ 297 char *LABEL; /* process's label */ 298 struct chain *SENSITIVITY; /* list of sensitivity */ 299 struct ptype *VARIABLE; /* list of variable */ 300 struct ptype *INSTRUCTION; /* list of instructions */ 301 unsigned char TYPE; /* process type */ 302 long LINE; 303 } 304 vbpcs_list; 305 306 typedef struct vbifs /* if statement */ 307 { 308 vexexpr *CND; /* condition (vex) */ 309 struct ptype *CNDTRUE; /* list of instructions when true */ 310 struct ptype *CNDFALSE; /* list of instructions when false */ 311 long LINE; 312 } 313 vbifs_list; 314 315 typedef struct vbasg /* signal assignment statement */ 316 { 317 vexexpr *TARGET; /* target (vex) */ 318 vexexpr *VEX; /* condition (vex) */ 319 vbtyp_list *TYPE; /* signal's type */ 320 long LINE; 321 } 322 vbasg_list; 323 324 typedef struct vbagr 325 { 326 struct ptype *ASSIGN; 327 long LINE; 328 } 329 vbagr_list; 330 331 typedef struct vbvar /* variable assignment statement */ 332 { 333 vexexpr *TARGET; /* target's name */ 334 vexexpr *VEX; /* condition (vex) */ 335 vbtyp_list *TYPE; /* signal's type */ 336 long LINE; 337 } 338 vbvar_list; 339 340 typedef struct vbcas /* case statement */ 341 { 342 vexexpr *VEX; /* list of expression (VEX) */ 343 struct vbcho *CHOICE; /* table of choices */ 344 vbtyp_list *TYPE; /* expression's type */ 345 unsigned int SIZE; /* size of choices' table */ 346 void *USER; 347 long LINE; 348 } 349 vbcas_list; 350 351 typedef struct vbcho /* a choice in a case instruction */ 352 { 353 chain_list *VALUES; /* the value's list of the choice */ 354 unsigned int SIZE; /* size of the value in byte */ 355 struct ptype *INSTRUCTION; /* list of instructions */ 356 long LINE; 357 } 358 vbcho_list; 359 360 typedef struct vbwhi /* a loop instruction */ 361 { 362 char *LABEL; /* the name of the loop */ 363 vexexpr *CND; /* condition clause */ 364 struct ptype *INSTRUCTION; /* list of instructions */ 365 long LINE; 366 } 367 vbwhi_list; 368 369 typedef struct vblop /* a loop instruction */ 370 { 371 char *LABEL; /* the name of the loop */ 372 struct ptype *INSTRUCTION; /* list of instructions */ 373 long LINE; 374 } 375 vblop_list; 376 377 typedef struct vbfor /* a loop instruction */ 378 { 379 char *LABEL; /* the name of the loop */ 380 vexexpr *VARIABLE; /* the name of the variable */ 381 vexexpr *LEFT; 382 vexexpr *RIGHT; 383 char UP; /* to or downto */ 384 struct ptype *INSTRUCTION; /* list of instructions */ 385 long LINE; 386 } 387 vbfor_list; 388 389 typedef struct vbwas /* sequential wait statement */ 390 { 391 struct chain *SEN; /* senisitvity list */ 392 vexexpr *CND; /* condition clause */ 393 unsigned char TIME_UNIT; /* name of the time unit */ 394 vexexpr *TIMEOUT; /* timeout clause */ 395 long LINE; 396 } 397 vbwas_list; 398 399 typedef struct vbext /* exit statement */ 400 { 401 char *LABEL; /* label of the targeted loop */ 402 vexexpr *CND; /* condition (vex) */ 403 long LINE; 404 } 405 vbext_list; 406 407 typedef struct vbnxt /* next statement */ 408 { 409 char *LABEL; /* label of the targeted loop */ 410 vexexpr *CND; /* condition (vex) */ 411 long LINE; 412 } 413 vbnxt_list; 414 415 typedef struct vbret /* return statement */ 416 { 417 vexexpr *RET; /* expression (vex) */ 418 long LINE; 419 } 420 vbret_list; 421 422 typedef struct vbcal /* call statement */ 423 { 424 vexexpr *CALL; /* procedure call (vex) */ 425 long LINE; 426 } 427 vbcal_list; 428 429 typedef struct vbarg 430 { 431 struct vbarg *NEXT; /* next param */ 432 vexexpr *TARGET; /* param's name */ 433 char DIR; /* param's mode (same as LOCON) */ 434 char CLASS; /* param's class C,V,S */ 435 vbtyp_list *TYPE; /* param's type (B, M or W) */ 436 long LINE; 437 } 438 vbarg_list; 439 440 typedef struct vbfun /* function statement */ 441 { 442 struct vbfun *NEXT; /* next process */ 443 char *NAME; /* function's name */ 444 struct vbarg *ARGUMENT; /* list of arguments */ 445 struct vbarg *RETURN; /* return value */ 446 struct ptype *VARIABLE; /* list of variable */ 447 struct ptype *INSTRUCTION; /* list of instructions */ 448 unsigned char TYPE; /* function type */ 449 long LINE; 450 } 451 vbfun_list; 452 453 /* ###------------------------------------------------------### */ 454 /* low-level functions */ 455 /* ###------------------------------------------------------### */ 456 457 extern struct vbaux *vbh_addvbaux (); 458 extern struct vbatr *vbh_addvbatr (); 459 extern struct vbcst *vbh_addvbcst (); 460 extern struct vbgen *vbh_addvbgen (); 461 extern struct vbfig *vbh_addvbfig (); 462 extern struct vbpor *vbh_addvbpor (); 463 extern struct ptype *vbh_addvbifs (); 464 extern struct ptype *vbh_addvbasg (); 465 extern struct ptype *vbh_addvbcas (); 466 extern struct ptype *vbh_addvbfor (); 467 extern struct ptype *vbh_addvbwhi (); 468 extern struct ptype *vbh_addvblop (); 469 extern struct vbpcs *vbh_addvbpcs (); 470 extern struct vbarg *vbh_addvbarg (); 471 extern ptype_list *vbh_addvbagr (); 472 extern struct vbfun *vbh_addvbfun (); 473 extern struct vbnxt *vbh_addvbnxt (); 474 extern struct vbret *vbh_addvbret (); 475 extern struct vbcal *vbh_addvbcal (); 476 extern struct vbext *vbh_addvbext (); 477 extern struct vbwas *vbh_addvbwas (); 478 extern ptype_list *vbh_addvbvar (); 479 extern struct vbtyp *vbh_addvbtyp (); 480 extern struct vbmap *vbh_addvbmap (); 481 extern struct vbmod *vbh_addvbmod (); 482 extern struct vbins *vbh_addvbins (); 483 extern struct vbgnr *vbh_addvbgnr (); 484 485 extern struct vbtyp *vbh_crtvbtyp (); 486 487 extern void vbh_delvbfig (); 488 extern void vbh_frevbfig (); 489 extern void vbh_frevbaux (); 490 extern void vbh_frevbatr (); 491 extern void vbh_frevbcst (); 492 extern void vbh_frevbgen (); 493 extern void vbh_frevbpor (); 494 extern void vbh_frevbpcs (); 495 extern void vbh_frevbarg (); 496 extern void vbh_frevbfun (); 497 extern void vbh_frevbifs (); 498 extern void vbh_frevbasg (); 499 extern void vbh_frevbcas (); 500 extern void vbh_frevbwhi (); 501 extern void vbh_frevblop (); 502 extern void vbh_frevbfor (); 503 extern void vbh_frevbpcs (); 504 extern void vbh_frevbnxt (); 505 extern void vbh_frevbret (); 506 extern void vbh_frevbcal (); 507 extern void vbh_frevbext (); 508 extern void vbh_frevbwas (); 509 extern void vbh_frevbvar (); 510 extern void vbh_frevbagr (); 511 extern void vbh_frevbtyp (); 512 extern void vbh_frevbinst (); 513 extern void vbh_frevbmod (); 514 extern void vbh_frevbins (); 515 extern void vbh_frevbmap (); 516 extern void vbh_frevbgnr (); 517 518 extern void vbh_viewvbfig(); 519 extern void vbh_viewvbtyp(); 520 extern void vbh_viewvbinst(); 521 522 extern void vbh_simpvbfig(); 523 extern void vbh_forallvexvbfig(); 524 extern void vbh_simpvbinst(); 525 526 extern vbtyp_list *vbh_prdeftyp(); 527 extern vbtyp_list *vbh_getvbtyp(); 528 extern vbtyp_list *vbh_getvbtypbyindex(); 529 530 extern void vbh_dupvbfig(); 531 extern ptype_list *vbh_dupvbinst(); 532 533 /* ###------------------------------------------------------### */ 534 /* parser-driver functions */ 535 /* ###------------------------------------------------------### */ 536 537 #endif 538