ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaSatLut.c File Reference
#include "gia.h"
#include "misc/tim/tim.h"
#include "misc/util/utilTruth.h"
#include "sat/bsat/satStore.h"
#include "misc/util/utilNam.h"
#include "map/scl/sclCon.h"
#include "misc/vec/vecHsh.h"
#include <unistd.h>
Include dependency graph for giaSatLut.c:

Go to the source code of this file.

Classes

struct  Sbl_Man_t_
 

Macros

#define KSAT_OBJS   24
 
#define KSAT_MINTS   64
 
#define KSAT_SPACE   (4+3*KSAT_OBJS+3*KSAT_MINTS)
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Sbl_Man_t_ Sbl_Man_t
 DECLARATIONS ///.
 

Enumerations

enum  Gia_ManGate_t {
  GIA_GATE_ZERO , GIA_GATE_ONE , GIA_GATE_BUF , GIA_GATE_INV ,
  GIA_GATE_NAN2 , GIA_GATE_NOR2 , GIA_GATE_AOI21 , GIA_GATE_NAN3 ,
  GIA_GATE_NOR3 , GIA_GATE_OAI21 , GIA_GATE_AOI22 , GIA_GATE_OAI22 ,
  RTM_VAL_VOID
}
 
enum  Gia_ManGate2_t {
  GIA_GATE2_ZERO , GIA_GATE2_ONE , GIA_GATE2_BUF , GIA_GATE2_INV ,
  GIA_GATE2_NAN2 , GIA_GATE2_NOR2 , GIA_GATE2_AOI21 , GIA_GATE2_NAN3 ,
  GIA_GATE2_NOR3 , GIA_GATE2_OAI21 , GIA_GATE2_NOR4 , GIA_GATE2_AOI211 ,
  GIA_GATE2_AOI22 , GIA_GATE2_NAN4 , GIA_GATE2_OAI211 , GIA_GATE2_OAI22 ,
  GIA_GATE2_VOID
}
 

Functions

sat_solverSbm_AddCardinSolver (int LogN, Vec_Int_t **pvVars)
 
Sbl_Man_tSbl_ManAlloc (Gia_Man_t *pGia, int Number)
 FUNCTION DEFINITIONS ///.
 
void Sbl_ManClean (Sbl_Man_t *p)
 
void Sbl_ManStop (Sbl_Man_t *p)
 
void Sbl_ManGetCurrentMapping (Sbl_Man_t *p)
 
int Sbl_ManComputeDelay (Sbl_Man_t *p, int iLut, Vec_Int_t *vFanins)
 
int Sbl_ManCreateTiming (Sbl_Man_t *p, int DelayStart)
 
int Sbl_ManEvaluateMappingEdge (Sbl_Man_t *p, int DelayGlo)
 
int Sbl_ManCriticalFanin (Sbl_Man_t *p, int iLut, Vec_Int_t *vFanins)
 
int Sbl_ManEvaluateMapping (Sbl_Man_t *p, int DelayGlo)
 
void Sbl_ManUpdateMapping (Sbl_Man_t *p)
 
int Sbl_ManComputeCuts (Sbl_Man_t *p)
 
int Sbl_ManCreateCnf (Sbl_Man_t *p)
 
void Sbl_ManWindow (Sbl_Man_t *p)
 
int Sbl_ManWindow2 (Sbl_Man_t *p, int iPivot)
 
int Sbl_ManTestSat (Sbl_Man_t *p, int iPivot)
 
void Sbl_ManPrintRuntime (Sbl_Man_t *p)
 
void Gia_ManLutSat (Gia_Man_t *pGia, int LutSize, int nNumber, int nImproves, int nBTLimit, int DelayMax, int nEdges, int fDelay, int fReverse, int fVerbose, int fVeryVerbose)
 
Vec_Int_tGia_RunKadical (char *pFileNameIn, char *pFileNameOut, int Seed, int nBTLimit, int TimeOut, int fVerbose, int *pStatus)
 
int Gia_SatVarReqPos (int i)
 
int Gia_SatVarReqNeg (int i)
 
int Gia_SatVarAckPos (int i)
 
int Gia_SatVarAckNeg (int i)
 
int Gia_SatVarInv (int i)
 
int Gia_SatVarFan0 (int i)
 
int Gia_SatVarFan1 (int i)
 
int Gia_SatValReqPos (Vec_Int_t *p, int i)
 
int Gia_SatValReqNeg (Vec_Int_t *p, int i)
 
int Gia_SatValAckPos (Vec_Int_t *p, int i)
 
int Gia_SatValAckNeg (Vec_Int_t *p, int i)
 
int Gia_SatValInv (Vec_Int_t *p, int i)
 
int Gia_SatValFan0 (Vec_Int_t *p, int i)
 
int Gia_SatValFan1 (Vec_Int_t *p, int i)
 
void Gia_SatDumpClause (Vec_Str_t *vStr, int *pLits, int nLits)
 
void Gia_SatDumpLiteral (Vec_Str_t *vStr, int Lit)
 
void Gia_SatDumpKlause (Vec_Str_t *vStr, int nIns, int nAnds, int nBound)
 
Vec_Str_tGia_ManSimpleCnf (Gia_Man_t *p, int nBound)
 
Vec_Int_tGia_ManDeriveSimpleMapping (Gia_Man_t *p, Vec_Int_t *vRes)
 
void Gia_ManSimplePrintMapping (Vec_Int_t *vRes, int nIns)
 
int Gia_ManDumpCnf (char *pFileName, Vec_Str_t *vStr, int nVars)
 
int Gia_ManDumpCnf2 (Vec_Str_t *vStr, int nVars, int argc, char **argv, abctime Time, int Status)
 
int Gia_ManSimpleMapping (Gia_Man_t *p, int nBound, int Seed, int nBTLimit, int nTimeout, int fVerbose, int fKeepFile, int argc, char **argv)
 
int Gia_KSatVarInv (int *pMap, int i)
 
int Gia_KSatVarAnd (int *pMap, int i)
 
int Gia_KSatVarEqu (int *pMap, int i)
 
int Gia_KSatVarRef (int *pMap, int i)
 
int Gia_KSatVarFan (int *pMap, int i, int f, int k)
 
int Gia_KSatVarMin (int *pMap, int i, int m, int k)
 
void Gia_KSatSetInv (int *pMap, int i, int iVar)
 
void Gia_KSatSetAnd (int *pMap, int i, int iVar)
 
void Gia_KSatSetEqu (int *pMap, int i, int iVar)
 
void Gia_KSatSetRef (int *pMap, int i, int iVar)
 
void Gia_KSatSetFan (int *pMap, int i, int f, int k, int iVar)
 
void Gia_KSatSetMin (int *pMap, int i, int m, int k, int iVar)
 
int Gia_KSatValInv (int *pMap, int i, Vec_Int_t *vRes)
 
int Gia_KSatValAnd (int *pMap, int i, Vec_Int_t *vRes)
 
int Gia_KSatValEqu (int *pMap, int i, Vec_Int_t *vRes)
 
int Gia_KSatValRef (int *pMap, int i, Vec_Int_t *vRes)
 
int Gia_KSatValFan (int *pMap, int i, int f, int k, Vec_Int_t *vRes)
 
int Gia_KSatValMin (int *pMap, int i, int m, int k, Vec_Int_t *vRes)
 
int * Gia_KSatMapInit (int nIns, int nNodes, word Truth, int *pnVars)
 
int Gia_KSatFindFan (int *pMap, int i, int f, Vec_Int_t *vRes)
 
Vec_Int_tGia_ManKSatGenLevels (char *pGuide, int nIns, int nNodes)
 
Vec_Str_tGia_ManKSatCnf (int *pMap, int nIns, int nNodes, int nBound, int fMultiLevel, char *pGuide)
 
Vec_Int_tGia_ManDeriveKSatMappingArray (Gia_Man_t *p, Vec_Int_t *vRes)
 
Gia_Man_tGia_ManDeriveKSatMapping (Vec_Int_t *vRes, int *pMap, int nIns, int nNodes, int fVerbose)
 
word Gia_ManGetTruth (Gia_Man_t *p)
 
Gia_Man_tGia_ManKSatMapping (word Truth, int nIns, int nNodes, int nBound, int Seed, int fMultiLevel, int nBTLimit, int nTimeout, int fVerbose, int fKeepFile, int argc, char **argv, char *pGuide)
 

Macro Definition Documentation

◆ KSAT_MINTS

#define KSAT_MINTS   64

Definition at line 1620 of file giaSatLut.c.

◆ KSAT_OBJS

#define KSAT_OBJS   24

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1619 of file giaSatLut.c.

◆ KSAT_SPACE

#define KSAT_SPACE   (4+3*KSAT_OBJS+3*KSAT_MINTS)

Definition at line 1621 of file giaSatLut.c.

Typedef Documentation

◆ Sbl_Man_t

typedef typedefABC_NAMESPACE_IMPL_START struct Sbl_Man_t_ Sbl_Man_t

DECLARATIONS ///.

CFile****************************************************************

