abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sim.h File Reference

Go to the source code of this file.

Data Structures

struct  Sym_Man_t_
 
struct  Sim_Man_t_
 
struct  Sim_Pat_t_
 

Macros

#define SIM_NUM_WORDS(n)   (((n)>>5) + (((n)&31) > 0))
 MACRO DEFINITIONS ///. More...
 
#define SIM_LAST_BITS(n)   ((((n)&31) > 0)? (n)&31 : 32)
 
#define SIM_MASK_FULL   (0xFFFFFFFF)
 
#define SIM_MASK_BEG(n)   (SIM_MASK_FULL >> (32-n))
 
#define SIM_MASK_END(n)   (SIM_MASK_FULL << (n))
 
#define SIM_SET_0_FROM(m, n)   ((m) & ~SIM_MASK_BEG(n))
 
#define SIM_SET_1_FROM(m, n)   ((m) | SIM_MASK_END(n))
 
#define SIM_RANDOM_UNSIGNED   ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand()))
 
#define Sim_SetBit(p, i)   ((p)[(i)>>5] |= (1<<((i) & 31)))
 
#define Sim_XorBit(p, i)   ((p)[(i)>>5] ^= (1<<((i) & 31)))
 
#define Sim_HasBit(p, i)   (((p)[(i)>>5] & (1<<((i) & 31))) > 0)
 
#define Sim_SuppStrSetVar(vSupps, pNode, v)   Sim_SetBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))
 
#define Sim_SuppStrHasVar(vSupps, pNode, v)   Sim_HasBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))
 
#define Sim_SuppFunSetVar(vSupps, Output, v)   Sim_SetBit((unsigned*)(vSupps)->pArray[Output],(v))
 
#define Sim_SuppFunHasVar(vSupps, Output, v)   Sim_HasBit((unsigned*)(vSupps)->pArray[Output],(v))
 
#define Sim_SimInfoSetVar(vSupps, pNode, v)   Sim_SetBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))
 
#define Sim_SimInfoHasVar(vSupps, pNode, v)   Sim_HasBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))
 
#define Sim_SimInfoGet(vInfo, pNode)   ((unsigned *)((vInfo)->pArray[(pNode)->Id]))
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Sym_Man_t_ 
Sym_Man_t
 INCLUDES ///. More...
 
typedef struct Sim_Man_t_ Sim_Man_t
 
typedef struct Sim_Pat_t_ Sim_Pat_t
 

Functions

Sym_Man_tSym_ManStart (Abc_Ntk_t *pNtk, int fVerbose)
 FUNCTION DECLARATIONS ///. More...
 
void Sym_ManStop (Sym_Man_t *p)
 
void Sym_ManPrintStats (Sym_Man_t *p)
 
Sim_Man_tSim_ManStart (Abc_Ntk_t *pNtk, int fLightweight)
 
void Sim_ManStop (Sim_Man_t *p)
 
void Sim_ManPrintStats (Sim_Man_t *p)
 
Sim_Pat_tSim_ManPatAlloc (Sim_Man_t *p)
 
void Sim_ManPatFree (Sim_Man_t *p, Sim_Pat_t *pPat)
 
Vec_Ptr_tSim_SimulateSeqRandom (Abc_Ntk_t *pNtk, int nFrames, int nWords)
 FUNCTION DEFINITIONS ///. More...
 
Vec_Ptr_tSim_SimulateSeqModel (Abc_Ntk_t *pNtk, int nFrames, int *pModel)
 
Vec_Ptr_tSim_ComputeStrSupp (Abc_Ntk_t *pNtk)
 FUNCTION DEFINITIONS ///. More...
 
Vec_Ptr_tSim_ComputeFunSupp (Abc_Ntk_t *pNtk, int fVerbose)
 
int Sim_ComputeTwoVarSymms (Abc_Ntk_t *pNtk, int fVerbose)
 DECLARATIONS ///. More...
 
int Sim_SymmsGetPatternUsingSat (Sym_Man_t *p, unsigned *pPattern)
 FUNCTION DEFINITIONS ///. More...
 
void Sim_SymmsStructCompute (Abc_Ntk_t *pNtk, Vec_Ptr_t *vMatrs, Vec_Ptr_t *vSuppFun)
 FUNCTION DEFINITIONS ///. More...
 
void Sim_SymmsSimulate (Sym_Man_t *p, unsigned *pPatRand, Vec_Ptr_t *vMatrsNonSym)
 FUNCTION DEFINITIONS ///. More...
 
Vec_Ptr_tSim_UtilInfoAlloc (int nSize, int nWords, int fClean)
 FUNCTION DEFINITIONS ///. More...
 
void Sim_UtilInfoFree (Vec_Ptr_t *p)
 
void Sim_UtilInfoAdd (unsigned *pInfo1, unsigned *pInfo2, int nWords)
 
void Sim_UtilInfoDetectDiffs (unsigned *pInfo1, unsigned *pInfo2, int nWords, Vec_Int_t *vDiffs)
 
void Sim_UtilInfoDetectNews (unsigned *pInfo1, unsigned *pInfo2, int nWords, Vec_Int_t *vDiffs)
 
void Sim_UtilInfoFlip (Sim_Man_t *p, Abc_Obj_t *pNode)
 
int Sim_UtilInfoCompare (Sim_Man_t *p, Abc_Obj_t *pNode)
 
void Sim_UtilSimulate (Sim_Man_t *p, int fFirst)
 
void Sim_UtilSimulateNode (Sim_Man_t *p, Abc_Obj_t *pNode, int fType, int fType1, int fType2)
 
void Sim_UtilSimulateNodeOne (Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords, int nOffset)
 
void Sim_UtilTransferNodeOne (Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords, int nOffset, int fShift)
 
int Sim_UtilCountSuppSizes (Sim_Man_t *p, int fStruct)
 
int Sim_UtilCountOnes (unsigned *pSimInfo, int nSimWords)
 
Vec_Int_tSim_UtilCountOnesArray (Vec_Ptr_t *vInfo, int nSimWords)
 
void Sim_UtilSetRandom (unsigned *pPatRand, int nSimWords)
 
void Sim_UtilSetCompl (unsigned *pPatRand, int nSimWords)
 
void Sim_UtilSetConst (unsigned *pPatRand, int nSimWords, int fConst1)
 
int Sim_UtilInfoIsEqual (unsigned *pPats1, unsigned *pPats2, int nSimWords)
 
int Sim_UtilInfoIsImp (unsigned *pPats1, unsigned *pPats2, int nSimWords)
 
int Sim_UtilInfoIsClause (unsigned *pPats1, unsigned *pPats2, int nSimWords)
 
int Sim_UtilCountAllPairs (Vec_Ptr_t *vSuppFun, int nSimWords, Vec_Int_t *vCounters)
 
void Sim_UtilCountPairsAll (Sym_Man_t *p)
 
int Sim_UtilMatrsAreDisjoint (Sym_Man_t *p)
 

Macro Definition Documentation

#define Sim_HasBit (   p,
 
)    (((p)[(i)>>5] & (1<<((i) & 31))) > 0)

Definition at line 163 of file sim.h.

#define SIM_LAST_BITS (   n)    ((((n)&31) > 0)? (n)&31 : 32)

Definition at line 149 of file sim.h.

#define SIM_MASK_BEG (   n)    (SIM_MASK_FULL >> (32-n))

Definition at line 152 of file sim.h.

#define SIM_MASK_END (   n)    (SIM_MASK_FULL << (n))

Definition at line 153 of file sim.h.

#define SIM_MASK_FULL   (0xFFFFFFFF)

Definition at line 151 of file sim.h.

#define SIM_NUM_WORDS (   n)    (((n)>>5) + (((n)&31) > 0))

MACRO DEFINITIONS ///.

Definition at line 148 of file sim.h.

#define SIM_RANDOM_UNSIGNED   ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand()))

Definition at line 158 of file sim.h.

#define SIM_SET_0_FROM (   m,
 
)    ((m) & ~SIM_MASK_BEG(n))

Definition at line 154 of file sim.h.

#define SIM_SET_1_FROM (   m,
 
)    ((m) | SIM_MASK_END(n))

Definition at line 155 of file sim.h.

#define Sim_SetBit (   p,
 
)    ((p)[(i)>>5] |= (1<<((i) & 31)))

Definition at line 161 of file sim.h.

#define Sim_SimInfoGet (   vInfo,
  pNode 
)    ((unsigned *)((vInfo)->pArray[(pNode)->Id]))

Definition at line 172 of file sim.h.

#define Sim_SimInfoHasVar (   vSupps,
  pNode,
 
)    Sim_HasBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))

Definition at line 171 of file sim.h.

#define Sim_SimInfoSetVar (   vSupps,
  pNode,
 
)    Sim_SetBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))

Definition at line 170 of file sim.h.

#define Sim_SuppFunHasVar (   vSupps,
  Output,
 
)    Sim_HasBit((unsigned*)(vSupps)->pArray[Output],(v))

Definition at line 169 of file sim.h.

#define Sim_SuppFunSetVar (   vSupps,
  Output,
 
)    Sim_SetBit((unsigned*)(vSupps)->pArray[Output],(v))

Definition at line 168 of file sim.h.

#define Sim_SuppStrHasVar (   vSupps,
  pNode,
 
)    Sim_HasBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))

Definition at line 167 of file sim.h.

#define Sim_SuppStrSetVar (   vSupps,
  pNode,
 
)    Sim_SetBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))

Definition at line 166 of file sim.h.

#define Sim_XorBit (   p,
 
)    ((p)[(i)>>5] ^= (1<<((i) & 31)))

Definition at line 162 of file sim.h.

Typedef Documentation

typedef struct Sim_Man_t_ Sim_Man_t

Definition at line 100 of file sim.h.

typedef struct Sim_Pat_t_ Sim_Pat_t

Definition at line 136 of file sim.h.

typedef typedefABC_NAMESPACE_HEADER_START struct Sym_Man_t_ Sym_Man_t

INCLUDES ///.

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

FileName [sim.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Simulation package.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
sim.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 48 of file sim.h.

Function Documentation

Vec_Ptr_t* Sim_ComputeFunSupp ( Abc_Ntk_t pNtk,
int  fVerbose 
)

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

Synopsis [Compute functional supports.]

Description [Supports are returned as an array of bit strings, one for each CO.]

SideEffects []

SeeAlso []

Definition at line 103 of file simSupp.c.

104 {
105  Sim_Man_t * p;
106  Vec_Ptr_t * vResult;
107  int nSolved, i;
108  abctime clk = Abc_Clock();
109 
110  srand( 0xABC );
111 
112  // start the simulation manager
113  p = Sim_ManStart( pNtk, 0 );
114 
115  // compute functional support using one round of random simulation
117  Sim_ComputeSuppRound( p, 0 );
118 
119  // set the support targets
121 if ( fVerbose )
122  printf( "Number of support targets after simulation = %5d.\n", Vec_VecSizeSize(p->vSuppTargs) );
123  if ( Vec_VecSizeSize(p->vSuppTargs) == 0 )
124  goto exit;
125 
126  for ( i = 0; i < 1; i++ )
127  {
128  // compute patterns using one round of random simulation
130  nSolved = Sim_ComputeSuppRound( p, 1 );
131  if ( Vec_VecSizeSize(p->vSuppTargs) == 0 )
132  goto exit;
133 
134 if ( fVerbose )
135  printf( "Targets = %5d. Solved = %5d. Fifo = %5d.\n",
136  Vec_VecSizeSize(p->vSuppTargs), nSolved, Vec_PtrSize(p->vFifo) );
137  }
138 
139  // try to solve the support targets
140  while ( Vec_VecSizeSize(p->vSuppTargs) > 0 )
141  {
142  // solve targets until the first disproved one (which gives counter-example)
144  // compute additional functional support
146  nSolved = Sim_ComputeSuppRound( p, 1 );
147 
148 if ( fVerbose )
149  printf( "Targets = %5d. Solved = %5d. Fifo = %5d. SAT runs = %3d.\n",
150  Vec_VecSizeSize(p->vSuppTargs), nSolved, Vec_PtrSize(p->vFifo), p->nSatRuns );
151  }
152 
153 exit:
154 p->timeTotal = Abc_Clock() - clk;
155  vResult = p->vSuppFun;
156  // p->vSuppFun = NULL;
157  Sim_ManStop( p );
158  return vResult;
159 }
Vec_Ptr_t * vFifo
Definition: sim.h:123
VOID_HACK exit()
int nSuppWords
Definition: sim.h:115
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Sim_UtilAssignFromFifo(Sim_Man_t *p)
Definition: simSupp.c:366
Vec_Ptr_t * vSuppFun
Definition: sim.h:117
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nSimWords
Definition: sim.h:110
int nSatRuns
Definition: sim.h:125
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
abctime timeTotal
Definition: sim.h:133
static void Sim_ComputeSuppSetTargets(Sim_Man_t *p)
Definition: simSupp.c:314
void Sim_ManStop(Sim_Man_t *p)
Definition: simMan.c:208
static void Sim_UtilAssignRandom(Sim_Man_t *p)
Definition: simSupp.c:341
static int Vec_VecSizeSize(Vec_Vec_t *p)
Definition: vecVec.h:417
Vec_Vec_t * vSuppTargs
Definition: sim.h:119
static ABC_NAMESPACE_IMPL_START int Sim_ComputeSuppRound(Sim_Man_t *p, int fUseTargets)
DECLARATIONS ///.
Definition: simSupp.c:172
Sim_Man_t * Sim_ManStart(Abc_Ntk_t *pNtk, int fLightweight)
Definition: simMan.c:166
ABC_INT64_T abctime
Definition: abc_global.h:278
static void Sim_SolveTargetsUsingSat(Sim_Man_t *p, int nCounters)
Definition: simSupp.c:449
Vec_Ptr_t* Sim_ComputeStrSupp ( Abc_Ntk_t pNtk)

FUNCTION DEFINITIONS ///.

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

Synopsis [Computes structural supports.]

Description [Supports are returned as an array of bit strings, one for each CO.]

SideEffects []

SeeAlso []

Definition at line 57 of file simSupp.c.

58 {
59  Vec_Ptr_t * vSuppStr;
60  Abc_Obj_t * pNode;
61  unsigned * pSimmNode, * pSimmNode1, * pSimmNode2;
62  int nSuppWords, i, k;
63  // allocate room for structural supports
64  nSuppWords = SIM_NUM_WORDS( Abc_NtkCiNum(pNtk) );
65  vSuppStr = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), nSuppWords, 1 );
66  // assign the structural support to the PIs
67  Abc_NtkForEachCi( pNtk, pNode, i )
68  Sim_SuppStrSetVar( vSuppStr, pNode, i );
69  // derive the structural supports of the internal nodes
70  Abc_NtkForEachNode( pNtk, pNode, i )
71  {
72 // if ( Abc_NodeIsConst(pNode) )
73 // continue;
74  pSimmNode = (unsigned *)vSuppStr->pArray[ pNode->Id ];
75  pSimmNode1 = (unsigned *)vSuppStr->pArray[ Abc_ObjFaninId0(pNode) ];
76  pSimmNode2 = (unsigned *)vSuppStr->pArray[ Abc_ObjFaninId1(pNode) ];
77  for ( k = 0; k < nSuppWords; k++ )
78  pSimmNode[k] = pSimmNode1[k] | pSimmNode2[k];
79  }
80  // set the structural supports of the PO nodes
81  Abc_NtkForEachCo( pNtk, pNode, i )
82  {
83  pSimmNode = (unsigned *)vSuppStr->pArray[ pNode->Id ];
84  pSimmNode1 = (unsigned *)vSuppStr->pArray[ Abc_ObjFaninId0(pNode) ];
85  for ( k = 0; k < nSuppWords; k++ )
86  pSimmNode[k] = pSimmNode1[k];
87  }
88  return vSuppStr;
89 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition: simUtils.c:57
#define SIM_NUM_WORDS(n)
MACRO DEFINITIONS ///.
Definition: sim.h:148
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_ObjFaninId1(Abc_Obj_t *pObj)
Definition: abc.h:368
#define Sim_SuppStrSetVar(vSupps, pNode, v)
Definition: sim.h:166
int Sim_ComputeTwoVarSymms ( Abc_Ntk_t pNtk,
int  fVerbose 
)

DECLARATIONS ///.

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

FileName [simSym.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Simulation to determine two-variable symmetries.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Computes two variable symmetries.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file simSym.c.

47 {
48  Sym_Man_t * p;
49  Vec_Ptr_t * vResult;
50  int Result;
51  int i;
52  abctime clk, clkTotal = Abc_Clock();
53 
54  srand( 0xABC );
55 
56  // start the simulation manager
57  p = Sym_ManStart( pNtk, fVerbose );
58  p->nPairsTotal = p->nPairsRem = Sim_UtilCountAllPairs( p->vSuppFun, p->nSimWords, p->vPairsTotal );
59  if ( fVerbose )
60  printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
61  p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
62 
63  // detect symmetries using circuit structure
64 clk = Abc_Clock();
65  Sim_SymmsStructCompute( pNtk, p->vMatrSymms, p->vSuppFun );
66 p->timeStruct = Abc_Clock() - clk;
67 
69  p->nPairsSymmStr = p->nPairsSymm;
70  if ( fVerbose )
71  printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
72  p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
73 
74  // detect symmetries using simulation
75  for ( i = 1; i <= 1000; i++ )
76  {
77  // simulate this pattern
78  Sim_UtilSetRandom( p->uPatRand, p->nSimWords );
79  Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
80  if ( i % 50 != 0 )
81  continue;
82  // check disjointness
84  // count the number of pairs
86  if ( i % 500 != 0 )
87  continue;
88  if ( fVerbose )
89  printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
90  p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
91  }
92 
93  // detect symmetries using SAT
94  for ( i = 1; Sim_SymmsGetPatternUsingSat( p, p->uPatRand ); i++ )
95  {
96  // simulate this pattern in four polarities
97  Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
98  Sim_XorBit( p->uPatRand, p->iVar1 );
99  Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
100  Sim_XorBit( p->uPatRand, p->iVar2 );
101  Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
102  Sim_XorBit( p->uPatRand, p->iVar1 );
103  Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
104  Sim_XorBit( p->uPatRand, p->iVar2 );
105 /*
106  // try the previuos pair
107  Sim_XorBit( p->uPatRand, p->iVar1Old );
108  Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
109  Sim_XorBit( p->uPatRand, p->iVar2Old );
110  Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
111  Sim_XorBit( p->uPatRand, p->iVar1Old );
112  Sim_SymmsSimulate( p, p->uPatRand, p->vMatrNonSymms );
113 */
114  if ( i % 10 != 0 )
115  continue;
116  // check disjointness
118  // count the number of pairs
120  if ( i % 50 != 0 )
121  continue;
122  if ( fVerbose )
123  printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
124  p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
125  }
126 
127  // count the number of pairs
129  if ( fVerbose )
130  printf( "Total = %8d. Sym = %8d. NonSym = %8d. Remaining = %8d.\n",
131  p->nPairsTotal, p->nPairsSymm, p->nPairsNonSymm, p->nPairsRem );
132 // Sim_UtilCountPairsAllPrint( p );
133 
134  Result = p->nPairsSymm;
135  vResult = p->vMatrSymms;
136 p->timeTotal = Abc_Clock() - clkTotal;
137  // p->vMatrSymms = NULL;
138  Sym_ManStop( p );
139  return Result;
140 }
int Sim_UtilCountAllPairs(Vec_Ptr_t *vSuppFun, int nSimWords, Vec_Int_t *vCounters)
Definition: simUtils.c:563
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Sym_ManStop(Sym_Man_t *p)
Definition: simMan.c:98
void Sim_UtilSetRandom(unsigned *pPatRand, int nSimWords)
Definition: simUtils.c:447
typedefABC_NAMESPACE_HEADER_START struct Sym_Man_t_ Sym_Man_t
INCLUDES ///.
Definition: sim.h:48
static abctime Abc_Clock()
Definition: abc_global.h:279
void Sim_SymmsStructCompute(Abc_Ntk_t *pNtk, Vec_Ptr_t *vMatrs, Vec_Ptr_t *vSuppFun)
FUNCTION DEFINITIONS ///.
Definition: simSymStr.c:61
int Sim_SymmsGetPatternUsingSat(Sym_Man_t *p, unsigned *pPattern)
FUNCTION DEFINITIONS ///.
Definition: simSymSat.c:51
void Sim_UtilCountPairsAll(Sym_Man_t *p)
Definition: simUtils.c:659
void Sim_SymmsSimulate(Sym_Man_t *p, unsigned *pPatRand, Vec_Ptr_t *vMatrsNonSym)
FUNCTION DEFINITIONS ///.
Definition: simSymSim.c:49
int Sim_UtilMatrsAreDisjoint(Sym_Man_t *p)
Definition: simUtils.c:703
#define Sim_XorBit(p, i)
Definition: sim.h:162
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
Sym_Man_t * Sym_ManStart(Abc_Ntk_t *pNtk, int fVerbose)
FUNCTION DECLARATIONS ///.
Definition: simMan.c:46
Sim_Pat_t* Sim_ManPatAlloc ( Sim_Man_t p)

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

Synopsis [Returns one simulation pattern.]

Description []

SideEffects []

SeeAlso []

Definition at line 261 of file simMan.c.

262 {
263  Sim_Pat_t * pPat;
264  pPat = (Sim_Pat_t *)Extra_MmFixedEntryFetch( p->pMmPat );
265  pPat->Output = -1;
266  pPat->pData = (unsigned *)((char *)pPat + sizeof(Sim_Pat_t));
267  memset( pPat->pData, 0, p->nSuppWords * sizeof(unsigned) );
268  return pPat;
269 }
char * memset()
int nSuppWords
Definition: sim.h:115
Extra_MmFixed_t * pMmPat
Definition: sim.h:122
struct Sim_Pat_t_ Sim_Pat_t
Definition: sim.h:136
unsigned * pData
Definition: sim.h:141
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
int Output
Definition: sim.h:140
void Sim_ManPatFree ( Sim_Man_t p,
Sim_Pat_t pPat 
)

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

Synopsis [Returns one simulation pattern.]

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file simMan.c.

283 {
284  Extra_MmFixedEntryRecycle( p->pMmPat, (char *)pPat );
285 }
Extra_MmFixed_t * pMmPat
Definition: sim.h:122
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
void Sim_ManPrintStats ( Sim_Man_t p)

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

Synopsis [Prints the manager statisticis.]

Description []

SideEffects []

SeeAlso []

Definition at line 233 of file simMan.c.

234 {
235 // printf( "Inputs = %5d. Outputs = %5d. Sim words = %5d.\n",
236 // Abc_NtkCiNum(p->pNtk), Abc_NtkCoNum(p->pNtk), p->nSimWords );
237  printf( "Total func supps = %8d.\n", Sim_UtilCountSuppSizes(p, 0) );
238  printf( "Total struct supps = %8d.\n", Sim_UtilCountSuppSizes(p, 1) );
239  printf( "Sat runs SAT = %8d.\n", p->nSatRunsSat );
240  printf( "Sat runs UNSAT = %8d.\n", p->nSatRunsUnsat );
241  ABC_PRT( "Simulation ", p->timeSim );
242  ABC_PRT( "Traversal ", p->timeTrav );
243  ABC_PRT( "Fraiging ", p->timeFraig );
244  ABC_PRT( "SAT ", p->timeSat );
245  ABC_PRT( "TOTAL ", p->timeTotal );
246 }
int Sim_UtilCountSuppSizes(Sim_Man_t *p, int fStruct)
Definition: simUtils.c:371
abctime timeSat
Definition: sim.h:132
int nSatRunsUnsat
Definition: sim.h:127
abctime timeTrav
Definition: sim.h:130
abctime timeTotal
Definition: sim.h:133
abctime timeSim
Definition: sim.h:129
abctime timeFraig
Definition: sim.h:131
int nSatRunsSat
Definition: sim.h:126
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Sim_Man_t* Sim_ManStart ( Abc_Ntk_t pNtk,
int  fLightweight 
)

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

Synopsis [Starts the simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 166 of file simMan.c.

167 {
168  Sim_Man_t * p;
169  // start the manager
170  p = ABC_ALLOC( Sim_Man_t, 1 );
171  memset( p, 0, sizeof(Sim_Man_t) );
172  p->pNtk = pNtk;
173  p->nInputs = Abc_NtkCiNum(p->pNtk);
174  p->nOutputs = Abc_NtkCoNum(p->pNtk);
175  // internal simulation information
176  p->nSimBits = 2048;
178  p->vSim0 = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSimWords, 0 );
179  p->fLightweight = fLightweight;
180  if (!p->fLightweight) {
181  p->vSim1 = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSimWords, 0 );
182  // support information
183  p->nSuppBits = Abc_NtkCiNum(pNtk);
185  p->vSuppStr = Sim_ComputeStrSupp( pNtk );
187  // other data
188  p->pMmPat = Extra_MmFixedStart( sizeof(Sim_Pat_t) + p->nSuppWords * sizeof(unsigned) );
189  p->vFifo = Vec_PtrAlloc( 100 );
190  p->vDiffs = Vec_IntAlloc( 100 );
191  // allocate support targets (array of unresolved outputs for each input)
192  p->vSuppTargs = Vec_VecStart( p->nInputs );
193  }
194  return p;
195 }
char * memset()
Vec_Ptr_t * vFifo
Definition: sim.h:123
int nSuppWords
Definition: sim.h:115
Vec_Ptr_t * vSuppFun
Definition: sim.h:117
Extra_MmFixed_t * pMmPat
Definition: sim.h:122
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nSimWords
Definition: sim.h:110
Vec_Int_t * vDiffs
Definition: sim.h:124
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
Vec_Ptr_t * Sim_ComputeStrSupp(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: simSupp.c:57
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition: simUtils.c:57
Vec_Ptr_t * vSuppStr
Definition: sim.h:116
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
Vec_Ptr_t * vSim1
Definition: sim.h:112
int fLightweight
Definition: sim.h:107
#define SIM_NUM_WORDS(n)
MACRO DEFINITIONS ///.
Definition: sim.h:148
int nSuppBits
Definition: sim.h:114
int nSimBits
Definition: sim.h:109
Vec_Ptr_t * vSim0
Definition: sim.h:111
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Vec_t * vSuppTargs
Definition: sim.h:119
Abc_Ntk_t * pNtk
Definition: sim.h:104
int nOutputs
Definition: sim.h:106
int nInputs
Definition: sim.h:105
void Sim_ManStop ( Sim_Man_t p)

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

Synopsis [Stops the simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 208 of file simMan.c.

209 {
210  Sim_ManPrintStats( p );
211  if ( p->vSim0 ) Sim_UtilInfoFree( p->vSim0 );
212  if ( p->vSim1 ) Sim_UtilInfoFree( p->vSim1 );
213  if ( p->vSuppStr ) Sim_UtilInfoFree( p->vSuppStr );
214 // if ( p->vSuppFun ) Sim_UtilInfoFree( p->vSuppFun );
215  if ( p->vSuppTargs ) Vec_VecFree( p->vSuppTargs );
216  if ( p->pMmPat ) Extra_MmFixedStop( p->pMmPat );
217  if ( p->vFifo ) Vec_PtrFree( p->vFifo );
218  if ( p->vDiffs ) Vec_IntFree( p->vDiffs );
219  ABC_FREE( p );
220 }
Vec_Ptr_t * vFifo
Definition: sim.h:123
Extra_MmFixed_t * pMmPat
Definition: sim.h:122
void Extra_MmFixedStop(Extra_MmFixed_t *p)
Vec_Int_t * vDiffs
Definition: sim.h:124
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
void Sim_UtilInfoFree(Vec_Ptr_t *p)
Definition: simUtils.c:83
Vec_Ptr_t * vSuppStr
Definition: sim.h:116
void Sim_ManPrintStats(Sim_Man_t *p)
Definition: simMan.c:233
Vec_Ptr_t * vSim1
Definition: sim.h:112
Vec_Ptr_t * vSim0
Definition: sim.h:111
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Vec_t * vSuppTargs
Definition: sim.h:119
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Vec_Ptr_t* Sim_SimulateSeqModel ( Abc_Ntk_t pNtk,
int  nFrames,
int *  pModel 
)

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

Synopsis [Simulates sequential circuit.]

Description [Takes sequential circuit (pNtk). Simulates the given number (nFrames) of the circuit with the given model. The model is assumed to contain values of PIs for each frame. The latches are initialized to the initial state. One word of data is simulated.]

SideEffects []

SeeAlso []

Definition at line 92 of file simSeq.c.

93 {
94  Vec_Ptr_t * vInfo;
95  Abc_Obj_t * pNode;
96  unsigned * pUnsigned;
97  int i, k;
98  vInfo = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), nFrames, 0 );
99  // set the constant data
100  pNode = Abc_AigConst1(pNtk);
101  Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nFrames, 1 );
102  // set the random PI data
103  Abc_NtkForEachPi( pNtk, pNode, i )
104  {
105  pUnsigned = Sim_SimInfoGet(vInfo,pNode);
106  for ( k = 0; k < nFrames; k++ )
107  pUnsigned[k] = pModel[k * Abc_NtkPiNum(pNtk) + i] ? ~((unsigned)0) : 0;
108  }
109  // set the initial state data
110  Abc_NtkForEachLatch( pNtk, pNode, i )
111  {
112  pUnsigned = Sim_SimInfoGet(vInfo,pNode);
113  if ( Abc_LatchIsInit0(pNode) )
114  pUnsigned[0] = 0;
115  else if ( Abc_LatchIsInit1(pNode) )
116  pUnsigned[0] = ~((unsigned)0);
117  else
118  pUnsigned[0] = SIM_RANDOM_UNSIGNED;
119  }
120  // simulate the nodes for the given number of timeframes
121  for ( i = 0; i < nFrames; i++ )
122  Sim_SimulateSeqFrame( vInfo, pNtk, i, 1, (int)(i < nFrames-1) );
123 /*
124  // print the simulated values
125  for ( i = 0; i < nFrames; i++ )
126  {
127  printf( "Frame %d : ", i+1 );
128  Abc_NtkForEachPi( pNtk, pNode, k )
129  printf( "%d", Sim_SimInfoGet(vInfo,pNode)[i] > 0 );
130  printf( " " );
131  Abc_NtkForEachLatch( pNtk, pNode, k )
132  printf( "%d", Sim_SimInfoGet(vInfo,pNode)[i] > 0 );
133  printf( " " );
134  Abc_NtkForEachPo( pNtk, pNode, k )
135  printf( "%d", Sim_SimInfoGet(vInfo,pNode)[i] > 0 );
136  printf( "\n" );
137  }
138  printf( "\n" );
139 */
140  return vInfo;
141 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
#define Sim_SimInfoGet(vInfo, pNode)
Definition: sim.h:172
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
#define SIM_RANDOM_UNSIGNED
Definition: sim.h:158
static int Abc_LatchIsInit0(Abc_Obj_t *pLatch)
Definition: abc.h:422
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition: simUtils.c:57
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
void Sim_UtilSetConst(unsigned *pPatRand, int nSimWords, int fConst1)
Definition: simUtils.c:483
static ABC_NAMESPACE_IMPL_START void Sim_SimulateSeqFrame(Vec_Ptr_t *vInfo, Abc_Ntk_t *pNtk, int iFrames, int nWords, int fTransfer)
DECLARATIONS ///.
Definition: simSeq.c:155
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
Vec_Ptr_t* Sim_SimulateSeqRandom ( Abc_Ntk_t pNtk,
int  nFrames,
int  nWords 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Simulates sequential circuit.]

