PageRenderTime 36ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/alliance-5.0/bvl/src/bvl_bcomp_y.y

#
Happy | 3400 lines | 3052 code | 348 blank | 0 comment | 0 complexity | 97e725e8f016e522118c9ad64c048264 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0
  1. /* ###--------------------------------------------------------------### */
  2. /* file : bvl_bcomp.yac */
  3. /* date : Mar 8 2000 */
  4. /* version : v114 */
  5. /* author : Pirouz BAZARGAN SABET, L.A. TABUSSE, VUONG H.N. */
  6. /* content : yacc rules for behavioural VHDL */
  7. /* ###--------------------------------------------------------------### */
  8. %{
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include "mut.h"
  13. #include "log.h"
  14. #include "beh.h"
  15. #include "bvl.h"
  16. #include "bvl_byacc.h"
  17. #include "bvl_bedef.h"
  18. /* ###--------------------------------------------------------------### */
  19. /* function : bvl_y_error */
  20. /* description : print an error message */
  21. /* called func. : none */
  22. /* ###--------------------------------------------------------------### */
  23. static void bvl_y_error (str)
  24. char *str;
  25. {
  26. BVL_ERRFLG++;
  27. fprintf (stderr, "`%s` Error line %d : %s\n", BVL_CURFIL, BEH_LINNUM, str);
  28. }
  29. /* ###--------------------------------------------------------------### */
  30. /* function : tobin */
  31. /* description : translate a StringLit, BitStringLit or CharacterLit */
  32. /* in a string of '0' and '1's */
  33. /* ###--------------------------------------------------------------### */
  34. static long tobin (
  35. char *trg ,
  36. char *src ,
  37. long left ,
  38. long right )
  39. {
  40. char base ;
  41. long indx ;
  42. long j = 0;
  43. long errflg = 0;
  44. char lcl_trg [256];
  45. lcl_trg [0] = '\0';
  46. if (src == NULL)
  47. {
  48. strcpy (trg,"0");
  49. }
  50. else
  51. {
  52. if (!strcmp (src,"others"))
  53. {
  54. strcpy (trg, src);
  55. }
  56. else
  57. {
  58. if ((src [0] != '\'') && (src [0] != '"') && (src [0] != '%'))
  59. {
  60. base = src [0];
  61. indx = 2;
  62. }
  63. else
  64. {
  65. base = 'B';
  66. indx = 1;
  67. }
  68. switch (base)
  69. {
  70. case 'B' :
  71. case 'b' :
  72. while ((lcl_trg[j] = src[indx]) != '\0')
  73. {
  74. switch (src[indx])
  75. {
  76. case '0':
  77. case '1':
  78. case 'd': /* Beware Not VHDL */
  79. j++; break;
  80. case '%' :
  81. case '"' :
  82. case '\'':
  83. case '_' :
  84. break;
  85. default :
  86. errflg = 1; bvl_error (73,src);
  87. }
  88. indx++;
  89. }
  90. break;
  91. case 'O' :
  92. case 'o' :
  93. while (src[indx] != '\0')
  94. {
  95. j += 3;
  96. switch (src[indx])
  97. {
  98. case '0' :
  99. strcat (lcl_trg,"000"); break;
  100. case '1' :
  101. strcat (lcl_trg,"001"); break;
  102. case '2' :
  103. strcat (lcl_trg,"010"); break;
  104. case '3' :
  105. strcat (lcl_trg,"011"); break;
  106. case '4' :
  107. strcat (lcl_trg,"100"); break;
  108. case '5' :
  109. strcat (lcl_trg,"101"); break;
  110. case '6' :
  111. strcat (lcl_trg,"110"); break;
  112. case '7' :
  113. strcat (lcl_trg,"111"); break;
  114. case '"' :
  115. case '%' :
  116. case '_' :
  117. j -= 3; break;
  118. default :
  119. j -= 3; errflg = 1; bvl_error (73, src);
  120. }
  121. indx++;
  122. }
  123. break;
  124. case 'X' :
  125. case 'x' :
  126. while (src[indx] != '\0')
  127. {
  128. j += 4;
  129. switch (src[indx])
  130. {
  131. case '0' :
  132. strcat (lcl_trg,"0000"); break;
  133. case '1' :
  134. strcat (lcl_trg,"0001"); break;
  135. case '2' :
  136. strcat (lcl_trg,"0010"); break;
  137. case '3' :
  138. strcat (lcl_trg,"0011"); break;
  139. case '4' :
  140. strcat (lcl_trg,"0100"); break;
  141. case '5' :
  142. strcat (lcl_trg,"0101"); break;
  143. case '6' :
  144. strcat (lcl_trg,"0110"); break;
  145. case '7' :
  146. strcat (lcl_trg,"0111"); break;
  147. case '8' :
  148. strcat (lcl_trg,"1000"); break;
  149. case '9' :
  150. strcat (lcl_trg,"1001"); break;
  151. case 'a' :
  152. case 'A' :
  153. strcat (lcl_trg,"1010"); break;
  154. case 'b' :
  155. case 'B' :
  156. strcat (lcl_trg,"1011"); break;
  157. case 'c' :
  158. case 'C' :
  159. strcat (lcl_trg,"1100"); break;
  160. case 'd' :
  161. case 'D' :
  162. strcat (lcl_trg,"1101"); break;
  163. case 'e' :
  164. case 'E' :
  165. strcat (lcl_trg,"1110"); break;
  166. case 'f' :
  167. case 'F' :
  168. strcat (lcl_trg,"1111"); break;
  169. case '%' :
  170. case '"' :
  171. case '_' :
  172. j -= 4; break;
  173. default :
  174. j -= 4; errflg = 1; bvl_error(73,src);
  175. }
  176. indx++;
  177. }
  178. break;
  179. default :
  180. beh_toolbug (17, "tobin", NULL, base);
  181. }
  182. if ((j == 0) || (j <= right))
  183. {
  184. trg[0] = '0';
  185. trg[1] = '\0';
  186. }
  187. else
  188. {
  189. if (left != -1)
  190. {
  191. strcpy (trg, &lcl_trg[left]);
  192. trg[right - left + 1] = '\0';
  193. }
  194. else
  195. strcpy (trg, lcl_trg);
  196. }
  197. }
  198. }
  199. return (errflg);
  200. }
  201. /* ###--------------------------------------------------------------### */
  202. /* function : chkdcl */
  203. /* ###--------------------------------------------------------------### */
  204. static long chkdcl (object, mode, type, flag, kind, constraint, conf)
  205. char object ;
  206. long mode ;
  207. long type ;
  208. char flag ;
  209. long kind ;
  210. char constraint;
  211. long *conf ;
  212. {
  213. long errflg = 0;
  214. long lclcnf = 0;
  215. if (flag != constraint)
  216. {
  217. errflg = 1;
  218. bvl_error (33, NULL);
  219. }
  220. else
  221. {
  222. switch (object)
  223. {
  224. case 'P':
  225. /* ###------------------------------------------------------### */
  226. /* If object is a port : */
  227. /* - if type is bit, no guard indication can be used */
  228. /* - if type is wor_bit or mux_bit, bus kind must be used */
  229. /* - other types are illegal */
  230. /* ###------------------------------------------------------### */
  231. switch (type)
  232. {
  233. case BIT:
  234. lclcnf += BVL_BITDFN + BVL_NORDFN;
  235. switch (mode)
  236. {
  237. case _IN :
  238. lclcnf += BVL_ICNDFN; break;
  239. case _OUT:
  240. lclcnf += BVL_OCNDFN; break;
  241. case _INOUT :
  242. lclcnf += BVL_BCNDFN; break;
  243. case _LINKAGE :
  244. case 0 :
  245. errflg = 1; break;
  246. }
  247. if (kind != 0)
  248. errflg = 1;
  249. break;
  250. case MUX_BIT:
  251. lclcnf += BVL_MUXDFN + BVL_BUSDFN;
  252. switch (mode)
  253. {
  254. case _OUT :
  255. lclcnf += BVL_OCNDFN; break;
  256. case _INOUT :
  257. lclcnf += BVL_BCNDFN; break;
  258. case _IN :
  259. case _LINKAGE :
  260. case 0 :
  261. errflg = 1; break;
  262. }
  263. if (kind != BUS)
  264. errflg = 1;
  265. break;
  266. case WOR_BIT:
  267. lclcnf += BVL_WORDFN + BVL_BUSDFN;
  268. switch (mode)
  269. {
  270. case _OUT :
  271. lclcnf += BVL_OCNDFN; break;
  272. case _INOUT :
  273. lclcnf += BVL_BCNDFN; break;
  274. case _IN :
  275. case _LINKAGE :
  276. case 0 :
  277. errflg = 1; break;
  278. }
  279. if (kind != BUS)
  280. errflg = 1;
  281. break;
  282. case REG_BIT:
  283. case NATURAL:
  284. errflg = 1;
  285. break;
  286. }
  287. if (errflg == 1)
  288. bvl_error (5, NULL);
  289. break;
  290. case 'G':
  291. /* ###------------------------------------------------------### */
  292. /* If object is a generic : */
  293. /* - only natural type is allowed */
  294. /* ###------------------------------------------------------### */
  295. if ((type != NATURAL) || (mode != 0) || (kind != 0))
  296. {
  297. errflg = 1;
  298. bvl_error (77, NULL);
  299. }
  300. break;
  301. case 'S':
  302. /* ###------------------------------------------------------### */
  303. /* If object is a signal : */
  304. /* - no mode can be specified */
  305. /* - if type is bit no guard indication can be used */
  306. /* - if type is wor_bit or mux_bit, bus kind must be used */
  307. /* - if type is reg_bit, register kind must be used */
  308. /* - other types are illegal */
  309. /* ###------------------------------------------------------### */
  310. switch (type)
  311. {
  312. case BIT:
  313. lclcnf += BVL_BITDFN + BVL_NORDFN;
  314. if ((mode != 0) || (kind != 0))
  315. errflg = 1;
  316. break;
  317. case MUX_BIT:
  318. lclcnf += BVL_MUXDFN + BVL_BUSDFN;
  319. if ((mode != 0) || (kind != BUS))
  320. errflg = 1;
  321. break;
  322. case WOR_BIT:
  323. lclcnf += BVL_WORDFN + BVL_BUSDFN;
  324. if ((mode != 0) || (kind != BUS))
  325. errflg = 1;
  326. break;
  327. case REG_BIT:
  328. lclcnf += BVL_RBIDFN + BVL_REGDFN;
  329. if ((mode != 0) || (kind != REGISTER))
  330. errflg = 1;
  331. break;
  332. case NATURAL:
  333. errflg = 1; break;
  334. }
  335. if (mode != 0)
  336. errflg = 1;
  337. if (errflg == 1)
  338. bvl_error (11, NULL);
  339. break;
  340. case 'C':
  341. /* ###------------------------------------------------------### */
  342. /* If object is a constant : */
  343. /* - only bit type without any other indication is legal */
  344. /* ###------------------------------------------------------### */
  345. lclcnf += BVL_CSTDFN;
  346. if ((type != BIT) || (mode != 0) || (kind != 0))
  347. {
  348. errflg = 1;
  349. bvl_error (78, NULL);
  350. }
  351. break;
  352. }
  353. }
  354. *conf = lclcnf ;
  355. return (errflg);
  356. }
  357. /* ###--------------------------------------------------------------### */
  358. /* function : addstr */
  359. /* ###--------------------------------------------------------------### */
  360. static void *addstr (ptfig, object, mode, type, flag, name, left, right)
  361. struct befig *ptfig ;
  362. char object;
  363. long mode ;
  364. long type ;
  365. char flag ;
  366. char *name ;
  367. short left ;
  368. short right ;
  369. {
  370. void *pnt = NULL;
  371. char porflg = 0;
  372. char rinflg = 0;
  373. char outflg = 0;
  374. char busflg = 0;
  375. char auxflg = 0;
  376. char buxflg = 0;
  377. char regflg = 0;
  378. char lclmod = 'I';
  379. char lcltyp = 'B';
  380. char extname [100];
  381. short i ;
  382. short inc = 1;
  383. switch (object)
  384. {
  385. case 'P':
  386. /* ###------------------------------------------------------### */
  387. /* if object is a port ... */
  388. /* ###------------------------------------------------------### */
  389. porflg = 1;
  390. switch (mode)
  391. {
  392. case _IN:
  393. lclmod = 'I'; lcltyp = 'B'; rinflg = 1; break;
  394. case _OUT:
  395. switch (type)
  396. {
  397. case BIT:
  398. lclmod = 'O'; lcltyp = 'B'; outflg = 1; break;
  399. case MUX_BIT:
  400. lclmod = 'Z'; lcltyp = 'M'; busflg = 1; break;
  401. case WOR_BIT:
  402. lclmod = 'Z'; lcltyp = 'W'; busflg = 1; break;
  403. }
  404. break;
  405. case _INOUT:
  406. rinflg = 1;
  407. switch (type)
  408. {
  409. case BIT:
  410. lclmod = 'B'; lcltyp = 'B'; outflg = 1; break;
  411. case MUX_BIT:
  412. lclmod = 'T'; lcltyp = 'M'; busflg = 1; break;
  413. case WOR_BIT:
  414. lclmod = 'T'; lcltyp = 'W'; busflg = 1; break;
  415. }
  416. break;
  417. }
  418. break;
  419. case 'S':
  420. /* ###------------------------------------------------------### */
  421. /* if object is a signal ... */
  422. /* ###------------------------------------------------------### */
  423. switch (type)
  424. {
  425. case BIT:
  426. lcltyp = 'B'; rinflg = BVL_AUXMOD; auxflg = 1; break;
  427. case REG_BIT:
  428. rinflg = 1; regflg = 1; break;
  429. case MUX_BIT:
  430. lcltyp = 'M'; rinflg = 1; buxflg = 1; break;
  431. case WOR_BIT:
  432. lcltyp = 'W'; rinflg = 1; buxflg = 1; break;
  433. }
  434. break;
  435. }
  436. if (flag == 'S')
  437. {
  438. /* ###------------------------------------------------------### */
  439. /* if object is a scalar ... */
  440. /* ###------------------------------------------------------### */
  441. if (porflg == 1)
  442. ptfig->BEPOR = beh_addbepor (ptfig->BEPOR, name, lclmod, lcltyp);
  443. if (rinflg == 1)
  444. ptfig->BERIN = beh_addberin (ptfig->BERIN, name);
  445. if (outflg == 1)
  446. ptfig->BEOUT = beh_addbeout (ptfig->BEOUT, name, NULL, NULL);
  447. if (busflg == 1)
  448. ptfig->BEBUS = beh_addbebus (ptfig->BEBUS, name, NULL, NULL, lcltyp);
  449. if (auxflg == 1)
  450. ptfig->BEAUX = beh_addbeaux (ptfig->BEAUX, name, NULL, NULL);
  451. if (buxflg == 1)
  452. ptfig->BEBUX = beh_addbebux (ptfig->BEBUX, name, NULL, NULL, lcltyp);
  453. if (regflg == 1)
  454. ptfig->BEREG = beh_addbereg (ptfig->BEREG, name, NULL, NULL);
  455. }
  456. else
  457. {
  458. /* ###------------------------------------------------------### */
  459. /* if object is an array ... */
  460. /* ###------------------------------------------------------### */
  461. if (left >= right)
  462. inc = -1;
  463. for (i=left ; i!=(right+inc) ; i+=inc)
  464. {
  465. sprintf (extname, "%s %d", name, i);
  466. if (porflg == 1)
  467. ptfig->BEPOR = beh_addbepor (ptfig->BEPOR, extname, lclmod, lcltyp);
  468. if (rinflg == 1)
  469. ptfig->BERIN = beh_addberin (ptfig->BERIN, extname);
  470. if (outflg == 1)
  471. ptfig->BEOUT = beh_addbeout (ptfig->BEOUT, extname, NULL, NULL);
  472. if (busflg == 1)
  473. ptfig->BEBUS = beh_addbebus (ptfig->BEBUS, extname, NULL, NULL, lcltyp);
  474. if (auxflg == 1)
  475. ptfig->BEAUX = beh_addbeaux (ptfig->BEAUX, extname, NULL, NULL);
  476. if (buxflg == 1)
  477. ptfig->BEBUX = beh_addbebux (ptfig->BEBUX, extname, NULL, NULL, lcltyp);
  478. if (regflg == 1)
  479. ptfig->BEREG = beh_addbereg (ptfig->BEREG, extname, NULL, NULL);
  480. }
  481. }
  482. if (outflg == 1)
  483. pnt = (void *) ptfig->BEOUT;
  484. if (busflg == 1)
  485. pnt = (void *) ptfig->BEBUS;
  486. if (auxflg == 1)
  487. pnt = (void *) ptfig->BEAUX;
  488. if (buxflg == 1)
  489. pnt = (void *) ptfig->BEBUX;
  490. if (regflg == 1)
  491. pnt = (void *) ptfig->BEREG;
  492. return (pnt);
  493. }
  494. /* ###--------------------------------------------------------------### */
  495. /* function : addgen */
  496. /* description : create one or more BEGEN structures */
  497. /* For a scalar a BEGEN is created at the head of */
  498. /* existing BEGEN list. */
  499. /* For an array (including arraies of one element) a set */
  500. /* of BEGENs are created in a sorted list. BEGEN related */
  501. /* to the index i of the array is named `name(i)`. The */
  502. /* head of the list represents the right bound of the */
  503. /* array. This list is then chained to the head of */
  504. /* existing BEGEN list. */
  505. /* called func. : beh_addbegen, namealloc */
  506. /* ###--------------------------------------------------------------### */
  507. static struct begen *addgen (last_gen, nat_lst, nam_lst, type, left, right)
  508. struct begen *last_gen; /* pointer on the last begen structure */
  509. struct chain *nam_lst ; /* generic's name list */
  510. struct chain *nat_lst ; /* generic's value list */
  511. char *type ; /* generic's type */
  512. short left ; /* array's left bound (= -1 if scalar) */
  513. short right ; /* array's right bound (= -1 if scalar) */
  514. {
  515. char extname [128];
  516. char *name ;
  517. struct begen *ptgen ;
  518. struct chain *ptauxnam ;
  519. struct chain *ptauxnat ;
  520. long i ;
  521. long inc = 1;
  522. ptgen = last_gen;
  523. ptauxnam = nam_lst ;
  524. ptauxnat = nat_lst ;
  525. if ((left == -1) && (right == -1))
  526. {
  527. if ((ptauxnat != NULL) && (ptauxnat->NEXT == NULL))
  528. {
  529. while (ptauxnam != NULL)
  530. {
  531. name = namealloc ((char *) ptauxnam->DATA);
  532. ptgen = beh_addbegen (ptgen, name, type, (void *) ptauxnat->DATA);
  533. ptauxnam = ptauxnam->NEXT;
  534. }
  535. }
  536. else
  537. bvl_error (75, NULL);
  538. }
  539. else
  540. {
  541. if (left >= right)
  542. inc = -1;
  543. while (ptauxnam != NULL)
  544. {
  545. for (i=left ; i!=(right+inc) ; i+=inc)
  546. {
  547. sprintf (extname, "%s %d", (char *)ptauxnam->DATA, i);
  548. name = namealloc (extname);
  549. if (ptauxnat != NULL)
  550. {
  551. ptgen = beh_addbegen (ptgen, name, type, (void *)ptauxnat->DATA);
  552. ptauxnat = ptauxnat->NEXT;
  553. }
  554. else
  555. bvl_error (75, NULL);
  556. }
  557. if (ptauxnat != NULL)
  558. bvl_error (75, NULL);
  559. ptauxnat = nat_lst;
  560. ptauxnam = ptauxnam->NEXT;
  561. }
  562. }
  563. return (ptgen);
  564. }
  565. /* ###--------------------------------------------------------------### */
  566. /* function : cpyabllst */
  567. /* description : duplicate bvl_abllst structure */
  568. /* called func. : addchain, reverse, copyExpr */
  569. /* ###--------------------------------------------------------------### */
  570. static struct chain *cpyabllst (abllst)
  571. struct chain *abllst;
  572. {
  573. struct chain *pt_abllst = NULL;
  574. while (abllst != NULL)
  575. {
  576. pt_abllst = addchain (pt_abllst, copyExpr ((struct chain *)abllst->DATA));
  577. abllst = abllst->NEXT;
  578. }
  579. pt_abllst = reverse (pt_abllst);
  580. return (pt_abllst);
  581. }
  582. /* ###--------------------------------------------------------------### */
  583. /* function : cpyablstr */
  584. /* description : duplicate bvl_ablstr structure */
  585. /* called func. : mbkalloc, cpyabllst */
  586. /* ###--------------------------------------------------------------### */
  587. static bvl_ablstr cpyablstr (ablstr)
  588. bvl_ablstr ablstr;
  589. {
  590. bvl_ablstr pt_ablstr;
  591. pt_ablstr.IDENT = NULL;
  592. pt_ablstr.WIDTH = ablstr.WIDTH;
  593. pt_ablstr.LIST_ABL = cpyabllst (ablstr.LIST_ABL);
  594. return (pt_ablstr);
  595. }
  596. /* ###--------------------------------------------------------------### */
  597. /* function : crtabl */
  598. /* description : combine at most two ABLs and build a new one */
  599. /* The following operations can be performed : */
  600. /* CONC perform concatenation */
  601. /* NOPI initialize a structure for a signal (scalar */
  602. /* or array) */
  603. /* NOPS initialize a structure for a literal */
  604. /* NE create a structure with an ABL representing */
  605. /* the 'non equality' of two expressions */
  606. /* EQ create a structure with an ABL representing */
  607. /* the 'equality' of two expressions */
  608. /* NOT perform logical not of an expression */
  609. /* AND perform logical and between two expressions*/
  610. /* OR perform logical or between two expressions*/
  611. /* NAND perform logical nand between two expressions*/
  612. /* NOR perform logical nor between two expressions*/
  613. /* XOR perform logical xor between two expressions*/
  614. /* ANDM perform logical and between two expressions*/
  615. /* (the second expression is a scalar) */
  616. /* called func. : createAtom , createExpr, addQExpr , beh_toolbug, */
  617. /* bvl_error , addchain , freechain */
  618. /* ###--------------------------------------------------------------### */
  619. static bvl_ablstr crtabl (
  620. short oper ,
  621. bvl_ablstr expr1,
  622. bvl_ablstr expr2,
  623. long left ,
  624. long right )
  625. {
  626. char name [256] ;
  627. char *name2 ;
  628. struct chain *pt_abl1 = NULL;
  629. struct chain *pt_abl2 = NULL;
  630. struct chain *pt_aux1 = NULL;
  631. struct chain *pt_aux2 = NULL;
  632. bvl_ablstr result ;
  633. char lcl_buffer [256];
  634. short inc ;
  635. short i ;
  636. char true_flag_un = 0;
  637. char true_flag_zero = 0;
  638. struct chain *abl_un = createAtom ("'1'");
  639. struct chain *abl_zero = createAtom ("'0'");
  640. result.IDENT = NULL;
  641. result.TIME = 0 ;
  642. result.LIST_ABL = NULL;
  643. result.WIDTH = 0 ;
  644. switch (oper)
  645. {
  646. case CONC :
  647. if ((expr1.LIST_ABL == NULL) || (expr2.LIST_ABL == NULL))
  648. beh_toolbug (4, "crtabl", NULL, 0);
  649. else
  650. {
  651. if (expr1.LIST_ABL == expr2.LIST_ABL)
  652. beh_toolbug (16, "crtabl", NULL, 0);
  653. else
  654. {
  655. pt_aux2 = expr2.LIST_ABL;
  656. while (pt_aux2->NEXT != NULL)
  657. pt_aux2 = pt_aux2->NEXT;
  658. pt_aux2->NEXT = expr1.LIST_ABL;
  659. result.LIST_ABL = expr2.LIST_ABL;
  660. result.WIDTH = expr1.WIDTH + expr2.WIDTH;
  661. expr1.LIST_ABL = NULL;
  662. expr2.LIST_ABL = NULL;
  663. }
  664. }
  665. break;
  666. case NOPI :
  667. if (expr1.IDENT == NULL)
  668. beh_toolbug (2, "crtabl", NULL, 0);
  669. else
  670. {
  671. if ((left == -1) && (right == -1))
  672. {
  673. result.LIST_ABL = addchain(result.LIST_ABL,createAtom(expr1.IDENT));
  674. result.WIDTH = 1;
  675. }
  676. else
  677. {
  678. if (left <= right)
  679. {
  680. inc = 1;
  681. result.WIDTH = right - left + 1;
  682. }
  683. else
  684. {
  685. inc = -1;
  686. result.WIDTH = left - right + 1;
  687. }
  688. for (i=left ; i!=(right+inc) ; i+=inc)
  689. {
  690. sprintf (name,"%s %i",expr1.IDENT,i);
  691. name2 = namealloc (name);
  692. result.LIST_ABL = addchain (result.LIST_ABL,createAtom(name2));
  693. }
  694. }
  695. expr1.IDENT = NULL;
  696. }
  697. break;
  698. case NOPS :
  699. if (expr1.IDENT == NULL)
  700. beh_toolbug (2, "crtabl", NULL, 0);
  701. else
  702. {
  703. tobin (lcl_buffer, expr1.IDENT, -1, -1);
  704. if ((left == -1) && (right == -1))
  705. {
  706. left = 0;
  707. right = strlen (lcl_buffer) - 1;
  708. }
  709. for (i=left ; i<=right ; i++)
  710. {
  711. switch ( lcl_buffer[i] )
  712. {
  713. case '0' :
  714. result.LIST_ABL = addchain (result.LIST_ABL,createAtom("'0'"));
  715. break;
  716. case '1' :
  717. result.LIST_ABL = addchain (result.LIST_ABL,createAtom("'1'"));
  718. break;
  719. /*----------- Beware Not VHDL -------------*/
  720. case 'd' :
  721. result.LIST_ABL = addchain (result.LIST_ABL,createAtom("'D'"));
  722. break;
  723. default :
  724. beh_toolbug (15, "crtabl", NULL, expr1.IDENT[i]);
  725. }
  726. }
  727. result.WIDTH = right - left + 1;
  728. }
  729. break;
  730. case STABLE :
  731. if (expr1.LIST_ABL == NULL)
  732. beh_toolbug (3, "crtabl", NULL, 0);
  733. else
  734. {
  735. pt_aux1 = expr1.LIST_ABL;
  736. while (pt_aux1 != NULL)
  737. {
  738. pt_abl1 = createExpr (STABLE);
  739. addQExpr (pt_abl1, (struct chain *)pt_aux1->DATA);
  740. pt_aux1->DATA = pt_abl1;
  741. pt_aux1 = pt_aux1->NEXT;
  742. }
  743. result.LIST_ABL = expr1.LIST_ABL;
  744. result.WIDTH = expr1.WIDTH;
  745. expr1.LIST_ABL = NULL;
  746. }
  747. break;
  748. case NOT :
  749. if (expr1.LIST_ABL == NULL)
  750. beh_toolbug (3, "crtabl", NULL, 0);
  751. else
  752. {
  753. pt_aux1 = expr1.LIST_ABL;
  754. while (pt_aux1 != NULL)
  755. {
  756. pt_abl1 = createExpr (NOT);
  757. addQExpr (pt_abl1, (struct chain *)pt_aux1->DATA);
  758. pt_aux1->DATA = pt_abl1;
  759. pt_aux1 = pt_aux1->NEXT;
  760. }
  761. result.LIST_ABL = expr1.LIST_ABL;
  762. result.WIDTH = expr1.WIDTH;
  763. expr1.LIST_ABL = NULL;
  764. }
  765. break;
  766. case EQ :
  767. if ((expr1.LIST_ABL == NULL) || (expr2.LIST_ABL == NULL))
  768. beh_toolbug (4, "crtabl", NULL, 0);
  769. else
  770. {
  771. if (expr1.WIDTH != expr2.WIDTH)
  772. {
  773. bvl_error (38,NULL);
  774. pt_abl2 = createAtom ("'1'");
  775. pt_aux1 = expr1.LIST_ABL;
  776. while (pt_aux1 != NULL)
  777. {
  778. freeExpr (pt_aux1->DATA);
  779. pt_aux1 = pt_aux1->NEXT;
  780. }
  781. pt_aux2 = expr2.LIST_ABL;
  782. while (pt_aux2 != NULL)
  783. {
  784. freeExpr (pt_aux2->DATA);
  785. pt_aux2 = pt_aux2->NEXT;
  786. }
  787. }
  788. else
  789. {
  790. pt_aux1 = expr1.LIST_ABL;
  791. pt_aux2 = expr2.LIST_ABL;
  792. /* If expr2 = '1' then return expr1 */
  793. while(pt_aux2 != NULL)
  794. {
  795. true_flag_un = 1;
  796. if(!equalExpr(pt_aux2->DATA,abl_un))
  797. {
  798. /* One abl not abl_un */
  799. true_flag_un = 0;
  800. break;
  801. }
  802. pt_aux2 = pt_aux2->NEXT;
  803. }
  804. if(true_flag_un == 1)
  805. {
  806. pt_abl1 = (struct chain *)pt_aux1->DATA;
  807. pt_aux1 = pt_aux1->NEXT;
  808. if(pt_aux1 != NULL)
  809. {
  810. pt_abl2 = createExpr(AND);
  811. addQExpr(pt_abl2,pt_abl1);
  812. pt_abl1 = pt_abl2;
  813. }
  814. while(pt_aux1 != NULL)
  815. {
  816. addQExpr(pt_abl1,(struct chain *)pt_aux1->DATA);
  817. pt_aux1 = pt_aux1->NEXT;
  818. }
  819. result.LIST_ABL = addchain(result.LIST_ABL,pt_abl1);
  820. result.WIDTH = 1;
  821. expr1.LIST_ABL = NULL;
  822. expr2.LIST_ABL = NULL;
  823. }
  824. /* If expr2 = '0' then return NOT(expr1) */
  825. pt_aux2 = expr2.LIST_ABL;
  826. true_flag_zero = 0;
  827. while(pt_aux2 != NULL)
  828. {
  829. true_flag_zero = 1;
  830. if(!equalExpr(pt_aux2->DATA,abl_zero))
  831. {
  832. /* One abl not abl_zero */
  833. true_flag_zero = 0;
  834. break;
  835. }
  836. pt_aux2 = pt_aux2->NEXT;
  837. }
  838. if(true_flag_zero == 1)
  839. {
  840. while(pt_aux1 != NULL)
  841. {
  842. pt_abl1 = createExpr(NOT);
  843. addQExpr(pt_abl1,(struct chain *)pt_aux1->DATA);
  844. pt_aux1 = pt_aux1->NEXT;
  845. if(pt_aux1 != NULL)
  846. {
  847. pt_abl2 = createExpr(AND);
  848. addQExpr(pt_abl2,pt_abl1);
  849. pt_abl1 = pt_abl2;
  850. }
  851. while(pt_aux1 != NULL)
  852. {
  853. pt_abl2 = createExpr(NOT);
  854. addQExpr(pt_abl2,(struct chain *)pt_aux1->DATA);
  855. addQExpr(pt_abl1,pt_abl2);
  856. pt_aux1 = pt_aux1->NEXT;
  857. }
  858. /* --pt_abl1 = createExpr(NOT);
  859. addQExpr(pt_abl1,(struct chain *)pt_aux1->DATA);
  860. pt_aux1->DATA = pt_abl1;
  861. pt_aux1 = pt_aux1->NEXT;
  862. --- */
  863. }
  864. result.LIST_ABL = addchain(result.LIST_ABL,pt_abl1);
  865. result.WIDTH = 1;
  866. expr1.LIST_ABL = NULL;
  867. expr2.LIST_ABL = NULL;
  868. }
  869. pt_aux2 = expr2.LIST_ABL;
  870. if((true_flag_zero == 0) && (true_flag_un == 0))
  871. {
  872. pt_abl1 = createExpr (XOR);
  873. addQExpr (pt_abl1, (struct chain *)pt_aux1->DATA);
  874. addQExpr (pt_abl1, (struct chain *)pt_aux2->DATA);
  875. pt_aux1 = pt_aux1->NEXT;
  876. pt_aux2 = pt_aux2->NEXT;
  877. while (pt_aux1 != NULL)
  878. {
  879. pt_abl2 = createExpr (OR);
  880. addQExpr (pt_abl2,pt_abl1);
  881. pt_abl1 = createExpr (XOR);
  882. addQExpr (pt_abl1, (struct chain *)pt_aux1->DATA);
  883. addQExpr (pt_abl1, (struct chain *)pt_aux2->DATA);
  884. addQExpr (pt_abl2, pt_abl1);
  885. pt_abl1 = pt_abl2;
  886. pt_aux1 = pt_aux1->NEXT;
  887. pt_aux2 = pt_aux2->NEXT;
  888. }
  889. pt_abl2 = createExpr (NOT);
  890. addQExpr (pt_abl2, pt_abl1);
  891. result.LIST_ABL = addchain (result.LIST_ABL,pt_abl2);
  892. result.WIDTH = 1;
  893. freechain (expr1.LIST_ABL);
  894. freechain (expr2.LIST_ABL);
  895. expr1.LIST_ABL = NULL;
  896. expr2.LIST_ABL = NULL;
  897. }
  898. }
  899. }
  900. break;
  901. case NE :
  902. if ((expr1.LIST_ABL == NULL) || (expr2.LIST_ABL == NULL))
  903. beh_toolbug (4, "crtabl", NULL, 0);
  904. else
  905. {
  906. if (expr1.WIDTH != expr2.WIDTH)
  907. {
  908. bvl_error(38,NULL);
  909. pt_abl1 = createAtom ("'1'");
  910. pt_aux1 = expr1.LIST_ABL;
  911. while (pt_aux1 != NULL)
  912. {
  913. freeExpr (pt_aux1->DATA);
  914. pt_aux1 = pt_aux1->NEXT;
  915. }
  916. pt_aux2 = expr2.LIST_ABL;
  917. while (pt_aux2 != NULL)
  918. {
  919. freeExpr (pt_aux2->DATA);
  920. pt_aux2 = pt_aux2->NEXT;
  921. }
  922. }
  923. else
  924. {
  925. pt_aux1 = expr1.LIST_ABL;
  926. pt_aux2 = expr2.LIST_ABL;
  927. /* If expr2 = '0' then return expr1 */
  928. while(pt_aux2 != NULL)
  929. {
  930. true_flag_zero = 1;
  931. if(!equalExpr(pt_aux2->DATA,abl_zero))
  932. {
  933. /* One abl not abl_zero */
  934. true_flag_zero = 0;
  935. break;
  936. }
  937. pt_aux2 = pt_aux2->NEXT;
  938. }
  939. if(true_flag_zero == 1)
  940. {
  941. result.LIST_ABL = expr1.LIST_ABL;
  942. result.WIDTH = 1;
  943. expr1.LIST_ABL = NULL;
  944. expr2.LIST_ABL = NULL;
  945. }
  946. /* If expr2 = '1' then return NOT(expr1) */
  947. pt_aux2 = expr2.LIST_ABL;
  948. true_flag_un = 0;
  949. while(pt_aux2 != NULL)
  950. {
  951. true_flag_un = 1;
  952. if(!equalExpr(pt_aux2->DATA,abl_un))
  953. {
  954. /* One abl not abl_un */
  955. true_flag_un = 0;
  956. break;
  957. }
  958. pt_aux2 = pt_aux2->NEXT;
  959. }
  960. if(true_flag_un == 1)
  961. {
  962. while(pt_aux1 != NULL)
  963. {
  964. pt_abl1 = createExpr(NOT);
  965. addQExpr(pt_abl1,(struct chain *)pt_aux1->DATA);
  966. pt_aux1->DATA = pt_abl1;
  967. pt_aux1 = pt_aux1->NEXT;
  968. }
  969. result.LIST_ABL = expr1.LIST_ABL;
  970. result.WIDTH = 1;
  971. expr1.LIST_ABL = NULL;
  972. expr2.LIST_ABL = NULL;
  973. }
  974. pt_aux2 = expr2.LIST_ABL;
  975. if((true_flag_zero == 0) && (true_flag_un == 0))
  976. {
  977. pt_abl1 = createExpr (XOR);
  978. addQExpr (pt_abl1, (struct chain *)pt_aux1->DATA);
  979. addQExpr (pt_abl1, (struct chain *)pt_aux2->DATA);
  980. pt_aux1 = pt_aux1->NEXT;
  981. pt_aux2 = pt_aux2->NEXT;
  982. for (i=2 ; i<=expr1.WIDTH ; i++)
  983. {
  984. pt_abl2 = createExpr (OR);
  985. addQExpr (pt_abl2, pt_abl1);
  986. pt_abl1 = createExpr (XOR);
  987. addQExpr (pt_abl1, (struct chain *)pt_aux1->DATA);
  988. addQExpr (pt_abl1, (struct chain *)pt_aux2->DATA);
  989. addQExpr (pt_abl2, pt_abl1);
  990. pt_abl1 = pt_abl2;
  991. pt_aux1 = pt_aux1->NEXT;
  992. pt_aux2 = pt_aux2->NEXT;
  993. }
  994. result.LIST_ABL = addchain(result.LIST_ABL,pt_abl1);
  995. result.WIDTH = 1;
  996. freechain (expr1.LIST_ABL);
  997. freechain (expr2.LIST_ABL);
  998. expr1.LIST_ABL = NULL;
  999. expr2.LIST_ABL = NULL;
  1000. }
  1001. }
  1002. }
  1003. break;
  1004. case AND :
  1005. case NAND :
  1006. case OR :
  1007. case NOR :
  1008. case XOR :
  1009. if (expr1.LIST_ABL == NULL)
  1010. {
  1011. if (expr2.LIST_ABL == NULL)
  1012. beh_toolbug (4, "crtabl", NULL, 0);
  1013. else
  1014. {
  1015. result.LIST_ABL = expr2.LIST_ABL;
  1016. result.WIDTH = expr2.WIDTH;
  1017. expr2.LIST_ABL = NULL;
  1018. }
  1019. }
  1020. else
  1021. {
  1022. if (expr2.LIST_ABL == NULL)
  1023. {
  1024. result.LIST_ABL = expr1.LIST_ABL;
  1025. result.WIDTH = expr1.WIDTH;
  1026. expr1.LIST_ABL = NULL;
  1027. }
  1028. else
  1029. {
  1030. if (expr1.LIST_ABL == expr2.LIST_ABL)
  1031. beh_toolbug (16, "crtabl", NULL, 0);
  1032. else
  1033. {
  1034. if (expr1.WIDTH != expr2.WIDTH)
  1035. {
  1036. bvl_error(38,NULL);
  1037. }
  1038. else
  1039. {
  1040. pt_aux1 = expr1.LIST_ABL;
  1041. pt_aux2 = expr2.LIST_ABL;
  1042. for (i=1 ; i<=expr1.WIDTH ; i++)
  1043. {
  1044. pt_abl1 = createExpr (oper);
  1045. addQExpr (pt_abl1, (struct chain *)pt_aux1->DATA);
  1046. addQExpr (pt_abl1, (struct chain *)pt_aux2->DATA);
  1047. pt_aux1->DATA = (void *)pt_abl1;
  1048. pt_aux1 = pt_aux1->NEXT;
  1049. pt_aux2 = pt_aux2->NEXT;
  1050. }
  1051. }
  1052. result.LIST_ABL = expr1.LIST_ABL;
  1053. result.WIDTH = expr1.WIDTH;
  1054. freechain (expr2.LIST_ABL);
  1055. expr1.LIST_ABL = NULL;
  1056. expr2.LIST_ABL = NULL;
  1057. }
  1058. }
  1059. }
  1060. break;
  1061. case ANDM :
  1062. if ((expr1.LIST_ABL == NULL) || (expr2.LIST_ABL == NULL))
  1063. beh_toolbug (4, "crtabl", NULL, 0);
  1064. else
  1065. {
  1066. if (expr2.WIDTH != 1)
  1067. {
  1068. bvl_error( 38,NULL);
  1069. }
  1070. else
  1071. {
  1072. pt_aux1 = expr1.LIST_ABL;
  1073. pt_aux2 = expr2.LIST_ABL;
  1074. while (pt_aux1 != NULL)
  1075. {
  1076. pt_abl1 = createExpr (AND);
  1077. addQExpr (pt_abl1, (struct chain *)pt_aux1->DATA);
  1078. addQExpr (pt_abl1, copyExpr((struct chain *)pt_aux2->DATA));
  1079. pt_aux1->DATA = (void *)pt_abl1;
  1080. pt_aux1 = pt_aux1->NEXT;
  1081. }
  1082. }
  1083. result.LIST_ABL = expr1.LIST_ABL;
  1084. result.WIDTH = expr1.WIDTH;
  1085. pt_aux2 = expr2.LIST_ABL;
  1086. while (pt_aux2 != NULL)
  1087. {
  1088. freeExpr (pt_aux2->DATA);
  1089. pt_aux2 = pt_aux2->NEXT;
  1090. }
  1091. freechain (expr2.LIST_ABL);
  1092. expr2.LIST_ABL = NULL;
  1093. expr1.LIST_ABL = NULL;
  1094. }
  1095. break;
  1096. default :
  1097. beh_toolbug (1, "crtabl", NULL, 0);
  1098. }
  1099. return (result);
  1100. }
  1101. /* ###--------------------------------------------------------------### */
  1102. /* function : bvl_select */
  1103. /* description : create an abl representing the choice in a selected */
  1104. /* signal assignment and perform unicity verification */
  1105. /* using BDDs. */
  1106. /* called func. : tobin , bddToAbl , addInputCct , */
  1107. /* substPhyExpr, initializeCct, createNodeTermBdd, */
  1108. /* bvl_error , notBdd , applyBinBdd , */
  1109. /* addchain , namealloc */
  1110. /* ###--------------------------------------------------------------### */
  1111. static void bvl_select (result, pt_str, pt_bdd, pt_ablstr)
  1112. bvl_ablstr *result;
  1113. struct chain *pt_str; /* pointer on a list of choices */
  1114. pNode *pt_bdd; /* used to check if a choice is legal */
  1115. bvl_ablstr pt_ablstr; /* tested expression */
  1116. {
  1117. char binstr[256];
  1118. long i;
  1119. struct chain *pt_auxabl;
  1120. pNode pt_bddres;
  1121. pNode pt_bddnew;
  1122. pNode pt_bddtmp;
  1123. pNode pt_bddaux;
  1124. char nomvar[10];
  1125. struct chain *pt_newabl;
  1126. struct chain *pt_newabl2;
  1127. static long oth_flg=0;
  1128. static long last_width=0;
  1129. static pCircuit pC = NULL;
  1130. result->LIST_ABL = NULL;
  1131. result->IDENT = NULL;
  1132. pt_bddtmp = zero;
  1133. if (pC == NULL)
  1134. pC = initializeCct ("-select-",200,0);
  1135. if (*pt_bdd == NULL)
  1136. {
  1137. if (last_width < pt_ablstr.WIDTH)
  1138. {
  1139. for (; last_width<pt_ablstr.WIDTH ; last_width++)
  1140. {
  1141. sprintf (nomvar,"(%d)",last_width);
  1142. createNodeTermBdd (addInputCct(pC,nomvar));
  1143. }
  1144. }
  1145. *pt_bdd = zero;
  1146. oth_flg = 0;
  1147. }
  1148. while (pt_str != NULL)
  1149. {
  1150. tobin (binstr, (char *)pt_str->DATA, -1, -1);
  1151. if (oth_flg != 0)
  1152. {
  1153. bvl_error(30,NULL);
  1154. }
  1155. if (strcmp("others", (char *)pt_str->DATA))
  1156. {
  1157. pt_bddres = one;
  1158. if (strlen (binstr) != pt_ablstr.WIDTH)
  1159. {
  1160. bvl_error(38,NULL);
  1161. }
  1162. for (i=0 ; binstr[i]!='\0' ; i++)
  1163. {
  1164. pt_bddaux = createNodeTermBdd (i+2);
  1165. if (binstr[i] == '0')
  1166. pt_bddaux = notBdd (pt_bddaux);
  1167. pt_bddres = applyBinBdd (AND, pt_bddaux, pt_bddres);
  1168. }
  1169. pt_bddnew = applyBinBdd (OR,*pt_bdd,pt_bddres);
  1170. if (*pt_bdd == pt_bddnew)
  1171. {
  1172. bvl_error(28,NULL);
  1173. }
  1174. *pt_bdd = pt_bddnew;
  1175. }
  1176. else
  1177. {
  1178. oth_flg = 1;
  1179. pt_bddres = notBdd (*pt_bdd);
  1180. *pt_bdd = one;
  1181. }
  1182. pt_bddtmp = applyBinBdd (OR,pt_bddtmp,pt_bddres);
  1183. pt_str = pt_str->NEXT;
  1184. }
  1185. pt_newabl = bddToAbl (pt_bddtmp, pC->pNameI);
  1186. pt_auxabl = pt_ablstr.LIST_ABL;
  1187. i = pt_ablstr.WIDTH - 1;
  1188. while (pt_auxabl != NULL)
  1189. {
  1190. sprintf (nomvar,"(%i)",i);
  1191. /*--------
  1192. substPhyExpr (pt_newabl,namealloc(nomvar),(struct chain *)pt_auxabl->DATA);
  1193. ---------*/
  1194. pt_newabl2 = substExpr (pt_newabl,namealloc(nomvar),
  1195. (struct chain *)pt_auxabl->DATA);
  1196. freeExpr (pt_newabl);
  1197. pt_newabl = pt_newabl2;
  1198. i--;
  1199. pt_auxabl = pt_auxabl->NEXT;
  1200. }
  1201. result->LIST_ABL = addchain (NULL, pt_newabl);
  1202. result->WIDTH = 1;
  1203. }
  1204. %}
  1205. %union {
  1206. long valu;
  1207. float flov;
  1208. char *text;
  1209. bvl_ablstr list;
  1210. bvl_name name;
  1211. struct g_type dble;
  1212. };
  1213. %token tok_AND
  1214. %token _BEGIN
  1215. %token _END
  1216. %token _EQSym
  1217. %token _EXIT
  1218. %token _FILE
  1219. %token _GESym
  1220. %token _GTSym
  1221. %token _IN
  1222. %token _INOUT
  1223. %token _LABEL
  1224. %token _LESym
  1225. %token _LINKAGE
  1226. %token _LTSym
  1227. %token _NAND
  1228. %token _NESym
  1229. %token _NEXT
  1230. %token _NOR
  1231. %token _NOT
  1232. %token tok_NULL
  1233. %token _OR
  1234. %token _OUT
  1235. %token _XOR
  1236. %token ABS
  1237. %token ACCESS
  1238. %token AFTER
  1239. %token ALIAS
  1240. %token ALL
  1241. %token ARCHITECTURE
  1242. %token ARRAY
  1243. %token ASSERT
  1244. %token ATTRIBUTE
  1245. %token <text> AbstractLit
  1246. %token Ampersand
  1247. %token Apostrophe
  1248. %token Arrow
  1249. %token BIT
  1250. %token BIT_VECTOR
  1251. %token BLOCK
  1252. %token BODY
  1253. %token BUFFER
  1254. %token BUS
  1255. %token Bar
  1256. %token BasedInt
  1257. %token BasedReal
  1258. %token <text> BitStringLit
  1259. %token Box
  1260. %token CASE
  1261. %token COMPONENT
  1262. %token CONFIGURATION
  1263. %token CONSTANT
  1264. %token <text> CharacterLit
  1265. %token Colon
  1266. %token Comma
  1267. %token DISCONNECT
  1268. %token DOWNTO
  1269. %token DecimalInt
  1270. %token DecimalReal
  1271. %token Dot
  1272. %token DoubleStar
  1273. %token ELSE
  1274. %token ELSIF
  1275. %token ENTITY
  1276. %token ERROR
  1277. %token FOR
  1278. %token FS
  1279. %token FUNCTION
  1280. %token GENERATE
  1281. %token GENERIC
  1282. %token GUARDED
  1283. %token IF
  1284. %token IS
  1285. %token <text> Identifier
  1286. %token LIBRARY
  1287. %token LOOP
  1288. %token LeftParen
  1289. %token MAP
  1290. %token MOD
  1291. %token MS
  1292. %token MUX_BIT
  1293. %token MUX_VECTOR
  1294. %token Minus
  1295. %token NATURAL
  1296. %token NATURAL_VECTOR
  1297. %token NEW
  1298. %token NS
  1299. %token OF
  1300. %token ON
  1301. %token OPEN
  1302. %token OTHERS
  1303. %token _PACKAGE
  1304. %token PORT
  1305. %token PROCEDURE
  1306. %token PROCESS
  1307. %token PS
  1308. %token Plus
  1309. %token RANGE
  1310. %token RECORD
  1311. %token REG_BIT
  1312. %token REG_VECTOR
  1313. %token REGISTER
  1314. %token REM
  1315. %token REPORT
  1316. %token RETURN
  1317. %token RightParen
  1318. %token SELECT
  1319. %token SEVERITY
  1320. %token SIGNAL
  1321. %token _STABLE
  1322. %token SUBTYPE
  1323. %token Semicolon
  1324. %token Slash
  1325. %token Star
  1326. %token <text> StringLit
  1327. %token THEN
  1328. %token TO
  1329. %token TRANSPORT
  1330. %token _TYPE
  1331. %token UNITS
  1332. %token UNTIL
  1333. %token US
  1334. %token USE
  1335. %token VARIABLE
  1336. %token VarAsgn
  1337. %token WAIT
  1338. %token WARNING
  1339. %token WHEN
  1340. %token WHILE
  1341. %token WITH
  1342. %token WOR_BIT
  1343. %token WOR_VECTOR
  1344. %left tok_AND _OR _NAND _NOR _XOR
  1345. %left _EQSym _NESym
  1346. %left _NOT
  1347. %type <text> choice
  1348. %type <text> .simple_name.
  1349. %type <text> simple_name
  1350. %type <text> a_label
  1351. %type <text> .label.
  1352. %type <text> label
  1353. %type <valu> severity__message
  1354. %type <text> report__message
  1355. %type <valu> .SEVERITY__expression.
  1356. %type <text> .REPORT__expression.
  1357. %type <text> .guard_expression.
  1358. %type <text> guard_expression
  1359. %type <list> ...waveform__WHEN__choices..
  1360. %type <list> waveform__WHEN__choices
  1361. %type <list> waveform_element
  1362. %type <list> waveform
  1363. %type <list> expression
  1364. %type <valu> .GUARDED.
  1365. %type <valu> .TRANSPORT.
  1366. %type <list> relation..AND__relation..
  1367. %type <list> relation..OR__relation..
  1368. %type <list> relation.NAND_NOR__relation.
  1369. %type <list> relation..XOR__relation..
  1370. %type <list> relation
  1371. %type <list> simple_expression
  1372. %type <list> .sign.term..add_op__term..
  1373. %type <list> term
  1374. %type <list> factor
  1375. %type <list> primary
  1376. %type <valu> relational_operator
  1377. %type <text> literal
  1378. %type <list> aggregate
  1379. %type <valu> .signal_kind.
  1380. %type <valu> .mode.
  1381. %type <dble> type_mark
  1382. %type <name> .constraint.
  1383. %type <name> constraint
  1384. %type <name> range
  1385. %type <valu> direction
  1386. %type <valu> abstractlit
  1387. %type <name> name
  1388. %type <name> slice_name
  1389. %type <name> indexed_name
  1390. %type <name> target
  1391. %type <name> attribute_name
  1392. %type <valu> generic_element_association
  1393. %type <text> constant_VarAsgn__expression
  1394. %type <flov> time_unit
  1395. %type <valu> delay_expression
  1396. %type <valu> .AFTER__delay_expression.
  1397. %start design_file
  1398. %%
  1399. design_file
  1400. : /*empty*/
  1401. {
  1402. /* ###----------------------------------------------### */
  1403. /* Initializations */
  1404. /* - initialize the time unit conversion variables */
  1405. /* - erroneous description presumed ! */
  1406. /* - zero delay description presumed ! */
  1407. /* ###----------------------------------------------### */
  1408. BVL_NM1LST = NULL;
  1409. BVL_GRDLST = NULL;
  1410. BVL_CNDLST = NULL;
  1411. BVL_VALLST = NULL;
  1412. BVL_ERRFLG = 0;
  1413. switch (BEH_TIMEUNIT)
  1414. {
  1415. case BEH_TU__FS :
  1416. BVL_CNVFS = 1 ;
  1417. BVL_CNVPS = 1.0E+3 ;
  1418. BVL_CNVNS = 1.0E+6 ;
  1419. BVL_CNVUS = 1.0E+9 ;
  1420. BVL_CNVMS = 1.0E+12;
  1421. break;
  1422. case BEH_TU__PS :
  1423. BVL_CNVFS = 1.0E-3 ;
  1424. BVL_CNVPS = 1 ;
  1425. BVL_CNVNS = 1.0E+3 ;
  1426. BVL_CNVUS = 1.0E+6 ;
  1427. BVL_CNVMS = 1.0E+9 ;
  1428. break;
  1429. case BEH_TU__NS :
  1430. BVL_CNVFS = 1.0E-6 ;
  1431. BVL_CNVPS = 1.0E-3 ;
  1432. BVL_CNVNS = 1 ;
  1433. BVL_CNVUS = 1.0E+3 ;
  1434. BVL_CNVMS = 1.0E+6 ;
  1435. break;
  1436. case BEH_TU__US :
  1437. BVL_CNVFS = 1.0E-9 ;
  1438. BVL_CNVPS = 1.0E-6 ;
  1439. BVL_CNVNS = 1.0E-3 ;
  1440. BVL_CNVUS = 1 ;
  1441. BVL_CNVMS = 1.0E+3 ;
  1442. break;
  1443. case BEH_TU__MS :
  1444. BVL_CNVFS = 1.0E-12;
  1445. BVL_CNVPS = 1.0E-9 ;
  1446. BVL_CNVNS = 1.0E-6 ;
  1447. BVL_CNVUS = 1.0E-3 ;
  1448. BVL_CNVMS = 1 ;
  1449. break;
  1450. default :
  1451. BVL_CNVFS = 1 ;
  1452. BVL_CNVPS = 1 ;
  1453. BVL_CNVNS = 1 ;
  1454. BVL_CNVUS = 1 ;
  1455. BVL_CNVMS = 1 ;
  1456. bvl_error (83, NULL);
  1457. }
  1458. if (BVL_ERRFLG == 0)
  1459. {
  1460. BVL_CNVFS = BVL_CNVFS / BEH_TIMESTEP;
  1461. BVL_CNVPS = BVL_CNVPS / BEH_TIMESTEP;
  1462. BVL_CNVNS = BVL_CNVNS / BEH_TIMESTEP;
  1463. BVL_CNVUS = BVL_CNVUS / BEH_TIMESTEP;
  1464. BVL_CNVMS = BVL_CNVMS / BEH_TIMESTEP;
  1465. }
  1466. dic = beh_initab ();
  1467. BVL_BEFPNT = beh_addbefig (BVL_HEDFIG, NULL);
  1468. BVL_BEFPNT->FLAG |= BEH_FIG_ZERODELAY;
  1469. BVL_BEFPNT->ERRFLG = 1;
  1470. BVL_HEDFIG = BVL_BEFPNT;
  1471. }
  1472. entity_declaration
  1473. architecture_body
  1474. {
  1475. if (BVL_ERRFLG == 0)
  1476. BVL_BEFPNT->ERRFLG = 0;
  1477. beh_fretab (dic);
  1478. }
  1479. ;
  1480. entity_declaration
  1481. : ENTITY
  1482. simple_name
  1483. IS
  1484. {
  1485. BVL_BEFPNT->NAME = $2;
  1486. BVL_MODNAM = $2;
  1487. }
  1488. .generic_clause.
  1489. .port_clause.
  1490. END_ERR
  1491. .simple_name.
  1492. Semicolon_ERR
  1493. {
  1494. if (($8 != NULL) && ($8 != $2))
  1495. bvl_error (1, $8);
  1496. }
  1497. | ENTITY
  1498. error
  1499. {
  1500. bvl_error (2, NULL);
  1501. }
  1502. ;
  1503. .generic_clause.
  1504. : /*empty*/
  1505. | generic_clause
  1506. {
  1507. BVL_BEFPNT->BEGEN = BVL_GENPNT;
  1508. BVL_GENPNT = NULL ;
  1509. }
  1510. ;
  1511. generic_clause
  1512. : GENERIC
  1513. LeftParen
  1514. formal_generic_list
  1515. RightParen_ERR
  1516. Semicolon_ERR
  1517. | GENERIC
  1518. error
  1519. Semicolon_ERR
  1520. { bvl_error (74, NULL); }
  1521. ;
  1522. formal_generic_list
  1523. : formal_generic_element
  1524. ...formal_generic_element..
  1525. ;
  1526. ...formal_generic_element..
  1527. : /*empty*/
  1528. | ...formal_generic_element..
  1529. Semicolon_ERR
  1530. formal_generic_element
  1531. ;
  1532. formal_generic_element
  1533. : CONSTANT
  1534. identifier_list
  1535. Colon
  1536. type_mark
  1537. .constraint.
  1538. generic_VarAsgn__expression
  1539. {
  1540. char *type;
  1541. if ($5.FLAG == $4.FLAG)
  1542. {
  1543. BVL_NM1LST = reverse (BVL_NM1LST);
  1544. type = namealloc ("natural");
  1545. BVL_GENPNT = addgen (BVL_GENPNT, BVL_INTLST, BVL_NM1LST,
  1546. type, $5.LEFT, $5.RIGHT);
  1547. }
  1548. else
  1549. bvl_error (33, NULL);
  1550. freechain (BVL_NM1LST);
  1551. freechain (BVL_INTLST);
  1552. BVL_NM1LST = NULL;
  1553. BVL_INTLST = NULL;
  1554. }
  1555. | error
  1556. {
  1557. /* ###----------------------------------------------### */
  1558. /* The following 3 lines reject tokens until the */
  1559. /* sync. token 'Semicolon' is found */
  1560. /* ###----------------------------------------------### */
  1561. do
  1562. yychar = yylex ();
  1563. while ((yychar != Semicolon) && (yychar != 0));
  1564. yyerrok;
  1565. bvl_error (75, NULL);
  1566. }
  1567. ;
  1568. generic_VarAsgn__expression
  1569. : VarAsgn
  1570. generic_expression
  1571. ;
  1572. generic_expression
  1573. : abstractlit
  1574. {
  1575. long *ptlong;
  1576. ptlong = (long *) mbkalloc (sizeof(long));
  1577. *ptlong = $1;
  1578. BVL_INTLST = addchain (BVL_INTLST, (void *)ptlong);
  1579. }
  1580. | generic_aggregate
  1581. ;
  1582. generic_aggregate
  1583. : LeftParen
  1584. generic_element_association
  1585. {
  1586. long *ptlong;
  1587. ptlong = (long *) mbkalloc (sizeof(long));
  1588. *ptlong = $2;
  1589. BVL_INTLST = addchain (BVL_INTLST, (void *)ptlong);
  1590. }
  1591. ...generic_element_association..
  1592. RightParen_ERR
  1593. ;
  1594. ...generic_element_association..
  1595. : /* empty */
  1596. | ...generic_element_association..
  1597. Comma
  1598. generic_element_association
  1599. {
  1600. long *ptlong;
  1601. ptlong = (long *) mbkalloc (sizeof(long));
  1602. *ptlong = $3;
  1603. BVL_INTLST = addchain (BVL_INTLST, (void *)ptlong);
  1604. }
  1605. ;
  1606. generic_element_association
  1607. : abstractlit
  1608. {$$ = $1;}
  1609. ;
  1610. .constraint.
  1611. : /*empty*/
  1612. {
  1613. $$.FLAG = 'S';
  1614. $$.LEFT = -1;
  1615. $$.RIGHT = -1;
  1616. }
  1617. | constraint
  1618. { $$ = $1; }
  1619. ;
  1620. constraint
  1621. : LeftParen
  1622. range
  1623. RightParen_ERR
  1624. { $$ = $2; }
  1625. ;
  1626. range
  1627. : abstractlit
  1628. direction
  1629. abstractlit
  1630. {
  1631. $$.FLAG = 'A';
  1632. $$.LEFT = $1;
  1633. $$.RIGHT = $3;
  1634. if ((($1 > $3) && ($2 == BVL_UPTDFN)) ||
  1635. (($1 < $3) && ($2 == BVL_DWTDFN)) ||
  1636. (($1 < 0 ) || ($2 < 0 )))
  1637. {
  1638. bvl_error (32, NULL);
  1639. }
  1640. }
  1641. ;
  1642. direction
  1643. : TO
  1644. { $$ = BVL_UPTDFN; }
  1645. | DOWNTO
  1646. { $$ = BVL_DWTDFN; }
  1647. ;
  1648. .port_clause.
  1649. : /*empty*/
  1650. | port_clause
  1651. ;
  1652. port_clause
  1653. : PORT
  1654. LeftParen
  1655. formal_port_list
  1656. RightParen_ERR
  1657. Semicolon_ERR
  1658. | PORT
  1659. error
  1660. Semicolon_ERR
  1661. { bvl_error (3, NULL); }
  1662. ;
  1663. formal_port_list
  1664. : formal_port_element
  1665. ...formal_port_element..
  1666. ;
  1667. ...formal_port_element..
  1668. : /*empty*/
  1669. | ...formal_port_element..
  1670. Semicolon_ERR
  1671. formal_port_element
  1672. ;
  1673. formal_port_element
  1674. : .SIGNAL.
  1675. identifier_list
  1676. Colon
  1677. .mode.
  1678. type_mark
  1679. .constraint.
  1680. .signal_kind.
  1681. {
  1682. char *signame;
  1683. long sigconf;
  1684. void *pnt;
  1685. /* ###----------------------------------------------### */
  1686. /* First, check the validity of the declaration. */
  1687. /* Then, for each port, create the apropriate set of */
  1688. /* structures (berin, bepor, beout, bebus) */
  1689. /* ###----------------------------------------------### */
  1690. chkdcl ('P', $4, $5.VALU, $5.FLAG, $7, $6.FLAG, &sigconf);
  1691. BVL_NM1LST = reverse (BVL_NM1LST);
  1692. while (BVL_NM1LST != NULL)
  1693. {
  1694. signame = (char *)BVL_NM1LST->DATA;
  1695. if (beh_chktab (dic, signame, BVL_MODNAM, BVL_SIGDFN) != 0)
  1696. bvl_error (4, signame);
  1697. pnt = addstr (BVL_BEFPNT, 'P', $4, $5.VALU, $5.FLAG, signame,
  1698. $6.LEFT, $6.RIGHT);
  1699. beh_addtab (dic, signame, BVL_MODNAM, BVL_SIGDFN, sigconf);
  1700. beh_addtab (dic, signame, BVL_MODNAM, BVL_WMNDFN, $6.LEFT);
  1701. beh_addtab (dic, signame, BVL_MODNAM, BVL_WMXDFN, $6.RIGHT);
  1702. beh_addtab (dic, signame, BVL_MODNAM, BVL_PNTDFN, (long)pnt);
  1703. BVL_NM1LST = delchain (BVL_NM1LST, BVL_NM1LST);
  1704. }
  1705. }
  1706. | error
  1707. {
  1708. /* ###----------------------------------------------### */
  1709. /* The following 3 lines reject tokens until the */
  1710. /* sync. token 'Semicolon' is found */
  1711. /* ###----------------------------------------------### */
  1712. do
  1713. yychar = yylex ();
  1714. while ((yychar != Semicolon) && (yychar != 0));
  1715. yyerrok;
  1716. bvl_error (6, NULL);
  1717. }
  1718. ;
  1719. .SIGNAL.
  1720. : /*empty*/
  1721. | SIGNAL
  1722. ;
  1723. .mode.
  1724. : /*empty*/
  1725. { $$ = _IN; }
  1726. | _IN
  1727. { $$ = _IN; }
  1728. | _OUT
  1729. { $$ = _OUT; }
  1730. | _INOUT
  1731. { $$ = _INOUT; }
  1732. ;
  1733. architecture_body
  1734. : ARCHITECTURE
  1735. Identifier
  1736. OF
  1737. simple_name
  1738. IS
  1739. {
  1740. if ($4 != BVL_MODNAM)
  1741. bvl_error (1, $4);
  1742. }
  1743. architecture_declarative_part
  1744. _BEGIN
  1745. architecture_statement_part
  1746. END_ERR
  1747. .simple_name.
  1748. Semicolon_ERR
  1749. {
  1750. if (($11 != NULL) && ($11 != $2))
  1751. bvl_error (7, $11);
  1752. }
  1753. | ARCHITECTURE
  1754. error
  1755. { bvl_error (8, NULL); }
  1756. ;
  1757. architecture_declarative_part
  1758. : ..block_declarative_item..
  1759. ;
  1760. ..block_declarative_item..
  1761. : /*empty*/
  1762. | ..block_declarative_item..
  1763. block_declarative_item
  1764. ;
  1765. block_declarative_item
  1766. : signal_declaration
  1767. | constant_declaration
  1768. | error
  1769. Semicolon_ERR
  1770. { bvl_error (9, NULL); }
  1771. ;
  1772. constant_declaration
  1773. : CONSTANT
  1774. Identifier
  1775. Colon
  1776. type_mark
  1777. .constraint.
  1778. constant_VarAsgn__expression
  1779. Semicolon_ERR
  1780. {
  1781. long sigconf;
  1782. if (chkdcl ('C', 0, $4.VALU, $4.FLAG, 0, $5.FLAG, &sigconf)==0)
  1783. {
  1784. beh_addtab (dic, $2, BVL_MODNAM, BVL_WMNDFN, $5.LEFT);
  1785. beh_addtab (dic, $2, BVL_MODNAM, BVL_WMXDFN, $5.RIGHT);
  1786. beh_addtab (dic, $2, BVL_MODNAM, BVL_SIGDFN, sigconf);
  1787. beh_addtab (dic, $2, NULL, BVL_PNTDFN, $6);
  1788. }
  1789. }
  1790. ;
  1791. constant_VarAsgn__expression
  1792. : VarAsgn
  1793. literal
  1794. { $$ = $2; }
  1795. ;
  1796. signal_declaration
  1797. : SIGNAL
  1798. identifier_list
  1799. Colon
  1800. type_mark
  1801. .constraint.
  1802. .signal_kind.
  1803. Semicolon_ERR
  1804. {
  1805. char *signame;
  1806. long sigconf;
  1807. void *pnt;
  1808. long errflg;
  1809. errflg = chkdcl ('S',0,$4.VALU,$4.FLAG,$6,$5.FLAG,&sigconf);
  1810. /* ###----------------------------------------------### */
  1811. /* First, check the validity of the declaration. */
  1812. /* Then, for each signal, create the apropriate set of */
  1813. /* structures (berin, bereg, beaux, bebux) */
  1814. /* ###----------------------------------------------### */
  1815. BVL_NM1LST = reverse (BVL_NM1LST);
  1816. while (BVL_NM1LST != NULL)
  1817. {
  1818. signame = (char *)BVL_NM1LST->DATA;
  1819. if (beh_chktab (dic, signame, BVL_MODNAM, BVL_SIGDFN) != 0)
  1820. bvl_error (10, signame);
  1821. pnt = addstr (BVL_BEFPNT, 'S', 0, $4.VALU, $4.FLAG, signame,
  1822. $5.LEFT, $5.RIGHT);
  1823. beh_addtab (dic, signame, BVL_MODNAM, BVL_SIGDFN, sigconf);
  1824. beh_addtab (dic, signame, BVL_MODNAM, BVL_WMNDFN, $5.LEFT);
  1825. beh_addtab (dic, signame, BVL_MODNAM, BVL_WMXDFN, $5.RIGHT);
  1826. beh_addtab (dic, signame, BVL_MODNAM, BVL_PNTDFN, (long)pnt);
  1827. BVL_NM1LST = delchain (BVL_NM1LST, BVL_NM1LST);
  1828. }
  1829. }
  1830. ;
  1831. .signal_kind.
  1832. : /*empty*/
  1833. { $$ = 0; }
  1834. | REGISTER
  1835. { $$ = REGISTER; }
  1836. | BUS
  1837. { $$ = BUS; }
  1838. ;
  1839. architecture_statement_part
  1840. : ..concurrent_statement..
  1841. ;
  1842. ..concurrent_statement..
  1843. : /*empty*/
  1844. | ..concurrent_statement..
  1845. concurrent_statement
  1846. ;
  1847. concurrent_statement
  1848. : block_statement
  1849. | concurrent_assertion_statement
  1850. | concurrent_signal_assignment_statement
  1851. | error
  1852. Semicolon_ERR
  1853. { bvl_error (18, NULL); }
  1854. ;
  1855. block_statement
  1856. : a_label
  1857. BLOCK
  1858. .guard_expression.
  1859. _BEGIN
  1860. {
  1861. if (beh_chktab (dic, $1, BVL_MODNAM, BVL_LBLDFN) != 0)
  1862. bvl_error (19, $1);
  1863. beh_addtab (dic, $1, BVL_MODNAM, BVL_LBLDFN, 1);
  1864. if ($3 != NULL)
  1865. BVL_GRDLST = addchain (BVL_GRDLST, (char *)$3);
  1866. }
  1867. set_of_statements
  1868. END_ERR
  1869. BLOCK
  1870. .label.
  1871. Semicolon_ERR
  1872. {
  1873. if ($3 != NULL)
  1874. BVL_GRDLST = delchain (BVL_GRDLST, BVL_GRDLST);
  1875. if (($9 != NULL) && ($9 != $1))
  1876. bvl_error (20, $9);
  1877. }
  1878. ;
  1879. set_of_statements
  1880. : ..concurrent_statement..
  1881. ;
  1882. concurrent_assertion_statement
  1883. : a_label
  1884. unlabeled_concurrent_assertion_statement
  1885. {
  1886. if (beh_chktab (dic, $1, BVL_MODNAM, BVL_LBLDFN) != 0)
  1887. bvl_error (19, $1);
  1888. beh_addtab (dic, $1, BVL_MODNAM, BVL_LBLDFN, 1);
  1889. if (BVL_ERRFLG == 0)
  1890. BVL_BEFPNT->BEMSG->LABEL = $1;
  1891. }
  1892. | unlabeled_concurrent_assertion_statement
  1893. ;
  1894. concurrent_signal_assignment_statement
  1895. : a_label
  1896. unlabeled_conditional_signal_assignment
  1897. {
  1898. if (beh_chktab (dic, $1, BVL_MODNAM, BVL_LBLDFN) != 0)
  1899. bvl_error (19, $1);
  1900. beh_addtab (dic, $1, BVL_MODNAM, BVL_LBLDFN, 1);
  1901. }
  1902. | unlabeled_conditional_signal_assignment
  1903. | a_label
  1904. unlabeled_selected_signal_assignment
  1905. {
  1906. if (beh_chktab (dic, $1, BVL_MODNAM, BVL_LBLDFN) != 0)
  1907. bvl_error (19, $1);
  1908. beh_addtab (dic, $1, BVL_MODNAM, BVL_LBLDFN, 1);
  1909. }
  1910. | unlabeled_selected_signal_assignment
  1911. ;
  1912. unlabeled_concurrent_assertion_statement
  1913. : assertion_statement
  1914. ;
  1915. assertion_statement
  1916. : ASSERT
  1917. expression
  1918. .REPORT__expression.
  1919. .SEVERITY__expression.
  1920. Semicolon_ERR
  1921. {
  1922. if (BVL_ERRFLG == 0)
  1923. {
  1924. BVL_BEFPNT->BEMSG = beh_addbemsg(BVL_BEFPNT->BEMSG, NULL, $4,
  1925. $3, $2.LIST_ABL->DATA, NULL);
  1926. }
  1927. }
  1928. ;
  1929. unlabeled_conditional_signal_assignment
  1930. : target
  1931. _LESym
  1932. .GUARDED.
  1933. .TRANSPORT.
  1934. ..waveform__WHEN__condition__ELSE..
  1935. waveform
  1936. Semicolon_ERR
  1937. {
  1938. long i ;
  1939. struct beout *beout_pnt;
  1940. struct bebus *bebus_pnt;
  1941. struct bereg *bereg_pnt;
  1942. struct beaux *beaux_pnt;
  1943. struct bebux *bebux_pnt;
  1944. struct chain *abl_pnt ;
  1945. unsigned long delay ;
  1946. struct bvl_expr expr0 ;
  1947. struct bvl_expr expr1 ;
  1948. struct bvl_expr expr2 ;
  1949. struct bvl_expr expr3 ;
  1950. struct bvl_expr expr4 ;
  1951. struct bvl_expr expr5 ;
  1952. struct bvl_expr expr6 ;
  1953. long rev_flg = 0;
  1954. long left_bnd ;
  1955. long right_bnd;
  1956. long left ;
  1957. long right ;
  1958. long in_bound ;
  1959. long out_bound;
  1960. long sig_width;
  1961. long sig_conf ;
  1962. delay = $6.TIME;
  1963. expr4 = $6 ;
  1964. while (BVL_CNDLST != NULL)
  1965. {
  1966. expr5 = *((bvl_ablstr *) BVL_CNDLST->DATA);
  1967. expr6 = *((bvl_ablstr *) BVL_VALLST->DATA);
  1968. expr0 = cpyablstr (expr5);
  1969. expr1 = crtabl (NOT , expr5, BVL_EMPSTR, -1, -1);
  1970. expr5 = expr0;
  1971. expr2 = crtabl (ANDM, expr4, expr1 , -1, -1);
  1972. expr3 = crtabl (ANDM, expr6, expr5 , -1, -1);
  1973. expr4 = crtabl (OR , expr2, expr3 , -1, -1);
  1974. BVL_CNDLST = delchain (BVL_CNDLST, BVL_CNDLST);
  1975. BVL_VALLST = delchain (BVL_VALLST, BVL_VALLST);
  1976. }
  1977. left_bnd = beh_chktab (dic, $1.NAME, BVL_MODNAM, BVL_WMNDFN);
  1978. right_bnd = beh_chktab (dic, $1.NAME, BVL_MODNAM, BVL_WMXDFN);
  1979. sig_conf = beh_chktab (dic, $1.NAME, BVL_MODNAM, BVL_SIGDFN);
  1980. left = $1.LEFT ;
  1981. right = $1.RIGHT;
  1982. if (left_bnd <= right_bnd)
  1983. {
  1984. sig_width = right_bnd - left_bnd + 1;
  1985. if (left <= right)
  1986. {
  1987. rev_flg = 0;
  1988. in_bound = right_bnd - right;
  1989. out_bound = right_bnd - left ;
  1990. if ((left < left_bnd) || (right > right_bnd))
  1991. bvl_error (36, $1.NAME);
  1992. }
  1993. else
  1994. {
  1995. rev_flg = 1;
  1996. in_bound = right_bnd - left ;
  1997. out_bound = right_bnd - right;
  1998. if ((left > right_bnd) || (right < left_bnd))
  1999. bvl_error (36, $1.NAME);
  2000. }
  2001. }
  2002. else
  2003. {
  2004. sig_width = left_bnd - right_bnd + 1;
  2005. if (left <= right)
  2006. {
  2007. rev_flg = 1;
  2008. in_bound = left - right_bnd;
  2009. out_bound = right - right_bnd;
  2010. if ((left < right_bnd) || (right > left_bnd))
  2011. bvl_error (36, $1.NAME);
  2012. }
  2013. else
  2014. {
  2015. rev_flg = 0;
  2016. in_bound = right - right_bnd;
  2017. out_bound = left - right_bnd;
  2018. if ((left > left_bnd) || (right < right_bnd))
  2019. bvl_error (36, $1.NAME);
  2020. }
  2021. }
  2022. if ((out_bound - in_bound + 1) != expr4.WIDTH)
  2023. bvl_error (35, $1.NAME);
  2024. if (rev_flg == 1)
  2025. expr4.LIST_ABL = reverse (expr4.LIST_ABL);
  2026. abl_pnt = expr4.LIST_ABL;
  2027. switch (sig_conf)
  2028. {
  2029. case (BVL_ICNDFN + BVL_BITDFN + BVL_NORDFN) :
  2030. bvl_error (21, $1.NAME);
  2031. break;
  2032. case (BVL_OCNDFN + BVL_BITDFN + BVL_NORDFN) :
  2033. case (BVL_BCNDFN + BVL_BITDFN + BVL_NORDFN) :
  2034. if ($3 == BVL_GRDDFN)
  2035. bvl_error (22, $1.NAME);
  2036. beout_pnt = (struct beout *)
  2037. beh_chktab (dic,$1.NAME,BVL_MODNAM,BVL_PNTDFN);
  2038. if (BVL_ERRFLG == 0)
  2039. {
  2040. for (i=0 ; i<sig_width ; i++)
  2041. {
  2042. if (i >= in_bound)
  2043. {
  2044. if (beout_pnt->ABL != NULL)
  2045. bvl_error (39, beout_pnt->NAME);
  2046. else
  2047. {
  2048. beout_pnt->ABL = (struct chain *) abl_pnt->DATA;
  2049. beout_pnt->TIME = delay;
  2050. beout_pnt->FLAG = $4 ;
  2051. }
  2052. abl_pnt = abl_pnt->NEXT;
  2053. }
  2054. if (i >= out_bound)
  2055. break;
  2056. beout_pnt = beout_pnt->NEXT;
  2057. }
  2058. }
  2059. break;
  2060. case (BVL_OCNDFN + BVL_MUXDFN + BVL_BUSDFN) :
  2061. case (BVL_OCNDFN + BVL_WORDFN + BVL_BUSDFN) :
  2062. case (BVL_BCNDFN + BVL_MUXDFN + BVL_BUSDFN) :
  2063. case (BVL_BCNDFN + BVL_WORDFN + BVL_BUSDFN) :
  2064. if (($3 != BVL_GRDDFN) || (BVL_GRDLST == NULL))
  2065. bvl_error (23, $1.NAME);
  2066. bebus_pnt = (struct bebus *)
  2067. beh_chktab (dic,$1.NAME,BVL_MODNAM,BVL_PNTDFN);
  2068. if (BVL_ERRFLG == 0)
  2069. {
  2070. for (i=0 ; i<sig_width ; i++)
  2071. {
  2072. if (i >= in_bound)
  2073. {
  2074. bebus_pnt->BINODE = beh_addbinode (bebus_pnt->BINODE,
  2075. NULL, NULL);
  2076. bebus_pnt->BINODE->TIME = delay;
  2077. bebus_pnt->BINODE->FLAG = $4 ;
  2078. bebus_pnt->BIABL = beh_addbiabl (bebus_pnt->BIABL,
  2079. BVL_LBLNAM,
  2080. copyExpr(BVL_GRDLST->DATA) ,
  2081. abl_pnt->DATA);
  2082. bebus_pnt->BIABL->TIME = delay;
  2083. bebus_pnt->BIABL->FLAG = $4 ;
  2084. abl_pnt = abl_pnt->NEXT;
  2085. }
  2086. if (i >= out_bound)
  2087. break;
  2088. bebus_pnt = bebus_pnt->NEXT;
  2089. }
  2090. }
  2091. break;
  2092. case (BVL_BITDFN + BVL_NORDFN):
  2093. if ($3 == BVL_GRDDFN)
  2094. bvl_error (22, $1.NAME);
  2095. beaux_pnt = (struct beaux *)
  2096. beh_chktab (dic,$1.NAME,BVL_MODNAM,BVL_PNTDFN);
  2097. if (BVL_ERRFLG == 0)
  2098. {
  2099. for (i=0 ; i<sig_width ; i++)
  2100. {
  2101. if (i >= in_bound)
  2102. {
  2103. if (beaux_pnt->ABL != NULL)
  2104. bvl_error (39, beaux_pnt->NAME);
  2105. else
  2106. {
  2107. beaux_pnt->ABL = (struct chain *) abl_pnt->DATA;
  2108. beaux_pnt->TIME = delay;
  2109. beaux_pnt->FLAG = $4 ;
  2110. }
  2111. abl_pnt = abl_pnt->NEXT;
  2112. }
  2113. if (i >= out_bound)
  2114. break;
  2115. beaux_pnt = beaux_pnt->NEXT;
  2116. }
  2117. }
  2118. break;
  2119. case (BVL_RBIDFN + BVL_REGDFN):
  2120. if (($3 != BVL_GRDDFN) || (BVL_GRDLST == NULL))
  2121. bvl_error (23, $1.NAME);
  2122. bereg_pnt = (struct bereg *)
  2123. beh_chktab (dic,$1.NAME,BVL_MODNAM,BVL_PNTDFN);
  2124. if (BVL_ERRFLG == 0)
  2125. {
  2126. for (i=0 ; i<sig_width ; i++)
  2127. {
  2128. if (i >= in_bound)
  2129. {
  2130. bereg_pnt->BINODE = beh_addbinode (bereg_pnt->BINODE,
  2131. NULL, NULL);
  2132. bereg_pnt->BINODE->TIME = delay;
  2133. bereg_pnt->BINODE->FLAG = $4 ;
  2134. bereg_pnt->BIABL = beh_addbiabl (bereg_pnt->BIABL,
  2135. BVL_LBLNAM,
  2136. copyExpr(BVL_GRDLST->DATA) ,
  2137. abl_pnt->DATA);
  2138. bereg_pnt->BIABL->TIME = delay;
  2139. bereg_pnt->BIABL->FLAG = $4 ;
  2140. abl_pnt = abl_pnt->NEXT;
  2141. }
  2142. if (i >= out_bound)
  2143. break;
  2144. bereg_pnt = bereg_pnt->NEXT;
  2145. }
  2146. }
  2147. break;
  2148. case (BVL_MUXDFN + BVL_BUSDFN) :
  2149. case (BVL_WORDFN + BVL_BUSDFN) :
  2150. if (($3 != BVL_GRDDFN) || (BVL_GRDLST == NULL))
  2151. bvl_error (23, $1.NAME);
  2152. bebux_pnt = (struct bebux *)
  2153. beh_chktab (dic,$1.NAME,BVL_MODNAM,BVL_PNTDFN);
  2154. if (BVL_ERRFLG == 0)
  2155. {
  2156. for (i=0 ; i<sig_width ; i++)
  2157. {
  2158. if (i >= in_bound)
  2159. {
  2160. bebux_pnt->BINODE = beh_addbinode (bebux_pnt->BINODE,
  2161. NULL, NULL);
  2162. bebux_pnt->BINODE->TIME = delay;
  2163. bebux_pnt->BINODE->FLAG = $4 ;
  2164. bebux_pnt->BIABL = beh_addbiabl (bebux_pnt->BIABL,
  2165. BVL_LBLNAM,
  2166. copyExpr(BVL_GRDLST->DATA) ,
  2167. abl_pnt->DATA);
  2168. bebux_pnt->BIABL->TIME = delay;
  2169. bebux_pnt->BIABL->FLAG = $4 ;
  2170. abl_pnt = abl_pnt->NEXT;
  2171. }
  2172. if (i >= out_bound)
  2173. break;
  2174. bebux_pnt = bebux_pnt->NEXT;
  2175. }
  2176. }
  2177. break;
  2178. default :
  2179. bvl_error (17, $1.NAME);
  2180. break;
  2181. }
  2182. }
  2183. ;
  2184. ..waveform__WHEN__condition__ELSE..
  2185. : /*empty*/
  2186. | ..waveform__WHEN__condition__ELSE..
  2187. waveform
  2188. WHEN
  2189. expression
  2190. ELSE
  2191. {
  2192. struct bvl_expr *expr_pnt;
  2193. expr_pnt = (bvl_ablstr *)mbkalloc(sizeof(bvl_ablstr));
  2194. expr_pnt->WIDTH = $4.WIDTH;
  2195. expr_pnt->LIST_ABL = $4.LIST_ABL;
  2196. BVL_CNDLST = addchain (BVL_CNDLST, (char *) expr_pnt);
  2197. expr_pnt = (bvl_ablstr *)mbkalloc(sizeof(bvl_ablstr));
  2198. expr_pnt->WIDTH = $2.WIDTH;
  2199. expr_pnt->LIST_ABL = $2.LIST_ABL;
  2200. BVL_VALLST = addchain (BVL_VALLST, (char *) expr_pnt);
  2201. }
  2202. ;
  2203. unlabeled_selected_signal_assignment
  2204. : WITH
  2205. expression
  2206. {
  2207. BVL_SLCEXP = $2;
  2208. BVL_BDDPNT = NULL;
  2209. }
  2210. SELECT
  2211. target
  2212. _LESym
  2213. .GUARDED.
  2214. .TRANSPORT.
  2215. waveform__WHEN__choices
  2216. ...waveform__WHEN__choices..
  2217. Semicolon_ERR
  2218. {
  2219. long i;
  2220. struct beout *beout_pnt;
  2221. struct bebus *bebus_pnt;
  2222. struct bereg *bereg_pnt;
  2223. struct beaux *beaux_pnt;
  2224. struct bebux *bebux_pnt;
  2225. struct chain *abl_pnt ;
  2226. unsigned long delay ;
  2227. struct bvl_expr expr1 ;
  2228. long rev_flg = 0;
  2229. long left_bnd;
  2230. long right_bnd;
  2231. long left;
  2232. long right;
  2233. long in_bound;
  2234. long out_bound;
  2235. long sig_width;
  2236. long sig_conf;
  2237. /* ###----------------------------------------------### */
  2238. /* $10 est une structure, pas un pointeur... */
  2239. /* et c'est bien la le probleme............ */
  2240. /* Pour BVL_EMPSTR le champs LIST_ABL doit etre NULL */
  2241. /* ###----------------------------------------------### */
  2242. if (($10.LIST_ABL != NULL) && ($9.TIME != $10.TIME))
  2243. {
  2244. bvl_error (80, NULL);
  2245. }
  2246. expr1 = crtabl (OR , $9 , $10, -1, -1);
  2247. expr1.TIME = $9.TIME;
  2248. if (BVL_BDDPNT != one)
  2249. bvl_error (25, NULL);
  2250. left_bnd = beh_chktab (dic, $5.NAME, BVL_MODNAM, BVL_WMNDFN);
  2251. right_bnd = beh_chktab (dic, $5.NAME, BVL_MODNAM, BVL_WMXDFN);
  2252. sig_conf = beh_chktab (dic, $5.NAME, BVL_MODNAM, BVL_SIGDFN);
  2253. left = $5.LEFT ;
  2254. right = $5.RIGHT;
  2255. if (left_bnd <= right_bnd)
  2256. {
  2257. sig_width = right_bnd - left_bnd + 1;
  2258. if (left <= right)
  2259. {
  2260. rev_flg = 0;
  2261. in_bound = right_bnd - right;
  2262. out_bound = right_bnd - left ;
  2263. if ((left < left_bnd) || (right > right_bnd))
  2264. bvl_error (36, $5.NAME);
  2265. }
  2266. else
  2267. {
  2268. rev_flg = 1;
  2269. in_bound = right_bnd - left ;
  2270. out_bound = right_bnd - right;
  2271. if ((left > right_bnd) || (right < left_bnd))
  2272. bvl_error (36, $5.NAME);
  2273. }
  2274. }
  2275. else
  2276. {
  2277. sig_width = left_bnd - right_bnd + 1;
  2278. if (left <= right)
  2279. {
  2280. rev_flg = 1;
  2281. in_bound = left - right_bnd;
  2282. out_bound = right - right_bnd;
  2283. if ((left < right_bnd) || (right > left_bnd))
  2284. bvl_error (36, $5.NAME);
  2285. }
  2286. else
  2287. {
  2288. rev_flg = 0;
  2289. in_bound = right - right_bnd;
  2290. out_bound = left - right_bnd;
  2291. if ((left > left_bnd) || (right < right_bnd))
  2292. bvl_error (36, $5.NAME);
  2293. }
  2294. }
  2295. if ((out_bound - in_bound + 1) != expr1.WIDTH)
  2296. bvl_error (35, $5.NAME);
  2297. if (rev_flg == 1)
  2298. expr1.LIST_ABL = reverse (expr1.LIST_ABL);
  2299. abl_pnt = expr1.LIST_ABL;
  2300. delay = expr1.TIME ;
  2301. switch (sig_conf)
  2302. {
  2303. case (BVL_ICNDFN + BVL_BITDFN + BVL_NORDFN) :
  2304. bvl_error (21, $5.NAME);
  2305. break;
  2306. case (BVL_OCNDFN + BVL_BITDFN + BVL_NORDFN) :
  2307. case (BVL_BCNDFN + BVL_BITDFN + BVL_NORDFN) :
  2308. if ($7 == BVL_GRDDFN)
  2309. bvl_error (22, $5.NAME);
  2310. beout_pnt = (struct beout *)
  2311. beh_chktab (dic,$5.NAME,BVL_MODNAM,BVL_PNTDFN);
  2312. if (BVL_ERRFLG == 0)
  2313. {
  2314. for (i=0 ; i<sig_width ; i++)
  2315. {
  2316. if (i >= in_bound)
  2317. {
  2318. if (beout_pnt->ABL != NULL)
  2319. bvl_error (39, beout_pnt->NAME);
  2320. else
  2321. {
  2322. beout_pnt->ABL = (struct chain *)abl_pnt->DATA;
  2323. beout_pnt->TIME = delay;
  2324. }
  2325. abl_pnt = abl_pnt->NEXT;
  2326. }
  2327. if (i >= out_bound)
  2328. break;
  2329. beout_pnt = beout_pnt->NEXT;
  2330. }
  2331. }
  2332. break;
  2333. case (BVL_OCNDFN + BVL_MUXDFN + BVL_BUSDFN) :
  2334. case (BVL_OCNDFN + BVL_WORDFN + BVL_BUSDFN) :
  2335. case (BVL_BCNDFN + BVL_MUXDFN + BVL_BUSDFN) :
  2336. case (BVL_BCNDFN + BVL_WORDFN + BVL_BUSDFN) :
  2337. if (($7 != BVL_GRDDFN) || (BVL_GRDLST == NULL))
  2338. bvl_error (23, $5.NAME);
  2339. bebus_pnt = (struct bebus *)
  2340. beh_chktab (dic,$5.NAME,BVL_MODNAM,BVL_PNTDFN);
  2341. if (BVL_ERRFLG == 0)
  2342. {
  2343. for (i=0 ; i<sig_width ; i++)
  2344. {
  2345. if (i >= in_bound)
  2346. {
  2347. bebus_pnt->BINODE = beh_addbinode (bebus_pnt->BINODE,
  2348. NULL, NULL);
  2349. bebus_pnt->BINODE->TIME = delay;
  2350. bebus_pnt->BINODE->FLAG = $8 ;
  2351. bebus_pnt->BIABL = beh_addbiabl (bebus_pnt->BIABL,
  2352. BVL_LBLNAM,
  2353. copyExpr(BVL_GRDLST->DATA) ,
  2354. abl_pnt->DATA);
  2355. bebus_pnt->BIABL->TIME = delay;
  2356. bebus_pnt->BIABL->FLAG = $8 ;
  2357. abl_pnt = abl_pnt->NEXT;
  2358. }
  2359. if (i >= out_bound)
  2360. break;
  2361. bebus_pnt = bebus_pnt->NEXT;
  2362. }
  2363. }
  2364. break;
  2365. case (BVL_BITDFN + BVL_NORDFN):
  2366. if ($7 == BVL_GRDDFN)
  2367. bvl_error (22, $5.NAME);
  2368. beaux_pnt = (struct beaux *)
  2369. beh_chktab (dic,$5.NAME,BVL_MODNAM,BVL_PNTDFN);
  2370. if (BVL_ERRFLG == 0)
  2371. {
  2372. for (i=0 ; i<sig_width ; i++)
  2373. {
  2374. if (i >= in_bound)
  2375. {
  2376. if (beaux_pnt->ABL != NULL)
  2377. bvl_error (39, beaux_pnt->NAME);
  2378. else
  2379. {
  2380. beaux_pnt->ABL = (struct chain *) abl_pnt->DATA;
  2381. beaux_pnt->TIME = delay;
  2382. beaux_pnt->FLAG = $8 ;
  2383. }
  2384. abl_pnt = abl_pnt->NEXT;
  2385. }
  2386. if (i >= out_bound)
  2387. break;
  2388. beaux_pnt = beaux_pnt->NEXT;
  2389. }
  2390. }
  2391. break;
  2392. case (BVL_RBIDFN + BVL_REGDFN):
  2393. if (($7 != BVL_GRDDFN) || (BVL_GRDLST == NULL))
  2394. bvl_error (23, $5.NAME);
  2395. bereg_pnt = (struct bereg *)
  2396. beh_chktab (dic,$5.NAME,BVL_MODNAM,BVL_PNTDFN);
  2397. if (BVL_ERRFLG == 0)
  2398. {
  2399. for (i=0 ; i<sig_width ; i++)
  2400. {
  2401. if (i >= in_bound)
  2402. {
  2403. bereg_pnt->BINODE = beh_addbinode (bereg_pnt->BINODE,
  2404. NULL, NULL);
  2405. bereg_pnt->BINODE->TIME = delay;
  2406. bereg_pnt->BINODE->FLAG = $8 ;
  2407. bereg_pnt->BIABL = beh_addbiabl (bereg_pnt->BIABL,
  2408. BVL_LBLNAM,
  2409. copyExpr(BVL_GRDLST->DATA) ,
  2410. abl_pnt->DATA);
  2411. bereg_pnt->BIABL->TIME = delay;
  2412. bereg_pnt->BIABL->FLAG = $8 ;
  2413. abl_pnt = abl_pnt->NEXT;
  2414. }
  2415. if (i >= out_bound)
  2416. break;
  2417. bereg_pnt = bereg_pnt->NEXT;
  2418. }
  2419. }
  2420. break;
  2421. case (BVL_MUXDFN + BVL_BUSDFN) :
  2422. case (BVL_WORDFN + BVL_BUSDFN) :
  2423. if (($7 != BVL_GRDDFN) || (BVL_GRDLST == NULL))
  2424. bvl_error (23, $5.NAME);
  2425. bebux_pnt = (struct bebux *)
  2426. beh_chktab (dic,$5.NAME,BVL_MODNAM,BVL_PNTDFN);
  2427. if (BVL_ERRFLG == 0)
  2428. {
  2429. for (i=0 ; i<sig_width ; i++)
  2430. {
  2431. if (i >= in_bound)
  2432. {
  2433. bebux_pnt->BINODE = beh_addbinode (bebux_pnt->BINODE,
  2434. NULL, NULL);
  2435. bebux_pnt->BINODE->TIME = delay;
  2436. bebux_pnt->BINODE->FLAG = $8 ;
  2437. bebux_pnt->BIABL = beh_addbiabl (bebux_pnt->BIABL,
  2438. BVL_LBLNAM,
  2439. copyExpr(BVL_GRDLST->DATA) ,
  2440. abl_pnt->DATA);
  2441. bebux_pnt->BIABL->TIME = delay;
  2442. bebux_pnt->BIABL->FLAG = $8 ;
  2443. abl_pnt = abl_pnt->NEXT;
  2444. }
  2445. if (i >= out_bound)
  2446. break;
  2447. bebux_pnt = bebux_pnt->NEXT;
  2448. }
  2449. }
  2450. break;
  2451. default :
  2452. bvl_error (17, $5.NAME);
  2453. break;
  2454. }
  2455. }
  2456. ;
  2457. ...waveform__WHEN__choices..
  2458. : /*empty*/
  2459. { $$ = BVL_EMPSTR; }
  2460. | ...waveform__WHEN__choices..
  2461. Comma
  2462. waveform__WHEN__choices
  2463. {
  2464. /* ###----------------------------------------------### */
  2465. /* $9 est une structure, pas un pointeur... */
  2466. /* et c'est bien la le probleme............ */
  2467. /* Pour BVL_EMPSTR le champs LIST_ABL doit etre NULL */
  2468. /* ###----------------------------------------------### */
  2469. if (($1.LIST_ABL != NULL) && ($1.TIME != $3.TIME))
  2470. {
  2471. bvl_error (80, NULL);
  2472. }
  2473. $$ = crtabl (OR, $1, $3, -1, -1);
  2474. $$.TIME = $3.TIME;
  2475. }
  2476. ;
  2477. waveform__WHEN__choices
  2478. : waveform
  2479. WHEN
  2480. choices
  2481. {
  2482. struct bvl_expr expr1;
  2483. bvl_select (&expr1, BVL_NM1LST, &BVL_BDDPNT, BVL_SLCEXP);
  2484. freechain (BVL_NM1LST);
  2485. BVL_NM1LST = NULL;
  2486. $$ = crtabl (ANDM, $1, expr1, -1, -1);
  2487. $$.TIME = $1.TIME;
  2488. }
  2489. ;
  2490. waveform
  2491. : waveform_element
  2492. { $$ = $1; }
  2493. ;
  2494. waveform_element
  2495. : expression
  2496. .AFTER__delay_expression.
  2497. {
  2498. $$ = $1;
  2499. $$.TIME = $2;
  2500. }
  2501. ;
  2502. .AFTER__delay_expression.
  2503. : /*empty*/
  2504. { $$ = 0; }
  2505. | AFTER
  2506. delay_expression
  2507. { $$ = $2; }
  2508. ;
  2509. delay_expression
  2510. : abstractlit
  2511. time_unit
  2512. {
  2513. unsigned long dly;
  2514. /* ###----------------------------------------------### */
  2515. /* if the delay is not null unset the 'zero delay' */
  2516. /* flag of the description */
  2517. /* ###----------------------------------------------### */
  2518. dly = $1 * $2;
  2519. if (dly != 0)
  2520. BVL_BEFPNT->FLAG &= ~BEH_FIG_ZERODELAY;
  2521. $$ = dly;
  2522. }
  2523. ;
  2524. time_unit
  2525. : FS
  2526. { $$ = BVL_CNVFS ; }
  2527. | PS
  2528. { $$ = BVL_CNVPS ; }
  2529. | NS
  2530. { $$ = BVL_CNVNS ; }
  2531. | US
  2532. { $$ = BVL_CNVUS ; }
  2533. | MS
  2534. { $$ = BVL_CNVMS ; }
  2535. ;
  2536. choices
  2537. : choice
  2538. { BVL_NM1LST = addchain (NULL, $1); }
  2539. ..Bar__choice..
  2540. { yyerrok; }
  2541. ;
  2542. ..Bar__choice..
  2543. : /*empty*/
  2544. | ..Bar__choice..
  2545. Bar
  2546. choice
  2547. {
  2548. if ($3 == "others")
  2549. bvl_error (30, NULL);
  2550. BVL_NM1LST = addchain (BVL_NM1LST, $3);
  2551. }
  2552. ;
  2553. choice
  2554. : literal
  2555. { $$ = $1; }
  2556. | OTHERS
  2557. { $$ = "others"; }
  2558. | name
  2559. {
  2560. char *val;
  2561. char val2[256];
  2562. long left;
  2563. long right;
  2564. long in_bound;
  2565. long out_bound;
  2566. long left_bnd;
  2567. long right_bnd;
  2568. long sig_conf;
  2569. strcpy (val2, "B\"");
  2570. sig_conf = beh_chktab (dic, $1.NAME, BVL_MODNAM, BVL_SIGDFN);
  2571. val = (char *) beh_chktab (dic, $1.NAME, NULL, BVL_PNTDFN);
  2572. if (sig_conf == 0)
  2573. bvl_error (17, $1.NAME);
  2574. else
  2575. {
  2576. if (sig_conf != BVL_CSTDFN)
  2577. bvl_error (76, $1.NAME);
  2578. }
  2579. left_bnd = beh_chktab (dic, $1.NAME, BVL_MODNAM, BVL_WMNDFN);
  2580. right_bnd = beh_chktab (dic, $1.NAME, BVL_MODNAM, BVL_WMXDFN);
  2581. left = $1.LEFT;
  2582. right = $1.RIGHT;
  2583. if (left_bnd <= right_bnd)
  2584. {
  2585. if (left <= right)
  2586. {
  2587. in_bound = left - left_bnd;
  2588. out_bound = right - left_bnd;
  2589. if ((left < left_bnd) || (right > right_bnd))
  2590. bvl_error (36, $1.NAME);
  2591. }
  2592. else
  2593. {
  2594. in_bound = left - right_bnd;
  2595. out_bound = right - right_bnd;
  2596. if ((left > right_bnd) || (right < left_bnd))
  2597. bvl_error (36, $1.NAME);
  2598. }
  2599. }
  2600. else
  2601. {
  2602. if (left <= right)
  2603. {
  2604. in_bound = right - left_bnd;
  2605. out_bound = left - left_bnd;
  2606. if ((left < right_bnd) || (right > left_bnd))
  2607. bvl_error (36, $1.NAME);
  2608. }
  2609. else
  2610. {
  2611. in_bound = right - right_bnd;
  2612. out_bound = left - right_bnd;
  2613. if ((left > left_bnd) || (right < right_bnd))
  2614. bvl_error (36, $1.NAME);
  2615. }
  2616. }
  2617. tobin (&val2[2], val, in_bound, out_bound);
  2618. strcat (val2, "\"");
  2619. $$ = namealloc (val2);
  2620. }
  2621. ;
  2622. .REPORT__expression.
  2623. : /*empty*/
  2624. { $$ = NULL; }
  2625. | REPORT
  2626. report__message
  2627. { $$ = $2; }
  2628. ;
  2629. .SEVERITY__expression.
  2630. : /*empty*/
  2631. { $$ = 'E'; }
  2632. | SEVERITY
  2633. severity__message
  2634. { $$ = $2; }
  2635. ;
  2636. report__message
  2637. : StringLit
  2638. { $$ = $1; }
  2639. ;
  2640. severity__message
  2641. : ERROR
  2642. { $$ = 'E'; }
  2643. | WARNING
  2644. { $$ = 'W'; }
  2645. ;
  2646. expression
  2647. : relation..AND__relation..
  2648. { $$ = $1; }
  2649. | relation..OR__relation..
  2650. { $$ = $1; }
  2651. | relation.NAND_NOR__relation.
  2652. { $$ = $1; }
  2653. | relation..XOR__relation..
  2654. { $$ = $1; }
  2655. ;
  2656. relation..AND__relation..
  2657. : relation
  2658. tok_AND
  2659. relation
  2660. { $$ = crtabl (AND , $1 , $3 , -1, -1); }
  2661. | relation..AND__relation..
  2662. tok_AND
  2663. relation
  2664. { $$ = crtabl (AND , $1 , $3 , -1, -1); }
  2665. ;
  2666. relation..OR__relation..
  2667. : relation
  2668. _OR
  2669. relation
  2670. { $$ = crtabl (OR , $1 , $3 , -1, -1); }
  2671. | relation..OR__relation..
  2672. _OR
  2673. relation
  2674. { $$ = crtabl (OR , $1 , $3 , -1, -1); }
  2675. ;
  2676. relation.NAND_NOR__relation.
  2677. : relation
  2678. { $$ = $1; }
  2679. | relation
  2680. _NAND
  2681. relation
  2682. { $$ = crtabl (NAND , $1 , $3 , -1, -1); }
  2683. | relation
  2684. _NOR
  2685. relation
  2686. { $$ = crtabl (NOR , $1 , $3 , -1, -1); }
  2687. ;
  2688. relation..XOR__relation..
  2689. : relation
  2690. _XOR
  2691. relation
  2692. { $$ = crtabl (XOR , $1 , $3 , -1, -1); }
  2693. | relation..XOR__relation..
  2694. _XOR
  2695. relation
  2696. { $$ = crtabl (XOR , $1 , $3 , -1, -1); }
  2697. ;
  2698. relation
  2699. : simple_expression
  2700. { $$ = $1; }
  2701. | simple_expression
  2702. relational_operator
  2703. simple_expression
  2704. { $$ = crtabl ($2 , $1 , $3 , -1, -1); }
  2705. ;
  2706. simple_expression
  2707. : .sign.term..add_op__term..
  2708. { $$ = $1; }
  2709. ;
  2710. .sign.term..add_op__term..
  2711. : term
  2712. { $$ = $1; }
  2713. | .sign.term..add_op__term..
  2714. Ampersand
  2715. term
  2716. { $$ = crtabl (CONC, $1, $3, -1, -1); }
  2717. ;
  2718. term
  2719. : factor
  2720. { $$ = $1; }
  2721. ;
  2722. factor
  2723. : primary
  2724. { $$ = $1; }
  2725. | _NOT
  2726. primary
  2727. { $$ = crtabl (NOT, $2, BVL_EMPSTR, -1, -1); }
  2728. ;
  2729. primary
  2730. : literal
  2731. {
  2732. struct bvl_expr expr1;
  2733. expr1.IDENT = $1;
  2734. $$ = crtabl (NOPS, expr1, BVL_EMPSTR, -1, -1);
  2735. }
  2736. | aggregate
  2737. { $$ = $1; }
  2738. | name
  2739. {
  2740. struct bvl_expr expr1;
  2741. long left;
  2742. long right;
  2743. long left_bnd;
  2744. long right_bnd;
  2745. long in_bound;
  2746. long out_bound;
  2747. long sig_conf;
  2748. sig_conf = beh_chktab (dic, $1.NAME, BVL_MODNAM, BVL_SIGDFN);
  2749. switch (sig_conf)
  2750. {
  2751. case (BVL_ICNDFN + BVL_BITDFN + BVL_NORDFN) :
  2752. case (BVL_BCNDFN + BVL_BITDFN + BVL_NORDFN) :
  2753. case (BVL_BCNDFN + BVL_MUXDFN + BVL_BUSDFN) :
  2754. case (BVL_BCNDFN + BVL_WORDFN + BVL_BUSDFN) :
  2755. case (BVL_BITDFN + BVL_NORDFN):
  2756. case (BVL_MUXDFN + BVL_BUSDFN):
  2757. case (BVL_WORDFN + BVL_BUSDFN):
  2758. case (BVL_RBIDFN + BVL_REGDFN):
  2759. case (BVL_CSTDFN):
  2760. break;
  2761. case (BVL_OCNDFN + BVL_BITDFN + BVL_NORDFN) :
  2762. case (BVL_OCNDFN + BVL_MUXDFN + BVL_BUSDFN) :
  2763. case (BVL_OCNDFN + BVL_WORDFN + BVL_BUSDFN) :
  2764. bvl_error (26, $1.NAME);
  2765. break;
  2766. default :
  2767. bvl_error (17, $1.NAME);
  2768. break;
  2769. }
  2770. left_bnd = beh_chktab (dic, $1.NAME, BVL_MODNAM, BVL_WMNDFN);
  2771. right_bnd = beh_chktab (dic, $1.NAME, BVL_MODNAM, BVL_WMXDFN);
  2772. left = $1.LEFT;
  2773. right = $1.RIGHT;
  2774. if (left_bnd <= right_bnd)
  2775. {
  2776. if (left <= right)
  2777. {
  2778. in_bound = left - left_bnd;
  2779. out_bound = right - left_bnd;
  2780. if ((left < left_bnd) || (right > right_bnd))
  2781. bvl_error (36, $1.NAME);
  2782. }
  2783. else
  2784. {
  2785. in_bound = right - left_bnd;
  2786. out_bound = left - left_bnd;
  2787. if ((left > right_bnd) || (right < left_bnd))
  2788. bvl_error (36, $1.NAME);
  2789. }
  2790. }
  2791. else
  2792. {
  2793. if (left <= right)
  2794. {
  2795. in_bound = left - right_bnd;
  2796. out_bound = right - right_bnd;
  2797. if ((left < right_bnd) || (right > left_bnd))
  2798. bvl_error (36, $1.NAME);
  2799. }
  2800. else
  2801. {
  2802. in_bound = right - right_bnd;
  2803. out_bound = left - right_bnd;
  2804. if ((left > left_bnd) || (right < right_bnd))
  2805. bvl_error (36, $1.NAME);
  2806. }
  2807. }
  2808. if (sig_conf != BVL_CSTDFN)
  2809. {
  2810. expr1.IDENT = $1.NAME;
  2811. if($1.FLAG == 'X')
  2812. {
  2813. expr1 = crtabl (NOPI , expr1, BVL_EMPSTR, left, right);
  2814. $$ = crtabl (STABLE, expr1, BVL_EMPSTR, left, right);
  2815. }
  2816. else
  2817. $$ = crtabl (NOPI , expr1, BVL_EMPSTR, left, right);
  2818. }
  2819. else
  2820. {
  2821. expr1.IDENT = (char *)beh_chktab(dic,$1.NAME,NULL,BVL_PNTDFN);
  2822. $$ = crtabl (NOPS,expr1,BVL_EMPSTR,in_bound,out_bound);
  2823. }
  2824. }
  2825. ;
  2826. relational_operator
  2827. : _EQSym
  2828. { $$ = EQ; }
  2829. | _NESym
  2830. { $$ = NE; }
  2831. ;
  2832. literal
  2833. : CharacterLit
  2834. { $$ = $1; }
  2835. | StringLit
  2836. { $$ = $1; }
  2837. | BitStringLit
  2838. { $$ = $1; }
  2839. ;
  2840. aggregate
  2841. : LeftParen
  2842. expression
  2843. RightParen
  2844. { $$ = $2; }
  2845. ;
  2846. name
  2847. : simple_name
  2848. {
  2849. $$.NAME = $1;
  2850. $$.LEFT = beh_chktab (dic, $1, BVL_MODNAM, BVL_WMNDFN);
  2851. $$.RIGHT = beh_chktab (dic, $1, BVL_MODNAM, BVL_WMXDFN);
  2852. }
  2853. | indexed_name
  2854. { $$ = $1; }
  2855. | slice_name
  2856. { $$ = $1; }
  2857. | attribute_name
  2858. { $$ = $1; }
  2859. ;
  2860. indexed_name
  2861. : simple_name
  2862. LeftParen
  2863. abstractlit
  2864. RightParen_ERR
  2865. {
  2866. $$.NAME = $1;
  2867. $$.LEFT = $3;
  2868. $$.RIGHT = $3;
  2869. }
  2870. ;
  2871. slice_name
  2872. : simple_name
  2873. LeftParen
  2874. abstractlit
  2875. direction
  2876. abstractlit
  2877. RightParen_ERR
  2878. {
  2879. if ((($5 > $3) && ($4 != BVL_UPTDFN)) ||
  2880. (($5 < $3) && ($4 != BVL_DWTDFN)))
  2881. bvl_error (32, $1);
  2882. $$.NAME = $1;
  2883. $$.LEFT = $3;
  2884. $$.RIGHT = $5;
  2885. }
  2886. ;
  2887. attribute_name
  2888. : simple_name
  2889. Apostrophe
  2890. attribute_designator
  2891. {
  2892. char extname [100];
  2893. char *lclname ;
  2894. long sig_conf ;
  2895. struct bvl_expr expr1 ;
  2896. struct bvl_expr expr2 ;
  2897. struct chain *ptabl ;
  2898. sig_conf = beh_chktab (dic, $1, BVL_MODNAM, BVL_SIGDFN);
  2899. switch (sig_conf)
  2900. {
  2901. case (BVL_ICNDFN + BVL_BITDFN + BVL_NORDFN) :
  2902. case (BVL_BCNDFN + BVL_BITDFN + BVL_NORDFN) :
  2903. case (BVL_BCNDFN + BVL_MUXDFN + BVL_BUSDFN) :
  2904. case (BVL_BCNDFN + BVL_WORDFN + BVL_BUSDFN) :
  2905. case (BVL_BITDFN + BVL_NORDFN):
  2906. case (BVL_MUXDFN + BVL_BUSDFN):
  2907. case (BVL_WORDFN + BVL_BUSDFN):
  2908. case (BVL_RBIDFN + BVL_REGDFN):
  2909. break;
  2910. default :
  2911. bvl_error (79, $1);
  2912. }
  2913. if (beh_chktab (dic, $1, BVL_MODNAM, BVL_WMNDFN) != -1)
  2914. bvl_error (79, $1);
  2915. sprintf (extname, "%s'delayed", $1);
  2916. lclname = namealloc (extname);
  2917. if (BVL_ERRFLG == 0)
  2918. {
  2919. if (beh_chktab (dic, $1, BVL_MODNAM, BVL_STBDFN) == 0)
  2920. {
  2921. expr1.IDENT = $1;
  2922. expr1.WIDTH = 1;
  2923. expr2 = crtabl (NOPI, expr1, BVL_EMPSTR, -1, -1);
  2924. ptabl = expr2.LIST_ABL->DATA;
  2925. if (BVL_AUXMOD == 1)
  2926. BVL_BEFPNT->BERIN=beh_addberin(BVL_BEFPNT->BERIN,lclname);
  2927. BVL_BEFPNT->BEDLY = beh_addbeaux(BVL_BEFPNT->BEDLY,lclname,
  2928. ptabl, NULL);
  2929. beh_addtab (dic, $1 , BVL_MODNAM, BVL_STBDFN, 1);
  2930. beh_addtab (dic, lclname, BVL_MODNAM, BVL_WMNDFN, -1);
  2931. beh_addtab (dic, lclname, BVL_MODNAM, BVL_WMXDFN, -1);
  2932. beh_addtab (dic, lclname, BVL_MODNAM, BVL_SIGDFN,
  2933. (BVL_ICNDFN + BVL_BITDFN + BVL_NORDFN));
  2934. }
  2935. }
  2936. BVL_BEFPNT->TYPE |= BEH_STABLE;
  2937. $$.NAME = $1 ;
  2938. $$.LEFT = -1 ;
  2939. $$.RIGHT = -1 ;
  2940. $$.FLAG = 'X';
  2941. }
  2942. ;
  2943. attribute_designator
  2944. : _STABLE
  2945. ;
  2946. type_mark
  2947. : BIT
  2948. { $$.VALU = BIT; $$.FLAG = 'S'; }
  2949. | WOR_BIT
  2950. { $$.VALU = WOR_BIT; $$.FLAG = 'S'; }
  2951. | MUX_BIT
  2952. { $$.VALU = MUX_BIT; $$.FLAG = 'S'; }
  2953. | BIT_VECTOR
  2954. { $$.VALU = BIT; $$.FLAG = 'A'; }
  2955. | WOR_VECTOR
  2956. { $$.VALU = WOR_BIT; $$.FLAG = 'A'; }
  2957. | MUX_VECTOR
  2958. { $$.VALU = MUX_BIT; $$.FLAG = 'A'; }
  2959. | REG_BIT
  2960. { $$.VALU = REG_BIT; $$.FLAG = 'S'; }
  2961. | REG_VECTOR
  2962. { $$.VALU = REG_BIT; $$.FLAG = 'A'; }
  2963. | NATURAL
  2964. { $$.VALU = NATURAL; $$.FLAG = 'S'; }
  2965. | NATURAL_VECTOR
  2966. { $$.VALU = NATURAL; $$.FLAG = 'A'; }
  2967. ;
  2968. identifier_list
  2969. : Identifier
  2970. { BVL_NM1LST = addchain (BVL_NM1LST, $1); }
  2971. ...identifier..
  2972. ;
  2973. ...identifier..
  2974. : /*empty*/
  2975. | ...identifier..
  2976. Comma
  2977. Identifier
  2978. { BVL_NM1LST = addchain (BVL_NM1LST, $3); }
  2979. ;
  2980. .label.
  2981. : /*empty*/
  2982. { $$ = NULL; }
  2983. | label
  2984. { $$ = $1; }
  2985. ;
  2986. .guard_expression.
  2987. : /*empty*/
  2988. { $$ = NULL; }
  2989. | guard_expression
  2990. { $$ = $1; }
  2991. ;
  2992. guard_expression
  2993. : LeftParen
  2994. expression
  2995. RightParen_ERR
  2996. { $$ = (char *)$2.LIST_ABL->DATA; }
  2997. ;
  2998. .TRANSPORT.
  2999. : /*empty*/
  3000. { $$ = BEH_ASG_INERTIAL ; }
  3001. | TRANSPORT
  3002. { $$ = BEH_ASG_TRANSPORT; }
  3003. ;
  3004. .GUARDED.
  3005. : /*empty*/
  3006. { $$ = BVL_UNGDFN ; }
  3007. | GUARDED
  3008. { $$ = BVL_GRDDFN; }
  3009. ;
  3010. .simple_name.
  3011. : /*empty*/
  3012. { $$ = NULL; }
  3013. | simple_name
  3014. { $$ = $1; }
  3015. ;
  3016. simple_name
  3017. : Identifier
  3018. { $$ = $1; }
  3019. ;
  3020. target
  3021. : name
  3022. { $$ = $1; }
  3023. ;
  3024. a_label
  3025. : label
  3026. Colon
  3027. {
  3028. BVL_LBLNAM = $1;
  3029. $$ = $1;
  3030. }
  3031. ;
  3032. label
  3033. : Identifier
  3034. { $$ = $1; }
  3035. ;
  3036. abstractlit
  3037. : AbstractLit
  3038. { $$ = atoi ($1); }
  3039. ;
  3040. RightParen_ERR
  3041. : RightParen
  3042. { yyerrok; }
  3043. ;
  3044. Semicolon_ERR
  3045. : Semicolon
  3046. { yyerrok; }
  3047. ;
  3048. END_ERR
  3049. : _END
  3050. { yyerrok; }
  3051. ;
  3052. %%