Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
11 | mjames | 1 | /* |
2 | * $Id: statistics.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $ |
||
2 | mjames | 3 | * |
4 | * $Log: statistics.c,v $ |
||
5 | * Revision 1.1.1.1 2003/11/04 23:34:57 mjames |
||
6 | * Imported into local repositrory |
||
7 | * |
||
8 | * Revision 1.9 2002/01/16 11:22:49 mjames |
||
9 | * database.h header file is read in first as it undefined DLL stuff irrelevant |
||
10 | * to HPUX |
||
11 | * |
||
12 | * Revision 1.8 2002/01/15 12:33:14 mjames |
||
13 | * removed unused variable |
||
14 | * |
||
15 | * Revision 1.7 2001/10/31 22:20:18 mjames |
||
16 | * Tidying up problematical comments caused by CVS |
||
17 | * 'intelligent' comment guessing |
||
18 | * |
||
19 | * Revision 1.6 2001/10/31 16:18:04 mjames |
||
20 | * Added a datastructure to hide regular expression information from programs. |
||
21 | * Changed call to regexec to indicate 0 subexpressions to be matched |
||
22 | * rather than a number dependent on strlen(string) which was wrong. |
||
23 | * |
||
24 | * Revision 1.5 2001/10/10 20:18:20 mjames |
||
25 | * Added a vert_regcomp function to compile regular expressions |
||
26 | * with '^' (match start string) and '$' (match end string) bracketing |
||
27 | * this => wildcard must match entire string not just a part of it. |
||
28 | * |
||
29 | * Revision 1.4 2001/10/07 20:50:51 mjames |
||
30 | * Added wildcard checking (warn user about |
||
31 | * using wildcard '*' on the end of a string in stead of wildcard '.*') |
||
32 | * |
||
33 | * Revision 1.3 2001/09/25 23:15:22 mjames |
||
34 | * Converted wildcards to use proper regexp pattern match library |
||
35 | * |
||
36 | * Revision 1.2 2001/06/06 12:10:17 mjames |
||
37 | * Move from HPUX |
||
38 | * |
||
39 | * Revision 1.1.1.1 2000/10/19 21:58:40 mjames |
||
40 | * Mike put it here |
||
41 | * |
||
42 | * |
||
43 | * Revision 1.37 2000/10/12 14:27:48 14:27:48 mjames (Mike James) |
||
44 | * changed listing vhdl signals to expand expressions |
||
11 | mjames | 45 | * until a constant is located |
46 | * |
||
2 | mjames | 47 | * Revision 1.36 2000/10/04 10:37:10 10:37:10 mjames (Mike James) |
48 | * Modified for Vertical2 : support COMPONENTS and SIGNALS |
||
11 | mjames | 49 | * |
2 | mjames | 50 | * Revision 1.36 2000/10/04 10:37:10 10:37:10 mjames (Mike James) |
51 | * Part of Release PSAVAT01 |
||
11 | mjames | 52 | * |
2 | mjames | 53 | * Revision 1.35 2000/10/02 11:04:21 11:04:21 mjames (Mike James) |
54 | * new_vhdl |
||
11 | mjames | 55 | * |
2 | mjames | 56 | * Revision 1.34 2000/09/27 14:42:21 14:42:21 mjames (Mike James) |
57 | * Part of Release Sep_27_ST_2000 |
||
11 | mjames | 58 | * |
2 | mjames | 59 | * Revision 1.33 2000/09/21 10:15:51 10:15:51 mjames (Mike James) |
60 | * Part of Release Sep21Alpha |
||
11 | mjames | 61 | * |
2 | mjames | 62 | * Revision 1.32 2000/09/21 09:47:33 09:47:33 mjames (Mike James) |
63 | * Corrected <cr> problem |
||
11 | mjames | 64 | * |
2 | mjames | 65 | * Revision 1.31 2000/08/25 09:57:17 09:57:17 mjames (Mike James) |
66 | * Part of Release Aug25_alpha |
||
11 | mjames | 67 | * |
2 | mjames | 68 | * Revision 1.30 2000/08/16 08:57:33 08:57:33 mjames (Mike James) |
69 | * Part of Release CD01_Aug2000 |
||
11 | mjames | 70 | * |
2 | mjames | 71 | * Revision 1.29 2000/08/14 14:45:14 14:45:14 mjames (Mike James) |
72 | * Part of Release Aug_14_2000 |
||
11 | mjames | 73 | * |
2 | mjames | 74 | * Revision 1.28 2000/08/11 08:30:34 08:30:34 mjames (Mike James) |
75 | * Part of Release Aug_11_2000 |
||
11 | mjames | 76 | * |
2 | mjames | 77 | * Revision 1.27 2000/08/09 10:31:50 10:31:50 mjames (Mike James) |
78 | * Part of Release Aug__9_2000 |
||
11 | mjames | 79 | * |
2 | mjames | 80 | * Revision 1.26 2000/05/31 11:43:01 11:43:01 mjames (Mike James) |
81 | * Part of Release May_31_2000 |
||
11 | mjames | 82 | * |
2 | mjames | 83 | * Revision 1.25 2000/05/08 17:01:40 17:01:40 mjames (Mike James) |
84 | * Part of Release May__8_2000 |
||
11 | mjames | 85 | * |
2 | mjames | 86 | * Revision 1.24 2000/05/08 16:59:33 16:59:33 mjames (Mike James) |
87 | * Part of Release May__8_2000 |
||
11 | mjames | 88 | * |
2 | mjames | 89 | * Revision 1.23 2000/05/08 16:57:10 16:57:10 mjames (Mike James) |
90 | * Part of Release May__8_2000 |
||
11 | mjames | 91 | * |
2 | mjames | 92 | * Revision 1.22 2000/05/03 15:28:39 15:28:39 mjames (Mike James) |
93 | * Corrected abuse of null pointers |
||
11 | mjames | 94 | * |
2 | mjames | 95 | * Revision 1.21 2000/03/08 16:19:33 16:19:33 mjames (Mike James) |
96 | * New version including PC |
||
11 | mjames | 97 | * |
2 | mjames | 98 | * Revision 1.18 2000/01/20 15:58:51 15:58:51 mjames (Mike James) |
99 | * Part of Release R22 |
||
11 | mjames | 100 | * |
2 | mjames | 101 | * Revision 1.17 99/12/22 11:15:31 11:15:31 mjames (Mike James) |
102 | * Part of Release Dec_22_1999 |
||
11 | mjames | 103 | * |
2 | mjames | 104 | * Revision 1.16 99/06/25 14:35:52 14:35:52 mjames (Mike James) |
11 | mjames | 105 | * Added in reference to expression.h, but no changes made |
2 | mjames | 106 | * to the function of acfread yet. |
11 | mjames | 107 | * |
2 | mjames | 108 | * Revision 1.15 99/05/04 09:52:55 09:52:55 mjames (Mike James) |
109 | * General checkin |
||
11 | mjames | 110 | * |
2 | mjames | 111 | * Revision 1.14 98/03/16 11:39:55 11:39:55 mjames (Mike James) |
112 | * Altered XREF printout to use wildcards. |
||
11 | mjames | 113 | * |
2 | mjames | 114 | * Revision 1.13 98/02/11 11:27:25 11:27:25 mjames (Mike James) |
115 | * Checked in for version 6.2a |
||
11 | mjames | 116 | * |
2 | mjames | 117 | * Revision 1.12 97/04/23 08:43:26 08:43:26 mjames (Mike James) |
118 | * CHecked in for release rel23041997 |
||
11 | mjames | 119 | * |
2 | mjames | 120 | * Revision 1.11 97/01/03 13:37:29 13:37:29 mjames (Mike James) |
11 | mjames | 121 | * Tidied up the ensure_reserved() function. Added in a flag to |
2 | mjames | 122 | * indicate that a net has been processed by ensure_reserved() |
123 | * And so is not in error for only having 0 or 1 nodes names (which is the |
||
124 | * case for a 1 or 2 node net that has been processed. One of the nodes will |
||
125 | * remain unnnamed and this will result in 0 or 1 nodes apparently in use |
||
11 | mjames | 126 | * |
2 | mjames | 127 | * Revision 1.10 96/12/23 15:15:34 15:15:34 mjames (Mike James) |
128 | * ? |
||
11 | mjames | 129 | * |
2 | mjames | 130 | * Revision 1.9 96/12/13 08:43:14 08:43:14 mjames (Mike James) |
131 | * Update to v5.1, added Write ID , exact routing |
||
11 | mjames | 132 | * |
2 | mjames | 133 | * Revision 1.8 96/08/06 13:38:57 13:38:57 mjames (Mike James) |
134 | * Added a count of nets with low numbers of nodes in the routed list. |
||
135 | * |
||
136 | * Revision 1.7 96/07/19 14:38:46 14:38:46 mjames (Mike James) |
||
137 | * Update to give to PRL |
||
138 | * |
||
139 | * Revision 1.6 1996/07/12 15:52:12 mjames |
||
140 | * Sorted out things like Alias and Jumpers |
||
141 | * Work Correctly |
||
142 | * Print COrrectly |
||
143 | * |
||
144 | * Revision 1.5 96/06/17 13:01:48 13:01:48 mjames (Mike James) |
||
145 | * Altered the printing of JUMPERED and ALIASED nets |
||
146 | * , |
||
147 | * |
||
148 | * Revision 1.4 96/04/26 16:02:36 16:02:36 mjames (Mike James) |
||
149 | * Altered inside/outside determination of signal directions |
||
150 | * |
||
151 | * Revision 1.3 96/04/15 14:19:38 14:19:38 mjames (Mike James) |
||
152 | * Checkin before datatype printing |
||
153 | * modifications |
||
154 | * |
||
155 | * Revision 1.2 96/03/29 14:46:34 14:46:34 mjames (Mike James) |
||
156 | * Added VHDL netlist writing to the capabilities of ACFREAD |
||
157 | * |
||
158 | * Revision 1.1 96/03/26 07:47:46 07:47:46 mjames (Mike James) |
||
159 | * Initial revision |
||
160 | * */ |
||
161 | /* The statistics module . This counts the connections between the chip and |
||
162 | other named chips. */ |
||
163 | |||
11 | mjames | 164 | #include <stdio.h> |
165 | #include <string.h> |
||
166 | #include <stdlib.h> |
||
167 | #include <sys/types.h> |
||
168 | #include <regex.h> |
||
2 | mjames | 169 | |
170 | #include "expression.h" |
||
171 | #include "generic.h" |
||
11 | mjames | 172 | #include "database.h" |
173 | |||
174 | |||
175 | |||
176 | #include "vertcl_main.h" |
||
177 | #include "statistics.h" |
||
178 | #include "cmdparse.h" |
||
179 | #include "cmdlog.h" |
||
2 | mjames | 180 | #include "lx_support.h" |
11 | mjames | 181 | #include "chck_names.h" |
2 | mjames | 182 | #include "sorting.h" |
183 | |||
11 | mjames | 184 | static char IDstr[] = "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/statistics.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $"; |
2 | mjames | 185 | |
186 | |||
187 | /* this procedure counts paths from a named socket to all other named |
||
188 | sockets. There are two wildcard options : |
||
189 | no wildcard : all sockets are listed |
||
190 | string* : any string beginning 'string' |
||
191 | * : all named sockets */ |
||
192 | |||
11 | mjames | 193 | int count_paths(char * template) |
2 | mjames | 194 | { |
11 | mjames | 195 | socket_t * skt_p, * skt_try; |
196 | noderef_t * net_nodes; |
||
197 | node_t * skt_nodes ; |
||
198 | net_t ** list_member; |
||
199 | int rc; |
||
2 | mjames | 200 | |
11 | mjames | 201 | char * pattern; |
202 | /* compile regular expression */ |
||
203 | vert_regex_t * preg; |
||
2 | mjames | 204 | |
205 | |||
11 | mjames | 206 | skt_p = socket_head; |
207 | /* clear all of the visit counters */ |
||
208 | while (skt_p) { |
||
209 | skt_p->named_in_use_cnt = |
||
210 | skt_p->named_cnt = |
||
211 | skt_p->routed_cnt= |
||
212 | skt_p->unrouted_cnt = 0; |
||
213 | skt_p=skt_p->next; |
||
214 | } |
||
215 | if(!ISNULLSTR(template)) |
||
216 | { |
||
217 | pattern = template; |
||
218 | } |
||
219 | else |
||
220 | { |
||
221 | pattern = ".*"; |
||
222 | } |
||
2 | mjames | 223 | |
11 | mjames | 224 | rc = vert_regcomp(&preg,pattern); |
2 | mjames | 225 | |
11 | mjames | 226 | if (rc != 0 ) |
227 | { |
||
228 | char errbuff[100]; |
||
229 | regerror(rc,preg->preg,errbuff,100); |
||
230 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,pattern); |
||
231 | |||
232 | return TCL_ERROR; |
||
233 | } |
||
2 | mjames | 234 | |
11 | mjames | 235 | Log(LOG_GENERAL,"-- Listing xref for socket names '%s' --\n", |
236 | template?template:"[ALL Sockets]"); |
||
2 | mjames | 237 | |
11 | mjames | 238 | skt_p = socket_head; |
239 | while(skt_p) { |
||
240 | int found; |
||
2 | mjames | 241 | |
11 | mjames | 242 | found = regexec(preg->preg,skt_p->name,0,preg->regpatt,0); |
243 | if(!found) { |
||
2 | mjames | 244 | |
11 | mjames | 245 | skt_nodes = skt_p -> nodes ; |
246 | /* |
||
247 | fprintf(f,"named = %p , routed = %p unrouted = %p\n", |
||
248 | &named_list,&routed_list,&unrouted_list); |
||
249 | */ |
||
250 | /* we have located the socket on the net . Let us now locate each net */ |
||
251 | /* some nodes on a socket will be unrouted nodes on unrouted nets that |
||
252 | have now been resolved , and the unrouted net will have been deleted . |
||
253 | These have the property that node->net->list_ref = NULL */ |
||
254 | while(skt_nodes) { |
||
255 | net_t * ref_net = skt_nodes->net; |
||
256 | if(ref_net) { |
||
257 | int high,low,width,net_high,net_low; |
||
2 | mjames | 258 | |
259 | |||
11 | mjames | 260 | net_nodes = ref_net->nodes; |
2 | mjames | 261 | |
262 | |||
11 | mjames | 263 | /* note the upper and lower bound of the bundle connected from this |
264 | * pin of this socket to the net. |
||
265 | * Also checking there is an associated VHDL type 4 May 2000 */ |
||
266 | if (skt_nodes->vhdltype) { |
||
267 | eval_vhdl_expression(skt_nodes->vhdltype->expr,&net_high,&net_low); |
||
268 | } |
||
269 | else { |
||
270 | net_low = 0; |
||
271 | net_high= 0; |
||
272 | } |
||
273 | |||
274 | /* which list is this net on */ |
||
275 | list_member = ref_net->list_ref; |
||
276 | /* visit each node */ |
||
277 | while(net_nodes){ |
||
278 | node_t * n = net_nodes->node; |
||
279 | vhdl_t * vhdl= net_nodes->vhdltype; |
||
280 | int vhdl_high,vhdl_low; |
||
281 | if (vhdl) { |
||
282 | /* to determine the intersection of the bundles, |
||
283 | * hence connection count : |
||
284 | * (15 downto 8) connected to (10 downto 5) has intersection |
||
285 | * (10 downto 8) |
||
286 | */ |
||
287 | if (vhdl->expr) |
||
288 | eval_vhdl_expression(vhdl->expr,&vhdl_high,&vhdl_low); |
||
289 | else { |
||
290 | vhdl_high = 0; |
||
291 | vhdl_low = 0; |
||
292 | } |
||
293 | /* use the lowest high bound of the node this net comes from */ |
||
294 | high = vhdl_high > net_high ? net_high : vhdl_high; |
||
295 | |||
296 | /* use the highest low bound of the node this net comes from */ |
||
297 | low = vhdl_low < net_low ? net_low : vhdl_low; |
||
298 | |||
299 | /* now get the number of wires in the bundle */ |
||
300 | width = high - low + 1; |
||
301 | if(list_member==&named_list) { |
||
302 | if (n->in_use) |
||
303 | n->socket->named_in_use_cnt += width; |
||
304 | else |
||
305 | n->socket->named_cnt += width; |
||
306 | } |
||
307 | else if (list_member==&routed_list) |
||
308 | n->socket->routed_cnt += width; |
||
309 | else if (list_member==&unrouted_list) |
||
310 | n->socket->unrouted_cnt += width; |
||
311 | else if (list_member!=NULL) |
||
312 | Log(LOG_ERROR,"# ERROR : Net %s is on unknown list pointer=%p , net \n",ref_net->name,list_member); |
||
313 | } |
||
314 | net_nodes = net_nodes->next; |
||
315 | } |
||
316 | } |
||
317 | skt_nodes = skt_nodes->sktnext; |
||
318 | } |
||
319 | /* now have compiled a cross reference count */ |
||
320 | skt_try = socket_head; |
||
321 | Log(LOG_GENERAL,"-- Cross reference for socket '%s'\n",skt_p->name); |
||
322 | Log(LOG_GENERAL,"Name : Named&Used, Named, Routed,Unrouted\n"); |
||
323 | skt_try = socket_head; |
||
324 | while(skt_try){ |
||
325 | if(!ISNULLSTR(skt_try->name)){ |
||
326 | Log(LOG_GENERAL,"%16s : %5d, %5d, %5d, %5d\n", |
||
327 | skt_try -> name, |
||
328 | skt_try -> named_in_use_cnt, |
||
329 | skt_try -> named_cnt, |
||
330 | skt_try -> routed_cnt, |
||
331 | skt_try -> unrouted_cnt); |
||
2 | mjames | 332 | } |
11 | mjames | 333 | skt_try->named_in_use_cnt = |
334 | skt_try->named_cnt = |
||
335 | skt_try->routed_cnt= |
||
336 | skt_try->unrouted_cnt = 0; |
||
337 | skt_try = skt_try->next; |
||
338 | } |
||
339 | } |
||
340 | skt_p = skt_p->next; |
||
341 | } |
||
342 | |||
343 | vert_regfree(&preg); |
||
344 | return OKCMD; /* success */ |
||
2 | mjames | 345 | } |
346 | |||
347 | /* this procedure counts up and displays the number of nets with less than a certain |
||
348 | threshold number of nodes actually in use. */ |
||
11 | mjames | 349 | void count_nets_with_few_nodes(int limit) |
2 | mjames | 350 | { |
11 | mjames | 351 | long lowcount=0; |
352 | net_t * routed_net = named_list; |
||
353 | Log(LOG_GENERAL,"-- Checking for nets with less than or equal to %d nodes in use\n", |
||
354 | limit); |
||
355 | while (routed_net) { |
||
356 | int nodecount = 0; |
||
357 | noderef_t * routed_nodes = routed_net->nodes; |
||
358 | while (routed_nodes) { |
||
359 | /* node_t *cnode = routed_nodes->node; */ |
||
360 | if (routed_nodes->node->net_assigned != 0) |
||
361 | nodecount++; |
||
2 | mjames | 362 | |
11 | mjames | 363 | routed_nodes = routed_nodes->next; |
364 | } |
||
365 | /* turn off warning if low nodecount is due to ensure_reserved processing in routing.c */ |
||
366 | if (nodecount <= limit && !routed_net->nodes_reserved) { |
||
367 | Log(LOG_GENERAL,"-- Net '%s' (name '%s') has only %d node(s) in use\n", |
||
368 | routed_net->identifier, |
||
369 | routed_net->name, |
||
370 | nodecount); |
||
371 | lowcount++; |
||
372 | } |
||
373 | routed_net = routed_net->next; |
||
374 | |||
375 | } |
||
376 | Log(LOG_GENERAL,"-- Found %d nets with less than %d nodes used\n", |
||
377 | lowcount,limit); |
||
378 | |||
2 | mjames | 379 | } |
380 | |||
381 | /* keep some cc's happy */ |
||
11 | mjames | 382 | void statistics_waste(void) |
2 | mjames | 383 | { |
11 | mjames | 384 | char * s=IDstr; |
385 | s=s; |
||
2 | mjames | 386 | } |
11 | mjames | 387 |