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
ce8dbc4a
Commit
ce8dbc4a
authored
Oct 01, 2017
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exact synthesis of majority gates.
parent
d3152aef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
13 deletions
+44
-13
src/misc/util/utilTruth.h
+32
-8
src/sat/bmc/bmcMaj.c
+12
-5
No files found.
src/misc/util/utilTruth.h
View file @
ce8dbc4a
...
...
@@ -1751,6 +1751,22 @@ static inline int Abc_TtFindFirstBit2( word * pIn, int nWords )
return
64
*
w
+
Abc_Tt6FirstBit
(
pIn
[
w
]);
return
-
1
;
}
static
inline
int
Abc_TtFindLastBit
(
word
*
pIn
,
int
nVars
)
{
int
w
,
nWords
=
Abc_TtWordNum
(
nVars
);
for
(
w
=
nWords
-
1
;
w
>=
0
;
w
--
)
if
(
pIn
[
w
]
)
return
64
*
w
+
Abc_Tt6LastBit
(
pIn
[
w
]);
return
-
1
;
}
static
inline
int
Abc_TtFindLastBit2
(
word
*
pIn
,
int
nWords
)
{
int
w
;
for
(
w
=
nWords
-
1
;
w
>=
0
;
w
--
)
if
(
pIn
[
w
]
)
return
64
*
w
+
Abc_Tt6LastBit
(
pIn
[
w
]);
return
-
1
;
}
static
inline
int
Abc_TtFindFirstDiffBit
(
word
*
pIn1
,
word
*
pIn2
,
int
nVars
)
{
int
w
,
nWords
=
Abc_TtWordNum
(
nVars
);
...
...
@@ -1767,20 +1783,28 @@ static inline int Abc_TtFindFirstDiffBit2( word * pIn1, word * pIn2, int nWords
return
64
*
w
+
Abc_Tt6FirstBit
(
pIn1
[
w
]
^
pIn2
[
w
]);
return
-
1
;
}
static
inline
int
Abc_TtFind
FirstZero
(
word
*
pIn
,
int
nVars
)
static
inline
int
Abc_TtFind
LastDiffBit
(
word
*
pIn1
,
word
*
pIn2
,
int
nVars
)
{
int
w
,
nWords
=
Abc_TtWordNum
(
nVars
);
for
(
w
=
0
;
w
<
nWords
;
w
++
)
if
(
~
pIn
[
w
]
)
return
64
*
w
+
Abc_Tt6
FirstBit
(
~
pIn
[
w
]);
for
(
w
=
nWords
-
1
;
w
>=
0
;
w
--
)
if
(
pIn1
[
w
]
^
pIn2
[
w
]
)
return
64
*
w
+
Abc_Tt6
LastBit
(
pIn1
[
w
]
^
pIn2
[
w
]);
return
-
1
;
}
static
inline
int
Abc_TtFindLast
Bit
(
word
*
pIn
,
int
nVar
s
)
static
inline
int
Abc_TtFindLast
DiffBit2
(
word
*
pIn1
,
word
*
pIn2
,
int
nWord
s
)
{
int
w
,
nWords
=
Abc_TtWordNum
(
nVars
)
;
int
w
;
for
(
w
=
nWords
-
1
;
w
>=
0
;
w
--
)
if
(
pIn
[
w
]
)
return
64
*
w
+
Abc_Tt6LastBit
(
pIn
[
w
]);
if
(
pIn1
[
w
]
^
pIn2
[
w
]
)
return
64
*
w
+
Abc_Tt6LastBit
(
pIn1
[
w
]
^
pIn2
[
w
]);
return
-
1
;
}
static
inline
int
Abc_TtFindFirstZero
(
word
*
pIn
,
int
nVars
)
{
int
w
,
nWords
=
Abc_TtWordNum
(
nVars
);
for
(
w
=
0
;
w
<
nWords
;
w
++
)
if
(
~
pIn
[
w
]
)
return
64
*
w
+
Abc_Tt6FirstBit
(
~
pIn
[
w
]);
return
-
1
;
}
static
inline
int
Abc_TtFindLastZero
(
word
*
pIn
,
int
nVars
)
...
...
src/sat/bmc/bmcMaj.c
View file @
ce8dbc4a
...
...
@@ -19,6 +19,7 @@
***********************************************************************/
#include "bmc.h"
#include "misc/extra/extra.h"
#include "misc/util/utilTruth.h"
#include "sat/glucose/AbcGlucose.h"
...
...
@@ -174,6 +175,7 @@ static inline int Maj_ManFindFanin( Maj_Man_t * p, int i, int k )
}
static
inline
int
Maj_ManEval
(
Maj_Man_t
*
p
)
{
static
int
Flag
=
0
;
int
i
,
k
,
iMint
;
word
*
pFanins
[
3
];
for
(
i
=
p
->
nVars
+
2
;
i
<
p
->
nObjs
;
i
++
)
{
...
...
@@ -181,7 +183,12 @@ static inline int Maj_ManEval( Maj_Man_t * p )
pFanins
[
k
]
=
Maj_ManTruth
(
p
,
Maj_ManFindFanin
(
p
,
i
,
k
)
);
Abc_TtMaj
(
Maj_ManTruth
(
p
,
i
),
pFanins
[
0
],
pFanins
[
1
],
pFanins
[
2
],
p
->
nWords
);
}
iMint
=
Abc_TtFindFirstDiffBit
(
Maj_ManTruth
(
p
,
p
->
nObjs
-
1
),
Maj_ManTruth
(
p
,
p
->
nObjs
),
p
->
nWords
);
if
(
Flag
&&
p
->
nVars
>=
6
)
iMint
=
Abc_TtFindLastDiffBit
(
Maj_ManTruth
(
p
,
p
->
nObjs
-
1
),
Maj_ManTruth
(
p
,
p
->
nObjs
),
p
->
nVars
);
else
iMint
=
Abc_TtFindFirstDiffBit
(
Maj_ManTruth
(
p
,
p
->
nObjs
-
1
),
Maj_ManTruth
(
p
,
p
->
nObjs
),
p
->
nVars
);
//Flag ^= 1;
assert
(
iMint
<
(
1
<<
p
->
nVars
)
);
return
iMint
;
}
...
...
@@ -290,7 +297,6 @@ int Maj_ManAddCnf( Maj_Man_t * p, int iMint )
int
iBaseSatVarI
=
p
->
iVar
+
4
*
(
i
-
p
->
nVars
-
2
);
for
(
k
=
0
;
k
<
3
;
k
++
)
{
int
nLits2
=
0
;
for
(
j
=
0
;
j
<
p
->
nObjs
;
j
++
)
if
(
p
->
VarMarks
[
i
][
k
][
j
]
)
{
int
iBaseSatVarJ
=
p
->
iVar
+
4
*
(
j
-
p
->
nVars
-
2
);
...
...
@@ -346,9 +352,10 @@ void Maj_ManExactSynthesis( int nVars, int nNodes, int fUseConst, int fVerbose )
if
(
fVerbose
)
{
printf
(
"Iter %3d : "
,
i
);
printf
(
"Vars = %5d "
,
p
->
iVar
);
printf
(
"Clauses = %5d "
,
bmcg_sat_solver_clausenum
(
p
->
pSat
)
);
printf
(
"Conflicts = %7d "
,
bmcg_sat_solver_conflictnum
(
p
->
pSat
)
);
Extra_PrintBinary
(
stdout
,
(
unsigned
*
)
&
iMint
,
p
->
nVars
);
printf
(
" Var =%5d "
,
p
->
iVar
);
printf
(
"Cla =%6d "
,
bmcg_sat_solver_clausenum
(
p
->
pSat
)
);
printf
(
"Conf =%8d "
,
bmcg_sat_solver_conflictnum
(
p
->
pSat
)
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
}
if
(
status
==
GLUCOSE_UNSAT
)
...
...
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