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
118eea84
Commit
118eea84
authored
Aug 17, 2016
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes to report quantum cost in Exorcism.
parent
b83c6aaf
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
23 deletions
+78
-23
src/aig/gia/giaEsop.c
+1
-1
src/base/abci/abc.c
+2
-2
src/base/exor/exor.c
+41
-7
src/base/exor/exor.h
+6
-0
src/base/exor/exorLink.c
+11
-9
src/base/exor/exorList.c
+7
-0
src/base/exor/exorUtil.c
+10
-4
No files found.
src/aig/gia/giaEsop.c
View file @
118eea84
...
@@ -167,7 +167,7 @@ Vec_Wec_t * Eso_ManCoverDerive( Eso_Man_t * p, Vec_Ptr_t * vCover )
...
@@ -167,7 +167,7 @@ Vec_Wec_t * Eso_ManCoverDerive( Eso_Man_t * p, Vec_Ptr_t * vCover )
}
}
}
}
}
}
assert
(
Vec_WecSize
(
vRes
)
==
Vec_WecCap
(
vRes
)
);
assert
(
Abc_MaxInt
(
Vec_WecSize
(
vRes
),
8
)
==
Vec_WecCap
(
vRes
)
);
return
vRes
;
return
vRes
;
}
}
Gia_Man_t
*
Eso_ManCoverConvert
(
Eso_Man_t
*
p
,
Vec_Ptr_t
*
vCover
)
Gia_Man_t
*
Eso_ManCoverConvert
(
Eso_Man_t
*
p
,
Vec_Ptr_t
*
vCover
)
...
...
src/base/abci/abc.c
View file @
118eea84
...
@@ -40460,13 +40460,13 @@ int Abc_CommandAbc9Exorcism( Abc_Frame_t * pAbc, int argc, char ** argv )
...
@@ -40460,13 +40460,13 @@ int Abc_CommandAbc9Exorcism( Abc_Frame_t * pAbc, int argc, char ** argv )
return
0
;
return
0
;
usage:
usage:
Abc_Print
(
-
2
,
"usage: &exorcism [-Q N] [-V N] <file>
\n
"
);
Abc_Print
(
-
2
,
"usage: &exorcism [-Q N] [-V N]
[-q]
<file>
\n
"
);
Abc_Print
(
-
2
,
" performs heuristic exclusive sum-of-project minimization
\n
"
);
Abc_Print
(
-
2
,
" performs heuristic exclusive sum-of-project minimization
\n
"
);
Abc_Print
(
-
2
,
" -Q N : minimization quality [default = %d]
\n
"
,
Quality
);
Abc_Print
(
-
2
,
" -Q N : minimization quality [default = %d]
\n
"
,
Quality
);
Abc_Print
(
-
2
,
" increasing this number improves quality and adds to runtime
\n
"
);
Abc_Print
(
-
2
,
" increasing this number improves quality and adds to runtime
\n
"
);
Abc_Print
(
-
2
,
" -V N : verbosity level [default = %d]
\n
"
,
Verbosity
);
Abc_Print
(
-
2
,
" -V N : verbosity level [default = %d]
\n
"
,
Verbosity
);
Abc_Print
(
-
2
,
" 0 = no output; 1 = outline; 2 = verbose
\n
"
);
Abc_Print
(
-
2
,
" 0 = no output; 1 = outline; 2 = verbose
\n
"
);
//
Abc_Print( -2, " -q : toggle using quantum cost [default = %s]\n", fUseQCost? "yes": "no" );
Abc_Print
(
-
2
,
" -q : toggle using quantum cost [default = %s]
\n
"
,
fUseQCost
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
" <file>: the output file name in ESOP-PLA format
\n
"
);
Abc_Print
(
-
2
,
" <file>: the output file name in ESOP-PLA format
\n
"
);
Abc_Print
(
-
2
,
"
\n
"
);
Abc_Print
(
-
2
,
"
\n
"
);
return
1
;
return
1
;
src/base/exor/exor.c
View file @
118eea84
...
@@ -90,16 +90,48 @@ static int QCost[16][16] =
...
@@ -90,16 +90,48 @@ static int QCost[16][16] =
{
56
,
56
,
56
,
56
,
58
,
60
,
62
,
64
},
// 7
{
56
,
56
,
56
,
56
,
58
,
60
,
62
,
64
},
// 7
{
0
}
{
0
}
};
};
int
CountNegLits
(
Vec_Int_t
*
vCube
)
int
GetQCost
(
int
nVars
,
int
nNegs
)
{
{
int
i
,
Entry
,
nLits
=
0
;
int
Extra
;
Vec_IntForEachEntry
(
vCube
,
Entry
,
i
)
assert
(
nVars
>=
nNegs
);
nLits
+=
Abc_LitIsCompl
(
Entry
);
if
(
nVars
==
0
)
return
nLits
;
return
1
;
if
(
nVars
==
1
)
{
if
(
nNegs
==
0
)
return
1
;
if
(
nNegs
==
1
)
return
2
;
}
if
(
nVars
==
2
)
{
if
(
nNegs
<=
1
)
return
5
;
if
(
nNegs
==
2
)
return
6
;
}
if
(
nVars
==
3
)
{
if
(
nNegs
<=
1
)
return
14
;
if
(
nNegs
==
2
)
return
16
;
if
(
nNegs
==
3
)
return
18
;
}
Extra
=
nNegs
-
nVars
/
2
;
return
20
+
12
*
(
nVars
-
4
)
+
(
Extra
>
0
?
2
*
Extra
:
0
);
}
void
GetQCostTest
()
{
int
i
,
k
,
Limit
=
10
;
for
(
i
=
0
;
i
<
Limit
;
i
++
)
{
for
(
k
=
0
;
k
<=
i
;
k
++
)
printf
(
"%4d "
,
GetQCost
(
i
,
k
)
);
printf
(
"
\n
"
);
}
}
}
int
ComputeQCost
(
Vec_Int_t
*
vCube
)
int
ComputeQCost
(
Vec_Int_t
*
vCube
)
{
{
return
QCost
[
Abc_MinInt
(
Vec_IntSize
(
vCube
),
7
)][
Abc_MinInt
(
CountNegLits
(
vCube
),
7
)];
int
i
,
Entry
,
nLitsN
=
0
;
Vec_IntForEachEntry
(
vCube
,
Entry
,
i
)
nLitsN
+=
Abc_LitIsCompl
(
Entry
);
return
GetQCost
(
Vec_IntSize
(
vCube
),
nLitsN
);
}
}
int
ComputeQCostBits
(
Cube
*
p
)
int
ComputeQCostBits
(
Cube
*
p
)
{
{
...
@@ -114,7 +146,7 @@ int ComputeQCostBits( Cube * p )
...
@@ -114,7 +146,7 @@ int ComputeQCostBits( Cube * p )
nLits
++
;
nLits
++
;
}
}
nLits
+=
nLitsN
;
nLits
+=
nLitsN
;
return
QCost
[
Abc_MinInt
(
nLits
,
7
)][
Abc_MinInt
(
nLitsN
,
7
)]
;
return
GetQCost
(
nLits
,
nLitsN
)
;
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -858,6 +890,8 @@ int Abc_ExorcismMain( Vec_Wec_t * vEsop, int nIns, int nOuts, char * pFileNameOu
...
@@ -858,6 +890,8 @@ int Abc_ExorcismMain( Vec_Wec_t * vEsop, int nIns, int nOuts, char * pFileNameOu
g_CoverInfo
.
Quality
=
Quality
;
g_CoverInfo
.
Quality
=
Quality
;
g_CoverInfo
.
Verbosity
=
Verbosity
;
g_CoverInfo
.
Verbosity
=
Verbosity
;
g_CoverInfo
.
fUseQCost
=
fUseQCost
;
g_CoverInfo
.
fUseQCost
=
fUseQCost
;
if
(
fUseQCost
)
s_fDecreaseLiterals
=
1
;
if
(
g_CoverInfo
.
Verbosity
)
if
(
g_CoverInfo
.
Verbosity
)
{
{
printf
(
"
\n
EXORCISM, Ver.4.7: Exclusive Sum-of-Product Minimizer
\n
"
);
printf
(
"
\n
EXORCISM, Ver.4.7: Exclusive Sum-of-Product Minimizer
\n
"
);
...
...
src/base/exor/exor.h
View file @
118eea84
...
@@ -167,6 +167,12 @@ extern int FindDiffVars( int *pDiffVars, Cube* pC1, Cube* pC2 );
...
@@ -167,6 +167,12 @@ extern int FindDiffVars( int *pDiffVars, Cube* pC1, Cube* pC2 );
// determines the variables that are different in cubes pC1 and pC2
// determines the variables that are different in cubes pC1 and pC2
// returns the number of variables
// returns the number of variables
extern
int
ComputeQCost
(
Vec_Int_t
*
vCube
);
extern
int
ComputeQCostBits
(
Cube
*
p
);
extern
int
CountLiterals
();
extern
int
CountQCost
();
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// VARVALUE and CUBEDIST enum typedefs ///
/// VARVALUE and CUBEDIST enum typedefs ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
...
src/base/exor/exorLink.c
View file @
118eea84
...
@@ -335,7 +335,6 @@ static int DiffVarBits[5];
...
@@ -335,7 +335,6 @@ static int DiffVarBits[5];
static
drow
MaskLiterals
;
static
drow
MaskLiterals
;
// the base for counting literals
// the base for counting literals
static
int
StartingLiterals
;
static
int
StartingLiterals
;
static
int
StartingQCost
;
// the number of literals in each cube
// the number of literals in each cube
static
int
CubeLiterals
[
32
];
static
int
CubeLiterals
[
32
];
static
int
BitShift
;
static
int
BitShift
;
...
@@ -525,9 +524,6 @@ int ExorLinkCubeIteratorStart( Cube** pGroup, Cube* pC1, Cube* pC2, cubedist Dis
...
@@ -525,9 +524,6 @@ int ExorLinkCubeIteratorStart( Cube** pGroup, Cube* pC1, Cube* pC2, cubedist Dis
NewZ
+=
BIT_COUNT
(
Temp
);
NewZ
+=
BIT_COUNT
(
Temp
);
}
}
}
}
// set the number of literals
ELCubes
[
CubeNum
]
->
a
=
StartingLiterals
+
CubeLiterals
[
CubeNum
];
ELCubes
[
CubeNum
]
->
z
=
NewZ
;
// set the variables that should be there
// set the variables that should be there
for
(
i
=
0
;
i
<
nDiffVarsIn
;
i
++
)
for
(
i
=
0
;
i
<
nDiffVarsIn
;
i
++
)
...
@@ -536,6 +532,11 @@ int ExorLinkCubeIteratorStart( Cube** pGroup, Cube* pC1, Cube* pC2, cubedist Dis
...
@@ -536,6 +532,11 @@ int ExorLinkCubeIteratorStart( Cube** pGroup, Cube* pC1, Cube* pC2, cubedist Dis
ELCubes
[
CubeNum
]
->
pCubeDataIn
[
DiffVarWords
[
i
]
]
|=
(
Value
<<
DiffVarBits
[
i
]
);
ELCubes
[
CubeNum
]
->
pCubeDataIn
[
DiffVarWords
[
i
]
]
|=
(
Value
<<
DiffVarBits
[
i
]
);
}
}
// set the number of literals
ELCubes
[
CubeNum
]
->
a
=
StartingLiterals
+
CubeLiterals
[
CubeNum
];
ELCubes
[
CubeNum
]
->
z
=
NewZ
;
ELCubes
[
CubeNum
]
->
q
=
ComputeQCostBits
(
ELCubes
[
CubeNum
]
);
// assign the ID
// assign the ID
ELCubes
[
CubeNum
]
->
ID
=
g_CoverInfo
.
cIDs
++
;
ELCubes
[
CubeNum
]
->
ID
=
g_CoverInfo
.
cIDs
++
;
// skip through zero-ID
// skip through zero-ID
...
@@ -645,11 +646,6 @@ int ExorLinkCubeIteratorNext( Cube** pGroup )
...
@@ -645,11 +646,6 @@ int ExorLinkCubeIteratorNext( Cube** pGroup )
NewZ
+=
BIT_COUNT
(
Temp
);
NewZ
+=
BIT_COUNT
(
Temp
);
}
}
}
}
// set the number of literals and output ones
ELCubes
[
CubeNum
]
->
a
=
StartingLiterals
+
CubeLiterals
[
CubeNum
];
ELCubes
[
CubeNum
]
->
z
=
NewZ
;
assert
(
NewZ
!=
255
);
// set the variables that should be there
// set the variables that should be there
for
(
i
=
0
;
i
<
nDiffVarsIn
;
i
++
)
for
(
i
=
0
;
i
<
nDiffVarsIn
;
i
++
)
...
@@ -658,6 +654,12 @@ int ExorLinkCubeIteratorNext( Cube** pGroup )
...
@@ -658,6 +654,12 @@ int ExorLinkCubeIteratorNext( Cube** pGroup )
ELCubes
[
CubeNum
]
->
pCubeDataIn
[
DiffVarWords
[
i
]
]
|=
(
Value
<<
DiffVarBits
[
i
]
);
ELCubes
[
CubeNum
]
->
pCubeDataIn
[
DiffVarWords
[
i
]
]
|=
(
Value
<<
DiffVarBits
[
i
]
);
}
}
// set the number of literals and output ones
ELCubes
[
CubeNum
]
->
a
=
StartingLiterals
+
CubeLiterals
[
CubeNum
];
ELCubes
[
CubeNum
]
->
z
=
NewZ
;
ELCubes
[
CubeNum
]
->
q
=
ComputeQCostBits
(
ELCubes
[
CubeNum
]
);
assert
(
NewZ
!=
255
);
// assign the ID
// assign the ID
ELCubes
[
CubeNum
]
->
ID
=
g_CoverInfo
.
cIDs
++
;
ELCubes
[
CubeNum
]
->
ID
=
g_CoverInfo
.
cIDs
++
;
// skip through zero-ID
// skip through zero-ID
...
...
src/base/exor/exorList.c
View file @
118eea84
...
@@ -393,6 +393,8 @@ SUCCESS:
...
@@ -393,6 +393,8 @@ SUCCESS:
printf
(
" NoResh= %4d"
,
s_cAttempts
-
s_cReshapes
);
printf
(
" NoResh= %4d"
,
s_cAttempts
-
s_cReshapes
);
printf
(
" Cubes= %3d"
,
g_CoverInfo
.
nCubesInUse
);
printf
(
" Cubes= %3d"
,
g_CoverInfo
.
nCubesInUse
);
printf
(
" (%d)"
,
s_nCubesBefore
-
g_CoverInfo
.
nCubesInUse
);
printf
(
" (%d)"
,
s_nCubesBefore
-
g_CoverInfo
.
nCubesInUse
);
printf
(
" Lits= %5d"
,
CountLiterals
()
);
printf
(
" QCost = %6d"
,
CountQCost
()
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -510,6 +512,8 @@ END_OF_LOOP: {}
...
@@ -510,6 +512,8 @@ END_OF_LOOP: {}
printf
(
" NoResh= %4d"
,
s_cAttempts
-
s_cReshapes
);
printf
(
" NoResh= %4d"
,
s_cAttempts
-
s_cReshapes
);
printf
(
" Cubes= %3d"
,
g_CoverInfo
.
nCubesInUse
);
printf
(
" Cubes= %3d"
,
g_CoverInfo
.
nCubesInUse
);
printf
(
" (%d)"
,
s_nCubesBefore
-
g_CoverInfo
.
nCubesInUse
);
printf
(
" (%d)"
,
s_nCubesBefore
-
g_CoverInfo
.
nCubesInUse
);
printf
(
" Lits= %5d"
,
CountLiterals
()
);
printf
(
" QCost = %6d"
,
CountQCost
()
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -619,6 +623,8 @@ END_OF_LOOP: {}
...
@@ -619,6 +623,8 @@ END_OF_LOOP: {}
printf
(
" NoResh= %4d"
,
s_cAttempts
-
s_cReshapes
);
printf
(
" NoResh= %4d"
,
s_cAttempts
-
s_cReshapes
);
printf
(
" Cubes= %3d"
,
g_CoverInfo
.
nCubesInUse
);
printf
(
" Cubes= %3d"
,
g_CoverInfo
.
nCubesInUse
);
printf
(
" (%d)"
,
s_nCubesBefore
-
g_CoverInfo
.
nCubesInUse
);
printf
(
" (%d)"
,
s_nCubesBefore
-
g_CoverInfo
.
nCubesInUse
);
printf
(
" Lits= %5d"
,
CountLiterals
()
);
printf
(
" QCost = %6d"
,
CountQCost
()
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
@@ -709,6 +715,7 @@ int CheckForCloseCubes( Cube* p, int fAddCube )
...
@@ -709,6 +715,7 @@ int CheckForCloseCubes( Cube* p, int fAddCube )
p
->
a
--
;
p
->
a
--
;
if
(
s_DiffVarValueP_new
==
VAR_NEG
||
s_DiffVarValueP_new
==
VAR_POS
)
if
(
s_DiffVarValueP_new
==
VAR_NEG
||
s_DiffVarValueP_new
==
VAR_POS
)
p
->
a
++
;
p
->
a
++
;
p
->
q
=
ComputeQCostBits
(
p
);
}
}
// move q to the free cube list
// move q to the free cube list
...
...
src/base/exor/exorUtil.c
View file @
118eea84
...
@@ -75,7 +75,15 @@ extern varvalue GetVar( Cube* pC, int Var );
...
@@ -75,7 +75,15 @@ extern varvalue GetVar( Cube* pC, int Var );
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
int
CountLiterals
()
int
CountLiterals
()
// nCubesAlloc is the number of allocated cubes
{
Cube
*
p
;
int
LitCounter
=
0
;
for
(
p
=
IterCubeSetStart
(
);
p
;
p
=
IterCubeSetNext
()
)
LitCounter
+=
p
->
a
;
return
LitCounter
;
}
int
CountLiteralsCheck
()
{
{
Cube
*
p
;
Cube
*
p
;
int
Value
,
v
;
int
Value
,
v
;
...
@@ -109,9 +117,7 @@ int CountLiterals()
...
@@ -109,9 +117,7 @@ int CountLiterals()
}
}
int
CountQCost
()
int
CountQCost
()
// nCubesAlloc is the number of allocated cubes
{
{
extern
int
ComputeQCostBits
(
Cube
*
p
);
Cube
*
p
;
Cube
*
p
;
int
QCost
=
0
;
int
QCost
=
0
;
int
QCostControl
=
0
;
int
QCostControl
=
0
;
...
@@ -191,7 +197,7 @@ int WriteResultIntoFile( char * pFileName )
...
@@ -191,7 +197,7 @@ int WriteResultIntoFile( char * pFileName )
time
(
&
ltime
);
time
(
&
ltime
);
TimeStr
=
asctime
(
localtime
(
&
ltime
)
);
TimeStr
=
asctime
(
localtime
(
&
ltime
)
);
// get the number of literals
// get the number of literals
g_CoverInfo
.
nLiteralsAfter
=
CountLiterals
();
g_CoverInfo
.
nLiteralsAfter
=
CountLiterals
Check
();
g_CoverInfo
.
QCostAfter
=
CountQCost
();
g_CoverInfo
.
QCostAfter
=
CountQCost
();
fprintf
(
pFile
,
"# EXORCISM-4 output for command line arguments: "
);
fprintf
(
pFile
,
"# EXORCISM-4 output for command line arguments: "
);
fprintf
(
pFile
,
"
\"
-Q %d -V %d
\"\n
"
,
g_CoverInfo
.
Quality
,
g_CoverInfo
.
Verbosity
);
fprintf
(
pFile
,
"
\"
-Q %d -V %d
\"\n
"
,
g_CoverInfo
.
Quality
,
g_CoverInfo
.
Verbosity
);
...
...
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