Commit 91ca630b by Alan Mishchenko

Version abc51002

parent 78fbd336
...@@ -270,6 +270,14 @@ SOURCE=.\src\base\abci\abcVerify.c ...@@ -270,6 +270,14 @@ SOURCE=.\src\base\abci\abcVerify.c
# PROP Default_Filter "" # PROP Default_Filter ""
# Begin Source File # Begin Source File
SOURCE=.\src\base\abcs\abcFpgaDelay.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abcs\abcFpgaSeq.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abcs\abcRetCore.c SOURCE=.\src\base\abcs\abcRetCore.c
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -1130,6 +1138,10 @@ SOURCE=.\src\opt\cut\cutNode.c ...@@ -1130,6 +1138,10 @@ SOURCE=.\src\opt\cut\cutNode.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\opt\cut\cutOracle.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutSeq.c SOURCE=.\src\opt\cut\cutSeq.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
No preview for this file type
...@@ -69,7 +69,7 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams ) ...@@ -69,7 +69,7 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
if ( Abc_ObjFanoutNum(pObj) > 0 ) if ( Abc_ObjFanoutNum(pObj) > 0 )
Cut_NodeSetTriv( p, pObj->Id ); Cut_NodeSetTriv( p, pObj->Id );
// compute cuts for internal nodes // compute cuts for internal nodes
vNodes = Abc_AigDfs( pNtk, 0, 1 ); vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
vChoices = Vec_IntAlloc( 100 ); vChoices = Vec_IntAlloc( 100 );
Vec_PtrForEachEntry( vNodes, pObj, i ) Vec_PtrForEachEntry( vNodes, pObj, i )
{ {
...@@ -105,13 +105,72 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams ) ...@@ -105,13 +105,72 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
if ( pParams->fMulti ) if ( pParams->fMulti )
Abc_NtkBalanceDetach(pNtk); Abc_NtkBalanceDetach(pNtk);
PRT( "Total", clock() - clk ); PRT( "Total", clock() - clk );
Abc_NtkPrintCuts_( p, pNtk, 0 ); //Abc_NtkPrintCuts_( p, pNtk, 0 );
// Cut_ManPrintStatsToFile( p, pNtk->pSpec, clock() - clk ); // Cut_ManPrintStatsToFile( p, pNtk->pSpec, clock() - clk );
return p; return p;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Cut computation using the oracle.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * p )
{
Abc_Obj_t * pObj;
Vec_Ptr_t * vNodes;
int i, clk = clock();
int fDrop = Cut_OracleReadDrop(p);
assert( Abc_NtkIsStrash(pNtk) );
// prepare cut droppping
if ( fDrop )
Cut_OracleSetFanoutCounts( p, Abc_NtkFanoutCounts(pNtk) );
// set cuts for PIs
Abc_NtkForEachCi( pNtk, pObj, i )
if ( Abc_ObjFanoutNum(pObj) > 0 )
Cut_OracleNodeSetTriv( p, pObj->Id );
// compute cuts for internal nodes
vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
Vec_PtrForEachEntry( vNodes, pObj, i )
{
// when we reached a CO, it is time to deallocate the cuts
if ( Abc_ObjIsCo(pObj) )
{
if ( fDrop )
Cut_OracleTryDroppingCuts( p, Abc_ObjFaninId0(pObj) );
continue;
}
// skip constant node, it has no cuts
if ( Abc_NodeIsConst(pObj) )
continue;
// compute the cuts to the internal node
Cut_OracleComputeCuts( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
// consider dropping the fanins cuts
if ( fDrop )
{
Cut_OracleTryDroppingCuts( p, Abc_ObjFaninId0(pObj) );
Cut_OracleTryDroppingCuts( p, Abc_ObjFaninId1(pObj) );
}
}
Vec_PtrFree( vNodes );
//PRT( "Total", clock() - clk );
//Abc_NtkPrintCuts_( p, pNtk, 0 );
}
/**Function*************************************************************
Synopsis [Computes the cuts for the network.] Synopsis [Computes the cuts for the network.]
Description [] Description []
...@@ -156,7 +215,6 @@ Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams ) ...@@ -156,7 +215,6 @@ Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
// compute the cuts for the internal nodes // compute the cuts for the internal nodes
Abc_AigForEachAnd( pNtk, pObj, i ) Abc_AigForEachAnd( pNtk, pObj, i )
Abc_NodeGetCutsSeq( p, pObj, nIters==0 ); Abc_NodeGetCutsSeq( p, pObj, nIters==0 );
Abc_NtkPrintCuts( p, pNtk, 1 );
// merge the new cuts with the old cuts // merge the new cuts with the old cuts
Abc_NtkForEachPi( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
Cut_NodeNewMergeWithOld( p, pObj->Id ); Cut_NodeNewMergeWithOld( p, pObj->Id );
...@@ -183,7 +241,7 @@ Abc_NtkPrintCuts( p, pNtk, 1 ); ...@@ -183,7 +241,7 @@ Abc_NtkPrintCuts( p, pNtk, 1 );
pObj->fMarkC = 0; pObj->fMarkC = 0;
PRT( "Total", clock() - clk ); PRT( "Total", clock() - clk );
printf( "Converged after %d iterations.\n", nIters ); printf( "Converged after %d iterations.\n", nIters );
Abc_NtkPrintCuts( p, pNtk, 1 ); //Abc_NtkPrintCuts( p, pNtk, 1 );
return p; return p;
} }
...@@ -225,7 +283,7 @@ void * Abc_NodeGetCuts( void * p, Abc_Obj_t * pObj, int fMulti ) ...@@ -225,7 +283,7 @@ void * Abc_NodeGetCuts( void * p, Abc_Obj_t * pObj, int fMulti )
assert( Abc_NtkIsStrash(pObj->pNtk) ); assert( Abc_NtkIsStrash(pObj->pNtk) );
assert( Abc_ObjFaninNum(pObj) == 2 ); assert( Abc_ObjFaninNum(pObj) == 2 );
return Cut_NodeComputeCuts( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj), return Cut_NodeComputeCuts( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), 1, 1, fTriv ); Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), fTriv );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -244,7 +302,7 @@ void Abc_NodeGetCutsSeq( void * p, Abc_Obj_t * pObj, int fTriv ) ...@@ -244,7 +302,7 @@ void Abc_NodeGetCutsSeq( void * p, Abc_Obj_t * pObj, int fTriv )
int CutSetNum; int CutSetNum;
assert( Abc_NtkIsSeq(pObj->pNtk) ); assert( Abc_NtkIsSeq(pObj->pNtk) );
assert( Abc_ObjFaninNum(pObj) == 2 ); assert( Abc_ObjFaninNum(pObj) == 2 );
// fTriv = pObj->fMarkC ? 0 : fTriv; fTriv = pObj->fMarkC ? 0 : fTriv;
CutSetNum = pObj->fMarkC ? (int)pObj->pCopy : -1; CutSetNum = pObj->fMarkC ? (int)pObj->pCopy : -1;
Cut_NodeComputeCutsSeq( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj), Cut_NodeComputeCutsSeq( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), Abc_ObjFaninL0(pObj), Abc_ObjFaninL1(pObj), fTriv, CutSetNum ); Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), Abc_ObjFaninL0(pObj), Abc_ObjFaninL1(pObj), fTriv, CutSetNum );
......
/**CFile****************************************************************
FileName [abcFpgaSeq.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Network and node package.]
Synopsis [Mapping for FPGAs using sequential cuts.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: abcFpgaSeq.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abcs.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
Abc_Ntk_t * Abc_NtkMapSeq( Abc_Ntk_t * pNtk, int fVerbose ) { return 0; }
extern Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams );
extern void Abc_NtkFpgaSeqRetimeDelayLags( Seq_FpgaMan_t * p );
static Seq_FpgaMan_t * Abc_NtkFpgaSeqStart( Abc_Ntk_t * pNtk, int fVerbose );
static void Abc_NtkFpgaSeqStop( Seq_FpgaMan_t * p );
static Abc_Ntk_t * Abc_NtkFpgaSeqConstruct( Seq_FpgaMan_t * p );
static void Abc_NtkFpgaSeqRetime( Seq_FpgaMan_t * p, Abc_Ntk_t * pNtkNew );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Retimes AIG for optimal delay.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkFpgaSeq( Abc_Ntk_t * pNtk, int fVerbose )
{
Abc_Ntk_t * pNtkNew;
Seq_FpgaMan_t * p;
Cut_Params_t Params, * pParams = &Params;
int clk;
assert( Abc_NtkIsSeq( pNtk ) );
// get the sequential FPGA manager
p = Abc_NtkFpgaSeqStart( pNtk, fVerbose );
// create the cuts
memset( pParams, 0, sizeof(Cut_Params_t) );
pParams->nVarsMax = 5; // the max cut size ("k" of the k-feasible cuts)
pParams->nKeepMax = 1000; // the max number of cuts kept at a node
pParams->fTruth = 0; // compute truth tables
pParams->fFilter = 1; // filter dominated cuts
pParams->fSeq = 1; // compute sequential cuts
pParams->fVerbose = 0; // the verbosiness flag
clk = clock();
p->pMan = Abc_NtkSeqCuts( pNtk, pParams );
p->timeCuts += clock() - clk;
// find best arrival times (p->vArrivals) and free the cuts
// select mapping (p->vMapping) and remember best cuts (p->vMapCuts)
clk = clock();
Abc_NtkFpgaSeqRetimeDelayLags( p );
p->timeDelay += clock() - clk;
return NULL;
// construct the network
clk = clock();
pNtkNew = Abc_NtkFpgaSeqConstruct( p );
p->timeNtk += clock() - clk;
// retime the network
clk = clock();
Abc_NtkFpgaSeqRetime( p, pNtkNew );
p->timeRet += clock() - clk;
// remove temporaries
Abc_NtkFpgaSeqStop( p );
// check the resulting network
if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkFpgaSeq(): Network check has failed.\n" );
return pNtkNew;
}
/**Function*************************************************************
Synopsis [Starts sequential FPGA mapper.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Seq_FpgaMan_t * Abc_NtkFpgaSeqStart( Abc_Ntk_t * pNtk, int fVerbose )
{
Seq_FpgaMan_t * p;
// create the FPGA mapping manager
p = ALLOC( Seq_FpgaMan_t, 1 );
memset( p, 0, sizeof(Seq_FpgaMan_t) );
p->pNtk = pNtk;
p->pMan = NULL;
p->vArrivals = Vec_IntAlloc( 0 );
p->vBestCuts = Vec_PtrAlloc( 0 );
p->vMapping = Vec_PtrAlloc( 0 );
p->vMapCuts = Vec_PtrAlloc( 0 );
p->vLagsMap = Vec_StrStart( Abc_NtkObjNumMax(pNtk) );
p->fVerbose = fVerbose;
return p;
}
/**Function*************************************************************
Synopsis [Stops sequential FPGA mapper.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkFpgaSeqStop( Seq_FpgaMan_t * p )
{
if ( p->fVerbose )
{
printf( "Sequential FPGA mapping stats:\n" );
// printf( "Total allocated = %8d.\n", p->nCutsAlloc );
// printf( "Cuts per node = %8.1f\n", ((float)(p->nCutsCur-p->nCutsTriv))/p->nNodes );
PRT( "Cuts ", p->timeCuts );
PRT( "Arrival", p->timeDelay );
PRT( "Network", p->timeNtk );
PRT( "Retime ", p->timeRet );
}
Vec_IntFree( p->vArrivals );
Vec_PtrFree( p->vBestCuts );
Vec_PtrFree( p->vMapping );
Vec_VecFree( (Vec_Vec_t *)p->vMapCuts );
Vec_StrFree( p->vLagsMap );
free( p );
}
/**Function*************************************************************
Synopsis [Construct the final network after mapping.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Abc_NtkFpgaSeqConstruct( Seq_FpgaMan_t * p )
{
Abc_Ntk_t * pNtk = NULL;
return pNtk;
}
/**Function*************************************************************
Synopsis [Retimes the final network after mapping.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkFpgaSeqRetime( Seq_FpgaMan_t * p, Abc_Ntk_t * pNtkNew )
{
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...@@ -24,12 +24,6 @@ ...@@ -24,12 +24,6 @@
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// storing arrival times in the nodes
static inline int Abc_NodeReadLValue( Abc_Obj_t * pNode ) { return Vec_IntEntry( (pNode)->pNtk->pData, (pNode)->Id ); }
static inline void Abc_NodeSetLValue( Abc_Obj_t * pNode, int Value ) { Vec_IntWriteEntry( (pNode)->pNtk->pData, (pNode)->Id, (Value) ); }
//static inline int Abc_NodeGetLag( int LValue, int Fi ) { return LValue/Fi - (int)(LValue % Fi == 0); }
static inline int Abc_NodeGetLag( int LValue, int Fi ) { return (LValue + 256*Fi)/Fi - 256 - (int)(LValue % Fi == 0); }
// the internal procedures // the internal procedures
static int Abc_NtkRetimeSearch_rec( Abc_Ntk_t * pNtk, int FiMin, int FiMax, int fVerbose ); static int Abc_NtkRetimeSearch_rec( Abc_Ntk_t * pNtk, int FiMin, int FiMax, int fVerbose );
static int Abc_NtkRetimeForPeriod( Abc_Ntk_t * pNtk, int Fi, int fVerbose ); static int Abc_NtkRetimeForPeriod( Abc_Ntk_t * pNtk, int Fi, int fVerbose );
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#include "abc.h" #include "abc.h"
#include "cut.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// PARAMETERS /// /// PARAMETERS ///
...@@ -38,6 +39,25 @@ ...@@ -38,6 +39,25 @@
/// BASIC TYPES /// /// BASIC TYPES ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
typedef struct Seq_FpgaMan_t_ Seq_FpgaMan_t;
struct Seq_FpgaMan_t_
{
Abc_Ntk_t * pNtk; // the network to be mapped
Cut_Man_t * pMan; // the cut manager
Vec_Int_t * vArrivals; // the arrival times (L-Values of nodes)
Vec_Ptr_t * vBestCuts; // the best cuts for nodes
Vec_Ptr_t * vMapping; // the nodes used in the mapping
Vec_Ptr_t * vMapCuts; // the info about the cut of each mapped node
Vec_Str_t * vLagsMap; // the lags of the mapped nodes
int fVerbose; // the verbose flag
// runtime stats
int timeCuts; // runtime to compute the cuts
int timeDelay; // runtime to compute the L-values
int timeRet; // runtime to retime the resulting network
int timeNtk; // runtime to create the final network
};
// representation of latch on the edge // representation of latch on the edge
typedef struct Abc_RetEdge_t_ Abc_RetEdge_t; typedef struct Abc_RetEdge_t_ Abc_RetEdge_t;
struct Abc_RetEdge_t_ // 1 word struct Abc_RetEdge_t_ // 1 word
...@@ -61,6 +81,12 @@ static inline Abc_RetEdge_t Abc_Int2RetEdge( int Num ) { return *((A ...@@ -61,6 +81,12 @@ static inline Abc_RetEdge_t Abc_Int2RetEdge( int Num ) { return *((A
static inline int Abc_RetStep2Int( Abc_RetStep_t Str ) { return *((int *)&Str); } static inline int Abc_RetStep2Int( Abc_RetStep_t Str ) { return *((int *)&Str); }
static inline Abc_RetStep_t Abc_Int2RetStep( int Num ) { return *((Abc_RetStep_t *)&Num); } static inline Abc_RetStep_t Abc_Int2RetStep( int Num ) { return *((Abc_RetStep_t *)&Num); }
// storing arrival times in the nodes
static inline int Abc_NodeReadLValue( Abc_Obj_t * pNode ) { return Vec_IntEntry( (pNode)->pNtk->pData, (pNode)->Id ); }
static inline void Abc_NodeSetLValue( Abc_Obj_t * pNode, int Value ) { Vec_IntWriteEntry( (pNode)->pNtk->pData, (pNode)->Id, (Value) ); }
//static inline int Abc_NodeGetLag( int LValue, int Fi ) { return LValue/Fi - (int)(LValue % Fi == 0); }
static inline int Abc_NodeGetLag( int LValue, int Fi ) { return (LValue + 256*Fi)/Fi - 256 - (int)(LValue % Fi == 0); }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// MACRO DEFITIONS /// /// MACRO DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -283,6 +283,7 @@ extern void Extra_Truth4VarN( unsigned short ** puCanons, char *** puPhas ...@@ -283,6 +283,7 @@ extern void Extra_Truth4VarN( unsigned short ** puCanons, char *** puPhas
extern unsigned short Extra_TruthPerm4One( unsigned uTruth, int Phase ); extern unsigned short Extra_TruthPerm4One( unsigned uTruth, int Phase );
extern unsigned Extra_TruthPerm5One( unsigned uTruth, int Phase ); extern unsigned Extra_TruthPerm5One( unsigned uTruth, int Phase );
extern void Extra_TruthPerm6One( unsigned * uTruth, int Phase, unsigned * uTruthRes ); extern void Extra_TruthPerm6One( unsigned * uTruth, int Phase, unsigned * uTruthRes );
extern void Extra_TruthExpand( int nVars, int nWords, unsigned * puTruth, unsigned uPhase, unsigned * puTruthR );
/* precomputing tables for permutation mapping */ /* precomputing tables for permutation mapping */
extern void ** Extra_ArrayAlloc( int nCols, int nRows, int Size ); extern void ** Extra_ArrayAlloc( int nCols, int nRows, int Size );
extern unsigned short ** Extra_TruthPerm43(); extern unsigned short ** Extra_TruthPerm43();
......
...@@ -40,7 +40,7 @@ typedef struct Abc_Fan_t_ Abc_Fan_t; ...@@ -40,7 +40,7 @@ typedef struct Abc_Fan_t_ Abc_Fan_t;
struct Abc_Fan_t_ // 1 word struct Abc_Fan_t_ // 1 word
{ {
unsigned iFan : 24; // the ID of the object unsigned iFan : 24; // the ID of the object
unsigned nLats : 7; // the number of latches (up to 31) unsigned nLats : 7; // the number of latches (up to 127)
unsigned fCompl : 1; // the complemented attribute unsigned fCompl : 1; // the complemented attribute
}; };
......
...@@ -29,32 +29,40 @@ ...@@ -29,32 +29,40 @@
/// PARAMETERS /// /// PARAMETERS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#define CUT_SIZE_MIN 3 // the min K of the K-feasible cut computation
#define CUT_SIZE_MAX 8 // the max K of the K-feasible cut computation
#define CUT_SHIFT 8 // the number of bits for storing latch number in the cut leaves
#define CUT_MASK 0xFF // the mask to get the stored latch number
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// BASIC TYPES /// /// BASIC TYPES ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
typedef struct Cut_ManStruct_t_ Cut_Man_t; typedef struct Cut_ManStruct_t_ Cut_Man_t;
typedef struct Cut_OracleStruct_t_ Cut_Oracle_t;
typedef struct Cut_CutStruct_t_ Cut_Cut_t; typedef struct Cut_CutStruct_t_ Cut_Cut_t;
typedef struct Cut_ParamsStruct_t_ Cut_Params_t; typedef struct Cut_ParamsStruct_t_ Cut_Params_t;
struct Cut_ParamsStruct_t_ struct Cut_ParamsStruct_t_
{ {
int nVarsMax; // the max cut size ("k" of the k-feasible cuts) int nVarsMax; // the max cut size ("k" of the k-feasible cuts)
int nKeepMax; // the max number of cuts kept at a node int nKeepMax; // the max number of cuts kept at a node
int nIdsMax; // the max number of IDs of cut objects int nIdsMax; // the max number of IDs of cut objects
int nCutSet; // the number of nodes in the cut set int nCutSet; // the number of nodes in the cut set
int fTruth; // compute truth tables int fTruth; // compute truth tables
int fFilter; // filter dominated cuts int fFilter; // filter dominated cuts
int fSeq; // compute sequential cuts int fSeq; // compute sequential cuts
int fDrop; // drop cuts on the fly int fDrop; // drop cuts on the fly
int fMulti; // compute cuts in multi-input AND gate graph int fMulti; // compute cuts in multi-input AND gate graph
int fVerbose; // the verbosiness flag int fRecord; // record the cut computation flow
int fVerbose; // the verbosiness flag
}; };
struct Cut_CutStruct_t_ struct Cut_CutStruct_t_
{ {
unsigned uTruth : 16; // truth table for 4-input cuts unsigned Num0 : 11; // temporary number
unsigned uPhase : 6; // the phase when mapping into a canonical form unsigned Num1 : 11; // temporary number
unsigned fSimul : 1; // the value of cut's output at 000.. pattern unsigned fSimul : 1; // the value of cut's output at 000.. pattern
unsigned fCompl : 1; // the cut is complemented unsigned fCompl : 1; // the cut is complemented
unsigned nVarsMax : 4; // the max number of vars [4-6] unsigned nVarsMax : 4; // the max number of vars [4-6]
...@@ -64,15 +72,13 @@ struct Cut_CutStruct_t_ ...@@ -64,15 +72,13 @@ struct Cut_CutStruct_t_
int pLeaves[0]; // the array of leaves int pLeaves[0]; // the array of leaves
}; };
static inline unsigned * Cut_CutReadTruth( Cut_Cut_t * p ) { if ( p->nVarsMax == 4 ) return (unsigned *)p; return (unsigned *)(p->pLeaves + p->nVarsMax); }
static inline unsigned Cut_CutReadPhase( Cut_Cut_t * p ) { return p->uPhase; }
static inline int Cut_CutReadLeaveNum( Cut_Cut_t * p ) { return p->nLeaves; } static inline int Cut_CutReadLeaveNum( Cut_Cut_t * p ) { return p->nLeaves; }
static inline int * Cut_CutReadLeaves( Cut_Cut_t * p ) { return p->pLeaves; } static inline int * Cut_CutReadLeaves( Cut_Cut_t * p ) { return p->pLeaves; }
static inline unsigned * Cut_CutReadTruth( Cut_Cut_t * p ) { return (unsigned *)(p->pLeaves + p->nVarsMax); }
static inline void Cut_CutWriteTruth( Cut_Cut_t * p, unsigned * puTruth ) { static inline void Cut_CutWriteTruth( Cut_Cut_t * p, unsigned * puTruth ) {
if ( p->nVarsMax == 4 ) { p->uTruth = *puTruth; return; } int i;
p->pLeaves[p->nVarsMax] = (int)puTruth[0]; for ( i = (p->nVarsMax <= 5) ? 0 : ((1 << (p->nVarsMax - 5)) - 1); i >= 0; i-- )
if ( p->nVarsMax == 6 ) p->pLeaves[p->nVarsMax + 1] = (int)puTruth[1]; p->pLeaves[p->nVarsMax + i] = (int)puTruth[i];
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -104,14 +110,21 @@ extern void Cut_ManPrintStatsToFile( Cut_Man_t * p, char * pFileName ...@@ -104,14 +110,21 @@ extern void Cut_ManPrintStatsToFile( Cut_Man_t * p, char * pFileName
extern void Cut_ManSetFanoutCounts( Cut_Man_t * p, Vec_Int_t * vFanCounts ); extern void Cut_ManSetFanoutCounts( Cut_Man_t * p, Vec_Int_t * vFanCounts );
extern int Cut_ManReadVarsMax( Cut_Man_t * p ); extern int Cut_ManReadVarsMax( Cut_Man_t * p );
/*=== cutNode.c ==========================================================*/ /*=== cutNode.c ==========================================================*/
extern Cut_Cut_t * Cut_NodeComputeCuts( Cut_Man_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int fNew0, int fNew1, int fTriv ); extern Cut_Cut_t * Cut_NodeComputeCuts( Cut_Man_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int fTriv );
extern Cut_Cut_t * Cut_NodeDoComputeCuts( Cut_Man_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int fNew0, int fNew1, int fTriv );
extern Cut_Cut_t * Cut_NodeUnionCuts( Cut_Man_t * p, Vec_Int_t * vNodes ); extern Cut_Cut_t * Cut_NodeUnionCuts( Cut_Man_t * p, Vec_Int_t * vNodes );
/*=== cutSeq.c ==========================================================*/ /*=== cutSeq.c ==========================================================*/
extern void Cut_NodeComputeCutsSeq( Cut_Man_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int nLat0, int nLat1, int fTriv, int CutSetNum ); extern void Cut_NodeComputeCutsSeq( Cut_Man_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int nLat0, int nLat1, int fTriv, int CutSetNum );
extern void Cut_NodeNewMergeWithOld( Cut_Man_t * p, int Node ); extern void Cut_NodeNewMergeWithOld( Cut_Man_t * p, int Node );
extern int Cut_NodeTempTransferToNew( Cut_Man_t * p, int Node, int CutSetNum ); extern int Cut_NodeTempTransferToNew( Cut_Man_t * p, int Node, int CutSetNum );
extern void Cut_NodeOldTransferToNew( Cut_Man_t * p, int Node ); extern void Cut_NodeOldTransferToNew( Cut_Man_t * p, int Node );
/*=== cutOracle.c ==========================================================*/
extern Cut_Oracle_t * Cut_OracleStart( Cut_Man_t * pMan );
extern void Cut_OracleStop( Cut_Oracle_t * p );
extern void Cut_OracleSetFanoutCounts( Cut_Oracle_t * p, Vec_Int_t * vFanCounts );
extern int Cut_OracleReadDrop( Cut_Oracle_t * p );
extern void Cut_OracleNodeSetTriv( Cut_Oracle_t * p, int Node );
extern Cut_Cut_t * Cut_OracleComputeCuts( Cut_Oracle_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1 );
extern void Cut_OracleTryDroppingCuts( Cut_Oracle_t * p, int Node );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
***********************************************************************/ ***********************************************************************/
#include "cutInt.h" #include "cutInt.h"
#include "npn.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// DECLARATIONS /// /// DECLARATIONS ///
...@@ -31,7 +30,7 @@ ...@@ -31,7 +30,7 @@
/**Function************************************************************* /**Function*************************************************************
Synopsis [Start the cut computation.] Synopsis [Allocates the cut.]
Description [] Description []
...@@ -58,7 +57,7 @@ Cut_Cut_t * Cut_CutAlloc( Cut_Man_t * p ) ...@@ -58,7 +57,7 @@ Cut_Cut_t * Cut_CutAlloc( Cut_Man_t * p )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Start the cut computation.] Synopsis [Recybles the cut.]
Description [] Description []
...@@ -67,29 +66,145 @@ Cut_Cut_t * Cut_CutAlloc( Cut_Man_t * p ) ...@@ -67,29 +66,145 @@ Cut_Cut_t * Cut_CutAlloc( Cut_Man_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Cut_Cut_t * Cut_CutCreateTriv( Cut_Man_t * p, int Node ) void Cut_CutRecycle( Cut_Man_t * p, Cut_Cut_t * pCut )
{
p->nCutsDealloc++;
p->nCutsCur--;
if ( pCut->nLeaves == 1 )
p->nCutsTriv--;
Extra_MmFixedEntryRecycle( p->pMmCuts, (char *)pCut );
}
/**Function*************************************************************
Synopsis [Compares two cuts.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Cut_CutCompare( Cut_Cut_t * pCut1, Cut_Cut_t * pCut2 )
{
int i;
if ( pCut1->nLeaves < pCut2->nLeaves )
return -1;
if ( pCut1->nLeaves > pCut2->nLeaves )
return 1;
for ( i = 0; i < (int)pCut1->nLeaves; i++ )
{
if ( pCut1->pLeaves[i] < pCut2->pLeaves[i] )
return -1;
if ( pCut1->pLeaves[i] > pCut2->pLeaves[i] )
return 1;
}
return 0;
}
/**Function*************************************************************
Synopsis [Duplicates the list.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Cut_Cut_t * Cut_CutDupList( Cut_Man_t * p, Cut_Cut_t * pList )
{
Cut_Cut_t * pHead = NULL, ** ppTail = &pHead;
Cut_Cut_t * pTemp, * pCopy;
if ( pList == NULL )
return NULL;
Cut_ListForEachCut( pList, pTemp )
{
pCopy = (Cut_Cut_t *)Extra_MmFixedEntryFetch( p->pMmCuts );
memcpy( pCopy, pTemp, p->EntrySize );
*ppTail = pCopy;
ppTail = &pCopy->pNext;
}
*ppTail = NULL;
return pHead;
}
/**Function*************************************************************
Synopsis [Recycles the list.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Cut_CutRecycleList( Cut_Man_t * p, Cut_Cut_t * pList )
{
Cut_Cut_t * pCut, * pCut2;
Cut_ListForEachCutSafe( pList, pCut, pCut2 )
Extra_MmFixedEntryRecycle( p->pMmCuts, (char *)pCut );
}
/**Function*************************************************************
Synopsis [Counts the number of cuts in the list.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Cut_CutCountList( Cut_Cut_t * pList )
{
int Counter = 0;
Cut_ListForEachCut( pList, pList )
Counter++;
return Counter;
}
/**Function*************************************************************
Synopsis [Merges two NULL-terminated linked lists.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Cut_Cut_t * Cut_CutMergeLists( Cut_Cut_t * pList1, Cut_Cut_t * pList2 )
{ {
Cut_Cut_t * pList = NULL, ** ppTail = &pList;
Cut_Cut_t * pCut; Cut_Cut_t * pCut;
if ( p->pParams->fSeq ) while ( pList1 && pList2 )
Node <<= 8;
pCut = Cut_CutAlloc( p );
pCut->nLeaves = 1;
pCut->pLeaves[0] = Node;
pCut->uSign = Cut_NodeSign( Node );
if ( p->pParams->fTruth )
{ {
if ( pCut->nVarsMax == 4 ) if ( Cut_CutCompare(pList1, pList2) < 0 )
Cut_CutWriteTruth( pCut, p->uTruthVars[0] ); {
pCut = pList1;
pList1 = pList1->pNext;
}
else else
Extra_BitCopy( pCut->nLeaves, p->uTruths[0], (uint8*)Cut_CutReadTruth(pCut) ); {
pCut = pList2;
pList2 = pList2->pNext;
}
*ppTail = pCut;
ppTail = &pCut->pNext;
} }
p->nCutsTriv++; *ppTail = pList1? pList1: pList2;
return pCut; return pList;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Start the cut computation.] Synopsis [Sets the number of the cuts in the list.]
Description [] Description []
...@@ -98,15 +213,51 @@ Cut_Cut_t * Cut_CutCreateTriv( Cut_Man_t * p, int Node ) ...@@ -98,15 +213,51 @@ Cut_Cut_t * Cut_CutCreateTriv( Cut_Man_t * p, int Node )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Cut_CutRecycle( Cut_Man_t * p, Cut_Cut_t * pCut ) void Cut_CutNumberList( Cut_Cut_t * pList )
{ {
p->nCutsDealloc++; Cut_Cut_t * pCut;
p->nCutsCur--; int i = 0;
if ( pCut->nLeaves == 1 ) Cut_ListForEachCut( pList, pCut )
p->nCutsTriv--; pCut->Num0 = i++;
Extra_MmFixedEntryRecycle( p->pMmCuts, (char *)pCut );
} }
/**Function*************************************************************
Synopsis [Creates the trivial cut.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Cut_Cut_t * Cut_CutCreateTriv( Cut_Man_t * p, int Node )
{
Cut_Cut_t * pCut;
if ( p->pParams->fSeq )
Node <<= CUT_SHIFT;
pCut = Cut_CutAlloc( p );
pCut->nLeaves = 1;
pCut->pLeaves[0] = Node;
pCut->uSign = Cut_NodeSign( Node );
if ( p->pParams->fTruth )
{
/*
if ( pCut->nVarsMax == 4 )
Cut_CutWriteTruth( pCut, p->uTruthVars[0] );
else
Extra_BitCopy( pCut->nLeaves, p->uTruths[0], (uint8*)Cut_CutReadTruth(pCut) );
*/
unsigned * pTruth = Cut_CutReadTruth(pCut);
int i;
for ( i = 0; i < p->nTruthWords; i++ )
pTruth[i] = 0xAAAAAAAA;
}
p->nCutsTriv++;
return pCut;
}
/**Function************************************************************* /**Function*************************************************************
...@@ -128,9 +279,9 @@ void Cut_CutPrint( Cut_Cut_t * pCut, int fSeq ) ...@@ -128,9 +279,9 @@ void Cut_CutPrint( Cut_Cut_t * pCut, int fSeq )
{ {
if ( fSeq ) if ( fSeq )
{ {
printf( " %d", pCut->pLeaves[i] >> 8 ); printf( " %d", pCut->pLeaves[i] >> CUT_SHIFT );
if ( pCut->pLeaves[i] & 0xFF ) if ( pCut->pLeaves[i] & CUT_MASK )
printf( "(%d)", pCut->pLeaves[i] & 0xFF ); printf( "(%d)", pCut->pLeaves[i] & CUT_MASK );
} }
else else
printf( " %d", pCut->pLeaves[i] ); printf( " %d", pCut->pLeaves[i] );
......
...@@ -29,14 +29,12 @@ ...@@ -29,14 +29,12 @@
#include "extra.h" #include "extra.h"
#include "vec.h" #include "vec.h"
#include "cut.h" #include "cut.h"
#include "cutList.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// PARAMETERS /// /// PARAMETERS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#define CUT_SIZE_MAX 8
#include "cutList.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// BASIC TYPES /// /// BASIC TYPES ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -55,6 +53,7 @@ struct Cut_ManStruct_t_ ...@@ -55,6 +53,7 @@ struct Cut_ManStruct_t_
// memory management // memory management
Extra_MmFixed_t * pMmCuts; Extra_MmFixed_t * pMmCuts;
int EntrySize; int EntrySize;
int nTruthWords;
// temporary variables // temporary variables
Cut_Cut_t * pReady; Cut_Cut_t * pReady;
Vec_Ptr_t * vTemp; Vec_Ptr_t * vTemp;
...@@ -62,12 +61,14 @@ struct Cut_ManStruct_t_ ...@@ -62,12 +61,14 @@ struct Cut_ManStruct_t_
int fCompl1; int fCompl1;
int fSimul; int fSimul;
int nNodeCuts; int nNodeCuts;
// precomputations Cut_Cut_t * pStore0[2];
uint8 uTruths[8][32]; Cut_Cut_t * pStore1[2];
unsigned uTruthVars[6][2]; Cut_Cut_t * pCompareOld;
unsigned short ** pPerms43; Cut_Cut_t * pCompareNew;
unsigned ** pPerms53; // record of the cut computation
unsigned ** pPerms54; Vec_Int_t * vNodeCuts; // the number of cuts for each node
Vec_Int_t * vNodeStarts; // the number of the starting cut of each node
Vec_Int_t * vCutPairs; // the pairs of parent cuts for each cut
// statistics // statistics
int nCutsCur; int nCutsCur;
int nCutsMulti; int nCutsMulti;
...@@ -108,7 +109,8 @@ struct Cut_ManStruct_t_ ...@@ -108,7 +109,8 @@ struct Cut_ManStruct_t_
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// computes signature of the node // computes signature of the node
static inline unsigned Cut_NodeSign( int Node ) { return (1 << (Node % 31)); } static inline unsigned Cut_NodeSign( int Node ) { return (1 << (Node % 31)); }
static inline int Cut_TruthWords( int nVarsMax ) { return nVarsMax <= 5 ? 1 : (1 << (nVarsMax - 5)); }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS /// /// FUNCTION DECLARATIONS ///
...@@ -116,11 +118,20 @@ static inline unsigned Cut_NodeSign( int Node ) { return (1 << (Node % 31)); } ...@@ -116,11 +118,20 @@ static inline unsigned Cut_NodeSign( int Node ) { return (1 << (Node % 31)); }
/*=== cutCut.c ==========================================================*/ /*=== cutCut.c ==========================================================*/
extern Cut_Cut_t * Cut_CutAlloc( Cut_Man_t * p ); extern Cut_Cut_t * Cut_CutAlloc( Cut_Man_t * p );
extern Cut_Cut_t * Cut_CutCreateTriv( Cut_Man_t * p, int Node );
extern void Cut_CutRecycle( Cut_Man_t * p, Cut_Cut_t * pCut ); extern void Cut_CutRecycle( Cut_Man_t * p, Cut_Cut_t * pCut );
extern int Cut_CutCompare( Cut_Cut_t * pCut1, Cut_Cut_t * pCut2 );
extern Cut_Cut_t * Cut_CutDupList( Cut_Man_t * p, Cut_Cut_t * pList );
extern void Cut_CutRecycleList( Cut_Man_t * p, Cut_Cut_t * pList );
extern int Cut_CutCountList( Cut_Cut_t * pList );
extern Cut_Cut_t * Cut_CutMergeLists( Cut_Cut_t * pList1, Cut_Cut_t * pList2 );
extern void Cut_CutNumberList( Cut_Cut_t * pList );
extern Cut_Cut_t * Cut_CutCreateTriv( Cut_Man_t * p, int Node );
extern void Cut_CutPrintMerge( Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1 ); extern void Cut_CutPrintMerge( Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1 );
/*=== cutMerge.c ==========================================================*/ /*=== cutMerge.c ==========================================================*/
extern Cut_Cut_t * Cut_CutMergeTwo( Cut_Man_t * p, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1 ); extern Cut_Cut_t * Cut_CutMergeTwo( Cut_Man_t * p, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1 );
/*=== cutNode.c ==========================================================*/
extern void Cut_NodeDoComputeCuts( Cut_Man_t * p, Cut_List_t * pSuper, int Node, int fCompl0, int fCompl1, Cut_Cut_t * pList0, Cut_Cut_t * pList1, int fTriv );
extern int Cut_CutListVerify( Cut_Cut_t * pList );
/*=== cutTable.c ==========================================================*/ /*=== cutTable.c ==========================================================*/
extern Cut_HashTable_t * Cut_TableStart( int Size ); extern Cut_HashTable_t * Cut_TableStart( int Size );
extern void Cut_TableStop( Cut_HashTable_t * pTable ); extern void Cut_TableStop( Cut_HashTable_t * pTable );
...@@ -128,7 +139,7 @@ extern int Cut_TableLookup( Cut_HashTable_t * pTable, Cut_Cut_t ...@@ -128,7 +139,7 @@ extern int Cut_TableLookup( Cut_HashTable_t * pTable, Cut_Cut_t
extern void Cut_TableClear( Cut_HashTable_t * pTable ); extern void Cut_TableClear( Cut_HashTable_t * pTable );
extern int Cut_TableReadTime( Cut_HashTable_t * pTable ); extern int Cut_TableReadTime( Cut_HashTable_t * pTable );
/*=== cutTruth.c ==========================================================*/ /*=== cutTruth.c ==========================================================*/
extern void Cut_TruthCompute( Cut_Man_t * p, Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1 ); extern void Cut_TruthCompute( Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1, int fCompl0, int fCompl1 );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -89,7 +89,42 @@ static inline void Cut_ListAdd( Cut_List_t * p, Cut_Cut_t * pCut ) ...@@ -89,7 +89,42 @@ static inline void Cut_ListAdd( Cut_List_t * p, Cut_Cut_t * pCut )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Adds one cut to the cut list.] Synopsis [Adds one cut to the cut list while preserving order.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Cut_ListAdd2( Cut_List_t * p, Cut_Cut_t * pCut )
{
extern int Cut_CutCompare( Cut_Cut_t * pCut1, Cut_Cut_t * pCut2 );
Cut_Cut_t * pTemp, ** ppSpot;
assert( pCut->nLeaves > 0 && pCut->nLeaves <= CUT_SIZE_MAX );
if ( p->pHead[pCut->nLeaves] != NULL )
{
ppSpot = &p->pHead[pCut->nLeaves];
for ( pTemp = p->pHead[pCut->nLeaves]; pTemp; pTemp = pTemp->pNext )
{
if ( Cut_CutCompare(pCut, pTemp) < 0 )
{
*ppSpot = pCut;
pCut->pNext = pTemp;
return;
}
else
ppSpot = &pTemp->pNext;
}
}
*p->ppTail[pCut->nLeaves] = pCut;
p->ppTail[pCut->nLeaves] = &pCut->pNext;
}
/**Function*************************************************************
Synopsis [Derive the super list from the linked list of cuts.]
Description [] Description []
...@@ -153,7 +188,7 @@ static inline Cut_Cut_t * Cut_ListFinish( Cut_List_t * p ) ...@@ -153,7 +188,7 @@ static inline Cut_Cut_t * Cut_ListFinish( Cut_List_t * p )
{ {
Cut_Cut_t * pHead = NULL, ** ppTail = &pHead; Cut_Cut_t * pHead = NULL, ** ppTail = &pHead;
int i; int i;
for ( i = 1; i < CUT_SIZE_MAX; i++ ) for ( i = 1; i <= CUT_SIZE_MAX; i++ )
{ {
if ( p->pHead[i] == NULL ) if ( p->pHead[i] == NULL )
continue; continue;
......
...@@ -45,7 +45,7 @@ Cut_Man_t * Cut_ManStart( Cut_Params_t * pParams ) ...@@ -45,7 +45,7 @@ Cut_Man_t * Cut_ManStart( Cut_Params_t * pParams )
{ {
Cut_Man_t * p; Cut_Man_t * p;
int clk = clock(); int clk = clock();
assert( pParams->nVarsMax >= 4 && pParams->nVarsMax <= CUT_SIZE_MAX ); assert( pParams->nVarsMax >= 3 && pParams->nVarsMax <= CUT_SIZE_MAX );
p = ALLOC( Cut_Man_t, 1 ); p = ALLOC( Cut_Man_t, 1 );
memset( p, 0, sizeof(Cut_Man_t) ); memset( p, 0, sizeof(Cut_Man_t) );
// set and correct parameters // set and correct parameters
...@@ -65,19 +65,28 @@ Cut_Man_t * Cut_ManStart( Cut_Params_t * pParams ) ...@@ -65,19 +65,28 @@ Cut_Man_t * Cut_ManStart( Cut_Params_t * pParams )
assert( !pParams->fTruth || pParams->nVarsMax <= 5 ); assert( !pParams->fTruth || pParams->nVarsMax <= 5 );
// entry size // entry size
p->EntrySize = sizeof(Cut_Cut_t) + pParams->nVarsMax * sizeof(int); p->EntrySize = sizeof(Cut_Cut_t) + pParams->nVarsMax * sizeof(int);
if ( pParams->fTruth && pParams->nVarsMax >= 5 && pParams->nVarsMax <= 8 ) if ( pParams->fTruth )
p->EntrySize += (1 << (pParams->nVarsMax - 5)) * sizeof(unsigned); {
if ( pParams->nVarsMax > 8 )
{
pParams->fTruth = 0;
printf( "Skipping computation of truth table for more than 8 inputs.\n" );
}
else
{
p->nTruthWords = Cut_TruthWords( pParams->nVarsMax );
p->EntrySize += p->nTruthWords * sizeof(unsigned);
}
}
// enable cut computation recording
if ( pParams->fRecord )
{
p->vNodeCuts = Vec_IntStart( pParams->nIdsMax );
p->vNodeStarts = Vec_IntStart( pParams->nIdsMax );
p->vCutPairs = Vec_IntAlloc( 0 );
}
// memory for cuts // memory for cuts
p->pMmCuts = Extra_MmFixedStart( p->EntrySize ); p->pMmCuts = Extra_MmFixedStart( p->EntrySize );
// elementary truth tables
Npn_StartTruth8( p->uTruths );
p->uTruthVars[0][1] = p->uTruthVars[0][0] = 0xAAAAAAAA; // 1010 1010 1010 1010 1010 1010 1010 1010
p->uTruthVars[1][1] = p->uTruthVars[1][0] = 0xCCCCCCCC; // 1010 1010 1010 1010 1010 1010 1010 1010
p->uTruthVars[2][1] = p->uTruthVars[2][0] = 0xF0F0F0F0; // 1111 0000 1111 0000 1111 0000 1111 0000
p->uTruthVars[3][1] = p->uTruthVars[3][0] = 0xFF00FF00; // 1111 1111 0000 0000 1111 1111 0000 0000
p->uTruthVars[4][1] = p->uTruthVars[4][0] = 0xFFFF0000; // 1111 1111 1111 1111 0000 0000 0000 0000
p->uTruthVars[5][0] = 0x00000000;
p->uTruthVars[5][1] = 0xFFFFFFFF;
p->vTemp = Vec_PtrAlloc( 100 ); p->vTemp = Vec_PtrAlloc( 100 );
return p; return p;
} }
...@@ -102,14 +111,16 @@ void Cut_ManStop( Cut_Man_t * p ) ...@@ -102,14 +111,16 @@ void Cut_ManStop( Cut_Man_t * p )
{ {
int k = 0; int k = 0;
} }
if ( p->vCutsNew ) Vec_PtrFree( p->vCutsNew ); if ( p->vCutsNew ) Vec_PtrFree( p->vCutsNew );
if ( p->vCutsOld ) Vec_PtrFree( p->vCutsOld ); if ( p->vCutsOld ) Vec_PtrFree( p->vCutsOld );
if ( p->vCutsTemp ) Vec_PtrFree( p->vCutsTemp ); if ( p->vCutsTemp ) Vec_PtrFree( p->vCutsTemp );
if ( p->vFanCounts ) Vec_IntFree( p->vFanCounts ); if ( p->vFanCounts ) Vec_IntFree( p->vFanCounts );
if ( p->pPerms43 ) free( p->pPerms43 ); if ( p->vTemp ) Vec_PtrFree( p->vTemp );
if ( p->pPerms53 ) free( p->pPerms53 );
if ( p->pPerms54 ) free( p->pPerms54 ); if ( p->vNodeCuts ) Vec_IntFree( p->vNodeCuts );
if ( p->vTemp ) Vec_PtrFree( p->vTemp ); if ( p->vNodeStarts ) Vec_IntFree( p->vNodeStarts );
if ( p->vCutPairs ) Vec_IntFree( p->vCutPairs );
Extra_MmFixedStop( p->pMmCuts, 0 ); Extra_MmFixedStop( p->pMmCuts, 0 );
free( p ); free( p );
} }
...@@ -146,8 +157,9 @@ void Cut_ManPrintStats( Cut_Man_t * p ) ...@@ -146,8 +157,9 @@ void Cut_ManPrintStats( Cut_Man_t * p )
PRT( "Union ", p->timeUnion ); PRT( "Union ", p->timeUnion );
PRT( "Filter", p->timeFilter ); PRT( "Filter", p->timeFilter );
PRT( "Truth ", p->timeTruth ); PRT( "Truth ", p->timeTruth );
printf( "Nodes = %d. Multi = %d. Cuts = %d. Multi = %d.\n", // printf( "Nodes = %d. Multi = %d. Cuts = %d. Multi = %d.\n",
p->nNodes, p->nNodesMulti, p->nCutsCur-p->nCutsTriv, p->nCutsMulti ); // p->nNodes, p->nNodesMulti, p->nCutsCur-p->nCutsTriv, p->nCutsMulti );
// printf( "Count0 = %d. Count1 = %d. Count2 = %d.\n\n", p->Count0, p->Count1, p->Count2 );
} }
......
...@@ -526,7 +526,7 @@ Cut_Cut_t * Cut_CutMergeTwo5( Cut_Man_t * p, Cut_Cut_t * pCut0, Cut_Cut_t * pCut ...@@ -526,7 +526,7 @@ Cut_Cut_t * Cut_CutMergeTwo5( Cut_Man_t * p, Cut_Cut_t * pCut0, Cut_Cut_t * pCut
return NULL; return NULL;
} }
pRes = Cut_CutAlloc( p ); pRes = Cut_CutAlloc( p );
pRes->uTruth = (uSign1 << 8); pRes->Num1 = uSign1;
} }
for ( i = 0; i < (int)pCut0->nLeaves; i++ ) for ( i = 0; i < (int)pCut0->nLeaves; i++ )
pRes->pLeaves[i] = pCut0->pLeaves[i]; pRes->pLeaves[i] = pCut0->pLeaves[i];
...@@ -645,7 +645,8 @@ Cut_Cut_t * Cut_CutMergeTwo5( Cut_Man_t * p, Cut_Cut_t * pCut0, Cut_Cut_t * pCut ...@@ -645,7 +645,8 @@ Cut_Cut_t * Cut_CutMergeTwo5( Cut_Man_t * p, Cut_Cut_t * pCut0, Cut_Cut_t * pCut
} }
assert( Count == nNodes ); assert( Count == nNodes );
pRes->nLeaves = nNodes; pRes->nLeaves = nNodes;
pRes->uTruth = (uSign1 << 8) | uSign0; pRes->Num1 = uSign1;
pRes->Num0 = uSign0;
return pRes; return pRes;
} }
......
...@@ -55,7 +55,7 @@ int Rwr_NodeRewrite( Rwr_Man_t * p, Cut_Man_t * pManCut, Abc_Obj_t * pNode, int ...@@ -55,7 +55,7 @@ int Rwr_NodeRewrite( Rwr_Man_t * p, Cut_Man_t * pManCut, Abc_Obj_t * pNode, int
Dec_Graph_t * pGraph; Dec_Graph_t * pGraph;
Cut_Cut_t * pCut; Cut_Cut_t * pCut;
Abc_Obj_t * pFanin; Abc_Obj_t * pFanin;
unsigned uPhase, uTruthBest; unsigned uPhase, uTruthBest, uTruth;
char * pPerm; char * pPerm;
int Required, nNodesSaved; int Required, nNodesSaved;
int i, GainCur, GainBest = -1; int i, GainCur, GainBest = -1;
...@@ -78,8 +78,9 @@ clk = clock(); ...@@ -78,8 +78,9 @@ clk = clock();
if ( pCut->nLeaves < 4 ) if ( pCut->nLeaves < 4 )
continue; continue;
// get the fanin permutation // get the fanin permutation
pPerm = p->pPerms4[ p->pPerms[pCut->uTruth] ]; uTruth = 0xFFFF & *Cut_CutReadTruth(pCut);
uPhase = p->pPhases[pCut->uTruth]; pPerm = p->pPerms4[ p->pPerms[uTruth] ];
uPhase = p->pPhases[uTruth];
// collect fanins with the corresponding permutation/phase // collect fanins with the corresponding permutation/phase
Vec_PtrClear( p->vFaninsCur ); Vec_PtrClear( p->vFaninsCur );
Vec_PtrFill( p->vFaninsCur, (int)pCut->nLeaves, 0 ); Vec_PtrFill( p->vFaninsCur, (int)pCut->nLeaves, 0 );
...@@ -122,7 +123,7 @@ p->timeEval += clock() - clk2; ...@@ -122,7 +123,7 @@ p->timeEval += clock() - clk2;
GainBest = GainCur; GainBest = GainCur;
p->pGraph = pGraph; p->pGraph = pGraph;
p->fCompl = ((uPhase & (1<<4)) > 0); p->fCompl = ((uPhase & (1<<4)) > 0);
uTruthBest = pCut->uTruth; uTruthBest = 0xFFFF & *Cut_CutReadTruth(pCut);
// collect fanins in the // collect fanins in the
Vec_PtrClear( p->vFanins ); Vec_PtrClear( p->vFanins );
Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i ) Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
...@@ -171,8 +172,10 @@ Dec_Graph_t * Rwr_CutEvaluate( Rwr_Man_t * p, Abc_Obj_t * pRoot, Cut_Cut_t * pCu ...@@ -171,8 +172,10 @@ Dec_Graph_t * Rwr_CutEvaluate( Rwr_Man_t * p, Abc_Obj_t * pRoot, Cut_Cut_t * pCu
Dec_Graph_t * pGraphBest, * pGraphCur; Dec_Graph_t * pGraphBest, * pGraphCur;
Rwr_Node_t * pNode, * pFanin; Rwr_Node_t * pNode, * pFanin;
int nNodesAdded, GainBest, i, k; int nNodesAdded, GainBest, i, k;
unsigned uTruth;
// find the matching class of subgraphs // find the matching class of subgraphs
vSubgraphs = Vec_VecEntry( p->vClasses, p->pMap[pCut->uTruth] ); uTruth = 0xFFFF & *Cut_CutReadTruth(pCut);
vSubgraphs = Vec_VecEntry( p->vClasses, p->pMap[uTruth] );
p->nSubgraphs += vSubgraphs->nSize; p->nSubgraphs += vSubgraphs->nSize;
// determine the best subgraph // determine the best subgraph
GainBest = -1; GainBest = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment