Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 11 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /* contains the database functions that store the pin configurations |
1 | /* contains the database functions that store the pin configurations |
| 2 | * |
2 | * |
| 3 | * $Header: c:\\cygwin\\cvsroot/Vert03/vertlib/database.c,v 1.1.1.1 2003/11/04 23:34:57 mjames |
3 | * $Header: c:\\cygwin\\cvsroot/Vert03/vertlib/database.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $ |
| - | 4 | * $Log: database.c,v $ |
|
| 4 | * Exp $ $Log: database.c,v $ Revision 1.1.1.1 2003/11/04 23:34:57 mjames Imported into local |
5 | * Revision 1.1.1.1 2003/11/04 23:34:57 mjames |
| 5 | * repositrory |
6 | * Imported into local repositrory |
| 6 | * |
7 | * |
| 7 | * Revision 1.13 2003/01/02 21:37:15 mjames |
8 | * Revision 1.13 2003/01/02 21:37:15 mjames |
| 8 | * Experiment on creating NOT_ROUTABLE_H and NOT_ROUTABLE_L |
9 | * Experiment on creating NOT_ROUTABLE_H and NOT_ROUTABLE_L |
| 9 | * properties on the nets so that pin jumpers can be made without a problem. |
10 | * properties on the nets so that pin jumpers can be made without a problem. |
| 10 | * |
11 | * |
| Line 65... | Line 66... | ||
| 65 | * Mike put it here |
66 | * Mike put it here |
| 66 | * |
67 | * |
| 67 | * |
68 | * |
| 68 | * Revision 1.61 2000/10/04 10:37:03 10:37:03 mjames (Mike James) |
69 | * Revision 1.61 2000/10/04 10:37:03 10:37:03 mjames (Mike James) |
| 69 | * COnversion to Vertical2, supports signals and components |
70 | * COnversion to Vertical2, supports signals and components |
| 70 | * |
71 | * |
| 71 | * Revision 1.61 2000/10/04 10:37:03 10:37:03 mjames (Mike James) |
72 | * Revision 1.61 2000/10/04 10:37:03 10:37:03 mjames (Mike James) |
| 72 | * Part of Release PSAVAT01 |
73 | * Part of Release PSAVAT01 |
| 73 | * |
74 | * |
| 74 | * Revision 1.60 2000/10/03 10:05:27 10:05:27 mjames (Mike James) |
75 | * Revision 1.60 2000/10/03 10:05:27 10:05:27 mjames (Mike James) |
| 75 | * Added CONSTANTS and SIGNALS to architecture |
76 | * Added CONSTANTS and SIGNALS to architecture |
| 76 | * |
77 | * |
| 77 | * Revision 1.58 2000/09/27 14:42:11 14:42:11 mjames (Mike James) |
78 | * Revision 1.58 2000/09/27 14:42:11 14:42:11 mjames (Mike James) |
| 78 | * Part of Release Sep_27_ST_2000 |
79 | * Part of Release Sep_27_ST_2000 |
| 79 | * |
80 | * |
| 80 | * Revision 1.57 2000/09/21 10:15:40 10:15:40 mjames (Mike James) |
81 | * Revision 1.57 2000/09/21 10:15:40 10:15:40 mjames (Mike James) |
| 81 | * Part of Release Sep21Alpha |
82 | * Part of Release Sep21Alpha |
| 82 | * |
83 | * |
| 83 | * Revision 1.56 2000/09/21 09:44:29 09:44:29 mjames (Mike James) |
84 | * Revision 1.56 2000/09/21 09:44:29 09:44:29 mjames (Mike James) |
| 84 | * Added in code to deal with pin equivalents, and removed some |
85 | * Added in code to deal with pin equivalents, and removed some |
| 85 | * spurious diagnostic puts() calls . |
86 | * spurious diagnostic puts() calls . |
| 86 | * |
87 | * |
| 87 | * Revision 1.55 2000/08/25 09:57:09 09:57:09 mjames (Mike James) |
88 | * Revision 1.55 2000/08/25 09:57:09 09:57:09 mjames (Mike James) |
| 88 | * Part of Release Aug25_alpha |
89 | * Part of Release Aug25_alpha |
| 89 | * |
90 | * |
| 90 | * Revision 1.54 2000/08/16 08:57:26 08:57:26 mjames (Mike James) |
91 | * Revision 1.54 2000/08/16 08:57:26 08:57:26 mjames (Mike James) |
| 91 | * Part of Release CD01_Aug2000 |
92 | * Part of Release CD01_Aug2000 |
| 92 | * |
93 | * |
| 93 | * Revision 1.53 2000/08/14 14:45:07 14:45:07 mjames (Mike James) |
94 | * Revision 1.53 2000/08/14 14:45:07 14:45:07 mjames (Mike James) |
| 94 | * Part of Release Aug_14_2000 |
95 | * Part of Release Aug_14_2000 |
| 95 | * |
96 | * |
| 96 | * Revision 1.52 2000/08/11 08:30:28 08:30:28 mjames (Mike James) |
97 | * Revision 1.52 2000/08/11 08:30:28 08:30:28 mjames (Mike James) |
| 97 | * Part of Release Aug_11_2000 |
98 | * Part of Release Aug_11_2000 |
| 98 | * |
99 | * |
| 99 | * Revision 1.51 2000/08/09 10:31:41 10:31:41 mjames (Mike James) |
100 | * Revision 1.51 2000/08/09 10:31:41 10:31:41 mjames (Mike James) |
| 100 | * Part of Release Aug__9_2000 |
101 | * Part of Release Aug__9_2000 |
| 101 | * |
102 | * |
| 102 | * Revision 1.50 2000/05/31 11:42:48 11:42:48 mjames (Mike James) |
103 | * Revision 1.50 2000/05/31 11:42:48 11:42:48 mjames (Mike James) |
| 103 | * Part of Release May_31_2000 |
104 | * Part of Release May_31_2000 |
| 104 | * |
105 | * |
| 105 | * Revision 1.49 2000/05/08 17:01:33 17:01:33 mjames (Mike James) |
106 | * Revision 1.49 2000/05/08 17:01:33 17:01:33 mjames (Mike James) |
| 106 | * Part of Release May__8_2000 |
107 | * Part of Release May__8_2000 |
| 107 | * |
108 | * |
| 108 | * Revision 1.48 2000/05/08 16:59:26 16:59:26 mjames (Mike James) |
109 | * Revision 1.48 2000/05/08 16:59:26 16:59:26 mjames (Mike James) |
| 109 | * Part of Release May__8_2000 |
110 | * Part of Release May__8_2000 |
| 110 | * |
111 | * |
| 111 | * Revision 1.47 2000/05/08 16:57:03 16:57:03 mjames (Mike James) |
112 | * Revision 1.47 2000/05/08 16:57:03 16:57:03 mjames (Mike James) |
| 112 | * Part of Release May__8_2000 |
113 | * Part of Release May__8_2000 |
| 113 | * |
114 | * |
| 114 | * Revision 1.46 2000/03/08 16:18:48 16:18:48 mjames (Mike James) |
115 | * Revision 1.46 2000/03/08 16:18:48 16:18:48 mjames (Mike James) |
| 115 | * New version including PC |
116 | * New version including PC |
| 116 | * |
117 | * |
| 117 | * Revision 1.43 2000/02/18 15:45:24 15:45:24 mjames (Mike James) |
118 | * Revision 1.43 2000/02/18 15:45:24 15:45:24 mjames (Mike James) |
| 118 | * Amended to support PC |
119 | * Amended to support PC |
| 119 | * |
120 | * |
| 120 | * Revision 1.42 2000/01/20 15:58:41 15:58:41 mjames (Mike James) |
121 | * Revision 1.42 2000/01/20 15:58:41 15:58:41 mjames (Mike James) |
| 121 | * Part of Release R22 |
122 | * Part of Release R22 |
| 122 | * |
123 | * |
| 123 | * Revision 1.41 99/12/22 11:15:22 11:15:22 mjames (Mike James) |
124 | * Revision 1.41 99/12/22 11:15:22 11:15:22 mjames (Mike James) |
| 124 | * Part of Release Dec_22_1999 |
125 | * Part of Release Dec_22_1999 |
| 125 | * |
126 | * |
| 126 | * Revision 1.40 99/06/25 14:34:42 14:34:42 mjames (Mike James) |
127 | * Revision 1.40 99/06/25 14:34:42 14:34:42 mjames (Mike James) |
| 127 | * Added in reference to expression.h, but no changes made |
128 | * Added in reference to expression.h, but no changes made |
| 128 | * to the function of acfread yet. |
129 | * to the function of acfread yet. |
| 129 | * |
130 | * |
| 130 | * Revision 1.39 99/06/18 09:23:19 09:23:19 mjames (Mike James) |
131 | * Revision 1.39 99/06/18 09:23:19 09:23:19 mjames (Mike James) |
| 131 | * |
132 | * |
| 132 | * Revision 1.38 99/05/04 09:50:36 09:50:36 mjames (Mike James) |
133 | * Revision 1.38 99/05/04 09:50:36 09:50:36 mjames (Mike James) |
| 133 | * General checkin |
134 | * General checkin |
| 134 | * |
135 | * |
| 135 | * Revision 1.34 98/08/12 14:19:52 14:19:52 mjames (Mike James) |
136 | * Revision 1.34 98/08/12 14:19:52 14:19:52 mjames (Mike James) |
| 136 | * Changed pin definition code to work with VHDL |
137 | * Changed pin definition code to work with VHDL |
| 137 | * parsing |
138 | * parsing |
| 138 | * as well as include file list being updated |
139 | * as well as include file list being updated |
| 139 | * |
140 | * |
| 140 | * Revision 1.33 98/06/15 14:17:51 14:17:51 mjames (Mike James) |
141 | * Revision 1.33 98/06/15 14:17:51 14:17:51 mjames (Mike James) |
| 141 | * Added socket templating pointers - reference to parent template |
142 | * Added socket templating pointers - reference to parent template |
| 142 | * for child template. |
143 | * for child template. |
| 143 | * |
144 | * |
| 144 | * Revision 1.32 98/02/11 11:25:52 11:25:52 mjames (Mike James) |
145 | * Revision 1.32 98/02/11 11:25:52 11:25:52 mjames (Mike James) |
| 145 | * Checked in for version 6.2a |
146 | * Checked in for version 6.2a |
| 146 | * |
147 | * |
| 147 | * Revision 1.31 98/01/13 11:33:35 11:33:35 mjames (Mike James) |
148 | * Revision 1.31 98/01/13 11:33:35 11:33:35 mjames (Mike James) |
| 148 | * Added the bility to use a VHDL template file |
149 | * Added the bility to use a VHDL template file |
| 149 | * containing $ENT$ and $ARCH$ in the position where one |
150 | * containing $ENT$ and $ARCH$ in the position where one |
| 150 | * wants the entity and architecture to be given. |
151 | * wants the entity and architecture to be given. |
| 151 | * |
152 | * |
| 152 | * Revision 1.30 97/04/23 08:42:49 08:42:49 mjames (Mike James) |
153 | * Revision 1.30 97/04/23 08:42:49 08:42:49 mjames (Mike James) |
| 153 | * CHecked in for release rel23041997 |
154 | * CHecked in for release rel23041997 |
| 154 | * |
155 | * |
| 155 | * Revision 1.29 96/12/23 15:13:48 15:13:48 mjames (Mike James) |
156 | * Revision 1.29 96/12/23 15:13:48 15:13:48 mjames (Mike James) |
| 156 | * Added reverse pointer to show which unrouted net was |
157 | * Added reverse pointer to show which unrouted net was |
| 157 | * responsible for the fixing of the pins. |
158 | * responsible for the fixing of the pins. |
| 158 | * |
159 | * |
| 159 | * Revision 1.28 96/12/23 10:24:02 10:24:02 mjames (Mike James) |
160 | * Revision 1.28 96/12/23 10:24:02 10:24:02 mjames (Mike James) |
| 160 | * Altered to make it sort the results |
161 | * Altered to make it sort the results |
| 161 | * of listing COMPONENTS and CHIP pins. |
162 | * of listing COMPONENTS and CHIP pins. |
| 162 | * / |
163 | * / |
| 163 | * |
164 | * |
| 164 | * Revision 1.27 96/12/13 08:43:08 08:43:08 mjames (Mike James) |
165 | * Revision 1.27 96/12/13 08:43:08 08:43:08 mjames (Mike James) |
| 165 | * Update to v5.1, added Write ID , exact routing |
166 | * Update to v5.1, added Write ID , exact routing |
| 166 | * |
167 | * |
| 167 | * Revision 1.26 96/08/06 13:38:51 13:38:51 mjames (Mike James) |
168 | * Revision 1.26 96/08/06 13:38:51 13:38:51 mjames (Mike James) |
| 168 | * Added FIX_LOCATION pin attribute to netlist |
169 | * Added FIX_LOCATION pin attribute to netlist |
| 169 | * |
170 | * |
| 170 | * Revision 1.25 96/07/19 14:38:43 14:38:43 mjames (Mike James) |
171 | * Revision 1.25 96/07/19 14:38:43 14:38:43 mjames (Mike James) |
| 171 | * Update to give to PRL |
172 | * Update to give to PRL |
| Line 247... | Line 248... | ||
| 247 | * Correcly reading ACF |
248 | * Correcly reading ACF |
| 248 | * |
249 | * |
| 249 | * Revision 1.1 96/01/04 11:37:22 11:37:22 mjames (Mike James) |
250 | * Revision 1.1 96/01/04 11:37:22 11:37:22 mjames (Mike James) |
| 250 | * Initial revision |
251 | * Initial revision |
| 251 | * |
252 | * |
| 252 | */ |
253 | */ |
| - | 254 | #include <stdio.h> |
|
| - | 255 | #include <string.h> |
|
| - | 256 | #include <stdlib.h> |
|
| 253 | #include "database.h" |
257 | #include <ctype.h> |
| - | 258 | #include <sys/types.h> |
|
| - | 259 | #include <regex.h> |
|
| 254 | 260 | ||
| - | 261 | ||
| 255 | #include "acf_yacc.h" |
262 | #include "vertcl_main.h" |
| 256 | #include "chck_names.h" |
- | |
| 257 | #include "cmdlog.h" |
- | |
| 258 | #include "cmdparse.h" |
- | |
| 259 | #include "expression.h" |
263 | #include "expression.h" |
| 260 | #include "generic.h" |
264 | #include "generic.h" |
| - | 265 | #include "database.h" |
|
| 261 | #include "lx_support.h" |
266 | #include "lx_support.h" |
| - | 267 | #include "cmdparse.h" |
|
| - | 268 | #include "cmdlog.h" |
|
| - | 269 | #include "acf_yacc.h" |
|
| - | 270 | #include "chck_names.h" |
|
| 262 | #include "sorting.h" |
271 | #include "sorting.h" |
| 263 | #include "version.h" |
272 | #include "version.h" |
| 264 | #include "vertcl_main.h" |
- | |
| 265 | 273 | ||
| 266 | #include <ctype.h> |
- | |
| 267 | #include <regex.h> |
- | |
| 268 | #include <stdio.h> |
- | |
| 269 | #include <stdlib.h> |
- | |
| 270 | #include <string.h> |
- | |
| 271 | #include <sys/types.h> |
274 | #ident "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/database.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $" |
| 272 | 275 | ||
| 273 | #ident \ |
- | |
| 274 | "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/database.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $" |
- | |
| 275 | 276 | ||
| - | 277 | ||
| 276 | vhdl_t *default_vhdl_datatype; |
278 | vhdl_t * default_vhdl_datatype; |
| 277 | vhdl_t *default_vhdl_bustype; |
279 | vhdl_t * default_vhdl_bustype; |
| 278 | 280 | ||
| 279 | /* string constants used around the place*/ |
281 | /* string constants used around the place*/ |
| 280 | 282 | ||
| 281 | char nullstr[] = ""; |
283 | char nullstr[] = ""; |
| - | 284 | ||
| 282 | 285 | ||
| 283 | /* database pointers */ |
286 | /* database pointers */ |
| 284 | __declspec(dllexport) socket_t *socket_head = NULL; |
287 | __declspec (dllexport) socket_t * socket_head = NULL; |
| - | 288 | ||
| - | 289 | __declspec (dllexport)socket_t * template_head = NULL; |
|
| - | 290 | ||
| - | 291 | ||
| 285 | 292 | ||
| - | 293 | net_t * routed_list = NULL; |
|
| - | 294 | net_t * named_list = NULL; |
|
| - | 295 | net_t * named_tail = NULL; /* as routed nets are moved to the named list */ |
|
| 286 | __declspec(dllexport) socket_t *template_head = NULL; |
296 | net_t * unrouted_list = NULL; |
| 287 | 297 | ||
| 288 | net_t *routed_list = NULL; |
- | |
| 289 | net_t *named_list = NULL; |
- | |
| 290 | net_t *named_tail = NULL; /* as routed nets are moved to the named list */ |
- | |
| 291 | net_t *unrouted_list = NULL; |
- | |
| 292 | 298 | ||
| 293 | /* these are ident counters. The first counts net identifiers */ |
299 | /* these are ident counters. The first counts net identifiers */ |
| 294 | static int n_idents = 1; /* net identifiers */ |
300 | static int n_idents = 1; /* net identifiers */ |
| 295 | static int s_idents = 1; /* socket identifiers */ |
301 | static int s_idents = 1; /* socket identifiers */ |
| 296 | static int i_idents = 1; /* pin identifiers */ |
302 | static int i_idents = 1; /* pin identifiers */ |
| 297 | 303 | ||
| 298 | /* compares two strings case insensitive with a pointer sanity check */ |
304 | /* compares two strings case insensitive with a pointer sanity check */ |
| 299 | 305 | ||
| 300 | int strcmp2 (char *s, char *t) |
306 | int strcmp2(char * s, char * t) |
| 301 | { |
307 | { |
| 302 | if (!s || !t) |
308 | if(!s || !t) |
| 303 | return (-1); |
309 | return(-1); |
| 304 | for (; tolower (*s) == tolower (*t); s++, t++) |
310 | for(;tolower(*s) == tolower(*t);s++,t++) |
| 305 | if (*s == 0) |
311 | if(*s==0) |
| 306 | return (0); |
312 | return(0); |
| 307 | return (tolower (*s) - tolower (*t)); |
313 | return(tolower(*s) - tolower(*t)); |
| 308 | } |
314 | } |
| 309 | 315 | ||
| 310 | /* allocates a space for a string */ |
316 | /* allocates a space for a string */ |
| 311 | 317 | ||
| - | 318 | ||
| 312 | #if !defined allocstr |
319 | #if !defined allocstr |
| 313 | /* we now use strdup.... */ |
320 | /* we now use strdup.... */ |
| 314 | char *allocstr (char *s) |
321 | char * allocstr(char * s) |
| 315 | { |
322 | { |
| 316 | char *t; |
323 | char * t; |
| 317 | /* added a check for allocating null string |
324 | /* added a check for allocating null string |
| 318 | * (its strlen that bombs in CygWin) */ |
325 | * (its strlen that bombs in CygWin) */ |
| 319 | if (!s) |
- | |
| 320 | return NULL; |
326 | if (!s) return NULL; |
| 321 | 327 | ||
| 322 | t = malloc (strlen (s) + 1); |
328 | t=malloc(strlen(s)+1); |
| 323 | strcpy (t, s); |
329 | strcpy(t,s); |
| 324 | return t; |
330 | return t; |
| 325 | } |
331 | } |
| 326 | #endif |
332 | #endif |
| 327 | 333 | ||
| 328 | /* allocates a space for a string and a suffix dependent on property */ |
334 | /* allocates a space for a string and a suffix dependent on property */ |
| 329 | 335 | ||
| 330 | #if defined USE_ALLOCSTR_PROP |
336 | #if defined USE_ALLOCSTR_PROP |
| 331 | static char *allocstr_prop (char *s, property_t prop) |
337 | static char * allocstr_prop(char * s,property_t prop) |
| 332 | { |
338 | { |
| 333 | char *t; |
339 | char * t; |
| 334 | switch (prop) |
340 | switch (prop) { |
| 335 | { |
- | |
| 336 | case Ident: |
341 | case Ident: |
| 337 | case Type: |
342 | case Type: |
| 338 | case Name: |
343 | case Name: |
| 339 | case Value: |
- | |
| 340 | t = strdup (s); |
344 | case Value: t=strdup(s); |
| 341 | break; |
345 | break; |
| 342 | } |
346 | } |
| 343 | return t; |
347 | return t; |
| 344 | } |
348 | } |
| 345 | #endif |
349 | #endif |
| 346 | 350 | ||
| 347 | /* this is a check on a socket ident - if absent, generates one */ |
351 | /* this is a check on a socket ident - if absent, generates one */ |
| 348 | 352 | ||
| 349 | __declspec(dllexport) void ensure_socket_ident (socket_t *chip) |
353 | __declspec (dllexport) void ensure_socket_ident(socket_t * chip) |
| 350 | { |
354 | { |
| 351 | char id[10]; |
355 | char id[10]; |
| 352 | if (chip->identifier == nullstr) |
356 | if (chip->identifier == nullstr) |
| 353 | { |
357 | { |
| 354 | sprintf (id, "ID%d", s_idents++); |
358 | sprintf(id,"ID%d",s_idents++); |
| 355 | set_socket (chip, Ident, id); |
359 | set_socket(chip,Ident,id); |
| 356 | }; |
360 | }; |
| 357 | } |
361 | } |
| 358 | 362 | ||
| - | 363 | ||
| 359 | /* set a socket property */ |
364 | /* set a socket property */ |
| 360 | __declspec(dllexport) void set_socket (socket_t *chip, property_t prop, char *str) |
365 | __declspec (dllexport)void set_socket(socket_t * chip,property_t prop,char * str) |
| 361 | { |
366 | { |
| 362 | char *s; |
367 | char * s; |
| 363 | s = strdup (str); |
368 | s = strdup(str); |
| 364 | 369 | ||
| 365 | /* printf("(Set socket prop%d to %s)",prop,s); */ |
370 | /* printf("(Set socket prop%d to %s)",prop,s); */ |
| 366 | switch (prop) |
371 | switch(prop) |
| 367 | { |
372 | { |
| 368 | case Ident: |
- | |
| 369 | chip->identifier = s; |
373 | case Ident: chip->identifier = s; break; |
| 370 | break; |
- | |
| 371 | case Type: |
- | |
| 372 | chip->type = s; |
374 | case Type: chip->type = s; break; |
| 373 | break; |
- | |
| 374 | case Name: |
- | |
| 375 | chip->name = s; |
375 | case Name: chip->name = s; break; |
| 376 | break; |
- | |
| 377 | case Value: |
- | |
| 378 | chip->value = s; |
376 | case Value: chip->value = s; break; |
| 379 | break; |
- | |
| 380 | default: |
- | |
| 381 | break; |
377 | default: break; |
| 382 | }; |
378 | }; |
| 383 | } |
379 | } |
| 384 | 380 | ||
| 385 | /* find a socket property */ |
381 | /* find a socket property */ |
| 386 | __declspec(dllexport) socket_t *find_socket ( |
382 | __declspec (dllexport) socket_t * find_socket(property_t prop, |
| - | 383 | char * str, |
|
| - | 384 | int srchonly, |
|
| 387 | property_t prop, char *str, int srchonly, socket_t **headref) |
385 | socket_t ** headref) |
| 388 | { |
386 | { |
| 389 | socket_t *c = *headref, *p = NULL; |
387 | socket_t * c=*headref, *p=NULL; |
| 390 | int f = 0; |
388 | int f=0; |
| 391 | /* printf("-- Socket %s : prop %d pointer=%p\n",str,prop,c); */ |
389 | /* printf("-- Socket %s : prop %d pointer=%p\n",str,prop,c); */ |
| 392 | 390 | ||
| 393 | while (c) |
391 | while(c) |
| 394 | { |
392 | { |
| 395 | switch (prop) |
393 | switch(prop) |
| 396 | { |
394 | { |
| 397 | case Ident: |
- | |
| 398 | f = strcmp2 (c->identifier, str) == 0; /*puts(c->identifier); */ |
395 | case Ident: f=strcmp2(c->identifier,str)==0;/*puts(c->identifier); */ break; |
| 399 | break; |
- | |
| 400 | case Type: |
- | |
| 401 | f = strcmp2 (c->type, str) == 0; |
396 | case Type: f=strcmp2(c->type,str)==0; break; |
| 402 | break; |
- | |
| 403 | case Name: |
- | |
| 404 | f = strcmp2 (c->name, str) == 0; /*puts(c->name);*/ |
397 | case Name: f=strcmp2(c->name,str)==0; /*puts(c->name);*/ break; |
| 405 | break; |
- | |
| 406 | case Value: |
- | |
| 407 | f = strcmp2 (c->value, str) == 0; |
398 | case Value: f=strcmp2(c->value,str)==0; break; |
| 408 | break; |
- | |
| 409 | default: |
- | |
| 410 | break; /* never find if wrong field specified */ |
399 | default : break; /* never find if wrong field specified */ |
| 411 | }; |
400 | }; |
| 412 | if (f) |
- | |
| 413 | break; |
401 | if(f) break; |
| 414 | p = c; |
402 | p=c; |
| 415 | c = c->next; |
403 | c=c->next; |
| 416 | }; |
404 | }; |
| 417 | 405 | ||
| 418 | if (srchonly || f) |
406 | if(srchonly || f ) |
| 419 | return (c); |
407 | return(c); |
| 420 | 408 | ||
| 421 | c = calloc (1, sizeof (socket_t)); /* all pointers are set to be null */ |
409 | c=calloc(1,sizeof(socket_t)); /* all pointers are set to be null */ |
| 422 | 410 | ||
| 423 | c->identifier = nullstr; |
411 | c->identifier = nullstr; |
| 424 | c->type = nullstr; |
412 | c->type = nullstr; |
| 425 | c->name = nullstr; |
413 | c->name = nullstr; |
| 426 | c->value = nullstr; |
414 | c->value = nullstr; |
| 427 | 415 | ||
| 428 | set_socket (c, prop, allocstr (str)); |
416 | set_socket(c,prop,allocstr(str)); |
| 429 | 417 | ||
| 430 | /* link in otherwise */ |
418 | /* link in otherwise */ |
| 431 | if (p) |
419 | if(p) |
| 432 | p->next = c; |
420 | p->next = c; |
| 433 | if (!(*headref)) |
421 | if (!(*headref)) |
| 434 | *headref = c; |
422 | *headref = c; |
| 435 | return c; |
423 | return c; |
| 436 | } |
424 | } |
| 437 | 425 | ||
| 438 | /* matches s into a table of n strings r[], default value is d */ |
426 | /* matches s into a table of n strings r[], default value is d */ |
| 439 | int str_to_int (char *s, char *r[], int n, int d) |
427 | int str_to_int(char * s,char * r[],int n,int d) |
| 440 | { |
428 | { |
| 441 | int i; |
429 | int i; |
| 442 | for (i = 0; i < n; i++) |
430 | for(i=0;i<n;i++) |
| 443 | if (strcmp2 (s, r[i]) == 0) |
431 | if(strcmp2(s,r[i])==0) |
| 444 | { |
432 | { |
| 445 | d = i; |
433 | d=i; |
| 446 | break; |
434 | break; |
| 447 | }; |
435 | }; |
| 448 | return d; |
436 | return d; |
| 449 | } |
437 | } |
| - | 438 | ||
| - | 439 | ||
| 450 | 440 | ||
| 451 | char *decode_how_routed[] = {"FREE_NAME", |
441 | char * decode_how_routed[]= { |
| - | 442 | "FREE_NAME", |
|
| 452 | "MATCHED_NAME", |
443 | "MATCHED_NAME", |
| 453 | "USED_WIRES", |
444 | "USED_WIRES", |
| 454 | "USED_FIXED_WIRES", |
445 | "USED_FIXED_WIRES", |
| 455 | "USED_EXACT_WIRES", |
446 | "USED_EXACT_WIRES", |
| 456 | "CREATED_NET", |
447 | "CREATED_NET", |
| 457 | "CREATED_JUMPER", |
448 | "CREATED_JUMPER", |
| 458 | "FIXED_PINS", |
449 | "FIXED_PINS", |
| 459 | "NOT_ROUTABLE", |
450 | "NOT_ROUTABLE", |
| 460 | "NOT_ROUTABLE_L", /* additions V16.5 onward */ |
451 | "NOT_ROUTABLE_L", /* additions V16.5 onward */ |
| 461 | "NOT_ROUTABLE_H"}; |
452 | "NOT_ROUTABLE_H" |
| - | 453 | }; |
|
| 462 | 454 | ||
| 463 | /* set a net property */ |
455 | /* set a net property */ |
| 464 | __declspec(dllexport) void set_net (net_t *net, property_t prop, char *str) |
456 | __declspec (dllexport) void set_net(net_t * net,property_t prop,char * str) |
| 465 | { |
457 | { |
| 466 | char *s; |
458 | char * s; |
| 467 | s = strdup (str); |
459 | s = strdup(str); |
| 468 | switch (prop) |
460 | switch(prop) |
| 469 | { |
461 | { |
| 470 | case Ident: |
- | |
| 471 | net->identifier = s; |
462 | case Ident: net->identifier = s; break; |
| 472 | break; |
- | |
| 473 | case Name: |
- | |
| 474 | net->name = s; |
463 | case Name: net->name = s; break; |
| 475 | break; |
- | |
| 476 | /* |
464 | /* |
| 477 | case Datatype: net->datatype = s; break; |
465 | case Datatype: net->datatype = s; break; |
| 478 | */ |
466 | */ |
| 479 | case How_Routed: |
467 | case How_Routed: |
| 480 | net->how_routed = (HowRouted_t) str_to_int ( |
468 | net->how_routed = (HowRouted_t)str_to_int(str, |
| - | 469 | decode_how_routed, |
|
| 481 | str, decode_how_routed, sizeof (decode_how_routed) / sizeof (char *), 0); |
470 | sizeof(decode_how_routed)/sizeof(char *), |
| 482 | break; |
471 | 0); |
| 483 | default: |
472 | break; |
| 484 | break; |
473 | default: break; |
| 485 | }; |
474 | }; |
| 486 | } |
475 | } |
| 487 | 476 | ||
| - | 477 | ||
| 488 | /* find a net by property, in a list pointed to by a pointer referred to |
478 | /* find a net by property, in a list pointed to by a pointer referred to |
| 489 | by net_head */ |
479 | by net_head */ |
| 490 | __declspec(dllexport) net_t *find_net ( |
- | |
| 491 | net_t **net_head, property_t prop, char *str, int srchonly) |
480 | __declspec (dllexport) net_t * find_net(net_t ** net_head,property_t prop,char * str,int srchonly ) |
| 492 | { |
481 | { |
| 493 | net_t *c, *p; |
482 | net_t * c, *p; |
| 494 | int f = 0; |
483 | int f=0; |
| 495 | c = *net_head; |
484 | c= *net_head; |
| 496 | p = NULL; |
485 | p=NULL; |
| 497 | while (c) |
486 | while(c) |
| 498 | { |
487 | { |
| 499 | switch (prop) |
488 | switch(prop) |
| 500 | { |
489 | { |
| 501 | case Ident: |
- | |
| 502 | f = strcmp2 (c->identifier, str) == 0; |
490 | case Ident: f=strcmp2(c->identifier,str)==0; break; |
| 503 | break; |
- | |
| 504 | case Name: |
- | |
| 505 | f = strcmp2 (c->name, str) == 0; |
491 | case Name: f=strcmp2(c->name,str)==0; break; |
| 506 | break; |
- | |
| 507 | default: |
492 | default: break; |
| 508 | break; |
- | |
| 509 | }; |
493 | }; |
| 510 | if (f) |
494 | if(f) |
| 511 | break; |
495 | break; |
| 512 | p = c; |
496 | p=c; |
| 513 | c = c->next; |
497 | c=c->next; |
| 514 | }; |
498 | }; |
| 515 | if (srchonly || f) |
499 | if(srchonly || f) |
| 516 | return (c); |
500 | return(c); |
| 517 | 501 | ||
| 518 | c = calloc (1, sizeof (net_t)); /* all pointers are set to be null */ |
502 | c=calloc(1,sizeof(net_t)); /* all pointers are set to be null */ |
| 519 | c->name = nullstr; |
503 | c->name = nullstr; |
| 520 | c->identifier = nullstr; |
504 | c->identifier = nullstr; |
| 521 | c->list_ref = net_head; /* record which list this net is a member of */ |
505 | c->list_ref = net_head; /* record which list this net is a member of */ |
| 522 | 506 | ||
| 523 | c->nodecount = 0; /* calloc does this : put here for readability : Oct 2000 */ |
507 | c->nodecount = 0; /* calloc does this : put here for readability : Oct 2000 */ |
| 524 | 508 | ||
| 525 | c->type_defined = 0; |
509 | c->type_defined= 0; |
| 526 | set_net (c, prop, str); |
510 | set_net(c,prop,str); |
| 527 | 511 | ||
| 528 | c->list_ref = net_head; /* which list does this net begin life on */ |
512 | c->list_ref = net_head; /* which list does this net begin life on */ |
| 529 | 513 | ||
| 530 | /* link at end of list otherwise */ |
514 | /* link at end of list otherwise */ |
| 531 | if (p) |
515 | if(p) |
| 532 | p->next = c; |
516 | p->next = c; |
| 533 | c->prev = p; /* and refer back to it */ |
517 | c->prev = p; /* and refer back to it */ |
| 534 | if (!(*net_head)) |
518 | if (!(*net_head)) |
| 535 | *net_head = c; |
519 | *net_head = c; |
| 536 | 520 | ||
| 537 | return c; |
521 | return c; |
| 538 | } |
522 | } |
| 539 | 523 | ||
| 540 | /* set a node property */ |
524 | /* set a node property */ |
| 541 | __declspec(dllexport) void set_node (node_t *node, property_t prop, char *str) |
525 | __declspec (dllexport) void set_node(node_t * node,property_t prop,char * str) |
| 542 | { |
526 | { |
| 543 | char *s; |
527 | char * s; |
| 544 | s = strdup (str); |
528 | s = strdup(str); |
| 545 | switch (prop) |
529 | switch(prop) |
| 546 | { |
530 | { |
| 547 | case Ident: |
- | |
| 548 | node->identifier = s; |
531 | case Ident: node->identifier = s; break; |
| 549 | break; |
- | |
| 550 | case Name: |
- | |
| 551 | node->name = s; |
532 | case Name: node->name = s; break; |
| 552 | break; |
- | |
| 553 | /* |
533 | /* |
| 554 | case Datatype: node->datatype = s; break; |
534 | case Datatype: node->datatype = s; break; |
| 555 | */ |
535 | */ |
| 556 | default: |
- | |
| 557 | break; |
536 | default: break; |
| 558 | }; |
537 | }; |
| 559 | } |
538 | } |
| 560 | 539 | ||
| 561 | /* locate a node on a chip by a property */ |
- | |
| 562 | __declspec(dllexport) node_t *find_node ( |
- | |
| 563 | socket_t *socket, property_t prop, char *str, int srchonly) |
- | |
| 564 | { |
- | |
| 565 | node_t *c, *p; |
- | |
| 566 | int f = 0; |
- | |
| 567 | - | ||
| 568 | /* catch null pointer reference 23 May 2001 */ |
- | |
| 569 | if (!socket) |
- | |
| 570 | return NULL; |
- | |
| 571 | 540 | ||
| 572 | c = socket->nodes; |
- | |
| 573 | 541 | ||
| 574 | p = NULL; |
542 | /* locate a node on a chip by a property */ |
| - | 543 | __declspec (dllexport) node_t * find_node(socket_t * socket, |
|
| 575 | while (c) |
544 | property_t prop, |
| 576 | { |
545 | char * str, |
| 577 | switch (prop) |
546 | int srchonly) |
| - | 547 | { |
|
| 578 | { |
548 | node_t * c, *p; |
| 579 | case Ident: |
549 | int f=0; |
| - | 550 | ||
| 580 | f = strcmp2 (c->identifier, str) == 0; |
551 | /* catch null pointer reference 23 May 2001 */ |
| - | 552 | if (!socket) |
|
| 581 | break; |
553 | return NULL; |
| - | 554 | ||
| - | 555 | c=socket->nodes; |
|
| - | 556 | ||
| - | 557 | p=NULL; |
|
| - | 558 | while(c) |
|
| - | 559 | { |
|
| 582 | case Name: |
560 | switch(prop) |
| - | 561 | { |
|
| - | 562 | ||
| 583 | f = strcmp2 (c->name, str) == 0; |
563 | case Ident: f=strcmp2(c->identifier,str)==0; break; |
| 584 | break; |
564 | case Name: f=strcmp2(c->name,str)==0; break; |
| 585 | /* case Datatype: f=strcmp2(c->datatype,str)==0; break; */ |
565 | /* case Datatype: f=strcmp2(c->datatype,str)==0; break; */ |
| 586 | default: |
- | |
| 587 | break; |
566 | default: break; |
| 588 | }; |
567 | }; |
| 589 | if (f) |
568 | if(f) |
| 590 | break; |
569 | break; |
| 591 | p = c; |
570 | p=c; |
| 592 | c = c->sktnext; |
571 | c=c->sktnext; |
| 593 | }; |
572 | }; |
| 594 | if (srchonly || f) |
573 | if(srchonly || f) |
| 595 | return (c); |
574 | return(c); |
| 596 | 575 | ||
| 597 | c = calloc (1, sizeof (node_t)); /* all pointers are set to be null */ |
576 | c=calloc(1,sizeof(node_t)); /* all pointers are set to be null */ |
| 598 | c->name = nullstr; |
577 | c->name = nullstr; |
| 599 | c->identifier = nullstr; |
578 | c->identifier = nullstr; |
| 600 | c->socket = socket; |
579 | c->socket = socket; |
| 601 | 580 | ||
| 602 | set_node (c, prop, str); |
581 | set_node(c,prop,str); |
| 603 | /* link at end of list otherwise */ |
582 | /* link at end of list otherwise */ |
| 604 | if (p) |
583 | if(p) |
| 605 | p->sktnext = c; |
584 | p->sktnext = c; |
| 606 | 585 | ||
| 607 | if (!socket->nodes) |
586 | if(!socket->nodes) |
| 608 | socket->nodes = c; |
587 | socket->nodes = c; |
| 609 | 588 | ||
| 610 | socket->lastnode = c; |
589 | socket->lastnode = c; |
| 611 | return c; |
590 | return c; |
| 612 | } |
591 | } |
| 613 | 592 | ||
| 614 | /* this connects the node to the list of node references on the net and |
593 | /* this connects the node to the list of node references on the net and |
| 615 | connects the net to the list of net references on the node */ |
594 | connects the net to the list of net references on the node */ |
| 616 | 595 | ||
| 617 | __declspec(dllexport) void connect_node_net ( |
596 | __declspec (dllexport) void connect_node_net( char * orig_name, |
| 618 | char *orig_name, |
- | |
| 619 | node_t *cnode, |
597 | node_t * cnode, |
| 620 | net_t *cnet, |
598 | net_t * cnet, |
| 621 | pindir_t pintype, |
599 | pindir_t pintype, |
| 622 | vhdl_t *vhdl, |
600 | vhdl_t * vhdl, |
| 623 | vhdl_t *orig_vhdl, |
601 | vhdl_t * orig_vhdl, |
| 624 | expression_t *lhs_expr) |
602 | expression_t * lhs_expr) |
| 625 | { |
603 | { |
| 626 | noderef_t *noderef; |
604 | noderef_t * noderef; |
| 627 | cnet->nodecount++; /* one more node on this net */ |
605 | cnet->nodecount++; /* one more node on this net */ |
| 628 | 606 | ||
| 629 | cnode->net = cnet; /* refer back to net this node is on */ |
607 | cnode->net = cnet; /* refer back to net this node is on */ |
| 630 | cnode->refcount++; /* and count references */ |
608 | cnode->refcount++; /* and count references */ |
| 631 | 609 | ||
| 632 | noderef = calloc (1, sizeof (noderef_t)); |
610 | noderef = calloc(1,sizeof(noderef_t)); |
| 633 | 611 | ||
| 634 | noderef->net = cnet; /* this node reference refers back to its parent net */ |
612 | noderef->net = cnet; /* this node reference refers back to its parent net */ |
| 635 | 613 | ||
| 636 | noderef->pindir = pintype; /* the reference has the pin direction _wanted_ */ |
614 | noderef->pindir = pintype; /* the reference has the pin direction _wanted_ */ |
| 637 | 615 | ||
| 638 | noderef->orig_name = orig_name; /* copy any alias over */ |
616 | noderef->orig_name = orig_name; /* copy any alias over */ |
| 639 | 617 | ||
| 640 | /* remeved reference to datatype */ |
618 | /* remeved reference to datatype */ |
| 641 | noderef->vhdltype = vhdl; |
619 | noderef->vhdltype = vhdl; |
| 642 | 620 | ||
| 643 | noderef->orig_vhdltype = orig_vhdl; |
621 | noderef->orig_vhdltype = orig_vhdl; |
| 644 | 622 | ||
| 645 | noderef->base_noderef = noderef; /* its original reference is itself */ |
623 | noderef->base_noderef = noderef; /* its original reference is itself */ |
| - | 624 | ||
| - | 625 | noderef->lhs_expr = lhs_expr; |
|
| - | 626 | ||
| - | 627 | /* link node reference to the net */ |
|
| - | 628 | noderef->next = cnet->nodes; |
|
| - | 629 | cnet->nodes = noderef; /* place reference on head of list */ |
|
| - | 630 | noderef->node = cnode; |
|
| - | 631 | ||
| - | 632 | } |
|
| 646 | 633 | ||
| 647 | noderef->lhs_expr = lhs_expr; |
- | |
| 648 | 634 | ||
| 649 | /* link node reference to the net */ |
- | |
| 650 | noderef->next = cnet->nodes; |
- | |
| 651 | cnet->nodes = noderef; /* place reference on head of list */ |
- | |
| 652 | noderef->node = cnode; |
- | |
| 653 | } |
- | |
| 654 | 635 | ||
| 655 | /* disconnect a node from the netlist */ |
636 | /* disconnect a node from the netlist */ |
| 656 | /* this intends to remove chip node from net in the routed list. If anyone has made a reference |
637 | /* this intends to remove chip node from net in the routed list. If anyone has made a reference to the node |
| 657 | to the node in a manner which results in this node reappearing then there will be a problem |
638 | in a manner which results in this node reappearing then there will be a problem as it will |
| 658 | as it will reappear (some route algorithms eg. create will do this) */ |
639 | reappear (some route algorithms eg. create will do this) */ |
| 659 | 640 | ||
| 660 | __declspec(dllexport) void disconnect_node (socket_t *chip, node_t *node) |
641 | __declspec (dllexport) void disconnect_node(socket_t * chip, node_t * node) |
| 661 | { |
642 | { |
| 662 | noderef_t *ref, *last_ref; |
643 | noderef_t * ref, * last_ref; |
| 663 | /* locate the net on the routed or named list */ |
644 | /* locate the net on the routed or named list */ |
| - | 645 | if(node->net && (node->net->list_ref== &routed_list || node->net->list_ref== &named_list)) |
|
| - | 646 | { |
|
| - | 647 | net_t * net; |
|
| 664 | if (node->net && |
648 | net = node->net; |
| - | 649 | ref = net->nodes; |
|
| - | 650 | last_ref = NULL; |
|
| - | 651 | /* locate the reference made */ |
|
| - | 652 | while(ref) |
|
| - | 653 | { |
|
| - | 654 | if (ref->node == node) |
|
| - | 655 | break; |
|
| - | 656 | last_ref = ref; |
|
| - | 657 | ref = ref->next; |
|
| - | 658 | } |
|
| 665 | (node->net->list_ref == &routed_list || node->net->list_ref == &named_list)) |
659 | /* reference is located. Remove from list of node references, |
| - | 660 | also patch up list head if needed */ |
|
| - | 661 | if(ref) |
|
| - | 662 | { |
|
| - | 663 | if(last_ref == NULL) |
|
| 666 | { |
664 | { |
| 667 | net_t *net; |
- | |
| 668 | net = node->net; |
665 | net->nodes = ref->next; |
| 669 | ref = net->nodes; |
- | |
| 670 | last_ref = NULL; |
- | |
| 671 | /* locate the reference made */ |
- | |
| 672 | while (ref) |
- | |
| 673 | { |
- | |
| 674 | if (ref->node == node) |
- | |
| 675 | break; |
- | |
| 676 | last_ref = ref; |
- | |
| 677 | ref = ref->next; |
- | |
| 678 | } |
- | |
| 679 | /* reference is located. Remove from list of node references, |
- | |
| 680 | also patch up list head if needed */ |
- | |
| 681 | if (ref) |
- | |
| 682 | { |
- | |
| 683 | if (last_ref == NULL) |
- | |
| 684 | { |
- | |
| 685 | net->nodes = ref->next; |
- | |
| 686 | } |
- | |
| 687 | else |
- | |
| 688 | { |
- | |
| 689 | last_ref->next = ref->next; |
- | |
| 690 | } |
- | |
| 691 | free (ref); |
- | |
| 692 | node->net = NULL; /* disconnect the ned from the node */ |
- | |
| 693 | node->refcount = node->refcount ? node->refcount-- : 0; |
- | |
| 694 | } |
- | |
| 695 | } |
666 | } |
| 696 | } |
- | |
| 697 | - | ||
| 698 | __declspec(dllexport) void define_pin ( |
- | |
| 699 | net_t **net_head, |
- | |
| 700 | socket_t *chip, |
- | |
| 701 | char *i_name, |
- | |
| 702 | int pin_type, |
- | |
| 703 | int pin_group, |
- | |
| 704 | char *i_identifier, |
- | |
| 705 | vhdl_t *vhdl, |
- | |
| 706 | expression_t *lhs_expr) |
- | |
| 707 | { |
- | |
| 708 | unrouted_ref_t *ref, *ptr; |
- | |
| 709 | - | ||
| 710 | int null_name; |
- | |
| 711 | char name[MAXIDLEN]; |
- | |
| 712 | char identifier[MAXIDLEN]; |
- | |
| 713 | - | ||
| 714 | /* actions here are : |
- | |
| 715 | 1: find a new node; |
- | |
| 716 | 2: attach a reference to it to the socket pin list; |
- | |
| 717 | 3: find the net it is joined to by name; |
- | |
| 718 | */ |
- | |
| 719 | - | ||
| 720 | null_name = ISNULLSTR (i_name); |
- | |
| 721 | - | ||
| 722 | /* if the name is not given, then dont create a net for it as it |
- | |
| 723 | is a waste of time */ |
- | |
| 724 | if (null_name) |
- | |
| 725 | /* count another ident for posisble use */ |
- | |
| 726 | sprintf (name, "NE%d", n_idents++); |
- | |
| 727 | else |
- | |
| 728 | strcpy (name, i_name); |
- | |
| 729 | - | ||
| 730 | if (ISNULLSTR (i_identifier)) |
- | |
| 731 | /* count another ident for posisble use */ |
- | |
| 732 | sprintf (identifier, "ID%d", i_idents++); |
- | |
| 733 | else |
- | |
| 734 | strcpy (identifier, i_identifier); |
- | |
| 735 | - | ||
| 736 | /* printf("-- Joining name %s to pin %s\n",name,identifier ); |
- | |
| 737 | */ |
- | |
| 738 | - | ||
| 739 | /* at this stage, simply create a potential reference */ |
- | |
| 740 | - | ||
| 741 | ref = calloc (1, sizeof (unrouted_ref_t)); |
- | |
| 742 | - | ||
| 743 | ref->pindir = pin_type; /* the reference has the pin direction _wanted_ */ |
- | |
| 744 | ref->pin_group = pin_group; |
- | |
| 745 | /* removed reference to datatype */ |
- | |
| 746 | - | ||
| 747 | ref->vhdltype = copy_vhdl (vhdl, chip); |
- | |
| 748 | ref->orig_vhdltype = NULL; |
- | |
| 749 | ref->identifier = allocstr (identifier); |
- | |
| 750 | ref->name = allocstr (name); |
- | |
| 751 | ref->orig_name = NULL; |
- | |
| 752 | ref->listref = net_head; /* identify the list context */ |
- | |
| 753 | ref->lhs_expr = lhs_expr; |
- | |
| 754 | ref->next = NULL; |
- | |
| 755 | if (!chip->unrouted_refs) |
- | |
| 756 | chip->unrouted_refs = ref; |
- | |
| 757 | else |
667 | else |
| 758 | { |
668 | { |
| 759 | ptr = chip->unrouted_refs; |
- | |
| 760 | while (ptr->next) |
- | |
| 761 | ptr = ptr->next; |
- | |
| 762 | ptr->next = ref; |
669 | last_ref->next = ref->next; |
| 763 | } |
670 | } |
| - | 671 | free(ref); |
|
| - | 672 | node->net = NULL; /* disconnect the ned from the node */ |
|
| - | 673 | node->refcount = node->refcount ? node->refcount--: 0 ; |
|
| - | 674 | ||
| - | 675 | } |
|
| - | 676 | } |
|
| - | 677 | } |
|
| 764 | 678 | ||
| 765 | /* splice the unrouted reference on */ |
- | |
| 766 | ref->next = NULL; |
- | |
| 767 | } |
- | |
| 768 | 679 | ||
| 769 | /* this function clears the name fields on identified nets */ |
- | |
| 770 | static void del_list_net_names (net_t *list, char *template) |
- | |
| 771 | { |
- | |
| 772 | int rc, found; |
- | |
| 773 | char *pattern; |
- | |
| 774 | /* compile regular expression */ |
- | |
| 775 | vert_regex_t *preg; |
- | |
| 776 | - | ||
| 777 | if (template) |
- | |
| 778 | { |
- | |
| 779 | pattern = template; |
- | |
| 780 | } |
- | |
| 781 | else |
- | |
| 782 | { |
- | |
| 783 | pattern = ".*"; |
- | |
| 784 | } |
- | |
| 785 | 680 | ||
| 786 | rc = vert_regcomp (&preg, pattern); |
- | |
| 787 | 681 | ||
| 788 | if (rc != 0) |
- | |
| 789 | { |
- | |
| 790 | char errbuff[100]; |
- | |
| 791 | regerror (rc, preg->preg, errbuff, 100); |
- | |
| 792 | Log ( |
- | |
| 793 | LOG_ERROR, |
- | |
| 794 | "-- Problem (rc=%d) %s with '%s' as regular expression\n", |
- | |
| 795 | rc, |
- | |
| 796 | errbuff, |
- | |
| 797 | pattern); |
- | |
| 798 | 682 | ||
| 799 | return /*TCL_ERROR*/; |
- | |
| 800 | } |
- | |
| 801 | 683 | ||
| - | 684 | __declspec (dllexport) void define_pin(net_t ** net_head, |
|
| - | 685 | socket_t * chip, |
|
| 802 | Log ( |
686 | char * i_name, |
| 803 | LOG_GENERAL, |
687 | int pin_type, |
| - | 688 | int pin_group, |
|
| 804 | "-- Beginning clearing name fields : net ID prefix '%s' --\n", |
689 | char * i_identifier, |
| - | 690 | vhdl_t * vhdl, |
|
| 805 | template ? template : "[ALL ID's]"); |
691 | expression_t * lhs_expr) |
| - | 692 | { |
|
| - | 693 | unrouted_ref_t * ref, *ptr; |
|
| - | 694 | ||
| - | 695 | int null_name; |
|
| - | 696 | char name[MAXIDLEN]; |
|
| - | 697 | char identifier[MAXIDLEN]; |
|
| - | 698 | ||
| - | 699 | /* actions here are : |
|
| 806 | while (list) |
700 | 1: find a new node; |
| - | 701 | 2: attach a reference to it to the socket pin list; |
|
| - | 702 | 3: find the net it is joined to by name; |
|
| 807 | { |
703 | */ |
| - | 704 | ||
| - | 705 | null_name = ISNULLSTR(i_name); |
|
| - | 706 | ||
| - | 707 | ||
| 808 | found = regexec (preg->preg, list->identifier, 0, preg->regpatt, 0); |
708 | /* if the name is not given, then dont create a net for it as it |
| 809 | if (!found) |
709 | is a waste of time */ |
| 810 | { |
710 | if(null_name) |
| - | 711 | /* count another ident for posisble use */ |
|
| - | 712 | sprintf(name,"NE%d",n_idents++); |
|
| - | 713 | else |
|
| - | 714 | strcpy(name,i_name); |
|
| - | 715 | ||
| 811 | Log ( |
716 | if(ISNULLSTR(i_identifier)) |
| 812 | LOG_GENERAL, |
717 | /* count another ident for posisble use */ |
| - | 718 | sprintf(identifier,"ID%d",i_idents++); |
|
| - | 719 | else |
|
| - | 720 | strcpy(identifier,i_identifier); |
|
| - | 721 | ||
| - | 722 | /* printf("-- Joining name %s to pin %s\n",name,identifier ); |
|
| - | 723 | */ |
|
| - | 724 | ||
| - | 725 | ||
| - | 726 | /* at this stage, simply create a potential reference */ |
|
| - | 727 | ||
| - | 728 | ||
| - | 729 | ref = calloc(1,sizeof(unrouted_ref_t)); |
|
| - | 730 | ||
| - | 731 | ||
| 813 | "-- Cleared name field for net ID '%s'\n", |
732 | ref->pindir = pin_type; /* the reference has the pin direction _wanted_ */ |
| - | 733 | ref->pin_group = pin_group; |
|
| - | 734 | /* removed reference to datatype */ |
|
| - | 735 | ||
| - | 736 | ref->vhdltype = copy_vhdl(vhdl,chip); |
|
| - | 737 | ref->orig_vhdltype = NULL; |
|
| 814 | list->identifier); |
738 | ref->identifier = allocstr(identifier); |
| 815 | list->name = nullstr; |
739 | ref->name = allocstr(name); |
| - | 740 | ref->orig_name = NULL; |
|
| - | 741 | ref->listref = net_head; /* identify the list context */ |
|
| - | 742 | ref->lhs_expr = lhs_expr; |
|
| 816 | } |
743 | ref->next = NULL; |
| - | 744 | if(!chip->unrouted_refs) |
|
| - | 745 | chip->unrouted_refs = ref; |
|
| - | 746 | else { |
|
| - | 747 | ptr = chip->unrouted_refs; |
|
| - | 748 | while(ptr->next) |
|
| 817 | list = list->next; |
749 | ptr=ptr->next; |
| - | 750 | ptr->next = ref; |
|
| 818 | } |
751 | } |
| - | 752 | ||
| 819 | Log (LOG_GENERAL, "-- Finished clearing name fields --\n"); |
753 | /* splice the unrouted reference on */ |
| 820 | vert_regfree (&preg); |
754 | ref->next = NULL; |
| - | 755 | ||
| - | 756 | ||
| 821 | } |
757 | } |
| 822 | 758 | ||
| 823 | __declspec(dllexport) void del_net_names (char *template) |
- | |
| 824 | { |
- | |
| 825 | del_list_net_names (routed_list, template); |
- | |
| 826 | } |
- | |
| 827 | 759 | ||
| - | 760 | /* this function clears the name fields on identified nets */ |
|
| - | 761 | static void del_list_net_names(net_t * list,char * template ) |
|
| - | 762 | { |
|
| - | 763 | int rc,found; |
|
| - | 764 | char * pattern; |
|
| 828 | /* added 8 March 2000 for PC support */ |
765 | /* compile regular expression */ |
| - | 766 | vert_regex_t * preg; |
|
| - | 767 | ||
| - | 768 | ||
| - | 769 | if (template) |
|
| - | 770 | { |
|
| - | 771 | pattern = template; |
|
| - | 772 | } |
|
| - | 773 | else |
|
| - | 774 | { |
|
| - | 775 | pattern = ".*"; |
|
| - | 776 | } |
|
| - | 777 | ||
| - | 778 | rc = vert_regcomp(&preg,pattern); |
|
| - | 779 | ||
| - | 780 | if (rc != 0 ) |
|
| - | 781 | { |
|
| - | 782 | char errbuff[100]; |
|
| - | 783 | regerror(rc,preg->preg,errbuff,100); |
|
| - | 784 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,pattern); |
|
| - | 785 | ||
| - | 786 | return /*TCL_ERROR*/; |
|
| - | 787 | } |
|
| - | 788 | ||
| - | 789 | ||
| - | 790 | Log(LOG_GENERAL,"-- Beginning clearing name fields : net ID prefix '%s' --\n", |
|
| - | 791 | template?template:"[ALL ID's]"); |
|
| - | 792 | while(list) { |
|
| - | 793 | found = regexec(preg->preg,list->identifier,0,preg->regpatt,0); |
|
| - | 794 | if(!found) { |
|
| - | 795 | Log(LOG_GENERAL,"-- Cleared name field for net ID '%s'\n",list->identifier); |
|
| - | 796 | list->name = nullstr; |
|
| - | 797 | } |
|
| - | 798 | list = list->next; |
|
| - | 799 | } |
|
| - | 800 | Log(LOG_GENERAL,"-- Finished clearing name fields --\n"); |
|
| - | 801 | vert_regfree(&preg); |
|
| - | 802 | } |
|
| - | 803 | ||
| - | 804 | __declspec (dllexport)void del_net_names(char * template ) |
|
| - | 805 | { |
|
| - | 806 | del_list_net_names(routed_list,template ); |
|
| - | 807 | } |
|
| 829 | 808 | ||
| 830 | __declspec(dllexport) void ensure_env_var (char *name, char *defval) |
- | |
| 831 | { |
- | |
| 832 | generic_info_t gen[1]; |
- | |
| 833 | if (get_generic_value (&global_generics, name, gen) != IS_STRING) |
- | |
| 834 | { |
- | |
| 835 | char sbuff[MAXIDLEN]; |
809 | /* added 8 March 2000 for PC support */ |
| 836 | gen->name = name; |
- | |
| 837 | gen->typename = "env_string"; |
- | |
| 838 | /* cannot use $(1) type command line variables as |
- | |
| 839 | *they are not passed here : argc = 0 , argv = NULL*/ |
- | |
| 840 | expand_string (defval, sbuff, 0, NULL); |
- | |
| 841 | gen->expr = compile_string (sbuff); |
- | |
| 842 | gen->g_type = IS_ENV_VAL; |
- | |
| 843 | gen->g_class = DEFAULT; |
- | |
| 844 | 810 | ||
| - | 811 | __declspec (dllexport) void ensure_env_var(char * name, char * defval) { |
|
| - | 812 | generic_info_t gen[1]; |
|
| - | 813 | if (get_generic_value(&global_generics, name,gen) != IS_STRING) { |
|
| - | 814 | char sbuff [MAXIDLEN]; |
|
| - | 815 | gen->name = name; |
|
| - | 816 | gen->typename = "env_string"; |
|
| - | 817 | /* cannot use $(1) type command line variables as |
|
| - | 818 | *they are not passed here : argc = 0 , argv = NULL*/ |
|
| - | 819 | expand_string(defval , sbuff,0 , NULL); |
|
| - | 820 | gen->expr = compile_string(sbuff); |
|
| - | 821 | gen->g_type = IS_ENV_VAL; |
|
| - | 822 | gen->g_class = DEFAULT; |
|
| - | 823 | ||
| 845 | set_generic_value (&global_generics, gen); |
824 | set_generic_value(&global_generics,gen ); |
| 846 | }; |
825 | }; |
| 847 | } |
826 | } |
| 848 | 827 | ||
| 849 | /* initialise default information used around the design database */ |
828 | /* initialise default information used around the design database */ |
| 850 | __declspec(dllexport) void InitialiseData (void) |
829 | __declspec (dllexport) void InitialiseData(void) { |
| - | 830 | generic_info_t gen[1]; |
|
| - | 831 | InitialiseVersionStrings(); |
|
| 851 | { |
832 | |
| 852 | generic_info_t gen[1]; |
833 | if (!default_vhdl_datatype) |
| - | 834 | default_vhdl_datatype= calloc(1,sizeof(vhdl_t)); |
|
| - | 835 | if (!default_vhdl_bustype) |
|
| 853 | InitialiseVersionStrings (); |
836 | default_vhdl_bustype = calloc(1,sizeof(vhdl_t)); |
| - | 837 | ||
| - | 838 | /* if we are using VHDL then look at the VHDL bus formatting tail*/ |
|
| - | 839 | if (get_generic_value(&global_generics, "vhdl_bit_type",gen) == IS_STRING) { |
|
| - | 840 | default_vhdl_datatype->basetype = strdup( gen->expr->left.s ); |
|
| - | 841 | } |
|
| - | 842 | else |
|
| - | 843 | default_vhdl_datatype->basetype = "std_logic"; |
|
| - | 844 | ||
| - | 845 | /* if we are using VHDL then look at the VHDL bus formatting tail*/ |
|
| - | 846 | if (get_generic_value(&global_generics, "vhdl_bus_type",gen) == IS_STRING) { |
|
| - | 847 | default_vhdl_bustype->basetype = strdup( gen->expr->left.s); |
|
| - | 848 | } |
|
| - | 849 | else |
|
| - | 850 | default_vhdl_bustype->basetype = "std_logic_vector"; |
|
| - | 851 | ||
| - | 852 | default_vhdl_bustype->expr = compile_expression(TO,compile_constant(0),compile_constant(0)); |
|
| - | 853 | default_vhdl_bustype->is_vector=1; /* is this port a vector */ |
|
| - | 854 | default_vhdl_bustype->is_downto=1; /* is the vector X TO Y or X DOWNTO Y */ |
|
| - | 855 | ||
| - | 856 | /* look up VERTICAL_INIT and give it a default value if unknown */ |
|
| - | 857 | ensure_env_var("VERTICAL_INIT",VERTICAL_INI_PATH); |
|
| - | 858 | ||
| - | 859 | ensure_env_var("VERTICAL_PATH",VERTICAL_PATH); |
|
| - | 860 | ||
| - | 861 | ||
| - | 862 | } |
|
| - | 863 | ||
| - | 864 | ||
| - | 865 | ||
| - | 866 | ||
| - | 867 | ||
| - | 868 | ||
| - | 869 | __declspec (dllexport) char * decode_which_list(net_t ** list_head) { |
|
| - | 870 | if(list_head == NULL) return "No List"; |
|
| - | 871 | if(list_head == &routed_list) return "routed list"; |
|
| - | 872 | if(list_head == &named_list) return "named list"; |
|
| - | 873 | if(list_head == &unrouted_list) return "unrouted list"; |
|
| - | 874 | return "ERROR : unknown"; |
|
| - | 875 | } |
|
| 854 | 876 | ||
| 855 | if (!default_vhdl_datatype) |
- | |
| 856 | default_vhdl_datatype = calloc (1, sizeof (vhdl_t)); |
- | |
| 857 | if (!default_vhdl_bustype) |
- | |
| 858 | default_vhdl_bustype = calloc (1, sizeof (vhdl_t)); |
- | |
| 859 | 877 | ||
| 860 | /* if we are using VHDL then look at the VHDL bus formatting tail*/ |
- | |
| 861 | if (get_generic_value (&global_generics, "vhdl_bit_type", gen) == IS_STRING) |
- | |
| 862 | { |
- | |
| 863 | default_vhdl_datatype->basetype = strdup (gen->expr->left.s); |
- | |
| 864 | } |
- | |
| 865 | else |
- | |
| 866 | default_vhdl_datatype->basetype = "std_logic"; |
- | |
| 867 | 878 | ||
| 868 | /* if we are using VHDL then look at the VHDL bus formatting tail*/ |
- | |
| 869 | if (get_generic_value (&global_generics, "vhdl_bus_type", gen) == IS_STRING) |
- | |
| 870 | { |
- | |
| 871 | default_vhdl_bustype->basetype = strdup (gen->expr->left.s); |
- | |
| 872 | } |
- | |
| 873 | else |
- | |
| 874 | default_vhdl_bustype->basetype = "std_logic_vector"; |
- | |
| 875 | 879 | ||
| 876 | default_vhdl_bustype->expr = |
- | |
| 877 | compile_expression (TO, compile_constant (0), compile_constant (0)); |
- | |
| 878 | default_vhdl_bustype->is_vector = 1; /* is this port a vector */ |
- | |
| 879 | default_vhdl_bustype->is_downto = 1; /* is the vector X TO Y or X DOWNTO Y */ |
- | |
| 880 | - | ||
| 881 | /* look up VERTICAL_INIT and give it a default value if unknown */ |
- | |
| 882 | ensure_env_var ("VERTICAL_INIT", VERTICAL_INI_PATH); |
- | |
| 883 | - | ||
| 884 | ensure_env_var ("VERTICAL_PATH", VERTICAL_PATH); |
- | |
| 885 | } |
- | |
| 886 | - | ||
| 887 | __declspec(dllexport) char *decode_which_list (net_t **list_head) |
- | |
| 888 | { |
- | |
| 889 | if (list_head == NULL) |
- | |
| 890 | return "No List"; |
- | |
| 891 | if (list_head == &routed_list) |
- | |
| 892 | return "routed list"; |
- | |
| 893 | if (list_head == &named_list) |
- | |
| 894 | return "named list"; |
- | |
| 895 | if (list_head == &unrouted_list) |
- | |
| 896 | return "unrouted list"; |
- | |
| 897 | return "ERROR : unknown"; |
- | |
| 898 | } |
- | |