FileName [giaSatLut.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
giaSatLut.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 42 of file giaSatLut.c.

Enumeration Type Documentation

◆ Gia_ManGate2_t

Enumerator
GIA_GATE2_ZERO 
GIA_GATE2_ONE 
GIA_GATE2_BUF 
GIA_GATE2_INV 
GIA_GATE2_NAN2 
GIA_GATE2_NOR2 
GIA_GATE2_AOI21 
GIA_GATE2_NAN3 
GIA_GATE2_NOR3 
GIA_GATE2_OAI21 
GIA_GATE2_NOR4 
GIA_GATE2_AOI211 
GIA_GATE2_AOI22 
GIA_GATE2_NAN4 
GIA_GATE2_OAI211 
GIA_GATE2_OAI22 
GIA_GATE2_VOID 

Definition at line 1904 of file giaSatLut.c.

1904 {
1905 GIA_GATE2_ZERO, // 0:
1906 GIA_GATE2_ONE, // 1:
1907 GIA_GATE2_BUF, // 2:
1908 GIA_GATE2_INV, // 3:
1909 GIA_GATE2_NAN2, // 4:
1910 GIA_GATE2_NOR2, // 5:
1911 GIA_GATE2_AOI21, // 6:
1912 GIA_GATE2_NAN3, // 7:
1913 GIA_GATE2_NOR3, // 8:
1914 GIA_GATE2_OAI21, // 9:
1915 GIA_GATE2_NOR4, // 10:
1916 GIA_GATE2_AOI211, // 11:
1917 GIA_GATE2_AOI22, // 12:
1918 GIA_GATE2_NAN4, // 13:
1919 GIA_GATE2_OAI211, // 14:
1920 GIA_GATE2_OAI22, // 15:
1921 GIA_GATE2_VOID // 16: unused value
Gia_ManGate2_t
Definition giaSatLut.c:1904
@ GIA_GATE2_INV
Definition giaSatLut.c:1908
@ GIA_GATE2_NOR2
Definition giaSatLut.c:1910
@ GIA_GATE2_OAI21
Definition giaSatLut.c:1914
@ GIA_GATE2_AOI21
Definition giaSatLut.c:1911
@ GIA_GATE2_NAN4
Definition giaSatLut.c:1918
@ GIA_GATE2_OAI211
Definition giaSatLut.c:1919
@ GIA_GATE2_ZERO
Definition giaSatLut.c:1905
@ GIA_GATE2_NAN3
Definition giaSatLut.c:1912
@ GIA_GATE2_NAN2
Definition giaSatLut.c:1909
@ GIA_GATE2_BUF
Definition giaSatLut.c:1907
@ GIA_GATE2_OAI22
Definition giaSatLut.c:1920
@ GIA_GATE2_NOR3
Definition giaSatLut.c:1913
@ GIA_GATE2_AOI211
Definition giaSatLut.c:1916
@ GIA_GATE2_NOR4
Definition giaSatLut.c:1915
@ GIA_GATE2_ONE
Definition giaSatLut.c:1906
@ GIA_GATE2_VOID
Definition giaSatLut.c:1921
@ GIA_GATE2_AOI22
Definition giaSatLut.c:1917

◆ Gia_ManGate_t

Enumerator
GIA_GATE_ZERO 
GIA_GATE_ONE 
GIA_GATE_BUF 
GIA_GATE_INV 
GIA_GATE_NAN2 
GIA_GATE_NOR2 
GIA_GATE_AOI21 
GIA_GATE_NAN3 
GIA_GATE_NOR3 
GIA_GATE_OAI21 
GIA_GATE_AOI22 
GIA_GATE_OAI22 
RTM_VAL_VOID 

Definition at line 1443 of file giaSatLut.c.

1443 {
1444 GIA_GATE_ZERO, // 0:
1445 GIA_GATE_ONE, // 1:
1446 GIA_GATE_BUF, // 2:
1447 GIA_GATE_INV, // 3:
1448 GIA_GATE_NAN2, // 4:
1449 GIA_GATE_NOR2, // 5:
1450 GIA_GATE_AOI21, // 6:
1451 GIA_GATE_NAN3, // 7:
1452 GIA_GATE_NOR3, // 8:
1453 GIA_GATE_OAI21, // 9:
1454 GIA_GATE_AOI22, // 10:
1455 GIA_GATE_OAI22, // 11:
1456 RTM_VAL_VOID // 12: unused value
@ RTM_VAL_VOID
Definition aigRet.c:35
Gia_ManGate_t
Definition giaSatLut.c:1443
@ GIA_GATE_AOI22
Definition giaSatLut.c:1454
@ GIA_GATE_INV
Definition giaSatLut.c:1447
@ GIA_GATE_NAN3
Definition giaSatLut.c:1451
@ GIA_GATE_OAI21
Definition giaSatLut.c:1453
@ GIA_GATE_ONE
Definition giaSatLut.c:1445
@ GIA_GATE_BUF
Definition giaSatLut.c:1446
@ GIA_GATE_ZERO
Definition giaSatLut.c:1444
@ GIA_GATE_OAI22
Definition giaSatLut.c:1455
@ GIA_GATE_NOR2
Definition giaSatLut.c:1449
@ GIA_GATE_NAN2
Definition giaSatLut.c:1448
@ GIA_GATE_NOR3
Definition giaSatLut.c:1452
@ GIA_GATE_AOI21
Definition giaSatLut.c:1450

Function Documentation

◆ Gia_KSatFindFan()

int Gia_KSatFindFan ( int * pMap,
int i,
int f,
Vec_Int_t * vRes )

Definition at line 1676 of file giaSatLut.c.

1677{
1678 assert( f < 2 );
1679 for ( int k = 0; k < i; k++ )
1680 if ( Gia_KSatValFan( pMap, i, f, k, vRes ) )
1681 return k;
1682 assert( 0 );
1683 return -1;
1684}
int Gia_KSatValFan(int *pMap, int i, int f, int k, Vec_Int_t *vRes)
Definition giaSatLut.c:1641
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_KSatMapInit()

int * Gia_KSatMapInit ( int nIns,
int nNodes,
word Truth,
int * pnVars )

Definition at line 1644 of file giaSatLut.c.

1645{
1646 assert( nIns + nNodes <= KSAT_OBJS );
1647 assert( (1 << nIns) <= KSAT_MINTS );
1648 int n, m, f, k, nVars = 2, * pMap = ABC_FALLOC( int, KSAT_OBJS*KSAT_SPACE );
1649 for ( n = nIns; n < nIns+nNodes; n++ ) {
1650 Gia_KSatSetInv(pMap, n, nVars++);
1651 Gia_KSatSetAnd(pMap, n, nVars++);
1652 Gia_KSatSetEqu(pMap, n, nVars++);
1653 Gia_KSatSetRef(pMap, n, nVars++);
1654 }
1655 for ( n = nIns; n < nIns+nNodes; n++ ) {
1656 for ( f = 0; f < 2; f++ )
1657 for ( k = 0; k < n; k++ )
1658 Gia_KSatSetFan(pMap, n, f, k, nVars++);
1659 for ( k = n+1; k < nIns+nNodes; k++ )
1660 Gia_KSatSetFan(pMap, n, 2, k, nVars++);
1661 }
1662 for ( m = 0; m < (1<<nIns); m++ ) {
1663 for ( n = 0; n < nIns; n++ )
1664 Gia_KSatSetMin(pMap, n, m, 0, (m >> n) & 1 );
1665 Gia_KSatSetMin(pMap, nIns+nNodes-1, m, 0, (Truth >> m) & 1 );
1666 for ( n = nIns; n < nIns+nNodes; n++ )
1667 for ( k = 0; k < 3; k++ )
1668 if ( k || n < nIns+nNodes-1 )
1669 Gia_KSatSetMin(pMap, n, m, k, nVars++);
1670
1671 }
1672 if ( pnVars ) *pnVars = nVars;
1673 return pMap;
1674}
#define ABC_FALLOC(type, num)
Definition abc_global.h:266
void Gia_KSatSetAnd(int *pMap, int i, int iVar)
Definition giaSatLut.c:1631
#define KSAT_SPACE
Definition giaSatLut.c:1621
#define KSAT_MINTS
Definition giaSatLut.c:1620
void Gia_KSatSetFan(int *pMap, int i, int f, int k, int iVar)
Definition giaSatLut.c:1634
void Gia_KSatSetInv(int *pMap, int i, int iVar)
Definition giaSatLut.c:1630
void Gia_KSatSetEqu(int *pMap, int i, int iVar)
Definition giaSatLut.c:1632
#define KSAT_OBJS
Definition giaSatLut.c:1619
void Gia_KSatSetRef(int *pMap, int i, int iVar)
Definition giaSatLut.c:1633
void Gia_KSatSetMin(int *pMap, int i, int m, int k, int iVar)
Definition giaSatLut.c:1635
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_KSatSetAnd()

void Gia_KSatSetAnd ( int * pMap,
int i,
int iVar )

Definition at line 1631 of file giaSatLut.c.

1631{ assert( -1 == pMap[i*KSAT_SPACE+1] ); pMap[i*KSAT_SPACE+1] = iVar; }
Here is the caller graph for this function:

◆ Gia_KSatSetEqu()

void Gia_KSatSetEqu ( int * pMap,
int i,
int iVar )

Definition at line 1632 of file giaSatLut.c.

1632{ assert( -1 == pMap[i*KSAT_SPACE+2] ); pMap[i*KSAT_SPACE+2] = iVar; }
Here is the caller graph for this function:

◆ Gia_KSatSetFan()

void Gia_KSatSetFan ( int * pMap,
int i,
int f,
int k,
int iVar )

Definition at line 1634 of file giaSatLut.c.

1634{ assert( -1 == pMap[i*KSAT_SPACE+4+f*KSAT_OBJS+k] ); pMap[i*KSAT_SPACE+4+f*KSAT_OBJS+k] = iVar; }
Here is the caller graph for this function:

◆ Gia_KSatSetInv()

void Gia_KSatSetInv ( int * pMap,
int i,
int iVar )

Definition at line 1630 of file giaSatLut.c.

1630{ assert( -1 == pMap[i*KSAT_SPACE+0] ); pMap[i*KSAT_SPACE+0] = iVar; }
Here is the caller graph for this function:

◆ Gia_KSatSetMin()

void Gia_KSatSetMin ( int * pMap,
int i,
int m,
int k,
int iVar )

Definition at line 1635 of file giaSatLut.c.

1635{ assert( -1 == pMap[i*KSAT_SPACE+4+3*KSAT_OBJS+3*m+k] ); pMap[i*KSAT_SPACE+4+3*KSAT_OBJS+3*m+k] = iVar; }
Here is the caller graph for this function:

◆ Gia_KSatSetRef()

void Gia_KSatSetRef ( int * pMap,
int i,
int iVar )

Definition at line 1633 of file giaSatLut.c.

1633{ assert( -1 == pMap[i*KSAT_SPACE+3] ); pMap[i*KSAT_SPACE+3] = iVar; }
Here is the caller graph for this function:

◆ Gia_KSatValAnd()

int Gia_KSatValAnd ( int * pMap,
int i,
Vec_Int_t * vRes )

Definition at line 1638 of file giaSatLut.c.

1638{ assert( -1 != pMap[i*KSAT_SPACE+1] ); return Vec_IntEntry( vRes, pMap[i*KSAT_SPACE+1] ); }
Here is the caller graph for this function:

◆ Gia_KSatValEqu()

int Gia_KSatValEqu ( int * pMap,
int i,
Vec_Int_t * vRes )

Definition at line 1639 of file giaSatLut.c.

1639{ assert( -1 != pMap[i*KSAT_SPACE+2] ); return Vec_IntEntry( vRes, pMap[i*KSAT_SPACE+2] ); }

◆ Gia_KSatValFan()

int Gia_KSatValFan ( int * pMap,
int i,
int f,
int k,
Vec_Int_t * vRes )

Definition at line 1641 of file giaSatLut.c.

1641{ assert( -1 != pMap[i*KSAT_SPACE+4+f*KSAT_OBJS+k] ); return Vec_IntEntry( vRes, pMap[i*KSAT_SPACE+4+f*KSAT_OBJS+k] ); }
Here is the caller graph for this function:

◆ Gia_KSatValInv()

int Gia_KSatValInv ( int * pMap,
int i,
Vec_Int_t * vRes )

Definition at line 1637 of file giaSatLut.c.

1637{ assert( -1 != pMap[i*KSAT_SPACE+0] ); return Vec_IntEntry( vRes, pMap[i*KSAT_SPACE+0] ); }
Here is the caller graph for this function:

◆ Gia_KSatValMin()

int Gia_KSatValMin ( int * pMap,
int i,
int m,
int k,
Vec_Int_t * vRes )

Definition at line 1642 of file giaSatLut.c.

1642{ assert( -1 != pMap[i*KSAT_SPACE+4+3*KSAT_OBJS+3*m+k] ); return Vec_IntEntry( vRes, pMap[i*KSAT_SPACE+4+3*KSAT_OBJS+3*m+k] ); }

◆ Gia_KSatValRef()

int Gia_KSatValRef ( int * pMap,
int i,
Vec_Int_t * vRes )

Definition at line 1640 of file giaSatLut.c.

1640{ assert( -1 != pMap[i*KSAT_SPACE+3] ); return Vec_IntEntry( vRes, pMap[i*KSAT_SPACE+3] ); }

◆ Gia_KSatVarAnd()

int Gia_KSatVarAnd ( int * pMap,
int i )

Definition at line 1624 of file giaSatLut.c.

1624{ return pMap[i*KSAT_SPACE+1]; }
Here is the caller graph for this function:

◆ Gia_KSatVarEqu()

int Gia_KSatVarEqu ( int * pMap,
int i )

Definition at line 1625 of file giaSatLut.c.

1625{ return pMap[i*KSAT_SPACE+2]; }
Here is the caller graph for this function:

◆ Gia_KSatVarFan()

int Gia_KSatVarFan ( int * pMap,
int i,
int f,
int k )

Definition at line 1627 of file giaSatLut.c.

1627{ return pMap[i*KSAT_SPACE+4+f*KSAT_OBJS+k]; }
Here is the caller graph for this function:

◆ Gia_KSatVarInv()

int Gia_KSatVarInv ( int * pMap,
int i )

Definition at line 1623 of file giaSatLut.c.

1623{ return pMap[i*KSAT_SPACE+0]; }
Here is the caller graph for this function:

◆ Gia_KSatVarMin()

int Gia_KSatVarMin ( int * pMap,
int i,
int m,
int k )

Definition at line 1628 of file giaSatLut.c.

1628{ return pMap[i*KSAT_SPACE+4+3*KSAT_OBJS+3*m+k]; }
Here is the caller graph for this function:

◆ Gia_KSatVarRef()

int Gia_KSatVarRef ( int * pMap,
int i )

Definition at line 1626 of file giaSatLut.c.

1626{ return pMap[i*KSAT_SPACE+3]; }
Here is the caller graph for this function:

◆ Gia_ManDeriveKSatMapping()

Gia_Man_t * Gia_ManDeriveKSatMapping ( Vec_Int_t * vRes,
int * pMap,
int nIns,
int nNodes,
int fVerbose )

Definition at line 1992 of file giaSatLut.c.

1993{
1994 Vec_Int_t * vGuide = Vec_IntStart( 1000 );
1995 Gia_Man_t * pNew = Gia_ManStart( nIns + nNodes + 2 );
1996 pNew->pName = Abc_UtilStrsav( "test" );
1997 int i, nSave = 0, pCopy[256] = {0};
1998 for ( i = 1; i <= nIns; i++ )
1999 pCopy[i] = Gia_ManAppendCi( pNew );
2000 for ( i = nIns; i < nIns+nNodes; i++ ) {
2001 int iFan0 = Gia_KSatFindFan( pMap, i, 0, vRes );
2002 int iFan1 = Gia_KSatFindFan( pMap, i, 1, vRes );
2003 if ( iFan0 == iFan1 )
2004 pCopy[i+1] = pCopy[iFan0+1];
2005 else if ( Gia_KSatValAnd(pMap, i, vRes) )
2006 pCopy[i+1] = Gia_ManAppendAnd( pNew, pCopy[iFan0+1], pCopy[iFan1+1] );
2007 else
2008 pCopy[i+1] = Gia_ManAppendOr( pNew, pCopy[iFan0+1], pCopy[iFan1+1] );
2009 pCopy[i+1] = Abc_LitNotCond( pCopy[i+1], Gia_KSatValInv(pMap, i, vRes) );
2010 if ( iFan0 == iFan1 )
2011 *Vec_IntEntryP(vGuide, Abc_Lit2Var(pCopy[i+1])) ^= 1;
2012 else if ( Gia_KSatValAnd(pMap, i, vRes) )
2013 *Vec_IntEntryP(vGuide, Abc_Lit2Var(pCopy[i+1])) ^= 4 | (2*Gia_KSatValInv(pMap, i, vRes));
2014 else
2015 *Vec_IntEntryP(vGuide, Abc_Lit2Var(pCopy[i+1])) ^= 8 | (2*Gia_KSatValInv(pMap, i, vRes));
2016 if ( fVerbose ) {
2017 if ( i == nIns+nNodes-1 )
2018 printf( " F = " );
2019 else
2020 printf( "%2d = ", i );
2021 if ( iFan0 == iFan1 )
2022 printf( "INV( %d )\n", iFan0 );
2023 else if ( Gia_KSatValAnd(pMap, i, vRes) )
2024 printf( "%sAND( %d, %d )\n", Gia_KSatValInv(pMap, i, vRes) ? "N":"", iFan0, iFan1 );
2025 else
2026 printf( "%sOR( %d, %d )\n", Gia_KSatValInv(pMap, i, vRes) ? "N":"", iFan0, iFan1 );
2027 nSave += (iFan0 == iFan1) || !Gia_KSatValInv(pMap, i, vRes);
2028 if ( i == nIns+nNodes-1 )
2029 printf( "Solution cost = %d\n", 2*(2*nNodes - nSave) );
2030 }
2031 }
2032 Gia_ManAppendCo( pNew, pCopy[nIns+nNodes] );
2033 //pNew->vCellMapping = Gia_ManDeriveKSatMappingArray( pNew, vGuide );
2034 Vec_IntFree( vGuide );
2035 return pNew;
2036}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
int Gia_KSatValAnd(int *pMap, int i, Vec_Int_t *vRes)
Definition giaSatLut.c:1638
int Gia_KSatFindFan(int *pMap, int i, int f, Vec_Int_t *vRes)
Definition giaSatLut.c:1676
int Gia_KSatValInv(int *pMap, int i, Vec_Int_t *vRes)
Definition giaSatLut.c:1637
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
char * pName
Definition gia.h:99
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDeriveKSatMappingArray()

Vec_Int_t * Gia_ManDeriveKSatMappingArray ( Gia_Man_t * p,
Vec_Int_t * vRes )

Definition at line 1924 of file giaSatLut.c.

1925{
1926 Vec_Int_t * vMapping = Vec_IntStart( 2*Gia_ManObjNum(p) );
1927 int i, Id; Gia_Obj_t * pObj;
1928 Gia_ManForEachCiId( p, Id, i )
1929 if ( Vec_IntEntry(vRes, Id) )
1930 Vec_IntWriteEntry( vMapping, Abc_Var2Lit(Id, 1), -1 );
1931 Gia_ManForEachAnd( p, pObj, i ) {
1932 assert( Vec_IntEntry(vRes, i) > 0 );
1933 if ( (Vec_IntEntry(vRes, i) & 2) == 0 ) {
1934 assert( (Vec_IntEntry(vRes, i) & 1) == 0 );
1935 continue;
1936 }
1937 Gia_Obj_t * pFans[2] = { Gia_ObjFanin0(pObj), Gia_ObjFanin1(pObj) };
1938 int fComp = ((Vec_IntEntry(vRes, i) >> 2) & 1) != 0;
1939 int fFan0 = ((Vec_IntEntry(vRes, Gia_ObjFaninId0(pObj, i)) >> 1) & 1) == 0 && Gia_ObjIsAnd(pFans[0]);
1940 int fFan1 = ((Vec_IntEntry(vRes, Gia_ObjFaninId1(pObj, i)) >> 1) & 1) == 0 && Gia_ObjIsAnd(pFans[1]);
1941 if ( Vec_IntEntry(vRes, i) & 1 )
1942 Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, !fComp), -1 );
1943 Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, fComp), Vec_IntSize(vMapping) );
1944 if ( fFan0 && fFan1 ) {
1945 Vec_IntPush( vMapping, 4 );
1946 if ( !Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) ) {
1947 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pFans[1]), !(fComp ^ Gia_ObjFaninC1(pObj) ^ Gia_ObjFaninC0(pFans[1]))) );
1948 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pFans[1]), !(fComp ^ Gia_ObjFaninC1(pObj) ^ Gia_ObjFaninC1(pFans[1]))) );
1949 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pFans[0]), !(fComp ^ Gia_ObjFaninC0(pObj) ^ Gia_ObjFaninC0(pFans[0]))) );
1950 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pFans[0]), !(fComp ^ Gia_ObjFaninC0(pObj) ^ Gia_ObjFaninC1(pFans[0]))) );
1951 }
1952 else {
1953 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pFans[0]), !(fComp ^ Gia_ObjFaninC0(pObj) ^ Gia_ObjFaninC0(pFans[0]))) );
1954 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pFans[0]), !(fComp ^ Gia_ObjFaninC0(pObj) ^ Gia_ObjFaninC1(pFans[0]))) );
1955 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pFans[1]), !(fComp ^ Gia_ObjFaninC1(pObj) ^ Gia_ObjFaninC0(pFans[1]))) );
1956 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pFans[1]), !(fComp ^ Gia_ObjFaninC1(pObj) ^ Gia_ObjFaninC1(pFans[1]))) );
1957 }
1958 if ( Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) )
1959 Vec_IntPush( vMapping, fComp ? GIA_GATE2_OAI22 : GIA_GATE2_AOI22 );
1960 else if ( !Gia_ObjFaninC0(pObj) && !Gia_ObjFaninC1(pObj) )
1961 Vec_IntPush( vMapping, fComp ? GIA_GATE2_NAN4 : GIA_GATE2_NOR4 );
1962 else
1963 Vec_IntPush( vMapping, fComp ? GIA_GATE2_OAI211 : GIA_GATE2_AOI211 );
1964 } else if ( fFan0 ) {
1965 Vec_IntPush( vMapping, 3 );
1966 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pFans[0]), !(fComp ^ Gia_ObjFaninC0(pObj) ^ Gia_ObjFaninC0(pFans[0]))) );
1967 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pFans[0]), !(fComp ^ Gia_ObjFaninC0(pObj) ^ Gia_ObjFaninC1(pFans[0]))) );
1968 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pObj), !(fComp ^ Gia_ObjFaninC1(pObj))) );
1969 if ( Gia_ObjFaninC0(pObj) )
1970 Vec_IntPush( vMapping, fComp ? GIA_GATE2_OAI21 : GIA_GATE2_AOI21 );
1971 else
1972 Vec_IntPush( vMapping, fComp ? GIA_GATE2_NAN3 : GIA_GATE2_NOR3 );
1973 } else if ( fFan1 ) {
1974 Vec_IntPush( vMapping, 3 );
1975 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pFans[1]), !(fComp ^ Gia_ObjFaninC1(pObj) ^ Gia_ObjFaninC0(pFans[1]))) );
1976 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pFans[1]), !(fComp ^ Gia_ObjFaninC1(pObj) ^ Gia_ObjFaninC1(pFans[1]))) );
1977 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pObj), !(fComp ^ Gia_ObjFaninC0(pObj))) );
1978 if ( Gia_ObjFaninC1(pObj) )
1979 Vec_IntPush( vMapping, fComp ? GIA_GATE2_OAI21 : GIA_GATE2_AOI21 );
1980 else
1981 Vec_IntPush( vMapping, fComp ? GIA_GATE2_NAN3 : GIA_GATE2_NOR3 );
1982 } else {
1983 Vec_IntPush( vMapping, 2 );
1984 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pObj), !(fComp ^ Gia_ObjFaninC0(pObj))) );
1985 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pObj), !(fComp ^ Gia_ObjFaninC1(pObj))) );
1986 Vec_IntPush( vMapping, fComp ? GIA_GATE2_NAN2 : GIA_GATE2_NOR2 );
1987 }
1988 }
1989 return vMapping;
1990}
Cube * p
Definition exorList.c:222
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_ManForEachCiId(p, Id, i)
Definition gia.h:1230

◆ Gia_ManDeriveSimpleMapping()

