abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cecSynth.c File Reference
#include "cecInt.h"
#include "aig/gia/giaAig.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Cec_SeqSynthesisSetDefaultParams (Cec_ParSeq_t *p)
 DECLARATIONS ///. More...
 
int Cec_SeqReadMinDomSize (Cec_ParSeq_t *p)
 
int Cec_SeqReadVerbose (Cec_ParSeq_t *p)
 
Gia_Man_tGia_ManRegCreatePart (Gia_Man_t *p, Vec_Int_t *vPart, int *pnCountPis, int *pnCountRegs, int **ppMapBack)
 
int Gia_TransferMappedClasses (Gia_Man_t *pPart, int *pMapBack, int *pReprs)
 
int Gia_ManFindRepr_rec (int *pReprs, int Id)
 
void Gia_ManNormalizeEquivalences (Gia_Man_t *p, int *pReprs)
 
int Cec_SequentialSynthesisPart (Gia_Man_t *p, Cec_ParSeq_t *pPars)
 

Function Documentation

int Cec_SeqReadMinDomSize ( Cec_ParSeq_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file cecSynth.c.

74 {
75  return p->nMinDomSize;
76 }
int nMinDomSize
Definition: cec.h:183
int Cec_SeqReadVerbose ( Cec_ParSeq_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file cecSynth.c.

90 {
91  return p->fVerbose;
92 }
int fVerbose
Definition: cec.h:185
ABC_NAMESPACE_IMPL_START void Cec_SeqSynthesisSetDefaultParams ( Cec_ParSeq_t p)

DECLARATIONS ///.

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

FileName [cecSynth.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Combinational equivalence checking.]

Synopsis [Partitioned sequential synthesis.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Populate sequential synthesis parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file cecSynth.c.

47 {
48  memset( p, 0, sizeof(Cec_ParSeq_t) );
49  p->fUseLcorr = 0; // enables latch correspondence
50  p->fUseScorr = 0; // enables signal correspondence
51  p->nBTLimit = 1000; // (scorr/lcorr) conflict limit at a node
52  p->nFrames = 1; // (scorr only) the number of timeframes
53  p->nLevelMax = -1; // (scorr only) the max number of levels
54  p->fConsts = 1; // (scl only) merging constants
55  p->fEquivs = 1; // (scl only) merging equivalences
56  p->fUseMiniSat = 0; // enables MiniSat in lcorr/scorr
57  p->nMinDomSize = 100; // the size of minimum clock domain
58  p->fVeryVerbose = 0; // verbose stats
59  p->fVerbose = 0; // verbose stats
60 }
char * memset()
int fUseLcorr
Definition: cec.h:175
int fVerbose
Definition: cec.h:185
int nFrames
Definition: cec.h:178
int fUseScorr
Definition: cec.h:176
int nBTLimit
Definition: cec.h:177
int fVeryVerbose
Definition: cec.h:184
int fEquivs
Definition: cec.h:181
int nLevelMax
Definition: cec.h:179
int fUseMiniSat
Definition: cec.h:182
int nMinDomSize
Definition: cec.h:183
int fConsts
Definition: cec.h:180
int Cec_SequentialSynthesisPart ( Gia_Man_t p,
Cec_ParSeq_t pPars 
)

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

Synopsis [Partitioned sequential synthesis.]

Description [Returns AIG annotated with equivalence classes.]

SideEffects []

SeeAlso []

Definition at line 291 of file cecSynth.c.

292 {
293  int fPrintParts = 0;
294  char Buffer[100];
295  Gia_Man_t * pTemp;
296  Vec_Ptr_t * vParts = (Vec_Ptr_t *)p->vClockDoms;
297  Vec_Int_t * vPart;
298  int * pMapBack, * pReprs;
299  int i, nCountPis, nCountRegs;
300  int nClasses;
301  abctime clk = Abc_Clock();
302 
303  // save parameters
304  if ( fPrintParts )
305  {
306  // print partitions
307  Abc_Print( 1, "The following clock domains are used:\n" );
308  Vec_PtrForEachEntry( Vec_Int_t *, vParts, vPart, i )
309  {
310  pTemp = Gia_ManRegCreatePart( p, vPart, &nCountPis, &nCountRegs, NULL );
311  sprintf( Buffer, "part%03d.aig", i );
312  Gia_AigerWrite( pTemp, Buffer, 0, 0 );
313  Abc_Print( 1, "part%03d.aig : Reg = %4d. PI = %4d. (True = %4d. Regs = %4d.) And = %5d.\n",
314  i, Vec_IntSize(vPart), Gia_ManCiNum(pTemp)-Vec_IntSize(vPart), nCountPis, nCountRegs, Gia_ManAndNum(pTemp) );
315  Gia_ManStop( pTemp );
316  }
317  }
318 
319  // perform sequential synthesis for clock domains
320  pReprs = ABC_FALLOC( int, Gia_ManObjNum(p) );
321  Vec_PtrForEachEntry( Vec_Int_t *, vParts, vPart, i )
322  {
323  pTemp = Gia_ManRegCreatePart( p, vPart, &nCountPis, &nCountRegs, &pMapBack );
324  if ( nCountPis > 0 )
325  {
326  if ( pPars->fUseScorr )
327  {
328  Cec_ParCor_t CorPars, * pCorPars = &CorPars;
329  Cec_ManCorSetDefaultParams( pCorPars );
330  pCorPars->nBTLimit = pPars->nBTLimit;
331  pCorPars->nLevelMax = pPars->nLevelMax;
332  pCorPars->fVerbose = pPars->fVeryVerbose;
333  pCorPars->fUseCSat = 1;
334  Cec_ManLSCorrespondenceClasses( pTemp, pCorPars );
335  }
336  else if ( pPars->fUseLcorr )
337  {
338  Cec_ParCor_t CorPars, * pCorPars = &CorPars;
339  Cec_ManCorSetDefaultParams( pCorPars );
340  pCorPars->fLatchCorr = 1;
341  pCorPars->nBTLimit = pPars->nBTLimit;
342  pCorPars->fVerbose = pPars->fVeryVerbose;
343  pCorPars->fUseCSat = 1;
344  Cec_ManLSCorrespondenceClasses( pTemp, pCorPars );
345  }
346  else
347  {
348 // pNew = Gia_ManSeqStructSweep( pTemp, pPars->fConsts, pPars->fEquivs, pPars->fVerbose );
349 // Gia_ManStop( pNew );
350  Gia_ManSeqCleanupClasses( pTemp, pPars->fConsts, pPars->fEquivs, pPars->fVerbose );
351  }
352 //Abc_Print( 1, "Part equivalences = %d.\n", Gia_ManEquivCountLitsAll(pTemp) );
353  nClasses = Gia_TransferMappedClasses( pTemp, pMapBack, pReprs );
354  if ( pPars->fVerbose )
355  {
356  Abc_Print( 1, "%3d : Reg = %4d. PI = %4d. (True = %4d. Regs = %4d.) And = %5d. Cl = %5d.\n",
357  i, Vec_IntSize(vPart), Gia_ManCiNum(pTemp)-Vec_IntSize(vPart), nCountPis, nCountRegs, Gia_ManAndNum(pTemp), nClasses );
358  }
359  }
360  Gia_ManStop( pTemp );
361  ABC_FREE( pMapBack );
362  }
363 
364  // generate resulting equivalences
365  Gia_ManNormalizeEquivalences( p, pReprs );
366 //Abc_Print( 1, "Total equivalences = %d.\n", Gia_ManEquivCountLitsAll(p) );
367  ABC_FREE( pReprs );
368  if ( pPars->fVerbose )
369  {
370  Abc_PrintTime( 1, "Total time", Abc_Clock() - clk );
371  }
372  return 1;
373 }
void Cec_ManCorSetDefaultParams(Cec_ParCor_t *p)
Definition: cecCore.c:181
Gia_Man_t * Gia_ManRegCreatePart(Gia_Man_t *p, Vec_Int_t *vPart, int *pnCountPis, int *pnCountRegs, int **ppMapBack)
Definition: cecSynth.c:105
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
int fUseLcorr
Definition: cec.h:175
int fUseCSat
Definition: cec.h:146
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int fVerbose
Definition: cec.h:185
static abctime Abc_Clock()
Definition: abc_global.h:279
int fUseScorr
Definition: cec.h:176
int fLatchCorr
Definition: cec.h:142
int nBTLimit
Definition: cec.h:177
int fVerbose
Definition: cec.h:152
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
int fVeryVerbose
Definition: cec.h:184
int nLevelMax
Definition: cec.h:140
void Gia_ManSeqCleanupClasses(Gia_Man_t *p, int fConst, int fEquiv, int fVerbose)
Definition: giaAig.c:603
char * sprintf()
void Gia_ManNormalizeEquivalences(Gia_Man_t *p, int *pReprs)
Definition: cecSynth.c:262
int Cec_ManLSCorrespondenceClasses(Gia_Man_t *pAig, Cec_ParCor_t *pPars)
Definition: cecCorr.c:909
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact)
Definition: giaAiger.c:1024
int fEquivs
Definition: cec.h:181
int nLevelMax
Definition: cec.h:179
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
Vec_Vec_t * vClockDoms
Definition: gia.h:163
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
int nBTLimit
Definition: cec.h:139
Definition: gia.h:95
int Gia_TransferMappedClasses(Gia_Man_t *pPart, int *pMapBack, int *pReprs)
Definition: cecSynth.c:204
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
int fConsts
Definition: cec.h:180
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
int Gia_ManFindRepr_rec ( int *  pReprs,
int  Id 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 242 of file cecSynth.c.

243 {
244  if ( pReprs[Id] == 0 )
245  return 0;
246  if ( pReprs[Id] == ~0 )
247  return Id;
248  return Gia_ManFindRepr_rec( pReprs, pReprs[Id] );
249 }
int Gia_ManFindRepr_rec(int *pReprs, int Id)
Definition: cecSynth.c:242
void Gia_ManNormalizeEquivalences ( Gia_Man_t p,
int *  pReprs 
)

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

Synopsis [Normalizes equivalences.]

Description []

SideEffects []

SeeAlso []

Definition at line 262 of file cecSynth.c.

263 {
264  int i, iRepr;
265  assert( p->pReprs == NULL );
266  assert( p->pNexts == NULL );
268  for ( i = 0; i < Gia_ManObjNum(p); i++ )
269  Gia_ObjSetRepr( p, i, GIA_VOID );
270  for ( i = 0; i < Gia_ManObjNum(p); i++ )
271  {
272  if ( pReprs[i] == ~0 )
273  continue;
274  iRepr = Gia_ManFindRepr_rec( pReprs, i );
275  Gia_ObjSetRepr( p, i, iRepr );
276  }
277  p->pNexts = Gia_ManDeriveNexts( p );
278 }
int * pNexts
Definition: gia.h:122
static void Gia_ObjSetRepr(Gia_Man_t *p, int Id, int Num)
Definition: gia.h:888
int * Gia_ManDeriveNexts(Gia_Man_t *p)
Definition: giaEquiv.c:97
#define GIA_VOID
Definition: gia.h:45
int Gia_ManFindRepr_rec(int *pReprs, int Id)
Definition: cecSynth.c:242
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Gia_Rpr_t * pReprs
Definition: gia.h:121
#define assert(ex)
Definition: util_old.h:213
Definition: gia.h:56
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
Gia_Man_t* Gia_ManRegCreatePart ( Gia_Man_t p,
Vec_Int_t vPart,
int *  pnCountPis,
int *  pnCountRegs,
int **  ppMapBack 
)

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

Synopsis [Computes partitioning of registers.]

Description []

SideEffects []

SeeAlso []

Definition at line 105 of file cecSynth.c.

106 {
107  Gia_Man_t * pNew;
108  Gia_Obj_t * pObj;
109  Vec_Int_t * vNodes, * vRoots;
110  int i, iOut, nCountPis, nCountRegs;
111  int * pMapBack;
112  // collect/mark nodes/PIs in the DFS order from the roots
114  vRoots = Vec_IntAlloc( Vec_IntSize(vPart) );
115  Vec_IntForEachEntry( vPart, iOut, i )
116  Vec_IntPush( vRoots, Gia_ObjId(p, Gia_ManCo(p, Gia_ManPoNum(p)+iOut)) );
117  vNodes = Gia_ManCollectNodesCis( p, Vec_IntArray(vRoots), Vec_IntSize(vRoots) );
118  Vec_IntFree( vRoots );
119  // unmark register outputs
120  Vec_IntForEachEntry( vPart, iOut, i )
122  // count pure PIs
123  nCountPis = nCountRegs = 0;
124  Gia_ManForEachPi( p, pObj, i )
125  nCountPis += Gia_ObjIsTravIdCurrent(p, pObj);
126  // count outputs of other registers
127  Gia_ManForEachRo( p, pObj, i )
128  nCountRegs += Gia_ObjIsTravIdCurrent(p, pObj); // should be !Gia_... ???
129  if ( pnCountPis )
130  *pnCountPis = nCountPis;
131  if ( pnCountRegs )
132  *pnCountRegs = nCountRegs;
133  // clean old manager
134  Gia_ManFillValue(p);
135  Gia_ManConst0(p)->Value = 0;
136  // create the new manager
137  pNew = Gia_ManStart( Vec_IntSize(vNodes) );
138  // create the PIs
139  Gia_ManForEachCi( p, pObj, i )
140  if ( Gia_ObjIsTravIdCurrent(p, pObj) )
141  pObj->Value = Gia_ManAppendCi(pNew);
142  // add variables for the register outputs
143  // create fake POs to hold the register outputs
144  Vec_IntForEachEntry( vPart, iOut, i )
145  {
146  pObj = Gia_ManCi(p, Gia_ManPiNum(p)+iOut);
147  pObj->Value = Gia_ManAppendCi(pNew);
148  Gia_ManAppendCo( pNew, pObj->Value );
149  Gia_ObjSetTravIdCurrent( p, pObj ); // added
150  }
151  // create the nodes
152  Gia_ManForEachObjVec( vNodes, p, pObj, i )
153  if ( Gia_ObjIsAnd(pObj) )
154  pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
155  // add real POs for the registers
156  Vec_IntForEachEntry( vPart, iOut, i )
157  {
158  pObj = Gia_ManCo( p, Gia_ManPoNum(p)+iOut );
159  Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
160  }
161  Gia_ManSetRegNum( pNew, Vec_IntSize(vPart) );
162  // create map
163  if ( ppMapBack )
164  {
165  pMapBack = ABC_FALLOC( int, Gia_ManObjNum(pNew) );
166  // map constant nodes
167  pMapBack[0] = 0;
168  // logic cones of register outputs
169  Gia_ManForEachObjVec( vNodes, p, pObj, i )
170  {
171 // pObjNew = Aig_Regular(pObj->pData);
172 // pMapBack[pObjNew->Id] = pObj->Id;
173  assert( Abc_Lit2Var(Gia_ObjValue(pObj)) >= 0 );
174  assert( Abc_Lit2Var(Gia_ObjValue(pObj)) < Gia_ManObjNum(pNew) );
175  pMapBack[ Abc_Lit2Var(Gia_ObjValue(pObj)) ] = Gia_ObjId(p, pObj);
176  }
177  // map register outputs
178  Vec_IntForEachEntry( vPart, iOut, i )
179  {
180  pObj = Gia_ManCi(p, Gia_ManPiNum(p)+iOut);
181 // pObjNew = pObj->pData;
182 // pMapBack[pObjNew->Id] = pObj->Id;
183  assert( Abc_Lit2Var(Gia_ObjValue(pObj)) >= 0 );
184  assert( Abc_Lit2Var(Gia_ObjValue(pObj)) < Gia_ManObjNum(pNew) );
185  pMapBack[ Abc_Lit2Var(Gia_ObjValue(pObj)) ] = Gia_ObjId(p, pObj);
186  }
187  *ppMapBack = pMapBack;
188  }
189  Vec_IntFree( vNodes );
190  return pNew;
191 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static Gia_Obj_t * Gia_ManCi(Gia_Man_t *p, int v)
Definition: gia.h:403
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Int_t * Gia_ManCollectNodesCis(Gia_Man_t *p, int *pNodes, int nNodes)
Definition: giaDfs.c:178
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:533
static void Gia_ObjSetTravIdPrevious(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:532
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static int Gia_ObjValue(Gia_Obj_t *pObj)
Definition: gia.h:413
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
Definition: gia.h:75
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
if(last==0)
Definition: sparse_int.h:34
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static Gia_Obj_t * Gia_ManCo(Gia_Man_t *p, int v)
Definition: gia.h:404
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: gia.h:95
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
#define assert(ex)
Definition: util_old.h:213
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
int Gia_TransferMappedClasses ( Gia_Man_t pPart,
int *  pMapBack,
int *  pReprs 
)

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

Synopsis [Transfers the classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 204 of file cecSynth.c.

205 {
206  Gia_Obj_t * pObj;
207  int i, Id1, Id2, nClasses;
208  if ( pPart->pReprs == NULL )
209  return 0;
210  nClasses = 0;
211  Gia_ManForEachObj( pPart, pObj, i )
212  {
213  if ( Gia_ObjRepr(pPart, i) == GIA_VOID )
214  continue;
215  assert( i < Gia_ManObjNum(pPart) );
216  assert( Gia_ObjRepr(pPart, i) < Gia_ManObjNum(pPart) );
217  Id1 = pMapBack[ i ];
218  Id2 = pMapBack[ Gia_ObjRepr(pPart, i) ];
219  if ( Id1 == Id2 )
220  continue;
221  if ( Id1 < Id2 )
222  pReprs[Id2] = Id1;
223  else
224  pReprs[Id1] = Id2;
225  nClasses++;
226  }
227  return nClasses;
228 }
Definition: gia.h:75
#define GIA_VOID
Definition: gia.h:45
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
Gia_Rpr_t * pReprs
Definition: gia.h:121
#define assert(ex)
Definition: util_old.h:213
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ObjRepr(Gia_Man_t *p, int Id)
Definition: gia.h:887