Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 11 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | * $Id: rename.c,v 1.2 2003/11/06 04:36:03 mjames Exp $ |
2 | * $Id: rename.c,v 1.2 2003/11/06 04:36:03 mjames Exp $ |
3 | * |
3 | * |
4 | * $Log: rename.c,v $ |
4 | * $Log: rename.c,v $ |
5 | * Revision 1.2 2003/11/06 04:36:03 mjames |
5 | * Revision 1.2 2003/11/06 04:36:03 mjames |
6 | * Checkin : builds but has problems with object renaming |
6 | * Checkin : builds but has problems with object renaming |
7 | * |
7 | * |
Line 63... | Line 63... | ||
63 | * Added a datastructure to hide regular expression information from programs. |
63 | * Added a datastructure to hide regular expression information from programs. |
64 | * Changed call to regexec to indicate 0 subexpressions to be matched |
64 | * Changed call to regexec to indicate 0 subexpressions to be matched |
65 | * rather than a number dependent on strlen(string) which was wrong. |
65 | * rather than a number dependent on strlen(string) which was wrong. |
66 | * |
66 | * |
67 | * Revision 1.10 2001/10/18 21:36:17 mjames |
67 | * Revision 1.10 2001/10/18 21:36:17 mjames |
68 | * Added modify pins command : nets inherit identifier from selected socket and pin on that |
68 | * Added modify pins command : nets inherit identifier from selected socket and pin on that socket to ease cross referencing. |
69 | * socket to ease cross referencing. |
- | |
70 | * |
69 | * |
71 | * Revision 1.9 2001/10/11 16:10:16 mjames |
70 | * Revision 1.9 2001/10/11 16:10:16 mjames |
72 | * Corrections to the SWAP command, and printout so that |
71 | * Corrections to the SWAP command, and printout so that |
73 | * WRITE net now outputs all chips in the design so that their generics |
72 | * WRITE net now outputs all chips in the design so that their generics |
74 | * can be passed forward to the next phase. |
73 | * can be passed forward to the next phase. |
Line 107... | Line 106... | ||
107 | * Mike put it here |
106 | * Mike put it here |
108 | * |
107 | * |
109 | * |
108 | * |
110 | * Revision 1.26 2000/08/25 09:57:15 09:57:15 mjames (Mike James) |
109 | * Revision 1.26 2000/08/25 09:57:15 09:57:15 mjames (Mike James) |
111 | * Modified for Vertical2 : support COMPONENTS and SIGNALS |
110 | * Modified for Vertical2 : support COMPONENTS and SIGNALS |
112 | * |
111 | * |
113 | * Revision 1.26 2000/08/25 09:57:15 09:57:15 mjames (Mike James) |
112 | * Revision 1.26 2000/08/25 09:57:15 09:57:15 mjames (Mike James) |
114 | * Part of Release Aug25_alpha |
113 | * Part of Release Aug25_alpha |
115 | * |
114 | * |
116 | * Revision 1.25 2000/08/16 08:57:31 08:57:31 mjames (Mike James) |
115 | * Revision 1.25 2000/08/16 08:57:31 08:57:31 mjames (Mike James) |
117 | * Part of Release CD01_Aug2000 |
116 | * Part of Release CD01_Aug2000 |
118 | * |
117 | * |
119 | * Revision 1.24 2000/08/14 14:45:12 14:45:12 mjames (Mike James) |
118 | * Revision 1.24 2000/08/14 14:45:12 14:45:12 mjames (Mike James) |
120 | * Part of Release Aug_14_2000 |
119 | * Part of Release Aug_14_2000 |
121 | * |
120 | * |
122 | * Revision 1.23 2000/08/11 08:30:33 08:30:33 mjames (Mike James) |
121 | * Revision 1.23 2000/08/11 08:30:33 08:30:33 mjames (Mike James) |
123 | * Part of Release Aug_11_2000 |
122 | * Part of Release Aug_11_2000 |
124 | * |
123 | * |
125 | * Revision 1.22 2000/08/09 10:31:48 10:31:48 mjames (Mike James) |
124 | * Revision 1.22 2000/08/09 10:31:48 10:31:48 mjames (Mike James) |
126 | * Part of Release Aug__9_2000 |
125 | * Part of Release Aug__9_2000 |
127 | * |
126 | * |
128 | * Revision 1.21 2000/05/31 11:42:58 11:42:58 mjames (Mike James) |
127 | * Revision 1.21 2000/05/31 11:42:58 11:42:58 mjames (Mike James) |
129 | * Part of Release May_31_2000 |
128 | * Part of Release May_31_2000 |
130 | * |
129 | * |
131 | * Revision 1.20 2000/05/08 17:01:38 17:01:38 mjames (Mike James) |
130 | * Revision 1.20 2000/05/08 17:01:38 17:01:38 mjames (Mike James) |
132 | * Part of Release May__8_2000 |
131 | * Part of Release May__8_2000 |
133 | * |
132 | * |
134 | * Revision 1.19 2000/05/08 16:59:31 16:59:31 mjames (Mike James) |
133 | * Revision 1.19 2000/05/08 16:59:31 16:59:31 mjames (Mike James) |
135 | * Part of Release May__8_2000 |
134 | * Part of Release May__8_2000 |
136 | * |
135 | * |
137 | * Revision 1.18 2000/05/08 16:57:08 16:57:08 mjames (Mike James) |
136 | * Revision 1.18 2000/05/08 16:57:08 16:57:08 mjames (Mike James) |
138 | * Part of Release May__8_2000 |
137 | * Part of Release May__8_2000 |
139 | * |
138 | * |
140 | * Revision 1.17 2000/03/08 16:19:26 16:19:26 mjames (Mike James) |
139 | * Revision 1.17 2000/03/08 16:19:26 16:19:26 mjames (Mike James) |
141 | * New version including PC |
140 | * New version including PC |
142 | * |
141 | * |
143 | * Revision 1.14 2000/01/20 15:58:48 15:58:48 mjames (Mike James) |
142 | * Revision 1.14 2000/01/20 15:58:48 15:58:48 mjames (Mike James) |
144 | * Part of Release R22 |
143 | * Part of Release R22 |
145 | * |
144 | * |
146 | * Revision 1.13 99/12/22 11:15:29 11:15:29 mjames (Mike James) |
145 | * Revision 1.13 99/12/22 11:15:29 11:15:29 mjames (Mike James) |
147 | * Part of Release Dec_22_1999 |
146 | * Part of Release Dec_22_1999 |
148 | * |
147 | * |
149 | * Revision 1.12 99/06/25 14:35:49 14:35:49 mjames (Mike James) |
148 | * Revision 1.12 99/06/25 14:35:49 14:35:49 mjames (Mike James) |
150 | * Added in reference to expression.h, but no changes made |
149 | * Added in reference to expression.h, but no changes made |
151 | * to the function of acfread yet. |
150 | * to the function of acfread yet. |
152 | * |
151 | * |
153 | * Revision 1.11 99/05/04 09:52:43 09:52:43 mjames (Mike James) |
152 | * Revision 1.11 99/05/04 09:52:43 09:52:43 mjames (Mike James) |
154 | * General checkin |
153 | * General checkin |
155 | * |
154 | * |
156 | * Revision 1.10 98/08/12 14:22:18 14:22:18 mjames (Mike James) |
155 | * Revision 1.10 98/08/12 14:22:18 14:22:18 mjames (Mike James) |
157 | * Corrected include file list |
156 | * Corrected include file list |
158 | * |
157 | * |
159 | * Revision 1.9 98/04/24 14:07:51 14:07:51 mjames (Mike James) |
158 | * Revision 1.9 98/04/24 14:07:51 14:07:51 mjames (Mike James) |
160 | * Added pin name swapping code |
159 | * Added pin name swapping code |
161 | * |
160 | * |
162 | * Revision 1.8 98/03/16 11:38:24 11:38:24 mjames (Mike James) |
161 | * Revision 1.8 98/03/16 11:38:24 11:38:24 mjames (Mike James) |
163 | * Removed an old bug - suffixing of PCB names has been broken for about |
162 | * Removed an old bug - suffixing of PCB names has been broken for about |
164 | * a year. If a pcb were read in non-suffixed and then another with a suffix, |
163 | * a year. If a pcb were read in non-suffixed and then another with a suffix, |
165 | * the suffix would be applied over all of the sockets and nets, not just the new ones. |
164 | * the suffix would be applied over all of the sockets and nets, not just the new ones. |
166 | * |
165 | * |
167 | * Revision 1.7 98/02/11 11:27:06 11:27:06 mjames (Mike James) |
166 | * Revision 1.7 98/02/11 11:27:06 11:27:06 mjames (Mike James) |
168 | * Checked in for version 6.2a |
167 | * Checked in for version 6.2a |
169 | * |
168 | * |
170 | * Revision 1.6 97/04/23 08:43:22 08:43:22 mjames (Mike James) |
169 | * Revision 1.6 97/04/23 08:43:22 08:43:22 mjames (Mike James) |
171 | * CHecked in for release rel23041997 |
170 | * CHecked in for release rel23041997 |
172 | * |
171 | * |
173 | * Revision 1.5 96/07/19 14:38:51 14:38:51 mjames (Mike James) |
172 | * Revision 1.5 96/07/19 14:38:51 14:38:51 mjames (Mike James) |
174 | * Update to give to PRL |
173 | * Update to give to PRL |
175 | * |
174 | * |
176 | * Revision 1.4 1996/07/12 15:52:12 mjames |
175 | * Revision 1.4 1996/07/12 15:52:12 mjames |
177 | * Sorted out things like Alias and Jumpers |
176 | * Sorted out things like Alias and Jumpers |
178 | * Work Correctly |
177 | * Work Correctly |
179 | * Print COrrectly |
178 | * Print COrrectly |
180 | * |
179 | * |
Line 183... | Line 182... | ||
183 | * Work Correctly |
182 | * Work Correctly |
184 | * Print COrrectly |
183 | * Print COrrectly |
185 | * |
184 | * |
186 | * Revision 1.3 96/06/04 11:53:28 11:53:28 mjames (Mike James) |
185 | * Revision 1.3 96/06/04 11:53:28 11:53:28 mjames (Mike James) |
187 | * Corrected the operation of the renaming function |
186 | * Corrected the operation of the renaming function |
188 | * |
187 | * |
189 | * Revision 1.2 96/05/29 11:00:10 11:00:10 mjames (Mike James) |
188 | * Revision 1.2 96/05/29 11:00:10 11:00:10 mjames (Mike James) |
190 | * Added explanatory comments |
189 | * Added explanatory comments |
191 | * |
190 | * |
192 | * Revision 1.1 96/05/29 10:53:13 10:53:13 mjames (Mike James) |
191 | * Revision 1.1 96/05/29 10:53:13 10:53:13 mjames (Mike James) |
193 | * Initial revision |
192 | * Initial revision |
194 | * */ |
193 | * */ |
195 | 194 | ||
196 | #include "rename.h" |
- | |
197 | 195 | ||
- | 196 | #include <stdio.h> |
|
198 | #include "chck_names.h" |
197 | #include <string.h> |
199 | #include "cmdlog.h" |
198 | #include <stdlib.h> |
200 | #include "cmdparse.h" |
199 | #include <ctype.h> |
- | 200 | #include <sys/types.h> |
|
- | 201 | #include <regex.h> |
|
- | 202 | ||
- | 203 | ||
- | 204 | ||
201 | #include "database.h" |
205 | #include "vertcl_main.h" |
202 | #include "expression.h" |
206 | #include "expression.h" |
203 | #include "generic.h" |
207 | #include "generic.h" |
- | 208 | #include "database.h" |
|
- | 209 | #include "rename.h" |
|
- | 210 | #include "cmdparse.h" |
|
- | 211 | #include "cmdlog.h" |
|
204 | #include "lx_support.h" |
212 | #include "lx_support.h" |
- | 213 | #include "chck_names.h" |
|
205 | #include "sorting.h" |
214 | #include "sorting.h" |
206 | #include "vertcl_main.h" |
- | |
207 | - | ||
208 | #include <ctype.h> |
- | |
209 | #include <regex.h> |
- | |
210 | #include <stdio.h> |
- | |
211 | #include <stdlib.h> |
- | |
212 | #include <string.h> |
- | |
213 | #include <sys/types.h> |
- | |
214 | 215 | ||
215 | #ident \ |
- | |
216 | "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/rename.c,v 1.2 2003/11/06 04:36:03 mjames Exp $" |
216 | #ident "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/rename.c,v 1.2 2003/11/06 04:36:03 mjames Exp $" |
217 | 217 | ||
218 | /* added on to suffix all signal names */ |
218 | /* added on to suffix all signal names */ |
219 | /* all new objects will appear after the 'mark'. Only |
219 | /* all new objects will appear after the 'mark'. Only |
220 | these new objects need to be renamed by adding a suffix. |
220 | these new objects need to be renamed by adding a suffix. |
221 | Older objects have already been renamed. */ |
221 | Older objects have already been renamed. */ |
222 | 222 | ||
223 | static net_t *mark_nets = NULL; |
223 | static net_t * mark_nets = NULL; |
224 | static socket_t *mark_skts = NULL; |
224 | static socket_t * mark_skts = NULL; |
225 | 225 | ||
226 | /* record the last known net and socket before |
226 | /* record the last known net and socket before |
227 | reading in new nets and sockets */ |
227 | reading in new nets and sockets */ |
228 | 228 | ||
229 | void mark_board_objects (void) |
229 | void mark_board_objects(void) { |
230 | { |
- | |
231 | net_t *net = routed_list; |
230 | net_t * net = routed_list; |
232 | socket_t *skt = socket_head; |
231 | socket_t * skt = socket_head; |
233 | while (net && net->next) |
232 | while(net && net->next ) { |
234 | { |
- | |
235 | net = net->next; |
233 | net = net->next; |
236 | } |
234 | } |
237 | mark_nets = net; |
235 | mark_nets = net; |
238 | while (skt && skt->next) |
236 | while(skt && skt->next ) { |
239 | { |
- | |
240 | skt = skt->next; |
237 | skt = skt->next; |
241 | } |
238 | } |
242 | mark_skts = skt; |
239 | mark_skts = skt; |
243 | /* |
240 | /* |
244 | printf("Mark at net=%p and skt=%p\n",mark_nets,mark_skts); |
241 | printf("Mark at net=%p and skt=%p\n",mark_nets,mark_skts); |
245 | */ |
242 | */ |
246 | } |
243 | } |
247 | 244 | ||
248 | /* only name nets that are not null names */ |
- | |
249 | static char *alter_id (char *id, char *suffix) |
- | |
250 | { |
- | |
251 | if (!ISNULLSTR (id) && !ISNULLSTR (suffix)) |
- | |
252 | { |
- | |
253 | id = realloc (id, strlen (id) + strlen (suffix) + 1); |
- | |
254 | strcat (id, suffix); |
- | |
255 | return (id); |
- | |
256 | } |
- | |
257 | return NULL; |
- | |
258 | } |
- | |
259 | 245 | ||
- | 246 | /* only name nets that are not null names */ |
|
- | 247 | static char * alter_id(char * id,char * suffix) |
|
- | 248 | { |
|
- | 249 | if(!ISNULLSTR(id) && !ISNULLSTR(suffix)) |
|
- | 250 | { |
|
- | 251 | id = realloc(id,strlen(id)+strlen(suffix)+1); |
|
- | 252 | strcat (id,suffix); |
|
- | 253 | return(id); |
|
- | 254 | } |
|
- | 255 | return NULL; |
|
- | 256 | } |
|
- | 257 | ||
- | 258 | ||
260 | /* suffixes all net and component identifiers |
259 | /* suffixes all net and component identifiers |
261 | since the last 'mark_board_objects' call with the string s */ |
260 | since the last 'mark_board_objects' call with the string s */ |
262 | 261 | ||
263 | void set_board_suffix (char *s) |
262 | void set_board_suffix(char * s) |
264 | { |
263 | { |
265 | net_t *net = mark_nets; |
264 | net_t * net = mark_nets; |
266 | socket_t *skt = mark_skts; |
265 | socket_t * skt = mark_skts; |
267 | 266 | ||
268 | /* |
- | |
269 | printf("Mark at net=%p and skt=%p\n",mark_nets,mark_skts); |
- | |
270 | */ |
- | |
271 | /* flag the nets and sockets as having been renamed */ |
- | |
272 | mark_nets = NULL; |
- | |
273 | mark_skts = NULL; |
- | |
274 | - | ||
275 | if (net) |
- | |
276 | net = net->next; /* move to next one (new one) */ |
- | |
277 | else |
- | |
278 | net = routed_list; |
- | |
279 | if (skt) |
- | |
280 | skt = skt->next; /* ditto */ |
- | |
281 | else |
- | |
282 | skt = socket_head; |
- | |
283 | 267 | ||
- | 268 | /* |
|
- | 269 | printf("Mark at net=%p and skt=%p\n",mark_nets,mark_skts); |
|
- | 270 | */ |
|
- | 271 | /* flag the nets and sockets as having been renamed */ |
|
- | 272 | mark_nets = NULL; |
|
- | 273 | mark_skts = NULL; |
|
- | 274 | ||
- | 275 | if(net) |
|
284 | /* rename all of the net identifiers */ |
276 | net=net->next; /* move to next one (new one) */ |
- | 277 | else |
|
285 | while (net) |
278 | net=routed_list; |
286 | { |
279 | if(skt) |
- | 280 | skt=skt->next; /* ditto */ |
|
- | 281 | else |
|
- | 282 | skt=socket_head; |
|
- | 283 | ||
- | 284 | ||
- | 285 | /* rename all of the net identifiers */ |
|
- | 286 | while(net) { |
|
287 | struct net *sub_n = net->subnets; |
287 | struct net * sub_n = net->subnets; |
288 | 288 | ||
289 | /* jumpered nets have their subnets renamed */ |
289 | /* jumpered nets have their subnets renamed */ |
290 | if (sub_n && net->how_joined == Jumpered) |
290 | if(sub_n && net->how_joined == Jumpered) |
291 | while (sub_n) |
- | |
292 | { |
291 | while (sub_n) { |
293 | sub_n->identifier = alter_id (sub_n->identifier, s); |
292 | sub_n->identifier = alter_id(sub_n->identifier,s); |
294 | sub_n = sub_n->subnets; |
293 | sub_n = sub_n -> subnets; |
295 | } |
294 | } |
296 | else |
295 | else |
297 | net->identifier = alter_id (net->identifier, s); |
296 | net->identifier = alter_id(net->identifier,s); |
298 | net = net->next; |
297 | net = net->next; |
299 | } |
298 | } |
300 | /* rename all of the socket identifiers */ |
299 | /* rename all of the socket identifiers */ |
301 | while (skt) |
300 | while(skt) { |
302 | { |
- | |
303 | skt->identifier = alter_id (skt->identifier, s); |
301 | skt->identifier = alter_id(skt->identifier,s); |
304 | if (skt->name) /* mod MDJ July 2001 */ |
302 | if(skt->name) /* mod MDJ July 2001 */ |
305 | skt->name = alter_id (skt->name, s); |
303 | skt->name = alter_id(skt->name,s); |
306 | skt = skt->next; |
304 | skt = skt->next; |
307 | } |
305 | } |
308 | } |
306 | |
- | 307 | ||
- | 308 | } |
|
309 | 309 | ||
310 | /*********************************************************************/ |
310 | /*********************************************************************/ |
311 | /* Pin_swapping : reverse A23 to 23a */ |
311 | /* Pin_swapping : reverse A23 to 23a */ |
312 | /* allow up to lead_chars before digits to permit pin swap */ |
312 | /* allow up to lead_chars before digits to permit pin swap */ |
313 | /* lead_chars = 2 -> aa23 maps to 23aa but pin23 remains unswapped */ |
313 | /* lead_chars = 2 -> aa23 maps to 23aa but pin23 remains unswapped */ |
314 | /*********************************************************************/ |
314 | /*********************************************************************/ |
315 | /* modified from the original, now allows swapping 1a to a1 if |
315 | /* modified from the original, now allows swapping 1a to a1 if |
316 | * AlphaSwap_t == Want_A1 |
316 | * AlphaSwap_t == Want_A1 |
317 | * or allows swapping a1 to 1a if |
317 | * or allows swapping a1 to 1a if |
318 | * AlphaSwap_t == Want_1A |
318 | * AlphaSwap_t == Want_1A |
319 | * probably better using the renaming command below. |
319 | * probably better using the renaming command below. |
320 | */ |
320 | */ |
321 | void pin_id_swap (char *template, int lead_chars, AlphaSwap_t lead_alpha) |
321 | void pin_id_swap(char * template, |
322 | { |
- | |
323 | enum |
322 | int lead_chars, |
324 | { |
323 | AlphaSwap_t lead_alpha) { |
325 | First_Char, |
324 | enum {First_Char, |
326 | Leading_Chars, |
325 | Leading_Chars, |
327 | Trailing_Digits, |
326 | Trailing_Digits, |
328 | Leading_Digits, |
327 | Leading_Digits, |
329 | Trailing_Chars, |
328 | Trailing_Chars, |
330 | No_Swap |
- | |
331 | } SwapState; |
329 | No_Swap } SwapState; |
332 | int rc; |
330 | int rc; |
333 | socket_t *chip; |
331 | socket_t * chip; |
334 | node_t *nodes; |
332 | node_t * nodes; |
335 | /* compile regular expression */ |
333 | /* compile regular expression */ |
336 | vert_regex_t *preg; |
334 | vert_regex_t * preg; |
- | 335 | ||
337 | 336 | ||
338 | if (ISNULLSTR (template)) |
337 | if(ISNULLSTR(template)) { |
339 | { |
- | |
340 | template = ".*"; |
338 | template = ".*"; |
341 | } |
339 | } |
342 | rc = vert_regcomp (&preg, template); |
340 | rc = vert_regcomp(&preg,template); |
343 | if (rc != 0) |
341 | if (rc != 0 ) |
344 | { |
342 | { |
345 | char errbuff[100]; |
343 | char errbuff[100]; |
346 | regerror (rc, preg->preg, errbuff, 100); |
344 | regerror(rc,preg->preg,errbuff,100); |
- | 345 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,template); |
|
- | 346 | ||
- | 347 | /* return TCL_ERROR; |
|
- | 348 | */ |
|
- | 349 | return; |
|
- | 350 | } |
|
- | 351 | else |
|
- | 352 | { |
|
- | 353 | Log(LOG_GENERAL,"-- Using '%s' as match pattern\n",template); |
|
- | 354 | } |
|
- | 355 | ||
- | 356 | ||
- | 357 | if (lead_alpha == Want_A1) { |
|
- | 358 | Log(LOG_GENERAL,"-- Swapping pin identifiers with up to %d leading letters\n", |
|
347 | Log ( |
359 | lead_chars); |
- | 360 | } |
|
- | 361 | else { |
|
- | 362 | Log(LOG_GENERAL,"-- Swapping pin identifiers with up to %d trailing letters\n", |
|
348 | LOG_ERROR, |
363 | lead_chars); |
- | 364 | } |
|
- | 365 | Log(LOG_GENERAL,"-- for sockets matching template '%s' --\n", |
|
- | 366 | template?template:"[ALL Sockets]"); |
|
- | 367 | ||
- | 368 | chip = socket_head; |
|
- | 369 | while(chip) { |
|
- | 370 | int found; |
|
- | 371 | ||
- | 372 | ||
- | 373 | found = regexec(preg->preg,chip->identifier,0,preg->regpatt,0); |
|
- | 374 | ||
- | 375 | if(!found) { |
|
349 | "-- Problem (rc=%d) %s with '%s' as regular expression\n", |
376 | Log(LOG_GENERAL,"-- Processing socket '%s' --\n",chip->identifier); |
- | 377 | ||
- | 378 | nodes = chip -> nodes ; |
|
- | 379 | while(nodes) { |
|
- | 380 | int lead_count = 0; |
|
350 | rc, |
381 | int done = 0; |
- | 382 | char new_id [MAXIDLEN]; |
|
- | 383 | char * pos = nodes->identifier; |
|
- | 384 | SwapState = First_Char; |
|
- | 385 | while(pos && *pos && !done) { |
|
- | 386 | ||
- | 387 | /* |
|
- | 388 | printf("%s (%c) State %d\n",nodes->identifier,*pos,SwapState); |
|
- | 389 | */ |
|
351 | errbuff, |
390 | switch(SwapState) { |
352 | template); |
391 | case First_Char: |
353 | 392 | ||
- | 393 | if(lead_alpha== Want_A1 &&isdigit(*pos) && lead_chars > 0) { |
|
- | 394 | SwapState = Leading_Digits; |
|
354 | /* return TCL_ERROR; |
395 | lead_count = 1; |
- | 396 | break; |
|
355 | */ |
397 | } |
- | 398 | if(lead_alpha== Want_1A &&isalpha(*pos) && lead_chars > 0) { |
|
- | 399 | SwapState = Leading_Chars; |
|
- | 400 | lead_count = 1; |
|
356 | return; |
401 | break; |
357 | } |
402 | } |
- | 403 | /* no action needed, so continue */ |
|
- | 404 | SwapState = No_Swap; |
|
- | 405 | done = 1; |
|
- | 406 | break; |
|
358 | else |
407 | |
- | 408 | case Leading_Chars: |
|
359 | { |
409 | |
- | 410 | if (isdigit (*pos)) { |
|
360 | Log (LOG_GENERAL, "-- Using '%s' as match pattern\n", template); |
411 | if(lead_count <= lead_chars) { /* encountered a digit after a character success so far */ |
- | 412 | SwapState = Trailing_Digits; |
|
- | 413 | break; |
|
- | 414 | } |
|
- | 415 | else{ |
|
- | 416 | SwapState = No_Swap; |
|
- | 417 | done = 1; |
|
- | 418 | break; |
|
- | 419 | } |
|
- | 420 | } |
|
- | 421 | if(isalpha ( *pos)) { |
|
- | 422 | lead_count++; |
|
- | 423 | break; |
|
361 | } |
424 | } |
- | 425 | SwapState = No_Swap; |
|
- | 426 | done = 1; |
|
- | 427 | break; |
|
362 | 428 | ||
363 | if (lead_alpha == Want_A1) |
429 | case Leading_Digits: |
364 | { |
430 | |
365 | Log ( |
431 | if (isalpha (*pos)) { |
366 | LOG_GENERAL, |
432 | if(lead_count <= lead_chars) { /* encountered a character after a number success so far */ |
367 | "-- Swapping pin identifiers with up to %d leading letters\n", |
433 | SwapState = Trailing_Chars; |
368 | lead_chars); |
434 | break; |
369 | } |
435 | } |
370 | else |
436 | else{ |
- | 437 | SwapState = No_Swap; |
|
- | 438 | done = 1; |
|
371 | { |
439 | break; |
372 | Log ( |
440 | } |
373 | LOG_GENERAL, |
441 | } |
374 | "-- Swapping pin identifiers with up to %d trailing letters\n", |
442 | if(isdigit ( *pos)) { /* continue ok */ |
375 | lead_chars); |
443 | lead_count++; |
376 | } |
444 | break; |
377 | Log ( |
445 | } |
378 | LOG_GENERAL, |
446 | SwapState = No_Swap; |
379 | "-- for sockets matching template '%s' --\n", |
447 | done = 1; |
380 | template ? template : "[ALL Sockets]"); |
448 | break; |
381 | 449 | ||
- | 450 | ||
- | 451 | case Trailing_Digits: |
|
- | 452 | ||
- | 453 | if (!isdigit (*pos)){ |
|
- | 454 | SwapState = No_Swap; |
|
- | 455 | done = 1; |
|
- | 456 | } |
|
382 | chip = socket_head; |
457 | break; |
- | 458 | case Trailing_Chars: |
|
- | 459 | ||
- | 460 | if (!isalpha (*pos)){ |
|
- | 461 | SwapState = No_Swap; |
|
- | 462 | done = 1; |
|
383 | while (chip) |
463 | } |
- | 464 | break; |
|
- | 465 | default: break; |
|
384 | { |
466 | } |
- | 467 | pos++; |
|
- | 468 | } |
|
- | 469 | /* on arrival here in either state we can swap the two parts of the ident */ |
|
- | 470 | if (SwapState == Trailing_Digits || SwapState == Trailing_Chars) { |
|
- | 471 | int i,l; |
|
- | 472 | strcpy (new_id,(nodes->identifier)+lead_count); |
|
- | 473 | strncat (new_id,nodes->identifier,lead_count); |
|
- | 474 | l = strlen(new_id); |
|
- | 475 | for(i=0;i<l;i++) |
|
- | 476 | new_id[i] = tolower(new_id[i]); |
|
- | 477 | Log(LOG_GENERAL,"# Renaming %s(%s) to %s(%s)\n", |
|
- | 478 | chip->identifier, nodes->identifier, |
|
- | 479 | chip->identifier, new_id); |
|
- | 480 | strcpy (nodes->identifier,new_id); |
|
385 | int found; |
481 | } |
- | 482 | nodes = nodes->sktnext; |
|
- | 483 | } |
|
- | 484 | } |
|
- | 485 | chip = chip->next; |
|
- | 486 | } |
|
- | 487 | vert_regfree(&preg); |
|
- | 488 | } |
|
- | 489 | ||
- | 490 | ||
- | 491 | /***************************************************************************************/ |
|
- | 492 | /* Name nets after node name on device instead of pcb CAD name */ |
|
- | 493 | /* Initially lookup all matching sockets */ |
|
386 | 494 | ||
387 | found = regexec (preg->preg, chip->identifier, 0, preg->regpatt, 0); |
- | |
388 | 495 | ||
- | 496 | void alter_net_to_socket_name(char * chip_id_template,char * prefix_opt) |
|
- | 497 | { |
|
389 | if (!found) |
498 | node_t * chip_node ; |
- | 499 | int found,rc,count = 0; |
|
- | 500 | socket_t * socket; |
|
- | 501 | vert_regex_t * preg; |
|
- | 502 | ||
- | 503 | socket = socket_head; |
|
- | 504 | ||
- | 505 | /* create_unrouted_list(); */ |
|
- | 506 | /* compile regular expression */ |
|
- | 507 | ||
- | 508 | ||
- | 509 | if(!chip_id_template) { |
|
- | 510 | chip_id_template = ".*"; |
|
- | 511 | } |
|
- | 512 | ||
- | 513 | rc = vert_regcomp(&preg,chip_id_template); |
|
390 | { |
514 | if (rc != 0 ) |
- | 515 | { |
|
- | 516 | char errbuff[100]; |
|
- | 517 | regerror(rc,preg->preg,errbuff,100); |
|
- | 518 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,chip_id_template); |
|
- | 519 | ||
- | 520 | /* return TCL_ERROR; |
|
- | 521 | */ |
|
- | 522 | return; |
|
- | 523 | } |
|
- | 524 | else |
|
- | 525 | { |
|
391 | Log (LOG_GENERAL, "-- Processing socket '%s' --\n", chip->identifier); |
526 | Log(LOG_GENERAL,"-- Using '%s' as match pattern\n",chip_id_template); |
- | 527 | } |
|
- | 528 | while(socket ) |
|
- | 529 | { |
|
- | 530 | ||
- | 531 | found = regexec(preg->preg,socket->identifier,0,preg->regpatt,0); |
|
392 | 532 | ||
393 | nodes = chip->nodes; |
- | |
394 | while (nodes) |
- | |
395 | { |
533 | if(!found) { |
396 | int lead_count = 0; |
- | |
397 | int done = 0; |
- | |
398 | char new_id[MAXIDLEN]; |
- | |
399 | char *pos = nodes->identifier; |
- | |
400 | SwapState = First_Char; |
- | |
401 | while (pos && *pos && !done) |
- | |
402 | { |
- | |
403 | /* |
- | |
404 | printf("%s (%c) State |
- | |
405 | %d\n",nodes->identifier,*pos,SwapState); |
- | |
406 | */ |
- | |
407 | switch (SwapState) |
- | |
408 | { |
- | |
409 | case First_Char: |
- | |
410 | 534 | /* |
|
411 | if (lead_alpha == Want_A1 && isdigit (*pos) && |
- | |
412 | lead_chars > 0) |
- | |
413 | { |
- | |
414 | SwapState = Leading_Digits; |
- | |
415 | lead_count = 1; |
- | |
416 | break; |
- | |
417 | } |
- | |
418 | if (lead_alpha == Want_1A && isalpha (*pos) && |
- | |
419 | lead_chars > 0) |
- | |
420 | { |
- | |
421 | SwapState = Leading_Chars; |
- | |
422 | lead_count = 1; |
- | |
423 | break; |
- | |
424 | } |
- | |
425 | /* no action needed, so continue */ |
- | |
426 | SwapState = No_Swap; |
- | |
427 | done = 1; |
- | |
428 | break; |
535 | Log(LOG_GENERAL,"found %s\n",skt->identifier); |
429 | 536 | */ |
|
430 | case Leading_Chars: |
537 | count++; |
431 | - | ||
432 | if (isdigit (*pos)) |
- | |
433 | { |
538 | chip_node = socket-> nodes; |
434 | if (lead_count <= lead_chars) |
- | |
435 | { /* encountered a digit after a |
- | |
436 | character success so far */ |
- | |
437 | SwapState = Trailing_Digits; |
- | |
438 | break; |
- | |
439 | } |
- | |
440 | else |
- | |
441 | { |
- | |
442 | SwapState = No_Swap; |
- | |
443 | done = 1; |
- | |
444 | break; |
- | |
445 | } |
- | |
446 | } |
539 | while (chip_node) |
447 | if (isalpha (*pos)) |
- | |
448 | { |
540 | { |
449 | lead_count++; |
- | |
450 | break; |
- | |
451 | } |
541 | char name_buff[MAXIDLEN]; |
452 | SwapState = No_Swap; |
- | |
453 | done = 1; |
- | |
454 | break; |
- | |
455 | - | ||
456 | case Leading_Digits: |
- | |
457 | - | ||
458 | if (isalpha (*pos)) |
- | |
459 | { |
542 | int count; |
460 | if (lead_count <= lead_chars) |
- | |
461 | { /* encountered a character after a |
- | |
462 | number success so far */ |
- | |
463 | SwapState = Trailing_Chars; |
- | |
464 | break; |
- | |
465 | } |
- | |
466 | else |
- | |
467 | { |
- | |
468 | SwapState = No_Swap; |
- | |
469 | done = 1; |
- | |
470 | break; |
- | |
471 | } |
- | |
472 | } |
543 | net_t * net = chip_node->net; |
473 | if (isdigit (*pos)) |
- | |
474 | { /* continue ok */ |
- | |
475 | lead_count++; |
- | |
476 | break; |
- | |
477 | } |
544 | if(net && IS_ROUTABLE(net->how_routed)) |
478 | SwapState = No_Swap; |
- | |
479 | done = 1; |
- | |
480 | break; |
- | |
481 | - | ||
482 | case Trailing_Digits: |
- | |
483 | - | ||
484 | if (!isdigit (*pos)) |
- | |
485 | { |
545 | { |
486 | SwapState = No_Swap; |
- | |
487 | done = 1; |
546 | if (prefix_opt) /* TH requests this change. Not a problem */ |
488 | } |
- | |
489 | break; |
- | |
490 | case Trailing_Chars: |
- | |
491 | - | ||
492 | if (!isalpha (*pos)) |
- | |
493 | { |
547 | { |
494 | SwapState = No_Swap; |
548 | count = sprintf(name_buff,"%s%s",prefix_opt,chip_node->identifier); |
495 | done = 1; |
- | |
496 | } |
- | |
497 | break; |
- | |
498 | default: |
- | |
499 | break; |
- | |
500 | } |
549 | } |
501 | pos++; |
- | |
502 | } |
550 | else |
503 | /* on arrival here in either state we can swap the two parts of |
- | |
504 | * the ident */ |
- | |
505 | if (SwapState == Trailing_Digits || |
- | |
506 | SwapState == Trailing_Chars) |
- | |
507 | { |
551 | { |
508 | int i, l; |
- | |
509 | strcpy (new_id, (nodes->identifier) + lead_count); |
- | |
510 | strncat (new_id, nodes->identifier, lead_count); |
552 | count = sprintf(name_buff,"%s_%s",socket->identifier,chip_node->identifier); |
511 | l = strlen (new_id); |
- | |
512 | for (i = 0; i < l; i++) |
- | |
513 | new_id[i] = tolower (new_id[i]); |
- | |
514 | Log ( |
553 | } |
515 | LOG_GENERAL, |
- | |
516 | "# Renaming %s(%s) to %s(%s)\n", |
- | |
517 | chip->identifier, |
- | |
518 | nodes->identifier, |
554 | net->identifier = realloc(net->identifier,count+1); |
519 | chip->identifier, |
- | |
520 | new_id); |
- | |
521 | strcpy (nodes->identifier, new_id); |
555 | strcpy(net->identifier,name_buff); |
522 | } |
- | |
523 | nodes = nodes->sktnext; |
556 | /* printf("-- id = %s\n",name_buff); */ |
524 | } |
- | |
525 | } |
557 | } |
526 | chip = chip->next; |
558 | chip_node = chip_node -> sktnext; |
527 | } |
559 | } |
528 | vert_regfree (&preg); |
- | |
529 | } |
- | |
530 | 560 | ||
531 | /***************************************************************************************/ |
- | |
- | 561 | } |
|
532 | /* Name nets after node name on device instead of pcb CAD name */ |
562 | socket = socket->next; |
- | 563 | } |
|
533 | /* Initially lookup all matching sockets */ |
564 | Log(LOG_GENERAL,"-- processed %d sockets\n",count); |
- | 565 | vert_regfree(&preg); |
|
534 | 566 | ||
535 | void alter_net_to_socket_name (char *chip_id_template, char *prefix_opt) |
- | |
536 | { |
567 | } |
537 | node_t *chip_node; |
- | |
538 | int found, rc, count = 0; |
- | |
539 | socket_t *socket; |
- | |
540 | vert_regex_t *preg; |
- | |
541 | 568 | ||
542 | socket = socket_head; |
- | |
543 | 569 | ||
544 | /* create_unrouted_list(); */ |
- | |
545 | /* compile regular expression */ |
- | |
546 | 570 | ||
547 | if (!chip_id_template) |
- | |
548 | { |
- | |
549 | chip_id_template = ".*"; |
- | |
550 | } |
- | |
551 | 571 | ||
552 | rc = vert_regcomp (&preg, chip_id_template); |
- | |
553 | if (rc != 0) |
- | |
554 | { |
- | |
555 | char errbuff[100]; |
- | |
556 | regerror (rc, preg->preg, errbuff, 100); |
- | |
557 | Log ( |
- | |
558 | LOG_ERROR, |
- | |
559 | "-- Problem (rc=%d) %s with '%s' as regular expression\n", |
- | |
560 | rc, |
- | |
561 | errbuff, |
- | |
562 | chip_id_template); |
- | |
563 | - | ||
564 | /* return TCL_ERROR; |
- | |
565 | */ |
- | |
566 | return; |
- | |
567 | } |
- | |
568 | else |
- | |
569 | { |
- | |
570 | Log (LOG_GENERAL, "-- Using '%s' as match pattern\n", chip_id_template); |
- | |
571 | } |
- | |
572 | while (socket) |
- | |
573 | { |
- | |
574 | found = regexec (preg->preg, socket->identifier, 0, preg->regpatt, 0); |
- | |
575 | - | ||
576 | if (!found) |
- | |
577 | { |
- | |
578 | /* |
- | |
579 | Log(LOG_GENERAL,"found %s\n",skt->identifier); |
- | |
580 | */ |
- | |
581 | count++; |
- | |
582 | chip_node = socket->nodes; |
- | |
583 | while (chip_node) |
- | |
584 | { |
- | |
585 | char name_buff[MAXIDLEN]; |
- | |
586 | int count; |
- | |
587 | net_t *net = chip_node->net; |
- | |
588 | if (net && IS_ROUTABLE (net->how_routed)) |
- | |
589 | { |
- | |
590 | if (prefix_opt) /* TH requests this change. Not a |
- | |
591 | problem */ |
- | |
592 | { |
- | |
593 | count = sprintf ( |
- | |
594 | name_buff, |
- | |
595 | "%s%s", |
- | |
596 | prefix_opt, |
- | |
597 | chip_node->identifier); |
- | |
598 | } |
- | |
599 | else |
- | |
600 | { |
- | |
601 | count = sprintf ( |
- | |
602 | name_buff, |
- | |
603 | "%s_%s", |
- | |
604 | socket->identifier, |
- | |
605 | chip_node->identifier); |
- | |
606 | } |
- | |
607 | net->identifier = realloc (net->identifier, count + 1); |
- | |
608 | strcpy (net->identifier, name_buff); |
- | |
609 | /* printf("-- id = %s\n",name_buff); */ |
- | |
610 | } |
- | |
611 | chip_node = chip_node->sktnext; |
- | |
612 | } |
- | |
613 | } |
- | |
614 | socket = socket->next; |
- | |
615 | } |
- | |
616 | Log (LOG_GENERAL, "-- processed %d sockets\n", count); |
- | |
617 | vert_regfree (&preg); |
- | |
618 | } |
- | |
619 | 572 | ||
620 | static char pin_map_chars[] = PIN_MAP_LEGAL_CHARS; |
573 | static char pin_map_chars[] = PIN_MAP_LEGAL_CHARS; |
621 | 574 | ||
622 | static int row_index, col_index; /* Made static so I can check them later .*/ |
575 | static int row_index,col_index; /* Made static so I can check them later .*/ |
623 | 576 | ||
624 | /***************************************************************************************/ |
577 | /***************************************************************************************/ |
625 | /* Name nets after node name on device instead of pcb CAD name */ |
578 | /* Name nets after node name on device instead of pcb CAD name */ |
626 | /* Initially lookup all matching sockets */ |
579 | /* Initially lookup all matching sockets */ |
627 | /* change device template pin identifiers */ |
580 | /* change device template pin identifiers */ |
628 | 581 | ||
629 | void edit_socket_pin_name ( |
- | |
630 | char *chip_id_template, char *pin_patt, char *pin_repl, property_t search_space) |
582 | void edit_socket_pin_name(char * chip_id_template,char * pin_patt, char * pin_repl, property_t search_space) |
631 | { |
583 | { |
632 | node_t *chip_node; |
584 | node_t * chip_node ; |
633 | int found, rc, count = 0; |
585 | int found,rc,count = 0; |
634 | int subexpressions; |
586 | int subexpressions; |
635 | socket_t *socket; |
587 | socket_t * socket; |
636 | vert_regex_t *preg; |
588 | vert_regex_t * preg; |
637 | vert_regex_t *ppin_reg; |
589 | vert_regex_t * ppin_reg; |
638 | int loop; |
590 | int loop; |
639 | 591 | ||
640 | if (ISNULLSTR (pin_patt)) |
592 | if (ISNULLSTR(pin_patt)) |
641 | { |
593 | { |
642 | return; |
594 | return; |
643 | } |
595 | } |
644 | 596 | ||
645 | socket = template_head; |
597 | socket = template_head; |
646 | 598 | ||
647 | /* create_unrouted_list(); */ |
599 | /* create_unrouted_list(); */ |
648 | /* compile regular expression for chip type */ |
600 | /* compile regular expression for chip type */ |
649 | 601 | ||
650 | if (!chip_id_template) |
602 | if(!chip_id_template) { |
651 | { |
- | |
652 | chip_id_template = ".*"; |
603 | chip_id_template = ".*"; |
653 | } |
604 | } |
654 | 605 | ||
655 | rc = vert_regcomp (&preg, chip_id_template); |
606 | rc = vert_regcomp(&preg,chip_id_template); |
656 | if (rc != 0) |
607 | if (rc != 0 ) |
657 | { |
608 | { |
658 | char errbuff[100]; |
609 | char errbuff[100]; |
659 | regerror (rc, preg->preg, errbuff, 100); |
610 | regerror(rc,preg->preg,errbuff,100); |
660 | Log ( |
- | |
661 | LOG_ERROR, |
- | |
662 | "-- Problem (rc=%d) %s with '%s' as regular expression\n", |
611 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,chip_id_template); |
663 | rc, |
612 | |
664 | errbuff, |
613 | /* return TCL_ERROR; |
665 | chip_id_template); |
- | |
666 | 614 | */ |
|
667 | /* return TCL_ERROR; |
- | |
668 | */ |
- | |
669 | return; |
615 | return; |
670 | } |
616 | } |
671 | else |
617 | else |
672 | { |
618 | { |
673 | Log ( |
- | |
674 | LOG_GENERAL, |
- | |
675 | "-- Using '%s' as match pattern for chip %s\n", |
619 | Log(LOG_GENERAL,"-- Using '%s' as match pattern for chip %s\n",chip_id_template,search_space==Type?"type":"ident"); |
676 | chip_id_template, |
- | |
677 | search_space == Type ? "type" : "ident"); |
- | |
678 | } |
620 | } |
- | 621 | ||
679 | 622 | ||
680 | /* now compile pin regexp match pattern */ |
623 | /* now compile pin regexp match pattern */ |
681 | rc = vert_regcomp (&ppin_reg, pin_patt); |
624 | rc = vert_regcomp(&ppin_reg,pin_patt); |
682 | if (rc != 0) |
625 | if (rc != 0 ) |
683 | { |
626 | { |
684 | char errbuff[100]; |
627 | char errbuff[100]; |
685 | regerror (rc, ppin_reg->preg, errbuff, 100); |
628 | regerror(rc,ppin_reg->preg,errbuff,100); |
- | 629 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,pin_patt); |
|
686 | Log ( |
630 | |
687 | LOG_ERROR, |
631 | /* return TCL_ERROR; |
- | 632 | */ |
|
- | 633 | return; |
|
- | 634 | } |
|
- | 635 | else |
|
- | 636 | { |
|
688 | "-- Problem (rc=%d) %s with '%s' as regular expression\n", |
637 | subexpressions = ppin_reg->preg->re_nsub+1; /* count up subexpressions */ |
- | 638 | Log(LOG_GENERAL,"-- Using '%s' as chip pin ID matching pattern (%d subexpressions)\n",pin_patt,subexpressions); |
|
- | 639 | } |
|
- | 640 | ||
- | 641 | ||
- | 642 | ||
689 | rc, |
643 | if (subexpressions > MAX_REGEXP_SUBEXPR) |
- | 644 | { |
|
- | 645 | Log(LOG_ERROR,"-- Too many (>%d) subexpressions\n",MAX_REGEXP_SUBEXPR); |
|
690 | errbuff, |
646 | return; |
- | 647 | } |
|
691 | pin_patt); |
648 | /* decode the command type */ |
692 | 649 | ||
- | 650 | switch (search_space) |
|
- | 651 | { |
|
693 | /* return TCL_ERROR; |
652 | case Ident: loop = 1; break; |
694 | */ |
653 | case Type : loop = 2; break; |
695 | return; |
654 | default : loop = 0; break; |
696 | } |
655 | } |
- | 656 | ||
- | 657 | /* loop 2,1, 0 or 1,0 dependent on whether search is type or ident based */ |
|
- | 658 | while(loop) |
|
- | 659 | { |
|
- | 660 | ||
697 | else |
661 | switch (loop) |
698 | { |
662 | { |
- | 663 | case 1: socket = socket_head; break; |
|
699 | subexpressions = ppin_reg->preg->re_nsub + 1; /* count up subexpressions */ |
664 | case 2: socket = template_head; break; |
700 | Log ( |
665 | default : break; |
- | 666 | } |
|
- | 667 | loop--; |
|
- | 668 | while(socket ) |
|
- | 669 | { |
|
701 | LOG_GENERAL, |
670 | if(search_space == Type) |
- | 671 | { |
|
702 | "-- Using '%s' as chip pin ID matching pattern (%d subexpressions)\n", |
672 | found = regexec(preg->preg,socket->type,0,preg->regpatt,0); |
- | 673 | } |
|
- | 674 | else |
|
703 | pin_patt, |
675 | { |
704 | subexpressions); |
676 | found = regexec(preg->preg,socket->identifier,0,preg->regpatt,0); |
705 | } |
677 | } |
- | 678 | if(!found) { |
|
- | 679 | /* |
|
- | 680 | Log(LOG_GENERAL,"found %s\n",skt->identifier); |
|
- | 681 | */ |
|
706 | 682 | ||
707 | if (subexpressions > MAX_REGEXP_SUBEXPR) |
- | |
708 | { |
- | |
709 | Log (LOG_ERROR, "-- Too many (>%d) subexpressions\n", MAX_REGEXP_SUBEXPR); |
- | |
710 | return; |
- | |
711 | } |
- | |
712 | /* decode the command type */ |
- | |
713 | 683 | ||
714 | switch (search_space) |
684 | int rows,columns; |
- | 685 | /* int row_index,col_index; Made static so I can check them later .*/ |
|
- | 686 | ||
715 | { |
687 | |
- | 688 | generic_info_t info,* row_expr, * col_expr; |
|
- | 689 | ||
716 | case Ident: |
690 | |
- | 691 | /* Setup the row and column variables for this device */ |
|
717 | loop = 1; |
692 | /* these are input names that can be used in an expression */ |
718 | break; |
693 | info.g_type = IS_ATTRIBUTE; |
719 | case Type: |
694 | info.g_class= DEFINED; |
- | 695 | ||
- | 696 | /* info is copied, simply change the variable parts and call the compile |
|
720 | loop = 2; |
697 | and set functions */ |
721 | break; |
698 | info.name = "pin_row"; |
- | 699 | info.expr = compile_variable_reference(&row_index,"pin_row"); |
|
722 | default: |
700 | set_generic_value(&socket->generics, &info); |
- | 701 | ||
723 | loop = 0; |
702 | info.name = "pin_col"; |
- | 703 | info.expr = compile_variable_reference(&row_index,"pin_col"); |
|
724 | break; |
704 | set_generic_value(&socket->generics, &info); |
- | 705 | ||
- | 706 | ||
- | 707 | /* this expression will be evaluated when &n is seen in the |
|
725 | } |
708 | input file */ |
- | 709 | row_expr = get_generic_ref(&socket->generics,"row_expr"); |
|
726 | 710 | ||
727 | /* loop 2,1, 0 or 1,0 dependent on whether search is type or ident based */ |
- | |
- | 711 | /* |
|
728 | while (loop) |
712 | if(row_expr && row_expr->expr) |
729 | { |
713 | { |
- | 714 | printf("row = "); |
|
- | 715 | print_expression(stdout,row_expr->expr,NO_RECURSE); |
|
- | 716 | printf("\n"); |
|
- | 717 | } |
|
- | 718 | */ |
|
- | 719 | ||
- | 720 | /* this expression will be evaluated when &a is seen in the |
|
- | 721 | input file */ |
|
- | 722 | col_expr = get_generic_ref(&socket->generics,"col_expr"); |
|
- | 723 | /* |
|
- | 724 | if(col_expr && col_expr->expr) |
|
- | 725 | { |
|
- | 726 | printf("col = "); |
|
- | 727 | print_expression(stdout,col_expr->expr,NO_RECURSE); |
|
- | 728 | printf("\n"); |
|
- | 729 | } |
|
- | 730 | */ |
|
- | 731 | count++; |
|
- | 732 | sort_nodes(socket,EXTRACT_XY); /* sort pins , determine pin row and column*/ |
|
- | 733 | ||
- | 734 | rows = socket->max_pin_row - socket->min_pin_row+1; |
|
- | 735 | columns = socket->max_pin_col - socket->min_pin_col+1; |
|
- | 736 | ||
- | 737 | chip_node = socket-> nodes; |
|
- | 738 | while (chip_node) |
|
- | 739 | { |
|
- | 740 | char * str; |
|
- | 741 | str = chip_node->identifier; |
|
- | 742 | /* allow one bracketed subexpression in pin names */ |
|
- | 743 | found = regexec(ppin_reg->preg,str,subexpressions,ppin_reg->regpatt,0); |
|
- | 744 | if(!found) |
|
- | 745 | { |
|
- | 746 | char name_buff[MAXIDLEN]; |
|
- | 747 | int count,fail; |
|
- | 748 | int editp,copyp; |
|
- | 749 | name_buff[0] = 0; |
|
- | 750 | /* get length of replacement string */ |
|
- | 751 | editp = 0; |
|
- | 752 | count = 0; |
|
- | 753 | fail = 0; |
|
- | 754 | /* printf("Processing '%s'\n",pin_repl); */ |
|
- | 755 | while(pin_repl[editp] && !fail) |
|
- | 756 | { |
|
- | 757 | /* escape anything */ |
|
- | 758 | if(pin_repl[editp] == '\\') |
|
- | 759 | { |
|
730 | switch (loop) |
760 | editp++; |
- | 761 | name_buff[count++]= pin_repl[editp]; |
|
- | 762 | if(pin_repl[editp]) |
|
731 | { |
763 | { |
732 | case 1: |
- | |
733 | socket = socket_head; |
- | |
734 | break; |
- | |
735 | case 2: |
- | |
736 | socket = template_head; |
- | |
737 | break; |
- | |
738 | default: |
764 | editp++; |
739 | break; |
- | |
740 | } |
765 | } |
- | 766 | } |
|
- | 767 | /* replace matched patterns */ |
|
- | 768 | else if(pin_repl[editp] == '&') |
|
- | 769 | { |
|
- | 770 | int index,len; |
|
- | 771 | char c; |
|
- | 772 | char temp[30]; |
|
- | 773 | int digits; |
|
- | 774 | /* change values to those seen on this pin */ |
|
- | 775 | col_index = chip_node -> pin_col; |
|
- | 776 | row_index = chip_node -> pin_row; |
|
- | 777 | ||
- | 778 | ||
- | 779 | ||
- | 780 | editp++; |
|
- | 781 | c = pin_repl[editp]; |
|
- | 782 | if(c) |
|
- | 783 | { |
|
- | 784 | /* printf("c='%c' row = %d col =%d\n",c,chip_node->pin_row ,chip_node->pin_col); */ |
|
741 | loop--; |
785 | editp++; |
742 | while (socket) |
786 | switch(c) |
743 | { |
787 | { |
- | 788 | case 'c': |
|
- | 789 | case 'C': |
|
- | 790 | if (chip_node->net && chip_node->net->name) |
|
- | 791 | { |
|
- | 792 | len = strlen(chip_node->net->name); |
|
- | 793 | strncpy(name_buff+count,chip_node->net->name,len); |
|
- | 794 | count += len; |
|
- | 795 | } |
|
- | 796 | else |
|
- | 797 | { |
|
- | 798 | fail = 1; |
|
- | 799 | } |
|
- | 800 | break; |
|
- | 801 | ||
- | 802 | ||
- | 803 | ||
- | 804 | /* &d or &D is the device identifier */ |
|
- | 805 | case 'd': |
|
- | 806 | case 'D': |
|
- | 807 | len = strlen(socket->identifier); |
|
- | 808 | strncpy(name_buff+count,socket->identifier,len); |
|
- | 809 | count += len; |
|
- | 810 | break; |
|
- | 811 | /* &p or &P is the pin identifier */ |
|
- | 812 | case 'p': |
|
- | 813 | case 'P': |
|
- | 814 | len = strlen(chip_node->identifier); |
|
- | 815 | strncpy(name_buff+count,chip_node->identifier,len); |
|
- | 816 | count += len; |
|
- | 817 | break; |
|
- | 818 | /* &a is the alpha component of the identifier */ |
|
- | 819 | case 'a': |
|
- | 820 | case 'A': |
|
- | 821 | /* always synthesise pin column from the info left by sort_nodes */ |
|
- | 822 | if(col_expr && col_expr->expr) |
|
- | 823 | { |
|
- | 824 | index = eval_expression(col_expr->expr,&socket->generics); |
|
- | 825 | } |
|
- | 826 | else |
|
- | 827 | { |
|
744 | if (search_space == Type) |
828 | index = chip_node -> pin_col; |
- | 829 | } |
|
- | 830 | /* printf("Alpha %d : ",index); */ |
|
- | 831 | digits = 0; |
|
- | 832 | /* always at least a single char */ |
|
- | 833 | if(index>0) /* index = 0 means no chars at all ! */ |
|
- | 834 | { |
|
- | 835 | do |
|
745 | { |
836 | { |
- | 837 | if(c=='a') /* lower case idents if lower case 'a' is used */ |
|
746 | found = |
838 | { |
747 | regexec (preg->preg, socket->type, 0, preg->regpatt, 0); |
839 | temp[digits++] = tolower(pin_map_chars[index % (PIN_MAP_LEGAL_CHAR_COUNT+1)-1]); |
748 | } |
840 | } |
749 | else |
841 | else |
- | 842 | { |
|
- | 843 | temp[digits++] = pin_map_chars[index % (PIN_MAP_LEGAL_CHAR_COUNT+1)-1]; |
|
- | 844 | } |
|
- | 845 | ||
- | 846 | index /= (PIN_MAP_LEGAL_CHAR_COUNT+1); |
|
- | 847 | } |
|
- | 848 | while(index); |
|
- | 849 | temp[digits]= 0; |
|
- | 850 | /* printf("conversion '%s'\n",temp); */ |
|
- | 851 | /* reverse copy string, at least one char */ |
|
- | 852 | for(;digits>0;name_buff[count++]=temp[--digits]); |
|
- | 853 | } |
|
- | 854 | else |
|
- | 855 | { |
|
- | 856 | /* error in the expansion as the index < 0 */ |
|
- | 857 | /* Leave it blank as there is a danger elsewhere |
|
- | 858 | name_buff[count++] = '&'; |
|
- | 859 | name_buff[count++] = c; |
|
- | 860 | */ |
|
- | 861 | } |
|
- | 862 | break; |
|
- | 863 | /* &n is the alpha component of the identifier */ |
|
- | 864 | case 'n': |
|
- | 865 | case 'N': |
|
- | 866 | if(row_expr && row_expr->expr) |
|
- | 867 | { |
|
- | 868 | index = eval_expression(row_expr->expr,&socket->generics); |
|
- | 869 | } |
|
- | 870 | else |
|
- | 871 | { |
|
- | 872 | index = chip_node -> pin_row; |
|
- | 873 | } |
|
- | 874 | /* printf("Numeric %d\n",index); */ |
|
- | 875 | if(index>0) /* index = 0 means no chars at all ! */ |
|
- | 876 | { |
|
- | 877 | ||
- | 878 | sprintf(temp,"%d",index); |
|
- | 879 | len = strlen(temp); |
|
- | 880 | strncpy(name_buff+count,temp,len); |
|
- | 881 | /* printf("result: '%s' %d\n",name_buff,strlen(name_buff)); */ |
|
- | 882 | count += len; |
|
- | 883 | } |
|
- | 884 | else |
|
- | 885 | { |
|
- | 886 | /* error in the expansion as the index < 0 */ |
|
- | 887 | name_buff[count++] = '&'; |
|
- | 888 | name_buff[count++] = c; |
|
- | 889 | ||
- | 890 | } |
|
- | 891 | ||
- | 892 | break; |
|
- | 893 | case 'i': |
|
- | 894 | case 'I': |
|
- | 895 | sprintf(temp,"%d",chip_node->pin_row - socket->min_pin_row + |
|
- | 896 | (chip_node->pin_col - socket->min_pin_col) * rows +1); |
|
- | 897 | ||
- | 898 | len = strlen(temp); |
|
- | 899 | strncpy(name_buff+count,temp,len); |
|
- | 900 | count += len; |
|
- | 901 | break; |
|
- | 902 | /* &0 to &9 or whatever is the regular expression bracketed |
|
- | 903 | section */ |
|
- | 904 | default: |
|
- | 905 | index = c -'0'; |
|
- | 906 | if(index <0 || index > subexpressions) |
|
- | 907 | { |
|
- | 908 | fail = 1; |
|
- | 909 | } |
|
- | 910 | else |
|
- | 911 | { |
|
- | 912 | /* copy subexpression over */ |
|
- | 913 | copyp = ppin_reg->regpatt[index].rm_so; |
|
- | 914 | if (copyp >=0 ) |
|
750 | { |
915 | { |
- | 916 | while(copyp < ppin_reg->regpatt[index].rm_eo) |
|
751 | found = regexec ( |
917 | { |
752 | preg->preg, socket->identifier, 0, preg->regpatt, 0); |
918 | name_buff[count++] = str[copyp++]; |
- | 919 | } |
|
753 | } |
920 | } |
754 | if (!found) |
921 | else |
755 | { |
922 | { |
756 | /* |
- | |
757 | Log(LOG_GENERAL,"found %s\n",skt->identifier); |
- | |
758 | */ |
- | |
759 | - | ||
760 | int rows, columns; |
- | |
761 | /* int row_index,col_index; Made static so I can check |
- | |
762 | * them later .*/ |
- | |
763 | - | ||
764 | generic_info_t info, *row_expr, *col_expr; |
- | |
765 | - | ||
766 | /* Setup the row and column variables for this device */ |
- | |
767 | /* these are input names that can be used in an expression */ |
- | |
768 | info.g_type = IS_ATTRIBUTE; |
- | |
769 | info.g_class = DEFINED; |
- | |
770 | - | ||
771 | /* info is copied, simply change the variable parts and call |
- | |
772 | the compile and set functions */ |
- | |
773 | info.name = "pin_row"; |
- | |
774 | info.expr = compile_variable_reference (&row_index, "pin_row"); |
- | |
775 | set_generic_value (&socket->generics, &info); |
- | |
776 | - | ||
777 | info.name = "pin_col"; |
- | |
778 | info.expr = compile_variable_reference (&row_index, "pin_col"); |
- | |
779 | set_generic_value (&socket->generics, &info); |
- | |
780 | - | ||
781 | /* this expression will be evaluated when &n is seen in the |
- | |
782 | input file */ |
- | |
783 | row_expr = get_generic_ref (&socket->generics, "row_expr"); |
- | |
784 | - | ||
785 | /* |
- | |
786 | if(row_expr && row_expr->expr) |
- | |
787 | { |
- | |
788 | printf("row = "); |
- | |
789 | print_expression(stdout,row_expr->expr,NO_RECURSE); |
- | |
790 | printf("\n"); |
- | |
791 | } |
- | |
792 | */ |
- | |
793 | - | ||
794 | /* this expression will be evaluated when &a is seen in the |
- | |
795 | input file */ |
- | |
796 | col_expr = get_generic_ref (&socket->generics, "col_expr"); |
- | |
797 | /* |
- | |
798 | if(col_expr && col_expr->expr) |
- | |
799 | { |
- | |
800 | printf("col = "); |
- | |
801 | print_expression(stdout,col_expr->expr,NO_RECURSE); |
- | |
802 | printf("\n"); |
- | |
803 | } |
- | |
804 | */ |
- | |
805 | count++; |
923 | name_buff[count++] = '@'; |
806 | sort_nodes (socket, EXTRACT_XY); /* sort pins , determine pin |
- | |
807 | row and column*/ |
- | |
808 | - | ||
809 | rows = socket->max_pin_row - socket->min_pin_row + 1; |
- | |
810 | columns = socket->max_pin_col - socket->min_pin_col + 1; |
- | |
811 | - | ||
812 | chip_node = socket->nodes; |
- | |
813 | while (chip_node) |
- | |
814 | { |
- | |
815 | char *str; |
- | |
816 | str = chip_node->identifier; |
- | |
817 | /* allow one bracketed subexpression in pin names */ |
- | |
818 | found = regexec ( |
- | |
819 | ppin_reg->preg, |
- | |
820 | str, |
- | |
821 | subexpressions, |
- | |
822 | ppin_reg->regpatt, |
- | |
823 | 0); |
- | |
824 | if (!found) |
- | |
825 | { |
- | |
826 | char name_buff[MAXIDLEN]; |
- | |
827 | int count, fail; |
- | |
828 | int editp, copyp; |
- | |
829 | name_buff[0] = 0; |
- | |
830 | /* get length of replacement string */ |
- | |
831 | editp = 0; |
- | |
832 | count = 0; |
- | |
833 | fail = 0; |
- | |
834 | /* printf("Processing |
- | |
835 | * '%s'\n",pin_repl); */ |
- | |
836 | while (pin_repl[editp] && !fail) |
- | |
837 | { |
- | |
838 | /* escape anything */ |
- | |
839 | if (pin_repl[editp] == '\\') |
- | |
840 | { |
- | |
841 | editp++; |
- | |
842 | name_buff[count++] = |
- | |
843 | pin_repl[editp]; |
- | |
844 | if (pin_repl[editp]) |
- | |
845 | { |
- | |
846 | editp++; |
- | |
847 | } |
- | |
848 | } |
- | |
849 | /* replace matched patterns */ |
- | |
850 | else if (pin_repl[editp] == '&') |
- | |
851 | { |
- | |
852 | int index, len; |
- | |
853 | char c; |
- | |
854 | char temp[30]; |
- | |
855 | int digits; |
- | |
856 | /* change values to those seen |
- | |
857 | * on this pin */ |
- | |
858 | col_index = chip_node->pin_col; |
- | |
859 | row_index = chip_node->pin_row; |
- | |
860 | - | ||
861 | editp++; |
- | |
862 | c = pin_repl[editp]; |
- | |
863 | if (c) |
- | |
864 | { |
- | |
865 | /* printf("c='%c' |
- | |
866 | * row = %d col |
- | |
867 | * =%d\n",c,chip_node->pin_row |
- | |
868 | * ,chip_node->pin_col); |
- | |
869 | */ |
- | |
870 | editp++; |
- | |
871 | switch (c) |
- | |
872 | { |
- | |
873 | case 'c': |
- | |
874 | case 'C': |
- | |
875 | if (chip_node |
- | |
876 | ->net && |
- | |
877 | chip_node |
- | |
878 | ->net |
- | |
879 | ->name) |
- | |
880 | { |
- | |
881 | len = strlen ( |
- | |
882 | chip_node |
- | |
883 | ->net |
- | |
884 | ->name); |
- | |
885 | strncpy ( |
- | |
886 | name_buff + |
- | |
887 | count, |
- | |
888 | chip_node |
- | |
889 | ->net |
- | |
890 | ->name, |
- | |
891 | len); |
- | |
892 | count += |
- | |
893 | len; |
- | |
894 | } |
- | |
895 | else |
- | |
896 | { |
- | |
897 | fail = |
- | |
898 | 1; |
- | |
899 | } |
- | |
900 | break; |
- | |
901 | - | ||
902 | /* &d or &D is |
- | |
903 | * the device |
- | |
904 | * identifier |
- | |
905 | */ |
- | |
906 | case 'd': |
- | |
907 | case 'D': |
- | |
908 | len = strlen ( |
- | |
909 | socket |
- | |
910 | ->identifier); |
- | |
911 | strncpy ( |
- | |
912 | name_buff + |
- | |
913 | count, |
- | |
914 | socket |
- | |
915 | ->identifier, |
- | |
916 | len); |
- | |
917 | count += len; |
- | |
918 | break; |
- | |
919 | /* &p or &P is |
- | |
920 | * the pin |
- | |
921 | * identifier |
- | |
922 | */ |
- | |
923 | case 'p': |
- | |
924 | case 'P': |
- | |
925 | len = strlen ( |
- | |
926 | chip_node |
- | |
927 | ->identifier); |
- | |
928 | strncpy ( |
- | |
929 | name_buff + |
- | |
930 | count, |
- | |
931 | chip_node |
- | |
932 | ->identifier, |
- | |
933 | len); |
- | |
934 | count += len; |
- | |
935 | break; |
- | |
936 | /* &a is the |
- | |
937 | * alpha |
- | |
938 | * component of |
- | |
939 | * the |
- | |
940 | * identifier |
- | |
941 | */ |
- | |
942 | case 'a': |
- | |
943 | case 'A': |
- | |
944 | /* always |
- | |
945 | * synthesise |
- | |
946 | * pin column |
- | |
947 | * from the |
- | |
948 | * info left by |
- | |
949 | * sort_nodes |
- | |
950 | */ |
- | |
951 | if (col_expr && |
- | |
952 | col_expr |
- | |
953 | ->expr) |
- | |
954 | { |
- | |
955 | index = eval_expression ( |
- | |
956 | col_expr |
- | |
957 | ->expr, |
- | |
958 | &socket |
- | |
959 | ->generics); |
- | |
960 | } |
- | |
961 | else |
- | |
962 | { |
- | |
963 | index = |
- | |
964 | chip_node |
- | |
965 | ->pin_col; |
- | |
966 | } |
- | |
967 | /* printf("Alpha |
- | |
968 | * %d : |
- | |
969 | * ",index); */ |
- | |
970 | digits = 0; |
- | |
971 | /* always at |
- | |
972 | * least a |
- | |
973 | * single char |
- | |
974 | */ |
- | |
975 | if (index > |
- | |
976 | 0) /* index |
- | |
977 | = 0 |
- | |
978 | means |
- | |
979 | no |
- | |
980 | chars |
- | |
981 | at |
- | |
982 | all ! |
- | |
983 | */ |
- | |
984 | { |
- | |
985 | do |
- | |
986 | { |
- | |
987 | if (c == |
- | |
988 | 'a') /* lower case idents if lower case 'a' is used */ |
- | |
989 | { |
- | |
990 | temp[digits++] = tolower ( |
- | |
991 | pin_map_chars |
- | |
992 | [index % |
- | |
993 | (PIN_MAP_LEGAL_CHAR_COUNT + |
- | |
994 | 1) - |
- | |
995 | 1]); |
- | |
996 | } |
- | |
997 | else |
- | |
998 | { |
- | |
999 | temp[digits++] = pin_map_chars |
- | |
1000 | [index % |
- | |
1001 | (PIN_MAP_LEGAL_CHAR_COUNT + |
- | |
1002 | 1) - |
- | |
1003 | 1]; |
- | |
1004 | } |
- | |
1005 | - | ||
1006 | index /= |
- | |
1007 | (PIN_MAP_LEGAL_CHAR_COUNT + |
- | |
1008 | 1); |
- | |
1009 | } while ( |
- | |
1010 | index); |
- | |
1011 | temp[digits] = |
- | |
1012 | 0; |
- | |
1013 | /* printf("conversion |
- | |
1014 | * '%s'\n",temp); |
- | |
1015 | */ |
- | |
1016 | /* reverse |
- | |
1017 | * copy |
- | |
1018 | * string, |
- | |
1019 | * at |
- | |
1020 | * least |
- | |
1021 | * one |
- | |
1022 | * char |
- | |
1023 | */ |
- | |
1024 | for ( |
- | |
1025 | ; |
- | |
1026 | digits > |
- | |
1027 | 0; |
- | |
1028 | name_buff |
- | |
1029 | [count++] = temp |
- | |
1030 | [--digits]) |
- | |
1031 | ; |
- | |
1032 | } |
- | |
1033 | else |
- | |
1034 | { |
- | |
1035 | /* error |
- | |
1036 | * in |
- | |
1037 | * the |
- | |
1038 | * expansion |
- | |
1039 | * as |
- | |
1040 | * the |
- | |
1041 | * index |
- | |
1042 | * < 0 |
- | |
1043 | */ |
- | |
1044 | /* Leave |
- | |
1045 | it |
- | |
1046 | blank |
- | |
1047 | as |
- | |
1048 | there |
- | |
1049 | is a |
- | |
1050 | danger |
- | |
1051 | elsewhere |
- | |
1052 | name_buff[count++] = '&'; |
- | |
1053 | name_buff[count++] = c; |
- | |
1054 | */ |
- | |
1055 | } |
- | |
1056 | break; |
- | |
1057 | /* &n is the |
- | |
1058 | * alpha |
- | |
1059 | * component of |
- | |
1060 | * the |
- | |
1061 | * identifier |
- | |
1062 | */ |
- | |
1063 | case 'n': |
- | |
1064 | case 'N': |
- | |
1065 | if (row_expr && |
- | |
1066 | row_expr |
- | |
1067 | ->expr) |
- | |
1068 | { |
- | |
1069 | index = eval_expression ( |
- | |
1070 | row_expr |
- | |
1071 | ->expr, |
- | |
1072 | &socket |
- | |
1073 | ->generics); |
- | |
1074 | } |
- | |
1075 | else |
- | |
1076 | { |
- | |
1077 | index = |
- | |
1078 | chip_node |
- | |
1079 | ->pin_row; |
- | |
1080 | } |
- | |
1081 | /* printf("Numeric |
- | |
1082 | * %d\n",index); |
- | |
1083 | */ |
- | |
1084 | if (index > |
- | |
1085 | 0) /* index |
- | |
1086 | = 0 |
- | |
1087 | means |
- | |
1088 | no |
- | |
1089 | chars |
- | |
1090 | at |
- | |
1091 | all ! |
- | |
1092 | */ |
- | |
1093 | { |
- | |
1094 | sprintf ( |
- | |
1095 | temp, |
- | |
1096 | "%" |
- | |
1097 | "d", |
- | |
1098 | index); |
- | |
1099 | len = strlen ( |
- | |
1100 | temp); |
- | |
1101 | strncpy ( |
- | |
1102 | name_buff + |
- | |
1103 | count, |
- | |
1104 | temp, |
- | |
1105 | len); |
- | |
1106 | /* printf("result: |
- | |
1107 | * '%s' |
- | |
1108 | * %d\n",name_buff,strlen(name_buff)); |
- | |
1109 | */ |
- | |
1110 | count += |
- | |
1111 | len; |
- | |
1112 | } |
- | |
1113 | else |
- | |
1114 | { |
- | |
1115 | /* error |
- | |
1116 | * in |
- | |
1117 | * the |
- | |
1118 | * expansion |
- | |
1119 | * as |
- | |
1120 | * the |
- | |
1121 | * index |
- | |
1122 | * < 0 |
- | |
1123 | */ |
- | |
1124 | name_buff |
- | |
1125 | [count++] = |
- | |
1126 | '&'; |
- | |
1127 | name_buff |
- | |
1128 | [count++] = |
- | |
1129 | c; |
- | |
1130 | } |
- | |
1131 | - | ||
1132 | break; |
- | |
1133 | case 'i': |
- | |
1134 | case 'I': |
- | |
1135 | sprintf ( |
- | |
1136 | temp, |
- | |
1137 | "%d", |
- | |
1138 | chip_node |
- | |
1139 | ->pin_row - |
- | |
1140 | socket |
- | |
1141 | ->min_pin_row + |
- | |
1142 | (chip_node |
- | |
1143 | ->pin_col - |
- | |
1144 | socket |
- | |
1145 | ->min_pin_col) * |
- | |
1146 | rows + |
- | |
1147 | 1); |
- | |
1148 | - | ||
1149 | len = strlen ( |
- | |
1150 | temp); |
- | |
1151 | strncpy ( |
- | |
1152 | name_buff + |
- | |
1153 | count, |
- | |
1154 | temp, |
- | |
1155 | len); |
- | |
1156 | count += len; |
- | |
1157 | break; |
- | |
1158 | /* &0 to &9 or |
- | |
1159 | whatever is |
- | |
1160 | the regular |
- | |
1161 | expression |
- | |
1162 | bracketed |
- | |
1163 | section */ |
- | |
1164 | default: |
- | |
1165 | index = |
- | |
1166 | c - '0'; |
- | |
1167 | if (index < |
- | |
1168 | 0 || |
- | |
1169 | index > |
- | |
1170 | subexpressions) |
- | |
1171 | { |
- | |
1172 | fail = |
- | |
1173 | 1; |
- | |
1174 | } |
- | |
1175 | else |
- | |
1176 | { |
- | |
1177 | /* copy |
- | |
1178 | * subexpression |
- | |
1179 | * over |
- | |
1180 | */ |
- | |
1181 | copyp = |
- | |
1182 | ppin_reg |
- | |
1183 | ->regpatt |
- | |
1184 | [index] |
- | |
1185 | .rm_so; |
- | |
1186 | if (copyp >= |
- | |
1187 | 0) |
- | |
1188 | { |
- | |
1189 | while ( |
- | |
1190 | copyp < |
- | |
1191 | ppin_reg |
- | |
1192 | ->regpatt |
- | |
1193 | [index] |
- | |
1194 | .rm_eo) |
- | |
1195 | { |
- | |
1196 | name_buff |
- | |
1197 | [count++] = str |
- | |
1198 | [copyp++]; |
- | |
1199 | } |
- | |
1200 | } |
- | |
1201 | else |
- | |
1202 | { |
- | |
1203 | name_buff |
- | |
1204 | [count++] = |
- | |
1205 | '@'; |
- | |
1206 | } |
- | |
1207 | } |
- | |
1208 | } |
- | |
1209 | } |
- | |
1210 | } |
- | |
1211 | - | ||
1212 | else |
- | |
1213 | { |
- | |
1214 | name_buff[count++] = |
- | |
1215 | pin_repl[editp++]; |
- | |
1216 | } |
- | |
1217 | } |
- | |
1218 | if (!fail) |
- | |
1219 | { |
- | |
1220 | name_buff[count] = 0; |
- | |
1221 | /* |
- | |
1222 | printf("replacing '%s' with |
- | |
1223 | '%s'\n",chip_node->identifier,name_buff); |
- | |
1224 | */ |
- | |
1225 | chip_node->identifier = realloc ( |
- | |
1226 | chip_node->identifier, count + 1); |
- | |
1227 | strcpy ( |
- | |
1228 | chip_node->identifier, name_buff); |
- | |
1229 | } |
- | |
1230 | } |
- | |
1231 | chip_node = chip_node->sktnext; |
- | |
1232 | } |
- | |
1233 | } |
924 | } |
1234 | sort_nodes (socket, NO_EXTRACT_XY); |
925 | } |
1235 | socket = socket->next; |
926 | } |
- | 927 | } |
|
1236 | } |
928 | } |
- | 929 | ||
- | 930 | else |
|
- | 931 | { |
|
- | 932 | name_buff[count++]=pin_repl[editp++]; |
|
- | 933 | } |
|
- | 934 | } |
|
- | 935 | if(!fail) |
|
- | 936 | { |
|
- | 937 | name_buff[count] = 0; |
|
- | 938 | /* |
|
- | 939 | printf("replacing '%s' with '%s'\n",chip_node->identifier,name_buff); |
|
- | 940 | */ |
|
- | 941 | chip_node->identifier = realloc(chip_node->identifier,count+1); |
|
- | 942 | strcpy(chip_node->identifier,name_buff); |
|
- | 943 | } |
|
- | 944 | } |
|
- | 945 | chip_node=chip_node->sktnext; |
|
1237 | } |
946 | } |
- | 947 | } |
|
- | 948 | sort_nodes(socket,NO_EXTRACT_XY); |
|
- | 949 | socket = socket->next; |
|
- | 950 | } |
|
- | 951 | ||
- | 952 | } |
|
1238 | Log (LOG_GENERAL, "-- processed %d sockets\n", count); |
953 | Log(LOG_GENERAL,"-- processed %d sockets\n",count); |
1239 | vert_regfree (&preg); |
954 | vert_regfree(&preg); |
1240 | vert_regfree (&ppin_reg); |
955 | vert_regfree(&ppin_reg); |
- | 956 | } |
|
- | 957 | ||
1241 | } |
958 | |
1242 | 959 | ||
1243 | /***************************************************************************************/ |
960 | /***************************************************************************************/ |
1244 | /* allows for net renaming : currently in the routed list only */ |
961 | /* allows for net renaming : currently in the routed list only */ |
1245 | void edit_net_names (char *pin_patt, char *pin_repl, property_t search_space) |
962 | void edit_net_names(char * pin_patt, char * pin_repl,property_t search_space) |
1246 | { |
963 | { |
1247 | net_t *curr_net; |
964 | net_t * curr_net ; |
1248 | int found, rc = 0; |
965 | int found,rc = 0; |
1249 | int subexpressions; |
966 | int subexpressions; |
1250 | int net_count; |
967 | int net_count; |
1251 | vert_regex_t *ppin_reg; |
968 | vert_regex_t * ppin_reg; |
1252 | int loop; |
969 | int loop; |
1253 | net_count = 0; |
970 | net_count = 0; |
- | 971 | ||
- | 972 | if (ISNULLSTR(pin_patt)) |
|
- | 973 | { |
|
- | 974 | return; |
|
- | 975 | } |
|
- | 976 | ||
- | 977 | curr_net = routed_list; |
|
- | 978 | ||
- | 979 | ||
- | 980 | /* now compile pin regexp match pattern */ |
|
- | 981 | rc = vert_regcomp(&ppin_reg,pin_patt); |
|
- | 982 | if (rc != 0 ) |
|
- | 983 | { |
|
- | 984 | char errbuff[100]; |
|
- | 985 | regerror(rc,ppin_reg->preg,errbuff,100); |
|
- | 986 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,pin_patt); |
|
- | 987 | ||
- | 988 | /* return TCL_ERROR; |
|
- | 989 | */ |
|
- | 990 | return; |
|
- | 991 | } |
|
- | 992 | else |
|
- | 993 | { |
|
- | 994 | subexpressions = ppin_reg->preg->re_nsub+1; /* count up subexpressions */ |
|
- | 995 | Log(LOG_GENERAL,"-- Using '%s' as net matching pattern (%d subexpressions)\n",pin_patt,subexpressions); |
|
- | 996 | } |
|
1254 | 997 | ||
1255 | if (ISNULLSTR (pin_patt)) |
- | |
1256 | { |
- | |
1257 | return; |
- | |
1258 | } |
- | |
1259 | 998 | ||
1260 | curr_net = routed_list; |
- | |
1261 | - | ||
1262 | /* now compile pin regexp match pattern */ |
- | |
1263 | rc = vert_regcomp (&ppin_reg, pin_patt); |
- | |
1264 | if (rc != 0) |
- | |
1265 | { |
- | |
1266 | char errbuff[100]; |
- | |
1267 | regerror (rc, ppin_reg->preg, errbuff, 100); |
- | |
1268 | Log ( |
- | |
1269 | LOG_ERROR, |
- | |
1270 | "-- Problem (rc=%d) %s with '%s' as regular expression\n", |
- | |
1271 | rc, |
- | |
1272 | errbuff, |
- | |
1273 | pin_patt); |
- | |
1274 | - | ||
1275 | /* return TCL_ERROR; |
- | |
1276 | */ |
- | |
1277 | return; |
- | |
1278 | } |
- | |
1279 | else |
- | |
1280 | { |
- | |
1281 | subexpressions = ppin_reg->preg->re_nsub + 1; /* count up subexpressions */ |
- | |
1282 | Log ( |
- | |
1283 | LOG_GENERAL, |
- | |
1284 | "-- Using '%s' as net matching pattern (%d subexpressions)\n", |
- | |
1285 | pin_patt, |
- | |
1286 | subexpressions); |
- | |
1287 | } |
- | |
1288 | 999 | ||
1289 | if (subexpressions > MAX_REGEXP_SUBEXPR) |
1000 | if (subexpressions > MAX_REGEXP_SUBEXPR) |
1290 | { |
1001 | { |
1291 | Log (LOG_ERROR, "-- Too many (>%d) subexpressions\n", MAX_REGEXP_SUBEXPR); |
1002 | Log(LOG_ERROR,"-- Too many (>%d) subexpressions\n",MAX_REGEXP_SUBEXPR); |
- | 1003 | return; |
|
- | 1004 | } |
|
- | 1005 | /* decode the command type */ |
|
- | 1006 | /* |
|
- | 1007 | switch (search_space) |
|
- | 1008 | { |
|
- | 1009 | case Ident: loop = 1; break; |
|
- | 1010 | case Type : loop = 2; break; |
|
- | 1011 | default : loop = 0; break; |
|
- | 1012 | } |
|
- | 1013 | */ |
|
- | 1014 | ||
- | 1015 | loop = 3; |
|
- | 1016 | /* loop 2,1, 0 or 1,0 dependent on whether search is type or ident based */ |
|
- | 1017 | while(loop) |
|
- | 1018 | { |
|
- | 1019 | char * str; |
|
- | 1020 | printf("In loop %d\n",loop); |
|
- | 1021 | switch (loop) |
|
- | 1022 | { |
|
- | 1023 | case 1: curr_net = routed_list; break; |
|
- | 1024 | case 2: curr_net = unrouted_list; break; |
|
- | 1025 | case 3: curr_net = named_list; break; |
|
- | 1026 | default : curr_net = NULL; break; |
|
- | 1027 | } |
|
- | 1028 | loop--; |
|
- | 1029 | while(curr_net ) |
|
- | 1030 | { |
|
- | 1031 | found = 1; |
|
- | 1032 | str = "nothing"; |
|
- | 1033 | if(search_space == Name && !ISNULLSTR(curr_net->name)) |
|
- | 1034 | { |
|
- | 1035 | found = regexec(ppin_reg->preg,curr_net->name,0,ppin_reg->regpatt,0); |
|
1292 | return; |
1036 | str = curr_net -> name; |
- | 1037 | } |
|
- | 1038 | ||
- | 1039 | if(search_space == Ident && !ISNULLSTR(curr_net->identifier)) |
|
- | 1040 | { |
|
- | 1041 | found = regexec(ppin_reg->preg,curr_net->identifier,0,ppin_reg->regpatt,0); |
|
- | 1042 | str = curr_net -> identifier; |
|
1293 | } |
1043 | } |
- | 1044 | /* printf("Checking '%s'\n",str); */ |
|
- | 1045 | ||
- | 1046 | /* found will not be set if neither Name or Ident is used */ |
|
- | 1047 | if(!found) |
|
- | 1048 | { |
|
- | 1049 | char name_buff[MAXIDLEN]; |
|
- | 1050 | int fail,count; |
|
- | 1051 | int editp,copyp; |
|
- | 1052 | name_buff[0] = 0; |
|
1294 | /* decode the command type */ |
1053 | /* get length of replacement string */ |
- | 1054 | editp = 0; |
|
- | 1055 | fail = 0; |
|
- | 1056 | count = 0; |
|
- | 1057 | net_count ++; |
|
- | 1058 | printf("Processing '%s'\n",str); |
|
- | 1059 | while(pin_repl[editp] && !fail) |
|
1295 | /* |
1060 | { |
1296 | switch (search_space) |
1061 | /* escape anything */ |
- | 1062 | if(pin_repl[editp] == '\\') |
|
1297 | { |
1063 | { |
1298 | case Ident: loop = 1; break; |
1064 | editp++; |
1299 | case Type : loop = 2; break; |
1065 | name_buff[count++]= pin_repl[editp]; |
1300 | default : loop = 0; break; |
1066 | if(pin_repl[editp]) |
- | 1067 | { |
|
- | 1068 | editp++; |
|
- | 1069 | } |
|
1301 | } |
1070 | } |
1302 | */ |
1071 | /* replace matched patterns */ |
1303 | 1072 | else if(pin_repl[editp] == '&') |
|
1304 | loop = 3; |
1073 | { |
1305 | /* loop 2,1, 0 or 1,0 dependent on whether search is type or ident based */ |
1074 | int index,len; |
1306 | while (loop) |
1075 | char c; |
1307 | { |
1076 | editp++; |
1308 | char *str; |
1077 | c = pin_repl[editp]; |
1309 | printf ("In loop %d\n", loop); |
1078 | if(c) |
1310 | switch (loop) |
1079 | { |
1311 | { |
1080 | editp++; |
1312 | case 1: |
1081 | switch(c) |
1313 | curr_net = routed_list; |
1082 | { |
1314 | break; |
1083 | /* replace with name part of net */ |
1315 | case 2: |
1084 | case 'n': |
1316 | curr_net = unrouted_list; |
1085 | case 'N': |
1317 | break; |
1086 | if (!ISNULLSTR(curr_net->name)) |
1318 | case 3: |
1087 | { |
1319 | curr_net = named_list; |
1088 | len = strlen(curr_net->name); |
1320 | break; |
1089 | strncpy(name_buff+count,curr_net->name,len); |
1321 | default: |
1090 | count += len; |
1322 | curr_net = NULL; |
1091 | } |
1323 | break; |
1092 | else |
1324 | } |
1093 | { |
1325 | loop--; |
1094 | fail = 1; |
1326 | while (curr_net) |
1095 | } |
1327 | { |
1096 | break; |
1328 | found = 1; |
1097 | |
1329 | str = "nothing"; |
1098 | case 'i': |
1330 | if (search_space == Name && !ISNULLSTR (curr_net->name)) |
1099 | case 'I': |
1331 | { |
1100 | if (!ISNULLSTR(curr_net->identifier)) |
1332 | found = regexec ( |
1101 | { |
1333 | ppin_reg->preg, curr_net->name, 0, ppin_reg->regpatt, 0); |
1102 | len = strlen(curr_net->identifier); |
1334 | str = curr_net->name; |
1103 | strncpy(name_buff+count,curr_net->identifier,len); |
1335 | } |
1104 | count += len; |
1336 | 1105 | } |
|
1337 | if (search_space == Ident && !ISNULLSTR (curr_net->identifier)) |
1106 | else |
1338 | { |
1107 | { |
1339 | found = regexec ( |
1108 | fail = 1; |
1340 | ppin_reg->preg, |
1109 | } |
1341 | curr_net->identifier, |
1110 | break; |
1342 | 0, |
1111 | |
1343 | ppin_reg->regpatt, |
1112 | |
1344 | 0); |
1113 | /* &0 to &9 or whatever is the regular expression bracketed |
1345 | str = curr_net->identifier; |
1114 | section */ |
1346 | } |
1115 | default: |
1347 | /* printf("Checking '%s'\n",str); */ |
1116 | index = c -'0'; |
1348 | 1117 | if(index <0 || index > subexpressions) |
|
1349 | /* found will not be set if neither Name or Ident is used */ |
1118 | { |
1350 | if (!found) |
1119 | fail = 1; |
1351 | { |
1120 | } |
1352 | char name_buff[MAXIDLEN]; |
1121 | else |
1353 | int fail, count; |
1122 | { |
1354 | int editp, copyp; |
1123 | /* copy subexpression over */ |
1355 | name_buff[0] = 0; |
1124 | copyp = ppin_reg->regpatt[index].rm_so; |
1356 | /* get length of replacement string */ |
1125 | if (copyp >=0 ) |
1357 | editp = 0; |
1126 | { |
1358 | fail = 0; |
1127 | while(copyp < ppin_reg->regpatt[index].rm_eo) |
1359 | count = 0; |
1128 | { |
1360 | net_count++; |
1129 | name_buff[count++] = str[copyp++]; |
1361 | printf ("Processing '%s'\n", str); |
1130 | } |
1362 | while (pin_repl[editp] && !fail) |
1131 | } |
1363 | { |
1132 | else |
1364 | /* escape anything */ |
1133 | { |
1365 | if (pin_repl[editp] == '\\') |
1134 | name_buff[count++] = '@'; |
1366 | { |
1135 | } |
1367 | editp++; |
1136 | } |
1368 | name_buff[count++] = pin_repl[editp]; |
1137 | } /* cae */ |
1369 | if (pin_repl[editp]) |
1138 | } |
1370 | { |
1139 | } |
1371 | editp++; |
1140 | |
1372 | } |
1141 | else |
1373 | } |
1142 | { |
1374 | /* replace matched patterns */ |
1143 | name_buff[count++]=pin_repl[editp++]; |
1375 | else if (pin_repl[editp] == '&') |
1144 | } |
1376 | { |
1145 | } |
1377 | int index, len; |
1146 | if(!fail) |
1378 | char c; |
1147 | { |
1379 | editp++; |
1148 | name_buff[count] = 0; |
1380 | c = pin_repl[editp]; |
1149 | /* |
1381 | if (c) |
1150 | printf("replacing '%s' with '%s'\n",chip_node->identifier,name_buff); |
1382 | { |
1151 | */ if(search_space == Ident) |
1383 | editp++; |
1152 | { |
1384 | switch (c) |
1153 | curr_net->identifier = realloc(curr_net->identifier,count+1); |
1385 | { |
1154 | |
1386 | /* replace with name part of |
1155 | printf("replacing '%s' with '%s'\n",curr_net->identifier,name_buff); |
1387 | * net */ |
1156 | strcpy(curr_net->identifier,name_buff); |
1388 | case 'n': |
1157 | } |
1389 | case 'N': |
1158 | if(search_space == Name) |
1390 | if (!ISNULLSTR ( |
1159 | { |
1391 | curr_net->name)) |
1160 | curr_net->name = realloc(curr_net->name,count+1); |
1392 | { |
1161 | printf("replacing '%s' with '%s'\n",curr_net->name,name_buff); |
1393 | len = strlen ( |
1162 | strcpy(curr_net->name,name_buff); |
1394 | curr_net->name); |
1163 | } |
1395 | strncpy ( |
1164 | |
1396 | name_buff + count, |
1165 | } |
1397 | curr_net->name, |
1166 | } |
1398 | len); |
1167 | curr_net=curr_net->next; |
1399 | count += len; |
1168 | } |
1400 | } |
1169 | } |
1401 | else |
1170 | Log(LOG_GENERAL,"-- processed %d nets\n",net_count); |
1402 | { |
1171 | vert_regfree(&ppin_reg); |
1403 | fail = 1; |
1172 | } |
1404 | } |
- | |
1405 | break; |
- | |
1406 | - | ||
1407 | case 'i': |
- | |
1408 | case 'I': |
- | |
1409 | if (!ISNULLSTR ( |
- | |
1410 | curr_net->identifier)) |
- | |
1411 | { |
- | |
1412 | len = strlen ( |
- | |
1413 | curr_net |
- | |
1414 | ->identifier); |
- | |
1415 | strncpy ( |
- | |
1416 | name_buff + count, |
- | |
1417 | curr_net |
- | |
1418 | ->identifier, |
- | |
1419 | len); |
- | |
1420 | count += len; |
- | |
1421 | } |
- | |
1422 | else |
- | |
1423 | { |
- | |
1424 | fail = 1; |
- | |
1425 | } |
- | |
1426 | break; |
- | |
1427 | - | ||
1428 | /* &0 to &9 or whatever is the |
- | |
1429 | regular expression bracketed |
- | |
1430 | section */ |
- | |
1431 | default: |
- | |
1432 | index = c - '0'; |
- | |
1433 | if (index < 0 || |
- | |
1434 | index > subexpressions) |
- | |
1435 | { |
- | |
1436 | fail = 1; |
- | |
1437 | } |
- | |
1438 | else |
- | |
1439 | { |
- | |
1440 | /* copy subexpression |
- | |
1441 | * over */ |
- | |
1442 | copyp = ppin_reg |
- | |
1443 | ->regpatt |
- | |
1444 | [index] |
- | |
1445 | .rm_so; |
- | |
1446 | if (copyp >= 0) |
- | |
1447 | { |
- | |
1448 | while ( |
- | |
1449 | copyp < |
- | |
1450 | ppin_reg |
- | |
1451 | ->regpatt |
- | |
1452 | [index] |
- | |
1453 | .rm_eo) |
- | |
1454 | { |
- | |
1455 | name_buff |
- | |
1456 | [count++] = str |
- | |
1457 | [copyp++]; |
- | |
1458 | } |
- | |
1459 | } |
- | |
1460 | else |
- | |
1461 | { |
- | |
1462 | name_buff |
- | |
1463 | [count++] = |
- | |
1464 | '@'; |
- | |
1465 | } |
- | |
1466 | } |
- | |
1467 | } /* cae */ |
- | |
1468 | } |
- | |
1469 | } |
- | |
1470 | - | ||
1471 | else |
- | |
1472 | { |
- | |
1473 | name_buff[count++] = pin_repl[editp++]; |
- | |
1474 | } |
- | |
1475 | } |
- | |
1476 | if (!fail) |
- | |
1477 | { |
- | |
1478 | name_buff[count] = 0; |
- | |
1479 | /* |
- | |
1480 | printf("replacing '%s' with |
- | |
1481 | '%s'\n",chip_node->identifier,name_buff); |
- | |
1482 | */ |
- | |
1483 | if (search_space == Ident) |
- | |
1484 | { |
- | |
1485 | curr_net->identifier = |
- | |
1486 | realloc (curr_net->identifier, count + 1); |
- | |
1487 | - | ||
1488 | printf ( |
- | |
1489 | "replacing '%s' with '%s'\n", |
- | |
1490 | curr_net->identifier, |
- | |
1491 | name_buff); |
- | |
1492 | strcpy (curr_net->identifier, name_buff); |
- | |
1493 | } |
- | |
1494 | if (search_space == Name) |
- | |
1495 | { |
- | |
1496 | curr_net->name = |
- | |
1497 | realloc (curr_net->name, count + 1); |
- | |
1498 | printf ( |
- | |
1499 | "replacing '%s' with '%s'\n", |
- | |
1500 | curr_net->name, |
- | |
1501 | name_buff); |
- | |
1502 | strcpy (curr_net->name, name_buff); |
- | |
1503 | } |
- | |
1504 | } |
- | |
1505 | } |
- | |
1506 | curr_net = curr_net->next; |
- | |
1507 | } |
- | |
1508 | } |
- | |
1509 | Log (LOG_GENERAL, "-- processed %d nets\n", net_count); |
- | |
1510 | vert_regfree (&ppin_reg); |
- | |
1511 | } |
- |