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
f5320744
Commit
f5320744
authored
Apr 15, 2019
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding switch 'read_truth -f <file_name>' to read truth table from file.
parent
1b59ec57
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
src/base/io/io.c
+22
-9
No files found.
src/base/io/io.c
View file @
f5320744
...
@@ -1102,19 +1102,23 @@ usage:
...
@@ -1102,19 +1102,23 @@ usage:
int
IoCommandReadTruth
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
int
IoCommandReadTruth
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
{
Abc_Ntk_t
*
pNtk
;
Abc_Ntk_t
*
pNtk
;
char
*
pStr
=
NULL
;
char
*
pSopCover
;
char
*
pSopCover
;
int
fHex
;
int
fHex
=
1
;
int
fFile
=
0
;
int
c
;
int
c
;
fHex
=
1
;
Extra_UtilGetoptReset
();
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"xh"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"x
f
h"
)
)
!=
EOF
)
{
{
switch
(
c
)
switch
(
c
)
{
{
case
'x'
:
case
'x'
:
fHex
^=
1
;
fHex
^=
1
;
break
;
break
;
case
'f'
:
fFile
^=
1
;
break
;
case
'h'
:
case
'h'
:
goto
usage
;
goto
usage
;
default:
default:
...
@@ -1123,15 +1127,22 @@ int IoCommandReadTruth( Abc_Frame_t * pAbc, int argc, char ** argv )
...
@@ -1123,15 +1127,22 @@ int IoCommandReadTruth( Abc_Frame_t * pAbc, int argc, char ** argv )
}
}
if
(
argc
!=
globalUtilOptind
+
1
)
if
(
argc
!=
globalUtilOptind
+
1
)
{
goto
usage
;
goto
usage
;
}
if
(
fFile
)
pStr
=
Extra_FileReadContents
(
argv
[
globalUtilOptind
]
);
else
pStr
=
argv
[
globalUtilOptind
];
while
(
pStr
[
strlen
(
pStr
)
-
1
]
==
'\n'
||
pStr
[
strlen
(
pStr
)
-
1
]
==
'\r'
)
pStr
[
strlen
(
pStr
)
-
1
]
=
'\0'
;
// convert truth table to SOP
// convert truth table to SOP
if
(
fHex
)
if
(
fHex
)
pSopCover
=
Abc_SopFromTruthHex
(
argv
[
globalUtilOptind
]
);
pSopCover
=
Abc_SopFromTruthHex
(
pStr
);
else
else
pSopCover
=
Abc_SopFromTruthBin
(
argv
[
globalUtilOptind
]);
pSopCover
=
Abc_SopFromTruthBin
(
pStr
);
if
(
fFile
)
ABC_FREE
(
pStr
);
if
(
pSopCover
==
NULL
||
pSopCover
[
0
]
==
0
)
if
(
pSopCover
==
NULL
||
pSopCover
[
0
]
==
0
)
{
{
ABC_FREE
(
pSopCover
);
ABC_FREE
(
pSopCover
);
...
@@ -1152,11 +1163,13 @@ int IoCommandReadTruth( Abc_Frame_t * pAbc, int argc, char ** argv )
...
@@ -1152,11 +1163,13 @@ int IoCommandReadTruth( Abc_Frame_t * pAbc, int argc, char ** argv )
return
0
;
return
0
;
usage:
usage:
fprintf
(
pAbc
->
Err
,
"usage: read_truth [-x
h] <truth
>
\n
"
);
fprintf
(
pAbc
->
Err
,
"usage: read_truth [-x
fh] <truth> <file
>
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
creates network with node having given truth table
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
creates network with node having given truth table
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
-x : toggles between bin and hex representation [default = %s]
\n
"
,
fHex
?
"hex"
:
"bin"
);
fprintf
(
pAbc
->
Err
,
"
\t
-x : toggles between bin and hex representation [default = %s]
\n
"
,
fHex
?
"hex"
:
"bin"
);
fprintf
(
pAbc
->
Err
,
"
\t
-f : toggles reading truth table from file [default = %s]
\n
"
,
fFile
?
"yes"
:
"no"
);
fprintf
(
pAbc
->
Err
,
"
\t
-h : prints the command summary
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
-h : prints the command summary
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
truth : truth table with most signficant bit first (e.g. 1000 for AND(a,b))
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
truth : truth table with most signficant bit first (e.g. 1000 for AND(a,b))
\n
"
);
fprintf
(
pAbc
->
Err
,
"
\t
file : file name with the truth table
\n
"
);
return
1
;
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