Subversion Repositories Vertical

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/*
2
 * $Id: statistics.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $
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
45
 * until a constant is located
46
 *
47
 * Revision 1.36  2000/10/04  10:37:10  10:37:10  mjames (Mike James)
48
 * Modified for Vertical2 : support COMPONENTS and SIGNALS
49
 *
50
 * Revision 1.36  2000/10/04  10:37:10  10:37:10  mjames (Mike James)
51
 * Part of Release PSAVAT01
52
 *
53
 * Revision 1.35  2000/10/02  11:04:21  11:04:21  mjames (Mike James)
54
 * new_vhdl
55
 *
56
 * Revision 1.34  2000/09/27  14:42:21  14:42:21  mjames (Mike James)
57
 * Part of Release Sep_27_ST_2000
58
 *
59
 * Revision 1.33  2000/09/21  10:15:51  10:15:51  mjames (Mike James)
60
 * Part of Release Sep21Alpha
61
 *
62
 * Revision 1.32  2000/09/21  09:47:33  09:47:33  mjames (Mike James)
63
 * Corrected <cr> problem
64
 *
65
 * Revision 1.31  2000/08/25  09:57:17  09:57:17  mjames (Mike James)
66
 * Part of Release Aug25_alpha
67
 *
68
 * Revision 1.30  2000/08/16  08:57:33  08:57:33  mjames (Mike James)
69
 * Part of Release CD01_Aug2000
70
 *
71
 * Revision 1.29  2000/08/14  14:45:14  14:45:14  mjames (Mike James)
72
 * Part of Release Aug_14_2000
73
 *
74
 * Revision 1.28  2000/08/11  08:30:34  08:30:34  mjames (Mike James)
75
 * Part of Release Aug_11_2000
76
 *
77
 * Revision 1.27  2000/08/09  10:31:50  10:31:50  mjames (Mike James)
78
 * Part of Release Aug__9_2000
79
 *
80
 * Revision 1.26  2000/05/31  11:43:01  11:43:01  mjames (Mike James)
81
 * Part of Release May_31_2000
82
 *
83
 * Revision 1.25  2000/05/08  17:01:40  17:01:40  mjames (Mike James)
84
 * Part of Release May__8_2000
85
 *
86
 * Revision 1.24  2000/05/08  16:59:33  16:59:33  mjames (Mike James)
87
 * Part of Release May__8_2000
88
 *
89
 * Revision 1.23  2000/05/08  16:57:10  16:57:10  mjames (Mike James)
90
 * Part of Release May__8_2000
91
 *
92
 * Revision 1.22  2000/05/03  15:28:39  15:28:39  mjames (Mike James)
93
 * Corrected abuse of null pointers
94
 *
95
 * Revision 1.21  2000/03/08  16:19:33  16:19:33  mjames (Mike James)
96
 * New version including PC
97
 *
98
 * Revision 1.18  2000/01/20  15:58:51  15:58:51  mjames (Mike James)
99
 * Part of Release R22
100
 *
101
 * Revision 1.17  99/12/22  11:15:31  11:15:31  mjames (Mike James)
102
 * Part of Release Dec_22_1999
103
 *
104
 * Revision 1.16  99/06/25  14:35:52  14:35:52  mjames (Mike James)
105
 * Added in reference to expression.h, but no changes made
106
 * to the function of acfread yet.
107
 *
108
 * Revision 1.15  99/05/04  09:52:55  09:52:55  mjames (Mike James)
109
 * General checkin
110
 *
111
 * Revision 1.14  98/03/16  11:39:55  11:39:55  mjames (Mike James)
112
 * Altered XREF printout to use wildcards.
113
 *
114
 * Revision 1.13  98/02/11  11:27:25  11:27:25  mjames (Mike James)
115
 * Checked in for version 6.2a
116
 *
117
 * Revision 1.12  97/04/23  08:43:26  08:43:26  mjames (Mike James)
118
 * CHecked in for release rel23041997
119
 *
120
 * Revision 1.11  97/01/03  13:37:29  13:37:29  mjames (Mike James)
121
 * Tidied up the ensure_reserved() function. Added in a flag to
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
126
 *
127
 * Revision 1.10  96/12/23  15:15:34  15:15:34  mjames (Mike James)
128
 * ?
129
 *
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
132
 *
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
 
164
#include "statistics.h"
165
 
166
#include "chck_names.h"
167
#include "cmdlog.h"
168
#include "cmdparse.h"
169
#include "database.h"
170
#include "expression.h"
171
#include "generic.h"
172
#include "lx_support.h"
173
#include "sorting.h"
174
#include "vertcl_main.h"
175
 
176
#include <regex.h>
177
#include <stdio.h>
178
#include <stdlib.h>
179
#include <string.h>
180
#include <sys/types.h>
181
 
182
static char IDstr[] = "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/statistics.c,v 1.1.1.1 "
183
                      "2003/11/04 23:34:57 mjames Exp $";
184
 
185
/* this procedure counts paths from a named socket to all other named
186
   sockets. There are two wildcard options :
187
   no wildcard : all sockets are listed
188
   string*     : any string beginning 'string'
189
   *           : all named sockets  */
