1 | /**CFile*********************************************************************** |
---|
2 | |
---|
3 | FileName [hrcCmd.c] |
---|
4 | |
---|
5 | PackageName [hrc] |
---|
6 | |
---|
7 | Synopsis [Commands for walking around HSIS/VIS hierarchies.] |
---|
8 | |
---|
9 | Description [] |
---|
10 | |
---|
11 | SeeAlso [] |
---|
12 | |
---|
13 | Author [Yuji Kukimoto] |
---|
14 | |
---|
15 | Copyright [Copyright (c) 1994-1996 The Regents of the Univ. of California. |
---|
16 | All rights reserved. |
---|
17 | |
---|
18 | Permission is hereby granted, without written agreement and without license |
---|
19 | or royalty fees, to use, copy, modify, and distribute this software and its |
---|
20 | documentation for any purpose, provided that the above copyright notice and |
---|
21 | the following two paragraphs appear in all copies of this software. |
---|
22 | |
---|
23 | IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR |
---|
24 | DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT |
---|
25 | OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF |
---|
26 | CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
27 | |
---|
28 | THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, |
---|
29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
---|
30 | FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN |
---|
31 | "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE |
---|
32 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.] |
---|
33 | |
---|
34 | ******************************************************************************/ |
---|
35 | |
---|
36 | #include "hrcInt.h" |
---|
37 | |
---|
38 | static char rcsid[] UNUSED = "$Id: hrcCmd.c,v 1.6 2002/09/08 21:54:25 fabio Exp $"; |
---|
39 | |
---|
40 | /*---------------------------------------------------------------------------*/ |
---|
41 | /* Constant declarations */ |
---|
42 | /*---------------------------------------------------------------------------*/ |
---|
43 | |
---|
44 | |
---|
45 | /*---------------------------------------------------------------------------*/ |
---|
46 | /* Type declarations */ |
---|
47 | /*---------------------------------------------------------------------------*/ |
---|
48 | |
---|
49 | |
---|
50 | /*---------------------------------------------------------------------------*/ |
---|
51 | /* Stucture declarations */ |
---|
52 | /*---------------------------------------------------------------------------*/ |
---|
53 | |
---|
54 | |
---|
55 | /*---------------------------------------------------------------------------*/ |
---|
56 | /* Variable declarations */ |
---|
57 | /*---------------------------------------------------------------------------*/ |
---|
58 | |
---|
59 | |
---|
60 | /*---------------------------------------------------------------------------*/ |
---|
61 | /* Macro declarations */ |
---|
62 | /*---------------------------------------------------------------------------*/ |
---|
63 | |
---|
64 | |
---|
65 | /**AutomaticStart*************************************************************/ |
---|
66 | |
---|
67 | /*---------------------------------------------------------------------------*/ |
---|
68 | /* Static function prototypes */ |
---|
69 | /*---------------------------------------------------------------------------*/ |
---|
70 | |
---|
71 | static int CommandCd(Hrc_Manager_t **hmgr, int argc, char **argv); |
---|
72 | static int CommandLs(Hrc_Manager_t **hmgr, int argc, char **argv); |
---|
73 | static int CommandPwd(Hrc_Manager_t **hmgr, int argc, char **argv); |
---|
74 | static void NodeListChildren(Hrc_Node_t *hnode, boolean recursiveFlag, int depth); |
---|
75 | static void PrintSpace(int depth); |
---|
76 | static int CommandPrintModels(Hrc_Manager_t **hmgr, int argc, char **argv); |
---|
77 | static int CommandPrintHierarchyStats(Hrc_Manager_t **hmgr, int argc, char **argv); |
---|
78 | static void PrintNodeStats(Hrc_Node_t *node, boolean isHnode); |
---|
79 | static void PrintNodeStatsRecursively(Hrc_Node_t *node); |
---|
80 | static int CommandPrintIo(Hrc_Manager_t **hmgr, int argc, char **argv); |
---|
81 | static int CommandPrintLatches(Hrc_Manager_t **hmgr, int argc, char **argv); |
---|
82 | static int _HrcStringCmp(const void * s1, const void * s2); |
---|
83 | |
---|
84 | /**AutomaticEnd***************************************************************/ |
---|
85 | |
---|
86 | |
---|
87 | /*---------------------------------------------------------------------------*/ |
---|
88 | /* Definition of exported functions */ |
---|
89 | /*---------------------------------------------------------------------------*/ |
---|
90 | |
---|
91 | /**Function******************************************************************** |
---|
92 | |
---|
93 | Synopsis [Initializes the hrc package.] |
---|
94 | |
---|
95 | SideEffects [] |
---|
96 | |
---|
97 | SeeAlso [Hrc_End] |
---|
98 | |
---|
99 | ******************************************************************************/ |
---|
100 | void |
---|
101 | Hrc_Init(void) |
---|
102 | { |
---|
103 | Cmd_CommandAdd("cd", CommandCd, 0); |
---|
104 | Cmd_CommandAdd("ls", CommandLs, 0); |
---|
105 | Cmd_CommandAdd("pwd", CommandPwd, 0); |
---|
106 | Cmd_CommandAdd("print_models", CommandPrintModels, 0); |
---|
107 | Cmd_CommandAdd("print_hierarchy_stats", CommandPrintHierarchyStats, 0); |
---|
108 | Cmd_CommandAdd("print_io", CommandPrintIo, 0); |
---|
109 | Cmd_CommandAdd("print_latches", CommandPrintLatches, 0); |
---|
110 | } |
---|
111 | |
---|
112 | /**Function******************************************************************** |
---|
113 | |
---|
114 | Synopsis [Ends the hrc package.] |
---|
115 | |
---|
116 | SideEffects [] |
---|
117 | |
---|
118 | SeeAlso [Hrc_Init] |
---|
119 | |
---|
120 | ******************************************************************************/ |
---|
121 | void |
---|
122 | Hrc_End(void) |
---|
123 | { |
---|
124 | } |
---|
125 | /*---------------------------------------------------------------------------*/ |
---|
126 | /* Definition of internal functions */ |
---|
127 | /*---------------------------------------------------------------------------*/ |
---|
128 | |
---|
129 | |
---|
130 | /*---------------------------------------------------------------------------*/ |
---|
131 | /* Definition of static functions */ |
---|
132 | /*---------------------------------------------------------------------------*/ |
---|
133 | |
---|
134 | /**Function******************************************************************** |
---|
135 | |
---|
136 | Synopsis [The top-level routine for cd.] |
---|
137 | |
---|
138 | SideEffects [] |
---|
139 | |
---|
140 | CommandName [cd] |
---|
141 | |
---|
142 | CommandSynopsis [change the current node] |
---|
143 | |
---|
144 | CommandArguments [ \[-h\] <child_instance_name> or <..>] |
---|
145 | |
---|
146 | CommandDescription [Changes the current node in the existing |
---|
147 | hierarchy. The argument should be either the name of a child node |
---|
148 | or .. meaning the parent node. Note that cd ../foo is not allowed.<p> |
---|
149 | Command options:<p> |
---|
150 | |
---|
151 | <dl> |
---|
152 | |
---|
153 | <dt> -h |
---|
154 | <dd> Print the command usage. |
---|
155 | |
---|
156 | </dl> |
---|
157 | ] |
---|
158 | |
---|
159 | SeeAlso [] |
---|
160 | |
---|
161 | ******************************************************************************/ |
---|
162 | static int |
---|
163 | CommandCd( |
---|
164 | Hrc_Manager_t **hmgr, |
---|
165 | int argc, |
---|
166 | char **argv) |
---|
167 | { |
---|
168 | Hrc_Node_t *currentNode, *parent, *child; |
---|
169 | int c; |
---|
170 | |
---|
171 | util_getopt_reset(); |
---|
172 | while ((c = util_getopt(argc, argv, "h")) != EOF) { |
---|
173 | switch(c){ |
---|
174 | case 'h': |
---|
175 | goto usage; |
---|
176 | default: |
---|
177 | goto usage; |
---|
178 | } |
---|
179 | } |
---|
180 | |
---|
181 | if (argc != 2){ |
---|
182 | goto usage; |
---|
183 | } |
---|
184 | |
---|
185 | currentNode = Hrc_ManagerReadCurrentNode(*hmgr); |
---|
186 | if (currentNode == NIL(Hrc_Node_t)){ |
---|
187 | (void)fprintf(vis_stdout,"No file has been read in.\n"); |
---|
188 | return 1; |
---|
189 | } |
---|
190 | /* go to the parent node */ |
---|
191 | if (strcmp(*(++argv),"..") == 0){ |
---|
192 | if ((parent = Hrc_NodeReadParentNode(currentNode)) == NIL(Hrc_Node_t)){ |
---|
193 | (void)fprintf(vis_stderr,"You are at the root node. Can't cd to a parent.\n"); |
---|
194 | return 1; |
---|
195 | } |
---|
196 | Hrc_ManagerSetCurrentNode(*hmgr,parent); |
---|
197 | return 0; |
---|
198 | } |
---|
199 | |
---|
200 | if ((child = Hrc_NodeFindChildByName(currentNode,*argv)) == NIL(Hrc_Node_t)){ |
---|
201 | (void)fprintf(vis_stderr,"No child node whose name is %s exists in the current node.\n",*argv); |
---|
202 | return 1; |
---|
203 | } |
---|
204 | Hrc_ManagerSetCurrentNode(*hmgr,child); |
---|
205 | return 0; |
---|
206 | |
---|
207 | usage: |
---|
208 | (void)fprintf(vis_stderr,"usage: cd [-h] child_name or cd ..\n"); |
---|
209 | (void) fprintf(vis_stderr, " -h \t\tprint the command usage\n"); |
---|
210 | return 1; |
---|
211 | } |
---|
212 | |
---|
213 | /**Function******************************************************************** |
---|
214 | |
---|
215 | Synopsis [The top-level routine for ls.] |
---|
216 | |
---|
217 | SideEffects [] |
---|
218 | |
---|
219 | CommandName [ls] |
---|
220 | |
---|
221 | CommandSynopsis [list all the child nodes at the current node] |
---|
222 | |
---|
223 | CommandArguments [\[-h\] \[-R\]] |
---|
224 | |
---|
225 | CommandDescription [Lists all the child nodes at the current node.<p> |
---|
226 | Command options:<p> |
---|
227 | |
---|
228 | <dl> |
---|
229 | |
---|
230 | <dt> -h |
---|
231 | <dd> Print the command usage.<p> |
---|
232 | |
---|
233 | <dt> -R |
---|
234 | <dd> Call ls recursively all the way down to leaves. |
---|
235 | </dl>] |
---|
236 | |
---|
237 | SeeAlso [] |
---|
238 | |
---|
239 | ******************************************************************************/ |
---|
240 | static int |
---|
241 | CommandLs( |
---|
242 | Hrc_Manager_t **hmgr, |
---|
243 | int argc, |
---|
244 | char **argv) |
---|
245 | { |
---|
246 | int recursiveFlag = 0; |
---|
247 | int c; |
---|
248 | Hrc_Node_t *currentNode; |
---|
249 | |
---|
250 | util_getopt_reset(); |
---|
251 | while ((c = util_getopt(argc, argv, "hR")) != EOF) { |
---|
252 | switch(c){ |
---|
253 | case 'h': |
---|
254 | goto usage; |
---|
255 | case 'R': |
---|
256 | recursiveFlag = 1; |
---|
257 | break; |
---|
258 | default: |
---|
259 | goto usage; |
---|
260 | } |
---|
261 | } |
---|
262 | /* if there are some arguments for ls */ |
---|
263 | if (argc != util_optind){ |
---|
264 | goto usage; |
---|
265 | } |
---|
266 | |
---|
267 | currentNode = Hrc_ManagerReadCurrentNode(*hmgr); |
---|
268 | if (currentNode == NIL(Hrc_Node_t)){ |
---|
269 | (void)fprintf(vis_stdout,"No file has been read in.\n"); |
---|
270 | return 1; |
---|
271 | } |
---|
272 | NodeListChildren(currentNode, recursiveFlag, 0); |
---|
273 | return 0; |
---|
274 | |
---|
275 | usage: |
---|
276 | (void)fprintf(vis_stderr,"usage: ls [-h] [-R]\n"); |
---|
277 | (void) fprintf(vis_stderr, " -h \t\tprint the command usage\n"); |
---|
278 | (void) fprintf(vis_stderr, " -R \t\tprint recursive tree\n"); |
---|
279 | |
---|
280 | return 1; |
---|
281 | } |
---|
282 | |
---|
283 | /**Function******************************************************************** |
---|
284 | |
---|
285 | Synopsis [The top-level routine for pwd.] |
---|
286 | |
---|
287 | SideEffects [] |
---|
288 | |
---|
289 | CommandName [pwd] |
---|
290 | |
---|
291 | CommandSynopsis [print out the full path of the current node |
---|
292 | from the root node] |
---|
293 | |
---|
294 | CommandArguments [ \[-h\] ] |
---|
295 | |
---|
296 | CommandDescription [Prints out the full path of the current node from |
---|
297 | the root node.<p> |
---|
298 | Command options:<p> |
---|
299 | |
---|
300 | <dl> |
---|
301 | |
---|
302 | <dt> -h |
---|
303 | <dd> Print the command usage. |
---|
304 | |
---|
305 | </dl> |
---|
306 | ] |
---|
307 | |
---|
308 | SeeAlso [] |
---|
309 | |
---|
310 | ******************************************************************************/ |
---|
311 | static int |
---|
312 | CommandPwd( |
---|
313 | Hrc_Manager_t **hmgr, |
---|
314 | int argc, |
---|
315 | char **argv) |
---|
316 | { |
---|
317 | Hrc_Node_t *currentNode; |
---|
318 | Hrc_Node_t *rootNode; |
---|
319 | char *separator, *hierarchicalName; |
---|
320 | int c; |
---|
321 | |
---|
322 | util_getopt_reset(); |
---|
323 | while ((c = util_getopt(argc, argv, "h")) != EOF) { |
---|
324 | switch(c){ |
---|
325 | case 'h': |
---|
326 | goto usage; |
---|
327 | default: |
---|
328 | goto usage; |
---|
329 | } |
---|
330 | } |
---|
331 | if (argc != 1){ |
---|
332 | goto usage; |
---|
333 | } |
---|
334 | |
---|
335 | currentNode = Hrc_ManagerReadCurrentNode(*hmgr); |
---|
336 | if (currentNode == NIL(Hrc_Node_t)){ |
---|
337 | (void)fprintf(vis_stdout,"No file has been read in.\n"); |
---|
338 | return 1; |
---|
339 | } |
---|
340 | rootNode = Hrc_ManagerReadRootNode(*hmgr); |
---|
341 | separator = (char *) ((rootNode == currentNode) ? "" : "."); |
---|
342 | hierarchicalName = Hrc_NodeFindHierarchicalName(currentNode, FALSE); |
---|
343 | (void)fprintf(vis_stdout,"%s%s%s\n", Hrc_NodeReadInstanceName(rootNode), |
---|
344 | separator, hierarchicalName); |
---|
345 | FREE(hierarchicalName); |
---|
346 | return 0; |
---|
347 | |
---|
348 | usage: |
---|
349 | (void)fprintf(vis_stderr,"usage: pwd [-h]\n"); |
---|
350 | (void) fprintf(vis_stderr, " -h \t\tprint the command usage\n"); |
---|
351 | return 1; |
---|
352 | } |
---|
353 | |
---|
354 | /**Function******************************************************************** |
---|
355 | |
---|
356 | Synopsis [The core routine for the command ls.] |
---|
357 | |
---|
358 | Description [The core routine for the command ls. If the second argument |
---|
359 | is set to 1, it calls the ls routine recursively all the way down to leaves.] |
---|
360 | |
---|
361 | SideEffects [] |
---|
362 | |
---|
363 | SeeAlso [] |
---|
364 | |
---|
365 | ******************************************************************************/ |
---|
366 | static void |
---|
367 | NodeListChildren( |
---|
368 | Hrc_Node_t *hnode, |
---|
369 | boolean recursiveFlag, |
---|
370 | int depth) |
---|
371 | { |
---|
372 | st_generator *gen; |
---|
373 | char *childName; |
---|
374 | Hrc_Node_t *child; |
---|
375 | int newDepth, i; |
---|
376 | array_t *tmpArray; |
---|
377 | |
---|
378 | newDepth = depth + 1; |
---|
379 | tmpArray = array_alloc(char *,0); |
---|
380 | Hrc_NodeForEachChild(hnode,gen,childName,child){ |
---|
381 | array_insert_last(char *,tmpArray,childName); |
---|
382 | } |
---|
383 | array_sort(tmpArray,_HrcStringCmp); |
---|
384 | for (i=0; i < array_n(tmpArray); i++){ |
---|
385 | PrintSpace(depth); |
---|
386 | childName = array_fetch(char *,tmpArray,i); |
---|
387 | (void)fprintf(vis_stdout,"%s\n",childName); |
---|
388 | if (recursiveFlag == 1){ |
---|
389 | NodeListChildren(Hrc_NodeFindChildByName(hnode,childName),recursiveFlag,newDepth); |
---|
390 | } |
---|
391 | } |
---|
392 | array_free(tmpArray); |
---|
393 | } |
---|
394 | |
---|
395 | |
---|
396 | /**Function******************************************************************** |
---|
397 | |
---|
398 | Synopsis [Prints out spaces.] |
---|
399 | |
---|
400 | SideEffects [] |
---|
401 | |
---|
402 | SeeAlso [] |
---|
403 | |
---|
404 | ******************************************************************************/ |
---|
405 | static void |
---|
406 | PrintSpace(int depth) |
---|
407 | { |
---|
408 | int i; |
---|
409 | for (i=0; i < depth; i++){ |
---|
410 | (void)fprintf(vis_stdout," "); |
---|
411 | } |
---|
412 | } |
---|
413 | |
---|
414 | /**Function******************************************************************** |
---|
415 | |
---|
416 | Synopsis [This function the statistics of a model.] |
---|
417 | |
---|
418 | SideEffects [] |
---|
419 | |
---|
420 | CommandName [print_models] |
---|
421 | |
---|
422 | CommandSynopsis [list all the models and their statistics] |
---|
423 | |
---|
424 | CommandArguments [ \[-h\] ] |
---|
425 | |
---|
426 | CommandDescription [Lists all the models and prints information about |
---|
427 | the number of variables, tables, latches etc. in them.<p> |
---|
428 | Command options:<p> |
---|
429 | |
---|
430 | <dl> |
---|
431 | |
---|
432 | <dt> -h |
---|
433 | <dd> Print the command usage. |
---|
434 | |
---|
435 | </dl> |
---|
436 | ] |
---|
437 | |
---|
438 | SeeAlso [] |
---|
439 | |
---|
440 | ******************************************************************************/ |
---|
441 | static int |
---|
442 | CommandPrintModels( |
---|
443 | Hrc_Manager_t **hmgr, |
---|
444 | int argc, |
---|
445 | char **argv) |
---|
446 | { |
---|
447 | st_generator *gen; |
---|
448 | char *name; |
---|
449 | Hrc_Model_t *model; |
---|
450 | Hrc_Node_t *node; |
---|
451 | int c; |
---|
452 | |
---|
453 | util_getopt_reset(); |
---|
454 | while ((c = util_getopt(argc, argv, "h")) != EOF) { |
---|
455 | switch(c){ |
---|
456 | case 'h': |
---|
457 | goto usage; |
---|
458 | default: |
---|
459 | goto usage; |
---|
460 | } |
---|
461 | } |
---|
462 | if(argc != 1) { |
---|
463 | goto usage; |
---|
464 | } |
---|
465 | |
---|
466 | node = Hrc_ManagerReadCurrentNode(*hmgr); |
---|
467 | if (node == NIL(Hrc_Node_t)){ |
---|
468 | (void)fprintf(vis_stderr,"No file has been read in.\n"); |
---|
469 | return 1; |
---|
470 | } |
---|
471 | |
---|
472 | Hrc_ManagerForEachModel(*hmgr, gen, name, model) { |
---|
473 | PrintNodeStats(Hrc_ModelReadMasterNode(model), FALSE); |
---|
474 | (void) fprintf(vis_stdout, "subckts = %d\n", |
---|
475 | st_count(Hrc_ModelReadSubcktTable(model))); |
---|
476 | } |
---|
477 | return 0; |
---|
478 | |
---|
479 | usage: |
---|
480 | (void) fprintf(vis_stderr, "usage: print_models [-h]\n"); |
---|
481 | (void) fprintf(vis_stderr, " -h \t\tprint the command usage\n"); |
---|
482 | return 1; |
---|
483 | } |
---|
484 | |
---|
485 | /**Function******************************************************************** |
---|
486 | |
---|
487 | Synopsis [This function prints the statistics of the hierarchy.] |
---|
488 | |
---|
489 | SideEffects [] |
---|
490 | |
---|
491 | CommandName [print_hierarchy_stats] |
---|
492 | |
---|
493 | CommandSynopsis [print the statistics of the current node] |
---|
494 | |
---|
495 | CommandArguments [ \[-h\] \[-R\] ] |
---|
496 | |
---|
497 | CommandDescription [Prints the statistics of the current node. Note that |
---|
498 | it is not necessary to invoke flatten_hierarchy first to create a network.<p> |
---|
499 | Command options:<p> |
---|
500 | <dl> |
---|
501 | |
---|
502 | <dt> -h |
---|
503 | <dd> Print the command usage <p> |
---|
504 | |
---|
505 | <dt> -R |
---|
506 | <dd> Print statistics for nodes recursively all the way down to leaves. |
---|
507 | |
---|
508 | </dl> |
---|
509 | ] |
---|
510 | |
---|
511 | SeeAlso [] |
---|
512 | |
---|
513 | ******************************************************************************/ |
---|
514 | static int |
---|
515 | CommandPrintHierarchyStats( |
---|
516 | Hrc_Manager_t **hmgr, |
---|
517 | int argc, |
---|
518 | char **argv) |
---|
519 | { |
---|
520 | int c; |
---|
521 | int recursiveFlag = 0; |
---|
522 | Hrc_Node_t *node; |
---|
523 | |
---|
524 | util_getopt_reset(); |
---|
525 | while ((c = util_getopt(argc, argv, "hR")) != EOF) { |
---|
526 | switch(c){ |
---|
527 | case 'h': |
---|
528 | goto usage; |
---|
529 | case 'R': |
---|
530 | recursiveFlag = 1; |
---|
531 | break; |
---|
532 | default: |
---|
533 | goto usage; |
---|
534 | } |
---|
535 | } |
---|
536 | /* if there are some arguments left */ |
---|
537 | if (argc != util_optind){ |
---|
538 | goto usage; |
---|
539 | } |
---|
540 | |
---|
541 | node = Hrc_ManagerReadCurrentNode(*hmgr); |
---|
542 | if (node == NIL(Hrc_Node_t)){ |
---|
543 | (void)fprintf(vis_stderr,"No file has been read in.\n"); |
---|
544 | return 1; |
---|
545 | } |
---|
546 | |
---|
547 | if(recursiveFlag) { |
---|
548 | PrintNodeStatsRecursively(node); |
---|
549 | } |
---|
550 | else { |
---|
551 | PrintNodeStats(node, TRUE); |
---|
552 | } |
---|
553 | return 0; |
---|
554 | usage: |
---|
555 | (void) fprintf(vis_stderr,"usage: print_hierarchy_stats [-h][-R]\n"); |
---|
556 | (void) fprintf(vis_stderr, " -h \t\tprint the command usage\n"); |
---|
557 | (void) fprintf(vis_stderr, " -R \t\tprint recursive tree\n"); |
---|
558 | return 1; |
---|
559 | } |
---|
560 | |
---|
561 | /**Function******************************************************************** |
---|
562 | |
---|
563 | Synopsis [This function prints the statistics of a node.] |
---|
564 | |
---|
565 | SideEffects [] |
---|
566 | |
---|
567 | SeeAlso [] |
---|
568 | |
---|
569 | ******************************************************************************/ |
---|
570 | static void |
---|
571 | PrintNodeStats( |
---|
572 | Hrc_Node_t *node, |
---|
573 | boolean isHnode) |
---|
574 | { |
---|
575 | (void) fprintf(vis_stdout, "Model name = %s", Hrc_NodeReadModelName(node)); |
---|
576 | if(isHnode) { |
---|
577 | (void) fprintf(vis_stdout, ", Instance name = %s\n", |
---|
578 | Hrc_NodeReadInstanceName(node)); |
---|
579 | } |
---|
580 | else { |
---|
581 | (void) fprintf(vis_stdout, "\n"); |
---|
582 | } |
---|
583 | (void) fprintf(vis_stdout, "inputs = %d,", Hrc_NodeReadNumFormalInputs(node)); |
---|
584 | (void) fprintf(vis_stdout, " outputs = %d,", Hrc_NodeReadNumFormalOutputs(node)); |
---|
585 | (void) fprintf(vis_stdout, " variables = %d,", Hrc_NodeReadNumVariables(node)); |
---|
586 | (void) fprintf(vis_stdout, " tables = %d,", Hrc_NodeReadNumTables(node)); |
---|
587 | (void) fprintf(vis_stdout, " latches = %d", Hrc_NodeReadNumLatches(node)); |
---|
588 | if(isHnode) { |
---|
589 | (void) fprintf(vis_stdout, ", children = %d\n", Hrc_NodeReadNumChildren(node)); |
---|
590 | } |
---|
591 | else { |
---|
592 | (void) fprintf(vis_stdout, "\n"); |
---|
593 | } |
---|
594 | } |
---|
595 | |
---|
596 | /**Function******************************************************************** |
---|
597 | |
---|
598 | Synopsis [This function prints the statistics of each node in the |
---|
599 | subtree rooted at node. ] |
---|
600 | |
---|
601 | SideEffects [] |
---|
602 | |
---|
603 | SeeAlso [] |
---|
604 | |
---|
605 | ******************************************************************************/ |
---|
606 | static void |
---|
607 | PrintNodeStatsRecursively( |
---|
608 | Hrc_Node_t *node) |
---|
609 | { |
---|
610 | Hrc_Node_t *childNode; |
---|
611 | st_generator *gen; |
---|
612 | char *name; |
---|
613 | |
---|
614 | PrintNodeStats(node, TRUE); |
---|
615 | Hrc_NodeForEachChild(node, gen, name, childNode) { |
---|
616 | PrintNodeStatsRecursively(childNode); |
---|
617 | } |
---|
618 | } |
---|
619 | |
---|
620 | /**Function******************************************************************** |
---|
621 | |
---|
622 | Synopsis [This function prints the names of inputs/outputs in |
---|
623 | the current node.] |
---|
624 | |
---|
625 | SideEffects [] |
---|
626 | |
---|
627 | CommandName [print_io] |
---|
628 | |
---|
629 | CommandSynopsis [print the names of inputs/outputs in the current node] |
---|
630 | |
---|
631 | CommandArguments [ \[-h\] ] |
---|
632 | |
---|
633 | CommandDescription [Prints the names of inputs/outputs in the current node.<p> |
---|
634 | Command options:<p> |
---|
635 | <dl> |
---|
636 | <dt> -h |
---|
637 | <dd> Print the command usage. |
---|
638 | </dl> |
---|
639 | ] |
---|
640 | |
---|
641 | SeeAlso [] |
---|
642 | |
---|
643 | ******************************************************************************/ |
---|
644 | static int |
---|
645 | CommandPrintIo( |
---|
646 | Hrc_Manager_t **hmgr, |
---|
647 | int argc, |
---|
648 | char **argv) |
---|
649 | { |
---|
650 | int c, i; |
---|
651 | Hrc_Node_t *node; |
---|
652 | Var_Variable_t *var; |
---|
653 | array_t *tmpArray; |
---|
654 | |
---|
655 | util_getopt_reset(); |
---|
656 | while ((c = util_getopt(argc, argv, "h")) != EOF) { |
---|
657 | switch(c){ |
---|
658 | case 'h': |
---|
659 | goto usage; |
---|
660 | default: |
---|
661 | goto usage; |
---|
662 | } |
---|
663 | } |
---|
664 | /* if there are some arguments left */ |
---|
665 | if (argc != util_optind){ |
---|
666 | goto usage; |
---|
667 | } |
---|
668 | node = Hrc_ManagerReadCurrentNode(*hmgr); |
---|
669 | if (node == NIL(Hrc_Node_t)){ |
---|
670 | (void)fprintf(vis_stderr,"No file has been read in.\n"); |
---|
671 | return 1; |
---|
672 | } |
---|
673 | |
---|
674 | if (Hrc_NodeReadNumFormalInputs(node) == 0){ |
---|
675 | fprintf(vis_stdout,"No inputs\n"); |
---|
676 | } |
---|
677 | else { |
---|
678 | tmpArray = array_alloc(char *,0); |
---|
679 | Hrc_NodeForEachFormalInput(node,i,var){ |
---|
680 | array_insert_last(char *,tmpArray,Var_VariableReadName(var)); |
---|
681 | } |
---|
682 | array_sort(tmpArray,_HrcStringCmp); |
---|
683 | fprintf(vis_stdout,"inputs:"); |
---|
684 | for (i=0; i < array_n(tmpArray); i++){ |
---|
685 | fprintf(vis_stdout," %s",array_fetch(char *,tmpArray,i)); |
---|
686 | } |
---|
687 | fprintf(vis_stdout,"\n"); |
---|
688 | array_free(tmpArray); |
---|
689 | } |
---|
690 | |
---|
691 | if (Hrc_NodeReadNumFormalOutputs(node) == 0){ |
---|
692 | fprintf(vis_stdout,"No outputs\n"); |
---|
693 | } |
---|
694 | else { |
---|
695 | tmpArray = array_alloc(char *,0); |
---|
696 | Hrc_NodeForEachFormalOutput(node,i,var){ |
---|
697 | array_insert_last(char *,tmpArray,Var_VariableReadName(var)); |
---|
698 | } |
---|
699 | array_sort(tmpArray,_HrcStringCmp); |
---|
700 | fprintf(vis_stdout,"outputs:"); |
---|
701 | for (i=0; i < array_n(tmpArray); i++){ |
---|
702 | fprintf(vis_stdout," %s",array_fetch(char *,tmpArray,i)); |
---|
703 | } |
---|
704 | fprintf(vis_stdout,"\n"); |
---|
705 | array_free(tmpArray); |
---|
706 | } |
---|
707 | return 0; |
---|
708 | |
---|
709 | usage: |
---|
710 | (void) fprintf(vis_stderr,"usage: print_io [-h]\n"); |
---|
711 | (void) fprintf(vis_stderr, " -h \t\tprint the command usage\n"); |
---|
712 | return 1; |
---|
713 | } |
---|
714 | |
---|
715 | /**Function******************************************************************** |
---|
716 | |
---|
717 | Synopsis [This function prints the names of latches in |
---|
718 | the current node.] |
---|
719 | |
---|
720 | SideEffects [] |
---|
721 | |
---|
722 | CommandName [print_latches] |
---|
723 | |
---|
724 | CommandSynopsis [print the names of latches in the current node] |
---|
725 | |
---|
726 | CommandArguments [ \[-h\] ] |
---|
727 | |
---|
728 | CommandDescription [Prints the names of latches in the current node.<p> |
---|
729 | Command options:<p> |
---|
730 | <dl> |
---|
731 | <dt> -h |
---|
732 | <dd> Print the command usage. |
---|
733 | </dl> |
---|
734 | ] |
---|
735 | |
---|
736 | SeeAlso [] |
---|
737 | |
---|
738 | ******************************************************************************/ |
---|
739 | static int |
---|
740 | CommandPrintLatches( |
---|
741 | Hrc_Manager_t **hmgr, |
---|
742 | int argc, |
---|
743 | char **argv) |
---|
744 | { |
---|
745 | int c, i; |
---|
746 | Hrc_Node_t *node; |
---|
747 | st_generator *gen; |
---|
748 | char *latchName; |
---|
749 | Hrc_Latch_t *latch; |
---|
750 | array_t *tmpArray; |
---|
751 | |
---|
752 | util_getopt_reset(); |
---|
753 | while ((c = util_getopt(argc, argv, "h")) != EOF) { |
---|
754 | switch(c){ |
---|
755 | case 'h': |
---|
756 | goto usage; |
---|
757 | default: |
---|
758 | goto usage; |
---|
759 | } |
---|
760 | } |
---|
761 | /* if there are some arguments left */ |
---|
762 | if (argc != util_optind){ |
---|
763 | goto usage; |
---|
764 | } |
---|
765 | node = Hrc_ManagerReadCurrentNode(*hmgr); |
---|
766 | if (node == NIL(Hrc_Node_t)){ |
---|
767 | (void)fprintf(vis_stderr,"No file has been read in.\n"); |
---|
768 | return 1; |
---|
769 | } |
---|
770 | |
---|
771 | if (Hrc_NodeReadNumLatches(node) == 0){ |
---|
772 | fprintf(vis_stdout,"No latches\n"); |
---|
773 | } |
---|
774 | else { |
---|
775 | tmpArray = array_alloc(char *,0); |
---|
776 | Hrc_NodeForEachLatch(node,gen,latchName,latch){ |
---|
777 | array_insert_last(char *,tmpArray,latchName); |
---|
778 | } |
---|
779 | array_sort(tmpArray,_HrcStringCmp); |
---|
780 | for (i=0; i < array_n(tmpArray); i++){ |
---|
781 | fprintf(vis_stdout,"%s ",array_fetch(char *,tmpArray,i)); |
---|
782 | } |
---|
783 | fprintf(vis_stdout,"\n"); |
---|
784 | array_free(tmpArray); |
---|
785 | } |
---|
786 | return 0; |
---|
787 | |
---|
788 | usage: |
---|
789 | (void) fprintf(vis_stderr,"usage: print_latches [-h]\n"); |
---|
790 | (void) fprintf(vis_stderr, " -h \t\tprint the command usage\n"); |
---|
791 | return 1; |
---|
792 | } |
---|
793 | |
---|
794 | /**Function******************************************************************** |
---|
795 | |
---|
796 | Synopsis [This function is used for string comparison in array_sort.] |
---|
797 | |
---|
798 | Description [This function is used for string comparison in array_sort.] |
---|
799 | |
---|
800 | SideEffects [] |
---|
801 | |
---|
802 | SeeAlso [] |
---|
803 | |
---|
804 | ******************************************************************************/ |
---|
805 | static int |
---|
806 | _HrcStringCmp( |
---|
807 | const void * s1, |
---|
808 | const void * s2) |
---|
809 | { |
---|
810 | return(strcmp(*(char **)s1, *(char **)s2)); |
---|
811 | } |
---|
812 | |
---|