Vec_Int_t * Gia_ManDeriveSimpleMapping ( Gia_Man_t * p,
Vec_Int_t * vRes )

Definition at line 1459 of file giaSatLut.c.

1460{
1461 Vec_Int_t * vMapping = Vec_IntStart( 2*Gia_ManObjNum(p) );
1462 int i, Id; Gia_Obj_t * pObj;
1463 Gia_ManForEachCiId( p, Id, i )
1464 if ( Gia_SatValReqNeg(vRes, Id) )
1465 Vec_IntWriteEntry( vMapping, Abc_Var2Lit(Id, 1), -1 );
1466 Gia_ManForEachAnd( p, pObj, i )
1467 {
1468 if ( Gia_SatValAckPos(vRes, i) + Gia_SatValAckNeg(vRes, i) == 0 )
1469 continue;
1470 assert( Gia_SatValAckPos(vRes, i) != Gia_SatValAckNeg(vRes, i) );
1471 if ( (Gia_SatValReqPos(vRes, i) && Gia_SatValReqNeg(vRes, i)) || Gia_SatValInv(vRes, i) )
1472 Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, Gia_SatValAckPos(vRes, i)), -1 );
1473 int fComp = Gia_SatValAckNeg(vRes, i);
1474 int fFan0 = Gia_SatValFan0(vRes, i);
1475 int fFan1 = Gia_SatValFan1(vRes, i);
1476 Gia_Obj_t * pFans[2] = { Gia_ObjFanin0(pObj), Gia_ObjFanin1(pObj) };
1477 Vec_IntWriteEntry( vMapping, Abc_Var2Lit(i, fComp), Vec_IntSize(vMapping) );
1478 if ( fFan0 && fFan1 ) {
1479 assert( Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) );
1480 Vec_IntPush( vMapping, 4 );
1481 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pFans[0]), !(fComp ^ Gia_ObjFaninC0(pObj) ^ Gia_ObjFaninC0(pFans[0]))) );
1482 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pFans[0]), !(fComp ^ Gia_ObjFaninC0(pObj) ^ Gia_ObjFaninC1(pFans[0]))) );
1483 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pFans[1]), !(fComp ^ Gia_ObjFaninC1(pObj) ^ Gia_ObjFaninC0(pFans[1]))) );
1484 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pFans[1]), !(fComp ^ Gia_ObjFaninC1(pObj) ^ Gia_ObjFaninC1(pFans[1]))) );
1485 Vec_IntPush( vMapping, fComp ? GIA_GATE_OAI22 : GIA_GATE_AOI22 );
1486 } else if ( fFan0 ) {
1487 Vec_IntPush( vMapping, 3 );
1488 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pFans[0]), !(fComp ^ Gia_ObjFaninC0(pObj) ^ Gia_ObjFaninC0(pFans[0]))) );
1489 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pFans[0]), !(fComp ^ Gia_ObjFaninC0(pObj) ^ Gia_ObjFaninC1(pFans[0]))) );
1490 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pObj), !(fComp ^ Gia_ObjFaninC1(pObj))) );
1491 if ( Gia_ObjFaninC0(pObj) )
1492 Vec_IntPush( vMapping, fComp ? GIA_GATE_OAI21 : GIA_GATE_AOI21 );
1493 else
1494 Vec_IntPush( vMapping, fComp ? GIA_GATE_NAN3 : GIA_GATE_NOR3 );
1495 } else if ( fFan1 ) {
1496 Vec_IntPush( vMapping, 3 );
1497 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pFans[1]), !(fComp ^ Gia_ObjFaninC1(pObj) ^ Gia_ObjFaninC0(pFans[1]))) );
1498 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pFans[1]), !(fComp ^ Gia_ObjFaninC1(pObj) ^ Gia_ObjFaninC1(pFans[1]))) );
1499 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pObj), !(fComp ^ Gia_ObjFaninC0(pObj))) );
1500 if ( Gia_ObjFaninC1(pObj) )
1501 Vec_IntPush( vMapping, fComp ? GIA_GATE_OAI21 : GIA_GATE_AOI21 );
1502 else
1503 Vec_IntPush( vMapping, fComp ? GIA_GATE_NAN3 : GIA_GATE_NOR3 );
1504 } else {
1505 Vec_IntPush( vMapping, 2 );
1506 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId0p(p, pObj), !(fComp ^ Gia_ObjFaninC0(pObj))) );
1507 Vec_IntPush( vMapping, Abc_Var2Lit(Gia_ObjFaninId1p(p, pObj), !(fComp ^ Gia_ObjFaninC1(pObj))) );
1508 Vec_IntPush( vMapping, fComp ? GIA_GATE_NAN2 : GIA_GATE_NOR2 );
1509 }
1510 }
1511 return vMapping;
1512}
int Gia_SatValReqPos(Vec_Int_t *p, int i)
Definition giaSatLut.c:1308
int Gia_SatValAckPos(Vec_Int_t *p, int i)
Definition giaSatLut.c:1310
int Gia_SatValReqNeg(Vec_Int_t *p, int i)
Definition giaSatLut.c:1309
int Gia_SatValFan0(Vec_Int_t *p, int i)
Definition giaSatLut.c:1313
int Gia_SatValInv(Vec_Int_t *p, int i)
Definition giaSatLut.c:1312
int Gia_SatValFan1(Vec_Int_t *p, int i)
Definition giaSatLut.c:1314
int Gia_SatValAckNeg(Vec_Int_t *p, int i)
Definition giaSatLut.c:1311
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManDumpCnf()

int Gia_ManDumpCnf ( char * pFileName,
Vec_Str_t * vStr,
int nVars )

Definition at line 1536 of file giaSatLut.c.

1537{
1538 FILE * pFile = fopen( pFileName, "wb" );
1539 if ( pFile == NULL ) { printf( "Cannot open input file \"%s\".\n", pFileName ); return 0; }
1540 fprintf( pFile, "p knf %d %d\n%s\n", nVars, Vec_StrCountEntry(vStr, '\n'), Vec_StrArray(vStr) );
1541 fclose( pFile );
1542 return 1;
1543}
Here is the caller graph for this function:

◆ Gia_ManDumpCnf2()

int Gia_ManDumpCnf2 ( Vec_Str_t * vStr,
int nVars,
int argc,
char ** argv,
abctime Time,
int Status )

Definition at line 1544 of file giaSatLut.c.

1545{
1546 Vec_Str_t * vFileName = Vec_StrAlloc( 100 ); int c;
1547 Vec_StrPrintF( vFileName, "%s", argv[0] + (argv[0][0] == '&') );
1548 for ( c = 1; c < argc; c++ )
1549 Vec_StrPrintF( vFileName, "_%s", argv[c] + (argv[c][0] == '-') );
1550 Vec_StrPrintF( vFileName, ".cnf" );
1551 Vec_StrPush( vFileName, '\0' );
1552 FILE * pFile = fopen( Vec_StrArray(vFileName), "wb" );
1553 if ( pFile == NULL ) { printf( "Cannot open output file \"%s\".\n", Vec_StrArray(vFileName) ); Vec_StrFree(vFileName); return 0; }
1554 Vec_StrFree(vFileName);
1555 fprintf( pFile, "c This file was generated by ABC command: \"" );
1556 fprintf( pFile, "%s", argv[0] );
1557 for ( c = 1; c < argc; c++ )
1558 fprintf( pFile, " %s", argv[c] );
1559 fprintf( pFile, "\" on %s\n", Gia_TimeStamp() );
1560 fprintf( pFile, "c Cardinality CDCL (https://github.com/jreeves3/Cardinality-CDCL) found it to be " );
1561 if ( Status == 1 )
1562 fprintf( pFile, "UNSAT" );
1563 if ( Status == 0 )
1564 fprintf( pFile, "SAT" );
1565 if ( Status == -1 )
1566 fprintf( pFile, "UNDECIDED" );
1567 fprintf( pFile, " in %.2f sec\n", 1.0*((double)(Time))/((double)CLOCKS_PER_SEC) );
1568 fprintf( pFile, "p knf %d %d\n%s\n", nVars, Vec_StrCountEntry(vStr, '\n'), Vec_StrArray(vStr) );
1569 fclose( pFile );
1570 return 1;
1571}
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
char * Gia_TimeStamp()
Definition giaUtil.c:106
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManGetTruth()

word Gia_ManGetTruth ( Gia_Man_t * p)

Definition at line 2038 of file giaSatLut.c.

2039{
2040 Gia_Obj_t * pObj; int i, Id;
2041 word pFuncs[256] = {0}, Const[2] = {0, ~(word)0};
2042 assert( Gia_ManObjNum(p) <= 256 );
2043 Gia_ManForEachCiId( p, Id, i )
2044 pFuncs[Id] = s_Truths6[i];
2045 Gia_ManForEachAnd( p, pObj, i )
2046 pFuncs[i] = (Const[Gia_ObjFaninC0(pObj)] ^ pFuncs[Gia_ObjFaninId0(pObj, i)]) & (Const[Gia_ObjFaninC1(pObj)] ^ pFuncs[Gia_ObjFaninId1(pObj, i)]);
2047 pObj = Gia_ManCo(p, 0);
2048 return Const[Gia_ObjFaninC0(pObj)] ^ pFuncs[Gia_ObjFaninId0p(p, pObj)];
2049}
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
Here is the caller graph for this function:

◆ Gia_ManKSatCnf()

Vec_Str_t * Gia_ManKSatCnf ( int * pMap,
int nIns,
int nNodes,
int nBound,
int fMultiLevel,
char * pGuide )

Definition at line 1715 of file giaSatLut.c.

1716{
1717 Vec_Str_t * vStr = Vec_StrAlloc( 10000 );
1718 Vec_Int_t * vRes = pGuide ? Gia_ManKSatGenLevels( pGuide, nIns, nNodes ) : NULL;
1719 int i, j, m, n, f, c, a, Start, Stop, nLits = 0, pLits[256] = {0};
1720 Gia_SatDumpLiteral( vStr, 1 );
1721 Gia_SatDumpLiteral( vStr, 2 );
1722 if ( vRes ) {
1723 n = nIns;
1724 Vec_IntForEachEntryDoubleStart( vRes, Start, Stop, i, 2*nIns ) {
1725 for ( j = 0; j < Start; j++ )
1726 Gia_SatDumpLiteral( vStr, Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 1, j), 1 ) );
1727 for ( f = 0; f < 2; f++ )
1728 for ( j = Stop; j < n; j++ )
1729 Gia_SatDumpLiteral( vStr, Abc_Var2Lit( Gia_KSatVarFan(pMap, n, f, j), 1 ) );
1730 n++;
1731 }
1732 assert( n == nIns + nNodes );
1733 }
1734 // fanins are connected once
1735 for ( n = nIns; n < nIns+nNodes; n++ )
1736 for ( f = 0; f < 2; f++ ) {
1737
1738 nLits = 0;
1739 for ( i = 0; i < n; i++ )
1740 pLits[nLits++] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, f, i), 0 );
1741 Gia_SatDumpClause( vStr, pLits, nLits );
1742/*
1743 for ( i = 0; i < n; i++ )
1744 for ( j = 0; j < i; j++ ) {
1745 pLits[0] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, f, i), 1 );
1746 pLits[1] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, f, j), 1 );
1747 Gia_SatDumpClause( vStr, pLits, 2 );
1748 }
1749*/
1750 Vec_StrPrintF( vStr, "k %d ", n-1 );
1751 for ( i = 0; i < n; i++ )
1752 pLits[i] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, f, i), 1 );
1753 Gia_SatDumpClause( vStr, pLits, n );
1754 }
1755 for ( n = nIns; n < nIns+nNodes; n++ ) {
1756 // fanins are equal
1757 for ( i = 0; i < n; i++ ) {
1758 pLits[0] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 0, i), 1 );
1759 pLits[1] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 1, i), 1 );
1760 pLits[2] = Abc_Var2Lit( Gia_KSatVarEqu(pMap, n), 0 );
1761 Gia_SatDumpClause( vStr, pLits, 3 );
1762 }
1763 for ( i = 0; i < n; i++ )
1764 for ( j = i+1; j < n; j++ ) {
1765 pLits[0] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 0, i), 1 );
1766 pLits[1] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 1, j), 1 );
1767 pLits[2] = Abc_Var2Lit( Gia_KSatVarEqu(pMap, n), 1 );
1768 Gia_SatDumpClause( vStr, pLits, 3 );
1769 }
1770 // if fanins are equal, inv is used
1771 pLits[0] = Abc_Var2Lit( Gia_KSatVarEqu(pMap, n), 1 );
1772 pLits[1] = Abc_Var2Lit( Gia_KSatVarInv(pMap, n), 0 );
1773 Gia_SatDumpClause( vStr, pLits, 2 );
1774 // fanin ordering
1775 for ( i = 0; i < n; i++ )
1776 for ( j = 0; j < i; j++ ) {
1777 pLits[0] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 0, i), 1 );
1778 pLits[1] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 1, j), 1 );
1779 Gia_SatDumpClause( vStr, pLits, 2 );
1780 }
1781 }
1782 for ( n = nIns; n < nIns+nNodes-1; n++ ) {
1783 // there is a fanout to the node above
1784 for ( i = n+1; i < nIns+nNodes; i++ ) {
1785 for ( f = 0; f < 2; f++ ) {
1786 pLits[0] = Abc_Var2Lit( Gia_KSatVarFan(pMap, i, f, n), 1 );
1787 pLits[1] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 2, i), 0 );
1788 Gia_SatDumpClause( vStr, pLits, 2 );
1789 }
1790 pLits[0] = Abc_Var2Lit( Gia_KSatVarFan(pMap, i, 0, n), 0 );
1791 pLits[1] = Abc_Var2Lit( Gia_KSatVarFan(pMap, i, 1, n), 0 );
1792 pLits[2] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 2, i), 1 );
1793 Gia_SatDumpClause( vStr, pLits, 3 );
1794 }
1795 // there is at least one fanout, except the last one
1796 nLits = 0;
1797 for ( i = n+1; i < nIns+nNodes; i++ )
1798 pLits[nLits++] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 2, i), 0 );
1799 assert( nLits > 0 );
1800 Gia_SatDumpClause( vStr, pLits, nLits );
1801 }
1802 // there is more than one fanout, except the last one
1803 for ( n = nIns; n < nIns+nNodes-1; n++ ) {
1804 for ( i = n+1; i < nIns+nNodes; i++ )
1805 for ( j = i+1; j < nIns+nNodes; j++ ) {
1806 pLits[0] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 2, i), 1 );
1807 pLits[1] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 2, j), 1 );
1808 pLits[2] = Abc_Var2Lit( Gia_KSatVarRef(pMap, n), 0 );
1809 Gia_SatDumpClause( vStr, pLits, 3 );
1810 }
1811 // if more than one fanout, inv is used
1812 pLits[0] = Abc_Var2Lit( Gia_KSatVarRef(pMap, n), 1 );
1813 pLits[1] = Abc_Var2Lit( Gia_KSatVarInv(pMap, n), 0 );
1814 Gia_SatDumpClause( vStr, pLits, 2 );
1815 // if inv is not used, its fanins' invs are used
1816 if ( !fMultiLevel ) {
1817 pLits[0] = Abc_Var2Lit( Gia_KSatVarInv(pMap, n), 0 );
1818 for ( i = nIns; i < n; i++ )
1819 for ( f = 0; f < 2; f++ ) {
1820 pLits[1] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, f, i), 1 );
1821 pLits[2] = Abc_Var2Lit( Gia_KSatVarInv(pMap, i), 0 );
1822 Gia_SatDumpClause( vStr, pLits, 3 );
1823 }
1824 }
1825 }
1826 // the last one always uses inverter
1827 Gia_SatDumpLiteral( vStr, Abc_Var2Lit( Gia_KSatVarInv(pMap, nIns+nNodes-1), 0 ) );
1828/*
1829 // for each minterm, for each pair of possible fanins, the node's output is determined using and/or and inv (4*N*N*M)
1830 for ( m = 0; m < (1 << nIns); m++ )
1831 for ( n = nIns; n < nIns+nNodes; n++ )
1832 for ( c = 0; c < 2; c++ )
1833 for ( a = 0; a < 2; a++ ) {
1834 // implications: Fan(f) & Mint(m) & !And & !Inv -> Val1
1835 for ( f = 0; f < 2; f++ )
1836 for ( i = 0; i < n; i++ ) {
1837 pLits[0] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, f, i), 1 );
1838 pLits[1] = Abc_Var2Lit( Gia_KSatVarMin(pMap, i, m, 0), !a );
1839 pLits[2] = Abc_Var2Lit( Gia_KSatVarAnd(pMap, n), a );
1840 pLits[3] = Abc_Var2Lit( Gia_KSatVarInv(pMap, n), c );
1841 pLits[4] = Abc_Var2Lit( Gia_KSatVarMin(pMap, n, m, 0), a^c );
1842 Gia_SatDumpClause( vStr, pLits, 5 );
1843 }
1844 // large clauses: Fan(0) & Fan(1) & !Mint(m) & !Mint(m) & !And & !Inv -> Val0
1845 for ( i = 0; i < n; i++ )
1846 for ( j = i; j < n; j++ ) {
1847 pLits[0] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 0, i), 1 );
1848 pLits[1] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, 1, j), 1 );
1849 pLits[2] = Abc_Var2Lit( Gia_KSatVarMin(pMap, i, m, 0), a );
1850 pLits[3] = Abc_Var2Lit( Gia_KSatVarMin(pMap, j, m, 0), a );
1851 pLits[4] = Abc_Var2Lit( Gia_KSatVarAnd(pMap, n), a );
1852 pLits[5] = Abc_Var2Lit( Gia_KSatVarInv(pMap, n), c );
1853 pLits[6] = Abc_Var2Lit( Gia_KSatVarMin(pMap, n, m, 0), a==c );
1854 Gia_SatDumpClause( vStr, pLits, 7 );
1855 }
1856 }
1857*/
1858 // for each minterm, define a fanin variable and use it to get the node's output based on and/or and inv (4*N*N*M)
1859 for ( m = 0; m < (1 << nIns); m++ )
1860 for ( n = nIns; n < nIns+nNodes; n++ ) {
1861 for ( i = 0; i < n; i++ )
1862 for ( f = 0; f < 2; f++ )
1863 for ( c = 0; c < 2; c++ ) {
1864 pLits[0] = Abc_Var2Lit( Gia_KSatVarFan(pMap, n, f, i), 1 );
1865 pLits[1] = Abc_Var2Lit( Gia_KSatVarMin(pMap, i, m, 0), c );
1866 pLits[2] = Abc_Var2Lit( Gia_KSatVarMin(pMap, n, m, 1+f), !c );
1867 Gia_SatDumpClause( vStr, pLits, 3 );
1868 }
1869 for ( c = 0; c < 2; c++ )
1870 for ( a = 0; a < 2; a++ ) {
1871 // implications: Mint(m,f) & !And & !Inv -> Val1
1872 for ( f = 0; f < 2; f++ ) {
1873 pLits[0] = Abc_Var2Lit( Gia_KSatVarMin(pMap, n, m, 1+f), !a );
1874 pLits[1] = Abc_Var2Lit( Gia_KSatVarAnd(pMap, n), a );
1875 pLits[2] = Abc_Var2Lit( Gia_KSatVarInv(pMap, n), c );
1876 pLits[3] = Abc_Var2Lit( Gia_KSatVarMin(pMap, n, m, 0), a^c );
1877 Gia_SatDumpClause( vStr, pLits, 4 );
1878 }
1879 // large clauses: !Mint(m,0) & !Mint(m,1) & !And & !Inv -> Val0
1880 pLits[0] = Abc_Var2Lit( Gia_KSatVarMin(pMap, n, m, 1), a );
1881 pLits[1] = Abc_Var2Lit( Gia_KSatVarMin(pMap, n, m, 2), a );
1882 pLits[2] = Abc_Var2Lit( Gia_KSatVarAnd(pMap, n), a );
1883 pLits[3] = Abc_Var2Lit( Gia_KSatVarInv(pMap, n), c );
1884 pLits[4] = Abc_Var2Lit( Gia_KSatVarMin(pMap, n, m, 0), a==c );
1885 Gia_SatDumpClause( vStr, pLits, 5 );
1886 }
1887 }
1888 // the number of nodes with duplicated fanins and without inv is maximized
1889 if ( nBound && 2*nNodes > nBound ) {
1890 Vec_StrPrintF( vStr, "k %d ", 2*nNodes-nBound );
1891 nLits = 0;
1892 for ( n = nIns; n < nIns+nNodes; n++ ) {
1893 pLits[nLits++] = Abc_Var2Lit(Gia_KSatVarEqu(pMap, n), 0);
1894 pLits[nLits++] = Abc_Var2Lit(Gia_KSatVarInv(pMap, n), 1);
1895 }
1896 Gia_SatDumpClause( vStr, pLits, nLits );
1897 }
1898 Vec_StrPush( vStr, '\0' );
1899 Vec_IntFreeP( &vRes );
1900 return vStr;
1901}
int Gia_KSatVarEqu(int *pMap, int i)
Definition giaSatLut.c:1625
void Gia_SatDumpLiteral(Vec_Str_t *vStr, int Lit)
Definition giaSatLut.c:1322
int Gia_KSatVarMin(int *pMap, int i, int m, int k)
Definition giaSatLut.c:1628
Vec_Int_t * Gia_ManKSatGenLevels(char *pGuide, int nIns, int nNodes)
Definition giaSatLut.c:1686
int Gia_KSatVarRef(int *pMap, int i)
Definition giaSatLut.c:1626
int Gia_KSatVarFan(int *pMap, int i, int f, int k)
Definition giaSatLut.c:1627
int Gia_KSatVarAnd(int *pMap, int i)
Definition giaSatLut.c:1624
int Gia_KSatVarInv(int *pMap, int i)
Definition giaSatLut.c:1623
void Gia_SatDumpClause(Vec_Str_t *vStr, int *pLits, int nLits)
Definition giaSatLut.c:1316
#define Vec_IntForEachEntryDoubleStart(vVec, Entry1, Entry2, i, Start)
Definition vecInt.h:74
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManKSatGenLevels()

