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
7ccb25bf
Commit
7ccb25bf
authored
May 07, 2019
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modifying 'write_truth' to dump truth table in hex.
parent
eb2764b5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
3 deletions
+30
-3
src/base/io/io.c
+11
-3
src/misc/extra/extra.h
+1
-0
src/misc/extra/extraUtilFile.c
+18
-0
No files found.
src/base/io/io.c
View file @
7ccb25bf
...
...
@@ -2968,14 +2968,18 @@ int IoCommandWriteTruth( Abc_Frame_t * pAbc, int argc, char **argv )
char
*
pFileName
;
FILE
*
pFile
;
unsigned
*
pTruth
;
int
fHex
=
1
;
int
fReverse
=
0
;
int
c
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"rh"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"
x
rh"
)
)
!=
EOF
)
{
switch
(
c
)
{
case
'x'
:
fHex
^=
1
;
break
;
case
'r'
:
fReverse
^=
1
;
break
;
...
...
@@ -3031,14 +3035,18 @@ int IoCommandWriteTruth( Abc_Frame_t * pAbc, int argc, char **argv )
printf
(
"Cannot open file
\"
%s
\"
for writing.
\n
"
,
pFileName
);
return
0
;
}
Extra_PrintBinary
(
pFile
,
pTruth
,
1
<<
Abc_ObjFaninNum
(
pNode
)
);
if
(
fHex
)
Extra_PrintHex2
(
pFile
,
pTruth
,
Abc_ObjFaninNum
(
pNode
)
);
else
Extra_PrintBinary
(
pFile
,
pTruth
,
1
<<
Abc_ObjFaninNum
(
pNode
)
);
fclose
(
pFile
);
Vec_IntFree
(
vTruth
);
return
0
;
usage
:
fprintf
(
pAbc
->
Err
,
"usage: write_truth [-rh] <file>
\n
"
);
fprintf
(
pAbc
->
Err
,
"usage: write_truth [-
x
rh] <file>
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
writes truth table into a file
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
-x : toggles between bin and hex representation [default = %s]
\n
"
,
fHex
?
"hex"
:
"bin"
);
fprintf
(
pAbc
->
Err
,
"
\t
-r : toggle reversing bits in the truth table [default = %s]
\n
"
,
fReverse
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-h : print the help massage
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
file : the name of the file to write
\n
"
);
...
...
src/misc/extra/extra.h
View file @
7ccb25bf
...
...
@@ -125,6 +125,7 @@ extern int Extra_ReadHexadecimal( unsigned Sign[], char * pString, int
extern
void
Extra_PrintHexadecimal
(
FILE
*
pFile
,
unsigned
Sign
[],
int
nVars
);
extern
void
Extra_PrintHexadecimalString
(
char
*
pString
,
unsigned
Sign
[],
int
nVars
);
extern
void
Extra_PrintHex
(
FILE
*
pFile
,
unsigned
*
pTruth
,
int
nVars
);
extern
void
Extra_PrintHex2
(
FILE
*
pFile
,
unsigned
*
pTruth
,
int
nVars
);
extern
void
Extra_PrintHexReverse
(
FILE
*
pFile
,
unsigned
*
pTruth
,
int
nVars
);
extern
void
Extra_PrintSymbols
(
FILE
*
pFile
,
char
Char
,
int
nTimes
,
int
fPrintNewLine
);
...
...
src/misc/extra/extraUtilFile.c
View file @
7ccb25bf
...
...
@@ -656,6 +656,24 @@ void Extra_PrintHex( FILE * pFile, unsigned * pTruth, int nVars )
}
// fprintf( pFile, "\n" );
}
void
Extra_PrintHex2
(
FILE
*
pFile
,
unsigned
*
pTruth
,
int
nVars
)
{
int
nMints
,
nDigits
,
Digit
,
k
;
// write the number into the file
//fprintf( pFile, "0x" );
nMints
=
(
1
<<
nVars
);
nDigits
=
nMints
/
4
+
((
nMints
%
4
)
>
0
);
for
(
k
=
nDigits
-
1
;
k
>=
0
;
k
--
)
{
Digit
=
((
pTruth
[
k
/
8
]
>>
(
k
*
4
))
&
15
);
if
(
Digit
<
10
)
fprintf
(
pFile
,
"%d"
,
Digit
);
else
fprintf
(
pFile
,
"%c"
,
'A'
+
Digit
-
10
);
}
// fprintf( pFile, "\n" );
}
void
Extra_PrintHexReverse
(
FILE
*
pFile
,
unsigned
*
pTruth
,
int
nVars
)
{
int
nMints
,
nDigits
,
Digit
,
k
;
...
...
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