abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcRpo.c File Reference
#include "misc/extra/extra.h"
#include "bool/rpo/rpo.h"
#include "bool/rpo/literal.h"

Go to the source code of this file.

Data Structures

struct  Rpo_TtStore_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Rpo_TtStore_t_ 
Rpo_TtStore_t
 

Functions

static int Abc_TruthGetBit (word *p, int i)
 
static void Abc_TruthSetBit (word *p, int i)
 
static void Abc_TruthXorBit (word *p, int i)
 
static int Abc_TruthGetHex (word *p, int k)
 
static void Abc_TruthSetHex (word *p, int k, int d)
 
static void Abc_TruthXorHex (word *p, int k, int d)
 
static int Abc_TruthReadHexDigit (char HexChar)
 FUNCTION DEFINITIONS ///. More...
 
static void Abc_TruthWriteHexDigit (FILE *pFile, int HexDigit)
 
static void Abc_TruthReadHex (word *pTruth, char *pString, int nVars)
 
static void Abc_TruthWriteHex (FILE *pFile, word *pTruth, int nVars)
 
static Rpo_TtStore_tAbc_TruthStoreAlloc (int nVars, int nFuncs)
 
static Rpo_TtStore_tAbc_TruthStoreAlloc2 (int nVars, int nFuncs, word *pBuffer)
 
static void Abc_TtStoreFree (Rpo_TtStore_t *p, int nVarNum)
 
int Abc_FileSize (char *pFileName)
 
char * Abc_FileRead (char *pFileName)
 
void Abc_TruthGetParams (char *pFileName, int *pnVars, int *pnTruths)
 
static void Abc_TruthStoreRead (char *pFileName, Rpo_TtStore_t *p)
 
static void Abc_TtStoreWrite (char *pFileName, Rpo_TtStore_t *p, int fBinary)
 
static Rpo_TtStore_tAbc_TtStoreLoad (char *pFileName, int nVarNum)
 
void Abc_TruthRpoPerform (Rpo_TtStore_t *p, int nThreshold, int fVerbose)
 
void Abc_TruthRpoTest (char *pFileName, int nVarNum, int nThreshold, int fVerbose)
 
int Abc_RpoTest (char *pFileName, int nVarNum, int nThreshold, int fVerbose)
 

Typedef Documentation

typedef typedefABC_NAMESPACE_IMPL_START struct Rpo_TtStore_t_ Rpo_TtStore_t

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

FileName [abcRpo.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Rpo package.]

Synopsis [Procedures for executing RPO.]

Author [Mayler G. A. Martins / Vinicius Callegaro]

Affiliation [UFRGS]

Date [Ver. 1.0. Started - May 08, 2013.]

Revision [

Id:
abcRpo.c,v 1.00 2013/05/08 00:00:00 mgamartins Exp

]

Definition at line 30 of file abcRpo.c.

Function Documentation

char* Abc_FileRead ( char *  pFileName)

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

Synopsis [Read file contents.]

Description []

SideEffects []

SeeAlso []

Definition at line 222 of file abcDec.c.

223 {
224  FILE * pFile;
225  char * pBuffer;
226  int nFileSize, RetValue;
227  pFile = fopen( pFileName, "rb" );
228  if ( pFile == NULL )
229  {
230  printf( "Cannot open file \"%s\" for reading.\n", pFileName );
231  return NULL;
232  }
233  // get the file size, in bytes
234  fseek( pFile, 0, SEEK_END );
235  nFileSize = ftell( pFile );
236  // move the file current reading position to the beginning
237  rewind( pFile );
238  // load the contents of the file into memory
239  pBuffer = (char *)malloc( nFileSize + 3 );
240  RetValue = fread( pBuffer, nFileSize, 1, pFile );
241  // add several empty lines at the end
242  // (these will be used to signal the end of parsing)
243  pBuffer[ nFileSize + 0] = '\n';
244  pBuffer[ nFileSize + 1] = '\n';
245  // terminate the string with '\0'
246  pBuffer[ nFileSize + 2] = '\0';
247  fclose( pFile );
248  return pBuffer;
249 }
char * malloc()
#define SEEK_END
Definition: zconf.h:392
VOID_HACK rewind()
int Abc_FileSize ( char *  pFileName)

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

