ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
casCore.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "base/main/main.h"
#include "base/cmd/cmd.h"
#include "bdd/extrab/extraBdd.h"
#include "cas.h"
Include dependency graph for casCore.c:

Go to the source code of this file.

Macros

#define PRD(p)
 static varibles ///
 
#define PRB_(f)
 
#define PRK(f, n)
 
#define PRK2(f, g, n)
 

Functions

ABC_NAMESPACE_IMPL_START DdNode * GetSingleOutputFunction (DdManager *dd, DdNode **pbOuts, int nOuts, DdNode **pbVarsEnc, int nVarsEnc, int fVerbose)
 static functions ///
 
DdNode * GetSingleOutputFunctionRemapped (DdManager *dd, DdNode **pOutputs, int nOuts, DdNode **pbVarsEnc, int nVarsEnc)
 INPUT REMAPPING ///.
 
DdNode * GetSingleOutputFunctionRemappedNewDD (DdManager *dd, DdNode **pOutputs, int nOuts, DdManager **DdNew)
 
int CreateDecomposedNetwork (DdManager *dd, DdNode *aFunc, char **pNames, int nNames, char *FileName, int nLutSize, int fCheck, int fVerbose)
 EXTERNAL FUNCTIONS ///.
 
void WriteSingleOutputFunctionBlif (DdManager *dd, DdNode *aFunc, char **pNames, int nNames, char *FileName)
 
DdNode * Cudd_bddTransferPermute (DdManager *ddSource, DdManager *ddDestination, DdNode *f, int *Permute)
 
int Abc_CascadeExperiment (char *pFileGeneric, DdManager *dd, DdNode **pOutputs, int nInputs, int nOutputs, int nLutSize, int fCheck, int fVerbose)
 EXTERNAL FUNCTIONS ///.
 
int CompareSupports (int *ptrX, int *ptrY)
 
int CompareMinterms (int *ptrX, int *ptrY)
 
int GrayCode (int BinCode)
 
void WriteDDintoBLIFfile (FILE *pFile, DdNode *Func, char *OutputName, char *Prefix, char **InputNames)
 BLIF WRITING FUNCTIONS ///.
 
void WriteDDintoBLIFfileReorder (DdManager *dd, FILE *pFile, DdNode *Func, char *OutputName, char *Prefix, char **InputNames)
 
DdNode * cuddBddTransferPermute (DdManager *ddS, DdManager *ddD, DdNode *f, int *Permute)
 

Macro Definition Documentation

◆ PRB_

