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
8752613e
Commit
8752613e
authored
Nov 19, 2019
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiments with truth tables.
parent
0d24b4e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
153 additions
and
0 deletions
+153
-0
src/base/abci/abc.c
+49
-0
src/base/abci/abcDec.c
+30
-0
src/bool/kit/kitGraph.c
+74
-0
No files found.
src/base/abci/abc.c
View file @
8752613e
...
...
@@ -135,6 +135,7 @@ static int Abc_CommandMerge ( Abc_Frame_t * pAbc, int argc, cha
static
int
Abc_CommandTestDec
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandTestNpn
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandTestRPO
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandTestTruth
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandRunEco
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandRunGen
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
static
int
Abc_CommandRunSim
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
);
...
...
@@ -838,6 +839,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd
(
pAbc
,
"Synthesis"
,
"testdec"
,
Abc_CommandTestDec
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Synthesis"
,
"testnpn"
,
Abc_CommandTestNpn
,
0
);
Cmd_CommandAdd
(
pAbc
,
"LogiCS"
,
"testrpo"
,
Abc_CommandTestRPO
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Synthesis"
,
"testtruth"
,
Abc_CommandTestTruth
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Synthesis"
,
"runeco"
,
Abc_CommandRunEco
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Synthesis"
,
"rungen"
,
Abc_CommandRunGen
,
0
);
Cmd_CommandAdd
(
pAbc
,
"Synthesis"
,
"runsim"
,
Abc_CommandRunSim
,
0
);
...
...
@@ -6931,6 +6933,53 @@ usage:
SeeAlso []
***********************************************************************/
int
Abc_CommandTestTruth
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
int
*
Kit_TruthTest
(
char
*
pFileName
);
int
*
pResult
=
NULL
;
int
c
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"vh"
)
)
!=
EOF
)
{
switch
(
c
)
{
case
'v'
:
fVerbose
^=
1
;
break
;
case
'h'
:
goto
usage
;
default:
goto
usage
;
}
}
if
(
argc
!=
globalUtilOptind
+
1
)
{
Abc_Print
(
1
,
"Input file is not given.
\n
"
);
return
0
;
}
pResult
=
Kit_TruthTest
(
argv
[
globalUtilOptind
]
);
ABC_FREE
(
pResult
);
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: testtruth [-vh] <file>
\n
"
);
Abc_Print
(
-
2
,
"
\t
printing truth table stats
\n
"
);
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_CommandRunEco
(
Abc_Frame_t
*
pAbc
,
int
argc
,
char
**
argv
)
{
extern
void
Acb_NtkRunEco
(
char
*
pFileNames
[
4
],
int
fCheck
,
int
fVerbose
);
src/base/abci/abcDec.c
View file @
8752613e
...
...
@@ -439,6 +439,36 @@ Abc_TtStore_t * Abc_TtStoreLoad( char * pFileName, int nVarNum )
SeeAlso []
***********************************************************************/
void
Abc_TtStoreLoadSave
(
char
*
pFileName
)
{
Abc_TtStore_t
*
p
;
char
*
pFileInput
=
pFileName
;
char
*
pFileOutput
=
Extra_FileNameGenericAppend
(
pFileName
,
"_binary.data"
);
// read info from file
p
=
Abc_TtStoreLoad
(
pFileInput
,
-
1
);
if
(
p
==
NULL
)
return
;
// write into another file
Abc_TtStoreWrite
(
pFileOutput
,
p
,
1
);
// delete data-structure
Abc_TtStoreFree
(
p
,
-
1
);
printf
(
"Input file
\"
%s
\"
was copied into output file
\"
%s
\"
.
\n
"
,
pFileInput
,
pFileOutput
);
}
/**Function*************************************************************
Synopsis [Read truth tables from input file and write them into output file.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Abc_TtStoreTest
(
char
*
pFileName
)
{
Abc_TtStore_t
*
p
;
...
...
src/bool/kit/kitGraph.c
View file @
8752613e
...
...
@@ -394,6 +394,80 @@ int Kit_GraphLeafDepth_rec( Kit_Graph_t * pGraph, Kit_Node_t * pNode, Kit_Node_t
return
Depth
;
}
/**Function*************************************************************
Synopsis [Derives logic level of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Kit_GraphLevelNum_rec
(
Kit_Graph_t
*
pGraph
,
Kit_Node_t
*
pNode
)
{
int
Depth0
,
Depth1
;
if
(
Kit_GraphNodeIsVar
(
pGraph
,
pNode
)
)
return
0
;
Depth0
=
Kit_GraphLevelNum_rec
(
pGraph
,
Kit_GraphNodeFanin0
(
pGraph
,
pNode
)
);
Depth1
=
Kit_GraphLevelNum_rec
(
pGraph
,
Kit_GraphNodeFanin1
(
pGraph
,
pNode
)
);
return
1
+
KIT_MAX
(
Depth0
,
Depth1
);
}
/**Function*************************************************************
Synopsis [Returns FF nodes and levels.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int
Kit_TruthStats
(
unsigned
*
pTruth
,
int
nVars
,
Vec_Int_t
*
vMemory
)
{
Kit_Graph_t
*
pGraph
=
Kit_TruthToGraph
(
pTruth
,
nVars
,
vMemory
);
int
nNodes
=
Kit_GraphNodeNum
(
pGraph
);
int
nLevels
=
Kit_GraphLevelNum_rec
(
pGraph
,
Kit_GraphNodeLast
(
pGraph
)
);
Kit_GraphFree
(
pGraph
);
return
(
nLevels
<<
16
)
|
nNodes
;
}
int
*
Kit_TruthStatsArray
(
unsigned
*
pArray
,
int
nVars
,
int
nFuncs
)
{
int
f
,
*
pRes
=
ABC_CALLOC
(
int
,
nFuncs
);
int
nInts
=
Abc_TruthWordNum
(
nVars
);
Vec_Int_t
*
vMemory
=
Vec_IntAlloc
(
1
<<
16
);
for
(
f
=
0
;
f
<
nFuncs
;
f
++
)
pRes
[
f
]
=
Kit_TruthStats
(
pArray
+
f
*
nInts
,
nVars
,
vMemory
);
Vec_IntFree
(
vMemory
);
return
pRes
;
}
int
Kit_TruthFindVarNum
(
char
*
pFileName
)
{
int
i
;
for
(
i
=
0
;
i
<
(
int
)
strlen
(
pFileName
);
i
++
)
if
(
pFileName
[
i
]
>=
'0'
&&
pFileName
[
i
]
<=
'9'
)
return
atoi
(
pFileName
+
i
);
return
-
1
;
}
int
*
Kit_TruthTest
(
char
*
pFileName
)
{
abctime
clk
=
Abc_Clock
();
int
i
;
int
nFileSize
=
Extra_FileSize
(
pFileName
);
int
nVars
=
Kit_TruthFindVarNum
(
pFileName
);
int
nFuncs
=
nFileSize
/
4
/
Abc_TruthWordNum
(
nVars
);
unsigned
*
pA
=
(
unsigned
*
)
Extra_FileReadContents
(
pFileName
);
int
*
pResult
=
Kit_TruthStatsArray
(
pA
,
nVars
,
nFuncs
);
printf
(
"Finished proceessing %d functions with %d variables. "
,
nFuncs
,
nVars
);
Abc_PrintTime
(
1
,
"Time"
,
Abc_Clock
()
-
clk
);
ABC_FREE
(
pA
);
for
(
i
=
0
;
i
<
5
;
i
++
)
printf
(
"Function %3d : AND2 = %3d Lev = %3d
\n
"
,
i
,
pResult
[
i
]
&
0xFFFF
,
pResult
[
i
]
>>
16
);
return
pResult
;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...
...
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