Synopsis [Read file contents.]

Description []

SideEffects []

SeeAlso []

Definition at line 194 of file abcDec.c.

195 {
196  FILE * pFile;
197  int nFileSize;
198  pFile = fopen( pFileName, "rb" );
199  if ( pFile == NULL )
200  {
201  printf( "Cannot open file \"%s\" for reading.\n", pFileName );
202  return -1;
203  }
204  // get the file size, in bytes
205  fseek( pFile, 0, SEEK_END );
206  nFileSize = ftell( pFile );
207  fclose( pFile );
208  return nFileSize;
209 }
#define SEEK_END
Definition: zconf.h:392
int Abc_RpoTest ( char *  pFileName,
int  nVarNum,
int  nThreshold,
int  fVerbose 
)

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

Synopsis [Testbench for decomposition algorithms.]

Description []

SideEffects []

SeeAlso []

Definition at line 425 of file abcRpo.c.

425  {
426  if (fVerbose) {
427  printf("Using truth tables from file \"%s\"...\n", pFileName);
428  }
429  Abc_TruthRpoTest(pFileName, nVarNum, nThreshold, fVerbose);
430  fflush(stdout);
431  return 0;
432 }
void Abc_TruthRpoTest(char *pFileName, int nVarNum, int nThreshold, int fVerbose)
Definition: abcRpo.c:394
static int Abc_TruthGetBit ( word p,
int  i 
)
inlinestatic

Definition at line 42 of file abcRpo.c.

