abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcNpnSave.c File Reference
#include "base/abc/abc.h"
#include "aig/aig/aig.h"

Go to the source code of this file.

Data Structures

struct  Npn_Obj_t_
 
struct  Npn_Man_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Npn_Obj_t_ 
Npn_Obj_t
 DECLARATIONS ///. More...
 
typedef struct Npn_Man_t_ Npn_Man_t
 

Functions

static Npn_Obj_tNpn_ManObj (Npn_Man_t *p, int i)
 
static int Npn_ManObjNum (Npn_Man_t *p, Npn_Obj_t *pObj)
 
void Npn_TruthPermute_rec (char *pStr, int mid, int end)
 FUNCTION DEFINITIONS ///. More...
 
static int Npn_TruthHasVar (word t, int v)
 
static int Npn_TruthSupport (word t)
 
static int Npn_TruthSuppSize (word t, int nVars)
 
static int Npn_TruthIsMinBase (word t)
 
word Npn_TruthPadWord (word uTruth, int nVars)
 
static int Npn_TruthCountOnes (word t)
 
static word Npn_TruthChangePhase (word t, int v)
 
static word Npn_TruthSwapAdjacentVars (word t, int v)
 
static word Npn_TruthCanon (word t, int nVars, int *pPhase)
 
static int Npn_ManHash (Npn_Man_t *p, word uTruth)
 
void Npn_ManResize (Npn_Man_t *p)
 
Npn_Obj_tNpn_ManAdd (Npn_Man_t *p, word uTruth)
 
void Npn_ManRead (Npn_Man_t *p, char *pFileName)
 
static int Npn_ManCompareEntries (Npn_Obj_t **pp1, Npn_Obj_t **pp2)
 
void Npn_ManWrite (Npn_Man_t *p, char *pFileName)
 
Npn_Man_tNpn_ManStart (char *pFileName)
 
void Npn_ManStop (Npn_Man_t *p)
 
void Npn_ManClean ()
 
void Npn_ManLoad (char *pFileName)
 
void Npn_ManSave (char *pFileName)
 
void Npn_ManSaveOne (unsigned *puTruth, int nVars)
 

Variables

static word Truth [8]
 
static Npn_Man_tpNpnMan = NULL
 

Typedef Documentation

typedef struct Npn_Man_t_ Npn_Man_t

Definition at line 32 of file abcNpnSave.c.

typedef typedefABC_NAMESPACE_IMPL_START struct Npn_Obj_t_ Npn_Obj_t

DECLARATIONS ///.

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

FileName [abcNpnSave.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Interface with the FPGA mapping package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 21, 2006.]

Revision [

Id:
abcNpnSave.c,v 1.00 2006/11/21 00:00:00 alanmi Exp

]

Definition at line 31 of file abcNpnSave.c.

Function Documentation

Npn_Obj_t* Npn_ManAdd ( Npn_Man_t p,
word  uTruth 
)

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

Synopsis [Adds one entry to the table.]

Description [Increments ref counter by 1.]

SideEffects []

SeeAlso []

Definition at line 437 of file abcNpnSave.c.

438 {
439  Npn_Obj_t * pEntry;
440  int * pPlace, Key = Npn_ManHash( p, uTruth );
441  // resize the link storage if needed
442  if ( p->nEntries == p->nBufferSize )
443  {
444  p->nBufferSize *= 2;
446  }
447  // find the entry
448  for ( pEntry = Npn_ManObj(p, p->pBins[Key]),
449  pPlace = p->pBins + Key;
450  pEntry;
451  pPlace = &pEntry->iNext,
452  pEntry = Npn_ManObj(p, pEntry->iNext) )
453  if ( pEntry->uTruth == uTruth )
454  {
455  pEntry->Count++;
456  return pEntry;
457  }
458  // create new entry
459  *pPlace = p->nEntries;
460  assert( p->nEntries < p->nBufferSize );
461  pEntry = Npn_ManObj( p, p->nEntries++ );
462  pEntry->uTruth = uTruth;
463  pEntry->Count = 1;
464  pEntry->iNext = 0;
465  // resize the table if needed
466  if ( p->nEntries > 3 * p->nBins )
467  Npn_ManResize( p );
468  return pEntry;
469 }
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
void Npn_ManResize(Npn_Man_t *p)
Definition: abcNpnSave.c:391
int * pBins
Definition: abcNpnSave.c:43
Npn_Obj_t * pBuffer
Definition: abcNpnSave.c:42
static int Npn_ManHash(Npn_Man_t *p, word uTruth)
Definition: abcNpnSave.c:374
static Npn_Obj_t * Npn_ManObj(Npn_Man_t *p, int i)
Definition: abcNpnSave.c:49
int nEntries
Definition: abcNpnSave.c:46
typedefABC_NAMESPACE_IMPL_START struct Npn_Obj_t_ Npn_Obj_t
DECLARATIONS ///.
Definition: abcNpnSave.c:31
#define assert(ex)
Definition: util_old.h:213
int nBufferSize
Definition: abcNpnSave.c:45
void Npn_ManClean ( )

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