Description [Takes sequential circuit (pNtk). Simulates the given number (nFrames) of the circuit with the given number of machine words (nWords) of random simulation data, starting from the initial state. If the initial state of some latches is a don't-care, uses random input for that latch.]

SideEffects []

SeeAlso []

Definition at line 51 of file simSeq.c.

52 {
53  Vec_Ptr_t * vInfo;
54  Abc_Obj_t * pNode;
55  int i;
56  assert( Abc_NtkIsStrash(pNtk) );
57  vInfo = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), nWords * nFrames, 0 );
58  // set the constant data
59  pNode = Abc_AigConst1(pNtk);
60  Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nWords * nFrames, 1 );
61  // set the random PI data
62  Abc_NtkForEachPi( pNtk, pNode, i )
63  Sim_UtilSetRandom( Sim_SimInfoGet(vInfo,pNode), nWords * nFrames );
64  // set the initial state data
65  Abc_NtkForEachLatch( pNtk, pNode, i )
66  if ( Abc_LatchIsInit0(pNode) )
67  Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nWords, 0 );
68  else if ( Abc_LatchIsInit1(pNode) )
69  Sim_UtilSetConst( Sim_SimInfoGet(vInfo,pNode), nWords, 1 );
70  else
71  Sim_UtilSetRandom( Sim_SimInfoGet(vInfo,pNode), nWords );
72  // simulate the nodes for the given number of timeframes
73  for ( i = 0; i < nFrames; i++ )
74  Sim_SimulateSeqFrame( vInfo, pNtk, i, nWords, (int)(i < nFrames-1) );
75  return vInfo;
76 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
#define Sim_SimInfoGet(vInfo, pNode)
Definition: sim.h:172
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
void Sim_UtilSetRandom(unsigned *pPatRand, int nSimWords)
Definition: simUtils.c:447
static int Abc_LatchIsInit0(Abc_Obj_t *pLatch)
Definition: abc.h:422
int nWords
Definition: abcNpn.c:127
for(p=first;p->value< newval;p=p->next)
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition: simUtils.c:57
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
void Sim_UtilSetConst(unsigned *pPatRand, int nSimWords, int fConst1)
Definition: simUtils.c:483
#define assert(ex)
Definition: util_old.h:213
static ABC_NAMESPACE_IMPL_START void Sim_SimulateSeqFrame(Vec_Ptr_t *vInfo, Abc_Ntk_t *pNtk, int iFrames, int nWords, int fTransfer)
DECLARATIONS ///.
Definition: simSeq.c:155
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
int Sim_SymmsGetPatternUsingSat ( Sym_Man_t p,
unsigned *  pPattern 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Tries to prove the remaining pairs using SAT.]

Description [Continues to prove as long as it encounters symmetric pairs. Returns 1 if a non-symmetric pair is found (which gives a counter-example). Returns 0 if it finishes considering all pairs for all outputs.]

SideEffects []

SeeAlso []

Definition at line 51 of file simSymSat.c.

52 {
53  Vec_Int_t * vSupport;
54  Extra_BitMat_t * pMatSym, * pMatNonSym;
55  int Index1, Index2, Index3, IndexU, IndexV;
56  int v, u, i, k, b, out;
57 
58  // iterate through outputs
59  for ( out = p->iOutput; out < p->nOutputs; out++ )
60  {
61  pMatSym = (Extra_BitMat_t *)Vec_PtrEntry( p->vMatrSymms, out );
62  pMatNonSym = (Extra_BitMat_t *)Vec_PtrEntry( p->vMatrNonSymms, out );
63 
64  // go through the remaining variable pairs
65  vSupport = Vec_VecEntryInt( p->vSupports, out );
66  Vec_IntForEachEntry( vSupport, v, Index1 )
67  Vec_IntForEachEntryStart( vSupport, u, Index2, Index1+1 )
68  {
69  if ( Extra_BitMatrixLookup1( pMatSym, v, u ) || Extra_BitMatrixLookup1( pMatNonSym, v, u ) )
70  continue;
71  p->nSatRuns++;
72 
73  // collect the support variables that are symmetric with u and v
74  Vec_IntClear( p->vVarsU );
75  Vec_IntClear( p->vVarsV );
76  Vec_IntForEachEntry( vSupport, b, Index3 )
77  {
78  if ( Extra_BitMatrixLookup1( pMatSym, u, b ) )
79  Vec_IntPush( p->vVarsU, b );
80  if ( Extra_BitMatrixLookup1( pMatSym, v, b ) )
81  Vec_IntPush( p->vVarsV, b );
82  }
83 
84  if ( Sim_SymmsSatProveOne( p, out, v, u, pPattern ) )
85  { // update the symmetric variable info
86  p->nSatRunsUnsat++;
87  Vec_IntForEachEntry( p->vVarsU, i, IndexU )
88  Vec_IntForEachEntry( p->vVarsV, k, IndexV )
89  {
90  Extra_BitMatrixInsert1( pMatSym, i, k ); // Theorem 1
91  Extra_BitMatrixInsert2( pMatSym, i, k ); // Theorem 1
92  Extra_BitMatrixOrTwo( pMatNonSym, i, k ); // Theorem 2
93  }
94  }
95  else
96  { // update the assymmetric variable info
97  p->nSatRunsSat++;
98  Vec_IntForEachEntry( p->vVarsU, i, IndexU )
99  Vec_IntForEachEntry( p->vVarsV, k, IndexV )
100  {
101  Extra_BitMatrixInsert1( pMatNonSym, i, k ); // Theorem 3
102  Extra_BitMatrixInsert2( pMatNonSym, i, k ); // Theorem 3
103  }
104 
105  // remember the out
106  p->iOutput = out;
107  p->iVar1Old = p->iVar1;
108  p->iVar2Old = p->iVar2;
109  p->iVar1 = v;
110  p->iVar2 = u;
111  return 1;
112 
113  }
114  }
115  // make sure that the symmetry matrix contains only cliques
116  assert( Extra_BitMatrixIsClique( pMatSym ) );
117  }
118 
119  // mark that we finished all outputs
120  p->iOutput = p->nOutputs;
121  return 0;
122 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Extra_BitMatrixInsert2(Extra_BitMat_t *p, int i, int k)
int Extra_BitMatrixLookup1(Extra_BitMat_t *p, int i, int k)
static ABC_NAMESPACE_IMPL_START int Sim_SymmsSatProveOne(Sym_Man_t *p, int Out, int Var1, int Var2, unsigned *pPattern)
DECLARATIONS ///.
Definition: simSymSat.c:135
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
int Extra_BitMatrixIsClique(Extra_BitMat_t *p)
static Vec_Int_t * Vec_VecEntryInt(Vec_Vec_t *p, int i)
Definition: vecVec.h:276
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
void Extra_BitMatrixOrTwo(Extra_BitMat_t *p, int i, int j)
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void Extra_BitMatrixInsert1(Extra_BitMat_t *p, int i, int k)
void Sim_SymmsSimulate ( Sym_Man_t p,
unsigned *  pPat,
Vec_Ptr_t vMatrsNonSym 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Detects non-symmetric pairs using one pattern.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file simSymSim.c.

50 {
51  Abc_Obj_t * pNode;
52  int i, nPairsTotal, nPairsSym, nPairsNonSym;
53  abctime clk;
54 
55  // create the simulation matrix
56  Sim_SymmsCreateSquare( p, pPat );
57  // simulate each node in the DFS order
58 clk = Abc_Clock();
59  Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pNode, i )
60  {
61 // if ( Abc_NodeIsConst(pNode) )
62 // continue;
63  Sim_UtilSimulateNodeOne( pNode, p->vSim, p->nSimWords, 0 );
64  }
65 p->timeSim += Abc_Clock() - clk;
66  // collect info into the CO matrices
67 clk = Abc_Clock();
68  Abc_NtkForEachCo( p->pNtk, pNode, i )
69  {
70  pNode = Abc_ObjFanin0(pNode);
71 // if ( Abc_ObjIsCi(pNode) || Abc_AigNodeIsConst(pNode) )
72 // continue;
73  nPairsTotal = Vec_IntEntry(p->vPairsTotal, i);
74  nPairsSym = Vec_IntEntry(p->vPairsSym, i);
75  nPairsNonSym = Vec_IntEntry(p->vPairsNonSym,i);
76  assert( nPairsTotal >= nPairsSym + nPairsNonSym );
77  if ( nPairsTotal == nPairsSym + nPairsNonSym )
78  continue;
79  Sim_SymmsDeriveInfo( p, pPat, pNode, vMatrsNonSym, i );
80  }
81 p->timeMatr += Abc_Clock() - clk;
82 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static abctime Abc_Clock()
Definition: abc_global.h:279
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
void Sim_UtilSimulateNodeOne(Abc_Obj_t *pNode, Vec_Ptr_t *vSimInfo, int nSimWords, int nOffset)
Definition: simUtils.c:302
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static ABC_NAMESPACE_IMPL_START void Sim_SymmsCreateSquare(Sym_Man_t *p, unsigned *pPat)
DECLARATIONS ///.
Definition: simSymSim.c:95
static void Sim_SymmsDeriveInfo(Sym_Man_t *p, unsigned *pPat, Abc_Obj_t *pNode, Vec_Ptr_t *vMatrsNonSym, int Output)
Definition: simSymSim.c:130
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
void Sim_SymmsStructCompute ( Abc_Ntk_t pNtk,
Vec_Ptr_t vMatrs,
Vec_Ptr_t vSuppFun 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Computes symmetries for a single output function.]

Description []

SideEffects []

SeeAlso []

Definition at line 61 of file simSymStr.c.

62 {
63  Vec_Ptr_t * vNodes;
64  Abc_Obj_t * pTemp;
65  int * pMap, i;
66 
67  assert( Abc_NtkCiNum(pNtk) + 10 < (1<<16) );
68 
69  // get the structural support
70  pNtk->vSupps = Sim_ComputeStrSupp( pNtk );
71  // set elementary info for the CIs
72  Abc_NtkForEachCi( pNtk, pTemp, i )
73  SIM_SET_SYMMS( pTemp, Vec_IntAlloc(0) );
74  // create the map of CI ids into their numbers
75  pMap = Sim_SymmsCreateMap( pNtk );
76  // collect the nodes in the TFI cone of this output
77  vNodes = Abc_NtkDfs( pNtk, 0 );
78  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pTemp, i )
79  {
80 // if ( Abc_NodeIsConst(pTemp) )
81 // continue;
82  Sim_SymmsStructComputeOne( pNtk, pTemp, pMap );
83  }
84  // collect the results for the COs;
85  Abc_NtkForEachCo( pNtk, pTemp, i )
86  {
87 //printf( "Output %d:\n", i );
88  pTemp = Abc_ObjFanin0(pTemp);
89  if ( Abc_ObjIsCi(pTemp) || Abc_AigNodeIsConst(pTemp) )
90  continue;
91  Sim_SymmsTransferToMatrix( (Extra_BitMat_t *)Vec_PtrEntry(vMatrs, i), SIM_READ_SYMMS(pTemp), (unsigned *)Vec_PtrEntry(vSuppFun, i) );
92  }
93  // clean the intermediate results
94  Sim_UtilInfoFree( pNtk->vSupps );
95  pNtk->vSupps = NULL;
96  Abc_NtkForEachCi( pNtk, pTemp, i )
97  Vec_IntFree( SIM_READ_SYMMS(pTemp) );
98  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pTemp, i )
99 // if ( !Abc_NodeIsConst(pTemp) )
100  Vec_IntFree( SIM_READ_SYMMS(pTemp) );
101  Vec_PtrFree( vNodes );
102  ABC_FREE( pMap );
103 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
#define SIM_SET_SYMMS(pNode, vVect)
Definition: simSymStr.c:32
static void Sim_SymmsStructComputeOne(Abc_Ntk_t *pNtk, Abc_Obj_t *pNode, int *pMap)
Definition: simSymStr.c:116
#define SIM_READ_SYMMS(pNode)
DECLARATIONS ///.
Definition: simSymStr.c:31
static int Abc_AigNodeIsConst(Abc_Obj_t *pNode)
Definition: abc.h:396
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static void Sim_SymmsTransferToMatrix(Extra_BitMat_t *pMatSymm, Vec_Int_t *vSymms, unsigned *pSupport)
Definition: simSymStr.c:437
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
Vec_Ptr_t * Sim_ComputeStrSupp(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: simSupp.c:57
void Sim_UtilInfoFree(Vec_Ptr_t *p)
Definition: simUtils.c:83
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Vec_Ptr_t * vSupps
Definition: abc.h:197
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
static int * Sim_SymmsCreateMap(Abc_Ntk_t *pNtk)
Definition: simSymStr.c:472
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Sim_UtilCountAllPairs ( Vec_Ptr_t vSuppFun,
int  nSimWords,
Vec_Int_t vCounters 
)

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

Synopsis [Counts the total number of pairs.]

Description []

SideEffects []

SeeAlso []

Definition at line 563 of file simUtils.c.

564 {
565  unsigned * pSupp;
566  int Counter, nOnes, nPairs, i;
567  Counter = 0;
568  Vec_PtrForEachEntry( unsigned *, vSuppFun, pSupp, i )
569  {
570  nOnes = Sim_UtilCountOnes( pSupp, nSimWords );
571  nPairs = nOnes * (nOnes - 1) / 2;
572  Vec_IntWriteEntry( vCounters, i, nPairs );
573  Counter += nPairs;
574  }
575  return Counter;
576 }
int Sim_UtilCountOnes(unsigned *pSimInfo, int nSimWords)
Definition: simUtils.c:402
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Counter
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Sim_UtilCountOnes ( unsigned *  pSimInfo,
int  nSimWords 
)

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

Synopsis [Counts the number of 1's in the bitstring.]

Description []

SideEffects []

SeeAlso []

Definition at line 402 of file simUtils.c.

403 {
404  unsigned char * pBytes;
405  int nOnes, nBytes, i;
406  pBytes = (unsigned char *)pSimInfo;
407  nBytes = 4 * nSimWords;
408  nOnes = 0;
409  for ( i = 0; i < nBytes; i++ )
410  nOnes += bit_count[ pBytes[i] ];
411  return nOnes;
412 }
static ABC_NAMESPACE_IMPL_START int bit_count[256]
DECLARATIONS ///.
Definition: simUtils.c:31
Vec_Int_t* Sim_UtilCountOnesArray ( Vec_Ptr_t vInfo,
int  nSimWords 
)

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

Synopsis [Counts the number of 1's in the bitstring.]

Description []

SideEffects []

SeeAlso []

Definition at line 425 of file simUtils.c.

426 {
427  Vec_Int_t * vCounters;
428  unsigned * pSimInfo;
429  int i;
430  vCounters = Vec_IntStart( Vec_PtrSize(vInfo) );
431  Vec_PtrForEachEntry( unsigned *, vInfo, pSimInfo, i )
432  Vec_IntWriteEntry( vCounters, i, Sim_UtilCountOnes(pSimInfo, nSimWords) );
433  return vCounters;
434 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Sim_UtilCountOnes(unsigned *pSimInfo, int nSimWords)
Definition: simUtils.c:402
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void Sim_UtilCountPairsAll ( Sym_Man_t p)

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

Synopsis [Counts the number of entries in the array of matrices.]

Description []

SideEffects []

SeeAlso []

Definition at line 659 of file simUtils.c.

660 {
661  int nPairsTotal, nPairsSym, nPairsNonSym, i;
662  abctime clk;
663 clk = Abc_Clock();
664  p->nPairsSymm = 0;
665  p->nPairsNonSymm = 0;
666  for ( i = 0; i < p->nOutputs; i++ )
667  {
668  nPairsTotal = Vec_IntEntry(p->vPairsTotal, i);
669  nPairsSym = Vec_IntEntry(p->vPairsSym, i);
670  nPairsNonSym = Vec_IntEntry(p->vPairsNonSym,i);
671  assert( nPairsTotal >= nPairsSym + nPairsNonSym );
672  if ( nPairsTotal == nPairsSym + nPairsNonSym )
673  {
674  p->nPairsSymm += nPairsSym;
675  p->nPairsNonSymm += nPairsNonSym;
676  continue;
677  }
678  nPairsSym = Sim_UtilCountPairsOne( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrSymms, i), Vec_VecEntryInt(p->vSupports, i) );
679  nPairsNonSym = Sim_UtilCountPairsOne( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrNonSymms,i), Vec_VecEntryInt(p->vSupports, i) );
680  assert( nPairsTotal >= nPairsSym + nPairsNonSym );
681  Vec_IntWriteEntry( p->vPairsSym, i, nPairsSym );
682  Vec_IntWriteEntry( p->vPairsNonSym, i, nPairsNonSym );
683  p->nPairsSymm += nPairsSym;
684  p->nPairsNonSymm += nPairsNonSym;
685 // printf( "%d ", nPairsTotal - nPairsSym - nPairsNonSym );
686  }
687 //printf( "\n" );
688  p->nPairsRem = p->nPairsTotal-p->nPairsSymm-p->nPairsNonSymm;
689 p->timeCount += Abc_Clock() - clk;
690 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static Vec_Int_t * Vec_VecEntryInt(Vec_Vec_t *p, int i)
Definition: vecVec.h:276
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
int Sim_UtilCountPairsOne(Extra_BitMat_t *pMat, Vec_Int_t *vSupport)
Definition: simUtils.c:589
int Sim_UtilCountSuppSizes ( Sim_Man_t p,
int  fStruct 
)

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

Synopsis [Returns 1 if the simulation infos are equal.]

Description []

SideEffects []

SeeAlso []

Definition at line 371 of file simUtils.c.

372 {
373  Abc_Obj_t * pNode, * pNodeCi;
374  int i, v, Counter;
375  Counter = 0;
376  if ( fStruct )
377  {
378  Abc_NtkForEachCo( p->pNtk, pNode, i )
379  Abc_NtkForEachCi( p->pNtk, pNodeCi, v )
380  Counter += Sim_SuppStrHasVar( p->vSuppStr, pNode, v );
381  }
382  else
383  {
384  Abc_NtkForEachCo( p->pNtk, pNode, i )
385  Abc_NtkForEachCi( p->pNtk, pNodeCi, v )
386  Counter += Sim_SuppFunHasVar( p->vSuppFun, i, v );
387  }
388  return Counter;
389 }
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
else
Definition: sparse_int.h:55
static int Counter
#define Sim_SuppStrHasVar(vSupps, pNode, v)
Definition: sim.h:167
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
Abc_Ntk_t * pNtk
Definition: sim.h:104
#define Sim_SuppFunHasVar(vSupps, Output, v)
Definition: sim.h:169
void Sim_UtilInfoAdd ( unsigned *  pInfo1,
unsigned *  pInfo2,
int  nWords 
)

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

Synopsis [Adds the second supp-info the first.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file simUtils.c.

101 {
102  int w;
103  for ( w = 0; w < nWords; w++ )
104  pInfo1[w] |= pInfo2[w];
105 }
int nWords
Definition: abcNpn.c:127
Vec_Ptr_t* Sim_UtilInfoAlloc ( int  nSize,
int  nWords,
int  fClean 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates simulation information for all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 57 of file simUtils.c.

58 {
59  Vec_Ptr_t * vInfo;
60  int i;
61  assert( nSize > 0 && nWords > 0 );
62  vInfo = Vec_PtrAlloc( nSize );
63  vInfo->pArray[0] = ABC_ALLOC( unsigned, nSize * nWords );
64  if ( fClean )
65  memset( vInfo->pArray[0], 0, sizeof(unsigned) * nSize * nWords );
66  for ( i = 1; i < nSize; i++ )
67  vInfo->pArray[i] = ((unsigned *)vInfo->pArray[i-1]) + nWords;
68  vInfo->nSize = nSize;
69  return vInfo;
70 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nWords
Definition: abcNpn.c:127
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
int Sim_UtilInfoCompare ( Sim_Man_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Returns 1 if the simulation infos are equal.]

Description []

SideEffects []

SeeAlso []

Definition at line 185 of file simUtils.c.

186 {
187  unsigned * pSimInfo1, * pSimInfo2;
188  int k;
189  pSimInfo1 = (unsigned *)p->vSim0->pArray[pNode->Id];
190  pSimInfo2 = (unsigned *)p->vSim1->pArray[pNode->Id];
191  for ( k = 0; k < p->nSimWords; k++ )
192  if ( pSimInfo2[k] != pSimInfo1[k] )
193  return 0;
194  return 1;
195 }
int nSimWords
Definition: sim.h:110
Vec_Ptr_t * vSim1
Definition: sim.h:112
Vec_Ptr_t * vSim0
Definition: sim.h:111
int Id
Definition: abc.h:132
void Sim_UtilInfoDetectDiffs ( unsigned *  pInfo1,
unsigned *  pInfo2,
int  nWords,
Vec_Int_t vDiffs 
)

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

Synopsis [Returns the positions where pInfo2 is 1 while pInfo1 is 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 118 of file simUtils.c.

119 {
120  int w, b;
121  unsigned uMask;
122  vDiffs->nSize = 0;
123  for ( w = 0; w < nWords; w++ )
124  if ( (uMask = (pInfo2[w] ^ pInfo1[w])) )
125  for ( b = 0; b < 32; b++ )
126  if ( uMask & (1 << b) )
127  Vec_IntPush( vDiffs, 32*w + b );
128 }
int nWords
Definition: abcNpn.c:127
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Sim_UtilInfoDetectNews ( unsigned *  pInfo1,
unsigned *  pInfo2,
int  nWords,
Vec_Int_t vDiffs 
)

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

Synopsis [Returns the positions where pInfo2 is 1 while pInfo1 is 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 141 of file simUtils.c.

142 {
143  int w, b;
144  unsigned uMask;
145  vDiffs->nSize = 0;
146  for ( w = 0; w < nWords; w++ )
147  if ( (uMask = (pInfo2[w] & ~pInfo1[w])) )
148  for ( b = 0; b < 32; b++ )
149  if ( uMask & (1 << b) )
150  Vec_IntPush( vDiffs, 32*w + b );
151 }
int nWords
Definition: abcNpn.c:127
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Sim_UtilInfoFlip ( Sim_Man_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Flips the simulation info of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file simUtils.c.

165 {
166  unsigned * pSimInfo1, * pSimInfo2;
167  int k;
168  pSimInfo1 = (unsigned *)p->vSim0->pArray[pNode->Id];
169  pSimInfo2 = (unsigned *)p->vSim1->pArray[pNode->Id];
170  for ( k = 0; k < p->nSimWords; k++ )
171  pSimInfo2[k] = ~pSimInfo1[k];
172 }
int nSimWords
Definition: sim.h:110
Vec_Ptr_t * vSim1
Definition: sim.h:112
Vec_Ptr_t * vSim0
Definition: sim.h:111
int Id
Definition: abc.h:132
void Sim_UtilInfoFree ( Vec_Ptr_t p)

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

Synopsis [Allocates simulation information for all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file simUtils.c.

84 {
85  ABC_FREE( p->pArray[0] );
86  Vec_PtrFree( p );
87 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Sim_UtilInfoIsClause ( unsigned *  pPats1,
unsigned *  pPats2,
int  nSimWords 
)

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

Synopsis [Returns 1 if Node1 v Node2 is always true.]

Description []

SideEffects []

SeeAlso []

Definition at line 543 of file simUtils.c.

544 {
545  int k;
546  for ( k = 0; k < nSimWords; k++ )
547  if ( ~pPats1[k] & ~pPats2[k] )
548  return 0;
549  return 1;
550 }
int Sim_UtilInfoIsEqual ( unsigned *  pPats1,
unsigned *  pPats2,
int  nSimWords 
)

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

Synopsis [Returns 1 if equal.]

Description []

SideEffects []

SeeAlso []

Definition at line 503 of file simUtils.c.

504 {
505  int k;
506  for ( k = 0; k < nSimWords; k++ )
507  if ( pPats1[k] != pPats2[k] )
508  return 0;
509  return 1;
510 }
int Sim_UtilInfoIsImp ( unsigned *  pPats1,
unsigned *  pPats2,
int  nSimWords 
)

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

Synopsis [Returns 1 if Node1 implies Node2.]

Description []

SideEffects []

SeeAlso []

Definition at line 523 of file simUtils.c.

524 {
525  int k;
526  for ( k = 0; k < nSimWords; k++ )
527  if ( pPats1[k] & ~pPats2[k] )
528  return 0;
529  return 1;
530 }
int Sim_UtilMatrsAreDisjoint ( Sym_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 703 of file simUtils.c.

704 {
705  int i;
706  for ( i = 0; i < p->nOutputs; i++ )
707  if ( !Extra_BitMatrixIsDisjoint( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrSymms,i), (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrNonSymms,i) ) )
708  return 0;
709  return 1;
710 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Extra_BitMatrixIsDisjoint(Extra_BitMat_t *p1, Extra_BitMat_t *p2)
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
void Sim_UtilSetCompl ( unsigned *  pPatRand,
int  nSimWords 
)

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

Synopsis [Returns complemented patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 465 of file simUtils.c.

466 {
467  int k;
468  for ( k = 0; k < nSimWords; k++ )
469  pPatRand[k] = ~pPatRand[k];
470 }
void Sim_UtilSetConst ( unsigned *  pPatRand,
int  nSimWords,
int  fConst1 
)

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

Synopsis [Returns constant patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 483 of file simUtils.c.

484 {
485  int k;
486  for ( k = 0; k < nSimWords; k++ )
487  pPatRand[k] = 0;
488  if ( fConst1 )
489  Sim_UtilSetCompl( pPatRand, nSimWords );
490 }
void Sim_UtilSetCompl(unsigned *pPatRand, int nSimWords)
Definition: simUtils.c:465
void Sim_UtilSetRandom ( unsigned *  pPatRand,
int  nSimWords 
)

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

Synopsis [Returns random patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 447 of file simUtils.c.

448 {
449  int k;
450  for ( k = 0; k < nSimWords; k++ )
451  pPatRand[k] = SIM_RANDOM_UNSIGNED;
452 }
#define SIM_RANDOM_UNSIGNED
Definition: sim.h:158
void Sim_UtilSimulate ( Sim_Man_t p,
int  fType 
)

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

Synopsis [Simulates the internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 208 of file simUtils.c.

209 {
210  Abc_Obj_t * pNode;
211  int i;
212  // simulate the internal nodes
213  Abc_NtkForEachNode( p->pNtk, pNode, i )
214  Sim_UtilSimulateNode( p, pNode, fType, fType, fType );
215  // assign simulation info of the CO nodes
216  Abc_NtkForEachCo( p->pNtk, pNode, i )
217  Sim_UtilSimulateNode( p, pNode, fType, fType, fType );
218 }
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
void Sim_UtilSimulateNode(Sim_Man_t *p, Abc_Obj_t *pNode, int fType, int fType1, int fType2)
Definition: simUtils.c:231
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
Abc_Ntk_t * pNtk
Definition: sim.h:104
void Sim_UtilSimulateNode ( Sim_Man_t p,
Abc_Obj_t pNode,
int  fType,
int  fType1,
int  fType2 
)

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

Synopsis [Simulates one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 231 of file simUtils.c.

232 {
233  unsigned * pSimmNode, * pSimmNode1, * pSimmNode2;
234  int k, fComp1, fComp2;
235  // simulate the internal nodes
236  if ( Abc_ObjIsNode(pNode) )
237  {
238  if ( fType )
239  pSimmNode = (unsigned *)p->vSim1->pArray[ pNode->Id ];
240  else
241  pSimmNode = (unsigned *)p->vSim0->pArray[ pNode->Id ];
242 
243  if ( fType1 )
244  pSimmNode1 = (unsigned *)p->vSim1->pArray[ Abc_ObjFaninId0(pNode) ];
245  else
246  pSimmNode1 = (unsigned *)p->vSim0->pArray[ Abc_ObjFaninId0(pNode) ];
247 
248  if ( fType2 )
249  pSimmNode2 = (unsigned *)p->vSim1->pArray[ Abc_ObjFaninId1(pNode) ];
250  else
251  pSimmNode2 = (unsigned *)p->vSim0->pArray[ Abc_ObjFaninId1(pNode) ];
252 
253  fComp1 = Abc_ObjFaninC0(pNode);
254  fComp2 = Abc_ObjFaninC1(pNode);
255  if ( fComp1 && fComp2 )
256  for ( k = 0; k < p->nSimWords; k++ )
257  pSimmNode[k] = ~pSimmNode1[k] & ~pSimmNode2[k];
258  else if ( fComp1 && !fComp2 )
259  for ( k = 0; k < p->nSimWords; k++ )
260  pSimmNode[k] = ~pSimmNode1[k] & pSimmNode2[k];
261  else if ( !fComp1 && fComp2 )
262  for ( k = 0; k < p->nSimWords; k++ )
263  pSimmNode[k] = pSimmNode1[k] & ~pSimmNode2[k];
264  else // if ( fComp1 && fComp2 )
265  for ( k = 0; k < p->nSimWords; k++ )
266  pSimmNode[k] = pSimmNode1[k] & pSimmNode2[k];
267  }
268  else
269  {
270  assert( Abc_ObjFaninNum(pNode) == 1 );
271  if ( fType )
272  pSimmNode = (unsigned *)p->vSim1->pArray[ pNode->Id ];
273  else
274  pSimmNode = (unsigned *)p->vSim0->pArray[ pNode->Id ];
275 
276  if ( fType1 )
277  pSimmNode1 = (unsigned *)p->vSim1->pArray[ Abc_ObjFaninId0(pNode) ];
278  else
279  pSimmNode1 = (unsigned *)p->vSim0->pArray[ Abc_ObjFaninId0(pNode) ];
280 
281  fComp1 = Abc_ObjFaninC0(pNode);
282  if ( fComp1 )
283  for ( k = 0; k < p->nSimWords; k++ )
284  pSimmNode[k] = ~pSimmNode1[k];
285  else
286  for ( k = 0; k < p->nSimWords; k++ )
287  pSimmNode[k] = pSimmNode1[k];
288  }
289 }
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
int nSimWords
Definition: sim.h:110
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Vec_Ptr_t * vSim1
Definition: sim.h:112
Vec_Ptr_t * vSim0
Definition: sim.h:111
int Id
Definition: abc.h:132
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjFaninId1(Abc_Obj_t *pObj)
Definition: abc.h:368
void Sim_UtilSimulateNodeOne ( Abc_Obj_t pNode,
Vec_Ptr_t vSimInfo,
int  nSimWords,
int  nOffset 
)

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

Synopsis [Simulates one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 302 of file simUtils.c.

303 {
304  unsigned * pSimmNode, * pSimmNode1, * pSimmNode2;
305  int k, fComp1, fComp2;
306  // simulate the internal nodes
307  assert( Abc_ObjIsNode(pNode) );
308  pSimmNode = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
309  pSimmNode1 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
310  pSimmNode2 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId1(pNode));
311  pSimmNode += nOffset;
312  pSimmNode1 += nOffset;
313  pSimmNode2 += nOffset;
314  fComp1 = Abc_ObjFaninC0(pNode);
315  fComp2 = Abc_ObjFaninC1(pNode);
316  if ( fComp1 && fComp2 )
317  for ( k = 0; k < nSimWords; k++ )
318  pSimmNode[k] = ~pSimmNode1[k] & ~pSimmNode2[k];
319  else if ( fComp1 && !fComp2 )
320  for ( k = 0; k < nSimWords; k++ )
321  pSimmNode[k] = ~pSimmNode1[k] & pSimmNode2[k];
322  else if ( !fComp1 && fComp2 )
323  for ( k = 0; k < nSimWords; k++ )
324  pSimmNode[k] = pSimmNode1[k] & ~pSimmNode2[k];
325  else // if ( fComp1 && fComp2 )
326  for ( k = 0; k < nSimWords; k++ )
327  pSimmNode[k] = pSimmNode1[k] & pSimmNode2[k];
328 }
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int Id
Definition: abc.h:132
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjFaninId1(Abc_Obj_t *pObj)
Definition: abc.h:368
void Sim_UtilTransferNodeOne ( Abc_Obj_t pNode,
Vec_Ptr_t vSimInfo,
int  nSimWords,
int  nOffset,
int  fShift 
)

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

Synopsis [Simulates one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 341 of file simUtils.c.

342 {
343  unsigned * pSimmNode, * pSimmNode1;
344  int k, fComp1;
345  // simulate the internal nodes
346  assert( Abc_ObjIsCo(pNode) );
347  pSimmNode = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
348  pSimmNode1 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
349  pSimmNode += nOffset + (fShift > 0)*nSimWords;
350  pSimmNode1 += nOffset;
351  fComp1 = Abc_ObjFaninC0(pNode);
352  if ( fComp1 )
353  for ( k = 0; k < nSimWords; k++ )
354  pSimmNode[k] = ~pSimmNode1[k];
355  else
356  for ( k = 0; k < nSimWords; k++ )
357  pSimmNode[k] = pSimmNode1[k];
358 }
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int Id
Definition: abc.h:132
#define assert(ex)
Definition: util_old.h:213
void Sym_ManPrintStats ( Sym_Man_t p)

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

Synopsis [Prints the manager statisticis.]

Description []

SideEffects []

SeeAlso []

Definition at line 135 of file simMan.c.

136 {
137 // printf( "Inputs = %5d. Outputs = %5d. Sim words = %5d.\n",
138 // Abc_NtkCiNum(p->pNtk), Abc_NtkCoNum(p->pNtk), p->nSimWords );
139  printf( "Total symm = %8d.\n", p->nPairsSymm );
140  printf( "Structural symm = %8d.\n", p->nPairsSymmStr );
141  printf( "Total non-sym = %8d.\n", p->nPairsNonSymm );
142  printf( "Total var pairs = %8d.\n", p->nPairsTotal );
143  printf( "Sat runs SAT = %8d.\n", p->nSatRunsSat );
144  printf( "Sat runs UNSAT = %8d.\n", p->nSatRunsUnsat );
145  ABC_PRT( "Structural ", p->timeStruct );
146  ABC_PRT( "Simulation ", p->timeSim );
147  ABC_PRT( "Matrix ", p->timeMatr );
148  ABC_PRT( "Counting ", p->timeCount );
149  ABC_PRT( "Fraiging ", p->timeFraig );
150  ABC_PRT( "SAT ", p->timeSat );
151  ABC_PRT( "TOTAL ", p->timeTotal );
152 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Sym_Man_t* Sym_ManStart ( Abc_Ntk_t pNtk,
int  fVerbose 
)

FUNCTION DECLARATIONS ///.

FUNCTION DECLARATIONS ///.

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

FileName [simMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Simulation manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Starts the simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file simMan.c.

47 {
48  Sym_Man_t * p;
49  int i, v;
50  // start the manager
51  p = ABC_ALLOC( Sym_Man_t, 1 );
52  memset( p, 0, sizeof(Sym_Man_t) );
53  p->pNtk = pNtk;
54  p->vNodes = Abc_NtkDfs( pNtk, 0 );
55  p->nInputs = Abc_NtkCiNum(p->pNtk);
56  p->nOutputs = Abc_NtkCoNum(p->pNtk);
57  // internal simulation information
58  p->nSimWords = SIM_NUM_WORDS(p->nInputs);
59  p->vSim = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSimWords, 0 );
60  // symmetry info for each output
61  p->vMatrSymms = Vec_PtrStart( p->nOutputs );
62  p->vMatrNonSymms = Vec_PtrStart( p->nOutputs );
63  p->vPairsTotal = Vec_IntStart( p->nOutputs );
64  p->vPairsSym = Vec_IntStart( p->nOutputs );
65  p->vPairsNonSym = Vec_IntStart( p->nOutputs );
66  for ( i = 0; i < p->nOutputs; i++ )
67  {
68  p->vMatrSymms->pArray[i] = Extra_BitMatrixStart( p->nInputs );
69  p->vMatrNonSymms->pArray[i] = Extra_BitMatrixStart( p->nInputs );
70  }
71  // temporary patterns
72  p->uPatRand = ABC_ALLOC( unsigned, p->nSimWords );
73  p->uPatCol = ABC_ALLOC( unsigned, p->nSimWords );
74  p->uPatRow = ABC_ALLOC( unsigned, p->nSimWords );
75  p->vVarsU = Vec_IntStart( 100 );
76  p->vVarsV = Vec_IntStart( 100 );
77  // compute supports
78  p->vSuppFun = Sim_ComputeFunSupp( pNtk, fVerbose );
79  p->vSupports = Vec_VecStart( p->nOutputs );
80  for ( i = 0; i < p->nOutputs; i++ )
81  for ( v = 0; v < p->nInputs; v++ )
82  if ( Sim_SuppFunHasVar( p->vSuppFun, i, v ) )
83  Vec_VecPush( p->vSupports, i, (void *)(ABC_PTRUINT_T)v );
84  return p;
85 }
char * memset()
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
static void Vec_VecPush(Vec_Vec_t *p, int Level, void *Entry)
Definition: vecVec.h:456
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
typedefABC_NAMESPACE_HEADER_START struct Sym_Man_t_ Sym_Man_t
INCLUDES ///.
Definition: sim.h:48
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
Vec_Ptr_t * Sim_UtilInfoAlloc(int nSize, int nWords, int fClean)
FUNCTION DEFINITIONS ///.
Definition: simUtils.c:57
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
#define SIM_NUM_WORDS(n)
MACRO DEFINITIONS ///.
Definition: sim.h:148
Extra_BitMat_t * Extra_BitMatrixStart(int nSize)
Vec_Ptr_t * Sim_ComputeFunSupp(Abc_Ntk_t *pNtk, int fVerbose)
Definition: simSupp.c:103
#define Sim_SuppFunHasVar(vSupps, Output, v)
Definition: sim.h:169
void Sym_ManStop ( Sym_Man_t p)

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

Synopsis [Stops the simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file simMan.c.

99 {
100  int i;
101  Sym_ManPrintStats( p );
102  if ( p->vSuppFun ) Sim_UtilInfoFree( p->vSuppFun );
103  if ( p->vSim ) Sim_UtilInfoFree( p->vSim );
104  if ( p->vNodes ) Vec_PtrFree( p->vNodes );
105  if ( p->vSupports ) Vec_VecFree( p->vSupports );
106  for ( i = 0; i < p->nOutputs; i++ )
107  {
108  Extra_BitMatrixStop( (Extra_BitMat_t *)p->vMatrSymms->pArray[i] );
109  Extra_BitMatrixStop( (Extra_BitMat_t *)p->vMatrNonSymms->pArray[i] );
110  }
111  Vec_IntFree( p->vVarsU );
112  Vec_IntFree( p->vVarsV );
113  Vec_PtrFree( p->vMatrSymms );
114  Vec_PtrFree( p->vMatrNonSymms );
115  Vec_IntFree( p->vPairsTotal );
116  Vec_IntFree( p->vPairsSym );
117  Vec_IntFree( p->vPairsNonSym );
118  ABC_FREE( p->uPatRand );
119  ABC_FREE( p->uPatCol );
120  ABC_FREE( p->uPatRow );
121  ABC_FREE( p );
122 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
void Sim_UtilInfoFree(Vec_Ptr_t *p)
Definition: simUtils.c:83
void Extra_BitMatrixStop(Extra_BitMat_t *p)
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Sym_ManPrintStats(Sym_Man_t *p)
Definition: simMan.c:135