Vec_Int_t * Gia_ManKSatGenLevels ( char * pGuide,
int nIns,
int nNodes )

Definition at line 1686 of file giaSatLut.c.

1687{
1688 Vec_Int_t * vRes;
1689 int i, k, Count = 0;
1690 for ( i = 0; pGuide[i]; i++ )
1691 Count += pGuide[i] - '0';
1692 if ( Count != nNodes ) {
1693 printf( "Guidance %s has %d nodes while the problem has %d nodes.\n", pGuide, Count, nNodes );
1694 return NULL;
1695 }
1696 int FirstPrev = 0;
1697 int FirstThis = nIns;
1698 int FirstNext = FirstThis;
1699 vRes = Vec_IntStartFull( 2*nIns );
1700 for ( i = 0; pGuide[i]; i++ ) {
1701 FirstNext += pGuide[i] - '0';
1702 for ( k = FirstThis; k < FirstNext; k++ )
1703 Vec_IntPushTwo( vRes, FirstPrev, FirstThis );
1704 FirstPrev = FirstThis;
1705 FirstThis = FirstNext;
1706 }
1707 assert( Vec_IntSize(vRes) == 2*(nIns + nNodes) );
1708 Count = 0;
1709 //int Start, Stop;
1710 //Vec_IntForEachEntryDouble(vRes, Start, Stop, i)
1711 // printf( "%2d : Start %2d Stop %2d\n", Count++, Start, Stop );
1712 return vRes;
1713}
Here is the caller graph for this function:

◆ Gia_ManKSatMapping()

Gia_Man_t * Gia_ManKSatMapping ( word Truth,
int nIns,
int nNodes,
int nBound,
int Seed,
int fMultiLevel,
int nBTLimit,
int nTimeout,
int fVerbose,
int fKeepFile,
int argc,
char ** argv,
char * pGuide )

Definition at line 2051 of file giaSatLut.c.

2052{
2053 abctime clkStart = Abc_Clock();
2054 Gia_Man_t * pNew = NULL;
2055 srand(time(NULL));
2056 int Status, Rand = ((((unsigned)rand()) << 12) ^ ((unsigned)rand())) & 0xFFFFFF;
2057 char pFileNameI[32]; sprintf( pFileNameI, "_%06x_.cnf", Rand );
2058 char pFileNameO[32]; sprintf( pFileNameO, "_%06x_.out", Rand );
2059 int nVars = 0, * pMap = Gia_KSatMapInit( nIns, nNodes, Truth, &nVars );
2060 Vec_Str_t * vStr = Gia_ManKSatCnf( pMap, nIns, nNodes, nBound/2, fMultiLevel, pGuide );
2061 if ( !Gia_ManDumpCnf(pFileNameI, vStr, nVars) ) {
2062 Vec_StrFree( vStr );
2063 return NULL;
2064 }
2065 if ( fVerbose )
2066 printf( "Vars = %d. Nodes = %d. Cardinality bound = %d. SAT vars = %d. SAT clauses = %d. Conflict limit = %d. Timeout = %d.\n",
2067 nIns, nNodes, nBound, nVars, Vec_StrCountEntry(vStr, '\n'), nBTLimit, nTimeout );
2068 Vec_Int_t * vRes = Gia_RunKadical( pFileNameI, pFileNameO, Seed, nBTLimit, nTimeout, 1, &Status );
2069 unlink( pFileNameI );
2070 //unlink( pFileNameO );
2071 if ( fKeepFile ) Gia_ManDumpCnf2( vStr, nVars, argc, argv, Abc_Clock() - clkStart, Status );
2072 Vec_StrFree( vStr );
2073 if ( vRes == NULL )
2074 return 0;
2075 Vec_IntDrop( vRes, 0 );
2076 pNew = Gia_ManDeriveKSatMapping( vRes, pMap, nIns, nNodes, fVerbose );
2077 printf( "Verification %s. ", Truth == Gia_ManGetTruth(pNew) ? "passed" : "failed" );
2078 Abc_PrintTime( 0, "Total time", Abc_Clock() - clkStart );
2079 Vec_IntFree( vRes );
2080 ABC_FREE( pMap );
2081 return pNew;
2082}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_FREE(obj)
Definition abc_global.h:267
int Gia_ManDumpCnf(char *pFileName, Vec_Str_t *vStr, int nVars)
Definition giaSatLut.c:1536
Vec_Str_t * Gia_ManKSatCnf(int *pMap, int nIns, int nNodes, int nBound, int fMultiLevel, char *pGuide)
Definition giaSatLut.c:1715
word Gia_ManGetTruth(Gia_Man_t *p)
Definition giaSatLut.c:2038
Gia_Man_t * Gia_ManDeriveKSatMapping(Vec_Int_t *vRes, int *pMap, int nIns, int nNodes, int fVerbose)
Definition giaSatLut.c:1992
Vec_Int_t * Gia_RunKadical(char *pFileNameIn, char *pFileNameOut, int Seed, int nBTLimit, int TimeOut, int fVerbose, int *pStatus)
Definition giaSatLut.c:1237
int Gia_ManDumpCnf2(Vec_Str_t *vStr, int nVars, int argc, char **argv, abctime Time, int Status)
Definition giaSatLut.c:1544
int * Gia_KSatMapInit(int nIns, int nNodes, word Truth, int *pnVars)
Definition giaSatLut.c:1644
char * sprintf()
Here is the call graph for this function:

◆ Gia_ManLutSat()

void Gia_ManLutSat ( Gia_Man_t * pGia,
int LutSize,
int nNumber,
int nImproves,
int nBTLimit,
int DelayMax,
int nEdges,
int fDelay,
int fReverse,
int fVerbose,
int fVeryVerbose )

Definition at line 1190 of file giaSatLut.c.

1191{
1192 int iLut, nImproveCount = 0;
1193 Sbl_Man_t * p = Sbl_ManAlloc( pGia, nNumber );
1194 p->LutSize = LutSize; // LUT size
1195 p->nBTLimit = nBTLimit; // conflicts
1196 p->DelayMax = DelayMax; // external delay
1197 p->nEdges = nEdges; // the number of edges
1198 p->fDelay = fDelay; // delay mode
1199 p->fReverse = fReverse; // reverse windowing
1200 p->fVerbose = fVerbose | fVeryVerbose;
1201 p->fVeryVerbose = fVeryVerbose;
1202 if ( p->fVerbose )
1203 printf( "Parameters: WinSize = %d AIG nodes. Conf = %d. DelayMax = %d.\n", p->nVars, p->nBTLimit, p->DelayMax );
1204 // determine delay limit
1205 if ( fDelay && pGia->vEdge1 && p->DelayMax == 0 )
1206 p->DelayMax = Gia_ManEvalEdgeDelay( pGia );
1207 // iterate through the internal nodes
1208 Gia_ManComputeOneWinStart( pGia, nNumber, fReverse );
1209 Gia_ManForEachLut2( pGia, iLut )
1210 {
1211 if ( Sbl_ManTestSat( p, iLut ) != 2 )
1212 continue;
1213 if ( ++nImproveCount == nImproves )
1214 break;
1215 }
1216 Gia_ManComputeOneWin( pGia, -1, NULL, NULL, NULL, NULL );
1217 if ( p->fVerbose )
1218 printf( "Tried = %d. Used = %d. HashWin = %d. SmallWin = %d. LargeWin = %d. IterOut = %d. SAT runs = %d.\n",
1219 p->nTried, p->nImproved, p->nHashWins, p->nSmallWins, p->nLargeWins, p->nIterOuts, p->nRuns );
1220 if ( p->fVerbose )
1222 Sbl_ManStop( p );
1223 Vec_IntFreeP( &pGia->vPacking );
1224}
typedefABC_NAMESPACE_IMPL_START struct Sbl_Man_t_ Sbl_Man_t
DECLARATIONS ///.
Definition giaSatLut.c:42
Sbl_Man_t * Sbl_ManAlloc(Gia_Man_t *pGia, int Number)
FUNCTION DEFINITIONS ///.
Definition giaSatLut.c:132
int Sbl_ManTestSat(Sbl_Man_t *p, int iPivot)
Definition giaSatLut.c:967
void Sbl_ManStop(Sbl_Man_t *p)
Definition giaSatLut.c:217
void Sbl_ManPrintRuntime(Sbl_Man_t *p)
Definition giaSatLut.c:1176
#define Gia_ManForEachLut2(p, i)
Definition gia.h:1168
int Gia_ManComputeOneWin(Gia_Man_t *p, int iPivot, Vec_Int_t **pvRoots, Vec_Int_t **pvNodes, Vec_Int_t **pvLeaves, Vec_Int_t **pvAnds)
Definition giaSplit.c:516
void Gia_ManComputeOneWinStart(Gia_Man_t *p, int nAnds, int fReverse)
Definition giaSplit.c:541
int Gia_ManEvalEdgeDelay(Gia_Man_t *p)
Definition giaEdge.c:201
Vec_Int_t * vPacking
Definition gia.h:141
Vec_Int_t * vEdge1
Definition gia.h:147
Here is the call graph for this function:

◆ Gia_ManSimpleCnf()

Vec_Str_t * Gia_ManSimpleCnf ( Gia_Man_t * p,
int nBound )

Definition at line 1339 of file giaSatLut.c.

1340{
1341 Vec_Str_t * vStr = Vec_StrAlloc( 10000 );
1342 Gia_SatDumpKlause( vStr, Gia_ManCiNum(p), Gia_ManAndNum(p), nBound );
1343 int i, n, m, Id, pLits[4]; Gia_Obj_t * pObj;
1344 for ( n = 0; n < 7; n++ )
1345 Gia_SatDumpLiteral( vStr, Abc_Var2Lit(n, 1) );
1346 // acknowledge positive PI literals
1347 Gia_ManForEachCiId( p, Id, i )
1348 for ( n = 0; n < 7; n++ ) if ( n != 1 )
1349 Gia_SatDumpLiteral( vStr, Abc_Var2Lit(Gia_SatVarReqPos(Id)+n, n>0) );
1350 // require driving PO literals
1351 Gia_ManForEachCo( p, pObj, i )
1352 Gia_SatDumpLiteral( vStr, Abc_Var2Lit( Gia_SatVarReqPos(Gia_ObjFaninId0p(p, pObj)) + Gia_ObjFaninC0(pObj), 0 ) );
1353 // internal nodes
1354 Gia_ManForEachAnd( p, pObj, i ) {
1355 int fCompl[2] = { Gia_ObjFaninC0(pObj), Gia_ObjFaninC1(pObj) };
1356 int iFans[2] = { Gia_ObjFaninId0(pObj, i), Gia_ObjFaninId1(pObj, i) };
1357 Gia_Obj_t * pFans[2] = { Gia_ObjFanin0(pObj), Gia_ObjFanin1(pObj) };
1358 // require inverter: p & !n & N -> i, n & !p & P -> i
1359 for ( n = 0; n < 2; n++ ) {
1360 pLits[0] = Abc_Var2Lit( Gia_SatVarReqPos(i)+n, 1 );
1361 pLits[1] = Abc_Var2Lit( Gia_SatVarReqNeg(i)-n, 0 );
1362 pLits[2] = Abc_Var2Lit( Gia_SatVarAckNeg(i)-n, 1 );
1363 pLits[3] = Abc_Var2Lit( Gia_SatVarInv (i), 0 );
1364 Gia_SatDumpClause( vStr, pLits, 4 );
1365 }
1366 // exclusive acknowledge: !P + !N
1367 pLits[0] = Abc_Var2Lit( Gia_SatVarAckPos(i), 1 );
1368 pLits[1] = Abc_Var2Lit( Gia_SatVarAckNeg(i), 1 );
1369 Gia_SatDumpClause( vStr, pLits, 2 );
1370 // required acknowledge: p -> P + N, n -> P + N
1371 pLits[1] = Abc_Var2Lit( Gia_SatVarAckPos(i), 0 );
1372 pLits[2] = Abc_Var2Lit( Gia_SatVarAckNeg(i), 0 );
1373 pLits[0] = Abc_Var2Lit( Gia_SatVarReqPos(i), 1 );
1374 Gia_SatDumpClause( vStr, pLits, 3 );
1375 pLits[0] = Abc_Var2Lit( Gia_SatVarReqNeg(i), 1 );
1376 Gia_SatDumpClause( vStr, pLits, 3 );
1377 // forbid acknowledge: !p & !n -> !P, !p & !n -> !N
1378 pLits[0] = Abc_Var2Lit( Gia_SatVarReqPos(i), 0 );
1379 pLits[1] = Abc_Var2Lit( Gia_SatVarReqNeg(i), 0 );
1380 pLits[2] = Abc_Var2Lit( Gia_SatVarAckPos(i), 1 );
1381 Gia_SatDumpClause( vStr, pLits, 3 );
1382 pLits[2] = Abc_Var2Lit( Gia_SatVarAckNeg(i), 1 );
1383 Gia_SatDumpClause( vStr, pLits, 3 );
1384 // when fanins can be used: !N & !P -> !0, !N & !P -> !1
1385 pLits[0] = Abc_Var2Lit( Gia_SatVarAckPos(i), 0 );
1386 pLits[1] = Abc_Var2Lit( Gia_SatVarAckNeg(i), 0 );
1387 pLits[2] = Abc_Var2Lit( Gia_SatVarFan0(i), 1 );
1388 Gia_SatDumpClause( vStr, pLits, 3 );
1389 pLits[2] = Abc_Var2Lit( Gia_SatVarFan1(i), 1 );
1390 Gia_SatDumpClause( vStr, pLits, 3 );
1391 // when fanins are not used: 0 -> !N, 0 -> !P, 1 -> !N, 1 -> !P
1392 for ( m = 0; m < 2; m++ )
1393 for ( n = 0; n < 2; n++ ) {
1394 pLits[0] = Abc_Var2Lit( Gia_SatVarFan0(i)+n, 1 );
1395 pLits[1] = Abc_Var2Lit( Gia_SatVarReqPos(iFans[n])+m, 1 );
1396 Gia_SatDumpClause( vStr, pLits, 2 );
1397 }
1398 // can only extend both when both complemented: !(C0 & C1) -> !0 + !1
1399 pLits[0] = Abc_Var2Lit( Gia_SatVarFan0(i), 1 );
1400 pLits[1] = Abc_Var2Lit( Gia_SatVarFan1(i), 1 );
1401 if ( !fCompl[0] || !fCompl[1] )
1402 Gia_SatDumpClause( vStr, pLits, 2 );
1403 // if fanin is a primary input, cannot extend it (pi -> !0 or pi -> !1)
1404 for ( n = 0; n < 2; n++ )
1405 if ( Gia_ObjIsCi(pFans[n]) )
1406 Gia_SatDumpLiteral( vStr, Abc_Var2Lit( Gia_SatVarFan0(i)+n, 1 ) );
1407 // propagating assignments when fanin is not used
1408 // P & !0 -> C0 ? P0 : N0
1409 // N & !0 -> C0 ? N0 : P0
1410 // P & !1 -> C1 ? P1 : N1
1411 // N & !1 -> C1 ? N1 : P1
1412 for ( m = 0; m < 2; m++ )
1413 for ( n = 0; n < 2; n++ ) {
1414 pLits[0] = Abc_Var2Lit( Gia_SatVarAckPos(i)+m, 1 );
1415 pLits[1] = Abc_Var2Lit( Gia_SatVarFan0(i)+n, 0 );
1416 pLits[2] = Abc_Var2Lit( Gia_SatVarReqPos(iFans[n]) + !(m ^ fCompl[n]), 0 );
1417 Gia_SatDumpClause( vStr, pLits, 3 );
1418 }
1419 // propagating assignments when fanins are used
1420 // P & 0 -> (C0 ^ C00) ? P00 : N00
1421 // P & 0 -> (C0 ^ C01) ? P01 : N01
1422 // N & 0 -> (C0 ^ C00) ? N00 : P00
1423 // N & 0 -> (C0 ^ C01) ? N01 : P01
1424 // P & 1 -> (C1 ^ C10) ? P10 : N10
1425 // P & 1 -> (C1 ^ C11) ? P11 : N11
1426 // N & 1 -> (C1 ^ C10) ? N10 : P10
1427 // N & 1 -> (C1 ^ C11) ? N11 : P11
1428 for ( m = 0; m < 2; m++ )
1429 for ( n = 0; n < 2; n++ )
1430 if ( Gia_ObjIsAnd(pFans[n]) ) {
1431 pLits[0] = Abc_Var2Lit( Gia_SatVarAckPos(i)+m, 1 );
1432 pLits[1] = Abc_Var2Lit( Gia_SatVarFan0(i)+n, 1 );
1433 pLits[2] = Abc_Var2Lit( Gia_SatVarReqPos(Gia_ObjFaninId0p(p, pFans[n])) + !(m ^ fCompl[n] ^ Gia_ObjFaninC0(pFans[n])), 0 );
1434 Gia_SatDumpClause( vStr, pLits, 3 );
1435 pLits[2] = Abc_Var2Lit( Gia_SatVarReqPos(Gia_ObjFaninId1p(p, pFans[n])) + !(m ^ fCompl[n] ^ Gia_ObjFaninC1(pFans[n])), 0 );
1436 Gia_SatDumpClause( vStr, pLits, 3 );
1437 }
1438 }
1439 Vec_StrPush( vStr, '\0' );
1440 return vStr;
1441}
int Gia_SatVarInv(int i)
Definition giaSatLut.c:1304
int Gia_SatVarFan0(int i)
Definition giaSatLut.c:1305
int Gia_SatVarFan1(int i)
Definition giaSatLut.c:1306
int Gia_SatVarAckPos(int i)
Definition giaSatLut.c:1302
int Gia_SatVarReqNeg(int i)
Definition giaSatLut.c:1301
int Gia_SatVarAckNeg(int i)
Definition giaSatLut.c:1303
void Gia_SatDumpKlause(Vec_Str_t *vStr, int nIns, int nAnds, int nBound)
Definition giaSatLut.c:1326
int Gia_SatVarReqPos(int i)
Definition giaSatLut.c:1300
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSimpleMapping()

int Gia_ManSimpleMapping ( Gia_Man_t * p,
int nBound,
int Seed,
int nBTLimit,
int nTimeout,
int fVerbose,
int fKeepFile,
int argc,
char ** argv )

Definition at line 1572 of file giaSatLut.c.

1573{
1574 abctime clkStart = Abc_Clock();
1575 srand(time(NULL));
1576 int Status, Rand = ((((unsigned)rand()) << 12) ^ ((unsigned)rand())) & 0xFFFFFF;
1577 char pFileNameI[32]; sprintf( pFileNameI, "_%06x_.cnf", Rand );
1578 char pFileNameO[32]; sprintf( pFileNameO, "_%06x_.out", Rand );
1579 if ( nBound == 0 )
1580 nBound = 5 * Gia_ManAndNum(p);
1581 Vec_Str_t * vStr = Gia_ManSimpleCnf( p, nBound/2 );
1582 int nVars = 7*(Gia_ManObjNum(p)-Gia_ManCoNum(p));
1583 if ( !Gia_ManDumpCnf(pFileNameI, vStr, nVars) ) {
1584 Vec_StrFree( vStr );
1585 return 0;
1586 }
1587 if ( fVerbose )
1588 printf( "SAT variables = %d. SAT clauses = %d. Cardinality bound = %d. Conflict limit = %d. Timeout = %d.\n",
1589 nVars, Vec_StrCountEntry(vStr, '\n'), nBound, nBTLimit, nTimeout );
1590 Vec_Int_t * vRes = Gia_RunKadical( pFileNameI, pFileNameO, Seed, nBTLimit, nTimeout, fVerbose, &Status );
1591 unlink( pFileNameI );
1592 //unlink( pFileNameO );
1593 if ( fKeepFile ) Gia_ManDumpCnf2( vStr, nVars, argc, argv, Abc_Clock() - clkStart, Status );
1594 Vec_StrFree( vStr );
1595 if ( vRes == NULL )
1596 return 0;
1597 Vec_IntFreeP( &p->vCellMapping );
1598 assert( p->vCellMapping == NULL );
1599 Vec_IntDrop( vRes, 0 );
1600 if ( fVerbose ) Gia_ManSimplePrintMapping( vRes, Gia_ManCiNum(p) );
1601 p->vCellMapping = Gia_ManDeriveSimpleMapping( p, vRes );
1602 Vec_IntFree( vRes );
1603 if ( fVerbose ) Abc_PrintTime( 0, "Total time", Abc_Clock() - clkStart );
1604 return 1;
1605}
void Gia_ManSimplePrintMapping(Vec_Int_t *vRes, int nIns)
Definition giaSatLut.c:1513
Vec_Str_t * Gia_ManSimpleCnf(Gia_Man_t *p, int nBound)
Definition giaSatLut.c:1339
Vec_Int_t * Gia_ManDeriveSimpleMapping(Gia_Man_t *p, Vec_Int_t *vRes)
Definition giaSatLut.c:1459
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManSimplePrintMapping()

void Gia_ManSimplePrintMapping ( Vec_Int_t * vRes,
int nIns )

Definition at line 1513 of file giaSatLut.c.

1514{
1515 int i, k, nObjs = Vec_IntSize(vRes)/7, nSteps = Abc_Base10Log(nObjs);
1516 int nCard = Vec_IntSum(vRes) - nIns; char NumStr[10];
1517 printf( "Solution with cardinality %d:\n", nCard );
1518 for ( k = 0; k < nSteps; k++ ) {
1519 printf( " " );
1520 for ( i = 0; i < nObjs; i++ ) {
1521 sprintf( NumStr, "%02d", i );
1522 printf( "%c", NumStr[k] );
1523 }
1524 printf( "\n" );
1525 }
1526 for ( k = 0; k < 7; k++ ) {
1527 printf( "%c ", "pnPNi01"[k] );
1528 for ( i = 0; i < nObjs; i++ )
1529 if ( Vec_IntEntry( vRes, i*7+k ) == 0 )
1530 printf( " " );
1531 else
1532 printf( "1" );
1533 printf( "\n" );
1534 }
1535}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_RunKadical()

Vec_Int_t * Gia_RunKadical ( char * pFileNameIn,
char * pFileNameOut,
int Seed,
int nBTLimit,
int TimeOut,
int fVerbose,
int * pStatus )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1237 of file giaSatLut.c.

1238{
1239 extern Vec_Int_t * Exa4_ManParse( char *pFileName );
1240 int fVerboseSolver = 0;
1241 abctime clkTotal = Abc_Clock();
1242 Vec_Int_t * vRes = NULL;
1243#ifdef _WIN32
1244 char * pKadical = "kadical.exe";
1245#else
1246 char * pKadical = "./kadical";
1247 FILE * pFile = fopen( pKadical, "rb" );
1248 if ( pFile == NULL )
1249 pKadical += 2;
1250 else
1251 fclose( pFile );
1252#endif
1253 char Command[1000], * pCommand = (char *)&Command;
1254 if ( nBTLimit ) {
1255 if ( TimeOut )
1256 sprintf( pCommand, "%s --seed=%d -c %d -t %d %s %s > %s", pKadical, Seed, nBTLimit, TimeOut, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
1257 else
1258 sprintf( pCommand, "%s --seed=%d -c %d %s %s > %s", pKadical, Seed, nBTLimit, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
1259 }
1260 else {
1261 if ( TimeOut )
1262 sprintf( pCommand, "%s --seed=%d -t %d %s %s > %s", pKadical, Seed, TimeOut, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
1263 else
1264 sprintf( pCommand, "%s --seed=%d %s %s > %s", pKadical, Seed, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
1265 }
1266#ifdef __wasm
1267 if ( 1 )
1268#else
1269 if ( system( pCommand ) == -1 )
1270#endif
1271 {
1272 fprintf( stdout, "Command \"%s\" did not succeed.\n", pCommand );
1273 return 0;
1274 }
1275 vRes = Exa4_ManParse( pFileNameOut );
1276 if ( fVerbose )
1277 {
1278 if ( vRes )
1279 printf( "The problem has a solution. " ), *pStatus = 0;
1280 else if ( vRes == NULL && TimeOut == 0 )
1281 printf( "The problem has no solution. " ), *pStatus = 1;
1282 else if ( vRes == NULL )
1283 printf( "The problem has no solution or reached a resource limit after %d sec. ", TimeOut ), *pStatus = -1;
1284 Abc_PrintTime( 1, "SAT solver time", Abc_Clock() - clkTotal );
1285 }
1286 return vRes;
1287}
Vec_Int_t * Exa4_ManParse(char *pFileName)
DECLARATIONS ///.
Definition bmcMaj.c:1812
int system()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_SatDumpClause()

void Gia_SatDumpClause ( Vec_Str_t * vStr,
int * pLits,
int nLits )

Definition at line 1316 of file giaSatLut.c.

1317{
1318 for ( int i = 0; i < nLits; i++ )
1319 Vec_StrPrintF( vStr, "%d ", Abc_LitIsCompl(pLits[i]) ? -Abc_Lit2Var(pLits[i])-1 : Abc_Lit2Var(pLits[i])+1 );
1320 Vec_StrPrintF( vStr, "0\n" );
1321}
Here is the caller graph for this function:

◆ Gia_SatDumpKlause()

void Gia_SatDumpKlause ( Vec_Str_t * vStr,
int nIns,
int nAnds,
int nBound )

Definition at line 1326 of file giaSatLut.c.

1327{
1328 int i, nVars = nIns + 7*nAnds;
1329 Vec_StrPrintF( vStr, "k %d ", nVars - nBound );
1330 // counting primary inputs: n
1331 for ( i = 0; i < nIns; i++ )
1332 Vec_StrPrintF( vStr, "-%d ", Gia_SatVarReqNeg(1+i)+1 );
1333 // counting internal nodes: p, n, P, N, i, 0, 1
1334 for ( i = 0; i < 7*nAnds; i++ )
1335 Vec_StrPrintF( vStr, "-%d ", (1+nIns)*7+i+1 );
1336 Vec_StrPrintF( vStr, "0\n" );
1337}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_SatDumpLiteral()

void Gia_SatDumpLiteral ( Vec_Str_t * vStr,
int Lit )

Definition at line 1322 of file giaSatLut.c.

1323{
1324 Gia_SatDumpClause( vStr, &Lit, 1 );
1325}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_SatValAckNeg()

int Gia_SatValAckNeg ( Vec_Int_t * p,
int i )

Definition at line 1311 of file giaSatLut.c.

1311{ return Vec_IntEntry(p, i*7+3); } // N
Here is the caller graph for this function:

◆ Gia_SatValAckPos()

int Gia_SatValAckPos ( Vec_Int_t * p,
int i )

Definition at line 1310 of file giaSatLut.c.

1310{ return Vec_IntEntry(p, i*7+2); } // P
Here is the caller graph for this function:

◆ Gia_SatValFan0()

int Gia_SatValFan0 ( Vec_Int_t * p,
int i )

Definition at line 1313 of file giaSatLut.c.

1313{ return Vec_IntEntry(p, i*7+5); } // 0
Here is the caller graph for this function:

◆ Gia_SatValFan1()

int Gia_SatValFan1 ( Vec_Int_t * p,
int i )

Definition at line 1314 of file giaSatLut.c.

1314{ return Vec_IntEntry(p, i*7+6); } // 1
Here is the caller graph for this function:

◆ Gia_SatValInv()

int Gia_SatValInv ( Vec_Int_t * p,
int i )

Definition at line 1312 of file giaSatLut.c.

1312{ return Vec_IntEntry(p, i*7+4); } // i
Here is the caller graph for this function:

◆ Gia_SatValReqNeg()

int Gia_SatValReqNeg ( Vec_Int_t * p,
int i )

Definition at line 1309 of file giaSatLut.c.

1309{ return Vec_IntEntry(p, i*7+1); } // n
Here is the caller graph for this function:

◆ Gia_SatValReqPos()

int Gia_SatValReqPos ( Vec_Int_t * p,
int i )

Definition at line 1308 of file giaSatLut.c.

1308{ return Vec_IntEntry(p, i*7+0); } // p
Here is the caller graph for this function:

◆ Gia_SatVarAckNeg()

int Gia_SatVarAckNeg ( int i)

Definition at line 1303 of file giaSatLut.c.

1303{ return i*7+3; } // N
Here is the caller graph for this function:

◆ Gia_SatVarAckPos()

int Gia_SatVarAckPos ( int i)

Definition at line 1302 of file giaSatLut.c.

1302{ return i*7+2; } // P
Here is the caller graph for this function:

◆ Gia_SatVarFan0()

int Gia_SatVarFan0 ( int i)

Definition at line 1305 of file giaSatLut.c.

1305{ return i*7+5; } // 0
Here is the caller graph for this function:

◆ Gia_SatVarFan1()

int Gia_SatVarFan1 ( int i)

Definition at line 1306 of file giaSatLut.c.

1306{ return i*7+6; } // 1
Here is the caller graph for this function:

◆ Gia_SatVarInv()

int Gia_SatVarInv ( int i)

Definition at line 1304 of file giaSatLut.c.

1304{ return i*7+4; } // i
Here is the caller graph for this function:

◆ Gia_SatVarReqNeg()

int Gia_SatVarReqNeg ( int i)

Definition at line 1301 of file giaSatLut.c.

1301{ return i*7+1; } // n
Here is the caller graph for this function:

◆ Gia_SatVarReqPos()

int Gia_SatVarReqPos ( int i)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1300 of file giaSatLut.c.

1300{ return i*7+0; } // p
Here is the caller graph for this function:

◆ Sbl_ManAlloc()

Sbl_Man_t * Sbl_ManAlloc ( Gia_Man_t * pGia,
int Number )

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 132 of file giaSatLut.c.

133{
135 p->nVars = Number;
136 p->LogN = Abc_Base2Log(Number);
137 p->Power2 = 1 << p->LogN;
138 p->pSat = Sbm_AddCardinSolver( p->LogN, &p->vCardVars );
139 p->FirstVar = sat_solver_nvars( p->pSat );
140 sat_solver_bookmark( p->pSat );
141 // window
142 p->pGia = pGia;
143 p->vLeaves = Vec_IntAlloc( p->nVars );
144 p->vAnds = Vec_IntAlloc( p->nVars );
145 p->vNodes = Vec_IntAlloc( p->nVars );
146 p->vRoots = Vec_IntAlloc( p->nVars );
147 p->vRootVars = Vec_IntAlloc( p->nVars );
148 p->pHash = Hsh_VecManStart( 1000 );
149 // timing
150 p->vArrs = Vec_IntAlloc( 0 );
151 p->vReqs = Vec_IntAlloc( 0 );
152 p->vWindow = Vec_WecAlloc( 128 );
153 p->vPath = Vec_IntAlloc( 32 );
154 p->vEdges = Vec_IntAlloc( 32 );
155 // cuts
156 p->vCutsI1 = Vec_WrdAlloc( 1000 ); // input bit patterns
157 p->vCutsI2 = Vec_WrdAlloc( 1000 ); // input bit patterns
158 p->vCutsN1 = Vec_WrdAlloc( 1000 ); // node bit patterns
159 p->vCutsN2 = Vec_WrdAlloc( 1000 ); // node bit patterns
160 p->vCutsNum = Vec_IntAlloc( 64 ); // cut counts for each obj
161 p->vCutsStart = Vec_IntAlloc( 64 ); // starting cuts for each obj
162 p->vCutsObj = Vec_IntAlloc( 1000 );
163 p->vSolInit = Vec_IntAlloc( 64 );
164 p->vSolCur = Vec_IntAlloc( 64 );
165 p->vSolBest = Vec_IntAlloc( 64 );
166 p->vTempI1 = Vec_WrdAlloc( 32 );
167 p->vTempI2 = Vec_WrdAlloc( 32 );
168 p->vTempN1 = Vec_WrdAlloc( 32 );
169 p->vTempN2 = Vec_WrdAlloc( 32 );
170 // internal
171 p->vLits = Vec_IntAlloc( 64 );
172 p->vAssump = Vec_IntAlloc( 64 );
173 p->vPolar = Vec_IntAlloc( 1000 );
174 // other
175 Gia_ManFillValue( pGia );
176 return p;
177}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
sat_solver * Sbm_AddCardinSolver(int LogN, Vec_Int_t **pvVars)
Definition giaSatMap.c:456
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
int sat_solver_nvars(sat_solver *s)
Definition satSolver.c:2369
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbl_ManClean()

void Sbl_ManClean ( Sbl_Man_t * p)

Definition at line 178 of file giaSatLut.c.

179{
180 p->timeStart = Abc_Clock();
181 sat_solver_rollback( p->pSat );
182 sat_solver_bookmark( p->pSat );
183 // internal
184 Vec_IntClear( p->vLeaves );
185 Vec_IntClear( p->vAnds );
186 Vec_IntClear( p->vNodes );
187 Vec_IntClear( p->vRoots );
188 Vec_IntClear( p->vRootVars );
189 // timing
190 Vec_IntClear( p->vArrs );
191 Vec_IntClear( p->vReqs );
192 Vec_WecClear( p->vWindow );
193 Vec_IntClear( p->vPath );
194 Vec_IntClear( p->vEdges );
195 // cuts
196 Vec_WrdClear( p->vCutsI1 );
197 Vec_WrdClear( p->vCutsI2 );
198 Vec_WrdClear( p->vCutsN1 );
199 Vec_WrdClear( p->vCutsN2 );
200 Vec_IntClear( p->vCutsNum );
201 Vec_IntClear( p->vCutsStart );
202 Vec_IntClear( p->vCutsObj );
203 Vec_IntClear( p->vSolInit );
204 Vec_IntClear( p->vSolCur );
205 Vec_IntClear( p->vSolBest );
206 Vec_WrdClear( p->vTempI1 );
207 Vec_WrdClear( p->vTempI2 );
208 Vec_WrdClear( p->vTempN1 );
209 Vec_WrdClear( p->vTempN2 );
210 // temporary
211 Vec_IntClear( p->vLits );
212 Vec_IntClear( p->vAssump );
213 Vec_IntClear( p->vPolar );
214 // other
215 Gia_ManFillValue( p->pGia );
216}
void sat_solver_rollback(sat_solver *s)
Definition satSolver.c:1643
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbl_ManComputeCuts()

int Sbl_ManComputeCuts ( Sbl_Man_t * p)

Definition at line 740 of file giaSatLut.c.

741{
742 abctime clk = Abc_Clock();
743 Gia_Obj_t * pObj; Vec_Int_t * vFanins;
744 int i, k, Index, Fanin, nObjs = Vec_IntSize(p->vLeaves) + Vec_IntSize(p->vAnds);
745 assert( Vec_IntSize(p->vLeaves) <= 128 && Vec_IntSize(p->vAnds) <= p->nVars );
746 // assign leaf cuts
747 Vec_IntClear( p->vCutsStart );
748 Vec_IntClear( p->vCutsObj );
749 Vec_IntClear( p->vCutsNum );
750 Vec_WrdClear( p->vCutsI1 );
751 Vec_WrdClear( p->vCutsI2 );
752 Vec_WrdClear( p->vCutsN1 );
753 Vec_WrdClear( p->vCutsN2 );
754 Gia_ManForEachObjVec( p->vLeaves, p->pGia, pObj, i )
755 {
756 Vec_IntPush( p->vCutsStart, Vec_WrdSize(p->vCutsI1) );
757 Vec_IntPush( p->vCutsObj, -1 );
758 Vec_IntPush( p->vCutsNum, 1 );
759 if ( i < 64 )
760 {
761 Vec_WrdPush( p->vCutsI1, (((word)1) << i) );
762 Vec_WrdPush( p->vCutsI2, 0 );
763 }
764 else
765 {
766 Vec_WrdPush( p->vCutsI1, 0 );
767 Vec_WrdPush( p->vCutsI2, (((word)1) << (i-64)) );
768 }
769 Vec_WrdPush( p->vCutsN1, 0 );
770 Vec_WrdPush( p->vCutsN2, 0 );
771 pObj->Value = i;
772 }
773 // assign internal cuts
774 Gia_ManForEachObjVec( p->vAnds, p->pGia, pObj, i )
775 {
776 assert( Gia_ObjIsAnd(pObj) );
777 assert( ~Gia_ObjFanin0(pObj)->Value );
778 assert( ~Gia_ObjFanin1(pObj)->Value );
779 Sbl_ManComputeCutsOne( p, Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value, i );
780 pObj->Value = Vec_IntSize(p->vLeaves) + i;
781 }
782 assert( Vec_IntSize(p->vCutsStart) == nObjs );
783 assert( Vec_IntSize(p->vCutsNum) == nObjs );
784 assert( Vec_WrdSize(p->vCutsI1) == Vec_WrdSize(p->vCutsN1) );
785 assert( Vec_WrdSize(p->vCutsI2) == Vec_WrdSize(p->vCutsN2) );
786 assert( Vec_WrdSize(p->vCutsI1) == Vec_IntSize(p->vCutsObj) );
787 // check that roots are mapped nodes
788 Vec_IntClear( p->vRootVars );
789 Gia_ManForEachObjVec( p->vRoots, p->pGia, pObj, i )
790 {
791 int Obj = Gia_ObjId(p->pGia, pObj);
792 if ( Gia_ObjIsCi(pObj) )
793 continue;
794 assert( Gia_ObjIsLut2(p->pGia, Obj) );
795 assert( ~pObj->Value );
796 Vec_IntPush( p->vRootVars, pObj->Value - Vec_IntSize(p->vLeaves) );
797 }
798 // create current solution
799 Vec_IntClear( p->vPolar );
800 Vec_IntClear( p->vSolInit );
801 Gia_ManForEachObjVec( p->vAnds, p->pGia, pObj, i )
802 {
803 word CutI1 = 0, CutI2 = 0, CutN1 = 0, CutN2 = 0;
804 int Obj = Gia_ObjId(p->pGia, pObj);
805 if ( !Gia_ObjIsLut2(p->pGia, Obj) )
806 continue;
807 assert( (int)pObj->Value == Vec_IntSize(p->vLeaves) + i );
808 // add node
809 Vec_IntPush( p->vPolar, i );
810 Vec_IntPush( p->vSolInit, i );
811 // add its cut
812 //Gia_LutForEachFaninObj( p->pGia, Obj, pFanin, k )
813 vFanins = Gia_ObjLutFanins2( p->pGia, Obj );
814 Vec_IntForEachEntry( vFanins, Fanin, k )
815 {
816 Gia_Obj_t * pFanin = Gia_ManObj( p->pGia, Fanin );
817 assert( (int)pFanin->Value < Vec_IntSize(p->vLeaves) || Gia_ObjIsLut2(p->pGia, Fanin) );
818// if ( ~pFanin->Value == 0 )
819// Gia_ManPrintConeMulti( p->pGia, p->vAnds, p->vLeaves, p->vPath );
820 if ( ~pFanin->Value == 0 )
821 continue;
822 assert( ~pFanin->Value );
823 if ( (int)pFanin->Value < Vec_IntSize(p->vLeaves) )
824 {
825 if ( (int)pFanin->Value < 64 )
826 CutI1 |= ((word)1 << pFanin->Value);
827 else
828 CutI2 |= ((word)1 << (pFanin->Value - 64));
829 }
830 else
831 {
832 if ( pFanin->Value - Vec_IntSize(p->vLeaves) < 64 )
833 CutN1 |= ((word)1 << (pFanin->Value - Vec_IntSize(p->vLeaves)));
834 else
835 CutN2 |= ((word)1 << (pFanin->Value - Vec_IntSize(p->vLeaves) - 64));
836 }
837 }
838 // find the new cut
839 Index = Sbl_ManFindCut( p, Vec_IntSize(p->vLeaves) + i, CutI1, CutI2, CutN1, CutN2 );
840 if ( Index < 0 )
841 {
842 //printf( "Cannot find the available cut.\n" );
843 continue;
844 }
845 assert( Index >= 0 );
846 Vec_IntPush( p->vPolar, p->FirstVar+Index );
847 }
848 // clean value
849 Gia_ManForEachObjVec( p->vLeaves, p->pGia, pObj, i )
850 pObj->Value = ~0;
851 Gia_ManForEachObjVec( p->vAnds, p->pGia, pObj, i )
852 pObj->Value = ~0;
853 p->timeCut += Abc_Clock() - clk;
854 return Vec_WrdSize(p->vCutsI1);
855}
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition gia.h:1194
unsigned Value
Definition gia.h:89
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the caller graph for this function:

◆ Sbl_ManComputeDelay()

int Sbl_ManComputeDelay ( Sbl_Man_t * p,
int iLut,
Vec_Int_t * vFanins )

Function*************************************************************

Synopsis [Timing computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 314 of file giaSatLut.c.

315{
316 int k, iFan, Delay = 0;
317 Vec_IntForEachEntry( vFanins, iFan, k )
318 Delay = Abc_MaxInt( Delay, Vec_IntEntry(p->vArrs, iFan) + 1 );
319 return Delay;
320}
Here is the caller graph for this function:

◆ Sbl_ManCreateCnf()

int Sbl_ManCreateCnf ( Sbl_Man_t * p)

Definition at line 856 of file giaSatLut.c.

857{
858 int i, k, c, pLits[2], value;
859 word * pCutsN1 = Vec_WrdArray(p->vCutsN1);
860 word * pCutsN2 = Vec_WrdArray(p->vCutsN2);
861 assert( p->FirstVar == sat_solver_nvars(p->pSat) );
862 sat_solver_setnvars( p->pSat, sat_solver_nvars(p->pSat) + Vec_WrdSize(p->vCutsI1) );
863 //printf( "\n" );
864 for ( i = 0; i < Vec_IntSize(p->vAnds); i++ )
865 {
866 int Start0 = Vec_IntEntry( p->vCutsStart, Vec_IntSize(p->vLeaves) + i );
867 int Limit0 = Start0 + Vec_IntEntry( p->vCutsNum, Vec_IntSize(p->vLeaves) + i ) - 1;
868 // add main clause
869 Vec_IntClear( p->vLits );
870 Vec_IntPush( p->vLits, Abc_Var2Lit(i, 1) );
871 //printf( "Node %d implies cuts: ", i );
872 for ( k = Start0; k < Limit0; k++ )
873 {
874 Vec_IntPush( p->vLits, Abc_Var2Lit(p->FirstVar+k, 0) );
875 //printf( "%d ", p->FirstVar+k );
876 }
877 //printf( "\n" );
878 value = sat_solver_addclause( p->pSat, Vec_IntArray(p->vLits), Vec_IntLimit(p->vLits) );
879 assert( value );
880 // binary clauses
881 for ( k = Start0; k < Limit0; k++ )
882 {
883 word Cut1 = pCutsN1[k];
884 word Cut2 = pCutsN2[k];
885 //printf( "Cut %d implies root node %d.\n", p->FirstVar+k, i );
886 // root clause
887 pLits[0] = Abc_Var2Lit( p->FirstVar+k, 1 );
888 pLits[1] = Abc_Var2Lit( i, 0 );
889 value = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
890 assert( value );
891 // fanin clauses
892 for ( c = 0; c < 64 && Cut1; c++, Cut1 >>= 1 )
893 {
894 if ( (Cut1 & 1) == 0 )
895 continue;
896 //printf( "Cut %d implies fanin %d.\n", p->FirstVar+k, c );
897 pLits[1] = Abc_Var2Lit( c, 0 );
898 value = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
899 assert( value );
900 }
901 for ( c = 0; c < 64 && Cut2; c++, Cut2 >>= 1 )
902 {
903 if ( (Cut2 & 1) == 0 )
904 continue;
905 //printf( "Cut %d implies fanin %d.\n", p->FirstVar+k, c );
906 pLits[1] = Abc_Var2Lit( c+64, 0 );
907 value = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
908 assert( value );
909 }
910 }
911 }
912 sat_solver_set_polarity( p->pSat, Vec_IntArray(p->vPolar), Vec_IntSize(p->vPolar) );
913 return 1;
914}
ABC_NAMESPACE_IMPL_START typedef signed char value
#define sat_solver_addclause
Definition cecSatG2.c:37
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbl_ManCreateTiming()

int Sbl_ManCreateTiming ( Sbl_Man_t * p,
int DelayStart )

Definition at line 321 of file giaSatLut.c.

322{
323 Vec_Int_t * vFanins;
324 int DelayMax = DelayStart, Delay, iLut, iFan, k;
325 // compute arrival times
326 Vec_IntFill( p->vArrs, Gia_ManObjNum(p->pGia), 0 );
327 if ( p->pGia->pManTime != NULL && Tim_ManBoxNum((Tim_Man_t*)p->pGia->pManTime) )
328 {
329 Gia_Obj_t * pObj;
330 Vec_Int_t * vNodes = Gia_ManOrderWithBoxes( p->pGia );
331 Tim_ManIncrementTravId( (Tim_Man_t*)p->pGia->pManTime );
332 Gia_ManForEachObjVec( vNodes, p->pGia, pObj, k )
333 {
334 iLut = Gia_ObjId( p->pGia, pObj );
335 if ( Gia_ObjIsAnd(pObj) )
336 {
337 if ( Gia_ObjIsLut2(p->pGia, iLut) )
338 {
339 vFanins = Gia_ObjLutFanins2(p->pGia, iLut);
340 Delay = Sbl_ManComputeDelay( p, iLut, vFanins );
341 Vec_IntWriteEntry( p->vArrs, iLut, Delay );
342 DelayMax = Abc_MaxInt( DelayMax, Delay );
343 }
344 }
345 else if ( Gia_ObjIsCi(pObj) )
346 {
347 int arrTime = Tim_ManGetCiArrival( (Tim_Man_t*)p->pGia->pManTime, Gia_ObjCioId(pObj) );
348 Vec_IntWriteEntry( p->vArrs, iLut, arrTime );
349 }
350 else if ( Gia_ObjIsCo(pObj) )
351 {
352 int arrTime = Vec_IntEntry( p->vArrs, Gia_ObjFaninId0(pObj, iLut) );
353 Tim_ManSetCoArrival( (Tim_Man_t*)p->pGia->pManTime, Gia_ObjCioId(pObj), arrTime );
354 }
355 else if ( !Gia_ObjIsConst0(pObj) )
356 assert( 0 );
357 }
358 Vec_IntFree( vNodes );
359 }
360 else
361 {
362 Gia_ManForEachLut2( p->pGia, iLut )
363 {
364 vFanins = Gia_ObjLutFanins2(p->pGia, iLut);
365 Delay = Sbl_ManComputeDelay( p, iLut, vFanins );
366 Vec_IntWriteEntry( p->vArrs, iLut, Delay );
367 DelayMax = Abc_MaxInt( DelayMax, Delay );
368 }
369 }
370 // compute required times
371 Vec_IntFill( p->vReqs, Gia_ManObjNum(p->pGia), ABC_INFINITY );
372 Gia_ManForEachCoDriverId( p->pGia, iLut, k )
373 Vec_IntDowndateEntry( p->vReqs, iLut, DelayMax );
374 if ( p->pGia->pManTime != NULL && Tim_ManBoxNum((Tim_Man_t*)p->pGia->pManTime) )
375 {
376 Gia_Obj_t * pObj;
377 Vec_Int_t * vNodes = Gia_ManOrderWithBoxes( p->pGia );
378 Tim_ManIncrementTravId( (Tim_Man_t*)p->pGia->pManTime );
379 Tim_ManInitPoRequiredAll( (Tim_Man_t*)p->pGia->pManTime, DelayMax );
380 Gia_ManForEachObjVecReverse( vNodes, p->pGia, pObj, k )
381 {
382 iLut = Gia_ObjId( p->pGia, pObj );
383 if ( Gia_ObjIsAnd(pObj) )
384 {
385 if ( Gia_ObjIsLut2(p->pGia, iLut) )
386 {
387 Delay = Vec_IntEntry(p->vReqs, iLut) - 1;
388 vFanins = Gia_ObjLutFanins2(p->pGia, iLut);
389 Vec_IntForEachEntry( vFanins, iFan, k )
390 Vec_IntDowndateEntry( p->vReqs, iFan, Delay );
391 }
392 }
393 else if ( Gia_ObjIsCi(pObj) )
394 {
395 int reqTime = Vec_IntEntry( p->vReqs, iLut );
396 Tim_ManSetCiRequired( (Tim_Man_t*)p->pGia->pManTime, Gia_ObjCioId(pObj), reqTime );
397 }
398 else if ( Gia_ObjIsCo(pObj) )
399 {
400 int reqTime = Tim_ManGetCoRequired( (Tim_Man_t*)p->pGia->pManTime, Gia_ObjCioId(pObj) );
401 Vec_IntWriteEntry( p->vReqs, Gia_ObjFaninId0(pObj, iLut), reqTime );
402 }
403 else if ( !Gia_ObjIsConst0(pObj) )
404 assert( 0 );
405 }
406 Vec_IntFree( vNodes );
407 }
408 else
409 {
410 Gia_ManForEachLut2Reverse( p->pGia, iLut )
411 {
412 Delay = Vec_IntEntry(p->vReqs, iLut) - 1;
413 vFanins = Gia_ObjLutFanins2(p->pGia, iLut);
414 Vec_IntForEachEntry( vFanins, iFan, k )
415 Vec_IntDowndateEntry( p->vReqs, iFan, Delay );
416 }
417 }
418 return DelayMax;
419}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
int Sbl_ManComputeDelay(Sbl_Man_t *p, int iLut, Vec_Int_t *vFanins)
Definition giaSatLut.c:314
#define Gia_ManForEachLut2Reverse(p, i)
Definition gia.h:1170
#define Gia_ManForEachCoDriverId(p, DriverId, i)
Definition gia.h:1246
#define Gia_ManForEachObjVecReverse(vVec, p, pObj, i)
Definition gia.h:1202
Vec_Int_t * Gia_ManOrderWithBoxes(Gia_Man_t *p)
Definition giaTim.c:286
void Tim_ManSetCoArrival(Tim_Man_t *p, int iCo, float Delay)
Definition timTime.c:116
int Tim_ManBoxNum(Tim_Man_t *p)
Definition timMan.c:722
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition tim.h:92
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Definition timTrav.c:44
void Tim_ManSetCiRequired(Tim_Man_t *p, int iCi, float Delay)
Definition timTime.c:135
void Tim_ManInitPoRequiredAll(Tim_Man_t *p, float Delay)
Definition timTime.c:97
float Tim_ManGetCiArrival(Tim_Man_t *p, int iCi)
Definition timTime.c:174
float Tim_ManGetCoRequired(Tim_Man_t *p, int iCo)
Definition timTime.c:222
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbl_ManCriticalFanin()

int Sbl_ManCriticalFanin ( Sbl_Man_t * p,
int iLut,
Vec_Int_t * vFanins )

Function*************************************************************

Synopsis [Given mapping in p->vSolCur, check the critical path.]

Description [Returns 1 if the mapping satisfies the timing. Returns 0, if the critical path is detected.]

SideEffects []

SeeAlso []

Definition at line 465 of file giaSatLut.c.

466{
467 int k, iFan, Delay = Vec_IntEntry(p->vArrs, iLut);
468 Vec_IntForEachEntry( vFanins, iFan, k )
469 if ( Vec_IntEntry(p->vArrs, iFan) + 1 == Delay )
470 return iFan;
471 return -1;
472}
Here is the caller graph for this function:

◆ Sbl_ManEvaluateMapping()

int Sbl_ManEvaluateMapping ( Sbl_Man_t * p,
int DelayGlo )

Definition at line 473 of file giaSatLut.c.

474{
475 abctime clk = Abc_Clock();
476 Vec_Int_t * vFanins;
477 int i, iLut = -1, iAnd, Delay, Required;
478 if ( p->pGia->vEdge1 )
479 return Sbl_ManEvaluateMappingEdge( p, DelayGlo );
480 Vec_IntClear( p->vPath );
481 // derive timing
482 Sbl_ManCreateTiming( p, DelayGlo );
483 // update new timing
485 Vec_IntForEachEntry( p->vAnds, iLut, i )
486 {
487 vFanins = Vec_WecEntry( p->vWindow, i );
488 Delay = Sbl_ManComputeDelay( p, iLut, vFanins );
489 Vec_IntWriteEntry( p->vArrs, iLut, Delay );
490 }
491 // compare timing at the root nodes
492 Vec_IntForEachEntry( p->vRoots, iLut, i )
493 {
494 Delay = Vec_IntEntry( p->vArrs, iLut );
495 Required = Vec_IntEntry( p->vReqs, iLut );
496 if ( Delay > Required ) // updated timing exceeded original timing
497 break;
498 }
499 p->timeTime += Abc_Clock() - clk;
500 if ( i == Vec_IntSize(p->vRoots) )
501 return 1;
502 // derive the critical path
503
504 // find SAT variable of the node whose GIA ID is "iLut"
505 iAnd = Vec_IntFind( p->vAnds, iLut );
506 assert( iAnd >= 0 );
507 // critical path begins in node "iLut", which is i-th root of the window
508 assert( iAnd == Vec_IntEntry(p->vRootVars, i) );
509 while ( 1 )
510 {
511 Vec_IntPush( p->vPath, Abc_Var2Lit(iAnd, 1) );
512 // find fanins of this node
513 vFanins = Vec_WecEntry( p->vWindow, iAnd );
514 // find critical fanin
515 iLut = Sbl_ManCriticalFanin( p, iLut, vFanins );
516 assert( iLut > 0 );
517 // find SAT variable of the node whose GIA ID is "iLut"
518 iAnd = Vec_IntFind( p->vAnds, iLut );
519 if ( iAnd == -1 )
520 break;
521 }
522 return 0;
523}
void Sbl_ManGetCurrentMapping(Sbl_Man_t *p)
Definition giaSatLut.c:268
int Sbl_ManEvaluateMappingEdge(Sbl_Man_t *p, int DelayGlo)
Definition giaSatLut.c:433
int Sbl_ManCreateTiming(Sbl_Man_t *p, int DelayStart)
Definition giaSatLut.c:321
int Sbl_ManCriticalFanin(Sbl_Man_t *p, int iLut, Vec_Int_t *vFanins)
Definition giaSatLut.c:465
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbl_ManEvaluateMappingEdge()

int Sbl_ManEvaluateMappingEdge ( Sbl_Man_t * p,
int DelayGlo )

Function*************************************************************

Synopsis [Given mapping in p->vSolCur, check if mapping meets delay.]

Description []

SideEffects []

SeeAlso []

Definition at line 433 of file giaSatLut.c.

434{
435 abctime clk = Abc_Clock();
436 Vec_Int_t * vArray;
437 int i, DelayMax;
438 Vec_IntClear( p->vPath );
439 // update new timing
441 // derive new timing
442 DelayMax = Gia_ManEvalWindow( p->pGia, p->vLeaves, p->vAnds, p->vWindow, p->vPolar, 1 );
443 p->timeTime += Abc_Clock() - clk;
444 if ( DelayMax <= DelayGlo )
445 return 1;
446 // create critical path composed of all nodes
447 Vec_WecForEachLevel( p->vWindow, vArray, i )
448 if ( Vec_IntSize(vArray) > 0 )
449 Vec_IntPush( p->vPath, Abc_Var2Lit(i, 1) );
450 return 0;
451}
int Gia_ManEvalWindow(Gia_Man_t *p, Vec_Int_t *vLeaves, Vec_Int_t *vNodes, Vec_Wec_t *vWin, Vec_Int_t *vTemp, int fUseTwo)
Definition giaEdge.c:633
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbl_ManGetCurrentMapping()

void Sbl_ManGetCurrentMapping ( Sbl_Man_t * p)

Function*************************************************************

Synopsis [For each node in the window, create fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 268 of file giaSatLut.c.

269{
270 Vec_Int_t * vObj;
271 word CutI1, CutI2, CutN1, CutN2;
272 int i, c, b, iObj;
273 Vec_WecClear( p->vWindow );
274 Vec_WecInit( p->vWindow, Vec_IntSize(p->vAnds) );
275 assert( Vec_IntSize(p->vSolCur) > 0 );
276 Vec_IntForEachEntry( p->vSolCur, c, i )
277 {
278 CutI1 = Vec_WrdEntry( p->vCutsI1, c );
279 CutI2 = Vec_WrdEntry( p->vCutsI2, c );
280 CutN1 = Vec_WrdEntry( p->vCutsN1, c );
281 CutN2 = Vec_WrdEntry( p->vCutsN2, c );
282 iObj = Vec_IntEntry( p->vCutsObj, c );
283 //iObj = Vec_IntEntry( p->vAnds, iObj );
284 vObj = Vec_WecEntry( p->vWindow, iObj );
285 Vec_IntClear( vObj );
286 assert( Vec_IntSize(vObj) == 0 );
287 for ( b = 0; b < 64; b++ )
288 if ( (CutI1 >> b) & 1 )
289 Vec_IntPush( vObj, Vec_IntEntry(p->vLeaves, b) );
290 for ( b = 0; b < 64; b++ )
291 if ( (CutI2 >> b) & 1 )
292 Vec_IntPush( vObj, Vec_IntEntry(p->vLeaves, 64+b) );
293 for ( b = 0; b < 64; b++ )
294 if ( (CutN1 >> b) & 1 )
295 Vec_IntPush( vObj, Vec_IntEntry(p->vAnds, b) );
296 for ( b = 0; b < 64; b++ )
297 if ( (CutN2 >> b) & 1 )
298 Vec_IntPush( vObj, Vec_IntEntry(p->vAnds, 64+b) );
299 }
300}
Here is the caller graph for this function:

◆ Sbl_ManPrintRuntime()

void Sbl_ManPrintRuntime ( Sbl_Man_t * p)

Definition at line 1176 of file giaSatLut.c.

1177{
1178 printf( "Runtime breakdown:\n" );
1179 p->timeOther = p->timeTotal - p->timeWin - p->timeCut - p->timeSat - p->timeTime;
1180 ABC_PRTP( "Win ", p->timeWin , p->timeTotal );
1181 ABC_PRTP( "Cut ", p->timeCut , p->timeTotal );
1182 ABC_PRTP( "Sat ", p->timeSat, p->timeTotal );
1183 ABC_PRTP( " Sat ", p->timeSatSat, p->timeTotal );
1184 ABC_PRTP( " Unsat", p->timeSatUns, p->timeTotal );
1185 ABC_PRTP( " Undec", p->timeSatUnd, p->timeTotal );
1186 ABC_PRTP( "Timing", p->timeTime , p->timeTotal );
1187 ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
1188 ABC_PRTP( "ALL ", p->timeTotal, p->timeTotal );
1189}
#define ABC_PRTP(a, t, T)
Definition abc_global.h:258
Here is the caller graph for this function:

◆ Sbl_ManStop()

void Sbl_ManStop ( Sbl_Man_t * p)

Definition at line 217 of file giaSatLut.c.

218{
219 sat_solver_delete( p->pSat );
220 Vec_IntFree( p->vCardVars );
221 // internal
222 Vec_IntFree( p->vLeaves );
223 Vec_IntFree( p->vAnds );
224 Vec_IntFree( p->vNodes );
225 Vec_IntFree( p->vRoots );
226 Vec_IntFree( p->vRootVars );
227 Hsh_VecManStop( p->pHash );
228 // timing
229 Vec_IntFree( p->vArrs );
230 Vec_IntFree( p->vReqs );
231 Vec_WecFree( p->vWindow );
232 Vec_IntFree( p->vPath );
233 Vec_IntFree( p->vEdges );
234 // cuts
235 Vec_WrdFree( p->vCutsI1 );
236 Vec_WrdFree( p->vCutsI2 );
237 Vec_WrdFree( p->vCutsN1 );
238 Vec_WrdFree( p->vCutsN2 );
239 Vec_IntFree( p->vCutsNum );
240 Vec_IntFree( p->vCutsStart );
241 Vec_IntFree( p->vCutsObj );
242 Vec_IntFree( p->vSolInit );
243 Vec_IntFree( p->vSolCur );
244 Vec_IntFree( p->vSolBest );
245 Vec_WrdFree( p->vTempI1 );
246 Vec_WrdFree( p->vTempI2 );
247 Vec_WrdFree( p->vTempN1 );
248 Vec_WrdFree( p->vTempN2 );
249 // temporary
250 Vec_IntFree( p->vLits );
251 Vec_IntFree( p->vAssump );
252 Vec_IntFree( p->vPolar );
253 // other
254 ABC_FREE( p );
255}
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbl_ManTestSat()

int Sbl_ManTestSat ( Sbl_Man_t * p,
int iPivot )

Definition at line 967 of file giaSatLut.c.

968{
969 int fKeepTrying = 1;
970 abctime clk = Abc_Clock(), clk2;
971 int i, status, Root, Count, StartSol, nConfTotal = 0, nIters = 0;
972 int nEntries = Hsh_VecSize( p->pHash );
973 p->nTried++;
974
975 Sbl_ManClean( p );
976
977 // compute one window
978 Count = Sbl_ManWindow2( p, iPivot );
979 if ( Count == 0 )
980 {
981 if ( p->fVeryVerbose )
982 printf( "Obj %d: Window with less than %d nodes does not exist.\n", iPivot, p->nVars );
983 p->nSmallWins++;
984 return 0;
985 }
986 Hsh_VecManAdd( p->pHash, p->vAnds );
987 if ( nEntries == Hsh_VecSize(p->pHash) )
988 {
989 if ( p->fVeryVerbose )
990 printf( "Obj %d: This window was already tried.\n", iPivot );
991 p->nHashWins++;
992 return 0;
993 }
994 if ( p->fVeryVerbose )
995 printf( "\nObj = %6d : Leaf = %2d. AND = %2d. Root = %2d. LUT = %2d.\n",
996 iPivot, Vec_IntSize(p->vLeaves), Vec_IntSize(p->vAnds), Vec_IntSize(p->vRoots), Vec_IntSize(p->vNodes) );
997
998 if ( Vec_IntSize(p->vLeaves) > 128 || Vec_IntSize(p->vAnds) > p->nVars )
999 {
1000 if ( p->fVeryVerbose )
1001 printf( "Obj %d: Encountered window with %d inputs and %d internal nodes.\n", iPivot, Vec_IntSize(p->vLeaves), Vec_IntSize(p->vAnds) );
1002 p->nLargeWins++;
1003 return 0;
1004 }
1005 if ( Vec_IntSize(p->vAnds) < 10 )
1006 {
1007 if ( p->fVeryVerbose )
1008 printf( "Skipping.\n" );
1009 return 0;
1010 }
1011
1012 // derive cuts
1014 // derive SAT instance
1016
1017 if ( p->fVeryVeryVerbose )
1018 printf( "All clauses = %d. Multi clauses = %d. Binary clauses = %d. Other clauses = %d.\n\n",
1019 sat_solver_nclauses(p->pSat), Vec_IntSize(p->vAnds), Vec_WrdSize(p->vCutsI1) - Vec_IntSize(p->vAnds),
1020 sat_solver_nclauses(p->pSat) - Vec_WrdSize(p->vCutsI1) );
1021
1022 // create assumptions
1023 // cardinality
1024 Vec_IntClear( p->vAssump );
1025 Vec_IntPush( p->vAssump, -1 );
1026 // unused variables
1027 for ( i = Vec_IntSize(p->vAnds); i < p->Power2; i++ )
1028 Vec_IntPush( p->vAssump, Abc_Var2Lit(i, 1) );
1029 // root variables
1030 Vec_IntForEachEntry( p->vRootVars, Root, i )
1031 Vec_IntPush( p->vAssump, Abc_Var2Lit(Root, 0) );
1032// Vec_IntPrint( p->vAssump );
1033
1034 StartSol = Vec_IntSize(p->vSolInit) + 1;
1035// StartSol = 30;
1036 while ( fKeepTrying && StartSol-fKeepTrying > 0 )
1037 {
1038 int Count = 0, LitCount = 0;
1039 int nConfBef, nConfAft;
1040 if ( p->fVeryVerbose )
1041 printf( "Trying to find mapping with %d LUTs.\n", StartSol-fKeepTrying );
1042 // for ( i = Vec_IntSize(p->vSolInit)-5; i < nVars; i++ )
1043 // Vec_IntPush( p->vAssump, Abc_Var2Lit(Vec_IntEntry(p->vCardVars, i), 1) );
1044 Vec_IntWriteEntry( p->vAssump, 0, Abc_Var2Lit(Vec_IntEntry(p->vCardVars, StartSol-fKeepTrying), 1) );
1045 // solve the problem
1046 clk2 = Abc_Clock();
1047 nConfBef = (int)p->pSat->stats.conflicts;
1048 status = sat_solver_solve( p->pSat, Vec_IntArray(p->vAssump), Vec_IntLimit(p->vAssump), p->nBTLimit, 0, 0, 0 );
1049 p->timeSat += Abc_Clock() - clk2;
1050 nConfAft = (int)p->pSat->stats.conflicts;
1051 nConfTotal += nConfAft - nConfBef;
1052 nIters++;
1053 p->nRuns++;
1054 if ( status == l_True )
1055 p->timeSatSat += Abc_Clock() - clk2;
1056 else if ( status == l_False )
1057 p->timeSatUns += Abc_Clock() - clk2;
1058 else
1059 p->timeSatUnd += Abc_Clock() - clk2;
1060 if ( status == l_Undef )
1061 break;
1062 if ( status == l_True )
1063 {
1064 if ( p->fVeryVeryVerbose )
1065 {
1066 for ( i = 0; i < Vec_IntSize(p->vAnds); i++ )
1067 printf( "%d", sat_solver_var_value(p->pSat, i) );
1068 printf( "\n" );
1069 for ( i = 0; i < Vec_IntSize(p->vAnds); i++ )
1070 if ( sat_solver_var_value(p->pSat, i) )
1071 {
1072 printf( "%d=%d ", i, sat_solver_var_value(p->pSat, i) );
1073 Count++;
1074 }
1075 printf( "Count = %d\n", Count );
1076 }
1077// for ( i = p->FirstVar; i < sat_solver_nvars(p->pSat); i++ )
1078// printf( "%d", sat_solver_var_value(p->pSat, i) );
1079// printf( "\n" );
1080 Count = 1;
1081 Vec_IntClear( p->vSolCur );
1082 for ( i = p->FirstVar; i < sat_solver_nvars(p->pSat); i++ )
1083 if ( sat_solver_var_value(p->pSat, i) )
1084 {
1085 if ( p->fVeryVeryVerbose )
1086 printf( "Cut %3d : Node = %3d %6d ", Count++, Vec_IntEntry(p->vCutsObj, i-p->FirstVar), Vec_IntEntry(p->vAnds, Vec_IntEntry(p->vCutsObj, i-p->FirstVar)) );
1087 if ( p->fVeryVeryVerbose )
1088 LitCount += Sbl_ManFindAndPrintCut( p, i-p->FirstVar );
1089 Vec_IntPush( p->vSolCur, i-p->FirstVar );
1090 }
1091 //Vec_IntPrint( p->vRootVars );
1092 //Vec_IntPrint( p->vRoots );
1093 //Vec_IntPrint( p->vAnds );
1094 //Vec_IntPrint( p->vLeaves );
1095 }
1096
1097// fKeepTrying = status == l_True ? fKeepTrying + 1 : 0;
1098 // check the timing
1099 if ( status == l_True )
1100 {
1101 if ( p->fDelay && !Sbl_ManEvaluateMapping(p, p->DelayMax) )
1102 {
1103 int iLit, value;
1104 if ( p->fVeryVerbose )
1105 {
1106 printf( "Critical path of length (%d) is detected: ", Vec_IntSize(p->vPath) );
1107 Vec_IntForEachEntry( p->vPath, iLit, i )
1108 printf( "%d=%d ", i, Vec_IntEntry(p->vAnds, Abc_Lit2Var(iLit)) );
1109 printf( "\n" );
1110 }
1111 // add the clause
1112 value = sat_solver_addclause( p->pSat, Vec_IntArray(p->vPath), Vec_IntLimit(p->vPath) );
1113 assert( value );
1114 }
1115 else
1116 {
1117 Vec_IntClear( p->vSolBest );
1118 Vec_IntAppend( p->vSolBest, p->vSolCur );
1119 fKeepTrying++;
1120 }
1121 }
1122 else
1123 fKeepTrying = 0;
1124 if ( p->fVeryVerbose )
1125 {
1126 if ( status == l_False )
1127 printf( "UNSAT " );
1128 else if ( status == l_True )
1129 printf( "SAT " );
1130 else
1131 printf( "UNDEC " );
1132 printf( "confl =%8d. ", nConfAft - nConfBef );
1133 Abc_PrintTime( 1, "Time", Abc_Clock() - clk2 );
1134
1135 printf( "Total " );
1136 printf( "confl =%8d. ", nConfTotal );
1137 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1138 if ( p->fVeryVeryVerbose && status == l_True )
1139 printf( "LitCount = %d.\n", LitCount );
1140 printf( "\n" );
1141 }
1142 if ( nIters == 10 )
1143 {
1144 p->nIterOuts++;
1145 //printf( "Obj %d : Quitting after %d iterations.\n", iPivot, nIters );
1146 break;
1147 }
1148 }
1149
1150 // update solution
1151 if ( Vec_IntSize(p->vSolBest) > 0 && Vec_IntSize(p->vSolBest) < Vec_IntSize(p->vSolInit) )
1152 {
1153 int nDelayCur, nEdgesCur = 0;
1155 if ( p->pGia->vEdge1 )
1156 {
1157 nDelayCur = Gia_ManEvalEdgeDelay( p->pGia );
1158 nEdgesCur = Gia_ManEvalEdgeCount( p->pGia );
1159 }
1160 else
1161 nDelayCur = Sbl_ManCreateTiming( p, p->DelayMax );
1162 if ( p->fVerbose )
1163 printf( "Object %5d : Saved %2d nodes (Conf =%8d) Iter =%3d Delay = %d Edges = %4d\n",
1164 iPivot, Vec_IntSize(p->vSolInit)-Vec_IntSize(p->vSolBest), nConfTotal, nIters, nDelayCur, nEdgesCur );
1165 p->timeTotal += Abc_Clock() - p->timeStart;
1166 p->nImproved++;
1167 return 2;
1168 }
1169 else
1170 {
1171// printf( "Object %5d : Saved %2d nodes (Conf =%8d) Iter =%3d\n", iPivot, 0, nConfTotal, nIters );
1172 }
1173 p->timeTotal += Abc_Clock() - p->timeStart;
1174 return 1;
1175}
#define l_True
Definition bmcBmcS.c:35
#define l_Undef
Definition bmcBmcS.c:34
#define l_False
Definition bmcBmcS.c:36
#define sat_solver_solve
Definition cecSatG2.c:45
int Sbl_ManWindow2(Sbl_Man_t *p, int iPivot)
Definition giaSatLut.c:946
void Sbl_ManClean(Sbl_Man_t *p)
Definition giaSatLut.c:178
int Sbl_ManCreateCnf(Sbl_Man_t *p)
Definition giaSatLut.c:856
void Sbl_ManUpdateMapping(Sbl_Man_t *p)
Definition giaSatLut.c:537
int Sbl_ManEvaluateMapping(Sbl_Man_t *p, int DelayGlo)
Definition giaSatLut.c:473
int Sbl_ManComputeCuts(Sbl_Man_t *p)
Definition giaSatLut.c:740
int Gia_ManEvalEdgeCount(Gia_Man_t *p)
Definition giaEdge.c:284
int sat_solver_nclauses(sat_solver *s)
Definition satSolver.c:2375
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbl_ManUpdateMapping()

void Sbl_ManUpdateMapping ( Sbl_Man_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 537 of file giaSatLut.c.

538{
539// Gia_Obj_t * pObj;
540 Vec_Int_t * vObj;
541 word CutI1, CutI2, CutN1, CutN2;
542 int i, c, b, iObj, iTemp;
543 assert( Vec_IntSize(p->vSolBest) < Vec_IntSize(p->vSolInit) );
544 Vec_IntForEachEntry( p->vAnds, iObj, i )
545 {
546 vObj = Vec_WecEntry(p->pGia->vMapping2, iObj);
547 Vec_IntForEachEntry( vObj, iTemp, b )
548 Gia_ObjLutRefDecId( p->pGia, iTemp );
549 Vec_IntClear( vObj );
550 }
551 Vec_IntForEachEntry( p->vSolBest, c, i )
552 {
553 CutI1 = Vec_WrdEntry( p->vCutsI1, c );
554 CutI2 = Vec_WrdEntry( p->vCutsI2, c );
555 CutN1 = Vec_WrdEntry( p->vCutsN1, c );
556 CutN2 = Vec_WrdEntry( p->vCutsN2, c );
557 iObj = Vec_IntEntry( p->vCutsObj, c );
558 iObj = Vec_IntEntry( p->vAnds, iObj );
559 vObj = Vec_WecEntry( p->pGia->vMapping2, iObj );
560 Vec_IntClear( vObj );
561 assert( Vec_IntSize(vObj) == 0 );
562 for ( b = 0; b < 64; b++ )
563 if ( (CutI1 >> b) & 1 )
564 Vec_IntPush( vObj, Vec_IntEntry(p->vLeaves, b) );
565 for ( b = 0; b < 64; b++ )
566 if ( (CutI2 >> b) & 1 )
567 Vec_IntPush( vObj, Vec_IntEntry(p->vLeaves, 64+b) );
568 for ( b = 0; b < 64; b++ )
569 if ( (CutN1 >> b) & 1 )
570 Vec_IntPush( vObj, Vec_IntEntry(p->vAnds, b) );
571 for ( b = 0; b < 64; b++ )
572 if ( (CutN2 >> b) & 1 )
573 Vec_IntPush( vObj, Vec_IntEntry(p->vAnds, 64+b) );
574 Vec_IntForEachEntry( vObj, iTemp, b )
575 Gia_ObjLutRefIncId( p->pGia, iTemp );
576 }
577/*
578 // verify
579 Gia_ManForEachLut2Vec( p->pGia, vObj, i )
580 Vec_IntForEachEntry( vObj, iTemp, b )
581 Gia_ObjLutRefDecId( p->pGia, iTemp );
582 Gia_ManForEachCo( p->pGia, pObj, i )
583 Gia_ObjLutRefDecId( p->pGia, Gia_ObjFaninId0p(p->pGia, pObj) );
584
585 for ( i = 0; i < Gia_ManObjNum(p->pGia); i++ )
586 if ( p->pGia->pLutRefs[i] )
587 printf( "Object %d has %d refs\n", i, p->pGia->pLutRefs[i] );
588
589 Gia_ManForEachCo( p->pGia, pObj, i )
590 Gia_ObjLutRefIncId( p->pGia, Gia_ObjFaninId0p(p->pGia, pObj) );
591 Gia_ManForEachLut2Vec( p->pGia, vObj, i )
592 Vec_IntForEachEntry( vObj, iTemp, b )
593 Gia_ObjLutRefIncId( p->pGia, iTemp );
594*/
595}
Here is the caller graph for this function:

◆ Sbl_ManWindow()

void Sbl_ManWindow ( Sbl_Man_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 929 of file giaSatLut.c.

930{
931 int i, ObjId;
932 // collect leaves
933 Vec_IntClear( p->vLeaves );
934 Gia_ManForEachCiId( p->pGia, ObjId, i )
935 Vec_IntPush( p->vLeaves, ObjId );
936 // collect internal
937 Vec_IntClear( p->vAnds );
938 Gia_ManForEachAndId( p->pGia, ObjId )
939 Vec_IntPush( p->vAnds, ObjId );
940 // collect roots
941 Vec_IntClear( p->vRoots );
942 Gia_ManForEachCoDriverId( p->pGia, ObjId, i )
943 Vec_IntPush( p->vRoots, ObjId );
944}
#define Gia_ManForEachAndId(p, i)
Definition gia.h:1216

◆ Sbl_ManWindow2()

int Sbl_ManWindow2 ( Sbl_Man_t * p,
int iPivot )

Definition at line 946 of file giaSatLut.c.

947{
948 abctime clk = Abc_Clock();
949 Vec_Int_t * vRoots, * vNodes, * vLeaves, * vAnds;
950 int Count = Gia_ManComputeOneWin( p->pGia, iPivot, &vRoots, &vNodes, &vLeaves, &vAnds );
951 p->timeWin += Abc_Clock() - clk;
952 if ( Count == 0 )
953 return 0;
954 Vec_IntClear( p->vRoots ); Vec_IntAppend( p->vRoots, vRoots );
955 Vec_IntClear( p->vNodes ); Vec_IntAppend( p->vNodes, vNodes );
956 Vec_IntClear( p->vLeaves ); Vec_IntAppend( p->vLeaves, vLeaves );
957 Vec_IntClear( p->vAnds ); Vec_IntAppend( p->vAnds, vAnds );
958//Vec_IntPrint( vRoots );
959//Vec_IntPrint( vAnds );
960//Vec_IntPrint( vLeaves );
961 // recompute internal nodes
962// Gia_ManIncrementTravId( p->pGia );
963// Gia_ManCollectAnds( p->pGia, Vec_IntArray(p->vRoots), Vec_IntSize(p->vRoots), p->vAnds, p->vLeaves );
964 return Count;
965}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sbm_AddCardinSolver()

sat_solver * Sbm_AddCardinSolver ( int LogN,
Vec_Int_t ** pvVars )
extern

Definition at line 456 of file giaSatMap.c.

457{
458 int nVars = 1 << LogN;
459 int nVarsAlloc = nVars + 2 * (nVars * LogN * (LogN-1) / 4 + nVars - 1), nVarsReal;
460 Vec_Int_t * vVars = Vec_IntStartNatural( nVars );
461 sat_solver * pSat = sat_solver_new();
462 sat_solver_setnvars( pSat, nVarsAlloc );
463 nVarsReal = Sbm_AddCardinConstrPairWise( pSat, vVars, 2 );
464 assert( nVarsReal == nVarsAlloc );
465 *pvVars = vVars;
466 return pSat;
467}
#define sat_solver
Definition cecSatG2.c:34
int Sbm_AddCardinConstrPairWise(sat_solver *p, Vec_Int_t *vVars, int K)
Definition giaSatMap.c:449
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
Here is the caller graph for this function: