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
059da574
Commit
059da574
authored
Oct 25, 2012
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding binary file dumping for truth tables.
parent
785ae9e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
19 deletions
+43
-19
src/base/abci/abc.c
+9
-4
src/base/abci/abcDec.c
+7
-5
src/base/abci/abcNpn.c
+9
-6
src/base/io/io.c
+18
-4
No files found.
src/base/abci/abc.c
View file @
059da574
...
...
@@ -4846,15 +4846,16 @@ usage:
***********************************************************************/
int
Abc_CommandTestNpn
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
int
Abc_NpnTest
(
char
*
pFileName
,
int
NpnType
,
int
nVarNum
,
int
fDumpRes
,
int
fVerbose
);
extern
int
Abc_NpnTest
(
char
*
pFileName
,
int
NpnType
,
int
nVarNum
,
int
fDumpRes
,
int
f
Binary
,
int
f
Verbose
);
char
*
pFileName
;
int
c
;
int
fVerbose
=
0
;
int
NpnType
=
0
;
int
nVarNum
=
-
1
;
int
fDumpRes
=
0
;
int
fBinary
=
0
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"ANdvh"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"ANd
b
vh"
)
)
!=
EOF
)
{
switch
(
c
)
{
...
...
@@ -4883,6 +4884,9 @@ int Abc_CommandTestNpn( Abc_Frame_t * pAbc, int argc, char ** argv )
case
'd'
:
fDumpRes
^=
1
;
break
;
case
'b'
:
fBinary
^=
1
;
break
;
case
'v'
:
fVerbose
^=
1
;
break
;
...
...
@@ -4905,11 +4909,11 @@ int Abc_CommandTestNpn( Abc_Frame_t * pAbc, int argc, char ** argv )
// get the output file name
pFileName
=
argv
[
globalUtilOptind
];
// call the testbench
Abc_NpnTest
(
pFileName
,
NpnType
,
nVarNum
,
fDumpRes
,
fVerbose
);
Abc_NpnTest
(
pFileName
,
NpnType
,
nVarNum
,
fDumpRes
,
f
Binary
,
f
Verbose
);
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: testnpn [-AN <num>] [-dvh] <file>
\n
"
);
Abc_Print
(
-
2
,
"usage: testnpn [-AN <num>] [-d
b
vh] <file>
\n
"
);
Abc_Print
(
-
2
,
"
\t
testbench for computing (semi-)canonical forms
\n
"
);
Abc_Print
(
-
2
,
"
\t
of completely-specified Boolean functions up to 16 varibles
\n
"
);
Abc_Print
(
-
2
,
"
\t
-A <num> : semi-caninical form computation algorithm [default = %d]
\n
"
,
NpnType
);
...
...
@@ -4920,6 +4924,7 @@ usage:
Abc_Print
(
-
2
,
"
\t
4: Jake's hybrid semi-canonical form (high-effort)
\n
"
);
Abc_Print
(
-
2
,
"
\t
-N <num> : the number of support variables (binary files only) [default = unused]
\n
"
);
Abc_Print
(
-
2
,
"
\t
-d : toggle dumping resulting functions into a file [default = %s]
\n
"
,
fDumpRes
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-b : toggle dumping in binary format [default = %s]
\n
"
,
fBinary
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-v : toggle verbose printout [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : print the command usage
\n
"
);
Abc_Print
(
-
2
,
"
\t
<file> : a text file with truth tables in hexadecimal, listed one per line,
\n
"
);
...
...
src/base/abci/abcDec.c
View file @
059da574
...
...
@@ -353,10 +353,10 @@ void Abc_TruthStoreRead( char * pFileName, Abc_TtStore_t * p )
SeeAlso []
***********************************************************************/
void
Abc_TtStoreWrite
(
char
*
pFileName
,
Abc_TtStore_t
*
p
)
void
Abc_TtStoreWrite
(
char
*
pFileName
,
Abc_TtStore_t
*
p
,
int
fBinary
)
{
FILE
*
pFile
;
int
i
;
int
i
,
nBytes
=
8
*
Abc_Truth6WordNum
(
p
->
nVars
)
;
pFile
=
fopen
(
pFileName
,
"wb"
);
if
(
pFile
==
NULL
)
{
...
...
@@ -365,8 +365,10 @@ void Abc_TtStoreWrite( char * pFileName, Abc_TtStore_t * p )
}
for
(
i
=
0
;
i
<
p
->
nFuncs
;
i
++
)
{
Abc_TruthWriteHex
(
pFile
,
p
->
pFuncs
[
i
],
p
->
nVars
);
fprintf
(
pFile
,
"
\n
"
);
if
(
fBinary
)
fwrite
(
p
->
pFuncs
[
i
],
nBytes
,
1
,
pFile
);
else
Abc_TruthWriteHex
(
pFile
,
p
->
pFuncs
[
i
],
p
->
nVars
),
fprintf
(
pFile
,
"
\n
"
);
}
fclose
(
pFile
);
}
...
...
@@ -441,7 +443,7 @@ void Abc_TtStoreTest( char * pFileName )
return
;
// write into another file
Abc_TtStoreWrite
(
pFileOutput
,
p
);
Abc_TtStoreWrite
(
pFileOutput
,
p
,
0
);
// delete data-structure
Abc_TtStoreFree
(
p
,
-
1
);
...
...
src/base/abci/abcNpn.c
View file @
059da574
...
...
@@ -49,7 +49,7 @@ struct Abc_TtStore_t_
extern
Abc_TtStore_t
*
Abc_TtStoreLoad
(
char
*
pFileName
,
int
nVarNum
);
extern
void
Abc_TtStoreFree
(
Abc_TtStore_t
*
p
,
int
nVarNum
);
extern
void
Abc_TtStoreWrite
(
char
*
pFileName
,
Abc_TtStore_t
*
p
);
extern
void
Abc_TtStoreWrite
(
char
*
pFileName
,
Abc_TtStore_t
*
p
,
int
fBinary
);
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
...
...
@@ -276,7 +276,7 @@ void Abc_TruthNpnPerform( Abc_TtStore_t * p, int NpnType, int fVerbose )
SeeAlso []
***********************************************************************/
void
Abc_TruthNpnTest
(
char
*
pFileName
,
int
NpnType
,
int
nVarNum
,
int
fDumpRes
,
int
fVerbose
)
void
Abc_TruthNpnTest
(
char
*
pFileName
,
int
NpnType
,
int
nVarNum
,
int
fDumpRes
,
int
f
Binary
,
int
f
Verbose
)
{
Abc_TtStore_t
*
p
;
char
*
pFileNameOut
;
...
...
@@ -292,8 +292,11 @@ void Abc_TruthNpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes,
// write the result
if
(
fDumpRes
)
{
pFileNameOut
=
Extra_FileNameGenericAppend
(
pFileName
,
"_out.txt"
);
Abc_TtStoreWrite
(
pFileNameOut
,
p
);
if
(
fBinary
)
pFileNameOut
=
Extra_FileNameGenericAppend
(
pFileName
,
"_out.tt"
);
else
pFileNameOut
=
Extra_FileNameGenericAppend
(
pFileName
,
"_out.txt"
);
Abc_TtStoreWrite
(
pFileNameOut
,
p
,
fBinary
);
if
(
fVerbose
)
printf
(
"The resulting functions are written into file
\"
%s
\"
.
\n
"
,
pFileNameOut
);
}
...
...
@@ -315,12 +318,12 @@ void Abc_TruthNpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes,
SeeAlso []
***********************************************************************/
int
Abc_NpnTest
(
char
*
pFileName
,
int
NpnType
,
int
nVarNum
,
int
fDumpRes
,
int
fVerbose
)
int
Abc_NpnTest
(
char
*
pFileName
,
int
NpnType
,
int
nVarNum
,
int
fDumpRes
,
int
f
Binary
,
int
f
Verbose
)
{
if
(
fVerbose
)
printf
(
"Using truth tables from file
\"
%s
\"
...
\n
"
,
pFileName
);
if
(
NpnType
>=
0
&&
NpnType
<=
4
)
Abc_TruthNpnTest
(
pFileName
,
NpnType
,
nVarNum
,
fDumpRes
,
fVerbose
);
Abc_TruthNpnTest
(
pFileName
,
NpnType
,
nVarNum
,
fDumpRes
,
f
Binary
,
f
Verbose
);
else
printf
(
"Unknown canonical form value (%d).
\n
"
,
NpnType
);
fflush
(
stdout
);
...
...
src/base/io/io.c
View file @
059da574
...
...
@@ -2739,17 +2739,22 @@ int IoCommandWriteTruths( Abc_Frame_t * pAbc, int argc, char **argv )
char
*
pFileName
;
FILE
*
pFile
;
unsigned
*
pTruth
;
int
nBytes
;
int
fReverse
=
0
;
int
fBinary
=
0
;
int
c
,
i
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"rh"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"r
b
h"
)
)
!=
EOF
)
{
switch
(
c
)
{
case
'r'
:
fReverse
^=
1
;
break
;
case
'b'
:
fBinary
^=
1
;
break
;
case
'h'
:
goto
usage
;
default
:
...
...
@@ -2766,6 +2771,11 @@ int IoCommandWriteTruths( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_Print
(
-
1
,
"IoCommandWriteTruths(): Can write truth tables up to 16 inputs.
\n
"
);
return
0
;
}
if
(
Gia_ManPiNum
(
pAbc
->
pGia
)
<
3
)
{
Abc_Print
(
-
1
,
"IoCommandWriteTruths(): Can write truth tables for 3 inputs or more.
\n
"
);
return
0
;
}
if
(
argc
!=
globalUtilOptind
+
1
)
goto
usage
;
// get the input file name
...
...
@@ -2777,19 +2787,23 @@ int IoCommandWriteTruths( Abc_Frame_t * pAbc, int argc, char **argv )
printf
(
"Cannot open file
\"
%s
\"
for writing.
\n
"
,
pFileName
);
return
0
;
}
nBytes
=
8
*
Abc_Truth6WordNum
(
Gia_ManPiNum
(
pAbc
->
pGia
)
);
Gia_ManForEachCo
(
pAbc
->
pGia
,
pObj
,
i
)
{
pTruth
=
Gia_ObjComputeTruthTable
(
pAbc
->
pGia
,
pObj
);
Extra_PrintHex
(
pFile
,
pTruth
,
Gia_ManPiNum
(
pAbc
->
pGia
)
);
fprintf
(
pFile
,
"
\n
"
);
if
(
fBinary
)
fwrite
(
pTruth
,
nBytes
,
1
,
pFile
);
else
Extra_PrintHex
(
pFile
,
pTruth
,
Gia_ManPiNum
(
pAbc
->
pGia
)
),
fprintf
(
pFile
,
"
\n
"
);
}
fclose
(
pFile
);
return
0
;
usage
:
fprintf
(
pAbc
->
Err
,
"usage: &write_truths [-rh] <file>
\n
"
);
fprintf
(
pAbc
->
Err
,
"usage: &write_truths [-r
b
h] <file>
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
writes truth tables of each PO of GIA manager into a file
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
-r : toggle reversing bits in the truth table [default = %s]
\n
"
,
fReverse
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-b : toggle using binary format [default = %s]
\n
"
,
fBinary
?
"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
"
);
return
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