abc/src/opt/sim/simSym.c

143 lines
4.9 KiB
C
Raw Normal View History

2005-09-04 17:01:00 +02:00
/**CFile****************************************************************
FileName [simSym.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Network and node package.]
Synopsis [Simulation to determine two-variable symmetries.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: simSym.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abc.h"
#include "sim.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
2005-10-12 17:01:00 +02:00
/// FUNCTION DEFINITIONS ///
2005-09-04 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Computes two variable symmetries.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
2005-09-05 17:01:00 +02:00
int Sim_ComputeTwoVarSymms( Abc_Ntk_t * pNtk, int fVerbose )
2005-09-04 17:01:00 +02:00
{
Sym_Man_t * p;
Vec_Ptr_t * vResult;
int Result;
2005-09-05 17:01:00 +02:00
int i, clk, clkTotal = clock();
2005-09-04 17:01:00 +02:00
srand( 0xABC );
// start the simulation manager
2005-09-05 17:01:00 +02:00
p = Sym_ManStart( pNtk, fVerbose );
p->nPairsTotal = p->nPairsRem = Sim_UtilCountAllPairs( p->vSuppFun, p->nSimWords, p->vPairsTotal );
if ( fVerbose )
printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
2005-09-04 17:01:00 +02:00
// detect symmetries using circuit structure
2005-09-05 17:01:00 +02:00
clk = clock();
Sim_SymmsStructCompute( pNtk, p->vMatrSymms, p->vSuppFun );
p->timeStruct = clock() - clk;
2005-09-04 17:01:00 +02:00
2005-09-05 17:01:00 +02:00
Sim_UtilCountPairsAll( p );
p->nPairsSymmStr = p->nPairsSymm;
if ( fVerbose )
printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
2005-09-04 17:01:00 +02:00
// detect symmetries using simulation
for ( i = 1; i <= 1000; i++ )
{
// simulate this pattern
2005-10-07 17:01:00 +02:00
Sim_UtilSetRandom( p->uPatRand, p->nSimWords );
2005-09-04 17:01:00 +02:00
Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
2005-09-05 17:01:00 +02:00
if ( i % 50 != 0 )
2005-09-04 17:01:00 +02:00
continue;
2005-09-05 17:01:00 +02:00
// check disjointness
assert( Sim_UtilMatrsAreDisjoint( p ) );
2005-09-04 17:01:00 +02:00
// count the number of pairs
2005-09-05 17:01:00 +02:00
Sim_UtilCountPairsAll( p );
if ( i % 500 != 0 )
continue;
if ( fVerbose )
printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
}
2005-09-04 17:01:00 +02:00
2005-09-05 17:01:00 +02:00
// detect symmetries using SAT
for ( i = 1; Sim_SymmsGetPatternUsingSat( p, p->uPatRand ); i++ )
{
// simulate this pattern in four polarities
Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
Sim_XorBit( p->uPatRand, p->iVar1 );
Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
Sim_XorBit( p->uPatRand, p->iVar2 );
Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
Sim_XorBit( p->uPatRand, p->iVar1 );
Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
Sim_XorBit( p->uPatRand, p->iVar2 );
/*
// try the previuos pair
Sim_XorBit( p->uPatRand, p->iVar1Old );
Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
Sim_XorBit( p->uPatRand, p->iVar2Old );
Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
Sim_XorBit( p->uPatRand, p->iVar1Old );
Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
*/
if ( i % 10 != 0 )
continue;
// check disjointness
assert( Sim_UtilMatrsAreDisjoint( p ) );
// count the number of pairs
Sim_UtilCountPairsAll( p );
if ( i % 50 != 0 )
continue;
if ( fVerbose )
printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
2005-09-04 17:01:00 +02:00
}
2005-09-05 17:01:00 +02:00
// count the number of pairs
Sim_UtilCountPairsAll( p );
if ( fVerbose )
printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
2005-10-10 17:01:00 +02:00
// Sim_UtilCountPairsAllPrint( p );
2005-09-05 17:01:00 +02:00
2005-09-04 17:01:00 +02:00
Result = p->nPairsSymm;
vResult = p->vMatrSymms;
2005-09-05 17:01:00 +02:00
p->timeTotal = clock() - clkTotal;
2005-09-04 17:01:00 +02:00
// p->vMatrSymms = NULL;
Sym_ManStop( p );
return Result;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////