42  {
43  return (int) (p[i >> 6] >> (i & 63)) & 1;
44 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_TruthGetHex ( word p,
int  k 
)
inlinestatic

Definition at line 56 of file abcRpo.c.

56  {
57  return (int) (p[k >> 4] >> ((k << 2) & 63)) & 15;
58 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Abc_TruthGetParams ( char *  pFileName,
int *  pnVars,
int *  pnTruths 
)

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

Synopsis [Determine the number of variables by reading the first line.]

Description [Determine the number of functions by counting the lines.]

SideEffects []

SeeAlso []

Definition at line 262 of file abcDec.c.

263 {
264  char * pContents;
265  int i, nVars, nLines;
266  // prepare the output
267  if ( pnVars )
268  *pnVars = 0;
269  if ( pnTruths )
270  *pnTruths = 0;
271  // read data from file
272  pContents = Abc_FileRead( pFileName );
273  if ( pContents == NULL )
274  return;
275  // count the number of symbols before the first space or new-line
276  // (note that on Windows symbols '\r' can be inserted before each '\n')
277  for ( i = 0; pContents[i]; i++ )
278  if ( pContents[i] == ' ' || pContents[i] == '\n' || pContents[i] == '\r' )
279  break;
280  if ( pContents[i] == 0 )
281  printf( "Strange, the input file does not have spaces and new-lines...\n" );
282 
283  // acount for the fact that truth tables may have "0x" at the beginning of each line
284  if ( pContents[0] == '0' && pContents[1] == 'x' )
285  i = i - 2;
286 
287  // determine the number of variables
288  for ( nVars = 0; nVars < 32; nVars++ )
289  if ( 4 * i == (1 << nVars) ) // the number of bits equal to the size of truth table
290  break;
291  if ( nVars < 2 || nVars > 16 )
292  {
293  printf( "Does not look like the input file contains truth tables...\n" );
294  return;
295  }
296  if ( pnVars )
297  *pnVars = nVars;
298 
299  // determine the number of functions by counting the lines
300  nLines = 0;
301  for ( i = 0; pContents[i]; i++ )
302  nLines += (pContents[i] == '\n');
303  if ( pnTruths )
304  *pnTruths = nLines;
305  ABC_FREE( pContents );
306 }
char * Abc_FileRead(char *pFileName)
Definition: abcDec.c:222
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Abc_TruthReadHex ( word pTruth,
char *  pString,
int  nVars 
)
static

Definition at line 97 of file abcRpo.c.

97  {
98  int nWords = (nVars < 7) ? 1 : (1 << (nVars - 6));
99  int k, Digit, nDigits = (nWords << 4);
100  char EndSymbol;
101  // skip the first 2 symbols if they are "0x"
102  if (pString[0] == '0' && pString[1] == 'x')
103  pString += 2;
104  // get the last symbol
105  EndSymbol = pString[nDigits];
106  // the end symbol of the TT (the one immediately following hex digits)
107  // should be one of the following: space, a new-line, or a zero-terminator
108  // (note that on Windows symbols '\r' can be inserted before each '\n')
109  assert(EndSymbol == ' ' || EndSymbol == '\n' || EndSymbol == '\r' || EndSymbol == '\0');
110  // read hexadecimal digits in the reverse order
111  // (the last symbol in the string is the least significant digit)
112  for (k = 0; k < nDigits; k++) {
113  Digit = Abc_TruthReadHexDigit(pString[nDigits - 1 - k]);
114  assert(Digit >= 0 && Digit < 16);
115  Abc_TruthSetHex(pTruth, k, Digit);
116  }
117 }
static int Abc_TruthReadHexDigit(char HexChar)
FUNCTION DEFINITIONS ///.
Definition: abcRpo.c:74
int nWords
Definition: abcNpn.c:127
#define assert(ex)
Definition: util_old.h:213
static void Abc_TruthSetHex(word *p, int k, int d)
Definition: abcRpo.c:60
static int Abc_TruthReadHexDigit ( char  HexChar)
inlinestatic

FUNCTION DEFINITIONS ///.

Definition at line 74 of file abcRpo.c.

74  {
75  if (HexChar >= '0' && HexChar <= '9')
76  return HexChar - '0';
77  if (HexChar >= 'A' && HexChar <= 'F')
78  return HexChar - 'A' + 10;
79  if (HexChar >= 'a' && HexChar <= 'f')
80  return HexChar - 'a' + 10;
81  assert(0); // not a hexadecimal symbol
82  return -1; // return value which makes no sense
83 }
#define assert(ex)
Definition: util_old.h:213
void Abc_TruthRpoPerform ( Rpo_TtStore_t p,
int  nThreshold,
int  fVerbose 
)

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

Synopsis [Apply decomposition to the truth table.]

Description [Returns the number of AIG nodes.]

SideEffects []

SeeAlso []

Definition at line 345 of file abcRpo.c.

345  {
346  clock_t clk = clock();
347  int i;
348  int rpoCount = 0;
349  Literal_t* lit;
350  float percent;
351  for (i = 0; i < p->nFuncs; i++) {
352 // if(i>1000) {
353 // continue;
354 // }
355 ////
356 // if(i!= 2196 ) { //5886
357 // continue;
358 // }
359  if(fVerbose) {
360  Abc_Print(-2,"%d: ", i+1);
361  }
362 
363  lit = Rpo_Factorize((unsigned *) p->pFuncs[i], p->nVars, nThreshold, fVerbose);
364  if (lit != NULL) {
365  if(fVerbose) {
366  Abc_Print(-2, "Solution : %s\n", lit->expression->pArray);
367  Abc_Print(-2, "\n\n");
368  }
369  Lit_Free(lit);
370  rpoCount++;
371  } else {
372  if(fVerbose) {
373  Abc_Print(-2, "null\n");
374  Abc_Print(-2, "\n\n");
375  }
376  }
377  }
378  percent = (rpoCount * 100.0) / p->nFuncs;
379  Abc_Print(-2,"%d of %d (%.2f %%) functions are RPO.\n", rpoCount,p->nFuncs,percent);
380  Abc_PrintTime(1, "Time", clock() - clk);
381 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Str_t * expression
Definition: literal.h:55
static void Lit_Free(Literal_t *lit)
Definition: literal.h:283
int lit
Definition: satVec.h:130
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
Literal_t * Rpo_Factorize(unsigned *target, int nVars, int nThreshold, int verbose)
Definition: rpo.c:174
char * pArray
Definition: bblif.c:51
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int nVars
Definition: llb3Image.c:58
void Abc_TruthRpoTest ( char *  pFileName,
int  nVarNum,
int  nThreshold,
int  fVerbose 
)

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

Synopsis [Apply decomposition to truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 394 of file abcRpo.c.

394  {
395  Rpo_TtStore_t * p;
396 
397  // allocate data-structure
398 // if (fVerbose) {
399 // Abc_Print(-2, "Number of variables = %d\n", nVarNum);
400 // }
401  p = Abc_TtStoreLoad(pFileName, nVarNum);
402 
403  if (fVerbose) {
404  Abc_Print(-2, "Number of variables = %d\n", p->nVars);
405  }
406  // consider functions from the file
407  Abc_TruthRpoPerform(p, nThreshold, fVerbose);
408 
409  // delete data-structure
410  Abc_TtStoreFree(p, nVarNum);
411  // printf( "Finished decomposing truth tables from file \"%s\".\n", pFileName );
412 }
static void Abc_TtStoreFree(Rpo_TtStore_t *p, int nVarNum)
Definition: abcRpo.c:179
void Abc_TruthRpoPerform(Rpo_TtStore_t *p, int nThreshold, int fVerbose)
Definition: abcRpo.c:345
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Rpo_TtStore_t_ Rpo_TtStore_t
Definition: abcRpo.c:30
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static Rpo_TtStore_t * Abc_TtStoreLoad(char *pFileName, int nVarNum)
Definition: abcRpo.c:301
static void Abc_TruthSetBit ( word p,
int  i 
)
inlinestatic

Definition at line 46 of file abcRpo.c.

46  {
47  p[i >> 6] |= (((word) 1) << (i & 63));
48 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Abc_TruthSetHex ( word p,
int  k,
int  d 
)
inlinestatic

Definition at line 60 of file abcRpo.c.

60  {
61  p[k >> 4] |= (((word) d) << ((k << 2) & 63));
62 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static Rpo_TtStore_t* Abc_TruthStoreAlloc ( int  nVars,
int  nFuncs 
)
static

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

Synopsis [Allocate/Deallocate storage for truth tables..]

Description []

SideEffects []

SeeAlso []

Definition at line 144 of file abcRpo.c.

144  {
145  Rpo_TtStore_t * p;
146  int i;
147  p = (Rpo_TtStore_t *) malloc(sizeof (Rpo_TtStore_t));
148  p->nVars = nVars;
149  p->nWords = (nVars < 7) ? 1 : (1 << (nVars - 6));
150  p->nFuncs = nFuncs;
151  // alloc storage for 'nFuncs' truth tables as one chunk of memory
152  p->pFuncs = (word **) malloc((sizeof (word *) + sizeof (word) * p->nWords) * p->nFuncs);
153  // assign and clean the truth table storage
154  p->pFuncs[0] = (word *) (p->pFuncs + p->nFuncs);
155  memset(p->pFuncs[0], 0, sizeof (word) * p->nWords * p->nFuncs);
156  // split it up into individual truth tables
157  for (i = 1; i < p->nFuncs; i++)
158  p->pFuncs[i] = p->pFuncs[i - 1] + p->nWords;
159  return p;
160 }
char * memset()
char * malloc()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Rpo_TtStore_t_ Rpo_TtStore_t
Definition: abcRpo.c:30
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static Rpo_TtStore_t* Abc_TruthStoreAlloc2 ( int  nVars,
int  nFuncs,
word pBuffer 
)
static

Definition at line 162 of file abcRpo.c.

162  {
163  Rpo_TtStore_t * p;
164  int i;
165  p = (Rpo_TtStore_t *) malloc(sizeof (Rpo_TtStore_t));
166  p->nVars = nVars;
167  p->nWords = (nVars < 7) ? 1 : (1 << (nVars - 6));
168  p->nFuncs = nFuncs;
169  // alloc storage for 'nFuncs' truth tables as one chunk of memory
170  p->pFuncs = (word **) malloc(sizeof (word *) * p->nFuncs);
171  // assign and clean the truth table storage
172  p->pFuncs[0] = pBuffer;
173  // split it up into individual truth tables
174  for (i = 1; i < p->nFuncs; i++)
175  p->pFuncs[i] = p->pFuncs[i - 1] + p->nWords;
176  return p;
177 }
char * malloc()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Rpo_TtStore_t_ Rpo_TtStore_t
Definition: abcRpo.c:30
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Abc_TruthStoreRead ( char *  pFileName,
Rpo_TtStore_t p 
)
static

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

Synopsis [Read truth tables from file.]

Description []

SideEffects []

SeeAlso []

Definition at line 237 of file abcRpo.c.

237  {
238  char * pContents;
239  int i, nLines;
240  pContents = Abc_FileRead(pFileName);
241  if (pContents == NULL)
242  return;
243  // here it is assumed (without checking!) that each line of the file
244  // begins with a string of hexadecimal chars followed by space
245 
246  // the file will be read till the first empty line (pContents[i] == '\n')
247  // (note that Abc_FileRead() added several empty lines at the end of the file contents)
248  for (nLines = i = 0; pContents[i] != '\n';) {
249  // read one line
250  Abc_TruthReadHex(p->pFuncs[nLines++], &pContents[i], p->nVars);
251  // skip till after the end-of-line symbol
252  // (note that end-of-line symbol is also skipped)
253  while (pContents[i++] != '\n');
254  }
255  // adjust the number of functions read
256  // (we may have allocated more storage because some lines in the file were empty)
257  assert(p->nFuncs >= nLines);
258  p->nFuncs = nLines;
259  ABC_FREE(pContents);
260 }
char * Abc_FileRead(char *pFileName)
Definition: abcDec.c:222
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Abc_TruthReadHex(word *pTruth, char *pString, int nVars)
Definition: abcRpo.c:97
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
int nVars
Definition: llb3Image.c:58
static void Abc_TruthWriteHex ( FILE *  pFile,
word pTruth,
int  nVars 
)
static

Definition at line 121 of file abcRpo.c.

121  {
122  int nDigits, Digit, k;
123  nDigits = (1 << (nVars - 2));
124  for (k = 0; k < nDigits; k++) {
125  Digit = Abc_TruthGetHex(pTruth, k);
126  assert(Digit >= 0 && Digit < 16);
127  Abc_TruthWriteHexDigit(pFile, Digit);
128  }
129 }
static int Abc_TruthGetHex(word *p, int k)
Definition: abcRpo.c:56
static void Abc_TruthWriteHexDigit(FILE *pFile, int HexDigit)
Definition: abcRpo.c:87
#define assert(ex)
Definition: util_old.h:213
static void Abc_TruthWriteHexDigit ( FILE *  pFile,
int  HexDigit 
)
inlinestatic

Definition at line 87 of file abcRpo.c.

87  {
88  assert(HexDigit >= 0 && HexDigit < 16);
89  if (HexDigit < 10)
90  fprintf(pFile, "%d", HexDigit);
91  else
92  fprintf(pFile, "%c", 'A' + HexDigit - 10);
93 }
#define assert(ex)
Definition: util_old.h:213
static void Abc_TruthXorBit ( word p,
int  i 
)
inlinestatic

Definition at line 50 of file abcRpo.c.

50  {
51  p[i >> 6] ^= (((word) 1) << (i & 63));
52 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Abc_TruthXorHex ( word p,
int  k,
int  d 
)
inlinestatic

Definition at line 64 of file abcRpo.c.

64  {
65  p[k >> 4] ^= (((word) d) << ((k << 2) & 63));
66 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Abc_TtStoreFree ( Rpo_TtStore_t p,
int  nVarNum 
)
static

Definition at line 179 of file abcRpo.c.

179  {
180  if (nVarNum >= 0)
181  ABC_FREE(p->pFuncs[0]);
182  ABC_FREE(p->pFuncs);
183  ABC_FREE(p);
184 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_FREE(obj)
Definition: abc_global.h:232
static Rpo_TtStore_t* Abc_TtStoreLoad ( char *  pFileName,
int  nVarNum 
)
static

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

Synopsis [Read truth tables from input file and write them into output file.]

Description []

SideEffects []

SeeAlso []

Definition at line 301 of file abcRpo.c.

301  {
302  Rpo_TtStore_t * p;
303  if (nVarNum < 0) {
304  int nVars, nTruths;
305  // figure out how many truth table and how many variables
306  Abc_TruthGetParams(pFileName, &nVars, &nTruths);
307  if (nVars < 2 || nVars > 16 || nTruths == 0)
308  return NULL;
309  // allocate data-structure
310  p = Abc_TruthStoreAlloc(nVars, nTruths);
311  // read info from file
312  Abc_TruthStoreRead(pFileName, p);
313  } else {
314  char * pBuffer;
315  int nFileSize = Abc_FileSize(pFileName);
316  int nBytes = (1 << (nVarNum - 3)); // why mishchencko put -3? ###
317  int nTruths = nFileSize / nBytes;
318  //Abc_Print(-2,"nFileSize=%d,nTruths=%d\n",nFileSize, nTruths);
319  if (nFileSize == -1)
320  return NULL;
321  assert(nVarNum >= 6);
322  if (nFileSize % nBytes != 0)
323  Abc_Print(0, "The file size (%d) is divided by the truth table size (%d) with remainder (%d).\n",
324  nFileSize, nBytes, nFileSize % nBytes);
325  // read file contents
326  pBuffer = Abc_FileRead(pFileName);
327  // allocate data-structure
328  p = Abc_TruthStoreAlloc2(nVarNum, nTruths, (word *) pBuffer);
329  }
330  return p;
331 }
char * Abc_FileRead(char *pFileName)
Definition: abcDec.c:222
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Abc_TruthStoreRead(char *pFileName, Rpo_TtStore_t *p)
Definition: abcRpo.c:237
int Abc_FileSize(char *pFileName)
Definition: abcDec.c:194
void Abc_TruthGetParams(char *pFileName, int *pnVars, int *pnTruths)
Definition: abcDec.c:262
typedefABC_NAMESPACE_IMPL_START struct Rpo_TtStore_t_ Rpo_TtStore_t
Definition: abcRpo.c:30
static Rpo_TtStore_t * Abc_TruthStoreAlloc(int nVars, int nFuncs)
Definition: abcRpo.c:144
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
#define assert(ex)
Definition: util_old.h:213
static Rpo_TtStore_t * Abc_TruthStoreAlloc2(int nVars, int nFuncs, word *pBuffer)
Definition: abcRpo.c:162
static void Abc_TtStoreWrite ( char *  pFileName,
Rpo_TtStore_t p,
int  fBinary 
)
static

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

Synopsis [Write truth tables into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 273 of file abcRpo.c.

273  {
274  FILE * pFile;
275  int i, nBytes = 8 * Abc_Truth6WordNum(p->nVars);
276  pFile = fopen(pFileName, "wb");
277  if (pFile == NULL) {
278  printf("Cannot open file \"%s\" for writing.\n", pFileName);
279  return;
280  }
281  for (i = 0; i < p->nFuncs; i++) {
282  if (fBinary)
283  fwrite(p->pFuncs[i], nBytes, 1, pFile);
284  else
285  Abc_TruthWriteHex(pFile, p->pFuncs[i], p->nVars), fprintf(pFile, "\n");
286  }
287  fclose(pFile);
288 }
static void Abc_TruthWriteHex(FILE *pFile, word *pTruth, int nVars)
Definition: abcRpo.c:121
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
int nVars
Definition: llb3Image.c:58