#define PRB_ ( f)
Value:
printf( #f " = " ); Cudd_bddPrint(dd,f); printf( "\n" )

Definition at line 59 of file casCore.c.

◆ PRD

#define PRD ( p)
Value:
printf( "\nDECOMPOSITION TREE:\n\n" ); PrintDecEntry( (p), 0 )
Cube * p
Definition exorList.c:222

static varibles ///

debugging macros ///

Definition at line 58 of file casCore.c.

◆ PRK

#define PRK ( f,
n )
Value:
Cudd_PrintKMap(stdout,dd,(f),Cudd_Not(f),(n),NULL,0); printf( "K-map for function" #f "\n\n" )

Definition at line 60 of file casCore.c.

◆ PRK2

#define PRK2 ( f,
g,
n )
Value:
Cudd_PrintKMap(stdout,dd,(f),(g),(n),NULL,0); printf( "K-map for function <" #f ", " #g ">\n\n" )

Definition at line 61 of file casCore.c.

Function Documentation

◆ Abc_CascadeExperiment()

int Abc_CascadeExperiment ( char * pFileGeneric,
DdManager * dd,
DdNode ** pOutputs,
int nInputs,
int nOutputs,
int nLutSize,
int fCheck,
int fVerbose )

EXTERNAL FUNCTIONS ///.

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 79 of file casCore.c.

80{
81 int i;
82 int nVars = nInputs;
83 int nOuts = nOutputs;
84 abctime clk1;
85
86 int nVarsEnc; // the number of additional variables to encode outputs
87 DdNode * pbVarsEnc[MAXOUTPUTS]; // the BDDs of the encoding vars
88
89 int nNames; // the total number of all inputs
90 char * pNames[MAXINPUTS]; // the temporary storage for the input (and output encoding) names
91
92 DdNode * aFunc; // the encoded 0-1 BDD containing all the outputs
93
94 char FileNameIni[100];
95 char FileNameFin[100];
96 char Buffer[100];
97
98
99//pTable = fopen( "stats.txt", "a+" );
100//fprintf( pTable, "%s ", pFileGeneric );
101//fprintf( pTable, "%d ", nVars );
102//fprintf( pTable, "%d ", nOuts );
103
104
105 // assign the file names
106 strcpy( FileNameIni, pFileGeneric );
107 strcat( FileNameIni, "_ENC.blif" );
108
109 strcpy( FileNameFin, pFileGeneric );
110 strcat( FileNameFin, "_LUT.blif" );
111
112
113 // create the variables to encode the outputs
114 nVarsEnc = Abc_Base2Log( nOuts );
115 for ( i = 0; i < nVarsEnc; i++ )
116 pbVarsEnc[i] = Cudd_bddNewVarAtLevel( dd, i );
117
118
119 // store the input names
120 nNames = nVars + nVarsEnc;
121 for ( i = 0; i < nVars; i++ )
122 {
123// pNames[i] = Extra_UtilStrsav( pFunc->pInputNames[i] );
124 sprintf( Buffer, "pi%03d", i );
125 pNames[i] = Extra_UtilStrsav( Buffer );
126 }
127 // set the encoding variable name
128 for ( ; i < nNames; i++ )
129 {
130 sprintf( Buffer, "OutEnc_%02d", i-nVars );
131 pNames[i] = Extra_UtilStrsav( Buffer );
132 }
133
134
135 // print the variable order
136// printf( "\n" );
137// printf( "Variable order is: " );
138// for ( i = 0; i < dd->size; i++ )
139// printf( " %d", dd->invperm[i] );
140// printf( "\n" );
141
142 // derive the single-output function
143 clk1 = Abc_Clock();
144 aFunc = GetSingleOutputFunction( dd, pOutputs, nOuts, pbVarsEnc, nVarsEnc, fVerbose ); Cudd_Ref( aFunc );
145// aFunc = GetSingleOutputFunctionRemapped( dd, pOutputs, nOuts, pbVarsEnc, nVarsEnc ); Cudd_Ref( aFunc );
146// if ( fVerbose )
147// printf( "Single-output function computation time = %.2f sec\n", (float)(Abc_Clock() - clk1)/(float)(CLOCKS_PER_SEC) );
148
149//fprintf( pTable, "%d ", Cudd_SharingSize( pOutputs, nOutputs ) );
150//fprintf( pTable, "%d ", Extra_ProfileWidthSharingMax(dd, pOutputs, nOutputs) );
151
152 // dispose of the multiple-output function
153// Extra_Dissolve( pFunc );
154
155 // reorder the single output function
156// if ( fVerbose )
157// printf( "Reordering variables...\n");
158 clk1 = Abc_Clock();
159// if ( fVerbose )
160// printf( "Node count before = %6d\n", Cudd_DagSize( aFunc ) );
161// Cudd_ReduceHeap(dd, CUDD_REORDER_SIFT,1);
162 Cudd_ReduceHeap(dd, CUDD_REORDER_SYMM_SIFT,1);
163 Cudd_ReduceHeap(dd, CUDD_REORDER_SYMM_SIFT,1);
164// Cudd_ReduceHeap(dd, CUDD_REORDER_SYMM_SIFT,1);
165// Cudd_ReduceHeap(dd, CUDD_REORDER_SYMM_SIFT,1);
166// Cudd_ReduceHeap(dd, CUDD_REORDER_SYMM_SIFT,1);
167// Cudd_ReduceHeap(dd, CUDD_REORDER_SYMM_SIFT,1);
168 if ( fVerbose )
169 printf( "MTBDD reordered = %6d nodes\n", Cudd_DagSize( aFunc ) );
170 if ( fVerbose )
171 printf( "Variable reordering time = %.2f sec\n", (float)(Abc_Clock() - clk1)/(float)(CLOCKS_PER_SEC) );
172// printf( "\n" );
173// printf( "Variable order is: " );
174// for ( i = 0; i < dd->size; i++ )
175// printf( " %d", dd->invperm[i] );
176// printf( "\n" );
177//fprintf( pTable, "%d ", Cudd_DagSize( aFunc ) );
178//fprintf( pTable, "%d ", Extra_ProfileWidthMax(dd, aFunc) );
179
180 // write the single-output function into BLIF for verification
181 clk1 = Abc_Clock();
182 if ( fCheck )
183 WriteSingleOutputFunctionBlif( dd, aFunc, pNames, nNames, FileNameIni );
184// if ( fVerbose )
185// printf( "Single-output function writing time = %.2f sec\n", (float)(Abc_Clock() - clk1)/(float)(CLOCKS_PER_SEC) );
186
187/*
189 // verification of single output function
190 clk1 = Abc_Clock();
191 {
192 BFunc g_Func;
193 DdNode * aRes;
194
195 g_Func.dd = dd;
196 g_Func.FileInput = Extra_UtilStrsav(FileNameIni);
197
198 if ( Extra_ReadFile( &g_Func ) == 0 )
199 {
200 printf( "\nSomething did not work out while reading the input file for verification\n");
201 Extra_Dissolve( &g_Func );
202 return;
203 }
204
205 aRes = Cudd_BddToAdd( dd, g_Func.pOutputs[0] ); Cudd_Ref( aRes );
206
207 if ( aRes != aFunc )
208 printf( "\nVerification FAILED!\n");
209 else
210 printf( "\nVerification okay!\n");
211
212 Cudd_RecursiveDeref( dd, aRes );
213
214 // delocate
215 Extra_Dissolve( &g_Func );
216 }
217 printf( "Preliminary verification time = %.2f sec\n", (float)(Abc_Clock() - clk1)/(float)(CLOCKS_PER_SEC) );
219*/
220
221 if ( !CreateDecomposedNetwork( dd, aFunc, pNames, nNames, FileNameFin, nLutSize, fCheck, fVerbose ) )
222 return 0;
223
224/*
226 // verification of the decomposed LUT network
227 clk1 = Abc_Clock();
228 {
229 BFunc g_Func;
230 DdNode * aRes;
231
232 g_Func.dd = dd;
233 g_Func.FileInput = Extra_UtilStrsav(FileNameFin);
234
235 if ( Extra_ReadFile( &g_Func ) == 0 )
236 {
237 printf( "\nSomething did not work out while reading the input file for verification\n");
238 Extra_Dissolve( &g_Func );
239 return;
240 }
241
242 aRes = Cudd_BddToAdd( dd, g_Func.pOutputs[0] ); Cudd_Ref( aRes );
243
244 if ( aRes != aFunc )
245 printf( "\nFinal verification FAILED!\n");
246 else
247 printf( "\nFinal verification okay!\n");
248
249 Cudd_RecursiveDeref( dd, aRes );
250
251 // delocate
252 Extra_Dissolve( &g_Func );
253 }
254 printf( "Final verification time = %.2f sec\n", (float)(Abc_Clock() - clk1)/(float)(CLOCKS_PER_SEC) );
256*/
257
258 // verify the results
259 if ( fCheck )
260 {
261 char Command[300];
262 sprintf( Command, "cec %s %s", FileNameIni, FileNameFin );
264 }
265
266 Cudd_RecursiveDeref( dd, aFunc );
267
268 // release the names
269 for ( i = 0; i < nNames; i++ )
270 ABC_FREE( pNames[i] );
271
272
273//fprintf( pTable, "\n" );
274//fclose( pTable );
275
276 return 1;
277}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_FREE(obj)
Definition abc_global.h:267
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
ABC_NAMESPACE_IMPL_START DdNode * GetSingleOutputFunction(DdManager *dd, DdNode **pbOuts, int nOuts, DdNode **pbVarsEnc, int nVarsEnc, int fVerbose)
static functions ///
Definition casCore.c:496
int CreateDecomposedNetwork(DdManager *dd, DdNode *aFunc, char **pNames, int nNames, char *FileName, int nLutSize, int fCheck, int fVerbose)
EXTERNAL FUNCTIONS ///.
Definition casDec.c:108
void WriteSingleOutputFunctionBlif(DdManager *dd, DdNode *aFunc, char **pNames, int nNames, char *FileName)
Definition casCore.c:769
#define MAXINPUTS
INCLUDES ///.
Definition cas.h:38
#define MAXOUTPUTS
Definition cas.h:39
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
char * Extra_UtilStrsav(const char *s)
char * sprintf()
char * strcpy()
char * strcat()
Here is the call graph for this function:

◆ CompareMinterms()

int CompareMinterms ( int * ptrX,
int * ptrY )

Definition at line 474 of file casCore.c.

475{
476 return ( s_MintOnes[*ptrY] - s_MintOnes[*ptrX] );
477}

◆ CompareSupports()

int CompareSupports ( int * ptrX,
int * ptrY )

Definition at line 465 of file casCore.c.

466{
467 return ( s_SuppSize[*ptrY] - s_SuppSize[*ptrX] );
468}
Here is the caller graph for this function:

◆ CreateDecomposedNetwork()

int CreateDecomposedNetwork ( DdManager * dd,
DdNode * aFunc,
char ** pNames,
int nNames,
char * FileName,
int nLutSize,
int fCheck,
int fVerbose )
extern

EXTERNAL FUNCTIONS ///.

Definition at line 108 of file casDec.c.

113{
114 static LUT * pLuts[MAXINPUTS]; // the LUT cascade
115 static int Profile[MAXINPUTS]; // the profile filled in with the info about the BDD width
116 static int Permute[MAXINPUTS]; // the array to store a temporary permutation of variables
117
118 LUT * p; // the current LUT
119 int i, v;
120
121 DdNode * bCVars[32]; // these are variables for the codes
122
123 int nVarsRem; // the number of remaining variables
124 int PrevMulti; // column multiplicity on the previous level
125 int fLastLut; // flag to signal the last LUT
126 int nLuts;
127 int nLutsTotal = 0;
128 int nLutOutputs = 0;
129 int nLutOutputsOrig = 0;
130
131 abctime clk1;
132
133 s_LutSize = nLutSize;
134
135 s_nFuncVars = nNames;
136
137 // get the profile
138 clk1 = Abc_Clock();
139 Extra_ProfileWidth( dd, aFunc, Profile, -1 );
140
141
142// for ( v = 0; v < nNames; v++ )
143// printf( "Level = %2d, Width = %2d\n", v+1, Profile[v] );
144
145
146//printf( "\n" );
147
148 // mark-up the LUTs
149 // assuming that the manager has exactly nNames vars (new vars have not been introduced yet)
150 nVarsRem = nNames; // the number of remaining variables
151 PrevMulti = 0; // column multiplicity on the previous level
152 fLastLut = 0;
153 nLuts = 0;
154 do
155 {
156 p = (LUT*) ABC_ALLOC( char, sizeof(LUT) );
157 memset( p, 0, sizeof(LUT) );
158
159 if ( nVarsRem + PrevMulti <= s_LutSize ) // this is the last LUT
160 {
161 p->nIns = nVarsRem + PrevMulti;
162 p->nInsP = PrevMulti;
163 p->nCols = 2;
164 p->nMulti = 1;
165 p->Level = nNames-nVarsRem;
166
167 nVarsRem = 0;
168 PrevMulti = 1;
169
170 fLastLut = 1;
171 }
172 else // this is not the last LUT
173 {
174 p->nIns = s_LutSize;
175 p->nInsP = PrevMulti;
176 p->nCols = Profile[nNames-(nVarsRem-(s_LutSize-PrevMulti))];
177 p->nMulti = Abc_Base2Log(p->nCols);
178 p->Level = nNames-nVarsRem;
179
180 nVarsRem = nVarsRem-(s_LutSize-PrevMulti);
181 PrevMulti = p->nMulti;
182 }
183
184 if ( p->nMulti >= s_LutSize )
185 {
186 printf( "The LUT size is too small\n" );
187 return 0;
188 }
189
190 nLutOutputsOrig += p->nMulti;
191
192
193//if ( fVerbose )
194//printf( "Stage %2d: In = %3d, InP = %3d, Cols = %5d, Multi = %2d, Level = %2d\n",
195// nLuts+1, p->nIns, p->nInsP, p->nCols, p->nMulti, p->Level );
196
197
198 // there should be as many columns, codes, and nodes, as there are columns on this level
199 p->pbCols = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) );
200 p->pbCodes = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) );
201 p->paNodes = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) );
202
203 pLuts[nLuts] = p;
204 nLuts++;
205 }
206 while ( !fLastLut );
207
208
209//if ( fVerbose )
210//printf( "The number of cascades = %d\n", nLuts );
211
212
213//fprintf( pTable, "%d ", nLuts );
214
215
216 // add the new variables at the bottom
217 for ( i = 0; i < s_LutSize; i++ )
218 bCVars[i] = Cudd_bddNewVar(dd);
219
220 // for each LUT - assign the LUT and encode the columns
221 s_EncodingTime = 0;
222 for ( i = 0; i < nLuts; i++ )
223 {
224 int RetValue;
225 DdNode * bVars[32];
226 int nVars;
227 DdNode * bVarsInCube;
228 DdNode * bVarsCCube;
229 DdNode * bVarsCube;
230 int CutLevel;
231
232 p = pLuts[i];
233
234 // compute the columns of this LUT starting from the given set of nodes with the given codes
235 // (these codes have been remapped to depend on the topmost variables in the manager)
236 // for the first LUT, start with the constant 1 BDD
237 CutLevel = p->Level + p->nIns - p->nInsP;
238 if ( i == 0 )
240 dd, &aFunc, &(b1), 1,
241 p->paNodes, p->pbCols, CutLevel );
242 else
244 dd, pLuts[i-1]->paNodes, pLuts[i-1]->pbCodes, pLuts[i-1]->nCols,
245 p->paNodes, p->pbCols, CutLevel );
246 assert( RetValue == p->nCols );
247 // at this point, we have filled out p->paNodes[] and p->pbCols[] of this LUT
248 // pLuts[i-1]->paNodes depended on normal vars
249 // pLuts[i-1]->pbCodes depended on the topmost variables
250 // the resulting p->paNodes depend on normal ADD nodes
251 // the resulting p->pbCols depend on normal vars and topmost variables in the manager
252
253 // perform the encoding
254
255 // create the cube of these variables
256 // collect the topmost variables of the manager
257 nVars = p->nInsP;
258 for ( v = 0; v < nVars; v++ )
259 bVars[v] = dd->vars[ dd->invperm[v] ];
260 bVarsCCube = Extra_bddBitsToCube( dd, (1<<nVars)-1, nVars, bVars, 1 ); Cudd_Ref( bVarsCCube );
261
262 // collect the primary input variables involved in this LUT
263 nVars = p->nIns - p->nInsP;
264 for ( v = 0; v < nVars; v++ )
265 bVars[v] = dd->vars[ dd->invperm[p->Level+v] ];
266 bVarsInCube = Extra_bddBitsToCube( dd, (1<<nVars)-1, nVars, bVars, 1 ); Cudd_Ref( bVarsInCube );
267
268 // get the cube
269 bVarsCube = Cudd_bddAnd( dd, bVarsInCube, bVarsCCube ); Cudd_Ref( bVarsCube );
270 Cudd_RecursiveDeref( dd, bVarsInCube );
271 Cudd_RecursiveDeref( dd, bVarsCCube );
272
273 // get the encoding relation
274 if ( i == nLuts -1 )
275 {
276 DdNode * bVar;
277 assert( p->nMulti == 1 );
278 assert( p->nCols == 2 );
279 assert( Cudd_IsConstant( p->paNodes[0] ) );
280 assert( Cudd_IsConstant( p->paNodes[1] ) );
281
282 bVar = ( p->paNodes[0] == a1 )? bCVars[0]: Cudd_Not( bCVars[0] );
283 p->bRelation = Cudd_bddIte( dd, bVar, p->pbCols[0], p->pbCols[1] ); Cudd_Ref( p->bRelation );
284 }
285 else
286 {
287 abctime clk2 = Abc_Clock();
288// p->bRelation = PerformTheEncoding( dd, p->pbCols, p->nCols, bVarsCube, bCVars, p->nMulti, &p->nSimple ); Cudd_Ref( p->bRelation );
289 p->bRelation = Extra_bddEncodingNonStrict( dd, p->pbCols, p->nCols, bVarsCube, bCVars, p->nMulti, &p->nSimple ); Cudd_Ref( p->bRelation );
290 s_EncodingTime += Abc_Clock() - clk2;
291 }
292
293 // update the number of LUT outputs
294 nLutOutputs += (p->nMulti - p->nSimple);
295 nLutsTotal += p->nMulti;
296
297//if ( fVerbose )
298//printf( "Stage %2d: Simple = %d\n", i+1, p->nSimple );
299
300if ( fVerbose )
301printf( "Stage %3d: In = %3d InP = %3d Cols = %5d Multi = %2d Simple = %2d Level = %3d\n",
302 i+1, p->nIns, p->nInsP, p->nCols, p->nMulti, p->nSimple, p->Level );
303
304 // get the codes from the relation (these are not necessarily cubes)
305 {
306 int c;
307 for ( c = 0; c < p->nCols; c++ )
308 {
309 p->pbCodes[c] = Cudd_bddAndAbstract( dd, p->bRelation, p->pbCols[c], bVarsCube ); Cudd_Ref( p->pbCodes[c] );
310 }
311 }
312
313 Cudd_RecursiveDeref( dd, bVarsCube );
314
315 // remap the codes to depend on the topmost varibles of the manager
316 // useful as a preparation for the next step
317 {
318 DdNode ** pbTemp;
319 int k, v;
320
321 pbTemp = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) );
322
323 // create the identical permutation
324 for ( v = 0; v < dd->size; v++ )
325 Permute[v] = v;
326
327 // use the topmost variables of the manager
328 // to represent the previous level codes
329 for ( v = 0; v < p->nMulti; v++ )
330 Permute[bCVars[v]->index] = dd->invperm[v];
331
332 Extra_bddPermuteArray( dd, p->pbCodes, pbTemp, p->nCols, Permute );
333 // the array pbTemp comes already referenced
334
335 // deref the old codes and assign the new ones
336 for ( k = 0; k < p->nCols; k++ )
337 {
338 Cudd_RecursiveDeref( dd, p->pbCodes[k] );
339 p->pbCodes[k] = pbTemp[k];
340 }
341 ABC_FREE( pbTemp );
342 }
343 }
344 if ( fVerbose )
345 printf( "LUTs: Total = %5d. Final = %5d. Simple = %5d. (%6.2f %%) ",
346 nLutsTotal, nLutOutputs, nLutsTotal-nLutOutputs, 100.0*(nLutsTotal-nLutOutputs)/nLutsTotal );
347 if ( fVerbose )
348 printf( "Memory = %6.2f MB\n", 1.0*nLutOutputs*(1<<nLutSize)/(1<<20) );
349// printf( "\n" );
350
351//fprintf( pTable, "%d ", nLutOutputsOrig );
352//fprintf( pTable, "%d ", nLutOutputs );
353
354 if ( fVerbose )
355 {
356 printf( "Pure decomposition time = %.2f sec\n", (float)(Abc_Clock() - clk1 - s_EncodingTime)/(float)(CLOCKS_PER_SEC) );
357 printf( "Encoding time = %.2f sec\n", (float)(s_EncodingTime)/(float)(CLOCKS_PER_SEC) );
358// printf( "Encoding search time = %.2f sec\n", (float)(s_EncSearchTime)/(float)(CLOCKS_PER_SEC) );
359// printf( "Encoding compute time = %.2f sec\n", (float)(s_EncComputeTime)/(float)(CLOCKS_PER_SEC) );
360 }
361
362
363//fprintf( pTable, "%.2f ", (float)(s_ReadingTime)/(float)(CLOCKS_PER_SEC) );
364//fprintf( pTable, "%.2f ", (float)(Abc_Clock() - clk1 - s_EncodingTime)/(float)(CLOCKS_PER_SEC) );
365//fprintf( pTable, "%.2f ", (float)(s_EncodingTime)/(float)(CLOCKS_PER_SEC) );
366//fprintf( pTable, "%.2f ", (float)(s_RemappingTime)/(float)(CLOCKS_PER_SEC) );
367
368
369 // write LUTs into the BLIF file
370 clk1 = Abc_Clock();
371 if ( fCheck )
372 {
373 FILE * pFile;
374 // start the file
375 pFile = fopen( FileName, "w" );
376 fprintf( pFile, ".model %s\n", FileName );
377
378 fprintf( pFile, ".inputs" );
379 for ( i = 0; i < nNames; i++ )
380 fprintf( pFile, " %s", pNames[i] );
381 fprintf( pFile, "\n" );
382 fprintf( pFile, ".outputs F" );
383 fprintf( pFile, "\n" );
384
385 // write the DD into the file
386 WriteLUTSintoBLIFfile( pFile, dd, pLuts, nLuts, bCVars, pNames, nNames, FileName );
387
388 fprintf( pFile, ".end\n" );
389 fclose( pFile );
390 if ( fVerbose )
391 printf( "Output file writing time = %.2f sec\n", (float)(Abc_Clock() - clk1)/(float)(CLOCKS_PER_SEC) );
392 }
393
394
395 // updo the LUT cascade
396 for ( i = 0; i < nLuts; i++ )
397 {
398 p = pLuts[i];
399 for ( v = 0; v < p->nCols; v++ )
400 {
401 Cudd_RecursiveDeref( dd, p->pbCols[v] );
402 Cudd_RecursiveDeref( dd, p->pbCodes[v] );
403 Cudd_RecursiveDeref( dd, p->paNodes[v] );
404 }
405 Cudd_RecursiveDeref( dd, p->bRelation );
406
407 ABC_FREE( p->pbCols );
408 ABC_FREE( p->pbCodes );
409 ABC_FREE( p->paNodes );
410 ABC_FREE( p );
411 }
412
413 return 1;
414}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define b1
Definition bbrImage.c:97
long s_EncodingTime
Definition casDec.c:83
void WriteLUTSintoBLIFfile(FILE *pFile, DdManager *dd, LUT **pLuts, int nLuts, DdNode **bCVars, char **pNames, int nNames, char *FileName)
static functions ///
Definition casDec.c:416
DdNode * Extra_bddBitsToCube(DdManager *dd, int Code, int CodeWidth, DdNode **pbVars, int fMsbFirst)
void Extra_bddPermuteArray(DdManager *dd, DdNode **bNodesIn, DdNode **bNodesOut, int nNodes, int *permut)
int Extra_ProfileWidth(DdManager *dd, DdNode *F, int *Profile, int CutLevel)
int Extra_bddNodePathsUnderCutArray(DdManager *dd, DdNode **paNodes, DdNode **pbCubes, int nNodes, DdNode **paNodesRes, DdNode **pbCubesRes, int CutLevel)
#define a1
Definition extraBdd.h:80
DdNode * Extra_bddEncodingNonStrict(DdManager *dd, DdNode **pbColumns, int nColumns, DdNode *bVarsCol, DdNode **pCVars, int nMulti, int *pSimple)
type definitions ///
Definition casDec.c:36
#define assert(ex)
Definition util_old.h:213
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cudd_bddTransferPermute()

