Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
81b51657
Commit
81b51657
authored
Mar 13, 2009
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version abc90313
parent
243cb29e
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
653 additions
and
135 deletions
+653
-135
src/aig/cec/cecCec.c
+1
-0
src/aig/cec/cecClass.c
+2
-1
src/aig/cec/cecCore.c
+8
-6
src/aig/cec/cecSeq.c
+0
-0
src/aig/cec/cecSolve.c
+2
-1
src/aig/gia/gia.h
+24
-4
src/aig/gia/giaAig.c
+23
-0
src/aig/gia/giaAiger.c
+1
-0
src/aig/gia/giaCof.c
+226
-0
src/aig/gia/giaDup.c
+98
-97
src/aig/gia/giaEnable.c
+217
-2
src/aig/gia/giaEquiv.c
+0
-0
src/aig/saig/saig.h
+1
-1
src/aig/saig/saigBmc2.c
+10
-2
src/aig/ssw/sswCore.c
+12
-12
src/base/abc/abc.h
+1
-0
src/base/abc/abcHie.c
+0
-0
src/base/abc/abcNames.c
+22
-4
src/base/abci/abc.c
+0
-0
src/base/abci/abcDar.c
+3
-3
src/base/main/mainMC.c
+2
-2
No files found.
src/aig/cec/cecCec.c
View file @
81b51657
...
...
@@ -129,6 +129,7 @@ int Cec_ManVerify( Gia_Man_t * p, Cec_ParCec_t * pPars )
double
clkTotal
=
clock
();
// sweep for equivalences
Cec_ManFraSetDefaultParams
(
pParsFra
);
pParsFra
->
nItersMax
=
1000
;
pParsFra
->
nBTLimit
=
pPars
->
nBTLimit
;
pParsFra
->
TimeLimit
=
pPars
->
TimeLimit
;
pParsFra
->
fVerbose
=
pPars
->
fVerbose
;
...
...
src/aig/cec/cecClass.c
View file @
81b51657
...
...
@@ -242,6 +242,7 @@ void Cec_ManSimClassCreate( Gia_Man_t * p, Vec_Int_t * vClass )
}
else
{
assert
(
Repr
<
Ent
);
Gia_ObjSetRepr
(
p
,
Ent
,
Repr
);
Gia_ObjSetNext
(
p
,
EntPrev
,
Ent
);
EntPrev
=
Ent
;
...
...
@@ -838,7 +839,7 @@ int Cec_ManSimClassesRefine( Cec_ManSim_t * p )
p
->
nWords
=
p
->
pPars
->
nWords
;
for
(
i
=
0
;
i
<
p
->
pPars
->
nRounds
;
i
++
)
{
if
(
(
i
%
4
)
==
0
&&
p
->
pPars
->
fVerbose
)
if
(
(
i
%
(
p
->
pPars
->
nRounds
/
5
)
)
==
0
&&
p
->
pPars
->
fVerbose
)
Gia_ManEquivPrintClasses
(
p
->
pAig
,
0
,
Cec_MemUsage
(
p
)
);
Cec_ManSimCreateInfo
(
p
,
p
->
vCiSimInfo
,
p
->
vCoSimInfo
);
if
(
Cec_ManSimSimulateRound
(
p
,
p
->
vCiSimInfo
,
p
->
vCoSimInfo
)
)
...
...
src/aig/cec/cecCore.c
View file @
81b51657
...
...
@@ -90,10 +90,10 @@ void Cec_ManSimSetDefaultParams( Cec_ParSim_t * p )
void
Cec_ManSmfSetDefaultParams
(
Cec_ParSmf_t
*
p
)
{
memset
(
p
,
0
,
sizeof
(
Cec_ParSmf_t
)
);
p
->
nWords
=
15
;
// the number of simulation words
p
->
nRounds
=
15
;
// the number of simulation rounds
p
->
nWords
=
31
;
// the number of simulation words
p
->
nRounds
=
1
;
// the number of simulation rounds
p
->
nFrames
=
2
;
// the number of time frames
p
->
nBTLimit
=
10
00
;
// conflict limit at a node
p
->
nBTLimit
=
1
00
;
// conflict limit at a node
p
->
TimeLimit
=
0
;
// the runtime limit in seconds
p
->
fDualOut
=
0
;
// miter with separate outputs
p
->
fCheckMiter
=
0
;
// the circuit is the miter
...
...
@@ -118,8 +118,8 @@ void Cec_ManFraSetDefaultParams( Cec_ParFra_t * p )
p
->
nWords
=
15
;
// the number of simulation words
p
->
nRounds
=
15
;
// the number of simulation rounds
p
->
TimeLimit
=
0
;
// the runtime limit in seconds
p
->
nItersMax
=
100
0
;
// the maximum number of iterations of SAT sweeping
p
->
nBTLimit
=
10
00
;
// conflict limit at a node
p
->
nItersMax
=
1
0
;
// the maximum number of iterations of SAT sweeping
p
->
nBTLimit
=
1
00
;
// conflict limit at a node
p
->
nLevelMax
=
0
;
// restriction on the level of nodes to be swept
p
->
nDepthMax
=
1
;
// the depth in terms of steps of speculative reduction
p
->
fRewriting
=
0
;
// enables AIG rewriting
...
...
@@ -322,6 +322,8 @@ p->timeSat += clock() - clk;
// update the manager
pSim
->
pAig
=
p
->
pAig
=
Gia_ManEquivReduceAndRemap
(
pTemp
=
p
->
pAig
,
0
,
pParsSim
->
fDualOut
);
Gia_ManStop
(
pTemp
);
if
(
p
->
pAig
==
NULL
)
break
;
if
(
p
->
pPars
->
fVerbose
)
{
printf
(
"%3d : P =%7d. D =%7d. F =%6d. M = %7d. And =%8d. "
,
...
...
@@ -381,7 +383,7 @@ finalize:
}
pTemp
=
p
->
pAig
;
p
->
pAig
=
NULL
;
if
(
pTemp
==
NULL
)
if
(
pTemp
==
NULL
&&
pSim
->
iOut
>=
0
)
printf
(
"Disproved at least one output of the miter (zero-based number %d).
\n
"
,
pSim
->
iOut
);
else
if
(
pSim
->
pCexes
)
printf
(
"Disproved %d outputs of the miter.
\n
"
,
pSim
->
nOuts
);
...
...
src/aig/cec/cecSeq.c
View file @
81b51657
src/aig/cec/cecSolve.c
View file @
81b51657
...
...
@@ -703,7 +703,8 @@ void Cec_ManSatSolveSeq( Vec_Ptr_t * vPatts, Gia_Man_t * pAig, Cec_ParSat_t * pP
}
p
->
timeTotal
=
clock
()
-
clk
;
Bar_ProgressStop
(
pProgress
);
// Cec_ManSatPrintStats( p );
if
(
pPars
->
fVerbose
)
Cec_ManSatPrintStats
(
p
);
Cec_ManSatStop
(
p
);
if
(
pnPats
)
*
pnPats
=
iPat
-
1
;
...
...
src/aig/gia/gia.h
View file @
81b51657
...
...
@@ -67,6 +67,11 @@ struct Gia_Obj_t_
unsigned
Value
;
// application-specific value
};
// Value is currently use to store several types of information
// - pointer to the next node in the hash table during structural hashing
// - pointer to the node copy during duplication
// - traversal ID of the node during traversal
// - reference counter of the node (will not be used in the future)
// sequential counter-example
typedef
struct
Gia_Cex_t_
Gia_Cex_t
;
...
...
@@ -177,6 +182,7 @@ static inline int Gia_ManPoNum( Gia_Man_t * p ) { return Vec_IntS
static
inline
int
Gia_ManRegNum
(
Gia_Man_t
*
p
)
{
return
p
->
nRegs
;
}
static
inline
int
Gia_ManObjNum
(
Gia_Man_t
*
p
)
{
return
p
->
nObjs
;
}
static
inline
int
Gia_ManAndNum
(
Gia_Man_t
*
p
)
{
return
p
->
nObjs
-
Vec_IntSize
(
p
->
vCis
)
-
Vec_IntSize
(
p
->
vCos
)
-
1
;
}
static
inline
int
Gia_ManCandNum
(
Gia_Man_t
*
p
)
{
return
Gia_ManCiNum
(
p
)
+
Gia_ManAndNum
(
p
);
}
static
inline
Gia_Obj_t
*
Gia_ManConst0
(
Gia_Man_t
*
p
)
{
return
p
->
pObjs
;
}
static
inline
Gia_Obj_t
*
Gia_ManConst1
(
Gia_Man_t
*
p
)
{
return
Gia_Not
(
Gia_ManConst0
(
p
));
}
...
...
@@ -193,6 +199,7 @@ static inline int Gia_ObjIsAndOrConst0( Gia_Obj_t * pObj ) {
static
inline
int
Gia_ObjIsCi
(
Gia_Obj_t
*
pObj
)
{
return
pObj
->
fTerm
&&
pObj
->
iDiff0
==
GIA_NONE
;
}
static
inline
int
Gia_ObjIsCo
(
Gia_Obj_t
*
pObj
)
{
return
pObj
->
fTerm
&&
pObj
->
iDiff0
!=
GIA_NONE
;
}
static
inline
int
Gia_ObjIsAnd
(
Gia_Obj_t
*
pObj
)
{
return
!
pObj
->
fTerm
&&
pObj
->
iDiff0
!=
GIA_NONE
;
}
static
inline
int
Gia_ObjIsCand
(
Gia_Obj_t
*
pObj
)
{
return
Gia_ObjIsAnd
(
pObj
)
||
Gia_ObjIsCi
(
pObj
);
}
static
inline
int
Gia_ObjIsConst0
(
Gia_Obj_t
*
pObj
)
{
return
pObj
->
iDiff0
==
GIA_NONE
&&
pObj
->
iDiff1
==
GIA_NONE
;
}
static
inline
int
Gia_ManObjIsConst0
(
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
){
return
pObj
==
p
->
pObjs
;
}
...
...
@@ -232,6 +239,12 @@ static inline int Gia_ObjWhatFanin( Gia_Obj_t * pObj, Gia_Obj_t * pFani
static
inline
int
Gia_ObjFanin0Copy
(
Gia_Obj_t
*
pObj
)
{
return
Gia_LitNotCond
(
Gia_ObjFanin0
(
pObj
)
->
Value
,
Gia_ObjFaninC0
(
pObj
)
);
}
static
inline
int
Gia_ObjFanin1Copy
(
Gia_Obj_t
*
pObj
)
{
return
Gia_LitNotCond
(
Gia_ObjFanin1
(
pObj
)
->
Value
,
Gia_ObjFaninC1
(
pObj
)
);
}
static
inline
int
Gia_ObjCopyF
(
Gia_Man_t
*
p
,
int
f
,
Gia_Obj_t
*
pObj
)
{
return
p
->
pCopies
[
Gia_ManObjNum
(
p
)
*
f
+
Gia_ObjId
(
p
,
pObj
)];
}
static
inline
void
Gia_ObjSetCopyF
(
Gia_Man_t
*
p
,
int
f
,
Gia_Obj_t
*
pObj
,
int
iLit
)
{
p
->
pCopies
[
Gia_ManObjNum
(
p
)
*
f
+
Gia_ObjId
(
p
,
pObj
)]
=
iLit
;
}
static
inline
int
Gia_ObjFanin0CopyF
(
Gia_Man_t
*
p
,
int
f
,
Gia_Obj_t
*
pObj
)
{
return
Gia_LitNotCond
(
Gia_ObjCopyF
(
p
,
f
,
Gia_ObjFanin0
(
pObj
)),
Gia_ObjFaninC0
(
pObj
));
}
static
inline
int
Gia_ObjFanin1CopyF
(
Gia_Man_t
*
p
,
int
f
,
Gia_Obj_t
*
pObj
)
{
return
Gia_LitNotCond
(
Gia_ObjCopyF
(
p
,
f
,
Gia_ObjFanin1
(
pObj
)),
Gia_ObjFaninC1
(
pObj
));
}
static
inline
Gia_Obj_t
*
Gia_ObjFromLit
(
Gia_Man_t
*
p
,
int
iLit
)
{
return
Gia_NotCond
(
Gia_ManObj
(
p
,
Gia_Lit2Var
(
iLit
)),
Gia_LitIsCompl
(
iLit
)
);
}
static
inline
int
Gia_ObjToLit
(
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
)
{
return
Gia_Var2Lit
(
Gia_ObjId
(
p
,
pObj
),
Gia_IsComplement
(
pObj
)
);
}
static
inline
int
Gia_ObjPhaseRealLit
(
Gia_Man_t
*
p
,
int
iLit
)
{
return
Gia_ObjPhaseReal
(
Gia_ObjFromLit
(
p
,
iLit
)
);
}
...
...
@@ -397,6 +410,8 @@ static inline int * Gia_ObjGateFanins( Gia_Man_t * p, int Id ) { re
for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Gia_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
#define Gia_ManForEachObjVecLit( vVec, p, pObj, fCompl, i ) \
for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Gia_ManObj(p, Gia_Lit2Var(Vec_IntEntry(vVec,i)))) && (((fCompl) = Gia_LitIsCompl(Vec_IntEntry(vVec,i))),1); i++ )
#define Gia_ManForEachObjReverse( p, pObj, i ) \
for ( i = p->nObjs - 1; (i > 0) && ((pObj) = Gia_ManObj(p, i)); i-- )
#define Gia_ManForEachAnd( p, pObj, i ) \
for ( i = 0; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ ) if ( !Gia_ObjIsAnd(pObj) ) {} else
#define Gia_ManForEachCi( p, pObj, i ) \
...
...
@@ -429,6 +444,9 @@ extern Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck );
extern
void
Gia_WriteAiger
(
Gia_Man_t
*
p
,
char
*
pFileName
,
int
fWriteSymbols
,
int
fCompact
);
/*=== giaCof.c ============================================================*/
extern
void
Gia_ManPrintFanio
(
Gia_Man_t
*
pGia
,
int
nNodes
);
extern
Gia_Man_t
*
Gia_ManDupCof
(
Gia_Man_t
*
p
,
int
iVar
);
extern
Gia_Man_t
*
Gia_ManDupCofAllInt
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vSigs
,
int
fVerbose
);
extern
Gia_Man_t
*
Gia_ManDupCofAll
(
Gia_Man_t
*
p
,
int
nFanLim
,
int
fVerbose
);
/*=== giaDfs.c ============================================================*/
extern
void
Gia_ManCollectCis
(
Gia_Man_t
*
p
,
int
*
pNodes
,
int
nNodes
,
Vec_Int_t
*
vSupp
);
extern
void
Gia_ManCollectAnds
(
Gia_Man_t
*
p
,
int
*
pNodes
,
int
nNodes
,
Vec_Int_t
*
vNodes
);
...
...
@@ -436,6 +454,7 @@ extern int Gia_ManSuppSize( Gia_Man_t * p, int * pNodes, int nNo
extern
int
Gia_ManConeSize
(
Gia_Man_t
*
p
,
int
*
pNodes
,
int
nNodes
);
/*=== giaDup.c ============================================================*/
extern
Gia_Man_t
*
Gia_ManDup
(
Gia_Man_t
*
p
);
extern
Gia_Man_t
*
Gia_ManDupSelf
(
Gia_Man_t
*
p
);
extern
Gia_Man_t
*
Gia_ManDupMarked
(
Gia_Man_t
*
p
);
extern
Gia_Man_t
*
Gia_ManDupTimes
(
Gia_Man_t
*
p
,
int
nTimes
);
extern
Gia_Man_t
*
Gia_ManDupDfs
(
Gia_Man_t
*
p
);
...
...
@@ -444,22 +463,23 @@ extern Gia_Man_t * Gia_ManDupDfsCone( Gia_Man_t * p, Gia_Obj_t * pObj );
extern
Gia_Man_t
*
Gia_ManDupDfsLitArray
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vLits
);
extern
Gia_Man_t
*
Gia_ManDupNormalized
(
Gia_Man_t
*
p
);
extern
Gia_Man_t
*
Gia_ManDupTrimmed
(
Gia_Man_t
*
p
,
int
fTrimCis
,
int
fTrimCos
);
extern
Gia_Man_t
*
Gia_ManDupCofactored
(
Gia_Man_t
*
p
,
int
iVar
,
int
nLimFan
);
extern
Gia_Man_t
*
Gia_ManDupDfsCiMap
(
Gia_Man_t
*
p
,
int
*
pCi2Lit
,
Vec_Int_t
*
vLits
);
extern
Gia_Man_t
*
Gia_ManDupDfsClasses
(
Gia_Man_t
*
p
);
extern
Gia_Man_t
*
Gia_ManDupTopAnd
(
Gia_Man_t
*
p
,
int
fVerbose
);
extern
Gia_Man_t
*
Gia_ManMiter
(
Gia_Man_t
*
pAig0
,
Gia_Man_t
*
pAig1
,
int
fDualOut
,
int
fSeq
,
int
fVerbose
);
extern
Gia_Man_t
*
Gia_ManTransformMiter
(
Gia_Man_t
*
p
);
/*=== giaEnable.c ==========================================================*/
extern
void
Gia_ManDetectSeqSignals
(
Gia_Man_t
*
p
,
int
fSetReset
);
extern
void
Gia_ManDetectSeqSignals
(
Gia_Man_t
*
p
,
int
fSetReset
,
int
fVerbose
);
extern
Gia_Man_t
*
Gia_ManUnrollAndCofactor
(
Gia_Man_t
*
p
,
int
nFrames
,
int
nFanMax
,
int
fVerbose
);
/*=== giaEquiv.c ==========================================================*/
extern
int
Gia_ManCheckTopoOrder
(
Gia_Man_t
*
p
);
extern
int
*
Gia_ManDeriveNexts
(
Gia_Man_t
*
p
);
extern
void
Gia_ManEquivPrintOne
(
Gia_Man_t
*
p
,
int
i
,
int
Counter
);
extern
void
Gia_ManEquivPrintClasses
(
Gia_Man_t
*
p
,
int
fVerbose
,
float
Mem
);
extern
Gia_Man_t
*
Gia_ManEquivReduce
(
Gia_Man_t
*
p
,
int
fUseAll
);
extern
Gia_Man_t
*
Gia_ManEquivReduce
(
Gia_Man_t
*
p
,
int
fUseAll
,
int
fDualOut
,
int
fVerbose
);
extern
Gia_Man_t
*
Gia_ManEquivReduceAndRemap
(
Gia_Man_t
*
p
,
int
fSeq
,
int
fMiterPairs
);
extern
int
Gia_ManEquivSetColors
(
Gia_Man_t
*
p
,
int
fVerbose
);
extern
Gia_Man_t
*
Gia_ManSpecReduce
(
Gia_Man_t
*
p
,
int
fDualOut
);
extern
Gia_Man_t
*
Gia_ManSpecReduce
(
Gia_Man_t
*
p
,
int
fDualOut
,
int
fVerbose
);
extern
Gia_Man_t
*
Gia_ManSpecReduceInit
(
Gia_Man_t
*
p
,
Gia_Cex_t
*
pInit
,
int
nFrames
,
int
fDualOut
);
extern
void
Gia_ManEquivTransform
(
Gia_Man_t
*
p
,
int
fVerbose
);
/*=== giaFanout.c =========================================================*/
...
...
src/aig/gia/giaAig.c
View file @
81b51657
...
...
@@ -205,6 +205,29 @@ Aig_Man_t * Gia_ManToAig( Gia_Man_t * p )
return
pNew
;
}
/**Function*************************************************************
Synopsis [Duplicates AIG in the DFS order.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Man_t
*
Gia_ManCofactorAig
(
Aig_Man_t
*
p
,
int
nFrames
,
int
nCofFanLit
)
{
Aig_Man_t
*
pMan
;
Gia_Man_t
*
pGia
,
*
pTemp
;
pGia
=
Gia_ManFromAig
(
p
);
pGia
=
Gia_ManUnrollAndCofactor
(
pTemp
=
pGia
,
nFrames
,
nCofFanLit
,
1
);
Gia_ManStop
(
pTemp
);
pMan
=
Gia_ManToAig
(
pGia
);
Gia_ManStop
(
pGia
);
return
pMan
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
src/aig/gia/giaAiger.c
View file @
81b51657
...
...
@@ -230,6 +230,7 @@ Gia_Rpr_t * Gia_ReadEquivClasses( unsigned char ** ppPos, int nSize )
iNode
+=
Item
;
pReprs
[
iNode
].
fProved
=
fProved
;
pReprs
[
iNode
].
iRepr
=
iRepr
;
assert
(
iRepr
<
iNode
);
//printf( "Node = %d ", iNode );
}
return
pReprs
;
...
...
src/aig/gia/giaCof.c
View file @
81b51657
...
...
@@ -685,6 +685,232 @@ ABC_PRT( "Time", clock() - clk );
}
/**Function*************************************************************
Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManDupCofInt
(
Gia_Man_t
*
p
,
int
iVar
)
{
Gia_Man_t
*
pNew
;
Gia_Obj_t
*
pObj
,
*
pPivot
;
int
i
,
iCofVar
=
-
1
;
if
(
!
(
iVar
>
0
&&
iVar
<
Gia_ManObjNum
(
p
))
)
{
printf
(
"Gia_ManDupCof(): Variable %d is out of range (%d; %d).
\n
"
,
iVar
,
0
,
Gia_ManObjNum
(
p
)
);
return
NULL
;
}
// find the cofactoring variable
pPivot
=
Gia_ManObj
(
p
,
iVar
);
if
(
!
Gia_ObjIsCand
(
pPivot
)
)
{
printf
(
"Gia_ManDupCof(): Variable %d should be a CI or an AND node.
\n
"
,
iVar
);
return
NULL
;
}
pNew
=
Gia_ManStart
(
Gia_ManObjNum
(
p
)
);
pNew
->
pName
=
Aig_UtilStrsav
(
p
->
pName
);
Gia_ManHashAlloc
(
pNew
);
Gia_ManFillValue
(
p
);
Gia_ManConst0
(
p
)
->
Value
=
0
;
// compute negative cofactor
Gia_ManForEachCi
(
p
,
pObj
,
i
)
{
pObj
->
Value
=
Gia_ManAppendCi
(
pNew
);
if
(
pObj
==
pPivot
)
{
iCofVar
=
pObj
->
Value
;
pObj
->
Value
=
Gia_Var2Lit
(
0
,
0
);
}
}
Gia_ManForEachAnd
(
p
,
pObj
,
i
)
{
pObj
->
Value
=
Gia_ManHashAnd
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
),
Gia_ObjFanin1Copy
(
pObj
)
);
if
(
pObj
==
pPivot
)
{
iCofVar
=
pObj
->
Value
;
pObj
->
Value
=
Gia_Var2Lit
(
0
,
0
);
}
}
Gia_ManForEachCo
(
p
,
pObj
,
i
)
pObj
->
Value
=
Gia_ObjFanin0Copy
(
pObj
);
// compute the positive cofactor
Gia_ManForEachCi
(
p
,
pObj
,
i
)
{
pObj
->
Value
=
Gia_Var2Lit
(
Gia_ObjId
(
pNew
,
Gia_ManCi
(
pNew
,
i
)),
0
);
if
(
pObj
==
pPivot
)
pObj
->
Value
=
Gia_Var2Lit
(
0
,
1
);
}
Gia_ManForEachAnd
(
p
,
pObj
,
i
)
{
pObj
->
Value
=
Gia_ManHashAnd
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
),
Gia_ObjFanin1Copy
(
pObj
)
);
if
(
pObj
==
pPivot
)
pObj
->
Value
=
Gia_Var2Lit
(
0
,
1
);
}
// create MUXes
assert
(
iCofVar
>
0
);
Gia_ManForEachCo
(
p
,
pObj
,
i
)
{
if
(
pObj
->
Value
==
(
unsigned
)
Gia_ObjFanin0Copy
(
pObj
)
)
pObj
->
Value
=
Gia_ManAppendCo
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
)
);
else
pObj
->
Value
=
Gia_ManAppendCo
(
pNew
,
Gia_ManHashMux
(
pNew
,
iCofVar
,
Gia_ObjFanin0Copy
(
pObj
),
pObj
->
Value
)
);
}
Gia_ManHashStop
(
pNew
);
Gia_ManSetRegNum
(
pNew
,
Gia_ManRegNum
(
p
)
);
return
pNew
;
}
/**Function*************************************************************
Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManDupCof
(
Gia_Man_t
*
p
,
int
iVar
)
{
Gia_Man_t
*
pNew
,
*
pTemp
;
pNew
=
Gia_ManDupCofInt
(
p
,
iVar
);
pNew
=
Gia_ManCleanup
(
pTemp
=
pNew
);
Gia_ManStop
(
pTemp
);
return
pNew
;
}
/**Function*************************************************************
Synopsis [Determines variables whose fanout count is higher than this.]
Description [Variables are returned in a reverse topological order.]
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t
*
Gia_ManCofVars
(
Gia_Man_t
*
p
,
int
nFanLim
)
{
Vec_Int_t
*
vVars
;
Gia_Obj_t
*
pObj
;
int
i
;
ABC_FREE
(
p
->
pRefs
);
Gia_ManCreateRefs
(
p
);
vVars
=
Vec_IntAlloc
(
100
);
Gia_ManForEachObj
(
p
,
pObj
,
i
)
if
(
Gia_ObjIsCand
(
pObj
)
&&
Gia_ObjRefs
(
p
,
pObj
)
>=
nFanLim
)
Vec_IntPush
(
vVars
,
i
);
ABC_FREE
(
p
->
pRefs
);
return
vVars
;
}
/**Function*************************************************************
Synopsis [Transfers attributes from the original one to the final one.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t
*
Gia_ManTransfer
(
Gia_Man_t
*
pAig
,
Gia_Man_t
*
pCof
,
Gia_Man_t
*
pNew
,
Vec_Int_t
*
vSigs
)
{
Vec_Int_t
*
vSigsNew
;
Gia_Obj_t
*
pObj
,
*
pObjF
;
int
i
;
vSigsNew
=
Vec_IntAlloc
(
100
);
Gia_ManForEachObjVec
(
vSigs
,
pAig
,
pObj
,
i
)
{
assert
(
Gia_ObjIsCand
(
pObj
)
);
pObjF
=
Gia_ManObj
(
pCof
,
Gia_Lit2Var
(
pObj
->
Value
)
);
if
(
pObjF
->
Value
&&
~
pObjF
->
Value
)
Vec_IntPushUnique
(
vSigsNew
,
Gia_Lit2Var
(
pObjF
->
Value
)
);
}
return
vSigsNew
;
}
/**Function*************************************************************
Synopsis [Cofactors selected variables (should be in reverse topo order).]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManDupCofAllInt
(
Gia_Man_t
*
p
,
Vec_Int_t
*
vSigs
,
int
fVerbose
)
{
Vec_Int_t
*
vSigsNew
,
*
vTemp
;
Gia_Man_t
*
pAig
,
*
pCof
,
*
pNew
;
int
iVar
;
if
(
fVerbose
)
{
printf
(
"Cofactoring %d signals.
\n
"
,
Vec_IntSize
(
vSigs
)
);
Gia_ManPrintStats
(
p
);
}
if
(
Vec_IntSize
(
vSigs
)
>
200
)
{
printf
(
"Too many signals to cofactor.
\n
"
);
return
NULL
;
}
pAig
=
Gia_ManDup
(
p
);
vSigsNew
=
Vec_IntDup
(
vSigs
);
while
(
Vec_IntSize
(
vSigsNew
)
>
0
)
{
Vec_IntSort
(
vSigsNew
,
0
);
iVar
=
Vec_IntPop
(
vSigsNew
);
// Gia_ManCreateRefs( pAig );
// printf( "ref count = %d\n", Gia_ObjRefs( pAig, Gia_ManObj(pAig, iVar) ) );
// ABC_FREE( pAig->pRefs );
pCof
=
Gia_ManDupCofInt
(
pAig
,
iVar
);
pNew
=
Gia_ManCleanup
(
pCof
);
vSigsNew
=
Gia_ManTransfer
(
pAig
,
pCof
,
pNew
,
vTemp
=
vSigsNew
);
Vec_IntFree
(
vTemp
);
Gia_ManStop
(
pAig
);
Gia_ManStop
(
pCof
);
pAig
=
pNew
;
if
(
fVerbose
)
printf
(
"Cofactored variable %d.
\n
"
,
iVar
);
if
(
fVerbose
)
Gia_ManPrintStats
(
pAig
);
}
Vec_IntFree
(
vSigsNew
);
return
pAig
;
}
/**Function*************************************************************
Synopsis [Cofactors all variables whose fanout is higher than this.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManDupCofAll
(
Gia_Man_t
*
p
,
int
nFanLim
,
int
fVerbose
)
{
Gia_Man_t
*
pNew
;
Vec_Int_t
*
vSigs
=
Gia_ManCofVars
(
p
,
nFanLim
);
pNew
=
Gia_ManDupCofAllInt
(
p
,
vSigs
,
fVerbose
);
Vec_IntFree
(
vSigs
);
return
pNew
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
src/aig/gia/giaDup.c
View file @
81b51657
...
...
@@ -62,6 +62,45 @@ Gia_Man_t * Gia_ManDup( Gia_Man_t * p )
/**Function*************************************************************
Synopsis [Duplicates while adding self-loops to the registers.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManDupSelf
(
Gia_Man_t
*
p
)
{
Gia_Man_t
*
pNew
,
*
pTemp
;
Gia_Obj_t
*
pObj
;
int
i
,
iCtrl
;
pNew
=
Gia_ManStart
(
Gia_ManObjNum
(
p
)
);
pNew
->
pName
=
Aig_UtilStrsav
(
p
->
pName
);
Gia_ManHashAlloc
(
pNew
);
Gia_ManFillValue
(
p
);
Gia_ManConst0
(
p
)
->
Value
=
0
;
iCtrl
=
Gia_ManAppendCi
(
pNew
);
Gia_ManForEachCi
(
p
,
pObj
,
i
)
pObj
->
Value
=
Gia_ManAppendCi
(
pNew
);
Gia_ManForEachAnd
(
p
,
pObj
,
i
)
pObj
->
Value
=
Gia_ManHashAnd
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
),
Gia_ObjFanin1Copy
(
pObj
)
);
Gia_ManForEachPo
(
p
,
pObj
,
i
)
pObj
->
Value
=
Gia_ObjFanin0Copy
(
pObj
);
Gia_ManForEachRi
(
p
,
pObj
,
i
)
pObj
->
Value
=
Gia_ManHashMux
(
pNew
,
iCtrl
,
Gia_ObjFanin0Copy
(
pObj
),
Gia_ObjRiToRo
(
p
,
pObj
)
->
Value
);
Gia_ManForEachCo
(
p
,
pObj
,
i
)
Gia_ManAppendCo
(
pNew
,
pObj
->
Value
);
Gia_ManHashStop
(
pNew
);
Gia_ManSetRegNum
(
pNew
,
Gia_ManRegNum
(
p
)
);
pNew
=
Gia_ManCleanup
(
pTemp
=
pNew
);
Gia_ManStop
(
pTemp
);
return
pNew
;
}
/**Function*************************************************************
Synopsis [Duplicates AIG without any changes.]
Description []
...
...
@@ -192,22 +231,22 @@ Gia_Man_t * Gia_ManDupTimes( Gia_Man_t * p, int nTimes )
SeeAlso []
***********************************************************************/
int
Gia_ManDupDfs_rec
(
Gia_Man_t
*
pNew
,
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
)
int
Gia_ManDupDfs
2
_rec
(
Gia_Man_t
*
pNew
,
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
)
{
if
(
~
pObj
->
Value
)
return
pObj
->
Value
;
if
(
p
->
pReprsOld
&&
~
p
->
pReprsOld
[
Gia_ObjId
(
p
,
pObj
)]
)
{
Gia_Obj_t
*
pRepr
=
Gia_ManObj
(
p
,
p
->
pReprsOld
[
Gia_ObjId
(
p
,
pObj
)]
);
pRepr
->
Value
=
Gia_ManDupDfs_rec
(
pNew
,
p
,
pRepr
);
pRepr
->
Value
=
Gia_ManDupDfs
2
_rec
(
pNew
,
p
,
pRepr
);
return
pObj
->
Value
=
Gia_LitNotCond
(
pRepr
->
Value
,
Gia_ObjPhaseReal
(
pRepr
)
^
Gia_ObjPhaseReal
(
pObj
)
);
}
if
(
Gia_ObjIsCi
(
pObj
)
)
return
pObj
->
Value
=
Gia_ManAppendCi
(
pNew
);
Gia_ManDupDfs_rec
(
pNew
,
p
,
Gia_ObjFanin0
(
pObj
)
);
Gia_ManDupDfs
2
_rec
(
pNew
,
p
,
Gia_ObjFanin0
(
pObj
)
);
if
(
Gia_ObjIsCo
(
pObj
)
)
return
pObj
->
Value
=
Gia_ManAppendCo
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
)
);
Gia_ManDupDfs_rec
(
pNew
,
p
,
Gia_ObjFanin1
(
pObj
)
);
Gia_ManDupDfs
2
_rec
(
pNew
,
p
,
Gia_ObjFanin1
(
pObj
)
);
if
(
pNew
->
pHTable
)
return
pObj
->
Value
=
Gia_ManHashAnd
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
),
Gia_ObjFanin1Copy
(
pObj
)
);
return
pObj
->
Value
=
Gia_ManAppendAnd
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
),
Gia_ObjFanin1Copy
(
pObj
)
);
...
...
@@ -224,7 +263,7 @@ int Gia_ManDupDfs_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManDupDfs
(
Gia_Man_t
*
p
)
Gia_Man_t
*
Gia_ManDupDfs
2
(
Gia_Man_t
*
p
)
{
Gia_Man_t
*
pNew
;
Gia_Obj_t
*
pObj
,
*
pObjNew
;
...
...
@@ -234,7 +273,7 @@ Gia_Man_t * Gia_ManDupDfs( Gia_Man_t * p )
pNew
->
pName
=
Aig_UtilStrsav
(
p
->
pName
);
Gia_ManConst0
(
p
)
->
Value
=
0
;
Gia_ManForEachCo
(
p
,
pObj
,
i
)
Gia_ManDupDfs_rec
(
pNew
,
p
,
pObj
);
Gia_ManDupDfs
2
_rec
(
pNew
,
p
,
pObj
);
Gia_ManForEachCi
(
p
,
pObj
,
i
)
if
(
~
pObj
->
Value
==
0
)
pObj
->
Value
=
Gia_ManAppendCi
(
pNew
);
...
...
@@ -253,6 +292,57 @@ Gia_Man_t * Gia_ManDupDfs( Gia_Man_t * p )
/**Function*************************************************************
Synopsis [Duplicates the AIG in the DFS order.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Gia_ManDupDfs_rec
(
Gia_Man_t
*
pNew
,
Gia_Man_t
*
p
,
Gia_Obj_t
*
pObj
)
{
if
(
~
pObj
->
Value
)
return
;
assert
(
Gia_ObjIsAnd
(
pObj
)
);
Gia_ManDupDfs_rec
(
pNew
,
p
,
Gia_ObjFanin0
(
pObj
)
);
Gia_ManDupDfs_rec
(
pNew
,
p
,
Gia_ObjFanin1
(
pObj
)
);
pObj
->
Value
=
Gia_ManAppendAnd
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
),
Gia_ObjFanin1Copy
(
pObj
)
);
}
/**Function*************************************************************
Synopsis [Duplicates AIG in the DFS order.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManDupDfs
(
Gia_Man_t
*
p
)
{
Gia_Man_t
*
pNew
;
Gia_Obj_t
*
pObj
;
int
i
;
pNew
=
Gia_ManStart
(
Gia_ManObjNum
(
p
)
);
pNew
->
pName
=
Aig_UtilStrsav
(
p
->
pName
);
Gia_ManFillValue
(
p
);
Gia_ManConst0
(
p
)
->
Value
=
0
;
Gia_ManForEachCi
(
p
,
pObj
,
i
)
pObj
->
Value
=
Gia_ManAppendCi
(
pNew
);
Gia_ManForEachCo
(
p
,
pObj
,
i
)
Gia_ManDupDfs_rec
(
pNew
,
p
,
Gia_ObjFanin0
(
pObj
)
);
Gia_ManForEachCo
(
p
,
pObj
,
i
)
Gia_ManAppendCo
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
)
);
Gia_ManSetRegNum
(
pNew
,
Gia_ManRegNum
(
p
)
);
return
pNew
;
}
/**Function*************************************************************
Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
Description []
...
...
@@ -332,7 +422,7 @@ Gia_Man_t * Gia_ManDupDfsLitArray( Gia_Man_t * p, Vec_Int_t * vLits )
pObj
->
Value
=
Gia_ManAppendCi
(
pNew
);
Vec_IntForEachEntry
(
vLits
,
iLit
,
i
)
{
iLitRes
=
Gia_ManDupDfs_rec
(
pNew
,
p
,
Gia_ManObj
(
p
,
Gia_Lit2Var
(
iLit
))
);
iLitRes
=
Gia_ManDupDfs
2
_rec
(
pNew
,
p
,
Gia_ManObj
(
p
,
Gia_Lit2Var
(
iLit
))
);
Gia_ManAppendCo
(
pNew
,
Gia_LitNotCond
(
iLitRes
,
Gia_LitIsCompl
(
iLit
))
);
}
Gia_ManSetRegNum
(
pNew
,
0
);
...
...
@@ -404,95 +494,6 @@ Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p, int fTrimCis, int fTrimCos )
/**Function*************************************************************
Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManDupCofactored
(
Gia_Man_t
*
p
,
int
iVar
,
int
nLimFan
)
{
Gia_Man_t
*
pNew
,
*
pTemp
;
Gia_Obj_t
*
pObj
,
*
pPivot
;
int
i
,
iCofVar
=
-
1
;
if
(
nLimFan
>
0
)
{
printf
(
"This feature is not implemented.
\n
"
);
return
NULL
;
}
if
(
!
(
iVar
>
0
&&
iVar
<
Gia_ManObjNum
(
p
))
)
{
printf
(
"Gia_ManDupCofactored(): Variable %d is out of range (%d; %d).
\n
"
,
iVar
,
0
,
Gia_ManObjNum
(
p
)
);
return
NULL
;
}
// find the cofactoring variable
pPivot
=
Gia_ManObj
(
p
,
iVar
);
if
(
!
(
Gia_ObjIsCi
(
pPivot
)
||
Gia_ObjIsAnd
(
pPivot
))
)
{
printf
(
"Gia_ManDupCofactored(): Variable %d should be a CI or an AND node.
\n
"
,
iVar
);
return
NULL
;
}
// assert( Gia_ManRegNum(p) == 0 );
pNew
=
Gia_ManStart
(
Gia_ManObjNum
(
p
)
);
pNew
->
pName
=
Aig_UtilStrsav
(
p
->
pName
);
Gia_ManHashAlloc
(
pNew
);
Gia_ManConst0
(
p
)
->
Value
=
0
;
// compute negative cofactor
Gia_ManForEachCi
(
p
,
pObj
,
i
)
{
pObj
->
Value
=
Gia_ManAppendCi
(
pNew
);
if
(
pObj
==
pPivot
)
{
iCofVar
=
pObj
->
Value
;
pObj
->
Value
=
Gia_Var2Lit
(
0
,
0
);
}
}
Gia_ManForEachAnd
(
p
,
pObj
,
i
)
{
pObj
->
Value
=
Gia_ManHashAnd
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
),
Gia_ObjFanin1Copy
(
pObj
)
);
if
(
pObj
==
pPivot
)
{
iCofVar
=
pObj
->
Value
;
pObj
->
Value
=
Gia_Var2Lit
(
0
,
0
);
}
}
Gia_ManForEachCo
(
p
,
pObj
,
i
)
pObj
->
Value
=
Gia_ObjFanin0Copy
(
pObj
);
// compute the positive cofactor
Gia_ManForEachCi
(
p
,
pObj
,
i
)
{
pObj
->
Value
=
Gia_Var2Lit
(
Gia_ObjId
(
pNew
,
Gia_ManCi
(
pNew
,
i
)),
0
);
if
(
pObj
==
pPivot
)
pObj
->
Value
=
Gia_Var2Lit
(
0
,
1
);
}
Gia_ManForEachAnd
(
p
,
pObj
,
i
)
{
pObj
->
Value
=
Gia_ManHashAnd
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
),
Gia_ObjFanin1Copy
(
pObj
)
);
if
(
pObj
==
pPivot
)
pObj
->
Value
=
Gia_Var2Lit
(
0
,
1
);
}
// create MUXes
assert
(
iCofVar
>
0
);
Gia_ManForEachCo
(
p
,
pObj
,
i
)
{
if
(
pObj
->
Value
==
(
unsigned
)
Gia_ObjFanin0Copy
(
pObj
)
)
pObj
->
Value
=
Gia_ManAppendCo
(
pNew
,
Gia_ObjFanin0Copy
(
pObj
)
);
else
pObj
->
Value
=
Gia_ManAppendCo
(
pNew
,
Gia_ManHashMux
(
pNew
,
iCofVar
,
Gia_ObjFanin0Copy
(
pObj
),
pObj
->
Value
)
);
}
Gia_ManHashStop
(
pNew
);
Gia_ManSetRegNum
(
pNew
,
Gia_ManRegNum
(
p
)
);
// rehash the result
pNew
=
Gia_ManCleanup
(
pTemp
=
pNew
);
Gia_ManStop
(
pTemp
);
return
pNew
;
}
/**Function*************************************************************
Synopsis [Print representatives.]
Description []
...
...
@@ -544,7 +545,7 @@ Gia_Man_t * Gia_ManDupDfsCiMap( Gia_Man_t * p, int * pCi2Lit, Vec_Int_t * vLits
int
iLit
,
iLitRes
;
Vec_IntForEachEntry
(
vLits
,
iLit
,
i
)
{
iLitRes
=
Gia_ManDupDfs_rec
(
pNew
,
p
,
Gia_ManObj
(
p
,
Gia_Lit2Var
(
iLit
))
);
iLitRes
=
Gia_ManDupDfs
2
_rec
(
pNew
,
p
,
Gia_ManObj
(
p
,
Gia_Lit2Var
(
iLit
))
);
Gia_ManAppendCo
(
pNew
,
Gia_LitNotCond
(
iLitRes
,
Gia_LitIsCompl
(
iLit
))
);
}
}
...
...
src/aig/gia/giaEnable.c
View file @
81b51657
...
...
@@ -104,7 +104,7 @@ void Gia_ManPrintSignals( Gia_Man_t * p, int * pFreq, char * pStr )
printf
(
"%s (total = %d driven = %d)
\n
"
,
pStr
,
Counter
,
nTotal
);
Counter
=
0
;
for
(
i
=
0
;
i
<
Gia_ManObjNum
(
p
);
i
++
)
if
(
pFreq
[
i
]
>
1
)
if
(
pFreq
[
i
]
>
1
0
)
{
printf
(
"%3d : Obj = %6d Refs = %6d Freq = %6d
\n
"
,
++
Counter
,
i
,
Gia_ObjRefs
(
p
,
Gia_ManObj
(
p
,
i
)),
pFreq
[
i
]
);
...
...
@@ -124,7 +124,7 @@ void Gia_ManPrintSignals( Gia_Man_t * p, int * pFreq, char * pStr )
SeeAlso []
***********************************************************************/
void
Gia_ManDetectSeqSignals
(
Gia_Man_t
*
p
,
int
fSetReset
)
void
Gia_ManDetectSeqSignals
(
Gia_Man_t
*
p
,
int
fSetReset
,
int
fVerbose
)
{
Vec_Int_t
*
vSuper
;
Gia_Obj_t
*
pFlop
,
*
pObjC
,
*
pObj0
,
*
pObj1
,
*
pNode
,
*
pTemp
;
...
...
@@ -189,7 +189,10 @@ void Gia_ManDetectSeqSignals( Gia_Man_t * p, int fSetReset )
}
}
Vec_IntFree
(
vSuper
);
ABC_FREE
(
p
->
pRefs
);
Gia_ManCreateRefs
(
p
);
if
(
fVerbose
)
{
printf
(
"Flops with set/reset = %6d. Flops with enable = %6d.
\n
"
,
nHaveSetReset
,
nHaveEnable
);
if
(
fSetReset
)
{
...
...
@@ -197,12 +200,224 @@ void Gia_ManDetectSeqSignals( Gia_Man_t * p, int fSetReset )
Gia_ManPrintSignals
(
p
,
pResets
,
"Reset signals"
);
}
Gia_ManPrintSignals
(
p
,
pEnables
,
"Enable signals"
);
}
ABC_FREE
(
p
->
pRefs
);
ABC_FREE
(
pSets
);
ABC_FREE
(
pResets
);
ABC_FREE
(
pEnables
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t
*
Gia_ManDetectSeqSignalsWithFanout
(
Gia_Man_t
*
p
,
int
nFanMax
,
int
fVerbose
)
{
Vec_Int_t
*
vResult
;
Vec_Int_t
*
vSuper
;
Gia_Obj_t
*
pFlop
,
*
pObjC
,
*
pObj0
,
*
pObj1
,
*
pNode
,
*
pTemp
;
int
i
,
k
,
Ent
,
*
pSets
,
*
pResets
,
*
pEnables
;
int
nHaveSetReset
=
0
,
nHaveEnable
=
0
;
assert
(
Gia_ManRegNum
(
p
)
>
0
);
pSets
=
ABC_CALLOC
(
int
,
Gia_ManObjNum
(
p
)
);
pResets
=
ABC_CALLOC
(
int
,
Gia_ManObjNum
(
p
)
);
pEnables
=
ABC_CALLOC
(
int
,
Gia_ManObjNum
(
p
)
);
vSuper
=
Vec_IntAlloc
(
100
);
Gia_ManForEachRi
(
p
,
pFlop
,
i
)
{
pNode
=
Gia_ObjFanin0
(
pFlop
);
if
(
!
Gia_ObjIsAnd
(
pNode
)
)
continue
;
// detect sets/resets
Gia_CollectSuper
(
p
,
pNode
,
vSuper
);
if
(
Gia_ObjFaninC0
(
pFlop
)
)
Vec_IntForEachEntry
(
vSuper
,
Ent
,
k
)
pSets
[
Ent
]
++
;
else
Vec_IntForEachEntry
(
vSuper
,
Ent
,
k
)
pResets
[
Ent
]
++
;
// detect enables
if
(
!
Gia_ObjIsMuxType
(
pNode
)
)
continue
;
pObjC
=
Gia_ObjRecognizeMux
(
pNode
,
&
pObj0
,
&
pObj1
);
pTemp
=
Gia_ObjRiToRo
(
p
,
pFlop
);
if
(
Gia_Regular
(
pObj0
)
!=
pTemp
&&
Gia_Regular
(
pObj1
)
!=
pTemp
)
continue
;
if
(
!
Gia_ObjFaninC0
(
pFlop
)
)
{
pObj0
=
Gia_Not
(
pObj0
);
pObj1
=
Gia_Not
(
pObj1
);
}
if
(
Gia_IsComplement
(
pObjC
)
)
{
pObjC
=
Gia_Not
(
pObjC
);
pTemp
=
pObj0
;
pObj0
=
pObj1
;
pObj1
=
pTemp
;
}
// detect controls
// Gia_CollectSuper( p, pObjC, vSuper );
// Vec_IntForEachEntry( vSuper, Ent, k )
// pEnables[Ent]++;
pEnables
[
Gia_ObjId
(
p
,
pObjC
)]
++
;
nHaveEnable
++
;
}
Gia_ManForEachRi
(
p
,
pFlop
,
i
)
{
pNode
=
Gia_ObjFanin0
(
pFlop
);
if
(
!
Gia_ObjIsAnd
(
pNode
)
)
continue
;
// detect sets/resets
Gia_CollectSuper
(
p
,
pNode
,
vSuper
);
Vec_IntForEachEntry
(
vSuper
,
Ent
,
k
)
if
(
pSets
[
Ent
]
>
1
||
pResets
[
Ent
]
>
1
)
{
nHaveSetReset
++
;
break
;
}
}
Vec_IntFree
(
vSuper
);
vResult
=
Vec_IntAlloc
(
100
);
for
(
i
=
1
;
i
<
Gia_ManObjNum
(
p
);
i
++
)
if
(
pSets
[
i
]
>
nFanMax
)
{
if
(
fVerbose
)
printf
(
"Adding set signal %d related to %d flops.
\n
"
,
i
,
pSets
[
i
]
);
Vec_IntPushUnique
(
vResult
,
i
);
}
for
(
i
=
1
;
i
<
Gia_ManObjNum
(
p
);
i
++
)
if
(
pResets
[
i
]
>
nFanMax
)
{
if
(
fVerbose
)
printf
(
"Adding reset signal %d related to %d flops.
\n
"
,
i
,
pResets
[
i
]
);
Vec_IntPushUnique
(
vResult
,
i
);
}
for
(
i
=
1
;
i
<
Gia_ManObjNum
(
p
);
i
++
)
if
(
pEnables
[
i
]
>
nFanMax
)
{
if
(
fVerbose
)
printf
(
"Adding enable signal %d related to %d flops.
\n
"
,
i
,
pEnables
[
i
]
);
Vec_IntPushUnique
(
vResult
,
i
);
}
ABC_FREE
(
pSets
);
ABC_FREE
(
pResets
);
ABC_FREE
(
pEnables
);
return
vResult
;
}
/**Function*************************************************************
Synopsis [Transfers attributes from the original one to the final one.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t
*
Gia_ManTransferFrames
(
Gia_Man_t
*
pAig
,
Gia_Man_t
*
pFrames
,
int
nFrames
,
Gia_Man_t
*
pNew
,
Vec_Int_t
*
vSigs
)
{
Vec_Int_t
*
vSigsNew
;
Gia_Obj_t
*
pObj
,
*
pObjF
;
int
k
,
f
;
vSigsNew
=
Vec_IntAlloc
(
100
);
Gia_ManForEachObjVec
(
vSigs
,
pAig
,
pObj
,
k
)
{
assert
(
Gia_ObjIsCand
(
pObj
)
);
for
(
f
=
0
;
f
<
nFrames
;
f
++
)
{
pObjF
=
Gia_ManObj
(
pFrames
,
Gia_Lit2Var
(
Gia_ObjCopyF
(
pAig
,
f
,
pObj
))
);
if
(
pObjF
->
Value
&&
~
pObjF
->
Value
)
Vec_IntPushUnique
(
vSigsNew
,
Gia_Lit2Var
(
pObjF
->
Value
)
);
}
}
return
vSigsNew
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManUnrollInit
(
Gia_Man_t
*
p
,
int
nFrames
)
{
Gia_Man_t
*
pNew
;
Gia_Obj_t
*
pObj
,
*
pObjRi
,
*
pObjRo
;
int
f
,
i
;
ABC_FREE
(
p
->
pCopies
);
p
->
pCopies
=
ABC_FALLOC
(
int
,
nFrames
*
Gia_ManObjNum
(
p
)
);
pNew
=
Gia_ManStart
(
nFrames
*
Gia_ManObjNum
(
p
)
);
pNew
->
pName
=
Aig_UtilStrsav
(
p
->
pName
);
Gia_ManHashAlloc
(
pNew
);
Gia_ManForEachRo
(
p
,
pObj
,
i
)
Gia_ObjSetCopyF
(
p
,
0
,
pObj
,
0
);
for
(
f
=
0
;
f
<
nFrames
;
f
++
)
{
Gia_ObjSetCopyF
(
p
,
f
,
Gia_ManConst0
(
p
),
0
);
Gia_ManForEachPi
(
p
,
pObj
,
i
)
Gia_ObjSetCopyF
(
p
,
f
,
pObj
,
Gia_ManAppendCi
(
pNew
)
);
Gia_ManForEachAnd
(
p
,
pObj
,
i
)
Gia_ObjSetCopyF
(
p
,
f
,
pObj
,
Gia_ManHashAnd
(
pNew
,
Gia_ObjFanin0CopyF
(
p
,
f
,
pObj
),
Gia_ObjFanin1CopyF
(
p
,
f
,
pObj
))
);
Gia_ManForEachCo
(
p
,
pObj
,
i
)
Gia_ObjSetCopyF
(
p
,
f
,
pObj
,
Gia_ObjFanin0CopyF
(
p
,
f
,
pObj
)
);
Gia_ManForEachPo
(
p
,
pObj
,
i
)
Gia_ManAppendCo
(
pNew
,
Gia_ObjCopyF
(
p
,
f
,
pObj
)
);
if
(
f
==
nFrames
-
1
)
break
;
Gia_ManForEachRiRo
(
p
,
pObjRi
,
pObjRo
,
i
)
Gia_ObjSetCopyF
(
p
,
f
+
1
,
pObjRo
,
Gia_ObjCopyF
(
p
,
f
,
pObjRi
)
);
}
Gia_ManHashStop
(
pNew
);
return
pNew
;
}
/**Function*************************************************************
Synopsis [Unrolls initialized timeframes while cofactoring some vars.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t
*
Gia_ManUnrollAndCofactor
(
Gia_Man_t
*
p
,
int
nFrames
,
int
nFanMax
,
int
fVerbose
)
{
Vec_Int_t
*
vCofSigs
,
*
vTemp
;
Gia_Man_t
*
pAig
,
*
pFrames
,
*
pNew
;
// compute initialized timeframes
pFrames
=
Gia_ManUnrollInit
(
p
,
nFrames
);
pAig
=
Gia_ManCleanup
(
pFrames
);
// compute and remap set/reset/enable signals
vCofSigs
=
Gia_ManDetectSeqSignalsWithFanout
(
p
,
nFanMax
,
fVerbose
);
vCofSigs
=
Gia_ManTransferFrames
(
p
,
pFrames
,
nFrames
,
pAig
,
vTemp
=
vCofSigs
);
Vec_IntFree
(
vTemp
);
Gia_ManStop
(
pFrames
);
ABC_FREE
(
p
->
pCopies
);
// cofactor all these variables
pNew
=
Gia_ManDupCofAllInt
(
pAig
,
vCofSigs
,
fVerbose
);
Vec_IntFree
(
vCofSigs
);
Gia_ManStop
(
pAig
);
return
pNew
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
src/aig/gia/giaEquiv.c
View file @
81b51657
This diff is collapsed.
Click to expand it.
src/aig/saig/saig.h
View file @
81b51657
...
...
@@ -92,7 +92,7 @@ static inline Aig_Obj_t * Saig_ObjLiToLo( Aig_Man_t * p, Aig_Obj_t * pObj ) {
/*=== sswAbs.c ==========================================================*/
extern
Aig_Man_t
*
Saig_ManProofAbstraction
(
Aig_Man_t
*
p
,
int
nFrames
,
int
nConfMax
,
int
fDynamic
,
int
fExtend
,
int
fSkipProof
,
int
fVerbose
);
/*=== saigBmc.c ==========================================================*/
extern
int
Saig_ManBmcSimple
(
Aig_Man_t
*
pAig
,
int
nFrames
,
int
nSizeMax
,
int
nBTLimit
,
int
fRewrite
,
int
fVerbose
,
int
*
piFrame
);
extern
int
Saig_ManBmcSimple
(
Aig_Man_t
*
pAig
,
int
nFrames
,
int
nSizeMax
,
int
nBTLimit
,
int
fRewrite
,
int
fVerbose
,
int
*
piFrame
,
int
nCofFanLit
);
extern
void
Saig_BmcPerform
(
Aig_Man_t
*
pAig
,
int
nFramesMax
,
int
nNodesMax
,
int
nConfMaxOne
,
int
nConfMaxAll
,
int
fVerbose
);
/*=== saigCone.c ==========================================================*/
extern
void
Saig_ManPrintCones
(
Aig_Man_t
*
p
);
...
...
src/aig/saig/saigBmc2.c
View file @
81b51657
...
...
@@ -173,16 +173,24 @@ Aig_Man_t * Saig_ManFramesBmcLimit( Aig_Man_t * pAig, int nFrames, int nSizeMax
SeeAlso []
***********************************************************************/
int
Saig_ManBmcSimple
(
Aig_Man_t
*
pAig
,
int
nFrames
,
int
nSizeMax
,
int
nConfLimit
,
int
fRewrite
,
int
fVerbose
,
int
*
piFrame
)
int
Saig_ManBmcSimple
(
Aig_Man_t
*
pAig
,
int
nFrames
,
int
nSizeMax
,
int
nConfLimit
,
int
fRewrite
,
int
fVerbose
,
int
*
piFrame
,
int
nCofFanLit
)
{
extern
Aig_Man_t
*
Gia_ManCofactorAig
(
Aig_Man_t
*
p
,
int
nFrames
,
int
nCofFanLit
);
sat_solver
*
pSat
;
Cnf_Dat_t
*
pCnf
;
Aig_Man_t
*
pFrames
,
*
pAigTemp
;
Aig_Obj_t
*
pObj
;
int
status
,
clk
,
Lit
,
i
,
RetValue
=
1
;
// derive the timeframes
clk
=
clock
();
if
(
nSizeMax
>
0
)
if
(
nCofFanLit
)
{
pFrames
=
Gia_ManCofactorAig
(
pAig
,
nFrames
,
nCofFanLit
);
if
(
pFrames
==
NULL
)
return
-
1
;
}
else
if
(
nSizeMax
>
0
)
{
pFrames
=
Saig_ManFramesBmcLimit
(
pAig
,
nFrames
,
nSizeMax
);
nFrames
=
Aig_ManPoNum
(
pFrames
)
/
Saig_ManPoNum
(
pAig
)
+
((
Aig_ManPoNum
(
pFrames
)
%
Saig_ManPoNum
(
pAig
))
>
0
);
...
...
src/aig/ssw/sswCore.c
View file @
81b51657
...
...
@@ -146,6 +146,18 @@ Aig_Man_t * Ssw_SignalCorrespondenceRefine( Ssw_Man_t * p )
nSatProof
=
nSatCallsSat
=
nRecycles
=
nSatFailsReal
=
nUniques
=
0
;
for
(
nIter
=
0
;
;
nIter
++
)
{
if
(
p
->
pPars
->
nItersStop
>=
0
&&
p
->
pPars
->
nItersStop
==
nIter
)
{
Aig_Man_t
*
pSRed
=
Ssw_SpeculativeReduction
(
p
);
Aig_ManDumpBlif
(
pSRed
,
"srm.blif"
,
NULL
,
NULL
);
Aig_ManStop
(
pSRed
);
printf
(
"Iterative refinement is stopped before iteration %d.
\n
"
,
nIter
);
printf
(
"The network is reduced using candidate equivalences.
\n
"
);
printf
(
"Speculatively reduced miter is saved in file
\"
%s
\"
.
\n
"
,
"srm.blif"
);
printf
(
"If the miter is SAT, the reduced result is incorrect.
\n
"
);
break
;
}
clk
=
clock
();
p
->
pMSat
=
Ssw_SatStart
(
0
);
if
(
p
->
pPars
->
fLatchCorrOpt
)
...
...
@@ -199,18 +211,6 @@ clk = clock();
Ssw_ManCleanup
(
p
);
if
(
!
RetValue
)
break
;
if
(
p
->
pPars
->
nItersStop
>=
0
&&
p
->
pPars
->
nItersStop
==
nIter
)
{
Aig_Man_t
*
pSRed
=
Ssw_SpeculativeReduction
(
p
);
Aig_ManDumpBlif
(
pSRed
,
"srm.blif"
,
NULL
,
NULL
);
Aig_ManStop
(
pSRed
);
printf
(
"Iterative refinement is stopped after iteration %d.
\n
"
,
nIter
);
printf
(
"The network is reduced using candidate equivalences.
\n
"
);
printf
(
"Speculatively reduced miter is saved in file
\"
%s
\"
.
\n
"
,
"srm.blif"
);
printf
(
"If the miter is SAT, the reduced result is incorrect.
\n
"
);
break
;
}
}
p
->
pPars
->
nIters
=
nIter
+
1
;
p
->
timeTotal
=
clock
()
-
clkTotal
;
...
...
src/base/abc/abc.h
View file @
81b51657
...
...
@@ -661,6 +661,7 @@ extern ABC_DLL Abc_Ntk_t * Abc_NtkFrames( Abc_Ntk_t * pNtk, int nFrames,
/*=== abcNames.c ====================================================*/
extern
ABC_DLL
char
*
Abc_ObjName
(
Abc_Obj_t
*
pNode
);
extern
ABC_DLL
char
*
Abc_ObjAssignName
(
Abc_Obj_t
*
pObj
,
char
*
pName
,
char
*
pSuffix
);
extern
ABC_DLL
char
*
Abc_ObjNamePrefix
(
Abc_Obj_t
*
pObj
,
char
*
pPrefix
);
extern
ABC_DLL
char
*
Abc_ObjNameSuffix
(
Abc_Obj_t
*
pObj
,
char
*
pSuffix
);
extern
ABC_DLL
char
*
Abc_ObjNameDummy
(
char
*
pPrefix
,
int
Num
,
int
nDigits
);
extern
ABC_DLL
void
Abc_NtkTrasferNames
(
Abc_Ntk_t
*
pNtk
,
Abc_Ntk_t
*
pNtkNew
);
...
...
src/base/abc/abcHie.c
View file @
81b51657
This diff is collapsed.
Click to expand it.
src/base/abc/abcNames.c
View file @
81b51657
...
...
@@ -70,9 +70,27 @@ char * Abc_ObjAssignName( Abc_Obj_t * pObj, char * pName, char * pSuffix )
/**Function*************************************************************
Synopsis [
Gets the long name of the node.
]
Synopsis [
Appends name to the prefix
]
Description [This name is the output net's name.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
char
*
Abc_ObjNamePrefix
(
Abc_Obj_t
*
pObj
,
char
*
pPrefix
)
{
static
char
Buffer
[
2000
];
sprintf
(
Buffer
,
"%s%s"
,
pPrefix
,
Abc_ObjName
(
pObj
)
);
return
Buffer
;
}
/**Function*************************************************************
Synopsis [Appends suffic to the name.]
Description []
SideEffects []
...
...
@@ -81,7 +99,7 @@ char * Abc_ObjAssignName( Abc_Obj_t * pObj, char * pName, char * pSuffix )
***********************************************************************/
char
*
Abc_ObjNameSuffix
(
Abc_Obj_t
*
pObj
,
char
*
pSuffix
)
{
static
char
Buffer
[
5
00
];
static
char
Buffer
[
20
00
];
sprintf
(
Buffer
,
"%s%s"
,
Abc_ObjName
(
pObj
),
pSuffix
);
return
Buffer
;
}
...
...
@@ -99,7 +117,7 @@ char * Abc_ObjNameSuffix( Abc_Obj_t * pObj, char * pSuffix )
***********************************************************************/
char
*
Abc_ObjNameDummy
(
char
*
pPrefix
,
int
Num
,
int
nDigits
)
{
static
char
Buffer
[
1
00
];
static
char
Buffer
[
20
00
];
sprintf
(
Buffer
,
"%s%0*d"
,
pPrefix
,
nDigits
,
Num
);
return
Buffer
;
}
...
...
src/base/abci/abc.c
View file @
81b51657
This diff is collapsed.
Click to expand it.
src/base/abci/abcDar.c
View file @
81b51657
...
...
@@ -1538,7 +1538,7 @@ Abc_Ntk_t * Abc_NtkDarLcorrNew( Abc_Ntk_t * pNtk, int nVarsMax, int nConfMax, in
SeeAlso []
***********************************************************************/
int
Abc_NtkDarBmc
(
Abc_Ntk_t
*
pNtk
,
int
nFrames
,
int
nSizeMax
,
int
nNodeDelta
,
int
nBTLimit
,
int
nBTLimitAll
,
int
fRewrite
,
int
fNewAlgo
,
int
fVerbose
)
int
Abc_NtkDarBmc
(
Abc_Ntk_t
*
pNtk
,
int
nFrames
,
int
nSizeMax
,
int
nNodeDelta
,
int
nBTLimit
,
int
nBTLimitAll
,
int
fRewrite
,
int
fNewAlgo
,
int
nCofFanLit
,
int
fVerbose
)
{
Aig_Man_t
*
pMan
;
int
status
,
RetValue
=
-
1
,
clk
=
clock
();
...
...
@@ -1554,7 +1554,7 @@ int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nFrames, int nSizeMax, int nNodeDelta,
if
(
fNewAlgo
)
{
int
iFrame
;
RetValue
=
Saig_ManBmcSimple
(
pMan
,
nFrames
,
nSizeMax
,
nBTLimit
,
fRewrite
,
fVerbose
,
&
iFrame
);
RetValue
=
Saig_ManBmcSimple
(
pMan
,
nFrames
,
nSizeMax
,
nBTLimit
,
fRewrite
,
fVerbose
,
&
iFrame
,
nCofFanLit
);
ABC_FREE
(
pNtk
->
pModel
);
ABC_FREE
(
pNtk
->
pSeqModel
);
pNtk
->
pSeqModel
=
pMan
->
pSeqModel
;
pMan
->
pSeqModel
=
NULL
;
...
...
@@ -1751,7 +1751,7 @@ int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar )
}
if
(
pSecPar
->
fTryBmc
)
{
RetValue
=
Abc_NtkDarBmc
(
pNtk
,
20
,
100000
,
-
1
,
2000
,
-
1
,
0
,
1
,
0
);
RetValue
=
Abc_NtkDarBmc
(
pNtk
,
20
,
100000
,
-
1
,
2000
,
-
1
,
0
,
1
,
0
,
0
);
if
(
RetValue
==
0
)
{
printf
(
"Networks are not equivalent.
\n
"
);
...
...
src/base/main/mainMC.c
View file @
81b51657
...
...
@@ -91,7 +91,7 @@ int main( int argc, char * argv[] )
{
// perform BMC
if
(
pAig
->
nRegs
!=
0
)
RetValue
=
Saig_ManBmcSimple
(
pAig
,
nFrames
,
nSizeMax
,
nBTLimit
,
fRewrite
,
fVerbose
,
NULL
);
RetValue
=
Saig_ManBmcSimple
(
pAig
,
nFrames
,
nSizeMax
,
nBTLimit
,
fRewrite
,
fVerbose
,
NULL
,
0
);
// perform full-blown SEC
if
(
RetValue
!=
0
)
...
...
@@ -120,7 +120,7 @@ int main( int argc, char * argv[] )
int
nSizeMax
=
500000
;
int
nBTLimit
=
10000000
;
int
fRewrite
=
0
;
RetValue
=
Saig_ManBmcSimple
(
pAig
,
nFrames
,
nSizeMax
,
nBTLimit
,
fRewrite
,
fVerbose
,
&
Depth
);
RetValue
=
Saig_ManBmcSimple
(
pAig
,
nFrames
,
nSizeMax
,
nBTLimit
,
fRewrite
,
fVerbose
,
&
Depth
,
0
);
if
(
RetValue
!=
0
)
RetValue
=
-
1
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment