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
f49e8f0f
Commit
f49e8f0f
authored
Jul 04, 2018
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding command 'majgen'.
parent
7522e68b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
146 additions
and
0 deletions
+146
-0
abclib.dsp
+4
-0
src/base/abci/abc.c
+54
-0
src/misc/extra/extra.h
+1
-0
src/misc/extra/extraUtilFile.c
+17
-0
src/misc/extra/extraUtilMaj.c
+0
-0
src/misc/extra/module.make
+1
-0
src/misc/util/utilTruth.h
+69
-0
No files found.
abclib.dsp
View file @
f49e8f0f
...
...
@@ -3655,6 +3655,10 @@ SOURCE=.\src\misc\extra\extraUtilFile.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilMaj.c
# End Source File
# Begin Source File
SOURCE=.\src\misc\extra\extraUtilMemory.c
# End Source File
# Begin Source File
...
...
src/base/abci/abc.c
View file @
f49e8f0f
...
...
@@ -155,6 +155,7 @@ static int Abc_CommandTwoExact ( Abc_Frame_t * pAbc, int argc, cha
static
int
Abc_CommandLutExact
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandAllExact
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandTestExact
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandMajGen
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandLogic
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandComb
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
...
...
@@ -847,6 +848,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd
(
pAbc
,
"Exact synthesis"
,
"lutexact"
,
Abc_CommandLutExact
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Exact synthesis"
,
"allexact"
,
Abc_CommandAllExact
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Exact synthesis"
,
"testexact"
,
Abc_CommandTestExact
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Exact synthesis"
,
"majgen"
,
Abc_CommandMajGen
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Various"
,
"logic"
,
Abc_CommandLogic
,
1
);
Cmd_CommandAdd
(
pAbc
,
"Various"
,
"comb"
,
Abc_CommandComb
,
1
);
...
...
@@ -8753,6 +8755,58 @@ usage:
SeeAlso []
***********************************************************************/
int
Abc_CommandMajGen
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
int
Gem_Enumerate
(
int
nVars
,
int
fVerbose
);
int
c
,
nVars
=
8
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"Nvh"
)
)
!=
EOF
)
{
switch
(
c
)
{
case
'N'
:
if
(
globalUtilOptind
>=
argc
)
{
Abc_Print
(
-
1
,
"Command line switch
\"
-N
\"
should be followed by an integer.
\n
"
);
goto
usage
;
}
nVars
=
atoi
(
argv
[
globalUtilOptind
]);
globalUtilOptind
++
;
if
(
nVars
<
0
)
goto
usage
;
break
;
case
'v'
:
fVerbose
^=
1
;
break
;
case
'h'
:
goto
usage
;
default:
goto
usage
;
}
}
Gem_Enumerate
(
nVars
,
fVerbose
);
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: majgen [-N <num>] [-vh]>
\n
"
);
Abc_Print
(
-
2
,
"
\t
generates networks for majority gates
\n
"
);
Abc_Print
(
-
2
,
"
\t
-N <num> : the maximum number of variables [default = %d]
\n
"
,
nVars
);
Abc_Print
(
-
2
,
"
\t
-v : toggle verbose printout [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : print the command usage
\n
"
);
return
1
;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Abc_CommandLogic
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
Abc_Ntk_t
*
pNtk
,
*
pNtkRes
;
src/misc/extra/extra.h
View file @
f49e8f0f
...
...
@@ -119,6 +119,7 @@ extern char * Extra_StringAppend( char * pStrGiven, char * pStrAdd );
extern
void
Extra_StringClean
(
char
*
pStrGiven
,
char
*
pCharKeep
);
extern
unsigned
Extra_ReadBinary
(
char
*
Buffer
);
extern
void
Extra_PrintBinary
(
FILE
*
pFile
,
unsigned
Sign
[],
int
nBits
);
extern
void
Extra_PrintBinary2
(
FILE
*
pFile
,
unsigned
Sign
[],
int
nBits
);
extern
int
Extra_ReadHex
(
unsigned
Sign
[],
char
*
pString
,
int
nDigits
);
extern
int
Extra_ReadHexadecimal
(
unsigned
Sign
[],
char
*
pString
,
int
nVars
);
extern
void
Extra_PrintHexadecimal
(
FILE
*
pFile
,
unsigned
Sign
[],
int
nVars
);
...
...
src/misc/extra/extraUtilFile.c
View file @
f49e8f0f
...
...
@@ -508,6 +508,23 @@ void Extra_PrintBinary( FILE * pFile, unsigned Sign[], int nBits )
// fprintf( pFile, "\n" );
}
void
Extra_PrintBinary2
(
FILE
*
pFile
,
unsigned
Sign
[],
int
nBits
)
{
int
Remainder
,
nWords
;
int
w
,
i
;
Remainder
=
(
nBits
%
(
sizeof
(
unsigned
)
*
8
));
nWords
=
(
nBits
/
(
sizeof
(
unsigned
)
*
8
))
+
(
Remainder
>
0
);
for
(
w
=
0
;
w
<
nWords
;
w
++
)
{
int
Limit
=
w
==
nWords
-
1
?
Remainder
:
32
;
for
(
i
=
0
;
i
<
Limit
;
i
++
)
fprintf
(
pFile
,
"%c"
,
'0'
+
(
int
)((
Sign
[
w
]
&
(
1
<<
i
))
>
0
)
);
}
// fprintf( pFile, "\n" );
}
/**Function*************************************************************
...
...
src/misc/extra/extraUtilMaj.c
0 → 100644
View file @
f49e8f0f
This diff is collapsed.
Click to expand it.
src/misc/extra/module.make
View file @
f49e8f0f
...
...
@@ -4,6 +4,7 @@ SRC += src/misc/extra/extraUtilBitMatrix.c \
src/misc/extra/extraUtilDsd.c
\
src/misc/extra/extraUtilEnum.c
\
src/misc/extra/extraUtilFile.c
\
src/misc/extra/extraUtilMaj.c
\
src/misc/extra/extraUtilMemory.c
\
src/misc/extra/extraUtilMisc.c
\
src/misc/extra/extraUtilMult.c
\
...
...
src/misc/util/utilTruth.h
View file @
f49e8f0f
...
...
@@ -3094,6 +3094,75 @@ static inline int Abc_Tt4Check( int t )
return
0
;
}
/**Function*************************************************************
Synopsis [Returns symmetry profile of the function.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
int
Abc_TtVarsAreSymmetric
(
word
*
pTruth
,
int
nVars
,
int
i
,
int
j
,
word
*
pCof0
,
word
*
pCof1
)
{
int
nWords
=
Abc_TtWordNum
(
nVars
);
assert
(
i
<
nVars
&&
j
<
nVars
);
Abc_TtCofactor0p
(
pCof0
,
pTruth
,
nWords
,
i
);
Abc_TtCofactor1p
(
pCof1
,
pTruth
,
nWords
,
i
);
Abc_TtCofactor1
(
pCof0
,
nWords
,
j
);
Abc_TtCofactor0
(
pCof1
,
nWords
,
j
);
return
Abc_TtEqual
(
pCof0
,
pCof1
,
nWords
);
}
static
inline
int
Abc_TtIsFullySymmetric
(
word
*
pTruth
,
int
nVars
)
{
int
m
,
v
,
Polar
=
0
,
Seen
=
0
;
for
(
m
=
0
;
m
<
(
1
<<
nVars
);
m
++
)
{
int
Count
=
0
;
int
Value
=
Abc_TtGetBit
(
pTruth
,
m
);
for
(
v
=
0
;
v
<
nVars
;
v
++
)
Count
+=
((
m
>>
v
)
&
1
);
if
(
(
Seen
>>
Count
)
&
1
)
// seen this count
{
if
(
Value
!=
((
Polar
>>
Count
)
&
1
)
)
return
-
1
;
}
else
// new count
{
Seen
|=
1
<<
Count
;
if
(
Value
)
Polar
|=
1
<<
Count
;
}
}
return
Polar
;
}
static
inline
void
Abc_TtGenFullySymmetric
(
word
*
pTruth
,
int
nVars
,
int
Polar
)
{
int
m
,
v
,
nWords
=
Abc_TtWordNum
(
nVars
);
Abc_TtClear
(
pTruth
,
nWords
);
for
(
m
=
0
;
m
<
(
1
<<
nVars
);
m
++
)
{
int
Count
=
0
;
for
(
v
=
0
;
v
<
nVars
;
v
++
)
Count
+=
((
m
>>
v
)
&
1
);
if
(
(
Polar
>>
Count
)
&
1
)
Abc_TtSetBit
(
pTruth
,
m
);
}
}
static
inline
void
Abc_TtTestFullySymmetric
()
{
word
pTruth
[
4
];
// 8-var function
int
PolarOut
,
PolarIn
=
271
;
Abc_TtGenFullySymmetric
(
pTruth
,
8
,
PolarIn
);
//Abc_TtXorBit( pTruth, 171 );
PolarOut
=
Abc_TtIsFullySymmetric
(
pTruth
,
8
);
assert
(
PolarIn
==
PolarOut
);
}
/*=== utilTruth.c ===========================================================*/
...
...
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