Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / mbkvhdl / mvl_sspec.c
1 /*
2 * This file is part of the Alliance CAD System
3 * Copyright (C) Laboratoire LIP6 - Département ASIM
4 * Universite Pierre et Marie Curie
5 *
6 * Home page : http://www-asim.lip6.fr/alliance/
7 * E-mail support : mailto:alliance-support@asim.lip6.fr
8 *
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Library General Public License as published
11 * by the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 *
14 * Alliance VLSI CAD System is distributed in the hope that it will be
15 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with the GNU C Library; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 /* ###--------------------------------------------------------------### */
25 /* */
26 /* file : mvl_sspec.yac */
27 /* date : Jan 29 1992 */
28 /* author : P. BAZARGAN */
29 /* L.A. TABUSSE */
30 /* VUONG H.N. */
31 /* */
32 /* content : these functions are used to build up MBK's structures */
33 /* */
34 /* ###--------------------------------------------------------------### */
35
36 #include <stdio.h>
37 #include MUT_H
38 #include MLO_H
39 #include "mvl_stype.h"
40 #include "mvl_sspec.h"
41 #include "mvl_stdef.h"
42
43 /* ###--------------------------------------------------------------### */
44 /* function : mvl_addlosig */
45 /* description : create one or more losig structures (for an array a */
46 /* losig is created for each bit) */
47 /* called func. : addlosig, addchain */
48 /* ###--------------------------------------------------------------### */
49
50 struct losig *mvl_addlosig (ptfig, index, type, ptype, name, left, right)
51
52 lofig_list *ptfig; /* pointer on LOFIG structure */
53 int index; /* index of the first signal */
54 char type ; /* signal's type */
55 char ptype; /* signal's resolution function */
56 char *name ; /* signal's name */
57 short left ; /* array's left bound (= -1 if scalar) */
58 short right; /* array's right bound (= -1 if scalar) */
59
60 {
61 char extname[100];
62 short i ;
63 short inc = 1;
64 struct chain *pt_chlst ;
65 struct losig *ptsig ;
66
67 if ((left==-1) && (right==-1))
68 {
69 pt_chlst = addchain (NULL, name);
70 ptsig = addlosig (ptfig, index, pt_chlst, type);
71
72 if (ptype != '0')
73 ptsig->USER = addptype (ptsig->USER, ptype, NULL);
74 }
75 else
76 {
77 if (left >= right) /* array */
78 inc = -1;
79
80 for (i=left ; i!=(right+inc) ; i+=inc)
81 {
82 sprintf (extname, "%s %d", name, i);
83 pt_chlst = addchain (NULL, extname);
84 ptsig = addlosig (ptfig, index, pt_chlst, type);
85
86 if (ptype != '0')
87 ptsig->USER = addptype (ptsig->USER, ptype, NULL);
88
89 index++;
90 }
91 }
92 return (ptsig);
93 }
94
95 /* ###--------------------------------------------------------------### */
96 /* function : mvl_addlocon */
97 /* description : create one or more locon structures (for an array a */
98 /* locon is created for each bit) */
99 /* called func. : addlocon, addchain */
100 /* ###--------------------------------------------------------------### */
101
102 struct locon *mvl_addlocon (ptfig, ptsig, dir, name, left, right)
103
104 struct lofig *ptfig; /* BEFIG structure's pointer */
105 struct losig *ptsig; /* external signal's pointer */
106 char dir ; /* port's mode */
107 char *name ; /* port's name */
108 short left ; /* array left bound (= -1 if scalar) */
109 short right; /* array right bound (= -1 if scalar) */
110
111 {
112 char extname[100];
113 short i ;
114 short inc = 1;
115 struct locon *ptcon ;
116 struct locon *ptcontmp ;
117
118 if ((left==-1) && (right==-1))
119 {
120 ptcon = addlocon (ptfig, name, ptsig, dir);
121 }
122 else
123 {
124 if (left >= right)
125 inc = -1;
126
127 for (i=left ; i!=(right+inc) ; i+=inc)
128 {
129 sprintf (extname, "%s %d", name, i);
130 ptcon = addlocon (ptfig, extname, NULL, dir);
131 }
132
133 if (ptsig != NULL)
134 {
135 ptcontmp = ptcon;
136 for (i=left ; i!=(right+inc) ; i+=inc)
137 {
138 ptcontmp->SIG = ptsig;
139 ptcontmp = ptcontmp->NEXT;
140 ptsig = ptsig->NEXT;
141 }
142 }
143 }
144 return (ptcon);
145 }