mirror of
https://github.com/The-OpenROAD-Project/abc.git
synced 2026-03-12 11:26:17 +08:00
Version abc70407
This commit is contained in:
4
abc.rc
4
abc.rc
@@ -141,9 +141,6 @@ alias qsA "qvar -I 96 -u; qvar -I 97 -u; qvar -I 98 -u; qvar -I 99 -u; qvar
|
||||
alias chnew "st; haig_start; resyn2; haig_use"
|
||||
alias chnewrs "st; haig_start; resyn2rs; haig_use"
|
||||
|
||||
alias bug "r a/quip_opt/nut_001_opt.blif; chnew; st; cec"
|
||||
alias bug2 "r a/quip_opt/nut_001_opt.blif; chnew; if -K 6; ps; cec"
|
||||
|
||||
alias t "read_dsd a*(b+(c*d)+e); clp -r; print_dsd"
|
||||
alias t1 "read_dsd a*(b+(c*d)); clp -r; print_dsd"
|
||||
alias t2 "read_dsd 56BA(a,b,c,d); clp -r; print_dsd"
|
||||
@@ -168,3 +165,4 @@ alias tst4n "r i10_if4.blif; st; ps; r 5npn/all_functions.aig; st; rec_start;
|
||||
alias tst6 "r i10_if6.blif; st; ps; r x/rec6_16_.blif; st; rec_start; r i10_if6.blif; st -r; ps; cec"
|
||||
|
||||
|
||||
alias bug "r pj1_if3.blif; lp"
|
||||
|
||||
@@ -234,6 +234,9 @@ struct Lut_Par_t_
|
||||
int nLutsMax; // (N) the maximum number of LUTs in the structure
|
||||
int nLutsOver; // (Q) the maximum number of LUTs not in the MFFC
|
||||
int nVarsShared; // (S) the maximum number of shared variables (crossbars)
|
||||
int nGrowthLevel; // (L) the maximum increase in the node level after resynthesis
|
||||
int fSatur; // iterate till saturation
|
||||
int fZeroCost; // accept zero-cost replacements
|
||||
int fVerbose; // the verbosiness flag
|
||||
int fVeryVerbose; // additional verbose info printout
|
||||
// internal parameters
|
||||
|
||||
@@ -38,6 +38,8 @@ static bool Abc_NtkComparePis( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
|
||||
static bool Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
|
||||
static bool Abc_NtkCompareLatches( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
|
||||
|
||||
static inline char * Abc_ObjNameNet( Abc_Obj_t * pObj ) { return (Abc_ObjIsNode(pObj) && Abc_NtkIsNetlist(pObj->pNtk)) ? Abc_ObjName(Abc_ObjFanout0(pObj)) : Abc_ObjName(pObj); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -523,7 +525,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
|
||||
// the node should have a function assigned unless it is an AIG
|
||||
if ( pNode->pData == NULL )
|
||||
{
|
||||
fprintf( stdout, "NodeCheck: An internal node \"%s\" does not have a logic function.\n", Abc_NtkIsNetlist(pNode->pNtk)? Abc_ObjName(Abc_ObjFanout0(pNode)) : Abc_ObjName(pNode) );
|
||||
fprintf( stdout, "NodeCheck: An internal node \"%s\" does not have a logic function.\n", Abc_ObjNameNet(pNode) );
|
||||
return 0;
|
||||
}
|
||||
// the netlist and SOP logic network should have SOPs
|
||||
@@ -531,7 +533,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
|
||||
{
|
||||
if ( !Abc_SopCheck( pNode->pData, Abc_ObjFaninNum(pNode) ) )
|
||||
{
|
||||
fprintf( stdout, "NodeCheck: SOP check for node \"%s\" has failed.\n", Abc_ObjName(pNode) );
|
||||
fprintf( stdout, "NodeCheck: SOP check for node \"%s\" has failed.\n", Abc_ObjNameNet(pNode) );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -540,7 +542,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
|
||||
int nSuppSize = Cudd_SupportSize(pNtk->pManFunc, pNode->pData);
|
||||
if ( nSuppSize > Abc_ObjFaninNum(pNode) )
|
||||
{
|
||||
fprintf( stdout, "NodeCheck: BDD of the node \"%s\" has incorrect support size.\n", Abc_ObjName(pNode) );
|
||||
fprintf( stdout, "NodeCheck: BDD of the node \"%s\" has incorrect support size.\n", Abc_ObjNameNet(pNode) );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1264,9 +1264,9 @@ int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( !Abc_NtkIsBddLogic(pNtk) )
|
||||
if ( !Abc_NtkIsLogic(pNtk) )
|
||||
{
|
||||
fprintf( pErr, "Visualizing Karnaugh map works for BDD logic networks (run \"bdd\").\n" );
|
||||
fprintf( pErr, "Visualization of Karnaugh maps works for logic networks.\n" );
|
||||
return 1;
|
||||
}
|
||||
if ( argc > globalUtilOptind + 1 )
|
||||
@@ -1292,6 +1292,7 @@ int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Abc_NtkToBdd(pNtk);
|
||||
Abc_NodePrintKMap( pNode, fUseRealNames );
|
||||
return 0;
|
||||
|
||||
@@ -2908,12 +2909,15 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
// set defaults
|
||||
memset( pPars, 0, sizeof(Lut_Par_t) );
|
||||
pPars->nLutsMax = 4; // (N) the maximum number of LUTs in the structure
|
||||
pPars->nLutsOver = 2; // (Q) the maximum number of LUTs not in the MFFC
|
||||
pPars->nLutsOver = 3; // (Q) the maximum number of LUTs not in the MFFC
|
||||
pPars->nVarsShared = 0; // (S) the maximum number of shared variables (crossbars)
|
||||
pPars->fVerbose = 0;
|
||||
pPars->nGrowthLevel = 1;
|
||||
pPars->fSatur = 1;
|
||||
pPars->fZeroCost = 0;
|
||||
pPars->fVerbose = 1;
|
||||
pPars->fVeryVerbose = 0;
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "NQSvwh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "NQSLszvwh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
@@ -2950,6 +2954,23 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
if ( pPars->nVarsShared < 0 || pPars->nVarsShared > 4 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'L':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
|
||||
goto usage;
|
||||
}
|
||||
pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
|
||||
globalUtilOptind++;
|
||||
if ( pPars->nGrowthLevel < 0 || pPars->nGrowthLevel > ABC_INFINITY )
|
||||
goto usage;
|
||||
break;
|
||||
case 's':
|
||||
pPars->fSatur ^= 1;
|
||||
break;
|
||||
case 'z':
|
||||
pPars->fZeroCost ^= 1;
|
||||
break;
|
||||
case 'v':
|
||||
pPars->fVerbose ^= 1;
|
||||
break;
|
||||
@@ -2983,11 +3004,14 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
fprintf( pErr, "usage: lutpack [-N <num>] [-Q <num>] [-S <num>] [-vwh]\n" );
|
||||
fprintf( pErr, "usage: lutpack [-N <num>] [-Q <num>] [-S <num>] [-L <num>] [-szvwh]\n" );
|
||||
fprintf( pErr, "\t performs \"rewriting\" for LUT networks\n" );
|
||||
fprintf( pErr, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax );
|
||||
fprintf( pErr, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver );
|
||||
fprintf( pErr, "\t-S <num> : the max number of LUT inputs shared (0 <= num) [default = %d]\n", pPars->nVarsShared );
|
||||
fprintf( pErr, "\t-L <num> : the largest increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
|
||||
fprintf( pErr, "\t-s : toggle iteration till saturation [default = %s]\n", pPars->fSatur? "yes": "no" );
|
||||
fprintf( pErr, "\t-z : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" );
|
||||
fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
|
||||
fprintf( pErr, "\t-w : toggle printout subgraph statistics [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
|
||||
fprintf( pErr, "\t-h : print the command usage\n");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,7 @@
|
||||
|
||||
static If_Man_t * Abc_NtkToIf( Abc_Ntk_t * pNtk, If_Par_t * pPars );
|
||||
static Abc_Ntk_t * Abc_NtkFromIf( If_Man_t * pIfMan, Abc_Ntk_t * pNtk );
|
||||
static Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t * pIfObj, Vec_Int_t * vCover );
|
||||
extern Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t * pIfObj, Vec_Int_t * vCover );
|
||||
static Hop_Obj_t * Abc_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t * pIfObj );
|
||||
static Vec_Ptr_t * Abc_NtkFindGoodOrder( Abc_Ntk_t * pNtk );
|
||||
|
||||
@@ -262,6 +262,11 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t
|
||||
If_CutForEachLeaf( pIfMan, pCutBest, pIfLeaf, i )
|
||||
Abc_ObjAddFanin( pNodeNew, Abc_NodeFromIf_rec(pNtkNew, pIfMan, pIfLeaf, vCover) );
|
||||
}
|
||||
// set the level of the new node
|
||||
{
|
||||
extern int Res_UpdateNetworkLevelNew( Abc_Obj_t * pObj );
|
||||
pNodeNew->Level = Res_UpdateNetworkLevelNew( pNodeNew );
|
||||
}
|
||||
// derive the function of this node
|
||||
if ( pIfMan->pPars->fTruth )
|
||||
{
|
||||
|
||||
@@ -331,17 +331,19 @@ extern void If_CutCopy( If_Man_t * p, If_Cut_t * pCutDest, If_Cut_t *
|
||||
extern void If_ManSortCuts( If_Man_t * p, int Mode );
|
||||
/*=== ifMan.c =============================================================*/
|
||||
extern If_Man_t * If_ManStart( If_Par_t * pPars );
|
||||
extern void If_ManRestart( If_Man_t * p );
|
||||
extern void If_ManStop( If_Man_t * p );
|
||||
extern If_Obj_t * If_ManCreateCi( If_Man_t * p );
|
||||
extern If_Obj_t * If_ManCreateCo( If_Man_t * p, If_Obj_t * pDriver, int fCompl0 );
|
||||
extern If_Obj_t * If_ManCreateAnd( If_Man_t * p, If_Obj_t * pFan0, int fCompl0, If_Obj_t * pFan1, int fCompl1 );
|
||||
extern If_Obj_t * If_ManCreateXnor( If_Man_t * p, If_Obj_t * pFan0, If_Obj_t * pFan1 );
|
||||
extern void If_ManCreateChoice( If_Man_t * p, If_Obj_t * pRepr );
|
||||
extern void If_ManSetupCutTriv( If_Man_t * p, If_Cut_t * pCut, int ObjId );
|
||||
extern void If_ManSetupCiCutSets( If_Man_t * p );
|
||||
extern If_Set_t * If_ManSetupNodeCutSet( If_Man_t * p, If_Obj_t * pObj );
|
||||
extern void If_ManDerefNodeCutSet( If_Man_t * p, If_Obj_t * pObj );
|
||||
extern void If_ManDerefChoiceCutSet( If_Man_t * p, If_Obj_t * pObj );
|
||||
extern void If_ManSetupSetAll( If_Man_t * p );
|
||||
extern void If_ManSetupSetAll( If_Man_t * p, int nCrossCut );
|
||||
/*=== ifMap.c =============================================================*/
|
||||
extern void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPreprocess );
|
||||
extern void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPreprocess );
|
||||
|
||||
@@ -48,7 +48,7 @@ int If_ManPerformMapping( If_Man_t * p )
|
||||
// create the CI cutsets
|
||||
If_ManSetupCiCutSets( p );
|
||||
// allocate memory for other cutsets
|
||||
If_ManSetupSetAll( p );
|
||||
If_ManSetupSetAll( p, If_ManCrossCut(p) );
|
||||
|
||||
// try sequential mapping
|
||||
if ( p->pPars->fSeqMap )
|
||||
|
||||
@@ -79,9 +79,38 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
|
||||
p->pConst1 = If_ManSetupObj( p );
|
||||
p->pConst1->Type = IF_CONST1;
|
||||
p->pConst1->fPhase = 1;
|
||||
p->nObjs[IF_CONST1]++;
|
||||
return p;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void If_ManRestart( If_Man_t * p )
|
||||
{
|
||||
FREE( p->pMemCi );
|
||||
Vec_PtrClear( p->vCis );
|
||||
Vec_PtrClear( p->vCos );
|
||||
Vec_PtrClear( p->vObjs );
|
||||
Vec_PtrClear( p->vMapped );
|
||||
Vec_PtrClear( p->vTemp );
|
||||
Mem_FixedRestart( p->pMemObj );
|
||||
// create the constant node
|
||||
p->pConst1 = If_ManSetupObj( p );
|
||||
p->pConst1->Type = IF_CONST1;
|
||||
p->pConst1->fPhase = 1;
|
||||
// reset the counter of other nodes
|
||||
p->nObjs[IF_CI] = p->nObjs[IF_CO] = p->nObjs[IF_AND] = 0;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
@@ -103,7 +132,6 @@ void If_ManStop( If_Man_t * p )
|
||||
if ( p->vLatchOrder ) Vec_PtrFree( p->vLatchOrder );
|
||||
if ( p->vLags ) Vec_IntFree( p->vLags );
|
||||
Mem_FixedStop( p->pMemObj, 0 );
|
||||
// Mem_FixedStop( p->pMemSet, 0 );
|
||||
FREE( p->pMemCi );
|
||||
FREE( p->pMemAnd );
|
||||
FREE( p->puTemp[0] );
|
||||
@@ -188,6 +216,25 @@ If_Obj_t * If_ManCreateAnd( If_Man_t * p, If_Obj_t * pFan0, int fCompl0, If_Obj_
|
||||
return pObj;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Create the new node assuming it does not exist.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
If_Obj_t * If_ManCreateXnor( If_Man_t * p, If_Obj_t * pFan0, If_Obj_t * pFan1 )
|
||||
{
|
||||
If_Obj_t * pRes1, * pRes2;
|
||||
pRes1 = If_ManCreateAnd( p, pFan0, 0, pFan1, 1 );
|
||||
pRes2 = If_ManCreateAnd( p, pFan0, 1, pFan1, 0 );
|
||||
return If_ManCreateAnd( p, pRes1, 1, pRes2, 1 );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Creates the choice node.]
|
||||
@@ -460,11 +507,10 @@ void If_ManDerefChoiceCutSet( If_Man_t * p, If_Obj_t * pObj )
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void If_ManSetupSetAll( If_Man_t * p )
|
||||
void If_ManSetupSetAll( If_Man_t * p, int nCrossCut )
|
||||
{
|
||||
If_Set_t * pCutSet;
|
||||
int i, nCrossCut, nCutSets;
|
||||
nCrossCut = If_ManCrossCut( p );
|
||||
int i, nCutSets;
|
||||
nCutSets = 128 + nCrossCut;
|
||||
p->pFreeList = p->pMemAnd = pCutSet = (If_Set_t *)malloc( nCutSets * p->nSetBytes );
|
||||
for ( i = 0; i < nCutSets; i++ )
|
||||
|
||||
@@ -87,6 +87,69 @@ struct Kit_Graph_t_
|
||||
Kit_Edge_t eRoot; // the pointer to the topmost node
|
||||
};
|
||||
|
||||
|
||||
// DSD node types
|
||||
typedef enum {
|
||||
KIT_DSD_NONE = 0, // 0: unknown
|
||||
KIT_DSD_CONST1, // 1: constant 1
|
||||
KIT_DSD_VAR, // 2: elementary variable
|
||||
KIT_DSD_AND, // 3: multi-input AND
|
||||
KIT_DSD_XOR, // 4: multi-input XOR
|
||||
KIT_DSD_PRIME // 5: arbitrary function of 3+ variables
|
||||
} Kit_Dsd_t;
|
||||
|
||||
// DSD node
|
||||
typedef struct Kit_DsdObj_t_ Kit_DsdObj_t;
|
||||
struct Kit_DsdObj_t_
|
||||
{
|
||||
unsigned Id : 6; // the number of this node
|
||||
unsigned Type : 3; // none, const, var, AND, XOR, MUX, PRIME
|
||||
unsigned fMark : 1; // finished checking output
|
||||
unsigned Offset : 8; // offset to the truth table
|
||||
unsigned nRefs : 8; // offset to the truth table
|
||||
unsigned nFans : 6; // the number of fanins of this node
|
||||
unsigned char pFans[0]; // the fanin literals
|
||||
};
|
||||
|
||||
// DSD network
|
||||
typedef struct Kit_DsdNtk_t_ Kit_DsdNtk_t;
|
||||
struct Kit_DsdNtk_t_
|
||||
{
|
||||
unsigned char nVars; // at most 16 (perhaps 18?)
|
||||
unsigned char nNodesAlloc; // the number of allocated nodes (at most nVars)
|
||||
unsigned char nNodes; // the number of nodes
|
||||
unsigned char Root; // the root of the tree
|
||||
unsigned * pMem; // memory for the truth tables (memory manager?)
|
||||
Kit_DsdObj_t * pNodes[0]; // the nodes
|
||||
};
|
||||
|
||||
// DSD manager
|
||||
typedef struct Kit_DsdMan_t_ Kit_DsdMan_t;
|
||||
struct Kit_DsdMan_t_
|
||||
{
|
||||
int nVars; // the maximum number of variables
|
||||
int nWords; // the number of words in TTs
|
||||
Vec_Ptr_t * vTtElems; // elementary truth tables
|
||||
Vec_Ptr_t * vTtNodes; // the node truth tables
|
||||
};
|
||||
|
||||
static inline int Kit_DsdVar2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
|
||||
static inline int Kit_DsdLit2Var( int Lit ) { return Lit >> 1; }
|
||||
static inline int Kit_DsdLitIsCompl( int Lit ) { return Lit & 1; }
|
||||
static inline int Kit_DsdLitNot( int Lit ) { return Lit ^ 1; }
|
||||
static inline int Kit_DsdLitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); }
|
||||
static inline int Kit_DsdLitRegular( int Lit ) { return Lit & 0xfe; }
|
||||
|
||||
static inline unsigned Kit_DsdObjOffset( int nFans ) { return (nFans >> 2) + ((nFans & 3) > 0); }
|
||||
static inline unsigned * Kit_DsdObjTruth( Kit_DsdObj_t * pObj ) { return pObj->Type == KIT_DSD_PRIME ? (unsigned *)pObj->pFans + pObj->Offset: NULL; }
|
||||
static inline Kit_DsdObj_t * Kit_DsdNtkObj( Kit_DsdNtk_t * pNtk, int Id ) { assert( Id >= 0 && Id < pNtk->nVars + pNtk->nNodes ); return Id < pNtk->nVars ? NULL : pNtk->pNodes[Id - pNtk->nVars]; }
|
||||
static inline Kit_DsdObj_t * Kit_DsdNtkRoot( Kit_DsdNtk_t * pNtk ) { return Kit_DsdNtkObj( pNtk, Kit_DsdLit2Var(pNtk->Root) ); }
|
||||
|
||||
#define Kit_DsdNtkForEachObj( pNtk, pObj, i ) \
|
||||
for ( i = 0; (i < (pNtk)->nNodes) && ((pObj) = (pNtk)->pNodes[i]); i++ )
|
||||
#define Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i ) \
|
||||
for ( i = 0; (i < (pObj)->nFans) && ((iLit) = (pObj)->pFans[i], 1); i++ )
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// MACRO DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -358,6 +421,13 @@ static inline void Kit_TruthAndPhase( unsigned * pOut, unsigned * pIn0, unsigned
|
||||
extern DdNode * Kit_SopToBdd( DdManager * dd, Kit_Sop_t * cSop, int nVars );
|
||||
extern DdNode * Kit_GraphToBdd( DdManager * dd, Kit_Graph_t * pGraph );
|
||||
extern DdNode * Kit_TruthToBdd( DdManager * dd, unsigned * pTruth, int nVars, int fMSBonTop );
|
||||
/*=== kitDsd.c ==========================================================*/
|
||||
extern Kit_DsdNtk_t * Kit_DsdDeriveNtk( unsigned * pTruth, int nVars, int nLutSize );
|
||||
extern unsigned * Kit_DsdTruthCompute( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk );
|
||||
extern void Kit_DsdPrint( FILE * pFile, Kit_DsdNtk_t * pNtk );
|
||||
extern Kit_DsdNtk_t * Kit_DsdDecompose( unsigned * pTruth, int nVars );
|
||||
extern void Kit_DsdNtkFree( Kit_DsdNtk_t * pNtk );
|
||||
extern int Kit_DsdNonDsdSizeMax( Kit_DsdNtk_t * pNtk );
|
||||
/*=== kitFactor.c ==========================================================*/
|
||||
extern Kit_Graph_t * Kit_SopFactor( Vec_Int_t * vCover, int fCompl, int nVars, Vec_Int_t * vMemory );
|
||||
/*=== kitGraph.c ==========================================================*/
|
||||
|
||||
@@ -24,74 +24,6 @@
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct Kit_DsdMan_t_ Kit_DsdMan_t;
|
||||
typedef struct Kit_DsdNtk_t_ Kit_DsdNtk_t;
|
||||
typedef struct Kit_DsdObj_t_ Kit_DsdObj_t;
|
||||
|
||||
// DSD node types
|
||||
typedef enum {
|
||||
KIT_DSD_NONE = 0, // 0: unknown
|
||||
KIT_DSD_CONST1, // 1: constant 1
|
||||
KIT_DSD_VAR, // 2: elementary variable
|
||||
KIT_DSD_AND, // 3: multi-input AND
|
||||
KIT_DSD_XOR, // 4: multi-input XOR
|
||||
KIT_DSD_PRIME // 5: arbitrary function of 3+ variables
|
||||
} Kit_Dsd_t;
|
||||
|
||||
// DSD manager
|
||||
struct Kit_DsdMan_t_
|
||||
{
|
||||
int nVars; // the maximum number of variables
|
||||
int nWords; // the number of words in TTs
|
||||
Vec_Ptr_t * vTtElems; // elementary truth tables
|
||||
Vec_Ptr_t * vTtNodes; // the node truth tables
|
||||
};
|
||||
|
||||
// DSD network
|
||||
struct Kit_DsdNtk_t_
|
||||
{
|
||||
unsigned char nVars; // at most 16 (perhaps 18?)
|
||||
unsigned char nNodesAlloc; // the number of allocated nodes (at most nVars)
|
||||
unsigned char nNodes; // the number of nodes
|
||||
unsigned char Root; // the root of the tree
|
||||
unsigned * pMem; // memory for the truth tables (memory manager?)
|
||||
Kit_DsdObj_t * pNodes[0]; // the nodes
|
||||
};
|
||||
|
||||
// DSD node
|
||||
struct Kit_DsdObj_t_
|
||||
{
|
||||
unsigned Id : 6; // the number of this node
|
||||
unsigned Type : 3; // none, const, var, AND, XOR, MUX, PRIME
|
||||
unsigned fMark : 1; // finished checking output
|
||||
unsigned Offset : 8; // offset to the truth table
|
||||
unsigned nRefs : 8; // offset to the truth table
|
||||
unsigned nFans : 6; // the number of fanins of this node
|
||||
unsigned char pFans[0]; // the fanin literals
|
||||
};
|
||||
|
||||
static inline int Kit_DsdVar2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
|
||||
static inline int Kit_DsdLit2Var( int Lit ) { return Lit >> 1; }
|
||||
static inline int Kit_DsdLitIsCompl( int Lit ) { return Lit & 1; }
|
||||
static inline int Kit_DsdLitNot( int Lit ) { return Lit ^ 1; }
|
||||
static inline int Kit_DsdLitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); }
|
||||
static inline int Kit_DsdLitRegular( int Lit ) { return Lit & 0xfe; }
|
||||
|
||||
static inline unsigned Kit_DsdObjOffset( int nFans ) { return (nFans >> 2) + ((nFans & 3) > 0); }
|
||||
static inline unsigned * Kit_DsdObjTruth( Kit_DsdObj_t * pObj ) { return pObj->Type == KIT_DSD_PRIME ? (unsigned *)pObj->pFans + pObj->Offset: NULL; }
|
||||
static inline Kit_DsdObj_t * Kit_DsdNtkObj( Kit_DsdNtk_t * pNtk, int Id ) { assert( Id >= 0 && Id < pNtk->nVars + pNtk->nNodes ); return Id < pNtk->nVars ? NULL : pNtk->pNodes[Id - pNtk->nVars]; }
|
||||
static inline Kit_DsdObj_t * Kit_DsdNtkRoot( Kit_DsdNtk_t * pNtk ) { return Kit_DsdNtkObj( pNtk, Kit_DsdLit2Var(pNtk->Root) ); }
|
||||
|
||||
#define Kit_DsdNtkForEachObj( pNtk, pObj, i ) \
|
||||
for ( i = 0; (i < (pNtk)->nNodes) && ((pObj) = (pNtk)->pNodes[i]); i++ )
|
||||
#define Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i ) \
|
||||
for ( i = 0; (i < (pObj)->nFans) && ((iLit) = (pObj)->pFans[i], 1); i++ )
|
||||
|
||||
extern unsigned * Kit_DsdTruthCompute( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk );
|
||||
extern void Kit_DsdPrint( FILE * pFile, Kit_DsdNtk_t * pNtk );
|
||||
extern Kit_DsdNtk_t * Kit_DsdDecompose( unsigned * pTruth, int nVars );
|
||||
extern void Kit_DsdNtkFree( Kit_DsdNtk_t * pNtk );
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -483,7 +415,7 @@ int Kit_DsdCountLuts_rec( Kit_DsdNtk_t * pNtk, int nLutSize, int Id, int * pCoun
|
||||
return nLutSize - 2;
|
||||
}
|
||||
assert( pObj->Type == KIT_DSD_PRIME );
|
||||
if ( (int)pObj->nFans > nLutSize )
|
||||
if ( (int)pObj->nFans > nLutSize ) //+ 1 )
|
||||
{
|
||||
*pCounter = 1000;
|
||||
return 0;
|
||||
@@ -491,6 +423,8 @@ int Kit_DsdCountLuts_rec( Kit_DsdNtk_t * pNtk, int nLutSize, int Id, int * pCoun
|
||||
Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
|
||||
Kit_DsdCountLuts_rec( pNtk, nLutSize, Kit_DsdLit2Var(iLit), pCounter );
|
||||
(*pCounter)++;
|
||||
// if ( (int)pObj->nFans == nLutSize + 1 )
|
||||
// (*pCounter)++;
|
||||
return nLutSize - pObj->nFans;
|
||||
}
|
||||
|
||||
@@ -518,6 +452,31 @@ int Kit_DsdCountLuts( Kit_DsdNtk_t * pNtk, int nLutSize )
|
||||
return Counter;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Counts the number of blocks of the given number of inputs.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Kit_DsdNonDsdSizeMax( Kit_DsdNtk_t * pNtk )
|
||||
{
|
||||
Kit_DsdObj_t * pObj;
|
||||
unsigned i, nSizeMax = 0;
|
||||
Kit_DsdNtkForEachObj( pNtk, pObj, i )
|
||||
{
|
||||
if ( pObj->Type != KIT_DSD_PRIME )
|
||||
continue;
|
||||
if ( nSizeMax < pObj->nFans )
|
||||
nSizeMax = pObj->nFans;
|
||||
}
|
||||
return nSizeMax;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
@@ -1197,6 +1156,50 @@ int Kit_DsdEval( unsigned * pTruth, int nVars, int nLutSize )
|
||||
return Result;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Performs decomposition of the truth table.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Kit_DsdNtk_t * Kit_DsdDeriveNtk( unsigned * pTruth, int nVars, int nLutSize )
|
||||
{
|
||||
// Kit_DsdMan_t * p;
|
||||
Kit_DsdNtk_t * pNtk;//, * pTemp;
|
||||
// unsigned * pTruthC;
|
||||
// int Result;
|
||||
|
||||
// decompose the function
|
||||
pNtk = Kit_DsdDecompose( pTruth, nVars );
|
||||
|
||||
// pNtk = Kit_DsdExpand( pTemp = pNtk );
|
||||
// Kit_DsdNtkFree( pTemp );
|
||||
|
||||
// Result = Kit_DsdCountLuts( pNtk, nLutSize );
|
||||
|
||||
// printf( "\n" );
|
||||
// Kit_DsdPrint( stdout, pNtk );
|
||||
// printf( "Eval = %d.\n", Result );
|
||||
|
||||
/*
|
||||
// recompute the truth table
|
||||
p = Kit_DsdManAlloc( nVars );
|
||||
pTruthC = Kit_DsdTruthCompute( p, pNtk );
|
||||
if ( !Extra_TruthIsEqual( pTruth, pTruthC, nVars ) )
|
||||
printf( "Verification failed.\n" );
|
||||
Kit_DsdManFree( p );
|
||||
*/
|
||||
|
||||
// Kit_DsdNtkFree( pNtk );
|
||||
// return Result;
|
||||
return pNtk;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Performs decomposition of the truth table.]
|
||||
|
||||
@@ -1216,7 +1216,7 @@ unsigned Kit_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVars,
|
||||
// short pStore2[32];
|
||||
unsigned * pIn = pInOut, * pOut = pAux, * pTemp;
|
||||
int nWords = Kit_TruthWordNum( nVars );
|
||||
int i, Temp, fChange, Counter, nOnes;//, k, j, w, Limit;
|
||||
int i, Temp, fChange, Counter;//, nOnes;//, k, j, w, Limit;
|
||||
unsigned uCanonPhase;
|
||||
|
||||
// canonicize output
|
||||
|
||||
@@ -25,12 +25,30 @@
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int Res_UpdateNetworkLevelNew( Abc_Obj_t * pObj );
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Computes the level of the node using its fanin levels.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Res_UpdateNetworkLevelNew( Abc_Obj_t * pObj )
|
||||
{
|
||||
Abc_Obj_t * pFanin;
|
||||
int i, Level = 0;
|
||||
Abc_ObjForEachFanin( pObj, pFanin, i )
|
||||
Level = ABC_MAX( Level, (int)pFanin->Level );
|
||||
return Level + 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Incrementally updates level of the nodes.]
|
||||
@@ -42,18 +60,10 @@ static int Res_UpdateNetworkLevelNew( Abc_Obj_t * pObj );
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Res_UpdateNetwork( Abc_Obj_t * pObj, Vec_Ptr_t * vFanins, Hop_Obj_t * pFunc, Vec_Vec_t * vLevels )
|
||||
void Res_UpdateNetworkLevel( Abc_Obj_t * pObjNew, Vec_Vec_t * vLevels )
|
||||
{
|
||||
Abc_Obj_t * pObjNew, * pFanin, * pFanout, * pTemp;
|
||||
Abc_Obj_t * pFanout, * pTemp;
|
||||
int Lev, k, m;
|
||||
// create the new node
|
||||
pObjNew = Abc_NtkCreateNode( pObj->pNtk );
|
||||
pObjNew->pData = pFunc;
|
||||
Vec_PtrForEachEntry( vFanins, pFanin, k )
|
||||
Abc_ObjAddFanin( pObjNew, pFanin );
|
||||
// replace the old node by the new node
|
||||
pObjNew->Level = pObj->Level;
|
||||
Abc_ObjReplace( pObj, pObjNew );
|
||||
// check if level has changed
|
||||
if ( (int)pObjNew->Level == Res_UpdateNetworkLevelNew(pObjNew) )
|
||||
return;
|
||||
@@ -81,7 +91,7 @@ void Res_UpdateNetwork( Abc_Obj_t * pObj, Vec_Ptr_t * vFanins, Hop_Obj_t * pFunc
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Computes the level of the node using its fanin levels.]
|
||||
Synopsis [Incrementally updates level of the nodes.]
|
||||
|
||||
Description []
|
||||
|
||||
@@ -90,13 +100,20 @@ void Res_UpdateNetwork( Abc_Obj_t * pObj, Vec_Ptr_t * vFanins, Hop_Obj_t * pFunc
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Res_UpdateNetworkLevelNew( Abc_Obj_t * pObj )
|
||||
void Res_UpdateNetwork( Abc_Obj_t * pObj, Vec_Ptr_t * vFanins, Hop_Obj_t * pFunc, Vec_Vec_t * vLevels )
|
||||
{
|
||||
Abc_Obj_t * pFanin;
|
||||
int i, Level = 0;
|
||||
Abc_ObjForEachFanin( pObj, pFanin, i )
|
||||
Level = ABC_MAX( Level, (int)pFanin->Level );
|
||||
return Level + 1;
|
||||
Abc_Obj_t * pObjNew, * pFanin;
|
||||
int k;
|
||||
// create the new node
|
||||
pObjNew = Abc_NtkCreateNode( pObj->pNtk );
|
||||
pObjNew->pData = pFunc;
|
||||
Vec_PtrForEachEntry( vFanins, pFanin, k )
|
||||
Abc_ObjAddFanin( pObjNew, pFanin );
|
||||
// replace the old node by the new node
|
||||
pObjNew->Level = pObj->Level;
|
||||
Abc_ObjReplace( pObj, pObjNew );
|
||||
// update the level of the node
|
||||
Res_UpdateNetworkLevel( pObjNew, vLevels );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user