abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
simSymSim.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [simSymSim.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [Simulation to determine two-variable symmetries.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: simSymSim.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 #include "sim.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 static void Sim_SymmsCreateSquare( Sym_Man_t * p, unsigned * pPat );
32 static void Sim_SymmsDeriveInfo( Sym_Man_t * p, unsigned * pPat, Abc_Obj_t * pNode, Vec_Ptr_t * vMatrsNonSym, int Output );
33 
34 ////////////////////////////////////////////////////////////////////////
35 /// FUNCTION DEFINITIONS ///
36 ////////////////////////////////////////////////////////////////////////
37 
38 /**Function*************************************************************
39 
40  Synopsis [Detects non-symmetric pairs using one pattern.]
41 
42  Description []
43 
44  SideEffects []
45 
46  SeeAlso []
47 
48 ***********************************************************************/
49 void Sim_SymmsSimulate( Sym_Man_t * p, unsigned * pPat, Vec_Ptr_t * vMatrsNonSym )
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 }
83 
84 /**Function*************************************************************
85 
86  Synopsis [Creates the square matrix of simulation info.]
87 
88  Description []
89 
90  SideEffects []
91 
92  SeeAlso []
93 
94 ***********************************************************************/
95 void Sim_SymmsCreateSquare( Sym_Man_t * p, unsigned * pPat )
96 {
97  unsigned * pSimInfo;
98  Abc_Obj_t * pNode;
99  int i, w;
100  // for each PI var copy the pattern
101  Abc_NtkForEachCi( p->pNtk, pNode, i )
102  {
103  pSimInfo = (unsigned *)Vec_PtrEntry( p->vSim, pNode->Id );
104  if ( Sim_HasBit(pPat, i) )
105  {
106  for ( w = 0; w < p->nSimWords; w++ )
107  pSimInfo[w] = SIM_MASK_FULL;
108  }
109  else
110  {
111  for ( w = 0; w < p->nSimWords; w++ )
112  pSimInfo[w] = 0;
113  }
114  // flip one bit
115  Sim_XorBit( pSimInfo, i );
116  }
117 }
118 
119 /**Function*************************************************************
120 
121  Synopsis [Transfers the info to the POs.]
122 
123  Description []
124 
125  SideEffects []
126 
127  SeeAlso []
128 
129 ***********************************************************************/
130 void Sim_SymmsDeriveInfo( Sym_Man_t * p, unsigned * pPat, Abc_Obj_t * pNode, Vec_Ptr_t * vMatrsNonSym, int Output )
131 {
132  Extra_BitMat_t * pMat;
133  Vec_Int_t * vSupport;
134  unsigned * pSupport;
135  unsigned * pSimInfo;
136  int i, w, Index;
137  // get the matrix, the support, and the simulation info
138  pMat = (Extra_BitMat_t *)Vec_PtrEntry( vMatrsNonSym, Output );
139  vSupport = Vec_VecEntryInt( p->vSupports, Output );
140  pSupport = (unsigned *)Vec_PtrEntry( p->vSuppFun, Output );
141  pSimInfo = (unsigned *)Vec_PtrEntry( p->vSim, pNode->Id );
142  // generate vectors A1 and A2
143  for ( w = 0; w < p->nSimWords; w++ )
144  {
145  p->uPatCol[w] = pSupport[w] & pPat[w] & pSimInfo[w];
146  p->uPatRow[w] = pSupport[w] & pPat[w] & ~pSimInfo[w];
147  }
148  // add two dimensions
149  Vec_IntForEachEntry( vSupport, i, Index )
150  if ( Sim_HasBit( p->uPatCol, i ) )
151  Extra_BitMatrixOr( pMat, i, p->uPatRow );
152  // add two dimensions
153  Vec_IntForEachEntry( vSupport, i, Index )
154  if ( Sim_HasBit( p->uPatRow, i ) )
155  Extra_BitMatrixOr( pMat, i, p->uPatCol );
156  // generate vectors B1 and B2
157  for ( w = 0; w < p->nSimWords; w++ )
158  {
159  p->uPatCol[w] = pSupport[w] & ~pPat[w] & pSimInfo[w];
160  p->uPatRow[w] = pSupport[w] & ~pPat[w] & ~pSimInfo[w];
161  }
162  // add two dimensions
163  Vec_IntForEachEntry( vSupport, i, Index )
164  if ( Sim_HasBit( p->uPatCol, i ) )
165  Extra_BitMatrixOr( pMat, i, p->uPatRow );
166  // add two dimensions
167  Vec_IntForEachEntry( vSupport, i, Index )
168  if ( Sim_HasBit( p->uPatRow, i ) )
169  Extra_BitMatrixOr( pMat, i, p->uPatCol );
170 }
171 
172 ////////////////////////////////////////////////////////////////////////
173 /// END OF FILE ///
174 ////////////////////////////////////////////////////////////////////////
175 
176 
178 
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define SIM_MASK_FULL
Definition: sim.h:151
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 Sim_SymmsSimulate(Sym_Man_t *p, unsigned *pPat, Vec_Ptr_t *vMatrsNonSym)
FUNCTION DEFINITIONS ///.
Definition: simSymSim.c:49
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
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
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
#define Sim_HasBit(p, i)
Definition: sim.h:163
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static ABC_NAMESPACE_IMPL_START void Sim_SymmsCreateSquare(Sym_Man_t *p, unsigned *pPat)
DECLARATIONS ///.
Definition: simSymSim.c:95
static Vec_Int_t * Vec_VecEntryInt(Vec_Vec_t *p, int i)
Definition: vecVec.h:276
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
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 Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
int Id
Definition: abc.h:132
#define Sim_XorBit(p, i)
Definition: sim.h:162
void Extra_BitMatrixOr(Extra_BitMat_t *p, int i, unsigned *pInfo)
#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
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54