DdNode * Cudd_bddTransferPermute ( DdManager * ddSource,
DdManager * ddDestination,
DdNode * f,
int * Permute )

Function********************************************************************

Synopsis [Convert a BDD from a manager to another one.]

Description [Convert a BDD from a manager to another one. The orders of the variables in the two managers may be different. Returns a pointer to the BDD in the destination manager if successful; NULL otherwise. The i-th entry in the array Permute tells what is the index of the i-th variable from the old manager in the new manager.]

SideEffects [None]

SeeAlso []

Definition at line 1082 of file casCore.c.

1084{
1085 DdNode *res;
1086 do
1087 {
1088 ddDestination->reordered = 0;
1089 res = cuddBddTransferPermute( ddSource, ddDestination, f, Permute );
1090 }
1091 while ( ddDestination->reordered == 1 );
1092 return ( res );
1093
1094} /* end of Cudd_bddTransferPermute */
DdNode * cuddBddTransferPermute(DdManager *ddS, DdManager *ddD, DdNode *f, int *Permute)
Definition casCore.c:1116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cuddBddTransferPermute()

DdNode * cuddBddTransferPermute ( DdManager * ddS,
DdManager * ddD,
DdNode * f,
int * Permute )

Function********************************************************************

Synopsis [Convert a BDD from a manager to another one.]

Description [Convert a BDD from a manager to another one. Returns a pointer to the BDD in the destination manager if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddTransferPermute]

Definition at line 1116 of file casCore.c.

1117{
1118 DdNode *res;
1119 st__table *table = NULL;
1120 st__generator *gen = NULL;
1121 DdNode *key, *value;
1122
1124 if ( table == NULL )
1125 goto failure;
1126 res = cuddBddTransferPermuteRecur( ddS, ddD, f, table, Permute );
1127 if ( res != NULL )
1128 cuddRef( res );
1129
1130 /* Dereference all elements in the table and dispose of the table.
1131 ** This must be done also if res is NULL to avoid leaks in case of
1132 ** reordering. */
1133 gen = st__init_gen( table );
1134 if ( gen == NULL )
1135 goto failure;
1136 while ( st__gen( gen, ( const char ** ) &key, ( char ** ) &value ) )
1137 {
1138 Cudd_RecursiveDeref( ddD, value );
1139 }
1140 st__free_gen( gen );
1141 gen = NULL;
1142 st__free_table( table );
1143 table = NULL;
1144
1145 if ( res != NULL )
1146 cuddDeref( res );
1147 return ( res );
1148
1149 failure:
1150 if ( table != NULL )
1151 st__free_table( table );
1152 if ( gen != NULL )
1153 st__free_gen( gen );
1154 return ( NULL );
1155
1156} /* end of cuddBddTransferPermute */
ABC_NAMESPACE_IMPL_START typedef signed char value
enum keys key
Definition main.h:25
int st__gen(st__generator *gen, const char **key_p, char **value_p)
Definition st.c:501
int st__ptrhash(const char *, int)
Definition st.c:467
int st__ptrcmp(const char *, const char *)
Definition st.c:479
void st__free_gen(st__generator *gen)
Definition st.c:555
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition st.c:72
st__generator * st__init_gen(st__table *table)
Definition st.c:485
void st__free_table(st__table *table)
Definition st.c:81
Definition st.h:52
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSingleOutputFunction()

DdNode * GetSingleOutputFunction ( DdManager * dd,
DdNode ** pbOuts,
int nOuts,
DdNode ** pbVarsEnc,
int nVarsEnc,
int fVerbose )

static functions ///

CFile****************************************************************

FileName [casCore.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [CASCADE: Decomposition of shared BDDs into a LUT cascade.]

Synopsis [Entrance into the implementation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Spring 2002.]

Revision [

Id
casCore.c,v 1.0 2002/01/01 00:00:00 alanmi Exp

]

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 496 of file casCore.c.

497{
498 int i;
499 DdNode * bResult, * aResult;
500 DdNode * bCube, * bTemp, * bProd;
501
502 int Order[MAXOUTPUTS];
503// int OrderMint[MAXOUTPUTS];
504
505 // sort the output according to their support size
506 for ( i = 0; i < nOuts; i++ )
507 {
508 s_SuppSize[i] = Cudd_SupportSize( dd, pbOuts[i] );
509// s_MintOnes[i] = BitCount8[i];
510 Order[i] = i;
511// OrderMint[i] = i;
512 }
513
514 // order the outputs
515 qsort( (void*)Order, (size_t)nOuts, sizeof(int), (int(*)(const void*, const void*)) CompareSupports );
516 // order the outputs
517// qsort( (void*)OrderMint, (size_t)nOuts, sizeof(int), (int(*)(const void*, const void*)) CompareMinterms );
518
519
520 bResult = b0; Cudd_Ref( bResult );
521 for ( i = 0; i < nOuts; i++ )
522 {
523// bCube = Cudd_bddBitsToCube( dd, OrderMint[i], nVarsEnc, pbVarsEnc ); Cudd_Ref( bCube );
524// bProd = Cudd_bddAnd( dd, bCube, pbOuts[Order[nOuts-1-i]] ); Cudd_Ref( bProd );
525 bCube = Extra_bddBitsToCube( dd, i, nVarsEnc, pbVarsEnc, 1 ); Cudd_Ref( bCube );
526 bProd = Cudd_bddAnd( dd, bCube, pbOuts[Order[i]] ); Cudd_Ref( bProd );
527 Cudd_RecursiveDeref( dd, bCube );
528
529 bResult = Cudd_bddOr( dd, bProd, bTemp = bResult ); Cudd_Ref( bResult );
530 Cudd_RecursiveDeref( dd, bTemp );
531 Cudd_RecursiveDeref( dd, bProd );
532 }
533
534 // convert to the ADD
535if ( fVerbose )
536printf( "Single BDD size = %6d nodes\n", Cudd_DagSize(bResult) );
537 aResult = Cudd_BddToAdd( dd, bResult ); Cudd_Ref( aResult );
538 Cudd_RecursiveDeref( dd, bResult );
539if ( fVerbose )
540printf( "MTBDD = %6d nodes\n", Cudd_DagSize(aResult) );
541 Cudd_Deref( aResult );
542 return aResult;
543}
#define b0
Definition bbrImage.c:96
int CompareSupports(int *ptrX, int *ptrY)
Definition casCore.c:465
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSingleOutputFunctionRemapped()

DdNode * GetSingleOutputFunctionRemapped ( DdManager * dd,
DdNode ** pOutputs,
int nOuts,
DdNode ** pbVarsEnc,
int nVarsEnc )

INPUT REMAPPING ///.

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 590 of file casCore.c.

592{
593 static int Permute[MAXINPUTS];
594 static DdNode * pRemapped[MAXOUTPUTS];
595
596 DdNode * bSupp, * bTemp;
597 int i, Counter;
598 DdNode * bFunc;
599 DdNode * aFunc;
600
601 Cudd_AutodynDisable(dd);
602
603 // perform the remapping
604 for ( i = 0; i < nOuts; i++ )
605 {
606 // get support
607 bSupp = Cudd_Support( dd, pOutputs[i] ); Cudd_Ref( bSupp );
608
609 // create the variable map
610 Counter = 0;
611 for ( bTemp = bSupp; bTemp != dd->one; bTemp = cuddT(bTemp) )
612 Permute[bTemp->index] = Counter++;
613
614 // transfer the BDD and remap it
615 pRemapped[i] = Cudd_bddPermute( dd, pOutputs[i], Permute ); Cudd_Ref( pRemapped[i] );
616
617 // remove support
618 Cudd_RecursiveDeref( dd, bSupp );
619 }
620
621 // perform the encoding
622 bFunc = Extra_bddEncodingBinary( dd, pRemapped, nOuts, pbVarsEnc, nVarsEnc ); Cudd_Ref( bFunc );
623
624 // convert to ADD
625 aFunc = Cudd_BddToAdd( dd, bFunc ); Cudd_Ref( aFunc );
626 Cudd_RecursiveDeref( dd, bFunc );
627
628 // deref the intermediate results
629 for ( i = 0; i < nOuts; i++ )
630 Cudd_RecursiveDeref( dd, pRemapped[i] );
631
632 Cudd_Deref( aFunc );
633 return aFunc;
634}
DdNode * Extra_bddEncodingBinary(DdManager *dd, DdNode **pbFuncs, int nFuncs, DdNode **pbVars, int nVars)
Here is the call graph for this function:

◆ GetSingleOutputFunctionRemappedNewDD()

DdNode * GetSingleOutputFunctionRemappedNewDD ( DdManager * dd,
DdNode ** pOutputs,
int nOuts,
DdManager ** DdNew )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 648 of file casCore.c.

650{
651 static int Permute[MAXINPUTS];
652 static DdNode * pRemapped[MAXOUTPUTS];
653
654 static DdNode * pbVarsEnc[MAXINPUTS];
655 int nVarsEnc;
656
657 DdManager * ddnew;
658
659 DdNode * bSupp, * bTemp;
660 int i, v, Counter;
661 DdNode * bFunc;
662
663 // these are in the new manager
664 DdNode * bFuncNew;
665 DdNode * aFuncNew;
666
667 int nVarsMax = 0;
668
669 // perform the remapping and write the DDs into the new manager
670 for ( i = 0; i < nOuts; i++ )
671 {
672 // get support
673 bSupp = Cudd_Support( dd, pOutputs[i] ); Cudd_Ref( bSupp );
674
675 // create the variable map
676 // to remap the DD into the upper part of the manager
677 Counter = 0;
678 for ( bTemp = bSupp; bTemp != dd->one; bTemp = cuddT(bTemp) )
679 Permute[bTemp->index] = dd->invperm[Counter++];
680
681 // transfer the BDD and remap it
682 pRemapped[i] = Cudd_bddPermute( dd, pOutputs[i], Permute ); Cudd_Ref( pRemapped[i] );
683
684 // remove support
685 Cudd_RecursiveDeref( dd, bSupp );
686
687
688 // determine the largest support size
689 if ( nVarsMax < Counter )
690 nVarsMax = Counter;
691 }
692
693 // select the encoding variables to follow immediately after the original variables
694 nVarsEnc = Abc_Base2Log(nOuts);
695/*
696 for ( v = 0; v < nVarsEnc; v++ )
697 if ( nVarsMax + v < dd->size )
698 pbVarsEnc[v] = dd->var[ dd->invperm[nVarsMax+v] ];
699 else
700 pbVarsEnc[v] = Cudd_bddNewVar( dd );
701*/
702 // create the new variables on top of the manager
703 for ( v = 0; v < nVarsEnc; v++ )
704 pbVarsEnc[v] = Cudd_bddNewVarAtLevel( dd, v );
705
706//fprintf( pTable, "%d ", Cudd_SharingSize( pRemapped, nOuts ) );
707//fprintf( pTable, "%d ", Extra_ProfileWidthSharingMax(dd, pRemapped, nOuts) );
708
709
710 // perform the encoding
711 bFunc = Extra_bddEncodingBinary( dd, pRemapped, nOuts, pbVarsEnc, nVarsEnc ); Cudd_Ref( bFunc );
712
713
714 // find the cross-manager permutation
715 // the variable from the level v in the old manager
716 // should become a variable number v in the new manager
717 for ( v = 0; v < nVarsMax + nVarsEnc; v++ )
718 Permute[dd->invperm[v]] = v;
719
720
722 // start the new manager
723 ddnew = Cudd_Init( nVarsMax + nVarsEnc, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0);
724// Cudd_AutodynDisable(ddnew);
725 Cudd_AutodynEnable(dd, CUDD_REORDER_SYMM_SIFT);
726
727 // transfer it to the new manager
728 bFuncNew = Cudd_bddTransferPermute( dd, ddnew, bFunc, Permute ); Cudd_Ref( bFuncNew );
730
731
732 // deref the intermediate results in the old manager
733 Cudd_RecursiveDeref( dd, bFunc );
734 for ( i = 0; i < nOuts; i++ )
735 Cudd_RecursiveDeref( dd, pRemapped[i] );
736
737
739 // convert to ADD in the new manager
740 aFuncNew = Cudd_BddToAdd( ddnew, bFuncNew ); Cudd_Ref( aFuncNew );
741 Cudd_RecursiveDeref( ddnew, bFuncNew );
742
743 // return the manager
744 *DdNew = ddnew;
746
747 Cudd_Deref( aFuncNew );
748 return aFuncNew;
749}
DdNode * Cudd_bddTransferPermute(DdManager *ddSource, DdManager *ddDestination, DdNode *f, int *Permute)
Definition casCore.c:1082
Here is the call graph for this function:

◆ GrayCode()

int GrayCode ( int BinCode)

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 480 of file casCore.c.

481{
482 return BinCode ^ ( BinCode >> 1 );
483}
Here is the caller graph for this function:

◆ WriteDDintoBLIFfile()

void WriteDDintoBLIFfile ( FILE * pFile,
DdNode * Func,
char * OutputName,
char * Prefix,
char ** InputNames )

BLIF WRITING FUNCTIONS ///.

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 803 of file casCore.c.

810{
811 int i;
812 st__table * visited;
813 st__generator * gen = NULL;
814 long refAddr, diff, mask;
815 DdNode * Node, * Else, * ElseR, * Then;
816
817 /* Initialize symbol table for visited nodes. */
819
820 /* Collect all the nodes of this DD in the symbol table. */
821 cuddCollectNodes( Cudd_Regular(Func), visited );
822
823 /* Find how many most significant hex digits are identical
824 ** in the addresses of all the nodes. Build a mask based
825 ** on this knowledge, so that digits that carry no information
826 ** will not be printed. This is done in two steps.
827 ** 1. We scan the symbol table to find the bits that differ
828 ** in at least 2 addresses.
829 ** 2. We choose one of the possible masks. There are 8 possible
830 ** masks for 32-bit integer, and 16 possible masks for 64-bit
831 ** integers.
832 */
833
834 /* Find the bits that are different. */
835 refAddr = ( long )Cudd_Regular(Func);
836 diff = 0;
837 gen = st__init_gen( visited );
838 while ( st__gen( gen, ( const char ** ) &Node, NULL ) )
839 {
840 diff |= refAddr ^ ( long ) Node;
841 }
842 st__free_gen( gen );
843 gen = NULL;
844
845 /* Choose the mask. */
846 for ( i = 0; ( unsigned ) i < 8 * sizeof( long ); i += 4 )
847 {
848 mask = ( 1 << i ) - 1;
849 if ( diff <= mask )
850 break;
851 }
852
853
854 // write the buffer for the output
855 fprintf( pFile, ".names %s%lx %s\n", Prefix, ( mask & (long)Cudd_Regular(Func) ) / sizeof(DdNode), OutputName );
856 fprintf( pFile, "%s 1\n", (Cudd_IsComplement(Func))? "0": "1" );
857
858
859 gen = st__init_gen( visited );
860 while ( st__gen( gen, ( const char ** ) &Node, NULL ) )
861 {
862 if ( Node->index == CUDD_MAXINDEX )
863 {
864 // write the terminal node
865 fprintf( pFile, ".names %s%lx\n", Prefix, ( mask & (long)Node ) / sizeof(DdNode) );
866 fprintf( pFile, " %s\n", (cuddV(Node) == 0.0)? "0": "1" );
867 continue;
868 }
869
870 Else = cuddE(Node);
871 ElseR = Cudd_Regular(Else);
872 Then = cuddT(Node);
873
874 assert( InputNames[Node->index] );
875 if ( Else == ElseR )
876 { // no inverter
877 fprintf( pFile, ".names %s %s%lx %s%lx %s%lx\n", InputNames[Node->index],
878 Prefix, ( mask & (long)ElseR ) / sizeof(DdNode),
879 Prefix, ( mask & (long)Then ) / sizeof(DdNode),
880 Prefix, ( mask & (long)Node ) / sizeof(DdNode) );
881 fprintf( pFile, "01- 1\n" );
882 fprintf( pFile, "1-1 1\n" );
883 }
884 else
885 { // inverter
886 int * pSlot;
887 fprintf( pFile, ".names %s %s%lx_i %s%lx %s%lx\n", InputNames[Node->index],
888 Prefix, ( mask & (long)ElseR ) / sizeof(DdNode),
889 Prefix, ( mask & (long)Then ) / sizeof(DdNode),
890 Prefix, ( mask & (long)Node ) / sizeof(DdNode) );
891 fprintf( pFile, "01- 1\n" );
892 fprintf( pFile, "1-1 1\n" );
893
894 // if the inverter is written, skip
895 if ( ! st__find( visited, (char *)ElseR, (char ***)&pSlot ) )
896 assert( 0 );
897 if ( *pSlot )
898 continue;
899 *pSlot = 1;
900
901 fprintf( pFile, ".names %s%lx %s%lx_i\n",
902 Prefix, ( mask & (long)ElseR ) / sizeof(DdNode),
903 Prefix, ( mask & (long)ElseR ) / sizeof(DdNode) );
904 fprintf( pFile, "0 1\n" );
905 }
906 }
907 st__free_gen( gen );
908 gen = NULL;
909 st__free_table( visited );
910}
int st__find(st__table *table, char *key, char ***slot)
Definition st.c:264
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteDDintoBLIFfileReorder()

void WriteDDintoBLIFfileReorder ( DdManager * dd,
FILE * pFile,
DdNode * Func,
char * OutputName,
char * Prefix,
char ** InputNames )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 928 of file casCore.c.

935{
936 int i;
937 st__table * visited;
938 st__generator * gen = NULL;
939 long refAddr, diff, mask;
940 DdNode * Node, * Else, * ElseR, * Then;
941
942
944 DdNode * bFmin;
945 abctime clk1;
946
947 if ( s_ddmin == NULL )
948 s_ddmin = Cudd_Init( dd->size, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0);
949
950 clk1 = Abc_Clock();
951 bFmin = Cudd_bddTransfer( dd, s_ddmin, Func ); Cudd_Ref( bFmin );
952
953 // reorder
954 printf( "Nodes before = %d. ", Cudd_DagSize(bFmin) );
955 Cudd_ReduceHeap(s_ddmin,CUDD_REORDER_SYMM_SIFT,1);
956// Cudd_ReduceHeap(s_ddmin,CUDD_REORDER_SYMM_SIFT_CONV,1);
957 printf( "Nodes after = %d. \n", Cudd_DagSize(bFmin) );
959
960
961
962 /* Initialize symbol table for visited nodes. */
964
965 /* Collect all the nodes of this DD in the symbol table. */
966 cuddCollectNodes( Cudd_Regular(bFmin), visited );
967
968 /* Find how many most significant hex digits are identical
969 ** in the addresses of all the nodes. Build a mask based
970 ** on this knowledge, so that digits that carry no information
971 ** will not be printed. This is done in two steps.
972 ** 1. We scan the symbol table to find the bits that differ
973 ** in at least 2 addresses.
974 ** 2. We choose one of the possible masks. There are 8 possible
975 ** masks for 32-bit integer, and 16 possible masks for 64-bit
976 ** integers.
977 */
978
979 /* Find the bits that are different. */
980 refAddr = ( long )Cudd_Regular(bFmin);
981 diff = 0;
982 gen = st__init_gen( visited );
983 while ( st__gen( gen, ( const char ** ) &Node, NULL ) )
984 {
985 diff |= refAddr ^ ( long ) Node;
986 }
987 st__free_gen( gen );
988 gen = NULL;
989
990 /* Choose the mask. */
991 for ( i = 0; ( unsigned ) i < 8 * sizeof( long ); i += 4 )
992 {
993 mask = ( 1 << i ) - 1;
994 if ( diff <= mask )
995 break;
996 }
997
998
999 // write the buffer for the output
1000 fprintf( pFile, ".names %s%lx %s\n", Prefix, ( mask & (long)Cudd_Regular(bFmin) ) / sizeof(DdNode), OutputName );
1001 fprintf( pFile, "%s 1\n", (Cudd_IsComplement(bFmin))? "0": "1" );
1002
1003
1004 gen = st__init_gen( visited );
1005 while ( st__gen( gen, ( const char ** ) &Node, NULL ) )
1006 {
1007 if ( Node->index == CUDD_MAXINDEX )
1008 {
1009 // write the terminal node
1010 fprintf( pFile, ".names %s%lx\n", Prefix, ( mask & (long)Node ) / sizeof(DdNode) );
1011 fprintf( pFile, " %s\n", (cuddV(Node) == 0.0)? "0": "1" );
1012 continue;
1013 }
1014
1015 Else = cuddE(Node);
1016 ElseR = Cudd_Regular(Else);
1017 Then = cuddT(Node);
1018
1019 assert( InputNames[Node->index] );
1020 if ( Else == ElseR )
1021 { // no inverter
1022 fprintf( pFile, ".names %s %s%lx %s%lx %s%lx\n", InputNames[Node->index],
1023 Prefix, ( mask & (long)ElseR ) / sizeof(DdNode),
1024 Prefix, ( mask & (long)Then ) / sizeof(DdNode),
1025 Prefix, ( mask & (long)Node ) / sizeof(DdNode) );
1026 fprintf( pFile, "01- 1\n" );
1027 fprintf( pFile, "1-1 1\n" );
1028 }
1029 else
1030 { // inverter
1031 fprintf( pFile, ".names %s %s%lx_i %s%lx %s%lx\n", InputNames[Node->index],
1032 Prefix, ( mask & (long)ElseR ) / sizeof(DdNode),
1033 Prefix, ( mask & (long)Then ) / sizeof(DdNode),
1034 Prefix, ( mask & (long)Node ) / sizeof(DdNode) );
1035 fprintf( pFile, "01- 1\n" );
1036 fprintf( pFile, "1-1 1\n" );
1037
1038 fprintf( pFile, ".names %s%lx %s%lx_i\n",
1039 Prefix, ( mask & (long)ElseR ) / sizeof(DdNode),
1040 Prefix, ( mask & (long)ElseR ) / sizeof(DdNode) );
1041 fprintf( pFile, "0 1\n" );
1042 }
1043 }
1044 st__free_gen( gen );
1045 gen = NULL;
1046 st__free_table( visited );
1047
1048
1050 Cudd_RecursiveDeref( s_ddmin, bFmin );
1052}
Here is the call graph for this function:

◆ WriteSingleOutputFunctionBlif()

void WriteSingleOutputFunctionBlif ( DdManager * dd,
DdNode * aFunc,
char ** pNames,
int nNames,
char * FileName )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 769 of file casCore.c.

770{
771 int i;
772 FILE * pFile;
773
774 // start the file
775 pFile = fopen( FileName, "w" );
776 fprintf( pFile, ".model %s\n", FileName );
777
778 fprintf( pFile, ".inputs" );
779 for ( i = 0; i < nNames; i++ )
780 fprintf( pFile, " %s", pNames[i] );
781 fprintf( pFile, "\n" );
782 fprintf( pFile, ".outputs F" );
783 fprintf( pFile, "\n" );
784
785 // write the DD into the file
786 WriteDDintoBLIFfile( pFile, aFunc, "F", "", pNames );
787
788 fprintf( pFile, ".end\n" );
789 fclose( pFile );
790}
void WriteDDintoBLIFfile(FILE *pFile, DdNode *Func, char *OutputName, char *Prefix, char **InputNames)
BLIF WRITING FUNCTIONS ///.
Definition casCore.c:803
Here is the call graph for this function:
Here is the caller graph for this function: