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
0f29f0ae
Commit
0f29f0ae
authored
May 21, 2016
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improving SMT-LIB parser.
parent
34c5ac88
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
76 deletions
+103
-76
src/base/wlc/wlc.h
+37
-36
src/base/wlc/wlcBlast.c
+12
-2
src/base/wlc/wlcCom.c
+13
-3
src/base/wlc/wlcNtk.c
+37
-34
src/base/wlc/wlcReadSmt.c
+0
-0
src/base/wlc/wlcReadVer.c
+1
-0
src/base/wlc/wlcStdin.c
+1
-1
src/base/wlc/wlcWriteVer.c
+2
-0
No files found.
src/base/wlc/wlc.h
View file @
0f29f0ae
...
...
@@ -61,40 +61,41 @@ typedef enum {
WLC_OBJ_BIT_AND
,
// 16: bitwise AND
WLC_OBJ_BIT_OR
,
// 17: bitwise OR
WLC_OBJ_BIT_XOR
,
// 18: bitwise XOR
WLC_OBJ_BIT_NAND
,
// 16: bitwise AND
WLC_OBJ_BIT_NOR
,
// 17: bitwise OR
WLC_OBJ_BIT_NXOR
,
// 19: bitwise NXOR
WLC_OBJ_BIT_SELECT
,
// 20: bit selection
WLC_OBJ_BIT_CONCAT
,
// 21: bit concatenation
WLC_OBJ_BIT_ZEROPAD
,
// 22: zero padding
WLC_OBJ_BIT_SIGNEXT
,
// 23: sign extension
WLC_OBJ_LOGIC_NOT
,
// 24: logic NOT
WLC_OBJ_LOGIC_AND
,
// 25: logic AND
WLC_OBJ_LOGIC_OR
,
// 27: logic OR
WLC_OBJ_LOGIC_XOR
,
// 28: logic XOR
WLC_OBJ_COMP_EQU
,
// 29: compare equal
WLC_OBJ_COMP_NOTEQU
,
// 30: compare not equal
WLC_OBJ_COMP_LESS
,
// 31: compare less
WLC_OBJ_COMP_MORE
,
// 32: compare more
WLC_OBJ_COMP_LESSEQU
,
// 33: compare less or equal
WLC_OBJ_COMP_MOREEQU
,
// 34: compare more or equal
WLC_OBJ_REDUCT_AND
,
// 35: reduction AND
WLC_OBJ_REDUCT_OR
,
// 36: reduction OR
WLC_OBJ_REDUCT_XOR
,
// 37: reduction XOR
WLC_OBJ_REDUCT_NAND
,
// 38: reduction NAND
WLC_OBJ_REDUCT_NOR
,
// 39: reduction NOR
WLC_OBJ_REDUCT_NXOR
,
// 40: reduction NXOR
WLC_OBJ_ARI_ADD
,
// 41: arithmetic addition
WLC_OBJ_ARI_SUB
,
// 42: arithmetic subtraction
WLC_OBJ_ARI_MULTI
,
// 43: arithmetic multiplier
WLC_OBJ_ARI_DIVIDE
,
// 44: arithmetic division
WLC_OBJ_ARI_MODULUS
,
// 45: arithmetic modulus
WLC_OBJ_ARI_POWER
,
// 46: arithmetic power
WLC_OBJ_ARI_MINUS
,
// 47: arithmetic minus
WLC_OBJ_ARI_SQRT
,
// 48: integer square root
WLC_OBJ_ARI_SQUARE
,
// 49: integer square
WLC_OBJ_TABLE
,
// 50: bit table
WLC_OBJ_NUMBER
// 51: unused
WLC_OBJ_BIT_NAND
,
// 19: bitwise AND
WLC_OBJ_BIT_NOR
,
// 20: bitwise OR
WLC_OBJ_BIT_NXOR
,
// 21: bitwise NXOR
WLC_OBJ_BIT_SELECT
,
// 22: bit selection
WLC_OBJ_BIT_CONCAT
,
// 23: bit concatenation
WLC_OBJ_BIT_ZEROPAD
,
// 24: zero padding
WLC_OBJ_BIT_SIGNEXT
,
// 25: sign extension
WLC_OBJ_LOGIC_NOT
,
// 26: logic NOT
WLC_OBJ_LOGIC_IMPL
,
// 27: logic implication
WLC_OBJ_LOGIC_AND
,
// 28: logic AND
WLC_OBJ_LOGIC_OR
,
// 29: logic OR
WLC_OBJ_LOGIC_XOR
,
// 30: logic XOR
WLC_OBJ_COMP_EQU
,
// 31: compare equal
WLC_OBJ_COMP_NOTEQU
,
// 32: compare not equal
WLC_OBJ_COMP_LESS
,
// 33: compare less
WLC_OBJ_COMP_MORE
,
// 34: compare more
WLC_OBJ_COMP_LESSEQU
,
// 35: compare less or equal
WLC_OBJ_COMP_MOREEQU
,
// 36: compare more or equal
WLC_OBJ_REDUCT_AND
,
// 37: reduction AND
WLC_OBJ_REDUCT_OR
,
// 38: reduction OR
WLC_OBJ_REDUCT_XOR
,
// 39: reduction XOR
WLC_OBJ_REDUCT_NAND
,
// 40: reduction NAND
WLC_OBJ_REDUCT_NOR
,
// 41: reduction NOR
WLC_OBJ_REDUCT_NXOR
,
// 42: reduction NXOR
WLC_OBJ_ARI_ADD
,
// 43: arithmetic addition
WLC_OBJ_ARI_SUB
,
// 44: arithmetic subtraction
WLC_OBJ_ARI_MULTI
,
// 45: arithmetic multiplier
WLC_OBJ_ARI_DIVIDE
,
// 46: arithmetic division
WLC_OBJ_ARI_MODULUS
,
// 47: arithmetic modulus
WLC_OBJ_ARI_POWER
,
// 48: arithmetic power
WLC_OBJ_ARI_MINUS
,
// 49: arithmetic minus
WLC_OBJ_ARI_SQRT
,
// 50: integer square root
WLC_OBJ_ARI_SQUARE
,
// 51: integer square
WLC_OBJ_TABLE
,
// 52: bit table
WLC_OBJ_NUMBER
// 53: unused
}
Wlc_ObjType_t
;
// when adding new types, remember to update table Wlc_Names in "wlcNtk.c"
...
...
@@ -273,8 +274,8 @@ extern Wlc_Ntk_t * Wlc_NtkDupDfs( Wlc_Ntk_t * p );
extern
void
Wlc_NtkTransferNames
(
Wlc_Ntk_t
*
pNew
,
Wlc_Ntk_t
*
p
);
extern
Wlc_Ntk_t
*
Wlc_NtkDupSingleNodes
(
Wlc_Ntk_t
*
p
);
/*=== wlcReadSmt.c ========================================================*/
extern
Wlc_Ntk_t
*
Wlc_ReadSmtBuffer
(
char
*
pFileName
,
char
*
pBuffer
,
char
*
pLimit
);
extern
Wlc_Ntk_t
*
Wlc_ReadSmt
(
char
*
pFileName
);
extern
Wlc_Ntk_t
*
Wlc_ReadSmtBuffer
(
char
*
pFileName
,
char
*
pBuffer
,
char
*
pLimit
,
int
fOldParser
,
int
fPrintTree
);
extern
Wlc_Ntk_t
*
Wlc_ReadSmt
(
char
*
pFileName
,
int
fOldParser
,
int
fPrintTree
);
/*=== wlcSim.c ========================================================*/
extern
Vec_Ptr_t
*
Wlc_NtkSimulate
(
Wlc_Ntk_t
*
p
,
Vec_Int_t
*
vNodes
,
int
nWords
,
int
nFrames
);
extern
void
Wlc_NtkDeleteSim
(
Vec_Ptr_t
*
p
);
...
...
src/base/wlc/wlcBlast.c
View file @
0f29f0ae
...
...
@@ -777,7 +777,9 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple
// blast in the topological order
Wlc_NtkForEachObj
(
p
,
pObj
,
i
)
{
// char * pName = Wlc_ObjName(p, i);
// char * pName1 = Wlc_ObjName(p, i);
// char * pName2 = Wlc_ObjFaninNum(pObj) ? Wlc_ObjName(p, Wlc_ObjFaninId0(pObj)) : NULL;
nAndPrev
=
Gia_ManAndNum
(
pNew
);
nRange
=
Wlc_ObjRange
(
pObj
);
nRange0
=
Wlc_ObjFaninNum
(
pObj
)
>
0
?
Wlc_ObjRange
(
Wlc_ObjFanin0
(
p
,
pObj
)
)
:
-
1
;
...
...
@@ -1007,7 +1009,7 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple
else
if
(
pObj
->
Type
==
WLC_OBJ_BIT_ZEROPAD
||
pObj
->
Type
==
WLC_OBJ_BIT_SIGNEXT
)
{
int
Pad
=
pObj
->
Type
==
WLC_OBJ_BIT_ZEROPAD
?
0
:
pFans0
[
nRange0
-
1
];
assert
(
nRange0
<
nRange
);
assert
(
nRange0
<
=
nRange
);
for
(
k
=
0
;
k
<
nRange0
;
k
++
)
Vec_IntPush
(
vRes
,
pFans0
[
k
]
);
for
(
;
k
<
nRange
;
k
++
)
...
...
@@ -1020,6 +1022,14 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple
for
(
k
=
1
;
k
<
nRange
;
k
++
)
Vec_IntPush
(
vRes
,
0
);
}
else
if
(
pObj
->
Type
==
WLC_OBJ_LOGIC_IMPL
)
{
int
iLit0
=
Wlc_BlastReduction
(
pNew
,
pFans0
,
nRange0
,
WLC_OBJ_REDUCT_OR
);
int
iLit1
=
Wlc_BlastReduction
(
pNew
,
pFans1
,
nRange1
,
WLC_OBJ_REDUCT_OR
);
Vec_IntFill
(
vRes
,
1
,
Gia_ManHashOr
(
pNew
,
Abc_LitNot
(
iLit0
),
iLit1
)
);
for
(
k
=
1
;
k
<
nRange
;
k
++
)
Vec_IntPush
(
vRes
,
0
);
}
else
if
(
pObj
->
Type
==
WLC_OBJ_LOGIC_AND
)
{
int
iLit0
=
Wlc_BlastReduction
(
pNew
,
pFans0
,
nRange0
,
WLC_OBJ_REDUCT_OR
);
...
...
src/base/wlc/wlcCom.c
View file @
0f29f0ae
...
...
@@ -119,12 +119,20 @@ int Abc_CommandReadWlc( Abc_Frame_t * pAbc, int argc, char ** argv )
FILE
*
pFile
;
Wlc_Ntk_t
*
pNtk
=
NULL
;
char
*
pFileName
=
NULL
;
int
fOldParser
=
0
;
int
fPrintTree
=
0
;
int
c
,
fVerbose
=
0
;
Extra_UtilGetoptReset
();
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"vh"
)
)
!=
EOF
)
while
(
(
c
=
Extra_UtilGetopt
(
argc
,
argv
,
"
op
vh"
)
)
!=
EOF
)
{
switch
(
c
)
{
case
'o'
:
fPrintTree
^=
1
;
break
;
case
'p'
:
fOldParser
^=
1
;
break
;
case
'v'
:
fVerbose
^=
1
;
break
;
...
...
@@ -155,7 +163,7 @@ int Abc_CommandReadWlc( Abc_Frame_t * pAbc, int argc, char ** argv )
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"v"
)
)
pNtk
=
Wlc_ReadVer
(
pFileName
);
else
if
(
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"smt"
)
||
!
strcmp
(
Extra_FileNameExtension
(
pFileName
),
"smt2"
)
)
pNtk
=
Wlc_ReadSmt
(
pFileName
);
pNtk
=
Wlc_ReadSmt
(
pFileName
,
fOldParser
,
fPrintTree
);
else
{
printf
(
"Abc_CommandReadWlc(): Unknown file extension.
\n
"
);
...
...
@@ -164,8 +172,10 @@ int Abc_CommandReadWlc( Abc_Frame_t * pAbc, int argc, char ** argv )
Wlc_AbcUpdateNtk
(
pAbc
,
pNtk
);
return
0
;
usage:
Abc_Print
(
-
2
,
"usage: %%read [-vh] <file_name>
\n
"
);
Abc_Print
(
-
2
,
"usage: %%read [-
op
vh] <file_name>
\n
"
);
Abc_Print
(
-
2
,
"
\t
reads word-level design from Verilog file
\n
"
);
Abc_Print
(
-
2
,
"
\t
-o : toggle using old SMT-LIB parser [default = %s]
\n
"
,
fOldParser
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-p : toggle printing parse SMT-LIB tree [default = %s]
\n
"
,
fPrintTree
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-v : toggle printing verbose information [default = %s]
\n
"
,
fVerbose
?
"yes"
:
"no"
);
Abc_Print
(
-
2
,
"
\t
-h : print the command usage
\n
"
);
return
1
;
...
...
src/base/wlc/wlcNtk.c
View file @
0f29f0ae
...
...
@@ -50,40 +50,41 @@ static char * Wlc_Names[WLC_OBJ_NUMBER+1] = {
"&"
,
// 16: bitwise AND
"|"
,
// 17: bitwise OR
"^"
,
// 18: bitwise XOR
"~&"
,
// 16: bitwise NAND
"~|"
,
// 17: bitwise NOR
"~^"
,
// 19: bitwise NXOR
"[:]"
,
// 20: bit selection
"{,}"
,
// 21: bit concatenation
"zeroPad"
,
// 22: zero padding
"signExt"
,
// 23: sign extension
"!"
,
// 24: logic NOT
"&&"
,
// 25: logic AND
"||"
,
// 27: logic OR
"^^"
,
// 28: logic XOR
"=="
,
// 29: compare equal
"!="
,
// 30: compare not equal
"<"
,
// 31: compare less
">"
,
// 32: compare more
"<="
,
// 33: compare less or equal
">="
,
// 34: compare more or equal
"&"
,
// 35: reduction AND
"|"
,
// 36: reduction OR
"^"
,
// 37: reduction XOR
"~&"
,
// 38: reduction NAND
"~|"
,
// 39: reduction NOR
"~^"
,
// 40: reduction NXOR
"+"
,
// 41: arithmetic addition
"-"
,
// 42: arithmetic subtraction
"*"
,
// 43: arithmetic multiplier
"/"
,
// 44: arithmetic division
"%"
,
// 45: arithmetic modulus
"**"
,
// 46: arithmetic power
"-"
,
// 47: arithmetic minus
"sqrt"
,
// 48: integer square root
"square"
,
// 49: integer square
"table"
,
// 50: bit table
NULL
// 51: unused
"~&"
,
// 19: bitwise NAND
"~|"
,
// 20: bitwise NOR
"~^"
,
// 21: bitwise NXOR
"[:]"
,
// 22: bit selection
"{,}"
,
// 23: bit concatenation
"zeroPad"
,
// 24: zero padding
"signExt"
,
// 25: sign extension
"!"
,
// 26: logic NOT
"=>"
,
// 27: logic implication
"&&"
,
// 28: logic AND
"||"
,
// 29: logic OR
"^^"
,
// 30: logic XOR
"=="
,
// 31: compare equal
"!="
,
// 32: compare not equal
"<"
,
// 33: compare less
">"
,
// 34: compare more
"<="
,
// 35: compare less or equal
">="
,
// 36: compare more or equal
"&"
,
// 37: reduction AND
"|"
,
// 38: reduction OR
"^"
,
// 39: reduction XOR
"~&"
,
// 40: reduction NAND
"~|"
,
// 41: reduction NOR
"~^"
,
// 42: reduction NXOR
"+"
,
// 43: arithmetic addition
"-"
,
// 44: arithmetic subtraction
"*"
,
// 45: arithmetic multiplier
"/"
,
// 46: arithmetic division
"%"
,
// 47: arithmetic modulus
"**"
,
// 48: arithmetic power
"-"
,
// 49: arithmetic minus
"sqrt"
,
// 50: integer square root
"square"
,
// 51: integer square
"table"
,
// 52: bit table
NULL
// 53: unused
};
////////////////////////////////////////////////////////////////////////
...
...
@@ -380,6 +381,8 @@ void Wlc_NtkPrintDistrib( Wlc_Ntk_t * p, int fVerbose )
Vec_IntAddToEntry
(
vAnds
,
WLC_OBJ_BIT_SIGNEXT
,
0
);
else
if
(
pObj
->
Type
==
WLC_OBJ_LOGIC_NOT
)
Vec_IntAddToEntry
(
vAnds
,
WLC_OBJ_LOGIC_NOT
,
Wlc_ObjRange
(
Wlc_ObjFanin0
(
p
,
pObj
))
-
1
);
else
if
(
pObj
->
Type
==
WLC_OBJ_LOGIC_IMPL
)
Vec_IntAddToEntry
(
vAnds
,
WLC_OBJ_LOGIC_IMPL
,
Wlc_ObjRange
(
Wlc_ObjFanin0
(
p
,
pObj
))
+
Wlc_ObjRange
(
Wlc_ObjFanin1
(
p
,
pObj
))
-
1
);
else
if
(
pObj
->
Type
==
WLC_OBJ_LOGIC_AND
)
Vec_IntAddToEntry
(
vAnds
,
WLC_OBJ_LOGIC_AND
,
Wlc_ObjRange
(
Wlc_ObjFanin0
(
p
,
pObj
))
+
Wlc_ObjRange
(
Wlc_ObjFanin1
(
p
,
pObj
))
-
1
);
else
if
(
pObj
->
Type
==
WLC_OBJ_LOGIC_OR
)
...
...
src/base/wlc/wlcReadSmt.c
View file @
0f29f0ae
This diff is collapsed.
Click to expand it.
src/base/wlc/wlcReadVer.c
View file @
0f29f0ae
...
...
@@ -781,6 +781,7 @@ static inline int Wlc_PrsFindDefinition( Wlc_Prs_t * p, char * pStr, Vec_Int_t *
else
if
(
pStr
[
0
]
==
'~'
&&
pStr
[
1
]
==
'&'
)
pStr
+=
2
,
Type
=
WLC_OBJ_BIT_NAND
;
else
if
(
pStr
[
0
]
==
'~'
&&
pStr
[
1
]
==
'|'
)
pStr
+=
2
,
Type
=
WLC_OBJ_BIT_NOR
;
else
if
(
pStr
[
0
]
==
'~'
&&
pStr
[
1
]
==
'^'
)
pStr
+=
2
,
Type
=
WLC_OBJ_BIT_NXOR
;
else
if
(
pStr
[
0
]
==
'='
&&
pStr
[
1
]
==
'>'
)
pStr
+=
2
,
Type
=
WLC_OBJ_LOGIC_IMPL
;
else
if
(
pStr
[
0
]
==
'&'
&&
pStr
[
1
]
==
'&'
)
pStr
+=
2
,
Type
=
WLC_OBJ_LOGIC_AND
;
else
if
(
pStr
[
0
]
==
'|'
&&
pStr
[
1
]
==
'|'
)
pStr
+=
2
,
Type
=
WLC_OBJ_LOGIC_OR
;
else
if
(
pStr
[
0
]
==
'^'
&&
pStr
[
1
]
==
'^'
)
pStr
+=
2
,
Type
=
WLC_OBJ_LOGIC_XOR
;
...
...
src/base/wlc/wlcStdin.c
View file @
0f29f0ae
...
...
@@ -192,7 +192,7 @@ int Wlc_StdinProcessSmt( Abc_Frame_t * pAbc, char * pCmd )
// collect stdin until (check-sat)
Vec_Str_t
*
vInput
=
Wlc_StdinCollectProblem
(
"(check-sat)"
);
// parse input
Wlc_Ntk_t
*
pNtk
=
Wlc_ReadSmtBuffer
(
NULL
,
Vec_StrArray
(
vInput
),
Vec_StrArray
(
vInput
)
+
Vec_StrSize
(
vInput
)
);
Wlc_Ntk_t
*
pNtk
=
Wlc_ReadSmtBuffer
(
NULL
,
Vec_StrArray
(
vInput
),
Vec_StrArray
(
vInput
)
+
Vec_StrSize
(
vInput
)
,
0
,
0
);
Vec_StrFree
(
vInput
);
// install current network
Wlc_SetNtk
(
pAbc
,
pNtk
);
...
...
src/base/wlc/wlcWriteVer.c
View file @
0f29f0ae
...
...
@@ -314,6 +314,8 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p, int fNoFlops )
fprintf
(
pFile
,
"~|"
);
else
if
(
pObj
->
Type
==
WLC_OBJ_BIT_NXOR
)
fprintf
(
pFile
,
"~^"
);
else
if
(
pObj
->
Type
==
WLC_OBJ_LOGIC_IMPL
)
fprintf
(
pFile
,
"=>"
);
else
if
(
pObj
->
Type
==
WLC_OBJ_LOGIC_AND
)
fprintf
(
pFile
,
"&&"
);
else
if
(
pObj
->
Type
==
WLC_OBJ_LOGIC_OR
)
...
...
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