Synopsis [Cleans the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 649 of file abcNpnSave.c.

650 {
651  if ( pNpnMan != NULL )
652  {
653  Npn_ManStop( pNpnMan );
654  pNpnMan = NULL;
655  }
656 }
void Npn_ManStop(Npn_Man_t *p)
Definition: abcNpnSave.c:631
static Npn_Man_t * pNpnMan
Definition: abcNpnSave.c:63
static int Npn_ManCompareEntries ( Npn_Obj_t **  pp1,
Npn_Obj_t **  pp2 
)
static

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

Synopsis [Comparison procedure for two entries.]

Description []

SideEffects []

SeeAlso []

Definition at line 532 of file abcNpnSave.c.

533 {
534  if ( (*pp1)->Count > (*pp2)->Count )
535  return -1;
536  if ( (*pp1)->Count < (*pp2)->Count )
537  return 1;
538  return 0;
539 }
static int Npn_ManHash ( Npn_Man_t p,
word  uTruth 
)
inlinestatic

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

Synopsis [Computes the hash key.]

Description []

SideEffects []

SeeAlso []

Definition at line 374 of file abcNpnSave.c.

375 {
376  word Key = (uTruth * (word)101) ^ (uTruth * (word)733) ^ (uTruth * (word)1777);
377  return (int)(Key % (word)p->nBins);
378 }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
void Npn_ManLoad ( char *  pFileName)

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

Synopsis [Loads functions from a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 669 of file abcNpnSave.c.

670 {
671 // Npn_TruthPermute_rec( "012345", 0, 5 );
672  if ( pNpnMan != NULL )
673  {
674  Abc_Print( 1, "Removing old table with %d entries.\n", pNpnMan->nEntries );
675  Npn_ManStop( pNpnMan );
676  }
677  pNpnMan = Npn_ManStart( pFileName );
678  Abc_Print( 1, "Created new table with %d entries from file \"%s\".\n", pNpnMan->nEntries, pFileName );
679 }
void Npn_ManStop(Npn_Man_t *p)
Definition: abcNpnSave.c:631
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
Npn_Man_t * Npn_ManStart(char *pFileName)
Definition: abcNpnSave.c:588
int nEntries
Definition: abcNpnSave.c:46
static Npn_Man_t * pNpnMan
Definition: abcNpnSave.c:63
static Npn_Obj_t* Npn_ManObj ( Npn_Man_t p,
int  i 
)
inlinestatic

Definition at line 49 of file abcNpnSave.c.

49 { assert( i < p->nBufferSize ); return i ? p->pBuffer + i : NULL; }
Npn_Obj_t * pBuffer
Definition: abcNpnSave.c:42
#define assert(ex)
Definition: util_old.h:213
static int Npn_ManObjNum ( Npn_Man_t p,
Npn_Obj_t pObj 
)
inlinestatic

Definition at line 50 of file abcNpnSave.c.

50 { assert( p->pBuffer < pObj ); return pObj - p->pBuffer; }
Npn_Obj_t * pBuffer
Definition: abcNpnSave.c:42
#define assert(ex)
Definition: util_old.h:213
void Npn_ManRead ( Npn_Man_t p,
char *  pFileName 
)

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

Synopsis [Fills table from file.]

Description []

SideEffects []

SeeAlso []

Definition at line 482 of file abcNpnSave.c.

483 {
484  char pBuffer[1000];
485  char * pToken;
486  Npn_Obj_t * pEntry;
487  unsigned Truth[2];
488  word uTruth;
489  FILE * pFile = fopen( pFileName, "r" );
490  if ( pFile == NULL )
491  {
492  Abc_Print( -1, "Cannot open NPN function file \"%s\".\n", pFileName );
493  return;
494  }
495  // read lines from the file
496  while ( fgets( pBuffer, 1000, pFile ) != NULL )
497  {
498  pToken = strtok( pBuffer, " \t\n" );
499  if ( pToken == NULL )
500  continue;
501  if ( pToken[0] == '#' )
502  continue;
503  if ( strlen(pToken) != 16 )
504  {
505  Abc_Print( 0, "Skipping token %s that does not look like a 16-digit hex number.\n" );
506  continue;
507  }
508  // extract truth table
509  Extra_ReadHexadecimal( Truth, pToken, 6 );
510  uTruth = (((word)Truth[1]) << 32) | (word)Truth[0];
511  // add truth table
512  pEntry = Npn_ManAdd( p, uTruth );
513  assert( pEntry->Count == 1 );
514  // read area
515  pToken = strtok( NULL, " \t\n" );
516  pEntry->Count = atoi(pToken);
517  }
518  fclose( pFile );
519 }
char * strtok()
static word Truth[8]
Definition: abcNpnSave.c:52
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int Extra_ReadHexadecimal(unsigned Sign[], char *pString, int nVars)
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
typedefABC_NAMESPACE_IMPL_START struct Npn_Obj_t_ Npn_Obj_t
DECLARATIONS ///.
Definition: abcNpnSave.c:31
Npn_Obj_t * Npn_ManAdd(Npn_Man_t *p, word uTruth)
Definition: abcNpnSave.c:437
#define assert(ex)
Definition: util_old.h:213
int strlen()
void Npn_ManResize ( Npn_Man_t p)

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

Synopsis [Resizes the table.]

Description []

SideEffects []

SeeAlso []

Definition at line 391 of file abcNpnSave.c.

392 {
393  Npn_Obj_t * pEntry, * pNext;
394  int * pBinsOld, * ppPlace;
395  int nBinsOld, Counter, i;
396  abctime clk;
397  assert( p->pBins != NULL );
398 clk = Abc_Clock();
399  // save the old Bins
400  pBinsOld = p->pBins;
401  nBinsOld = p->nBins;
402  // get the new Bins
403  p->nBins = Abc_PrimeCudd( 3 * nBinsOld );
404  p->pBins = ABC_CALLOC( int, p->nBins );
405  // rehash the entries from the old table
406  Counter = 1;
407  for ( i = 0; i < nBinsOld; i++ )
408  for ( pEntry = Npn_ManObj(p, pBinsOld[i]),
409  pNext = pEntry ? Npn_ManObj(p, pEntry->iNext) : NULL;
410  pEntry;
411  pEntry = pNext,
412  pNext = pEntry ? Npn_ManObj(p, pEntry->iNext) : NULL )
413  {
414  // get the place where this entry goes
415  ppPlace = p->pBins + Npn_ManHash( p, pEntry->uTruth );
416  // add the entry to the list
417  pEntry->iNext = *ppPlace;
418  *ppPlace = Npn_ManObjNum( p, pEntry );
419  Counter++;
420  }
421  assert( Counter == p->nEntries );
422  ABC_FREE( pBinsOld );
423 //ABC_PRT( "Hash table resizing time", Abc_Clock() - clk );
424 }
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static abctime Abc_Clock()
Definition: abc_global.h:279
int * pBins
Definition: abcNpnSave.c:43
static int Counter
static int Npn_ManHash(Npn_Man_t *p, word uTruth)
Definition: abcNpnSave.c:374
static int Npn_ManObjNum(Npn_Man_t *p, Npn_Obj_t *pObj)
Definition: abcNpnSave.c:50
static Npn_Obj_t * Npn_ManObj(Npn_Man_t *p, int i)
Definition: abcNpnSave.c:49
#define ABC_FREE(obj)
Definition: abc_global.h:232
int nEntries
Definition: abcNpnSave.c:46
typedefABC_NAMESPACE_IMPL_START struct Npn_Obj_t_ Npn_Obj_t
DECLARATIONS ///.
Definition: abcNpnSave.c:31
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
void Npn_ManSave ( char *  pFileName)

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

Synopsis [Saves functions into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 692 of file abcNpnSave.c.

693 {
694  if ( pNpnMan == NULL )
695  {
696  Abc_Print( 1, "There is no table with entries.\n" );
697  return;
698  }
699  Npn_ManWrite( pNpnMan, pFileName );
700  Abc_Print( 1, "Dumped table with %d entries from file \"%s\".\n", pNpnMan->nEntries, pFileName );
701 }
void Npn_ManWrite(Npn_Man_t *p, char *pFileName)
Definition: abcNpnSave.c:552
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int nEntries
Definition: abcNpnSave.c:46
static Npn_Man_t * pNpnMan
Definition: abcNpnSave.c:63
void Npn_ManSaveOne ( unsigned *  puTruth,
int  nVars 
)

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

Synopsis [Saves one function into storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 714 of file abcNpnSave.c.

715 {
716  word uTruth = (((word)puTruth[1]) << 32) | (word)puTruth[0];
717  assert( nVars >= 0 && nVars <= 6 );
718  if ( pNpnMan == NULL )
719  {
720  Abc_Print( 1, "Creating new table with 0 entries.\n" );
721  pNpnMan = Npn_ManStart( NULL );
722  }
723  // skip truth tables that do not depend on some vars
724  if ( !Npn_TruthIsMinBase( uTruth ) )
725  return;
726  // extend truth table to look like 6-input
727  uTruth = Npn_TruthPadWord( uTruth, nVars );
728  // semi(!)-NPN-canonize the truth table
729  uTruth = Npn_TruthCanon( uTruth, 6, NULL );
730  // add to storage
731  Npn_ManAdd( pNpnMan, uTruth );
732 }
static int Npn_TruthIsMinBase(word t)
Definition: abcNpnSave.c:174
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word Npn_TruthCanon(word t, int nVars, int *pPhase)
Definition: abcNpnSave.c:282
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
Npn_Man_t * Npn_ManStart(char *pFileName)
Definition: abcNpnSave.c:588
Npn_Obj_t * Npn_ManAdd(Npn_Man_t *p, word uTruth)
Definition: abcNpnSave.c:437
static Npn_Man_t * pNpnMan
Definition: abcNpnSave.c:63
#define assert(ex)
Definition: util_old.h:213
word Npn_TruthPadWord(word uTruth, int nVars)
Definition: abcNpnSave.c:191
Npn_Man_t* Npn_ManStart ( char *  pFileName)

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

Synopsis [Creates the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 588 of file abcNpnSave.c.

589 {
590  Npn_Man_t * p;
591  p = ABC_CALLOC( Npn_Man_t, 1 );
592  if ( pFileName == NULL )
593  {
594  p->nBufferSize = 1000000;
595  p->nBufferSize = 100;
597  p->nBins = Abc_PrimeCudd( p->nBufferSize / 2 );
598  p->pBins = ABC_CALLOC( int, p->nBins );
599  p->nEntries = 1;
600  }
601  else
602  {
603  FILE * pFile = fopen( pFileName, "r" );
604  if ( pFile == NULL )
605  {
606  Abc_Print( -1, "Cannot open NPN function file \"%s\".\n", pFileName );
607  return NULL;
608  }
609  fclose( pFile );
610  p->nBufferSize = 4 * ( Extra_FileSize(pFileName) / 20 );
612  p->nBins = Abc_PrimeCudd( p->nBufferSize / 2 );
613  p->pBins = ABC_CALLOC( int, p->nBins );
614  p->nEntries = 1;
615  Npn_ManRead( p, pFileName );
616  }
617  return p;
618 }
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int * pBins
Definition: abcNpnSave.c:43
int Extra_FileSize(char *pFileName)
Npn_Obj_t * pBuffer
Definition: abcNpnSave.c:42
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int nEntries
Definition: abcNpnSave.c:46
typedefABC_NAMESPACE_IMPL_START struct Npn_Obj_t_ Npn_Obj_t
DECLARATIONS ///.
Definition: abcNpnSave.c:31
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
void Npn_ManRead(Npn_Man_t *p, char *pFileName)
Definition: abcNpnSave.c:482
int nBufferSize
Definition: abcNpnSave.c:45
void Npn_ManStop ( Npn_Man_t p)

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

Synopsis [Deletes the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 631 of file abcNpnSave.c.

632 {
633  ABC_FREE( p->pBuffer );
634  ABC_FREE( p->pBins );
635  ABC_FREE( p );
636 }
int * pBins
Definition: abcNpnSave.c:43
Npn_Obj_t * pBuffer
Definition: abcNpnSave.c:42
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Npn_ManWrite ( Npn_Man_t p,
char *  pFileName 
)

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

Synopsis [Adds one entry to the table.]

Description []

SideEffects []

SeeAlso []

Definition at line 552 of file abcNpnSave.c.

553 {
554  Vec_Ptr_t * vEntries;
555  Npn_Obj_t * pEntry;
556  FILE * pFile = fopen( pFileName, "w" );
557  int i;
558  if ( pFile == NULL )
559  {
560  Abc_Print( -1, "Cannot open NPN function file \"%s\".\n", pFileName );
561  return;
562  }
563  vEntries = Vec_PtrAlloc( p->nEntries );
564  for ( i = 0; i < p->nBins; i++ )
565  for ( pEntry = Npn_ManObj(p, p->pBins[i]); pEntry; pEntry = Npn_ManObj(p, pEntry->iNext) )
566  Vec_PtrPush( vEntries, pEntry );
567  Vec_PtrSort( vEntries, (int (*)())Npn_ManCompareEntries );
568  Vec_PtrForEachEntry( Npn_Obj_t *, vEntries, pEntry, i )
569  {
570  Extra_PrintHexadecimal( pFile, (unsigned *)&pEntry->uTruth, 6 );
571  fprintf( pFile, " %d %d\n", pEntry->Count, Npn_TruthSuppSize(pEntry->uTruth, 6) );
572  }
573  fclose( pFile );
574  Vec_PtrFree( vEntries );
575 }
static int Npn_TruthSuppSize(word t, int nVars)
Definition: abcNpnSave.c:153
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Npn_ManCompareEntries(Npn_Obj_t **pp1, Npn_Obj_t **pp2)
Definition: abcNpnSave.c:532
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
Definition: vecPtr.h:851
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
int * pBins
Definition: abcNpnSave.c:43
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static Npn_Obj_t * Npn_ManObj(Npn_Man_t *p, int i)
Definition: abcNpnSave.c:49
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int nEntries
Definition: abcNpnSave.c:46
typedefABC_NAMESPACE_IMPL_START struct Npn_Obj_t_ Npn_Obj_t
DECLARATIONS ///.
Definition: abcNpnSave.c:31
void Extra_PrintHexadecimal(FILE *pFile, unsigned Sign[], int nVars)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static word Npn_TruthCanon ( word  t,
int  nVars,
int *  pPhase 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file abcNpnSave.c.

283 {
284  int fUsePolarity = 0;
285  int fUsePermutation = 0;
286  char Temp, pSigs[13], pCanonPerm[6];
287  int v, fChange, CanonPhase = 0;
288  assert( nVars < 7 );
289  pSigs[12] = Npn_TruthCountOnes( t );
290  if ( pSigs[12] > 32 )
291  {
292  t = ~t;
293  pSigs[12] = 64 - pSigs[12];
294  CanonPhase |= (1 << 6);
295  }
296  if ( fUsePolarity || fUsePermutation )
297  {
298  for ( v = 0; v < nVars; v++ )
299  {
300  pCanonPerm[v] = v;
301  pSigs[2*v+1] = Npn_TruthCountOnes( t & Truth[v] );
302  pSigs[2*v] = pSigs[12] - pSigs[2*v+1];
303  }
304  }
305  if ( fUsePolarity )
306  {
307  for ( v = 0; v < nVars; v++ )
308  {
309  if ( pSigs[2*v] >= pSigs[2*v+1] )
310  continue;
311  CanonPhase |= (1 << v);
312  Temp = pSigs[2*v];
313  pSigs[2*v] = pSigs[2*v+1];
314  pSigs[2*v+1] = Temp;
315  t = Npn_TruthChangePhase( t, v );
316  }
317  }
318  if ( fUsePermutation )
319  {
320  do {
321  fChange = 0;
322  for ( v = 0; v < nVars-1; v++ )
323  {
324  if ( fUsePolarity )
325  {
326  if ( pSigs[2*v] >= pSigs[2*(v+1)] )
327  continue;
328  }
329  else
330  {
331  if ( Abc_MinInt(pSigs[2*v],pSigs[2*v+1]) >= Abc_MinInt(pSigs[2*(v+1)],pSigs[2*(v+1)+1]) )
332  continue;
333  }
334  fChange = 1;
335 
336  Temp = pCanonPerm[v];
337  pCanonPerm[v] = pCanonPerm[v+1];
338  pCanonPerm[v+1] = Temp;
339 
340  Temp = pSigs[2*v];
341  pSigs[2*v] = pSigs[2*(v+1)];
342  pSigs[2*(v+1)] = Temp;
343 
344  Temp = pSigs[2*v+1];
345  pSigs[2*v+1] = pSigs[2*(v+1)+1];
346  pSigs[2*(v+1)+1] = Temp;
347 
348  t = Npn_TruthSwapAdjacentVars( t, v );
349  }
350  } while ( fChange );
351  }
352  if ( pPhase )
353  {
354  *pPhase = 0;
355  for ( v = 0; v < nVars; v++ )
356  *pPhase |= (pCanonPerm[v] << (4 * v));
357  *pPhase |= (CanonPhase << 24);
358  }
359  return t;
360 }
static int Npn_TruthCountOnes(word t)
Definition: abcNpnSave.c:221
static word Truth[8]
Definition: abcNpnSave.c:52
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static word Npn_TruthSwapAdjacentVars(word t, int v)
Definition: abcNpnSave.c:258
static word Npn_TruthChangePhase(word t, int v)
Definition: abcNpnSave.c:242
#define assert(ex)
Definition: util_old.h:213
static word Npn_TruthChangePhase ( word  t,
int  v 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 242 of file abcNpnSave.c.

243 {
244  return ((t & Truth[v]) >> (1<<v)) | ((t & ~Truth[v]) << (1<<v));
245 }
static word Truth[8]
Definition: abcNpnSave.c:52
static int Npn_TruthCountOnes ( word  t)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file abcNpnSave.c.

222 {
223  t = (t & ABC_CONST(0x5555555555555555)) + ((t>> 1) & ABC_CONST(0x5555555555555555));
224  t = (t & ABC_CONST(0x3333333333333333)) + ((t>> 2) & ABC_CONST(0x3333333333333333));
225  t = (t & ABC_CONST(0x0F0F0F0F0F0F0F0F)) + ((t>> 4) & ABC_CONST(0x0F0F0F0F0F0F0F0F));
226  t = (t & ABC_CONST(0x00FF00FF00FF00FF)) + ((t>> 8) & ABC_CONST(0x00FF00FF00FF00FF));
227  t = (t & ABC_CONST(0x0000FFFF0000FFFF)) + ((t>>16) & ABC_CONST(0x0000FFFF0000FFFF));
228  return (t & ABC_CONST(0x00000000FFFFFFFF)) + (t>>32);
229 }
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
static int Npn_TruthHasVar ( word  t,
int  v 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 117 of file abcNpnSave.c.

118 {
119  return ((t & Truth[v]) >> (1<<v)) != (t & ~Truth[v]);
120 }
static word Truth[8]
Definition: abcNpnSave.c:52
static int Npn_TruthIsMinBase ( word  t)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 174 of file abcNpnSave.c.

175 {
176  int Supp = Npn_TruthSupport(t);
177  return (Supp & (Supp+1)) == 0;
178 }
static int Npn_TruthSupport(word t)
Definition: abcNpnSave.c:133
word Npn_TruthPadWord ( word  uTruth,
int  nVars 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 191 of file abcNpnSave.c.

192 {
193  if ( nVars == 6 )
194  return uTruth;
195  if ( nVars <= 5 )
196  uTruth = ((uTruth & ABC_CONST(0x00000000FFFFFFFF)) << 32) | (uTruth & ABC_CONST(0x00000000FFFFFFFF));
197  if ( nVars <= 4 )
198  uTruth = ((uTruth & ABC_CONST(0x0000FFFF0000FFFF)) << 16) | (uTruth & ABC_CONST(0x0000FFFF0000FFFF));
199  if ( nVars <= 3 )
200  uTruth = ((uTruth & ABC_CONST(0x00FF00FF00FF00FF)) << 8) | (uTruth & ABC_CONST(0x00FF00FF00FF00FF));
201  if ( nVars <= 2 )
202  uTruth = ((uTruth & ABC_CONST(0x0F0F0F0F0F0F0F0F)) << 4) | (uTruth & ABC_CONST(0x0F0F0F0F0F0F0F0F));
203  if ( nVars <= 1 )
204  uTruth = ((uTruth & ABC_CONST(0x3333333333333333)) << 2) | (uTruth & ABC_CONST(0x3333333333333333));
205  if ( nVars == 0 )
206  uTruth = ((uTruth & ABC_CONST(0x5555555555555555)) << 1) | (uTruth & ABC_CONST(0x5555555555555555));
207  return uTruth;
208 }
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
void Npn_TruthPermute_rec ( char *  pStr,
int  mid,
int  end 
)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file abcNpnSave.c.

81 {
82  static int count = 0;
83  char * pTemp = Abc_UtilStrsav(pStr);
84  char e;
85  int i;
86  if ( mid == end )
87  {
88  printf( "%03d: %s\n", count++, pTemp );
89  return ;
90  }
91  for ( i = mid; i <= end; i++ )
92  {
93  e = pTemp[mid];
94  pTemp[mid] = pTemp[i];
95  pTemp[i] = e;
96 
97  Npn_TruthPermute_rec( pTemp, mid + 1, end );
98 
99  e = pTemp[mid];
100  pTemp[mid] = pTemp[i];
101  pTemp[i] = e;
102  }
103  ABC_FREE( pTemp );
104 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Npn_TruthPermute_rec(char *pStr, int mid, int end)
FUNCTION DEFINITIONS ///.
Definition: abcNpnSave.c:80
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
static int Npn_TruthSupport ( word  t)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 133 of file abcNpnSave.c.

134 {
135  int v, Supp = 0;
136  for ( v = 0; v < 6; v++ )
137  if ( Npn_TruthHasVar( t, v ) )
138  Supp |= (1 << v);
139  return Supp;
140 }
static int Npn_TruthHasVar(word t, int v)
Definition: abcNpnSave.c:117
static int Npn_TruthSuppSize ( word  t,
int  nVars 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file abcNpnSave.c.

154 {
155  int v, nSupp = 0;
156  assert( nVars <= 6 );
157  for ( v = 0; v < nVars; v++ )
158  if ( Npn_TruthHasVar( t, v ) )
159  nSupp++;
160  return nSupp;
161 }
static int Npn_TruthHasVar(word t, int v)
Definition: abcNpnSave.c:117
#define assert(ex)
Definition: util_old.h:213
static word Npn_TruthSwapAdjacentVars ( word  t,
int  v 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 258 of file abcNpnSave.c.

259 {
260  static word PMasks[5][3] = {
261  { ABC_CONST(0x9999999999999999), ABC_CONST(0x2222222222222222), ABC_CONST(0x4444444444444444) },
262  { ABC_CONST(0xC3C3C3C3C3C3C3C3), ABC_CONST(0x0C0C0C0C0C0C0C0C), ABC_CONST(0x3030303030303030) },
263  { ABC_CONST(0xF00FF00FF00FF00F), ABC_CONST(0x00F000F000F000F0), ABC_CONST(0x0F000F000F000F00) },
264  { ABC_CONST(0xFF0000FFFF0000FF), ABC_CONST(0x0000FF000000FF00), ABC_CONST(0x00FF000000FF0000) },
265  { ABC_CONST(0xFFFF00000000FFFF), ABC_CONST(0x00000000FFFF0000), ABC_CONST(0x0000FFFF00000000) }
266  };
267  assert( v < 6 );
268  return (t & PMasks[v][0]) | ((t & PMasks[v][1]) << (1 << v)) | ((t & PMasks[v][2]) >> (1 << v));
269 }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word PMasks[5][3]
Definition: ifDec07.c:44
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
#define assert(ex)
Definition: util_old.h:213

Variable Documentation

Npn_Man_t* pNpnMan = NULL
static

Definition at line 63 of file abcNpnSave.c.

word Truth[8]
static
Initial value:
= {
ABC_CONST(0xAAAAAAAAAAAAAAAA),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0x0000000000000000),
}
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206

Definition at line 52 of file abcNpnSave.c.