Commit c345a60e by Alan Mishchenko

Experiments with variable permutation.

parent 9382c8fd
...@@ -198,6 +198,7 @@ int Cnf_IsopWriteCube( int Cube, int nVars, int * pVars, int * pLiterals ) ...@@ -198,6 +198,7 @@ int Cnf_IsopWriteCube( int Cube, int nVars, int * pVars, int * pLiterals )
***********************************************************************/ ***********************************************************************/
Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs ) Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs )
{ {
int fChangeVariableOrder = 0; // should be set to 0 to improve performance
Aig_Obj_t * pObj; Aig_Obj_t * pObj;
Cnf_Dat_t * pCnf; Cnf_Dat_t * pCnf;
Cnf_Cut_t * pCut; Cnf_Cut_t * pCut;
...@@ -252,12 +253,14 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs ) ...@@ -252,12 +253,14 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs )
pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 ); pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 );
pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals ); pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals );
pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals; pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals;
// create room for variable numbers // create room for variable numbers
pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(p->pManAig) ); pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(p->pManAig) );
// memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(p->pManAig) ); // memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(p->pManAig) );
for ( i = 0; i < Aig_ManObjNumMax(p->pManAig); i++ ) for ( i = 0; i < Aig_ManObjNumMax(p->pManAig); i++ )
pCnf->pVarNums[i] = -1; pCnf->pVarNums[i] = -1;
if ( !fChangeVariableOrder )
{
// assign variables to the last (nOutputs) POs // assign variables to the last (nOutputs) POs
Number = 1; Number = 1;
if ( nOutputs ) if ( nOutputs )
...@@ -283,6 +286,36 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs ) ...@@ -283,6 +286,36 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs )
pCnf->pVarNums[pObj->Id] = Number++; pCnf->pVarNums[pObj->Id] = Number++;
pCnf->pVarNums[Aig_ManConst1(p->pManAig)->Id] = Number++; pCnf->pVarNums[Aig_ManConst1(p->pManAig)->Id] = Number++;
pCnf->nVars = Number; pCnf->nVars = Number;
}
else
{
// assign variables to the last (nOutputs) POs
Number = Aig_ManObjNumMax(p->pManAig) + 1;
pCnf->nVars = Number + 1;
if ( nOutputs )
{
if ( Aig_ManRegNum(p->pManAig) == 0 )
{
assert( nOutputs == Aig_ManPoNum(p->pManAig) );
Aig_ManForEachPo( p->pManAig, pObj, i )
pCnf->pVarNums[pObj->Id] = Number--;
}
else
{
assert( nOutputs == Aig_ManRegNum(p->pManAig) );
Aig_ManForEachLiSeq( p->pManAig, pObj, i )
pCnf->pVarNums[pObj->Id] = Number--;
}
}
// assign variables to the internal nodes
Vec_PtrForEachEntry( Aig_Obj_t *, vMapped, pObj, i )
pCnf->pVarNums[pObj->Id] = Number--;
// assign variables to the PIs and constant node
Aig_ManForEachPi( p->pManAig, pObj, i )
pCnf->pVarNums[pObj->Id] = Number--;
pCnf->pVarNums[Aig_ManConst1(p->pManAig)->Id] = Number--;
assert( Number >= 0 );
}
// assign the clauses // assign the clauses
vSopTemp = Vec_IntAlloc( 1 << 16 ); vSopTemp = Vec_IntAlloc( 1 << 16 );
......
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