summaryrefslogtreecommitdiffstats
path: root/src/aig/cnf
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2011-11-06 23:14:32 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2011-11-06 23:14:32 -0800
commitc345a60ee7f0156e11cf6b5e107eecc867ca2a3a (patch)
treef9a2624d0ede96e51ad472c6aeb1f11b7764adad /src/aig/cnf
parent9382c8fdd1feb4f69ab6d2e99dfc43658b14079d (diff)
downloadabc-c345a60ee7f0156e11cf6b5e107eecc867ca2a3a.tar.gz
abc-c345a60ee7f0156e11cf6b5e107eecc867ca2a3a.tar.bz2
abc-c345a60ee7f0156e11cf6b5e107eecc867ca2a3a.zip
Experiments with variable permutation.
Diffstat (limited to 'src/aig/cnf')
-rw-r--r--src/aig/cnf/cnfWrite.c73
1 files changed, 53 insertions, 20 deletions
diff --git a/src/aig/cnf/cnfWrite.c b/src/aig/cnf/cnfWrite.c
index 7a9443f2..54c28967 100644
--- a/src/aig/cnf/cnfWrite.c
+++ b/src/aig/cnf/cnfWrite.c
@@ -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 )
{
+ int fChangeVariableOrder = 0; // should be set to 0 to improve performance
Aig_Obj_t * pObj;
Cnf_Dat_t * pCnf;
Cnf_Cut_t * pCut;
@@ -252,37 +253,69 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs )
pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 );
pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals );
pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals;
-
// create room for variable numbers
pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(p->pManAig) );
// memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(p->pManAig) );
for ( i = 0; i < Aig_ManObjNumMax(p->pManAig); i++ )
pCnf->pVarNums[i] = -1;
- // assign variables to the last (nOutputs) POs
- Number = 1;
- if ( nOutputs )
+
+ if ( !fChangeVariableOrder )
{
- if ( Aig_ManRegNum(p->pManAig) == 0 )
+ // assign variables to the last (nOutputs) POs
+ Number = 1;
+ if ( nOutputs )
{
- assert( nOutputs == Aig_ManPoNum(p->pManAig) );
- Aig_ManForEachPo( p->pManAig, pObj, i )
- pCnf->pVarNums[pObj->Id] = Number++;
+ 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++;
+ }
}
- else
+ // 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++;
+ pCnf->nVars = Number;
+ }
+ else
+ {
+ // assign variables to the last (nOutputs) POs
+ Number = Aig_ManObjNumMax(p->pManAig) + 1;
+ pCnf->nVars = Number + 1;
+ if ( nOutputs )
{
- assert( nOutputs == Aig_ManRegNum(p->pManAig) );
- Aig_ManForEachLiSeq( p->pManAig, pObj, i )
- pCnf->pVarNums[pObj->Id] = Number++;
+ 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 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++;
- pCnf->nVars = Number;
// assign the clauses
vSopTemp = Vec_IntAlloc( 1 << 16 );