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
38e577f5
Commit
38e577f5
authored
Oct 02, 2013
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enabling counter-example generation in the new BMC engine.
parent
e01174c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
22 deletions
+27
-22
src/base/abci/abc.c
+3
-1
src/sat/bmc/bmcBmcAnd.c
+24
-21
No files found.
src/base/abci/abc.c
View file @
38e577f5
...
@@ -32230,7 +32230,9 @@ int Abc_CommandAbc9Bmc( Abc_Frame_t * pAbc, int argc, char ** argv )
...
@@ -32230,7 +32230,9 @@ int Abc_CommandAbc9Bmc( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print
(
-
1
,
"Abc_CommandAbc9Bmc(): There is no AIG.
\n
"
);
Abc_Print
(
-
1
,
"Abc_CommandAbc9Bmc(): There is no AIG.
\n
"
);
return
0
;
return
0
;
}
}
Gia_ManBmcPerform
(
pAbc
->
pGia
,
pPars
);
pAbc
->
Status
=
Gia_ManBmcPerform
(
pAbc
->
pGia
,
pPars
);
pAbc
->
nFrames
=
pPars
->
iFrame
;
Abc_FrameReplaceCex
(
pAbc
,
&
pAbc
->
pGia
->
pCexSeq
);
return
0
;
return
0
;
usage:
usage:
src/sat/bmc/bmcBmcAnd.c
View file @
38e577f5
...
@@ -34,6 +34,7 @@ typedef struct Bmc_Mna_t_ Bmc_Mna_t;
...
@@ -34,6 +34,7 @@ typedef struct Bmc_Mna_t_ Bmc_Mna_t;
struct
Bmc_Mna_t_
struct
Bmc_Mna_t_
{
{
Gia_Man_t
*
pFrames
;
// time frames
Gia_Man_t
*
pFrames
;
// time frames
Vec_Int_t
*
vPiMap
;
// maps unrolled GIA PIs into user GIA PIs
Vec_Int_t
*
vId2Var
;
// maps GIA IDs into SAT vars
Vec_Int_t
*
vId2Var
;
// maps GIA IDs into SAT vars
Vec_Int_t
*
vInputs
;
// inputs of the cone
Vec_Int_t
*
vInputs
;
// inputs of the cone
Vec_Int_t
*
vOutputs
;
// outputs of the cone
Vec_Int_t
*
vOutputs
;
// outputs of the cone
...
@@ -284,7 +285,7 @@ Gia_Man_t * Gia_ManBmcUnroll( Gia_Man_t * pGia, int nFramesMax, int nFramesAdd,
...
@@ -284,7 +285,7 @@ Gia_Man_t * Gia_ManBmcUnroll( Gia_Man_t * pGia, int nFramesMax, int nFramesAdd,
Gia_Obj_t
*
pObj
;
Gia_Obj_t
*
pObj
;
Gia_Man_t
*
pNew
,
*
pTemp
;
Gia_Man_t
*
pNew
,
*
pTemp
;
Vec_Ptr_t
*
vStates
,
*
vBegins
;
Vec_Ptr_t
*
vStates
,
*
vBegins
;
Vec_Int_t
*
vRoots
,
*
vCone
,
*
vLeaves
,
*
vMap
,
*
vPiMap
;
Vec_Int_t
*
vRoots
,
*
vCone
,
*
vLeaves
,
*
vMap
;
unsigned
*
pStateF
,
*
pStateP
;
unsigned
*
pStateF
,
*
pStateP
;
int
f
,
i
,
iFirst
;
int
f
,
i
,
iFirst
;
Gia_ManCleanPhase
(
pGia
);
Gia_ManCleanPhase
(
pGia
);
...
@@ -293,7 +294,7 @@ Gia_Man_t * Gia_ManBmcUnroll( Gia_Man_t * pGia, int nFramesMax, int nFramesAdd,
...
@@ -293,7 +294,7 @@ Gia_Man_t * Gia_ManBmcUnroll( Gia_Man_t * pGia, int nFramesMax, int nFramesAdd,
// perform ternary simulation
// perform ternary simulation
vStates
=
Bmc_MnaTernary
(
pGia
,
nFramesMax
,
nFramesAdd
,
fVerbose
,
&
iFirst
);
vStates
=
Bmc_MnaTernary
(
pGia
,
nFramesMax
,
nFramesAdd
,
fVerbose
,
&
iFirst
);
// go backward
// go backward
vPiMap
=
Vec_IntAlloc
(
1000
);
*
p
vPiMap
=
Vec_IntAlloc
(
1000
);
vBegins
=
Vec_PtrStart
(
Vec_PtrSize
(
vStates
)
);
vBegins
=
Vec_PtrStart
(
Vec_PtrSize
(
vStates
)
);
for
(
f
=
Vec_PtrSize
(
vStates
)
-
1
;
f
>=
0
;
f
--
)
for
(
f
=
Vec_PtrSize
(
vStates
)
-
1
;
f
>=
0
;
f
--
)
{
{
...
@@ -340,9 +341,9 @@ Gia_Man_t * Gia_ManBmcUnroll( Gia_Man_t * pGia, int nFramesMax, int nFramesAdd,
...
@@ -340,9 +341,9 @@ Gia_Man_t * Gia_ManBmcUnroll( Gia_Man_t * pGia, int nFramesMax, int nFramesAdd,
Gia_ManForEachPo
(
pGia
,
pObj
,
i
)
Gia_ManForEachPo
(
pGia
,
pObj
,
i
)
Vec_IntWriteEntry
(
vMap
,
Gia_ObjId
(
pGia
,
pObj
),
0
);
Vec_IntWriteEntry
(
vMap
,
Gia_ObjId
(
pGia
,
pObj
),
0
);
// find the cone
// find the cone
Vec_IntPush
(
vPiMap
,
-
f
-
1
);
Vec_IntPush
(
*
p
vPiMap
,
-
f
-
1
);
Bmc_MnaCollect
(
pGia
,
vRoots
,
vCone
,
pStateP
);
// computes vCone
Bmc_MnaCollect
(
pGia
,
vRoots
,
vCone
,
pStateP
);
// computes vCone
Bmc_MnaBuild
(
pGia
,
vRoots
,
vCone
,
pNew
,
vMap
,
vPiMap
);
// computes pNew
Bmc_MnaBuild
(
pGia
,
vRoots
,
vCone
,
pNew
,
vMap
,
*
p
vPiMap
);
// computes pNew
if
(
fVerbose
)
if
(
fVerbose
)
printf
(
"Frame %4d : Roots = %6d Leaves = %6d Cone = %6d
\n
"
,
printf
(
"Frame %4d : Roots = %6d Leaves = %6d Cone = %6d
\n
"
,
f
,
Vec_IntSize
(
vRoots
),
Vec_IntSize
(
vLeaves
),
Vec_IntSize
(
vCone
)
);
f
,
Vec_IntSize
(
vRoots
),
Vec_IntSize
(
vLeaves
),
Vec_IntSize
(
vCone
)
);
...
@@ -368,7 +369,6 @@ Gia_Man_t * Gia_ManBmcUnroll( Gia_Man_t * pGia, int nFramesMax, int nFramesAdd,
...
@@ -368,7 +369,6 @@ Gia_Man_t * Gia_ManBmcUnroll( Gia_Man_t * pGia, int nFramesMax, int nFramesAdd,
pNew
=
Gia_ManCleanup
(
pTemp
=
pNew
);
pNew
=
Gia_ManCleanup
(
pTemp
=
pNew
);
Gia_ManStop
(
pTemp
);
Gia_ManStop
(
pTemp
);
// Gia_ManPrintStats( pNew, NULL );
// Gia_ManPrintStats( pNew, NULL );
*
pvPiMap
=
vPiMap
;
return
pNew
;
return
pNew
;
}
}
...
@@ -400,6 +400,7 @@ Bmc_Mna_t * Bmc_MnaAlloc()
...
@@ -400,6 +400,7 @@ Bmc_Mna_t * Bmc_MnaAlloc()
}
}
void
Bmc_MnaFree
(
Bmc_Mna_t
*
p
)
void
Bmc_MnaFree
(
Bmc_Mna_t
*
p
)
{
{
Vec_IntFreeP
(
&
p
->
vPiMap
);
Vec_IntFreeP
(
&
p
->
vId2Var
);
Vec_IntFreeP
(
&
p
->
vId2Var
);
Vec_IntFreeP
(
&
p
->
vInputs
);
Vec_IntFreeP
(
&
p
->
vInputs
);
Vec_IntFreeP
(
&
p
->
vOutputs
);
Vec_IntFreeP
(
&
p
->
vOutputs
);
...
@@ -493,7 +494,7 @@ int Gia_ManBmcAssignVarIds( Bmc_Mna_t * p, Vec_Int_t * vIns, Vec_Int_t * vUsed,
...
@@ -493,7 +494,7 @@ int Gia_ManBmcAssignVarIds( Bmc_Mna_t * p, Vec_Int_t * vIns, Vec_Int_t * vUsed,
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
void
Gia_ManBmcAddCnf
(
Bmc_Mna_t
*
p
,
Gia_Man_t
*
pGia
,
Vec_Int_t
*
vIns
,
Vec_Int_t
*
vNodes
,
Vec_Int_t
*
vOuts
,
Vec_Int_t
*
vSatMap
)
void
Gia_ManBmcAddCnf
(
Bmc_Mna_t
*
p
,
Gia_Man_t
*
pGia
,
Vec_Int_t
*
vIns
,
Vec_Int_t
*
vNodes
,
Vec_Int_t
*
vOuts
)
{
{
Gia_Man_t
*
pNew
=
Gia_ManBmcDupCone
(
pGia
,
vIns
,
vNodes
,
vOuts
);
Gia_Man_t
*
pNew
=
Gia_ManBmcDupCone
(
pGia
,
vIns
,
vNodes
,
vOuts
);
Aig_Man_t
*
pAig
=
Gia_ManToAigSimple
(
pNew
);
Aig_Man_t
*
pAig
=
Gia_ManToAigSimple
(
pNew
);
...
@@ -661,7 +662,7 @@ int Gia_ManBmcPerform_Unr( Gia_Man_t * pGia, Bmc_AndPar_t * pPars )
...
@@ -661,7 +662,7 @@ int Gia_ManBmcPerform_Unr( Gia_Man_t * pGia, Bmc_AndPar_t * pPars )
// create another slice
// create another slice
Gia_ManBmcAddCone
(
p
,
f
*
Gia_ManPoNum
(
pGia
),
(
f
+
1
)
*
Gia_ManPoNum
(
pGia
)
);
Gia_ManBmcAddCone
(
p
,
f
*
Gia_ManPoNum
(
pGia
),
(
f
+
1
)
*
Gia_ManPoNum
(
pGia
)
);
// create CNF in the SAT solver
// create CNF in the SAT solver
Gia_ManBmcAddCnf
(
p
,
p
->
pFrames
,
p
->
vInputs
,
p
->
vNodes
,
p
->
vOutputs
,
NULL
);
Gia_ManBmcAddCnf
(
p
,
p
->
pFrames
,
p
->
vInputs
,
p
->
vNodes
,
p
->
vOutputs
);
// try solving the outputs
// try solving the outputs
for
(
i
=
f
*
Gia_ManPoNum
(
pGia
);
i
<
(
f
+
1
)
*
Gia_ManPoNum
(
pGia
);
i
++
)
for
(
i
=
f
*
Gia_ManPoNum
(
pGia
);
i
<
(
f
+
1
)
*
Gia_ManPoNum
(
pGia
);
i
++
)
{
{
...
@@ -728,27 +729,30 @@ int Gia_ManBmcPerform_Unr( Gia_Man_t * pGia, Bmc_AndPar_t * pPars )
...
@@ -728,27 +729,30 @@ int Gia_ManBmcPerform_Unr( Gia_Man_t * pGia, Bmc_AndPar_t * pPars )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
Abc_Cex_t
*
Gia_ManBmcCexGen
(
Gia_Man_t
*
p
,
sat_solver
*
pSat
,
Vec_Int_t
*
vPiMap
,
Vec_Int_t
*
vSatMa
p
,
int
iOut
)
Abc_Cex_t
*
Gia_ManBmcCexGen
(
Bmc_Mna_t
*
pMan
,
Gia_Man_t
*
p
,
int
iOut
)
{
{
Abc_Cex_t
*
pCex
;
Abc_Cex_t
*
pCex
;
int
i
,
iOrigPi
,
iFramePi
=
0
,
iSatVar
,
iFrame
=
-
1
;
int
i
,
iObjId
,
iSatVar
,
iOrigPi
;
int
iFramePi
=
0
,
iFrame
=
-
1
;
pCex
=
Abc_CexAlloc
(
Gia_ManRegNum
(
p
),
Gia_ManPiNum
(
p
),
iOut
/
Gia_ManPoNum
(
p
)
+
1
);
pCex
=
Abc_CexAlloc
(
Gia_ManRegNum
(
p
),
Gia_ManPiNum
(
p
),
iOut
/
Gia_ManPoNum
(
p
)
+
1
);
pCex
->
iPo
=
iOut
%
Gia_ManPoNum
(
p
);
pCex
->
iFrame
=
iOut
/
Gia_ManPoNum
(
p
);
pCex
->
iFrame
=
iOut
/
Gia_ManPoNum
(
p
);
pCex
->
iPo
=
iOut
%
Gia_ManPoNum
(
p
);
// fill in the input values
// fill in the input values
Vec_IntForEachEntry
(
vPiMap
,
iOrigPi
,
i
)
Vec_IntForEachEntry
(
pMan
->
vPiMap
,
iOrigPi
,
i
)
{
{
if
(
iOrigPi
<
0
)
if
(
iOrigPi
<
0
)
{
{
iFrame
=
-
iOrigPi
-
1
;
iFrame
=
-
iOrigPi
-
1
;
continue
;
continue
;
}
}
// iOrigPi in iFrame has index iFramePi in the frames
// iOrigPi in iFrame of pGia has PI index iFramePi in pMan->pFrames,
iSatVar
=
Vec_IntEntry
(
vSatMap
,
iFramePi
);
iObjId
=
Gia_ObjId
(
pMan
->
pFrames
,
Gia_ManPi
(
pMan
->
pFrames
,
iFramePi
)
);
if
(
sat_solver_var_value
(
pSat
,
iSatVar
)
)
iSatVar
=
Vec_IntEntry
(
pMan
->
vId2Var
,
iObjId
);
Abc_InfoSetBit
(
pCex
->
pData
,
Gia_ManRegNum
(
p
)
+
Gia_ManPiNum
(
p
)
*
iFrame
+
iFramePi
);
if
(
sat_solver_var_value
(
pMan
->
pSat
,
iSatVar
)
)
Abc_InfoSetBit
(
pCex
->
pData
,
Gia_ManRegNum
(
p
)
+
Gia_ManPiNum
(
p
)
*
iFrame
+
iOrigPi
);
iFramePi
++
;
iFramePi
++
;
}
}
assert
(
iFramePi
==
Gia_ManPiNum
(
pMan
->
pFrames
)
);
return
pCex
;
return
pCex
;
}
}
...
@@ -766,11 +770,10 @@ Abc_Cex_t * Gia_ManBmcCexGen( Gia_Man_t * p, sat_solver * pSat, Vec_Int_t * vPiM
...
@@ -766,11 +770,10 @@ Abc_Cex_t * Gia_ManBmcCexGen( Gia_Man_t * p, sat_solver * pSat, Vec_Int_t * vPiM
int
Gia_ManBmcPerform
(
Gia_Man_t
*
pGia
,
Bmc_AndPar_t
*
pPars
)
int
Gia_ManBmcPerform
(
Gia_Man_t
*
pGia
,
Bmc_AndPar_t
*
pPars
)
{
{
Bmc_Mna_t
*
p
;
Bmc_Mna_t
*
p
;
Vec_Int_t
*
vPiMap
,
*
vSatMap
;
int
nFramesMax
,
f
,
i
=
0
,
Lit
,
status
,
RetValue
=
-
2
;
int
nFramesMax
,
f
,
i
=
0
,
Lit
,
status
,
RetValue
=
-
2
;
abctime
clk
=
Abc_Clock
();
abctime
clk
=
Abc_Clock
();
p
=
Bmc_MnaAlloc
();
p
=
Bmc_MnaAlloc
();
p
->
pFrames
=
Gia_ManBmcUnroll
(
pGia
,
pPars
->
nFramesMax
,
pPars
->
nFramesAdd
,
pPars
->
fVeryVerbose
,
&
vPiMap
);
p
->
pFrames
=
Gia_ManBmcUnroll
(
pGia
,
pPars
->
nFramesMax
,
pPars
->
nFramesAdd
,
pPars
->
fVeryVerbose
,
&
p
->
vPiMap
);
nFramesMax
=
Gia_ManPoNum
(
p
->
pFrames
)
/
Gia_ManPoNum
(
pGia
);
nFramesMax
=
Gia_ManPoNum
(
p
->
pFrames
)
/
Gia_ManPoNum
(
pGia
);
if
(
pPars
->
fVerbose
)
if
(
pPars
->
fVerbose
)
{
{
...
@@ -784,7 +787,6 @@ int Gia_ManBmcPerform( Gia_Man_t * pGia, Bmc_AndPar_t * pPars )
...
@@ -784,7 +787,6 @@ int Gia_ManBmcPerform( Gia_Man_t * pGia, Bmc_AndPar_t * pPars )
Gia_AigerWrite
(
p
->
pFrames
,
"frames.aig"
,
0
,
0
);
Gia_AigerWrite
(
p
->
pFrames
,
"frames.aig"
,
0
,
0
);
printf
(
"Dumped unfolded frames into file
\"
frames.aig
\"
.
\n
"
);
printf
(
"Dumped unfolded frames into file
\"
frames.aig
\"
.
\n
"
);
}
}
vSatMap
=
Vec_IntStartFull
(
Gia_ManPoNum
(
p
->
pFrames
)
);
for
(
f
=
0
;
f
<
nFramesMax
;
f
++
)
for
(
f
=
0
;
f
<
nFramesMax
;
f
++
)
{
{
if
(
!
Gia_ManBmcCheckOutputs
(
p
->
pFrames
,
f
*
Gia_ManPoNum
(
pGia
),
(
f
+
1
)
*
Gia_ManPoNum
(
pGia
)
)
)
if
(
!
Gia_ManBmcCheckOutputs
(
p
->
pFrames
,
f
*
Gia_ManPoNum
(
pGia
),
(
f
+
1
)
*
Gia_ManPoNum
(
pGia
)
)
)
...
@@ -792,7 +794,7 @@ int Gia_ManBmcPerform( Gia_Man_t * pGia, Bmc_AndPar_t * pPars )
...
@@ -792,7 +794,7 @@ int Gia_ManBmcPerform( Gia_Man_t * pGia, Bmc_AndPar_t * pPars )
// create another slice
// create another slice
Gia_ManBmcAddCone
(
p
,
f
*
Gia_ManPoNum
(
pGia
),
(
f
+
1
)
*
Gia_ManPoNum
(
pGia
)
);
Gia_ManBmcAddCone
(
p
,
f
*
Gia_ManPoNum
(
pGia
),
(
f
+
1
)
*
Gia_ManPoNum
(
pGia
)
);
// create CNF in the SAT solver
// create CNF in the SAT solver
Gia_ManBmcAddCnf
(
p
,
p
->
pFrames
,
p
->
vInputs
,
p
->
vNodes
,
p
->
vOutputs
,
vSatMap
);
Gia_ManBmcAddCnf
(
p
,
p
->
pFrames
,
p
->
vInputs
,
p
->
vNodes
,
p
->
vOutputs
);
// try solving the outputs
// try solving the outputs
for
(
i
=
f
*
Gia_ManPoNum
(
pGia
);
i
<
(
f
+
1
)
*
Gia_ManPoNum
(
pGia
);
i
++
)
for
(
i
=
f
*
Gia_ManPoNum
(
pGia
);
i
<
(
f
+
1
)
*
Gia_ManPoNum
(
pGia
);
i
++
)
{
{
...
@@ -825,14 +827,15 @@ int Gia_ManBmcPerform( Gia_Man_t * pGia, Bmc_AndPar_t * pPars )
...
@@ -825,14 +827,15 @@ int Gia_ManBmcPerform( Gia_Man_t * pGia, Bmc_AndPar_t * pPars )
printf
(
"SAT solver reached conflict/runtime limit in frame %d.
\n
"
,
f
);
printf
(
"SAT solver reached conflict/runtime limit in frame %d.
\n
"
,
f
);
else
else
{
{
//
ABC_FREE( pGia->pCexSeq );
ABC_FREE
(
pGia
->
pCexSeq
);
// pGia->pCexSeq = Gia_ManBmcCexGen( pGia, p->pSat, vPiMap, vSatMap
, i );
pGia
->
pCexSeq
=
Gia_ManBmcCexGen
(
p
,
pGia
,
i
);
printf
(
"Output %d of miter
\"
%s
\"
was asserted in frame %d. "
,
printf
(
"Output %d of miter
\"
%s
\"
was asserted in frame %d. "
,
i
-
f
*
Gia_ManPoNum
(
pGia
),
Gia_ManName
(
pGia
),
f
);
i
-
f
*
Gia_ManPoNum
(
pGia
),
Gia_ManName
(
pGia
),
f
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
p
->
clkStart
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
p
->
clkStart
);
}
}
break
;
break
;
}
}
pPars
->
iFrame
=
f
;
}
}
if
(
RetValue
==
-
2
)
if
(
RetValue
==
-
2
)
RetValue
=
-
1
;
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