190
 
191
int count_paths (char *template)
192
{
193
        socket_t *skt_p, *skt_try;
194
        noderef_t *net_nodes;
195
        node_t *skt_nodes;
196
        net_t **list_member;
197
        int rc;
198
 
199
        char *pattern;
200
        /* compile regular expression */
201
        vert_regex_t *preg;
202
 
203
        skt_p = socket_head;
204
        /* clear all of the visit counters */
205
        while (skt_p)
206
        {
207
                skt_p->named_in_use_cnt = skt_p->named_cnt = skt_p->routed_cnt =
208
                    skt_p->unrouted_cnt = 0;
209
                skt_p = skt_p->next;
210
        }
211
        if (!ISNULLSTR (template))
212
        {
213
                pattern = template;
214
        }
215
        else
216
        {
217
                pattern = ".*";
218
        }
219
 
220
        rc = vert_regcomp (&preg, pattern);
221
 
222
        if (rc != 0)
223
        {
224
                char errbuff[100];
225
                regerror (rc, preg->preg, errbuff, 100);
226
                Log (
227
                    LOG_ERROR,
228
                    "-- Problem (rc=%d) %s with '%s' as regular expression\n",
229
                    rc,
230
                    errbuff,
231
                    pattern);
232
 
233
                return TCL_ERROR;
234
        }
235
 
236
        Log (
237
            LOG_GENERAL,
238
            "-- Listing xref for socket names '%s' --\n",
239
            template ? template : "[ALL Sockets]");
240
 
241
        skt_p = socket_head;
242
        while (skt_p)
243
        {
244
                int found;
245
 
246
                found = regexec (preg->preg, skt_p->name, 0, preg->regpatt, 0);
247
                if (!found)
248
                {
249
                        skt_nodes = skt_p->nodes;
250
                        /*
251
                          fprintf(f,"named = %p , routed = %p  unrouted = %p\n",
252
                                &named_list,&routed_list,&unrouted_list);
253
                        */
254
                        /* we have located the socket on the net . Let us now locate each net
255
                         */
256
                        /* some nodes on a socket will be unrouted nodes on unrouted nets that
257
                           have now been resolved , and the unrouted net will have been deleted
258
                           . These have the property that node->net->list_ref = NULL */
259
                        while (skt_nodes)
260
                        {
261
                                net_t *ref_net = skt_nodes->net;
262
                                if (ref_net)
263
                                {
264
                                        int high, low, width, net_high, net_low;
265
 
266
                                        net_nodes = ref_net->nodes;
267
 
268
                                        /* note the upper and lower bound of the bundle
269
                                         * connected from this pin of this socket to the net.
270
                                         * Also checking there is an associated VHDL type 4 May
271
                                         * 2000 */
272
                                        if (skt_nodes->vhdltype)
273
                                        {
274
                                                eval_vhdl_expression (
275
                                                    skt_nodes->vhdltype->expr,
276
                                                    &net_high,
277
                                                    &net_low);
278
                                        }
279
                                        else
280
                                        {
281
                                                net_low = 0;
282
                                                net_high = 0;
283
                                        }
284
 
285
                                        /* which list is this net on */
286
                                        list_member = ref_net->list_ref;
287
                                        /* visit each node */
288
                                        while (net_nodes)
289
                                        {
290
                                                node_t *n = net_nodes->node;
291
                                                vhdl_t *vhdl = net_nodes->vhdltype;
292
                                                int vhdl_high, vhdl_low;
293
                                                if (vhdl)
294
                                                {
295
                                                        /* to determine the intersection of the
296
                                                         * bundles, hence connection count :
297
                                                         * (15 downto 8) connected to (10
298
                                                         * downto 5) has intersection (10
299
                                                         * downto 8)
300
                                                         */
301
                                                        if (vhdl->expr)
302
                                                                eval_vhdl_expression (
303
                                                                    vhdl->expr,
304
                                                                    &vhdl_high,
305
                                                                    &vhdl_low);
306
                                                        else
307
                                                        {
308
                                                                vhdl_high = 0;
309
                                                                vhdl_low = 0;
310
                                                        }
311
                                                        /* use the lowest high bound of the
312
                                                         * node this net comes from */
313
                                                        high = vhdl_high > net_high
314
                                                                   ? net_high
315
                                                                   : vhdl_high;
316
 
317
                                                        /* use the highest low bound of the
318
                                                         * node this net comes from */
319
                                                        low = vhdl_low < net_low ? net_low
320
                                                                                 : vhdl_low;
321
 
322
                                                        /* now get the number of wires in the
323
                                                         * bundle */
324
                                                        width = high - low + 1;
325
                                                        if (list_member == &named_list)
326
                                                        {
327
                                                                if (n->in_use)
328
                                                                        n->socket
329
                                                                            ->named_in_use_cnt +=
330
                                                                            width;
331
                                                                else
332
                                                                        n->socket->named_cnt +=
333
                                                                            width;
334
                                                        }
335
                                                        else if (list_member == &routed_list)
336
                                                                n->socket->routed_cnt += width;
337
                                                        else if (list_member == &unrouted_list)
338
                                                                n->socket->unrouted_cnt +=
339
                                                                    width;
340
                                                        else if (list_member != NULL)
341
                                                                Log (
342
                                                                    LOG_ERROR,
343
                                                                    "# ERROR : Net %s is on "
344
                                                                    "unknown list pointer=%p "
345
                                                                    ", net \n",
346
                                                                    ref_net->name,
347
                                                                    list_member);
348
                                                }
349
                                                net_nodes = net_nodes->next;
350
                                        }
351
                                }
352
                                skt_nodes = skt_nodes->sktnext;
353
                        }
354
                        /* now have compiled a cross reference count */
355
                        skt_try = socket_head;
356
                        Log (
357
                            LOG_GENERAL, "--  Cross reference for socket '%s'\n", skt_p->name);
358
                        Log (
359
                            LOG_GENERAL,
360
                            "Name            : Named&Used, Named, Routed,Unrouted\n");
361
                        skt_try = socket_head;
362
                        while (skt_try)
363
                        {
364
                                if (!ISNULLSTR (skt_try->name))
365
                                {
366
                                        Log (
367
                                            LOG_GENERAL,
368
                                            "%16s :  %5d, %5d, %5d, %5d\n",
369
                                            skt_try->name,
370
                                            skt_try->named_in_use_cnt,
371
                                            skt_try->named_cnt,
372
                                            skt_try->routed_cnt,
373
                                            skt_try->unrouted_cnt);
374
                                }
375
                                skt_try->named_in_use_cnt = skt_try->named_cnt =
376
                                    skt_try->routed_cnt = skt_try->unrouted_cnt = 0;
377
                                skt_try = skt_try->next;
378
                        }
379
                }
380
                skt_p = skt_p->next;
381
        }
382
 
383
        vert_regfree (&preg);
384
        return OKCMD; /* success */
385
}
386
 
