Commit 91ca630b by Alan Mishchenko

Version abc51002

parent 78fbd336
......@@ -270,6 +270,14 @@ SOURCE=.\src\base\abci\abcVerify.c
# PROP Default_Filter ""
# 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
# End Source File
# Begin Source File
......@@ -1130,6 +1138,10 @@ SOURCE=.\src\opt\cut\cutNode.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutOracle.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\cut\cutSeq.c
# End Source File
# Begin Source File
......
No preview for this file type
......@@ -91,6 +91,8 @@ static int Abc_CommandPipe ( Abc_Frame_t * pAbc, int argc, char ** argv
static int Abc_CommandSeq ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandUnseq ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandRetime ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSeqFpga ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSeqMap ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandCec ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSec ( Abc_Frame_t * pAbc, int argc, char ** argv );
......@@ -172,6 +174,8 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Sequential", "seq", Abc_CommandSeq, 1 );
Cmd_CommandAdd( pAbc, "Sequential", "unseq", Abc_CommandUnseq, 1 );
Cmd_CommandAdd( pAbc, "Sequential", "retime", Abc_CommandRetime, 1 );
Cmd_CommandAdd( pAbc, "Sequential", "sfpga", Abc_CommandSeqFpga, 1 );
Cmd_CommandAdd( pAbc, "Sequential", "smap", Abc_CommandSeqMap, 1 );
Cmd_CommandAdd( pAbc, "Verification", "cec", Abc_CommandCec, 0 );
Cmd_CommandAdd( pAbc, "Verification", "sec", Abc_CommandSec, 0 );
......@@ -2735,16 +2739,20 @@ int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Cut_Params_t Params, * pParams = &Params;
Cut_Man_t * pCutMan;
Cut_Oracle_t * pCutOracle;
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk;
int c;
int fOracle;
extern Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams );
extern void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * pCutOracle );
pNtk = Abc_FrameReadNet(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set defaults
fOracle = 0;
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
......@@ -2754,7 +2762,7 @@ int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
pParams->fMulti = 0; // use multi-input AND-gates
pParams->fVerbose = 0; // the verbosiness flag
util_getopt_reset();
while ( ( c = util_getopt( argc, argv, "KMtfdmvh" ) ) != EOF )
while ( ( c = util_getopt( argc, argv, "KMtfdmvoh" ) ) != EOF )
{
switch ( c )
{
......@@ -2795,6 +2803,9 @@ int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'v':
pParams->fVerbose ^= 1;
break;
case 'o':
fOracle ^= 1;
break;
case 'h':
goto usage;
default:
......@@ -2812,15 +2823,30 @@ int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( pErr, "Cut computation is available only for AIGs (run \"strash\").\n" );
return 1;
}
if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX )
{
fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
return 1;
}
if ( fOracle )
pParams->fRecord = 1;
pCutMan = Abc_NtkCuts( pNtk, pParams );
Cut_ManPrintStats( pCutMan );
if ( fOracle )
pCutOracle = Cut_OracleStart( pCutMan );
Cut_ManStop( pCutMan );
if ( fOracle )
{
Abc_NtkCutsOracle( pNtk, pCutOracle );
Cut_OracleStop( pCutOracle );
}
return 0;
usage:
fprintf( pErr, "usage: cut [-K num] [-M num] [-tfdmvh]\n" );
fprintf( pErr, "\t computes k-feasible cuts for the AIG\n" );
fprintf( pErr, "\t-K num : max number of leaves (4 <= num <= 6) [default = %d]\n", pParams->nVarsMax );
fprintf( pErr, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
fprintf( pErr, "\t-M num : max number of cuts stored at a node [default = %d]\n", pParams->nKeepMax );
fprintf( pErr, "\t-t : toggle truth table computation [default = %s]\n", pParams->fTruth? "yes": "no" );
fprintf( pErr, "\t-f : toggle filtering of duplicated/dominated [default = %s]\n", pParams->fFilter? "yes": "no" );
......@@ -2913,6 +2939,12 @@ int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( pErr, "Sequential cuts can be computed for sequential AIGs (run \"seq\").\n" );
return 1;
}
if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX )
{
fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
return 1;
}
pCutMan = Abc_NtkSeqCuts( pNtk, pParams );
Cut_ManPrintStats( pCutMan );
Cut_ManStop( pCutMan );
......@@ -2921,7 +2953,7 @@ int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv )
usage:
fprintf( pErr, "usage: scut [-K num] [-M num] [-tvh]\n" );
fprintf( pErr, "\t computes k-feasible cuts for the sequential AIG\n" );
fprintf( pErr, "\t-K num : max number of leaves (4 <= num <= 6) [default = %d]\n", pParams->nVarsMax );
fprintf( pErr, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
fprintf( pErr, "\t-M num : max number of cuts stored at a node [default = %d]\n", pParams->nKeepMax );
fprintf( pErr, "\t-t : toggle truth table computation [default = %s]\n", pParams->fTruth? "yes": "no" );
fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
......@@ -4434,6 +4466,149 @@ usage:
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fVerbose;
extern Abc_Ntk_t * Abc_NtkFpgaSeq( Abc_Ntk_t * pNtk, int fVerbose );
pNtk = Abc_FrameReadNet(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set defaults
fVerbose = 1;
util_getopt_reset();
while ( ( c = util_getopt( argc, argv, "vh" ) ) != EOF )
{
switch ( c )
{
case 'v':
fVerbose ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pNtk == NULL )
{
fprintf( pErr, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsSeq(pNtk) )
{
fprintf( pErr, "Works only for sequential AIG (run \"seq\").\n" );
return 1;
}
// get the new network
pNtkRes = Abc_NtkFpgaSeq( pNtk, fVerbose );
if ( pNtkRes == NULL )
{
fprintf( pErr, "Sequential FPGA mapping has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
fprintf( pErr, "usage: sfpga [-vh]\n" );
fprintf( pErr, "\t performs integrated sequential FPGA mapping\n" );
fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fVerbose;
extern Abc_Ntk_t * Abc_NtkMapSeq( Abc_Ntk_t * pNtk, int fVerbose );
pNtk = Abc_FrameReadNet(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set defaults
fVerbose = 1;
util_getopt_reset();
while ( ( c = util_getopt( argc, argv, "vh" ) ) != EOF )
{
switch ( c )
{
case 'v':
fVerbose ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pNtk == NULL )
{
fprintf( pErr, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsSeq(pNtk) )
{
fprintf( pErr, "Works only for sequential AIG (run \"seq\").\n" );
return 1;
}
// get the new network
pNtkRes = Abc_NtkMapSeq( pNtk, fVerbose );
if ( pNtkRes == NULL )
{
fprintf( pErr, "Sequential FPGA mapping has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
fprintf( pErr, "usage: smap [-vh]\n" );
fprintf( pErr, "\t performs integrated sequential standard-cell mapping" );
fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
return 1;
}
/**Function*************************************************************
......
......@@ -69,7 +69,7 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
if ( Abc_ObjFanoutNum(pObj) > 0 )
Cut_NodeSetTriv( p, pObj->Id );
// compute cuts for internal nodes
vNodes = Abc_AigDfs( pNtk, 0, 1 );
vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
vChoices = Vec_IntAlloc( 100 );
Vec_PtrForEachEntry( vNodes, pObj, i )
{
......@@ -105,13 +105,72 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
if ( pParams->fMulti )
Abc_NtkBalanceDetach(pNtk);
PRT( "Total", clock() - clk );
Abc_NtkPrintCuts_( p, pNtk, 0 );
//Abc_NtkPrintCuts_( p, pNtk, 0 );
// Cut_ManPrintStatsToFile( p, pNtk->pSpec, clock() - clk );
return p;
}
/**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.]
Description []
......@@ -156,7 +215,6 @@ Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
// compute the cuts for the internal nodes
Abc_AigForEachAnd( pNtk, pObj, i )
Abc_NodeGetCutsSeq( p, pObj, nIters==0 );
Abc_NtkPrintCuts( p, pNtk, 1 );
// merge the new cuts with the old cuts
Abc_NtkForEachPi( pNtk, pObj, i )
Cut_NodeNewMergeWithOld( p, pObj->Id );
......@@ -183,7 +241,7 @@ Abc_NtkPrintCuts( p, pNtk, 1 );
pObj->fMarkC = 0;
PRT( "Total", clock() - clk );
printf( "Converged after %d iterations.\n", nIters );
Abc_NtkPrintCuts( p, pNtk, 1 );
//Abc_NtkPrintCuts( p, pNtk, 1 );
return p;
}
......@@ -225,7 +283,7 @@ void * Abc_NodeGetCuts( void * p, Abc_Obj_t * pObj, int fMulti )
assert( Abc_NtkIsStrash(pObj->pNtk) );
assert( Abc_ObjFaninNum(pObj) == 2 );
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*************************************************************
......@@ -244,7 +302,7 @@ void Abc_NodeGetCutsSeq( void * p, Abc_Obj_t * pObj, int fTriv )
int CutSetNum;
assert( Abc_NtkIsSeq(pObj->pNtk) );
assert( Abc_ObjFaninNum(pObj) == 2 );
// fTriv = pObj->fMarkC ? 0 : fTriv;
fTriv = pObj->fMarkC ? 0 : fTriv;
CutSetNum = pObj->fMarkC ? (int)pObj->pCopy : -1;
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 );
......
/**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 @@
/// 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
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 );
......
......@@ -26,6 +26,7 @@
////////////////////////////////////////////////////////////////////////
#include "abc.h"
#include "cut.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
......@@ -38,6 +39,25 @@
/// 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
typedef struct Abc_RetEdge_t_ Abc_RetEdge_t;
struct Abc_RetEdge_t_ // 1 word
......@@ -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 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 ///
////////////////////////////////////////////////////////////////////////
......
......@@ -283,6 +283,7 @@ extern void Extra_Truth4VarN( unsigned short ** puCanons, char *** puPhas
extern unsigned short Extra_TruthPerm4One( 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_TruthExpand( int nVars, int nWords, unsigned * puTruth, unsigned uPhase, unsigned * puTruthR );
/* precomputing tables for permutation mapping */
extern void ** Extra_ArrayAlloc( int nCols, int nRows, int Size );
extern unsigned short ** Extra_TruthPerm43();
......
......@@ -40,7 +40,7 @@ typedef struct Abc_Fan_t_ Abc_Fan_t;
struct Abc_Fan_t_ // 1 word
{
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
};
......
......@@ -29,11 +29,18 @@
/// 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 ///
////////////////////////////////////////////////////////////////////////
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_ParamsStruct_t_ Cut_Params_t;
......@@ -48,13 +55,14 @@ struct Cut_ParamsStruct_t_
int fSeq; // compute sequential cuts
int fDrop; // drop cuts on the fly
int fMulti; // compute cuts in multi-input AND gate graph
int fRecord; // record the cut computation flow
int fVerbose; // the verbosiness flag
};
struct Cut_CutStruct_t_
{
unsigned uTruth : 16; // truth table for 4-input cuts
unsigned uPhase : 6; // the phase when mapping into a canonical form
unsigned Num0 : 11; // temporary number
unsigned Num1 : 11; // temporary number
unsigned fSimul : 1; // the value of cut's output at 000.. pattern
unsigned fCompl : 1; // the cut is complemented
unsigned nVarsMax : 4; // the max number of vars [4-6]
......@@ -64,15 +72,13 @@ struct Cut_CutStruct_t_
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_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 ) {
if ( p->nVarsMax == 4 ) { p->uTruth = *puTruth; return; }
p->pLeaves[p->nVarsMax] = (int)puTruth[0];
if ( p->nVarsMax == 6 ) p->pLeaves[p->nVarsMax + 1] = (int)puTruth[1];
int i;
for ( i = (p->nVarsMax <= 5) ? 0 : ((1 << (p->nVarsMax - 5)) - 1); i >= 0; i-- )
p->pLeaves[p->nVarsMax + i] = (int)puTruth[i];
}
////////////////////////////////////////////////////////////////////////
......@@ -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 int Cut_ManReadVarsMax( Cut_Man_t * p );
/*=== 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_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_NodeComputeCuts( Cut_Man_t * p, int Node, int Node0, int Node1, int fCompl0, int fCompl1, int fTriv );
extern Cut_Cut_t * Cut_NodeUnionCuts( Cut_Man_t * p, Vec_Int_t * vNodes );
/*=== 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_NodeNewMergeWithOld( Cut_Man_t * p, int Node );
extern int Cut_NodeTempTransferToNew( Cut_Man_t * p, int Node, int CutSetNum );
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 ///
......
......@@ -19,7 +19,6 @@
***********************************************************************/
#include "cutInt.h"
#include "npn.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
......@@ -31,7 +30,7 @@
/**Function*************************************************************
Synopsis [Start the cut computation.]
Synopsis [Allocates the cut.]
Description []
......@@ -58,7 +57,7 @@ Cut_Cut_t * Cut_CutAlloc( Cut_Man_t * p )
/**Function*************************************************************
Synopsis [Start the cut computation.]
Synopsis [Recybles the cut.]
Description []
......@@ -67,29 +66,145 @@ Cut_Cut_t * Cut_CutAlloc( Cut_Man_t * p )
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;
if ( p->pParams->fSeq )
Node <<= 8;
pCut = Cut_CutAlloc( p );
pCut->nLeaves = 1;
pCut->pLeaves[0] = Node;
pCut->uSign = Cut_NodeSign( Node );
if ( p->pParams->fTruth )
while ( pList1 && pList2 )
{
if ( pCut->nVarsMax == 4 )
Cut_CutWriteTruth( pCut, p->uTruthVars[0] );
if ( Cut_CutCompare(pList1, pList2) < 0 )
{
pCut = pList1;
pList1 = pList1->pNext;
}
else
Extra_BitCopy( pCut->nLeaves, p->uTruths[0], (uint8*)Cut_CutReadTruth(pCut) );
{
pCut = pList2;
pList2 = pList2->pNext;
}
p->nCutsTriv++;
return pCut;
*ppTail = pCut;
ppTail = &pCut->pNext;
}
*ppTail = pList1? pList1: pList2;
return pList;
}
/**Function*************************************************************
Synopsis [Start the cut computation.]
Synopsis [Sets the number of the cuts in the list.]
Description []
......@@ -98,13 +213,49 @@ Cut_Cut_t * Cut_CutCreateTriv( Cut_Man_t * p, int Node )
SeeAlso []
***********************************************************************/
void Cut_CutRecycle( Cut_Man_t * p, Cut_Cut_t * pCut )
void Cut_CutNumberList( Cut_Cut_t * pList )
{
p->nCutsDealloc++;
p->nCutsCur--;
if ( pCut->nLeaves == 1 )
p->nCutsTriv--;
Extra_MmFixedEntryRecycle( p->pMmCuts, (char *)pCut );
Cut_Cut_t * pCut;
int i = 0;
Cut_ListForEachCut( pList, pCut )
pCut->Num0 = i++;
}
/**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;
}
......@@ -128,9 +279,9 @@ void Cut_CutPrint( Cut_Cut_t * pCut, int fSeq )
{
if ( fSeq )
{
printf( " %d", pCut->pLeaves[i] >> 8 );
if ( pCut->pLeaves[i] & 0xFF )
printf( "(%d)", pCut->pLeaves[i] & 0xFF );
printf( " %d", pCut->pLeaves[i] >> CUT_SHIFT );
if ( pCut->pLeaves[i] & CUT_MASK )
printf( "(%d)", pCut->pLeaves[i] & CUT_MASK );
}
else
printf( " %d", pCut->pLeaves[i] );
......
......@@ -29,14 +29,12 @@
#include "extra.h"
#include "vec.h"
#include "cut.h"
#include "cutList.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
#define CUT_SIZE_MAX 8
#include "cutList.h"
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
......@@ -55,6 +53,7 @@ struct Cut_ManStruct_t_
// memory management
Extra_MmFixed_t * pMmCuts;
int EntrySize;
int nTruthWords;
// temporary variables
Cut_Cut_t * pReady;
Vec_Ptr_t * vTemp;
......@@ -62,12 +61,14 @@ struct Cut_ManStruct_t_
int fCompl1;
int fSimul;
int nNodeCuts;
// precomputations
uint8 uTruths[8][32];
unsigned uTruthVars[6][2];
unsigned short ** pPerms43;
unsigned ** pPerms53;
unsigned ** pPerms54;
Cut_Cut_t * pStore0[2];
Cut_Cut_t * pStore1[2];
Cut_Cut_t * pCompareOld;
Cut_Cut_t * pCompareNew;
// record of the cut computation
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
int nCutsCur;
int nCutsMulti;
......@@ -109,6 +110,7 @@ struct Cut_ManStruct_t_
// computes signature of the node
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 ///
......@@ -116,11 +118,20 @@ static inline unsigned Cut_NodeSign( int Node ) { return (1 << (Node % 31)); }
/*=== cutCut.c ==========================================================*/
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 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 );
/*=== cutMerge.c ==========================================================*/
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 ==========================================================*/
extern Cut_HashTable_t * Cut_TableStart( int Size );
extern void Cut_TableStop( Cut_HashTable_t * pTable );
......@@ -128,7 +139,7 @@ extern int Cut_TableLookup( Cut_HashTable_t * pTable, Cut_Cut_t
extern void Cut_TableClear( Cut_HashTable_t * pTable );
extern int Cut_TableReadTime( Cut_HashTable_t * pTable );
/*=== 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 ///
......
......@@ -89,7 +89,42 @@ static inline void Cut_ListAdd( Cut_List_t * p, Cut_Cut_t * pCut )
/**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 []
......@@ -153,7 +188,7 @@ static inline Cut_Cut_t * Cut_ListFinish( Cut_List_t * p )
{
Cut_Cut_t * pHead = NULL, ** ppTail = &pHead;
int i;
for ( i = 1; i < CUT_SIZE_MAX; i++ )
for ( i = 1; i <= CUT_SIZE_MAX; i++ )
{
if ( p->pHead[i] == NULL )
continue;
......
......@@ -45,7 +45,7 @@ Cut_Man_t * Cut_ManStart( Cut_Params_t * pParams )
{
Cut_Man_t * p;
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 );
memset( p, 0, sizeof(Cut_Man_t) );
// set and correct parameters
......@@ -65,19 +65,28 @@ Cut_Man_t * Cut_ManStart( Cut_Params_t * pParams )
assert( !pParams->fTruth || pParams->nVarsMax <= 5 );
// entry size
p->EntrySize = sizeof(Cut_Cut_t) + pParams->nVarsMax * sizeof(int);
if ( pParams->fTruth && pParams->nVarsMax >= 5 && pParams->nVarsMax <= 8 )
p->EntrySize += (1 << (pParams->nVarsMax - 5)) * sizeof(unsigned);
if ( pParams->fTruth )
{
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
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 );
return p;
}
......@@ -106,10 +115,12 @@ void Cut_ManStop( Cut_Man_t * p )
if ( p->vCutsOld ) Vec_PtrFree( p->vCutsOld );
if ( p->vCutsTemp ) Vec_PtrFree( p->vCutsTemp );
if ( p->vFanCounts ) Vec_IntFree( p->vFanCounts );
if ( p->pPerms43 ) free( p->pPerms43 );
if ( p->pPerms53 ) free( p->pPerms53 );
if ( p->pPerms54 ) free( p->pPerms54 );
if ( p->vTemp ) Vec_PtrFree( p->vTemp );
if ( p->vNodeCuts ) Vec_IntFree( p->vNodeCuts );
if ( p->vNodeStarts ) Vec_IntFree( p->vNodeStarts );
if ( p->vCutPairs ) Vec_IntFree( p->vCutPairs );
Extra_MmFixedStop( p->pMmCuts, 0 );
free( p );
}
......@@ -146,8 +157,9 @@ void Cut_ManPrintStats( Cut_Man_t * p )
PRT( "Union ", p->timeUnion );
PRT( "Filter", p->timeFilter );
PRT( "Truth ", p->timeTruth );
printf( "Nodes = %d. Multi = %d. Cuts = %d. Multi = %d.\n",
p->nNodes, p->nNodesMulti, p->nCutsCur-p->nCutsTriv, p->nCutsMulti );
// printf( "Nodes = %d. Multi = %d. Cuts = %d. Multi = %d.\n",
// 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
return NULL;
}
pRes = Cut_CutAlloc( p );
pRes->uTruth = (uSign1 << 8);
pRes->Num1 = uSign1;
}
for ( i = 0; i < (int)pCut0->nLeaves; 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
}
assert( Count == nNodes );
pRes->nLeaves = nNodes;
pRes->uTruth = (uSign1 << 8) | uSign0;
pRes->Num1 = uSign1;
pRes->Num0 = uSign0;
return pRes;
}
......
......@@ -24,15 +24,39 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static void Cut_NodeShiftLat( Cut_Man_t * p, int Node, int nLat );
static int Cut_ListCount( Cut_Cut_t * pList );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Shifts all cut leaves of the node by the given number of latches.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Cut_NodeShiftCutLeaves( Cut_Cut_t * pList, int nLat )
{
Cut_Cut_t * pTemp;
int i;
// shift the cuts by as many latches
Cut_ListForEachCut( pList, pTemp )
{
pTemp->uSign = 0;
for ( i = 0; i < (int)pTemp->nLeaves; i++ )
{
pTemp->pLeaves[i] += nLat;
pTemp->uSign |= Cut_NodeSign( pTemp->pLeaves[i] );
}
}
}
/**Function*************************************************************
Synopsis [Computes sequential cuts for the node from its fanins.]
Description []
......@@ -44,42 +68,70 @@ static int Cut_ListCount( Cut_Cut_t * pList );
***********************************************************************/
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 )
{
Cut_List_t List1, List2, List3;
Cut_Cut_t * pList1, * pList2, * pList3, * pListNew;
int clk = clock();
// assert( Node != Node0 );
// assert( Node != Node1 );
Cut_List_t Super, * pSuper = &Super;
Cut_Cut_t * pListNew;
int clk;
// get the number of cuts at the node
p->nNodeCuts = Cut_ListCount( Cut_NodeReadCutsOld(p, Node) );
p->nNodeCuts = Cut_CutCountList( Cut_NodeReadCutsOld(p, Node) );
if ( p->nNodeCuts >= p->pParams->nKeepMax )
return;
// count only the first visit
if ( p->nNodeCuts == 0 )
p->nNodes++;
// shift the cuts by as many latches
if ( nLat0 ) Cut_NodeShiftLat( p, Node0, nLat0 );
if ( nLat1 ) Cut_NodeShiftLat( p, Node1, nLat1 );
// merge the old and new
pList1 = Cut_NodeDoComputeCuts( p, Node, Node0, Node1, fCompl0, fCompl1, 0, 1, 0 );
// merge the new and old
pList2 = Cut_NodeDoComputeCuts( p, Node, Node0, Node1, fCompl0, fCompl1, 1, 0, 0 );
// merge the new and new
pList3 = Cut_NodeDoComputeCuts( p, Node, Node0, Node1, fCompl0, fCompl1, 1, 1, fTriv );
// store the fanin lists
p->pStore0[0] = Cut_NodeReadCutsOld( p, Node0 );
p->pStore0[1] = Cut_NodeReadCutsNew( p, Node0 );
p->pStore1[0] = Cut_NodeReadCutsOld( p, Node1 );
p->pStore1[1] = Cut_NodeReadCutsNew( p, Node1 );
// duplicate the cut lists if fanin nodes are non-standard
if ( Node == Node0 || Node == Node1 || Node0 == Node1 )
{
p->pStore0[0] = Cut_CutDupList( p, p->pStore0[0] );
p->pStore0[1] = Cut_CutDupList( p, p->pStore0[1] );
p->pStore1[0] = Cut_CutDupList( p, p->pStore1[0] );
p->pStore1[1] = Cut_CutDupList( p, p->pStore1[1] );
}
// shift the cuts by as many latches and recompute signatures
if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[0], nLat0 );
if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[1], nLat0 );
if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[0], nLat1 );
if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[1], nLat1 );
// store the original lists for comparison
p->pCompareOld = Cut_NodeReadCutsOld( p, Node );
p->pCompareNew = Cut_NodeReadCutsNew( p, Node );
// merge the old and the new
clk = clock();
Cut_ListStart( pSuper );
Cut_NodeDoComputeCuts( p, pSuper, Node, fCompl0, fCompl1, p->pStore0[0], p->pStore1[1], 0 );
Cut_NodeDoComputeCuts( p, pSuper, Node, fCompl0, fCompl1, p->pStore0[1], p->pStore1[0], 0 );
Cut_NodeDoComputeCuts( p, pSuper, Node, fCompl0, fCompl1, p->pStore0[1], p->pStore1[1], fTriv );
pListNew = Cut_ListFinish( pSuper );
p->timeMerge += clock() - clk;
// merge all lists
Cut_ListDerive( &List1, pList1 );
Cut_ListDerive( &List2, pList2 );
Cut_ListDerive( &List3, pList3 );
Cut_ListAddList( &List1, &List2 );
Cut_ListAddList( &List1, &List3 );
// shift the cuts by as many latches and recompute signatures
if ( Node == Node0 || Node == Node1 || Node0 == Node1 )
{
Cut_CutRecycleList( p, p->pStore0[0] );
Cut_CutRecycleList( p, p->pStore0[1] );
Cut_CutRecycleList( p, p->pStore1[0] );
Cut_CutRecycleList( p, p->pStore1[1] );
}
else
{
if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[0], -nLat0 );
if ( nLat0 ) Cut_NodeShiftCutLeaves( p->pStore0[1], -nLat0 );
if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[0], -nLat1 );
if ( nLat1 ) Cut_NodeShiftCutLeaves( p->pStore1[1], -nLat1 );
}
// set the lists at the node
pListNew = Cut_ListFinish( &List1 );
if ( CutSetNum >= 0 )
{
assert( Cut_NodeReadCutsTemp(p, CutSetNum) == NULL );
......@@ -91,17 +143,14 @@ p->timeMerge += clock() - clk;
Cut_NodeWriteCutsNew( p, Node, pListNew );
}
// shift the cuts by as many latches back
if ( nLat0 ) Cut_NodeShiftLat( p, Node0, -nLat0 );
if ( nLat1 ) Cut_NodeShiftLat( p, Node1, -nLat1 );
// mark the node if we exceeded the number of cuts
if ( p->nNodeCuts >= p->pParams->nKeepMax )
p->nCutsLimit++;
}
/**Function*************************************************************
Synopsis []
Synopsis [Merges the new cuts with the old cuts.]
Description []
......@@ -112,8 +161,7 @@ p->timeMerge += clock() - clk;
***********************************************************************/
void Cut_NodeNewMergeWithOld( Cut_Man_t * p, int Node )
{
Cut_List_t Old, New;
Cut_Cut_t * pListOld, * pListNew;
Cut_Cut_t * pListOld, * pListNew, * pList;
// get the new cuts
pListNew = Cut_NodeReadCutsNew( p, Node );
if ( pListNew == NULL )
......@@ -127,19 +175,16 @@ void Cut_NodeNewMergeWithOld( Cut_Man_t * p, int Node )
return;
}
// merge the lists
Cut_ListDerive( &Old, pListOld );
Cut_ListDerive( &New, pListNew );
Cut_ListAddList( &Old, &New );
pListOld = Cut_ListFinish( &Old );
Cut_NodeWriteCutsOld( p, Node, pListOld );
pList = Cut_CutMergeLists( pListOld, pListNew );
Cut_NodeWriteCutsOld( p, Node, pList );
}
/**Function*************************************************************
Synopsis [Returns 1 if something was transferred.]
Synopsis [Transfers the temporary cuts to be the new cuts.]
Description []
Description [Returns 1 if something was transferred.]
SideEffects []
......@@ -148,16 +193,16 @@ void Cut_NodeNewMergeWithOld( Cut_Man_t * p, int Node )
***********************************************************************/
int Cut_NodeTempTransferToNew( Cut_Man_t * p, int Node, int CutSetNum )
{
Cut_Cut_t * pCut;
pCut = Cut_NodeReadCutsTemp( p, CutSetNum );
Cut_Cut_t * pList;
pList = Cut_NodeReadCutsTemp( p, CutSetNum );
Cut_NodeWriteCutsTemp( p, CutSetNum, NULL );
Cut_NodeWriteCutsNew( p, Node, pCut );
return pCut != NULL;
Cut_NodeWriteCutsNew( p, Node, pList );
return pList != NULL;
}
/**Function*************************************************************
Synopsis [Returns 1 if something was transferred.]
Synopsis [Transfers the old cuts to be the new cuts.]
Description []
......@@ -168,66 +213,11 @@ int Cut_NodeTempTransferToNew( Cut_Man_t * p, int Node, int CutSetNum )
***********************************************************************/
void Cut_NodeOldTransferToNew( Cut_Man_t * p, int Node )
{
Cut_Cut_t * pCut;
pCut = Cut_NodeReadCutsOld( p, Node );
Cut_Cut_t * pList;
pList = Cut_NodeReadCutsOld( p, Node );
Cut_NodeWriteCutsOld( p, Node, NULL );
Cut_NodeWriteCutsNew( p, Node, pCut );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Cut_NodeShiftLat( Cut_Man_t * p, int Node, int nLat )
{
Cut_Cut_t * pTemp;
int i;
// shift the cuts by as many latches
Cut_ListForEachCut( Cut_NodeReadCutsOld(p, Node), pTemp )
{
pTemp->uSign = 0;
for ( i = 0; i < (int)pTemp->nLeaves; i++ )
{
pTemp->pLeaves[i] += nLat;
pTemp->uSign |= Cut_NodeSign( pTemp->pLeaves[i] );
}
}
Cut_ListForEachCut( Cut_NodeReadCutsNew(p, Node), pTemp )
{
pTemp->uSign = 0;
for ( i = 0; i < (int)pTemp->nLeaves; i++ )
{
pTemp->pLeaves[i] += nLat;
pTemp->uSign |= Cut_NodeSign( pTemp->pLeaves[i] );
}
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Cut_ListCount( Cut_Cut_t * pList )
{
int Counter = 0;
Cut_ListForEachCut( pList, pList )
Counter++;
return Counter;
Cut_NodeWriteCutsNew( p, Node, pList );
// Cut_CutListVerify( pList );
}
////////////////////////////////////////////////////////////////////////
......
......@@ -55,7 +55,7 @@ int Rwr_NodeRewrite( Rwr_Man_t * p, Cut_Man_t * pManCut, Abc_Obj_t * pNode, int
Dec_Graph_t * pGraph;
Cut_Cut_t * pCut;
Abc_Obj_t * pFanin;
unsigned uPhase, uTruthBest;
unsigned uPhase, uTruthBest, uTruth;
char * pPerm;
int Required, nNodesSaved;
int i, GainCur, GainBest = -1;
......@@ -78,8 +78,9 @@ clk = clock();
if ( pCut->nLeaves < 4 )
continue;
// get the fanin permutation
pPerm = p->pPerms4[ p->pPerms[pCut->uTruth] ];
uPhase = p->pPhases[pCut->uTruth];
uTruth = 0xFFFF & *Cut_CutReadTruth(pCut);
pPerm = p->pPerms4[ p->pPerms[uTruth] ];
uPhase = p->pPhases[uTruth];
// collect fanins with the corresponding permutation/phase
Vec_PtrClear( p->vFaninsCur );
Vec_PtrFill( p->vFaninsCur, (int)pCut->nLeaves, 0 );
......@@ -122,7 +123,7 @@ p->timeEval += clock() - clk2;
GainBest = GainCur;
p->pGraph = pGraph;
p->fCompl = ((uPhase & (1<<4)) > 0);
uTruthBest = pCut->uTruth;
uTruthBest = 0xFFFF & *Cut_CutReadTruth(pCut);
// collect fanins in the
Vec_PtrClear( p->vFanins );
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
Dec_Graph_t * pGraphBest, * pGraphCur;
Rwr_Node_t * pNode, * pFanin;
int nNodesAdded, GainBest, i, k;
unsigned uTruth;
// 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;
// determine the best subgraph
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