1 | /**CFile*********************************************************************** |
---|
2 | |
---|
3 | FileName [hrcInOut.c] |
---|
4 | |
---|
5 | PackageName [hrc] |
---|
6 | |
---|
7 | Synopsis [This file provides the functions for accessing the fields |
---|
8 | of the data structures of the hrc package.] |
---|
9 | |
---|
10 | SeeAlso [] |
---|
11 | |
---|
12 | Author [Shaz Qadeer] |
---|
13 | |
---|
14 | Copyright [Copyright (c) 1994-1996 The Regents of the Univ. of California. |
---|
15 | All rights reserved. |
---|
16 | |
---|
17 | Permission is hereby granted, without written agreement and without license |
---|
18 | or royalty fees, to use, copy, modify, and distribute this software and its |
---|
19 | documentation for any purpose, provided that the above copyright notice and |
---|
20 | the following two paragraphs appear in all copies of this software. |
---|
21 | |
---|
22 | IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR |
---|
23 | DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT |
---|
24 | OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF |
---|
25 | CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
26 | |
---|
27 | THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, |
---|
28 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
---|
29 | FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN |
---|
30 | "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE |
---|
31 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.] |
---|
32 | |
---|
33 | ******************************************************************************/ |
---|
34 | |
---|
35 | #include "hrcInt.h" |
---|
36 | #include "io.h" |
---|
37 | |
---|
38 | static char rcsid[] UNUSED = "$Id: hrcInOut.c,v 1.6 2005/04/28 14:16:09 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 | |
---|
72 | /**AutomaticEnd***************************************************************/ |
---|
73 | |
---|
74 | |
---|
75 | /*---------------------------------------------------------------------------*/ |
---|
76 | /* Definition of exported functions */ |
---|
77 | /*---------------------------------------------------------------------------*/ |
---|
78 | /**Function******************************************************************** |
---|
79 | |
---|
80 | Synopsis [Associates application specific data with a node.] |
---|
81 | |
---|
82 | Description [Adds the key/data pair to the node's applInfoTable. Key may |
---|
83 | be an arbitrary string; to avoid possible conflicts with other applications, |
---|
84 | key should be prefixed with the application's package name, for example |
---|
85 | "Pkg_HrcNodeApplKey". A copy is made of the string key before it is |
---|
86 | inserted into applInfoTable. The contents of data are arbitrary; the |
---|
87 | hierarchy package does not interpret the data. The freeFn is called on data |
---|
88 | when a node is freed, or when Hrc_NodeFreeApplInfo() is called with the same |
---|
89 | value of key. The freeFn takes (void *) as its only argument, and returns |
---|
90 | void. The changeFn is called when a subtree in the hierarchy rooted at |
---|
91 | oldNode is replaced by another tree rooted at newNode. It takes three |
---|
92 | arguments - oldNode, newNode and &(applInfo->data), and returns void. Note |
---|
93 | the order of the three arguments. <p> |
---|
94 | |
---|
95 | If this function is called with a value of key that already exists in the |
---|
96 | applInfoTable then the data for the previous entry is freed using the |
---|
97 | freeFn, its fields are overwritten by the new ones passed as arguments to |
---|
98 | the function and TRUE is returned. Otherwise, FALSE is returned. |
---|
99 | |
---|
100 | <p> |
---|
101 | WARNING: This function does not make a copy of data before inserting it |
---|
102 | into the table. By calling this function, the application is surrendering |
---|
103 | responsibility to the hierarchy to free the data. Once this function is |
---|
104 | called on data, the data should be freed only by calling |
---|
105 | Hrc_NodeFreeApplInfo(), Hrc_ManagerFree() or Hrc_TreeReplace(). In other |
---|
106 | words, it is an error for the application to explicitly free the data |
---|
107 | without using one of these functions. </p>] |
---|
108 | |
---|
109 | SideEffects [] |
---|
110 | |
---|
111 | SeeAlso [Hrc_NodeFreeApplInfo() Hrc_NodeReadApplInfo()] |
---|
112 | |
---|
113 | ******************************************************************************/ |
---|
114 | boolean |
---|
115 | Hrc_NodeAddApplInfo( |
---|
116 | Hrc_Node_t *node, |
---|
117 | char * key, |
---|
118 | Hrc_ApplInfoFreeFn freeFn, |
---|
119 | Hrc_ApplInfoChangeFn changeFn, |
---|
120 | void * data) |
---|
121 | { |
---|
122 | ApplInfo_t *applInfo; |
---|
123 | boolean status; |
---|
124 | |
---|
125 | if (st_lookup(node->applInfoTable, key, &applInfo)) { |
---|
126 | (*applInfo->freeFn)(applInfo->data); |
---|
127 | status = TRUE; |
---|
128 | } |
---|
129 | else { |
---|
130 | char *keyCopy = util_strsav(key); |
---|
131 | |
---|
132 | applInfo = ALLOC(ApplInfo_t, 1); |
---|
133 | st_insert(node->applInfoTable, keyCopy, applInfo); |
---|
134 | status = FALSE; |
---|
135 | } |
---|
136 | applInfo->freeFn = freeFn; |
---|
137 | applInfo->changeFn = changeFn; |
---|
138 | applInfo->data = data; |
---|
139 | return status; |
---|
140 | } |
---|
141 | |
---|
142 | |
---|
143 | /**Function******************************************************************** |
---|
144 | |
---|
145 | Synopsis [Returns data corresponding to key if it exists, else returns NULL.] |
---|
146 | |
---|
147 | Description [If data corresponding to key is associated with the node, then |
---|
148 | returns a pointer to data (as void *). Otherwise, returns NULL.] |
---|
149 | |
---|
150 | SideEffects [] |
---|
151 | |
---|
152 | SeeAlso [Hrc_NodeAddApplInfo() Hrc_NodeFreeApplInfo()] |
---|
153 | |
---|
154 | ******************************************************************************/ |
---|
155 | void * |
---|
156 | Hrc_NodeReadApplInfo( |
---|
157 | Hrc_Node_t *node, |
---|
158 | char * key) |
---|
159 | { |
---|
160 | int status; |
---|
161 | ApplInfo_t *applInfo; |
---|
162 | |
---|
163 | status = st_lookup(node->applInfoTable, key, &applInfo); |
---|
164 | if (status == 1) { |
---|
165 | return (applInfo->data); |
---|
166 | } |
---|
167 | else { |
---|
168 | return (NIL(void)); |
---|
169 | } |
---|
170 | } |
---|
171 | |
---|
172 | |
---|
173 | /**Function******************************************************************** |
---|
174 | |
---|
175 | Synopsis [Frees application-specific data from a node.] |
---|
176 | |
---|
177 | Description [If data corresponding to key exists in the node, then frees |
---|
178 | the data using the associated free function, removes the key/data pair from |
---|
179 | the network's applInfoTable, and returns TRUE. If key does not exist, then |
---|
180 | the function does nothing and returns FALSE. |
---|
181 | <p> |
---|
182 | WARNING: This function should be called only if a corresponding call to |
---|
183 | Hrc_NodeAddApplInfo() has already been made.</p>] |
---|
184 | |
---|
185 | SideEffects [] |
---|
186 | |
---|
187 | SeeAlso [Hrc_NodeAddApplInfo() Hrc_NodeReadApplInfo()] |
---|
188 | |
---|
189 | ******************************************************************************/ |
---|
190 | boolean |
---|
191 | Hrc_NodeFreeApplInfo( |
---|
192 | Hrc_Node_t *node, |
---|
193 | char * key) |
---|
194 | { |
---|
195 | int status; |
---|
196 | ApplInfo_t *applInfo; |
---|
197 | |
---|
198 | status = st_lookup(node->applInfoTable, key, &applInfo); |
---|
199 | |
---|
200 | if (status == 1) { |
---|
201 | st_delete(node->applInfoTable, &key, &applInfo); |
---|
202 | (*applInfo->freeFn)(applInfo->data); |
---|
203 | FREE(key); /* frees the string contained in the table */ |
---|
204 | FREE(applInfo); |
---|
205 | } |
---|
206 | |
---|
207 | return ((status) ? TRUE : FALSE); |
---|
208 | } |
---|
209 | |
---|
210 | /**Function******************************************************************** |
---|
211 | |
---|
212 | Synopsis [Writes out a model definition.] |
---|
213 | |
---|
214 | Description [Writes out a model definition. The second argument is a pointer |
---|
215 | to a model to be written out. If isRootModel is TRUE, the function prints |
---|
216 | out .root to specify that the model is a root model. The last argument |
---|
217 | specifies the instance name of the root model and is used only if isRootModel |
---|
218 | is set to TRUE.] |
---|
219 | |
---|
220 | SideEffects [] |
---|
221 | |
---|
222 | SeeAlso [] |
---|
223 | |
---|
224 | ******************************************************************************/ |
---|
225 | void |
---|
226 | Hrc_ModelWriteBlifMv( |
---|
227 | FILE *fp, |
---|
228 | Hrc_Model_t *model, |
---|
229 | boolean isRootModel, |
---|
230 | char *rootInstanceName) |
---|
231 | { |
---|
232 | Hrc_Node_t *hnode, *subcktHnode; |
---|
233 | Hrc_Model_t *subcktModel; |
---|
234 | int i, is_enum, range; |
---|
235 | Var_Variable_t *var, *actualVar; |
---|
236 | Hrc_Latch_t *latch; |
---|
237 | Hrc_Subckt_t *subckt; |
---|
238 | Tbl_Table_t *table; |
---|
239 | char *varName, *latchName, *instanceName; |
---|
240 | st_generator *gen; |
---|
241 | array_t *subcktActualInputVars, *subcktActualOutputVars; |
---|
242 | |
---|
243 | (void)fprintf(fp,".model %s\n",Hrc_ModelReadName(model)); |
---|
244 | if (isRootModel){ |
---|
245 | (void)fprintf(fp,".root %s\n",rootInstanceName); |
---|
246 | } |
---|
247 | hnode = Hrc_ModelReadMasterNode(model); |
---|
248 | |
---|
249 | /* .inputs */ |
---|
250 | if (Hrc_NodeReadNumFormalInputs(hnode) != 0){ |
---|
251 | (void)fprintf(fp,".inputs "); |
---|
252 | Hrc_NodeForEachFormalInput(hnode,i,var){ |
---|
253 | (void)fprintf(fp,"%s ",Var_VariableReadName(var)); |
---|
254 | } |
---|
255 | (void)fprintf(fp,"\n"); |
---|
256 | } |
---|
257 | |
---|
258 | /* .outputs */ |
---|
259 | if (Hrc_NodeReadNumFormalOutputs(hnode) != 0){ |
---|
260 | (void)fprintf(fp,".outputs "); |
---|
261 | Hrc_NodeForEachFormalOutput(hnode,i,var){ |
---|
262 | (void)fprintf(fp,"%s ",Var_VariableReadName(var)); |
---|
263 | } |
---|
264 | (void)fprintf(fp,"\n"); |
---|
265 | } |
---|
266 | |
---|
267 | /* .mv */ |
---|
268 | Hrc_NodeForEachVariable(hnode,gen,varName,var){ |
---|
269 | is_enum = Var_VariableTestIsEnumerative(var); |
---|
270 | range = Var_VariableReadNumValues(var); |
---|
271 | |
---|
272 | if (is_enum == 1){ |
---|
273 | if (range == 2){ |
---|
274 | /* Boolean enumerative variables need no .mv declaration. */ |
---|
275 | continue; |
---|
276 | } |
---|
277 | else { |
---|
278 | (void)fprintf(fp,".mv %s %d\n",Var_VariableReadName(var),range); |
---|
279 | } |
---|
280 | } |
---|
281 | else { |
---|
282 | /* variable var is symbolic */ |
---|
283 | (void)fprintf(fp,".mv %s %d ",Var_VariableReadName(var),range); |
---|
284 | for (i=0; i < range; i++){ |
---|
285 | (void)fprintf(fp,"%s ",Var_VariableReadSymbolicValueFromIndex(var,i)); |
---|
286 | } |
---|
287 | (void)fprintf(fp,"\n"); |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | /* .latches */ |
---|
292 | Hrc_NodeForEachLatch(hnode,gen,latchName,latch){ |
---|
293 | (void)fprintf(fp,".latch %s %s\n", |
---|
294 | Var_VariableReadName(Hrc_LatchReadInput(latch)), |
---|
295 | Var_VariableReadName(Hrc_LatchReadOutput(latch))); |
---|
296 | Tbl_TableWriteBlifMvToFile(Hrc_LatchReadResetTable(latch),1,fp); |
---|
297 | } |
---|
298 | |
---|
299 | /* .subckt */ |
---|
300 | Hrc_ModelForEachSubckt(model,gen,instanceName,subckt){ |
---|
301 | subcktModel = Hrc_SubcktReadModel(subckt); |
---|
302 | subcktHnode = Hrc_ModelReadMasterNode(subcktModel); |
---|
303 | subcktActualInputVars = Hrc_SubcktReadActualInputVars(subckt); |
---|
304 | subcktActualOutputVars = Hrc_SubcktReadActualOutputVars(subckt); |
---|
305 | |
---|
306 | (void)fprintf(fp,".subckt %s %s ", |
---|
307 | Hrc_ModelReadName(subcktModel), Hrc_SubcktReadInstanceName(subckt)); |
---|
308 | Hrc_NodeForEachFormalInput(subcktHnode,i,var){ |
---|
309 | actualVar = array_fetch(Var_Variable_t *,subcktActualInputVars,i); |
---|
310 | (void)fprintf(fp,"%s = %s ",Var_VariableReadName(var),Var_VariableReadName(actualVar)); |
---|
311 | } |
---|
312 | Hrc_NodeForEachFormalOutput(subcktHnode,i,var){ |
---|
313 | actualVar = array_fetch(Var_Variable_t *,subcktActualOutputVars,i); |
---|
314 | (void)fprintf(fp,"%s = %s ",Var_VariableReadName(var),Var_VariableReadName(actualVar)); |
---|
315 | } |
---|
316 | (void)fprintf(fp,"\n"); |
---|
317 | } |
---|
318 | |
---|
319 | /* .names */ |
---|
320 | Hrc_NodeForEachNameTable(hnode,i,table){ |
---|
321 | Tbl_TableWriteBlifMvToFile(table,0,fp); |
---|
322 | } |
---|
323 | |
---|
324 | (void)fprintf(fp,".end\n"); |
---|
325 | } |
---|
326 | |
---|
327 | |
---|
328 | /**Function******************************************************************** |
---|
329 | |
---|
330 | Synopsis [Writes out a model definition in NuSMV format.] |
---|
331 | |
---|
332 | Description [Writes out a model definition. The second argument is a |
---|
333 | pointer to a model to be written out. If isRootModel is TRUE, the |
---|
334 | function prints out .root to specify that the model is a root |
---|
335 | model. The last argument specifies the instance name of the root |
---|
336 | model and is used only if isRootModel is set to TRUE.] |
---|
337 | |
---|
338 | SideEffects [] |
---|
339 | |
---|
340 | SeeAlso [] |
---|
341 | |
---|
342 | ******************************************************************************/ |
---|
343 | void |
---|
344 | Hrc_ModelWriteSmv( |
---|
345 | FILE *fp, |
---|
346 | Hrc_Model_t *model, |
---|
347 | boolean isRootModel, |
---|
348 | char *rootInstanceName) |
---|
349 | { |
---|
350 | Hrc_Node_t *hnode, *subcktHnode; |
---|
351 | Hrc_Model_t *subcktModel; |
---|
352 | int i, is_enum, range; |
---|
353 | Var_Variable_t *var, *actualVar; |
---|
354 | Hrc_Latch_t *latch; |
---|
355 | Hrc_Subckt_t *subckt; |
---|
356 | Tbl_Table_t *table; |
---|
357 | char *varName, *latchName, *instanceName; |
---|
358 | st_generator *gen; |
---|
359 | array_t *subcktActualInputVars, *subcktActualOutputVars; |
---|
360 | |
---|
361 | hnode = Hrc_ModelReadMasterNode(model); |
---|
362 | |
---|
363 | if (isRootModel){ |
---|
364 | (void)fprintf(fp,"\n\nMODULE main --("); |
---|
365 | if (Hrc_NodeReadNumFormalInputs(hnode) != 0){ |
---|
366 | fprintf(stderr, |
---|
367 | "Warning: ignored %d input parameter(s) in the main module (root model)\n", |
---|
368 | Hrc_NodeReadNumFormalInputs(hnode)); |
---|
369 | } |
---|
370 | if (Hrc_NodeReadNumFormalOutputs(hnode) != 0){ |
---|
371 | fprintf(stderr, |
---|
372 | "Warning: ignored %d output parameter(s) in the main module (root model)\n", |
---|
373 | Hrc_NodeReadNumFormalOutputs(hnode)); |
---|
374 | } |
---|
375 | } else { |
---|
376 | (void)fprintf(fp,"\n\nMODULE %s (",Hrc_ModelReadName(model)); |
---|
377 | } |
---|
378 | |
---|
379 | /* Input parameters */ |
---|
380 | if (Hrc_NodeReadNumFormalInputs(hnode) != 0){ |
---|
381 | Hrc_NodeForEachFormalInput(hnode,i,var){ |
---|
382 | Io_SmvPrintVar(fp, var); |
---|
383 | if(i < Hrc_NodeReadNumFormalInputs(hnode)-1 || |
---|
384 | Hrc_NodeReadNumFormalOutputs(hnode) > 0) { |
---|
385 | (void)fprintf(fp,", "); |
---|
386 | } |
---|
387 | } |
---|
388 | } |
---|
389 | /* Output parameters */ |
---|
390 | if (Hrc_NodeReadNumFormalOutputs(hnode) != 0){ |
---|
391 | Hrc_NodeForEachFormalOutput(hnode,i,var){ |
---|
392 | Io_SmvPrintVar(fp, var); |
---|
393 | if(i < Hrc_NodeReadNumFormalOutputs(hnode)-1) { |
---|
394 | (void)fprintf(fp,", "); |
---|
395 | } |
---|
396 | } |
---|
397 | } |
---|
398 | (void)fprintf(fp,")\n"); |
---|
399 | |
---|
400 | /* Variables */ |
---|
401 | Hrc_NodeForEachVariable(hnode,gen,varName,var){ |
---|
402 | if (!isRootModel && (Var_VariableTestIsPI(var) || Var_VariableTestIsPO(var))) { |
---|
403 | fprintf(fp,"-- PI or PO: "); |
---|
404 | } |
---|
405 | |
---|
406 | is_enum = Var_VariableTestIsEnumerative(var); |
---|
407 | range = Var_VariableReadNumValues(var); |
---|
408 | |
---|
409 | (void)fprintf(fp,"VAR "); |
---|
410 | Io_SmvPrintVar(fp, var); |
---|
411 | if (is_enum == 1){ |
---|
412 | if (range == 2){ |
---|
413 | (void)fprintf(fp," : boolean;\n"); |
---|
414 | } |
---|
415 | else { |
---|
416 | (void)fprintf(fp," : 0..%d;\n",range-1); |
---|
417 | } |
---|
418 | } |
---|
419 | else { |
---|
420 | /* variable var is symbolic */ |
---|
421 | (void)fprintf(fp," : {"); |
---|
422 | for (i=0; i < range; i++){ |
---|
423 | (void)fprintf(fp,"%s",Var_VariableReadSymbolicValueFromIndex(var,i)); |
---|
424 | if(i < range-1) |
---|
425 | (void)fprintf(fp, ", "); |
---|
426 | } |
---|
427 | (void)fprintf(fp,"};\n"); |
---|
428 | } |
---|
429 | } |
---|
430 | |
---|
431 | /* Subcircuits */ |
---|
432 | Hrc_ModelForEachSubckt(model,gen,instanceName,subckt){ |
---|
433 | subcktModel = Hrc_SubcktReadModel(subckt); |
---|
434 | subcktHnode = Hrc_ModelReadMasterNode(subcktModel); |
---|
435 | subcktActualInputVars = Hrc_SubcktReadActualInputVars(subckt); |
---|
436 | subcktActualOutputVars = Hrc_SubcktReadActualOutputVars(subckt); |
---|
437 | |
---|
438 | /* Note: mv uses named parameters; we do not check that there are |
---|
439 | enough parameters or that they occur in the correct order. This |
---|
440 | doesn't seem to matter at the moment. */ |
---|
441 | (void)fprintf(fp,"VAR %s : %s(", |
---|
442 | Hrc_SubcktReadInstanceName(subckt), Hrc_ModelReadName(subcktModel)); |
---|
443 | Hrc_NodeForEachFormalInput(subcktHnode,i,var){ |
---|
444 | actualVar = array_fetch(Var_Variable_t *,subcktActualInputVars,i); |
---|
445 | Io_SmvPrintVar(fp, actualVar); |
---|
446 | if(i < Hrc_NodeReadNumFormalInputs(subcktHnode)-1 || |
---|
447 | Hrc_NodeReadNumFormalOutputs(subcktHnode) > 0) { |
---|
448 | (void)fprintf(fp,", "); |
---|
449 | } |
---|
450 | } |
---|
451 | Hrc_NodeForEachFormalOutput(subcktHnode,i,var){ |
---|
452 | actualVar = array_fetch(Var_Variable_t *,subcktActualOutputVars,i); |
---|
453 | Io_SmvPrintVar(fp, actualVar); |
---|
454 | if(i < Hrc_NodeReadNumFormalOutputs(subcktHnode)-1) { |
---|
455 | (void)fprintf(fp,", "); |
---|
456 | } |
---|
457 | } |
---|
458 | (void)fprintf(fp,");\n"); |
---|
459 | } |
---|
460 | |
---|
461 | /* .latches */ |
---|
462 | (void)fprintf(fp,"\nASSIGN\n"); |
---|
463 | Hrc_NodeForEachLatch(hnode,gen,latchName,latch){ |
---|
464 | (void)fprintf(fp,"next("); |
---|
465 | Io_SmvPrintVar(fp, Hrc_LatchReadOutput(latch)); |
---|
466 | (void)fprintf(fp,") := "); |
---|
467 | Io_SmvPrintVar(fp, Hrc_LatchReadInput(latch)); |
---|
468 | (void)fprintf(fp,";\ninit("); |
---|
469 | Io_SmvPrintVar(fp, Hrc_LatchReadOutput(latch)); |
---|
470 | (void)fprintf(fp,") := "); |
---|
471 | Tbl_TableWriteSmvToFile(Hrc_LatchReadResetTable(latch),1,fp); |
---|
472 | (void)fprintf(fp,"\n"); |
---|
473 | } |
---|
474 | |
---|
475 | /* .names */ |
---|
476 | Hrc_NodeForEachNameTable(hnode,i,table){ |
---|
477 | Tbl_TableWriteSmvToFile(table,0,fp); |
---|
478 | } |
---|
479 | |
---|
480 | } |
---|
481 | |
---|
482 | /**Function******************************************************************** |
---|
483 | |
---|
484 | Synopsis [Returns pointer to root node in the hierarchy.] |
---|
485 | |
---|
486 | Description [The function simply accesses the rootNode field of the |
---|
487 | hierarchy manager.] |
---|
488 | |
---|
489 | SideEffects [] |
---|
490 | |
---|
491 | SeeAlso [Hrc_ManagerReadCurrentNode()] |
---|
492 | |
---|
493 | ******************************************************************************/ |
---|
494 | Hrc_Node_t * |
---|
495 | Hrc_ManagerReadRootNode( |
---|
496 | Hrc_Manager_t *manager) |
---|
497 | { |
---|
498 | return manager->rootNode; |
---|
499 | } |
---|
500 | |
---|
501 | /**Function******************************************************************** |
---|
502 | |
---|
503 | Synopsis [Returns pointer to the current node.] |
---|
504 | |
---|
505 | Description [The function simply accesses the currentNode field of the |
---|
506 | hierarchy manager.] |
---|
507 | |
---|
508 | SideEffects [] |
---|
509 | |
---|
510 | SeeAlso [Hrc_ManagerReadRootNode()] |
---|
511 | |
---|
512 | ******************************************************************************/ |
---|
513 | Hrc_Node_t * |
---|
514 | Hrc_ManagerReadCurrentNode( |
---|
515 | Hrc_Manager_t *manager) |
---|
516 | { |
---|
517 | return manager->currentNode; |
---|
518 | } |
---|
519 | |
---|
520 | /**Function******************************************************************** |
---|
521 | |
---|
522 | Synopsis [Returns the hash table of all the models.] |
---|
523 | |
---|
524 | Description [A pointer to the table containing all the models currently |
---|
525 | registered with the manager is returned. This table should |
---|
526 | not be modified in any way.] |
---|
527 | |
---|
528 | SideEffects [] |
---|
529 | |
---|
530 | SeeAlso [] |
---|
531 | |
---|
532 | ******************************************************************************/ |
---|
533 | st_table * |
---|
534 | Hrc_ManagerReadModelTable( |
---|
535 | Hrc_Manager_t *manager) |
---|
536 | { |
---|
537 | return manager->modelTable; |
---|
538 | } |
---|
539 | |
---|
540 | /**Function******************************************************************** |
---|
541 | |
---|
542 | Synopsis [Returns pointer to model corresponding to the given name.] |
---|
543 | |
---|
544 | Description [The function looks up the name in the hash table of models. |
---|
545 | If the name is found, the corresponding model is returned |
---|
546 | otherwise NULL is returned.] |
---|
547 | |
---|
548 | SideEffects [] |
---|
549 | |
---|
550 | SeeAlso [] |
---|
551 | |
---|
552 | ******************************************************************************/ |
---|
553 | Hrc_Model_t * |
---|
554 | Hrc_ManagerFindModelByName( |
---|
555 | Hrc_Manager_t *manager, |
---|
556 | char *modelName) |
---|
557 | { |
---|
558 | Hrc_Model_t *model; |
---|
559 | |
---|
560 | if(st_lookup(manager->modelTable, modelName, &model)) { |
---|
561 | return model; |
---|
562 | } |
---|
563 | else { |
---|
564 | return NIL(Hrc_Model_t); |
---|
565 | } |
---|
566 | } |
---|
567 | |
---|
568 | /**Function******************************************************************** |
---|
569 | |
---|
570 | Synopsis [Returns pointer to the master node of a model.] |
---|
571 | |
---|
572 | SideEffects [] |
---|
573 | |
---|
574 | SeeAlso [] |
---|
575 | |
---|
576 | ******************************************************************************/ |
---|
577 | Hrc_Node_t * |
---|
578 | Hrc_ModelReadMasterNode( |
---|
579 | Hrc_Model_t *model) |
---|
580 | { |
---|
581 | return model->masterNode; |
---|
582 | } |
---|
583 | |
---|
584 | /**Function******************************************************************** |
---|
585 | |
---|
586 | Synopsis [Returns the model name.] |
---|
587 | |
---|
588 | Description [A pointer to model name is returned. Note that this string |
---|
589 | should not be freed by the user.] |
---|
590 | |
---|
591 | SideEffects [] |
---|
592 | |
---|
593 | SeeAlso [] |
---|
594 | |
---|
595 | ******************************************************************************/ |
---|
596 | char * |
---|
597 | Hrc_ModelReadName( |
---|
598 | Hrc_Model_t *model) |
---|
599 | { |
---|
600 | return model->modelName; |
---|
601 | } |
---|
602 | |
---|
603 | /**Function******************************************************************** |
---|
604 | |
---|
605 | Synopsis [Returns the hash table of sub-circuits of the model.] |
---|
606 | |
---|
607 | Description [A pointer to the table containing all the sub-circuits of a |
---|
608 | model is returned. Note that this table should not be modified |
---|
609 | in any way.] |
---|
610 | |
---|
611 | SideEffects [] |
---|
612 | |
---|
613 | SeeAlso [] |
---|
614 | |
---|
615 | ******************************************************************************/ |
---|
616 | st_table * |
---|
617 | Hrc_ModelReadSubcktTable( |
---|
618 | Hrc_Model_t *model) |
---|
619 | { |
---|
620 | return model->subcktTable; |
---|
621 | } |
---|
622 | |
---|
623 | /**Function******************************************************************** |
---|
624 | |
---|
625 | Synopsis [Returns pointer to model of the sub-circuit.] |
---|
626 | |
---|
627 | Description [A pointer to the model whose instantiation created this |
---|
628 | sub-circuit is returned.] |
---|
629 | |
---|
630 | SideEffects [] |
---|
631 | |
---|
632 | SeeAlso [] |
---|
633 | |
---|
634 | ******************************************************************************/ |
---|
635 | Hrc_Model_t * |
---|
636 | Hrc_SubcktReadModel( |
---|
637 | Hrc_Subckt_t *subckt) |
---|
638 | { |
---|
639 | return subckt->model; |
---|
640 | } |
---|
641 | |
---|
642 | /**Function******************************************************************** |
---|
643 | |
---|
644 | Synopsis [Returns pointer to instance name of a sub-circuit.] |
---|
645 | |
---|
646 | Description [A pointer to instance name of a sub-circuit is returned. Note |
---|
647 | that this string should not be freed by the user.] |
---|
648 | |
---|
649 | SideEffects [] |
---|
650 | |
---|
651 | SeeAlso [] |
---|
652 | |
---|
653 | ******************************************************************************/ |
---|
654 | char * |
---|
655 | Hrc_SubcktReadInstanceName( |
---|
656 | Hrc_Subckt_t *subckt) |
---|
657 | { |
---|
658 | return subckt->instanceName; |
---|
659 | } |
---|
660 | |
---|
661 | /**Function******************************************************************** |
---|
662 | |
---|
663 | Synopsis [Returns pointer to the array of actual input variables used for |
---|
664 | instantiating the model.] |
---|
665 | |
---|
666 | Description [A pointer to the array of actual input variables is returned. |
---|
667 | Note that the array should not be modified in any way.] |
---|
668 | |
---|
669 | SideEffects [] |
---|
670 | |
---|
671 | SeeAlso [Hrc_SubcktReadActualOutputVars()] |
---|
672 | |
---|
673 | ******************************************************************************/ |
---|
674 | array_t * |
---|
675 | Hrc_SubcktReadActualInputVars( |
---|
676 | Hrc_Subckt_t *subckt) |
---|
677 | { |
---|
678 | return subckt->actualInputVars; |
---|
679 | } |
---|
680 | |
---|
681 | /**Function******************************************************************** |
---|
682 | |
---|
683 | Synopsis [Returns pointer to the array of actual output variables used for |
---|
684 | instantiating the model.] |
---|
685 | |
---|
686 | Description [A pointer to the array of actual output variables is returned. |
---|
687 | Note that the array should not be modified in any way.] |
---|
688 | |
---|
689 | SideEffects [] |
---|
690 | |
---|
691 | SeeAlso [Hrc_SubcktReadActualInputVars()] |
---|
692 | |
---|
693 | ******************************************************************************/ |
---|
694 | array_t * |
---|
695 | Hrc_SubcktReadActualOutputVars( |
---|
696 | Hrc_Subckt_t *subckt) |
---|
697 | { |
---|
698 | return subckt->actualOutputVars; |
---|
699 | } |
---|
700 | |
---|
701 | /**Function******************************************************************** |
---|
702 | |
---|
703 | Synopsis [Returns the manager of a node.] |
---|
704 | |
---|
705 | Description [The function returns a pointer to the manager of a node.] |
---|
706 | |
---|
707 | SideEffects [] |
---|
708 | |
---|
709 | SeeAlso [] |
---|
710 | |
---|
711 | ******************************************************************************/ |
---|
712 | Hrc_Manager_t * |
---|
713 | Hrc_NodeReadManager( |
---|
714 | Hrc_Node_t *node) |
---|
715 | { |
---|
716 | return node->manager; |
---|
717 | } |
---|
718 | |
---|
719 | /**Function******************************************************************** |
---|
720 | |
---|
721 | Synopsis [Returns the model name of a node.] |
---|
722 | |
---|
723 | Description [A pointer to the name of the model whose instantiation |
---|
724 | created this node is returned. Note that the string should not |
---|
725 | be freed by the user.] |
---|
726 | |
---|
727 | SideEffects [] |
---|
728 | |
---|
729 | SeeAlso [] |
---|
730 | |
---|
731 | ******************************************************************************/ |
---|
732 | char * |
---|
733 | Hrc_NodeReadModelName( |
---|
734 | Hrc_Node_t *node) |
---|
735 | { |
---|
736 | return node->modelName; |
---|
737 | } |
---|
738 | |
---|
739 | /**Function******************************************************************** |
---|
740 | |
---|
741 | Synopsis [Returns the instance name of a node.] |
---|
742 | |
---|
743 | Description [A pointer to the name used when instantiating a node is |
---|
744 | returned. Note that the string should not be freed by |
---|
745 | the user.] |
---|
746 | |
---|
747 | SideEffects [] |
---|
748 | |
---|
749 | SeeAlso [] |
---|
750 | |
---|
751 | ******************************************************************************/ |
---|
752 | char * |
---|
753 | Hrc_NodeReadInstanceName( |
---|
754 | Hrc_Node_t *node) |
---|
755 | { |
---|
756 | return node->instanceName; |
---|
757 | } |
---|
758 | |
---|
759 | /**Function******************************************************************** |
---|
760 | |
---|
761 | Synopsis [Returns pointer to the parent node of a node.] |
---|
762 | |
---|
763 | Description [A pointer to the parent node of a node is returned.] |
---|
764 | |
---|
765 | SideEffects [] |
---|
766 | |
---|
767 | SeeAlso [] |
---|
768 | |
---|
769 | ******************************************************************************/ |
---|
770 | Hrc_Node_t * |
---|
771 | Hrc_NodeReadParentNode( |
---|
772 | Hrc_Node_t *node) |
---|
773 | { |
---|
774 | return node->parentNode; |
---|
775 | } |
---|
776 | |
---|
777 | /**Function******************************************************************** |
---|
778 | |
---|
779 | Synopsis [Returns the number of formal inputs of a node.] |
---|
780 | |
---|
781 | Description [The number of formal inputs of a node is returned.] |
---|
782 | |
---|
783 | SideEffects [] |
---|
784 | |
---|
785 | SeeAlso [Hrc_NodeReadNumFormalOutputs()] |
---|
786 | |
---|
787 | ******************************************************************************/ |
---|
788 | int |
---|
789 | Hrc_NodeReadNumFormalInputs( |
---|
790 | Hrc_Node_t *node) |
---|
791 | { |
---|
792 | return array_n(node->formalInputs); |
---|
793 | } |
---|
794 | |
---|
795 | /**Function******************************************************************** |
---|
796 | |
---|
797 | Synopsis [Returns the number of formal outputs of a node.] |
---|
798 | |
---|
799 | Description [The number of formal outputs of a node is returned.] |
---|
800 | |
---|
801 | SideEffects [] |
---|
802 | |
---|
803 | SeeAlso [Hrc_NodeReadNumFormalInputs()] |
---|
804 | |
---|
805 | ******************************************************************************/ |
---|
806 | int |
---|
807 | Hrc_NodeReadNumFormalOutputs( |
---|
808 | Hrc_Node_t *node) |
---|
809 | { |
---|
810 | return array_n(node->formalOutputs); |
---|
811 | } |
---|
812 | |
---|
813 | /**Function******************************************************************** |
---|
814 | |
---|
815 | Synopsis [This function returns the number of formal variables in a node.] |
---|
816 | |
---|
817 | SideEffects [] |
---|
818 | |
---|
819 | SeeAlso [] |
---|
820 | |
---|
821 | ******************************************************************************/ |
---|
822 | int |
---|
823 | Hrc_NodeReadNumVariables( |
---|
824 | Hrc_Node_t *node) |
---|
825 | { |
---|
826 | return st_count(node->varTable); |
---|
827 | } |
---|
828 | |
---|
829 | /**Function******************************************************************** |
---|
830 | |
---|
831 | Synopsis [This function returns the number of tables in the node.] |
---|
832 | |
---|
833 | SideEffects [] |
---|
834 | |
---|
835 | SeeAlso [] |
---|
836 | |
---|
837 | ******************************************************************************/ |
---|
838 | int |
---|
839 | Hrc_NodeReadNumTables( |
---|
840 | Hrc_Node_t *node) |
---|
841 | { |
---|
842 | return array_n(node->nameTables); |
---|
843 | } |
---|
844 | |
---|
845 | /**Function******************************************************************** |
---|
846 | |
---|
847 | Synopsis [This function returns the number of latches in a node.] |
---|
848 | |
---|
849 | SideEffects [] |
---|
850 | |
---|
851 | SeeAlso [] |
---|
852 | |
---|
853 | ******************************************************************************/ |
---|
854 | int |
---|
855 | Hrc_NodeReadNumLatches( |
---|
856 | Hrc_Node_t *node) |
---|
857 | { |
---|
858 | return st_count(node->latchTable); |
---|
859 | } |
---|
860 | |
---|
861 | /**Function******************************************************************** |
---|
862 | |
---|
863 | Synopsis [This function returns the number of children of a node.] |
---|
864 | |
---|
865 | SideEffects [] |
---|
866 | |
---|
867 | SeeAlso [] |
---|
868 | |
---|
869 | ******************************************************************************/ |
---|
870 | int |
---|
871 | Hrc_NodeReadNumChildren( |
---|
872 | Hrc_Node_t *node) |
---|
873 | { |
---|
874 | return st_count(node->childTable); |
---|
875 | } |
---|
876 | |
---|
877 | /**Function******************************************************************** |
---|
878 | |
---|
879 | Synopsis [Returns the array of formal inputs of a node.] |
---|
880 | |
---|
881 | Description [Note that this function has been exported only to provide |
---|
882 | the exported macro to iterate over the formal inputs of a node. |
---|
883 | It is not supposed to be used for any other purpose.] |
---|
884 | |
---|
885 | SideEffects [] |
---|
886 | |
---|
887 | SeeAlso [] |
---|
888 | |
---|
889 | ******************************************************************************/ |
---|
890 | array_t * |
---|
891 | Hrc_NodeReadFormalInputs( |
---|
892 | Hrc_Node_t *node) |
---|
893 | { |
---|
894 | return node->formalInputs; |
---|
895 | } |
---|
896 | |
---|
897 | /**Function******************************************************************** |
---|
898 | |
---|
899 | Synopsis [Returns the array of formal outputs of a node.] |
---|
900 | |
---|
901 | Description [Note that this function has been exported only to provide |
---|
902 | the exported macro to iterate over the formal outputs of a |
---|
903 | node. It is not supposed to be used for any other purpose.] |
---|
904 | |
---|
905 | SideEffects [] |
---|
906 | |
---|
907 | SeeAlso [] |
---|
908 | |
---|
909 | ******************************************************************************/ |
---|
910 | array_t * |
---|
911 | Hrc_NodeReadFormalOutputs( |
---|
912 | Hrc_Node_t *node) |
---|
913 | { |
---|
914 | return node->formalOutputs; |
---|
915 | } |
---|
916 | |
---|
917 | /**Function******************************************************************** |
---|
918 | |
---|
919 | Synopsis [Returns the array of actual inputs of a node.] |
---|
920 | |
---|
921 | Description [Note that this function has been exported only to provide |
---|
922 | the exported macro to iterate over the actual inputs of a node. |
---|
923 | It is not supposed to be used for any other purpose.] |
---|
924 | |
---|
925 | SideEffects [] |
---|
926 | |
---|
927 | SeeAlso [] |
---|
928 | |
---|
929 | ******************************************************************************/ |
---|
930 | array_t * |
---|
931 | Hrc_NodeReadActualInputs( |
---|
932 | Hrc_Node_t *node) |
---|
933 | { |
---|
934 | return node->actualInputs; |
---|
935 | } |
---|
936 | |
---|
937 | /**Function******************************************************************** |
---|
938 | |
---|
939 | Synopsis [Returns the array of actual outputs of a node.] |
---|
940 | |
---|
941 | Description [Note that this function has been exported only to provide |
---|
942 | the exported macro to iterate over the actual outputs of a |
---|
943 | node. It is not supposed to be used for any other purpose.] |
---|
944 | |
---|
945 | SideEffects [] |
---|
946 | |
---|
947 | SeeAlso [] |
---|
948 | |
---|
949 | ******************************************************************************/ |
---|
950 | array_t * |
---|
951 | Hrc_NodeReadActualOutputs( |
---|
952 | Hrc_Node_t *node) |
---|
953 | { |
---|
954 | return node->actualOutputs; |
---|
955 | } |
---|
956 | |
---|
957 | /**Function******************************************************************** |
---|
958 | |
---|
959 | Synopsis [Returns the array of name tables of a node.] |
---|
960 | |
---|
961 | Description [Note that this function has been exported only to provide |
---|
962 | the exported macro to iterate over the name tables in a |
---|
963 | node. It is not supposed to be used for any other purpose.] |
---|
964 | |
---|
965 | SideEffects [] |
---|
966 | |
---|
967 | SeeAlso [] |
---|
968 | |
---|
969 | ******************************************************************************/ |
---|
970 | array_t * |
---|
971 | Hrc_NodeReadNameTables( |
---|
972 | Hrc_Node_t *node) |
---|
973 | { |
---|
974 | return node->nameTables; |
---|
975 | } |
---|
976 | |
---|
977 | /**Function******************************************************************** |
---|
978 | |
---|
979 | Synopsis [Returns the hash table of children of a node.] |
---|
980 | |
---|
981 | Description [Note that this function has been exported only to provide |
---|
982 | the exported macro to iterate over the children of a node. |
---|
983 | It is not supposed to be used for any other purpose.] |
---|
984 | |
---|
985 | SideEffects [] |
---|
986 | |
---|
987 | SeeAlso [] |
---|
988 | |
---|
989 | ******************************************************************************/ |
---|
990 | st_table * |
---|
991 | Hrc_NodeReadChildTable( |
---|
992 | Hrc_Node_t *node) |
---|
993 | { |
---|
994 | return node->childTable; |
---|
995 | } |
---|
996 | |
---|
997 | /**Function******************************************************************** |
---|
998 | |
---|
999 | Synopsis [Returns the hash table of latches of a node.] |
---|
1000 | |
---|
1001 | Description [Note that this function has been exported only to provide |
---|
1002 | the exported macro to iterate over the latches in a node. |
---|
1003 | It is not supposed to be used for any other purpose.] |
---|
1004 | |
---|
1005 | SideEffects [] |
---|
1006 | |
---|
1007 | SeeAlso [] |
---|
1008 | |
---|
1009 | ******************************************************************************/ |
---|
1010 | st_table * |
---|
1011 | Hrc_NodeReadLatchTable( |
---|
1012 | Hrc_Node_t *node) |
---|
1013 | { |
---|
1014 | return node->latchTable; |
---|
1015 | } |
---|
1016 | |
---|
1017 | /**Function******************************************************************** |
---|
1018 | |
---|
1019 | Synopsis [Returns the hash table of variables of a node.] |
---|
1020 | |
---|
1021 | Description [Note that this function has been exported only to provide |
---|
1022 | the exported macro to iterate over the variables in a node. |
---|
1023 | It is not supposed to be used for any other purpose.] |
---|
1024 | |
---|
1025 | SideEffects [] |
---|
1026 | |
---|
1027 | SeeAlso [] |
---|
1028 | |
---|
1029 | ******************************************************************************/ |
---|
1030 | st_table * |
---|
1031 | Hrc_NodeReadVariableTable( |
---|
1032 | Hrc_Node_t *node) |
---|
1033 | { |
---|
1034 | return node->varTable; |
---|
1035 | } |
---|
1036 | |
---|
1037 | /**Function******************************************************************** |
---|
1038 | |
---|
1039 | Synopsis [Returns pointer to the undef field of a node.] |
---|
1040 | |
---|
1041 | SideEffects [] |
---|
1042 | |
---|
1043 | SeeAlso [] |
---|
1044 | |
---|
1045 | ******************************************************************************/ |
---|
1046 | void * |
---|
1047 | Hrc_NodeReadUndef( |
---|
1048 | Hrc_Node_t *node) |
---|
1049 | { |
---|
1050 | return node->undef; |
---|
1051 | } |
---|
1052 | /**Function******************************************************************** |
---|
1053 | |
---|
1054 | Synopsis [Returns pointer to a latch corresponding to a name.] |
---|
1055 | |
---|
1056 | Description [The name is looked up in the hash table of latches. If it is |
---|
1057 | found, a pointer to the corresponding latch is returned |
---|
1058 | otherwise NULL is returned.] |
---|
1059 | |
---|
1060 | SideEffects [] |
---|
1061 | |
---|
1062 | SeeAlso [Hrc_NodeFindVariableByName(), Hrc_NodeFindChildByName()] |
---|
1063 | |
---|
1064 | ******************************************************************************/ |
---|
1065 | Hrc_Latch_t * |
---|
1066 | Hrc_NodeFindLatchByName( |
---|
1067 | Hrc_Node_t *node, |
---|
1068 | char *latchName) |
---|
1069 | { |
---|
1070 | Hrc_Latch_t *latch; |
---|
1071 | |
---|
1072 | if(st_lookup(node->latchTable, latchName, &latch)) { |
---|
1073 | return latch; |
---|
1074 | } |
---|
1075 | else { |
---|
1076 | return NIL(Hrc_Latch_t); |
---|
1077 | } |
---|
1078 | } |
---|
1079 | |
---|
1080 | /**Function******************************************************************** |
---|
1081 | |
---|
1082 | Synopsis [Returns pointer to a variable corresponding to a name.] |
---|
1083 | |
---|
1084 | Description [The name is looked up in the hash table of variables. If it is |
---|
1085 | found, a pointer to the corresponding variable is returned |
---|
1086 | otherwise NULL is returned.] |
---|
1087 | |
---|
1088 | SideEffects [] |
---|
1089 | |
---|
1090 | SeeAlso [Hrc_NodeFindLatchByName(), Hrc_NodeFindChildByName()] |
---|
1091 | |
---|
1092 | ******************************************************************************/ |
---|
1093 | Var_Variable_t * |
---|
1094 | Hrc_NodeFindVariableByName( |
---|
1095 | Hrc_Node_t *node, |
---|
1096 | char *varName) |
---|
1097 | { |
---|
1098 | Var_Variable_t *var; |
---|
1099 | |
---|
1100 | if(st_lookup(node->varTable, varName, &var)) { |
---|
1101 | return var; |
---|
1102 | } |
---|
1103 | else { |
---|
1104 | return NIL(Var_Variable_t); |
---|
1105 | } |
---|
1106 | } |
---|
1107 | |
---|
1108 | /**Function******************************************************************** |
---|
1109 | |
---|
1110 | Synopsis [Returns pointer to child node corresponding to an instance |
---|
1111 | name.] |
---|
1112 | |
---|
1113 | Description [The name is looked up in the hash table of children. If it is |
---|
1114 | found, a pointer to the corresponding child is returned |
---|
1115 | otherwise NULL is returned.] |
---|
1116 | |
---|
1117 | SideEffects [] |
---|
1118 | |
---|
1119 | SeeAlso [Hrc_NodeFindLatchByName(), Hrc_NodeFindVariableByName()] |
---|
1120 | |
---|
1121 | ******************************************************************************/ |
---|
1122 | Hrc_Node_t * |
---|
1123 | Hrc_NodeFindChildByName( |
---|
1124 | Hrc_Node_t *node, |
---|
1125 | char *instanceName) |
---|
1126 | { |
---|
1127 | Hrc_Node_t *childNode; |
---|
1128 | |
---|
1129 | if(st_lookup(node->childTable, instanceName, &childNode)) { |
---|
1130 | return childNode; |
---|
1131 | } |
---|
1132 | else { |
---|
1133 | return NIL(Hrc_Node_t); |
---|
1134 | } |
---|
1135 | } |
---|
1136 | |
---|
1137 | /**Function******************************************************************** |
---|
1138 | |
---|
1139 | Synopsis [Returns pointer to input variable of a latch.] |
---|
1140 | |
---|
1141 | SideEffects [] |
---|
1142 | |
---|
1143 | SeeAlso [Hrc_LatchReadOutput()] |
---|
1144 | |
---|
1145 | ******************************************************************************/ |
---|
1146 | Var_Variable_t * |
---|
1147 | Hrc_LatchReadInput( |
---|
1148 | Hrc_Latch_t *latch) |
---|
1149 | { |
---|
1150 | return latch->latchInput; |
---|
1151 | } |
---|
1152 | |
---|
1153 | /**Function******************************************************************** |
---|
1154 | |
---|
1155 | Synopsis [Returns pointer to output variable of a latch.] |
---|
1156 | |
---|
1157 | SideEffects [] |
---|
1158 | |
---|
1159 | SeeAlso [Hrc_LatchReadInput()] |
---|
1160 | |
---|
1161 | ******************************************************************************/ |
---|
1162 | Var_Variable_t * |
---|
1163 | Hrc_LatchReadOutput( |
---|
1164 | Hrc_Latch_t *latch) |
---|
1165 | { |
---|
1166 | return latch->latchOutput; |
---|
1167 | } |
---|
1168 | |
---|
1169 | /**Function******************************************************************** |
---|
1170 | |
---|
1171 | Synopsis [Returns pointer to the reset table of a latch.] |
---|
1172 | |
---|
1173 | SideEffects [] |
---|
1174 | |
---|
1175 | SeeAlso [] |
---|
1176 | |
---|
1177 | ******************************************************************************/ |
---|
1178 | Tbl_Table_t * |
---|
1179 | Hrc_LatchReadResetTable( |
---|
1180 | Hrc_Latch_t *latch) |
---|
1181 | { |
---|
1182 | return latch->resetTable; |
---|
1183 | } |
---|
1184 | |
---|
1185 | /**Function******************************************************************** |
---|
1186 | |
---|
1187 | Synopsis [Returns pointer to the undef field in a latch.] |
---|
1188 | |
---|
1189 | SideEffects [] |
---|
1190 | |
---|
1191 | SeeAlso [] |
---|
1192 | |
---|
1193 | ******************************************************************************/ |
---|
1194 | void * |
---|
1195 | Hrc_LatchReadUndef( |
---|
1196 | Hrc_Latch_t *latch) |
---|
1197 | { |
---|
1198 | return latch->undef; |
---|
1199 | } |
---|
1200 | |
---|
1201 | /**Function******************************************************************** |
---|
1202 | |
---|
1203 | Synopsis [Sets the rootNode field of a manager.] |
---|
1204 | |
---|
1205 | SideEffects [] |
---|
1206 | |
---|
1207 | SeeAlso [] |
---|
1208 | |
---|
1209 | ******************************************************************************/ |
---|
1210 | void |
---|
1211 | Hrc_ManagerSetRootNode( |
---|
1212 | Hrc_Manager_t *manager, |
---|
1213 | Hrc_Node_t *node) |
---|
1214 | { |
---|
1215 | manager->rootNode = node; |
---|
1216 | } |
---|
1217 | |
---|
1218 | /**Function******************************************************************** |
---|
1219 | |
---|
1220 | Synopsis [Sets the currentNode field of a manager.] |
---|
1221 | |
---|
1222 | SideEffects [] |
---|
1223 | |
---|
1224 | SeeAlso [] |
---|
1225 | |
---|
1226 | ******************************************************************************/ |
---|
1227 | void |
---|
1228 | Hrc_ManagerSetCurrentNode( |
---|
1229 | Hrc_Manager_t *manager, |
---|
1230 | Hrc_Node_t *currentNode) |
---|
1231 | { |
---|
1232 | manager->currentNode = currentNode; |
---|
1233 | } |
---|
1234 | |
---|
1235 | /**Function******************************************************************** |
---|
1236 | |
---|
1237 | Synopsis [Adds a formal input variable to a node.] |
---|
1238 | |
---|
1239 | Description [The formal input variable is added to the array of formal |
---|
1240 | inputs and to the hash table of variables and TRUE is returned. |
---|
1241 | If the variable is a primary input already, nothing is done |
---|
1242 | and FALSE is returned.] |
---|
1243 | |
---|
1244 | SideEffects [] |
---|
1245 | |
---|
1246 | SeeAlso [Hrc_NodeAddFormalOutput()] |
---|
1247 | |
---|
1248 | ******************************************************************************/ |
---|
1249 | boolean |
---|
1250 | Hrc_NodeAddFormalInput( |
---|
1251 | Hrc_Node_t *node, |
---|
1252 | Var_Variable_t *var) |
---|
1253 | { |
---|
1254 | char *name = Var_VariableReadName(var); |
---|
1255 | |
---|
1256 | if(!Var_VariableTestIsPI(var)) { |
---|
1257 | array_insert_last(Var_Variable_t *, node->formalInputs, var); |
---|
1258 | st_insert(node->varTable, name, (char *) var); |
---|
1259 | (void)Var_VariableSetPI(var); |
---|
1260 | return TRUE; |
---|
1261 | } |
---|
1262 | else { |
---|
1263 | return FALSE; |
---|
1264 | } |
---|
1265 | } |
---|
1266 | |
---|
1267 | /**Function******************************************************************** |
---|
1268 | |
---|
1269 | Synopsis [Adds a formal output variable to a node.] |
---|
1270 | |
---|
1271 | Description [The formal output variable is added to the array of formal |
---|
1272 | outputs and to the hash table of variables and TRUE is |
---|
1273 | returned. If the variable is a primary output already, |
---|
1274 | nothing is done and FALSE is returned.] |
---|
1275 | |
---|
1276 | SideEffects [] |
---|
1277 | |
---|
1278 | SeeAlso [Hrc_NodeAddFormalInput()] |
---|
1279 | |
---|
1280 | ******************************************************************************/ |
---|
1281 | boolean |
---|
1282 | Hrc_NodeAddFormalOutput( |
---|
1283 | Hrc_Node_t *node, |
---|
1284 | Var_Variable_t *var) |
---|
1285 | { |
---|
1286 | char *name = Var_VariableReadName(var); |
---|
1287 | |
---|
1288 | if(!Var_VariableTestIsPO(var)) { |
---|
1289 | array_insert_last(Var_Variable_t *, node->formalOutputs, var); |
---|
1290 | st_insert(node->varTable, name, (char *) var); |
---|
1291 | (void)Var_VariableSetPO(var); |
---|
1292 | return TRUE; |
---|
1293 | } |
---|
1294 | else { |
---|
1295 | return FALSE; |
---|
1296 | } |
---|
1297 | } |
---|
1298 | |
---|
1299 | /**Function******************************************************************** |
---|
1300 | |
---|
1301 | Synopsis [Adds a name table to a node.] |
---|
1302 | |
---|
1303 | SideEffects [] |
---|
1304 | |
---|
1305 | SeeAlso [Hrc_NodeAddFormalInput(), Hrc_NodeAddFormalOutput()] |
---|
1306 | |
---|
1307 | ******************************************************************************/ |
---|
1308 | void |
---|
1309 | Hrc_NodeAddNameTable( |
---|
1310 | Hrc_Node_t *node, |
---|
1311 | Tbl_Table_t *nameTable) |
---|
1312 | { |
---|
1313 | array_insert_last(Tbl_Table_t *, node->nameTables, nameTable); |
---|
1314 | } |
---|
1315 | |
---|
1316 | /**Function******************************************************************** |
---|
1317 | |
---|
1318 | Synopsis [Sets the undef field of a node.] |
---|
1319 | |
---|
1320 | SideEffects [] |
---|
1321 | |
---|
1322 | SeeAlso [] |
---|
1323 | |
---|
1324 | ******************************************************************************/ |
---|
1325 | void |
---|
1326 | Hrc_NodeSetUndef( |
---|
1327 | Hrc_Node_t *node, |
---|
1328 | void *value) |
---|
1329 | { |
---|
1330 | node->undef = value; |
---|
1331 | } |
---|
1332 | |
---|
1333 | /**Function******************************************************************** |
---|
1334 | |
---|
1335 | Synopsis [Sets the reset table of a latch.] |
---|
1336 | |
---|
1337 | Description [If the resetTable field of the latch is NULL, it is set to |
---|
1338 | table and TRUE is returned otherwise FALSE is returned. ] |
---|
1339 | |
---|
1340 | SideEffects [] |
---|
1341 | |
---|
1342 | SeeAlso [] |
---|
1343 | |
---|
1344 | ******************************************************************************/ |
---|
1345 | |
---|
1346 | boolean |
---|
1347 | Hrc_LatchSetResetTable( |
---|
1348 | Hrc_Latch_t *latch, |
---|
1349 | Tbl_Table_t *table) |
---|
1350 | { |
---|
1351 | if (latch->resetTable != NIL(Tbl_Table_t)){ |
---|
1352 | return FALSE; |
---|
1353 | } |
---|
1354 | latch->resetTable = table; |
---|
1355 | return TRUE; |
---|
1356 | } |
---|
1357 | |
---|
1358 | /**Function******************************************************************** |
---|
1359 | |
---|
1360 | Synopsis [Set the undef field of a latch.] |
---|
1361 | |
---|
1362 | SideEffects [] |
---|
1363 | |
---|
1364 | SeeAlso [] |
---|
1365 | |
---|
1366 | ******************************************************************************/ |
---|
1367 | void |
---|
1368 | Hrc_LatchSetUndef( |
---|
1369 | Hrc_Latch_t *latch, |
---|
1370 | void *value) |
---|
1371 | { |
---|
1372 | latch->undef = value; |
---|
1373 | } |
---|
1374 | |
---|
1375 | |
---|
1376 | /*---------------------------------------------------------------------------*/ |
---|
1377 | /* Definition of internal functions */ |
---|
1378 | /*---------------------------------------------------------------------------*/ |
---|
1379 | |
---|
1380 | |
---|
1381 | /*---------------------------------------------------------------------------*/ |
---|
1382 | /* Definition of static functions */ |
---|
1383 | /*---------------------------------------------------------------------------*/ |
---|
1384 | |
---|
1385 | |
---|
1386 | |
---|
1387 | |
---|
1388 | |
---|
1389 | |
---|
1390 | |
---|
1391 | |
---|
1392 | |
---|
1393 | |
---|
1394 | |
---|
1395 | |
---|
1396 | |
---|
1397 | |
---|
1398 | |
---|
1399 | |
---|
1400 | |
---|
1401 | |
---|
1402 | |
---|
1403 | |
---|
1404 | |
---|
1405 | |
---|
1406 | |
---|
1407 | |
---|
1408 | |
---|