387
/* this procedure counts up and displays the number of nets with less than a certain
388
 threshold number of nodes actually in use. */
389
void count_nets_with_few_nodes (int limit)
390
{
391
        long lowcount = 0;
392
        net_t *routed_net = named_list;
393
        Log (
394
            LOG_GENERAL,
395
            "-- Checking for nets with less than or equal to %d nodes in use\n",
396
            limit);
397
        while (routed_net)
398
        {
399
                int nodecount = 0;
400
                noderef_t *routed_nodes = routed_net->nodes;
401
                while (routed_nodes)
402
                {
403
                        /*        node_t *cnode = routed_nodes->node;  */
404
                        if (routed_nodes->node->net_assigned != 0)
405
                                nodecount++;
406
 
407
                        routed_nodes = routed_nodes->next;
408
                }
409
                /* turn off warning if low nodecount is due to ensure_reserved processing in
410
                 * routing.c */
411
                if (nodecount <= limit && !routed_net->nodes_reserved)
412
                {
413
                        Log (
414
                            LOG_GENERAL,
415
                            "-- Net '%s' (name '%s') has only %d node(s) in use\n",
416
                            routed_net->identifier,
417
                            routed_net->name,
418
                            nodecount);
419
                        lowcount++;
420
                }
421
                routed_net = routed_net->next;
422
        }
423
        Log (LOG_GENERAL, "-- Found %d nets with less than %d nodes used\n", lowcount, limit);
424
}
425
 
426
/* keep some cc's happy */
427
void statistics_waste (void)
428
{
429
        char *s = IDstr;
430
        s = s;
431
}