source: vis_dev/vis-2.3/src/spfd/spfdAPI.c@ 56

Last change on this file since 56 was 14, checked in by cecile, 15 years ago

vis2.3

File size: 15.8 KB
RevLine 
[14]1/**CFile***********************************************************************
2
3 FileName [spfdAPI.c]
4
5 PackageName [spfd]
6
7 Synopsis [Routines to read, delete and update data structures used
8 in the package.]
9
10 Description [Routines to read, delete and update data structures used
11 in the package.]
12
13 SeeAlso [spfdUtil.c spfdClean.c]
14
15 Author [Balakrishna Kumthekar]
16
17 Copyright [This file was created at the University of Colorado at Boulder.
18 The University of Colorado at Boulder makes no warranty about the suitability
19 of this software for any purpose. It is presented on an AS IS basis.]
20
21******************************************************************************/
22
23#include "spfdInt.h"
24
25/*---------------------------------------------------------------------------*/
26/* Constant declarations */
27/*---------------------------------------------------------------------------*/
28
29
30/*---------------------------------------------------------------------------*/
31/* Type declarations */
32/*---------------------------------------------------------------------------*/
33
34
35/*---------------------------------------------------------------------------*/
36/* Structure declarations */
37/*---------------------------------------------------------------------------*/
38
39
40/*---------------------------------------------------------------------------*/
41/* Variable declarations */
42/*---------------------------------------------------------------------------*/
43
44extern int sfpdVerbose;
45extern float alpha;
46
47/*---------------------------------------------------------------------------*/
48/* Macro declarations */
49/*---------------------------------------------------------------------------*/
50
51
52/**AutomaticStart*************************************************************/
53
54/*---------------------------------------------------------------------------*/
55/* Static function prototypes */
56/*---------------------------------------------------------------------------*/
57
58
59/**AutomaticEnd***************************************************************/
60
61
62/*---------------------------------------------------------------------------*/
63/* Definition of exported functions */
64/*---------------------------------------------------------------------------*/
65
66/*---------------------------------------------------------------------------*/
67/* Definition of internal functions */
68/*---------------------------------------------------------------------------*/
69
70/**Function********************************************************************
71
72 Synopsis [Returns whether the node is locked.]
73
74 SideEffects [None]
75
76******************************************************************************/
77boolean
78SpfdNodeReadLocked(
79 SpfdApplData_t *applData,
80 Ntk_Node_t *node)
81{
82 st_table *nodeToData = applData->nodeToData;
83 SpfdNodeData_t *nodeData;
84
85 st_lookup(nodeToData,(char *)node,&nodeData);
86
87 return nodeData->locked;
88
89} /* End of SpfdNodeReadLocked */
90
91
92/**Function********************************************************************
93
94 Synopsis [Read the auxillary BDD id associated with the node.]
95
96 SideEffects [None]
97
98******************************************************************************/
99int
100SpfdNodeReadAuxId(
101 SpfdApplData_t *applData,
102 Ntk_Node_t *node)
103{
104 st_table *nodeToData = applData->nodeToData;
105 SpfdNodeData_t *nodeData;
106
107 st_lookup(nodeToData,(char *)node,&nodeData);
108
109 return nodeData->auxId;
110
111} /* End of SpfdNodeReadAuxId */
112
113
114/**Function********************************************************************
115
116 Synopsis [Set the auxillary BDD id for the node]
117
118 SideEffects [None]
119
120******************************************************************************/
121void
122SpfdNodeSetAuxId(
123 SpfdApplData_t *applData,
124 Ntk_Node_t *node,
125 int auxId)
126{
127 st_table *nodeToData = applData->nodeToData;
128 SpfdNodeData_t *nodeData;
129
130 st_lookup(nodeToData,(char *)node,&nodeData);
131 nodeData->auxId = auxId;
132
133} /* End of SpfdNodeSetAuxId */
134
135
136/**Function********************************************************************
137
138 Synopsis [Read the node's spfd.]
139
140 SideEffects [None]
141
142******************************************************************************/
143bdd_node *
144SpfdNodeReadSpfd(
145 SpfdApplData_t *applData,
146 Ntk_Node_t *node)
147{
148 st_table *nodeToData = applData->nodeToData;
149 SpfdNodeData_t *nodeData;
150
151 st_lookup(nodeToData,(char *)node,&nodeData);
152
153 return nodeData->spfd;
154
155} /* End of SpfdNodeReadSpfd */
156
157
158/**Function********************************************************************
159
160 Synopsis [Free the BDD representing the spfd of the node.]
161
162 SideEffects [None]
163
164******************************************************************************/
165void
166SpfdNodeDeleteSpfd(
167 SpfdApplData_t *applData,
168 Ntk_Node_t *node)
169{
170 st_table *nodeToData = applData->nodeToData;
171 SpfdNodeData_t *nodeData;
172
173 st_lookup(nodeToData,(char *)node,&nodeData);
174
175 if (nodeData->spfd)
176 bdd_recursive_deref(applData->ddManager,nodeData->spfd);
177 nodeData->spfd = NIL(bdd_node);
178
179 return;
180
181} /* End of SpfdNodeDeleteSpfd */
182
183
184/**Function********************************************************************
185
186 Synopsis [Set the node's spfd]
187
188 SideEffects [None]
189
190******************************************************************************/
191void
192SpfdNodeSetSpfd(
193 SpfdApplData_t *applData,
194 Ntk_Node_t *node,
195 bdd_node *spfd)
196{
197 st_table *nodeToData = applData->nodeToData;
198 SpfdNodeData_t *nodeData;
199
200 st_lookup(nodeToData,(char *)node,&nodeData);
201
202 if (nodeData->spfd) {
203 (void) fprintf(vis_stdout,
204 "** spfd warning: <%s: set spfd> Possible memory leak.\n",
205 Ntk_NodeReadName(node));
206 }
207 nodeData->spfd = spfd;
208
209} /* End of SpfdNodeSetSpfd */
210
211
212/**Function********************************************************************
213
214 Synopsis [Read the array of BDD variables (parameters) associated
215 with the spfd of the node.]
216
217 SideEffects [None]
218
219******************************************************************************/
220bdd_node **
221SpfdNodeReadParameters(
222 SpfdApplData_t *applData,
223 Ntk_Node_t *node)
224{
225 st_table *nodeToData = applData->nodeToData;
226 SpfdNodeData_t *nodeData;
227
228 st_lookup(nodeToData,(char *)node,&nodeData);
229
230 return nodeData->parameters;
231
232} /* End of SpfdNodeReadParameters */
233
234
235/**Function********************************************************************
236
237 Synopsis [Free the array of BDD variables (parameters) associated
238 with the spfd of the node.]
239
240 SideEffects [None]
241
242******************************************************************************/
243void
244SpfdNodeDeleteParameters(
245 SpfdApplData_t *applData,
246 Ntk_Node_t *node)
247{
248 st_table *nodeToData = applData->nodeToData;
249 SpfdNodeData_t *nodeData;
250
251 st_lookup(nodeToData,(char *)node,&nodeData);
252
253 if (nodeData->parameters)
254 FREE(nodeData->parameters);
255
256 nodeData->parameters = NIL(bdd_node *);
257 nodeData->numParams = 0;
258
259 return;
260
261} /* End of SpfdNodeDeleteParameters */
262
263
264/**Function********************************************************************
265
266 Synopsis [Set the array of BDD variables (parameters) associated
267 with the spfd of the node.]
268
269 SideEffects [None]
270
271******************************************************************************/
272void
273SpfdNodeSetParameters(
274 SpfdApplData_t *applData,
275 Ntk_Node_t *node,
276 bdd_node **parameters,
277 int numParams)
278{
279 st_table *nodeToData = applData->nodeToData;
280 SpfdNodeData_t *nodeData;
281
282 st_lookup(nodeToData,(char *)node,&nodeData);
283
284 if (nodeData->parameters) {
285 (void) fprintf(vis_stdout,
286 "** spfd warning: <%s: set parameters> Possible memory leak.\n",
287 Ntk_NodeReadName(node));
288 }
289
290 nodeData->parameters = parameters;
291 nodeData->numParams = numParams;
292
293} /* End of SpfdNodeSetParameters */
294
295
296/**Function********************************************************************
297
298 Synopsis [Read the sorted array of fanin nodes.]
299
300 SideEffects [None]
301
302******************************************************************************/
303array_t *
304SpfdNodeReadFaninOrder(
305 SpfdApplData_t *applData,
306 Ntk_Node_t *node)
307{
308 st_table *nodeToData = applData->nodeToData;
309 SpfdNodeData_t *nodeData;
310
311 st_lookup(nodeToData,(char *)node,&nodeData);
312
313 return nodeData->faninOrder;
314
315} /* End of SpfdNodeReadFaninOrder */
316
317
318/**Function********************************************************************
319
320 Synopsis [Delete the sorted array of fanin nodes.]
321
322 SideEffects [None]
323
324******************************************************************************/
325void
326SpfdNodeDeleteFaninOrder(
327 SpfdApplData_t *applData,
328 Ntk_Node_t *node)
329{
330 st_table *nodeToData = applData->nodeToData;
331 SpfdNodeData_t *nodeData;
332
333 st_lookup(nodeToData,(char *)node,&nodeData);
334
335 if (nodeData->faninOrder)
336 array_free(nodeData->faninOrder);
337
338 nodeData->faninOrder = NIL(array_t);
339
340 return;
341
342} /* End of SpfdNodeDeleteFaninOrder */
343
344
345/**Function********************************************************************
346
347 Synopsis [Set the array faninOrder required during SPFD computation.]
348
349 SideEffects [None]
350
351******************************************************************************/
352void
353SpfdNodeSetFaninOrder(
354 SpfdApplData_t *applData,
355 Ntk_Node_t *node,
356 array_t *faninOrder)
357{
358 st_table *nodeToData = applData->nodeToData;
359 SpfdNodeData_t *nodeData;
360
361 st_lookup(nodeToData,(char *)node,&nodeData);
362 if (nodeData->faninOrder) {
363 (void) fprintf(vis_stdout,
364 "** spfd warning: <%s: set fanin order> Possible memory leak.\n",
365 Ntk_NodeReadName(node));
366 }
367 nodeData->faninOrder = faninOrder;
368
369} /* End of SpfdNodeSetFaninOrder */
370
371/**Function********************************************************************
372
373 Synopsis [Read the global BDD of the node. The global BDD is derived
374 from the node's spfd.]
375
376 SideEffects [SpfdNodeDeleteGlobalAlternative]
377
378******************************************************************************/
379bdd_node *
380SpfdNodeReadGlobalAlternative(
381 SpfdApplData_t *applData,
382 Ntk_Node_t *node)
383{
384 st_table *nodeToData = applData->nodeToData;
385 SpfdNodeData_t *nodeData;
386
387 st_lookup(nodeToData,(char *)node,&nodeData);
388
389 return nodeData->alternative;
390
391} /* End of SpfdNodeReadGlobalAlternative */
392
393
394/**Function********************************************************************
395
396 Synopsis [Delete the global BDD of the node. The global BDD is
397 derived from the node's spfd.]
398
399 SideEffects [None]
400
401 SeeAlso [SpfdNodeReadGlobalAlternative]
402
403******************************************************************************/
404void
405SpfdNodeDeleteGlobalAlternative(
406 SpfdApplData_t *applData,
407 Ntk_Node_t *node)
408{
409 st_table *nodeToData = applData->nodeToData;
410 SpfdNodeData_t *nodeData;
411
412 st_lookup(nodeToData,(char *)node,&nodeData);
413
414 if (nodeData->alternative)
415 bdd_recursive_deref(applData->ddManager,nodeData->alternative);
416
417 nodeData->alternative = NIL(bdd_node);
418
419 return;
420
421} /* End of SpfdNodeDeleteGlobalAlternative */
422
423
424/**Function********************************************************************
425
426 Synopsis [Set the BDD as the node's global BDD.]
427
428 SideEffects [None]
429
430******************************************************************************/
431void
432SpfdNodeSetGlobalAlternative(
433 SpfdApplData_t *applData,
434 Ntk_Node_t *node,
435 bdd_node *alternative)
436{
437 st_table *nodeToData = applData->nodeToData;
438 SpfdNodeData_t *nodeData;
439
440 st_lookup(nodeToData,(char *)node,&nodeData);
441 if (nodeData->alternative) {
442 (void) fprintf(vis_stdout,
443 "** spfd warning: <%s: set global alternative>"
444 " Possible memory leak.\n",
445 Ntk_NodeReadName(node));
446 }
447 nodeData->alternative = alternative;
448
449} /* End of SpfdNodeSetGlobalAlternative */
450
451
452/**Function********************************************************************
453
454 Synopsis [Read the local BDD, which is in terms of the node's
455 immediate fanin.]
456
457 SideEffects [None]
458
459******************************************************************************/
460bdd_node *
461SpfdNodeReadLocalAlt(
462 SpfdApplData_t *applData,
463 Ntk_Node_t *node)
464{
465 st_table *nodeToData = applData->nodeToData;
466 SpfdNodeData_t *nodeData;
467
468 st_lookup(nodeToData,(char *)node,&nodeData);
469
470 return nodeData->localAlt;
471
472} /* End of SpfdNodeReadLocalAlt */
473
474
475/**Function********************************************************************
476
477 Synopsis [Delete the local BDD, which is in terms of the node's
478 immediate fanin.]
479
480 SideEffects [None]
481
482******************************************************************************/
483void
484SpfdNodeDeleteLocalAlt(
485 SpfdApplData_t *applData,
486 Ntk_Node_t *node)
487{
488 st_table *nodeToData = applData->nodeToData;
489 SpfdNodeData_t *nodeData;
490
491 st_lookup(nodeToData,(char *)node,&nodeData);
492
493 if (nodeData->localAlt)
494 bdd_recursive_deref(applData->ddManager,nodeData->localAlt);
495
496 nodeData->localAlt = NIL(bdd_node);
497
498 return;
499
500} /* End of SpfdNodeDeleteLocalAlt */
501
502
503/**Function********************************************************************
504
505 Synopsis [Set localAlt as the local BDD. localAlt is in terms of the
506 node's immediate fanin.]
507
508 SideEffects [None]
509
510******************************************************************************/
511void
512SpfdNodeSetLocalAlt(
513 SpfdApplData_t *applData,
514 Ntk_Node_t *node,
515 bdd_node *localAlt)
516{
517 st_table *nodeToData = applData->nodeToData;
518 SpfdNodeData_t *nodeData;
519
520 st_lookup(nodeToData,(char *)node,&nodeData);
521 if (nodeData->localAlt) {
522 (void) fprintf(vis_stdout,
523 "** spfd warning: <%s: set local alt> Possible memory leak.\n",
524 Ntk_NodeReadName(node));
525 }
526 nodeData->localAlt = localAlt;
527
528} /* End of SpfdNodeSetLocalAlt */
529
530
531/**Function********************************************************************
532
533 Synopsis [Set the node as locked.]
534
535 SideEffects [None]
536
537******************************************************************************/
538void
539SpfdNodeSetLocked(
540 SpfdApplData_t *applData,
541 Ntk_Node_t *node,
542 boolean locked)
543{
544 st_table *nodeToData = applData->nodeToData;
545 SpfdNodeData_t *nodeData;
546
547 st_lookup(nodeToData,(char *)node,&nodeData);
548
549 nodeData->locked = locked;
550
551} /* End of SpfdNodeSetLocked */
552
553
554/**Function********************************************************************
555
556 Synopsis [Read the number of parameters associated with the node's
557 SPFD.]
558
559 SideEffects [None]
560
561******************************************************************************/
562int
563SpfdNodeReadNumParams(
564 SpfdApplData_t *applData,
565 Ntk_Node_t *node)
566{
567 st_table *nodeToData = applData->nodeToData;
568 SpfdNodeData_t *nodeData;
569
570 st_lookup(nodeToData,(char *)node,&nodeData);
571
572 return nodeData->numParams;
573
574} /* End of SpfdNodeReadNumParams */
575
576/**Function********************************************************************
577
578 Synopsis [This is used to get the index of the source of the net
579 data structure used in VPR.]
580
581 SideEffects [None]
582
583******************************************************************************/
584int
585SpfdNodeReadNetIndex(
586 SpfdApplData_t *applData,
587 Ntk_Node_t *node)
588{
589 SpfdPlaceData_t *placeData;
590 int index = -1;
591
592 placeData = applData->placeData;
593 st_lookup(placeData->nodeToNetIndex,(char *)node,&index);
594
595 return index;
596
597} /* End of SpfdNodeReadNetIndex */
598
599/*---------------------------------------------------------------------------*/
600/* Definition of static functions */
601/*---------------------------------------------------------------------------*/
602
603
Note: See TracBrowser for help on using the repository browser.