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
ffd77ffe
Commit
ffd77ffe
authored
Sep 17, 2014
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improvements to word-level Verilog parser.
parent
43ee0cff
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
168 additions
and
73 deletions
+168
-73
src/base/wlc/wlc.h
+35
-32
src/base/wlc/wlcBlast.c
+0
-0
src/base/wlc/wlcNtk.c
+31
-28
src/base/wlc/wlcReadVer.c
+17
-10
src/base/wlc/wlcWriteVer.c
+85
-3
No files found.
src/base/wlc/wlc.h
View file @
ffd77ffe
...
...
@@ -42,8 +42,8 @@ ABC_NAMESPACE_HEADER_START
// object types
typedef
enum
{
WLC_OBJ_NONE
=
0
,
// 00: unknown
WLC_OBJ_PI
,
// 01: primary input
terminal
WLC_OBJ_PO
,
// 02: primary output
terminal
WLC_OBJ_PI
,
// 01: primary input
WLC_OBJ_PO
,
// 02: primary output
WLC_OBJ_BO
,
// 03: box output
WLC_OBJ_BI
,
// 04: box input
WLC_OBJ_FF
,
// 05: flop
...
...
@@ -54,34 +54,37 @@ typedef enum {
WLC_OBJ_SHIFT_RA
,
// 10: shift right (arithmetic)
WLC_OBJ_SHIFT_L
,
// 11: shift left
WLC_OBJ_SHIFT_LA
,
// 12: shift left (arithmetic)
WLC_OBJ_BIT_NOT
,
// 13: bitwise NOT
WLC_OBJ_BIT_AND
,
// 14: bitwise AND
WLC_OBJ_BIT_OR
,
// 15: bitwise OR
WLC_OBJ_BIT_XOR
,
// 16: bitwise XOR
WLC_OBJ_BIT_SELECT
,
// 17: bit selection
WLC_OBJ_BIT_CONCAT
,
// 18: bit concatenation
WLC_OBJ_BIT_ZEROPAD
,
// 19: zero padding
WLC_OBJ_BIT_SIGNEXT
,
// 20: sign extension
WLC_OBJ_LOGIC_NOT
,
// 21: logic NOT
WLC_OBJ_LOGIC_AND
,
// 22: logic AND
WLC_OBJ_LOGIC_OR
,
// 23: logic OR
WLC_OBJ_COMP_EQU
,
// 24: compare equal
WLC_OBJ_COMP_NOT
,
// 25: compare not equal
WLC_OBJ_COMP_LESS
,
// 26: compare less
WLC_OBJ_COMP_MORE
,
// 27: compare more
WLC_OBJ_COMP_LESSEQU
,
// 28: compare less or equal
WLC_OBJ_COMP_MOREEQU
,
// 29: compare more or equal
WLC_OBJ_REDUCT_AND
,
// 30: reduction AND
WLC_OBJ_REDUCT_OR
,
// 31: reduction OR
WLC_OBJ_REDUCT_XOR
,
// 32: reduction XOR
WLC_OBJ_ARI_ADD
,
// 33: arithmetic addition
WLC_OBJ_ARI_SUB
,
// 34: arithmetic subtraction
WLC_OBJ_ARI_MULTI
,
// 35: arithmetic multiplier
WLC_OBJ_ARI_DIVIDE
,
// 36: arithmetic division
WLC_OBJ_ARI_MODULUS
,
// 37: arithmetic modulus
WLC_OBJ_ARI_POWER
,
// 38: arithmetic power
WLC_OBJ_TABLE
,
// 39: arithmetic power
WLC_OBJ_NUMBER
// 40: unused
WLC_OBJ_ROTATE_R
,
// 13: rotate right
WLC_OBJ_ROTATE_L
,
// 14: rotate left
WLC_OBJ_BIT_NOT
,
// 15: bitwise NOT
WLC_OBJ_BIT_AND
,
// 16: bitwise AND
WLC_OBJ_BIT_OR
,
// 17: bitwise OR
WLC_OBJ_BIT_XOR
,
// 18: bitwise XOR
WLC_OBJ_BIT_SELECT
,
// 19: bit selection
WLC_OBJ_BIT_CONCAT
,
// 20: bit concatenation
WLC_OBJ_BIT_ZEROPAD
,
// 21: zero padding
WLC_OBJ_BIT_SIGNEXT
,
// 22: sign extension
WLC_OBJ_LOGIC_NOT
,
// 23: logic NOT
WLC_OBJ_LOGIC_AND
,
// 24: logic AND
WLC_OBJ_LOGIC_OR
,
// 25: logic OR
WLC_OBJ_COMP_EQU
,
// 26: compare equal
WLC_OBJ_COMP_NOTEQU
,
// 27: compare not equal
WLC_OBJ_COMP_LESS
,
// 28: compare less
WLC_OBJ_COMP_MORE
,
// 29: compare more
WLC_OBJ_COMP_LESSEQU
,
// 30: compare less or equal
WLC_OBJ_COMP_MOREEQU
,
// 31: compare more or equal
WLC_OBJ_REDUCT_AND
,
// 32: reduction AND
WLC_OBJ_REDUCT_OR
,
// 33: reduction OR
WLC_OBJ_REDUCT_XOR
,
// 34: reduction XOR
WLC_OBJ_ARI_ADD
,
// 35: arithmetic addition
WLC_OBJ_ARI_SUB
,
// 36: arithmetic subtraction
WLC_OBJ_ARI_MULTI
,
// 37: arithmetic multiplier
WLC_OBJ_ARI_DIVIDE
,
// 38: arithmetic division
WLC_OBJ_ARI_MODULUS
,
// 39: arithmetic modulus
WLC_OBJ_ARI_POWER
,
// 40: arithmetic power
WLC_OBJ_ARI_MINUS
,
// 41: arithmetic minus
WLC_OBJ_TABLE
,
// 42: bit table
WLC_OBJ_NUMBER
// 43: unused
}
Wlc_ObjType_t
;
...
...
@@ -89,9 +92,7 @@ typedef enum {
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
typedef
struct
Wlc_Ntk_t_
Wlc_Ntk_t
;
typedef
struct
Wlc_Obj_t_
Wlc_Obj_t
;
struct
Wlc_Obj_t_
// 16 bytes
{
unsigned
Type
:
6
;
// node type
...
...
@@ -104,6 +105,7 @@ struct Wlc_Obj_t_ // 16 bytes
int
*
pFanins
[
1
];
};
};
typedef
struct
Wlc_Ntk_t_
Wlc_Ntk_t
;
struct
Wlc_Ntk_t_
{
char
*
pName
;
// model name
...
...
@@ -163,6 +165,7 @@ static inline int Wlc_ObjRangeEnd( Wlc_Obj_t * p )
static
inline
int
Wlc_ObjRangeBeg
(
Wlc_Obj_t
*
p
)
{
assert
(
p
->
Type
==
WLC_OBJ_BIT_SELECT
);
return
p
->
Fanins
[
1
]
&
0xFFFF
;
}
static
inline
int
*
Wlc_ObjConstValue
(
Wlc_Obj_t
*
p
)
{
assert
(
p
->
Type
==
WLC_OBJ_CONST
);
return
Wlc_ObjFanins
(
p
);
}
static
inline
int
Wlc_ObjTableId
(
Wlc_Obj_t
*
p
)
{
assert
(
p
->
Type
==
WLC_OBJ_TABLE
);
return
p
->
Fanins
[
1
];
}
static
inline
word
*
Wlc_ObjTable
(
Wlc_Ntk_t
*
p
,
Wlc_Obj_t
*
pObj
)
{
return
(
word
*
)
Vec_PtrEntry
(
p
->
vTables
,
Wlc_ObjTableId
(
pObj
)
);
}
static
inline
void
Wlc_NtkCleanCopy
(
Wlc_Ntk_t
*
p
)
{
Vec_IntFill
(
&
p
->
vCopies
,
p
->
nObjsAlloc
,
0
);
}
static
inline
int
Wlc_NtkHasCopy
(
Wlc_Ntk_t
*
p
)
{
return
Vec_IntSize
(
&
p
->
vCopies
)
>
0
;
}
...
...
src/base/wlc/wlcBlast.c
View file @
ffd77ffe
This diff is collapsed.
Click to expand it.
src/base/wlc/wlcNtk.c
View file @
ffd77ffe
...
...
@@ -42,34 +42,37 @@ static char * Wlc_Names[WLC_OBJ_NUMBER+1] = {
">>>"
,
// 10: shift right (arithmetic)
"<<"
,
// 11: shift left
"<<<"
,
// 12: shift left (arithmetic)
"~"
,
// 13: bitwise NOT
"&"
,
// 14: bitwise AND
"|"
,
// 15: bitwise OR
"^"
,
// 16: bitwise XOR
"[:]"
,
// 17: bit selection
"{,}"
,
// 18: bit concatenation
"BitPad"
,
// 19: zero padding
"SgnExt"
,
// 20: sign extension
"!"
,
// 21: logic NOT
"&&"
,
// 22: logic AND
"||"
,
// 23: logic OR
"=="
,
// 24: compare equal
"!="
,
// 25: compare not equal
"<"
,
// 26: compare less
">"
,
// 27: compare more
"<="
,
// 28: compare less or equal
">="
,
// 29: compare more or equal
"&"
,
// 30: reduction AND
"|"
,
// 31: reduction OR
"^"
,
// 32: reduction XOR
"+"
,
// 33: arithmetic addition
"-"
,
// 34: arithmetic subtraction
"*"
,
// 35: arithmetic multiplier
"//"
,
// 36: arithmetic division
"%%"
,
// 37: arithmetic modulus
"**"
,
// 38: arithmetic power
"table"
,
// 39: lookup table
NULL
// 40: unused
"rotateR"
,
// 13: shift left (arithmetic)
"rotateL"
,
// 14: shift left (arithmetic)
"~"
,
// 15: bitwise NOT
"&"
,
// 16: bitwise AND
"|"
,
// 17: bitwise OR
"^"
,
// 18: bitwise XOR
"[:]"
,
// 19: bit selection
"{,}"
,
// 20: bit concatenation
"bitPad"
,
// 21: zero padding
"signExtend"
,
// 22: sign extension
"!"
,
// 23: logic NOT
"&&"
,
// 24: logic AND
"||"
,
// 25: logic OR
"=="
,
// 26: compare equal
"!="
,
// 27: compare not equal
"<"
,
// 28: compare less
">"
,
// 29: compare more
"<="
,
// 30: compare less or equal
">="
,
// 31: compare more or equal
"&"
,
// 32: reduction AND
"|"
,
// 33: reduction OR
"^"
,
// 34: reduction XOR
"+"
,
// 35: arithmetic addition
"-"
,
// 36: arithmetic subtraction
"*"
,
// 37: arithmetic multiplier
"//"
,
// 38: arithmetic division
"%%"
,
// 39: arithmetic modulus
"**"
,
// 40: arithmetic power
"-"
,
// 41: arithmetic minus
"table"
,
// 42: bit table
NULL
// 43: unused
};
////////////////////////////////////////////////////////////////////////
...
...
src/base/wlc/wlcReadVer.c
View file @
ffd77ffe
...
...
@@ -409,6 +409,7 @@ static inline char * Wlc_PrsReadConstant( Wlc_Prs_t * p, char * pStr, Vec_Int_t
*
pRange
=
Abc_Base2Log
(
Number
);
while
(
Wlc_PrsIsDigit
(
pStr
)
)
pStr
++
;
Vec_IntFill
(
vFanins
,
1
,
Number
);
return
pStr
;
}
pStr
=
Wlc_PrsFindSymbol
(
pStr
,
'\''
);
...
...
@@ -424,7 +425,7 @@ static inline char * Wlc_PrsReadConstant( Wlc_Prs_t * p, char * pStr, Vec_Int_t
if
(
nDigits
!=
(
nBits
+
3
)
/
4
)
{
// return (char *)(ABC_PTRINT_T)Wlc_PrsWriteErrorMessage( p, pStr, "The length of a constant does not match." );
printf
(
"Warning: The length of a constant (%d hex digits) does not match the number of bits (%d).
\n
"
,
nDigits
,
nBits
);
//
printf( "Warning: The length of a constant (%d hex digits) does not match the number of bits (%d).\n", nDigits, nBits );
}
*
pRange
=
nBits
;
pStr
+=
2
;
...
...
@@ -452,7 +453,7 @@ static inline char * Wlc_PrsReadName( Wlc_Prs_t * p, char * pStr, Vec_Int_t * vF
Wlc_ObjAddFanins
(
p
->
pNtk
,
Wlc_NtkObj
(
p
->
pNtk
,
iObj
),
vFanins
);
Vec_IntFree
(
vFanins
);
// add node's name
sprintf
(
Buffer
,
"
const%d
"
,
p
->
nConsts
++
);
sprintf
(
Buffer
,
"
_c%d_
"
,
p
->
nConsts
++
);
NameId
=
Abc_NamStrFindOrAdd
(
p
->
pNtk
->
pManName
,
Buffer
,
&
fFound
);
if
(
fFound
)
return
(
char
*
)(
ABC_PTRINT_T
)
Wlc_PrsWriteErrorMessage
(
p
,
pStr
,
"Name %s is already used."
,
Buffer
);
...
...
@@ -530,7 +531,7 @@ static inline int Wlc_PrsFindDefinition( Wlc_Prs_t * p, char * pStr, Vec_Int_t *
if
(
!
(
pStr
=
Wlc_PrsReadName
(
p
,
pStr
,
vFanins
))
)
return
Wlc_PrsWriteErrorMessage
(
p
,
pStr
,
"Cannot read name after !."
);
}
else
if
(
pStr
[
0
]
==
'&'
||
pStr
[
0
]
==
'|'
||
pStr
[
0
]
==
'^'
)
else
if
(
pStr
[
0
]
==
'&'
||
pStr
[
0
]
==
'|'
||
pStr
[
0
]
==
'^'
||
pStr
[
0
]
==
'-'
)
{
if
(
pStr
[
0
]
==
'&'
)
Type
=
WLC_OBJ_REDUCT_AND
;
...
...
@@ -538,9 +539,11 @@ static inline int Wlc_PrsFindDefinition( Wlc_Prs_t * p, char * pStr, Vec_Int_t *
Type
=
WLC_OBJ_REDUCT_OR
;
else
if
(
pStr
[
0
]
==
'^'
)
Type
=
WLC_OBJ_REDUCT_XOR
;
else
if
(
pStr
[
0
]
==
'-'
)
Type
=
WLC_OBJ_ARI_MINUS
;
else
assert
(
0
);
if
(
!
(
pStr
=
Wlc_PrsReadName
(
p
,
pStr
+
1
,
vFanins
))
)
return
Wlc_PrsWriteErrorMessage
(
p
,
pStr
,
"Cannot read name after
reduction
operator."
);
return
Wlc_PrsWriteErrorMessage
(
p
,
pStr
,
"Cannot read name after
a unary
operator."
);
}
else
if
(
pStr
[
0
]
==
'{'
)
{
...
...
@@ -603,9 +606,9 @@ static inline int Wlc_PrsFindDefinition( Wlc_Prs_t * p, char * pStr, Vec_Int_t *
}
else
{
if
(
pStr
[
0
]
==
'>'
&&
pStr
[
1
]
==
'>'
&&
pStr
[
2
]
!=
'>'
)
pStr
+=
2
,
Type
=
WLC_OBJ_SHIFT_R
;
if
(
pStr
[
0
]
==
'>'
&&
pStr
[
1
]
==
'>'
&&
pStr
[
2
]
!=
'>'
)
pStr
+=
2
,
Type
=
fRotating
?
WLC_OBJ_ROTATE_R
:
WLC_OBJ_SHIFT_R
;
else
if
(
pStr
[
0
]
==
'>'
&&
pStr
[
1
]
==
'>'
&&
pStr
[
2
]
==
'>'
)
pStr
+=
3
,
Type
=
WLC_OBJ_SHIFT_RA
;
else
if
(
pStr
[
0
]
==
'<'
&&
pStr
[
1
]
==
'<'
&&
pStr
[
2
]
!=
'<'
)
pStr
+=
2
,
Type
=
WLC_OBJ_SHIFT_L
;
else
if
(
pStr
[
0
]
==
'<'
&&
pStr
[
1
]
==
'<'
&&
pStr
[
2
]
!=
'<'
)
pStr
+=
2
,
Type
=
fRotating
?
WLC_OBJ_ROTATE_L
:
WLC_OBJ_SHIFT_L
;
else
if
(
pStr
[
0
]
==
'<'
&&
pStr
[
1
]
==
'<'
&&
pStr
[
2
]
==
'<'
)
pStr
+=
3
,
Type
=
WLC_OBJ_SHIFT_LA
;
else
if
(
pStr
[
0
]
==
'&'
&&
pStr
[
1
]
!=
'&'
)
pStr
+=
1
,
Type
=
WLC_OBJ_BIT_AND
;
else
if
(
pStr
[
0
]
==
'|'
&&
pStr
[
1
]
!=
'|'
)
pStr
+=
1
,
Type
=
WLC_OBJ_BIT_OR
;
...
...
@@ -613,7 +616,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_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_COMP_EQU
;
else
if
(
pStr
[
0
]
==
'!'
&&
pStr
[
1
]
==
'='
)
pStr
+=
2
,
Type
=
WLC_OBJ_COMP_NOT
;
else
if
(
pStr
[
0
]
==
'!'
&&
pStr
[
1
]
==
'='
)
pStr
+=
2
,
Type
=
WLC_OBJ_COMP_NOT
EQU
;
else
if
(
pStr
[
0
]
==
'<'
&&
pStr
[
1
]
!=
'='
)
pStr
+=
1
,
Type
=
WLC_OBJ_COMP_LESS
;
else
if
(
pStr
[
0
]
==
'>'
&&
pStr
[
1
]
!=
'='
)
pStr
+=
1
,
Type
=
WLC_OBJ_COMP_MORE
;
else
if
(
pStr
[
0
]
==
'<'
&&
pStr
[
1
]
==
'='
)
pStr
+=
2
,
Type
=
WLC_OBJ_COMP_LESSEQU
;
...
...
@@ -702,6 +705,7 @@ int Wlc_PrsDerive( Wlc_Prs_t * p )
if
(
Wlc_PrsStrCmp
(
pName
,
"table"
)
)
{
// THIS IS A HACK TO DETECT tables
int
Width1
,
Width2
;
int
v
,
b
,
Value
,
nBits
,
nInts
,
*
pTable
;
Vec_Int_t
*
vValues
=
Vec_IntAlloc
(
256
);
Wlc_PrsForEachLineStart
(
p
,
pStart
,
i
,
i
+
1
)
...
...
@@ -711,9 +715,11 @@ int Wlc_PrsDerive( Wlc_Prs_t * p )
pStart
=
Wlc_PrsFindSymbol
(
pStart
,
'\''
);
if
(
pStart
==
NULL
)
continue
;
Width1
=
atoi
(
pStart
-
1
);
pStart
=
Wlc_PrsFindSymbol
(
pStart
+
2
,
'\''
);
if
(
pStart
==
NULL
)
continue
;
Width2
=
atoi
(
pStart
-
1
);
Value
=
0
;
Abc_TtReadHexNumber
(
(
word
*
)
&
Value
,
pStart
+
2
);
Vec_IntPush
(
vValues
,
Value
);
...
...
@@ -725,14 +731,15 @@ int Wlc_PrsDerive( Wlc_Prs_t * p )
Vec_IntFree
(
vValues
);
return
Wlc_PrsWriteErrorMessage
(
p
,
pStart
,
"Cannot read module
\"
%s
\"
."
,
pName
);
}
assert
(
Width1
==
nBits
);
// create bitmap
nInts
=
Abc_BitWordNum
(
nBits
*
Vec_IntSize
(
vValues
)
);
nInts
=
Abc_BitWordNum
(
Width2
*
Vec_IntSize
(
vValues
)
);
pTable
=
(
unsigned
*
)
Mem_FlexEntryFetch
(
p
->
pMemTable
,
nInts
*
sizeof
(
unsigned
)
);
memset
(
pTable
,
0
,
nInts
*
sizeof
(
unsigned
)
);
Vec_IntForEachEntry
(
vValues
,
Value
,
v
)
for
(
b
=
0
;
b
<
nBits
;
b
++
)
for
(
b
=
0
;
b
<
Width2
;
b
++
)
if
(
(
Value
>>
b
)
&
1
)
Abc_InfoSetBit
(
pTable
,
v
*
nBits
+
b
);
Abc_InfoSetBit
(
pTable
,
v
*
Width2
+
b
);
Vec_PtrPush
(
p
->
vTables
,
pTable
);
Vec_IntFree
(
vValues
);
continue
;
...
...
src/base/wlc/wlcWriteVer.c
View file @
ffd77ffe
...
...
@@ -42,6 +42,60 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
void
Wlc_WriteTableOne
(
FILE
*
pFile
,
int
nFans
,
int
nOuts
,
word
*
pTable
,
int
Id
)
{
int
m
,
nMints
=
(
1
<<
nFans
);
// Abc_TtPrintHexArrayRev( stdout, pTable, nMints ); printf( "\n" );
assert
(
nOuts
>
0
&&
nOuts
<=
64
&&
(
64
%
nOuts
)
==
0
);
fprintf
(
pFile
,
"module table%d(ind, val);
\n
"
,
Id
);
fprintf
(
pFile
,
" input [%d:0] ind;
\n
"
,
nFans
-
1
);
fprintf
(
pFile
,
" output [%d:0] val;
\n
"
,
nOuts
-
1
);
fprintf
(
pFile
,
" reg [%d:0] val;
\n
"
,
nOuts
-
1
);
fprintf
(
pFile
,
" always @(ind)
\n
"
);
fprintf
(
pFile
,
" begin
\n
"
);
fprintf
(
pFile
,
" case (ind)
\n
"
);
for
(
m
=
0
;
m
<
nMints
;
m
++
)
fprintf
(
pFile
,
" %d
\'
h%x: val = %d
\'
h%x;
\n
"
,
nFans
,
m
,
nOuts
,
(
pTable
[(
nOuts
*
m
)
>>
6
]
>>
((
nOuts
*
m
)
&
63
))
&
Abc_Tt6Mask
(
nOuts
)
);
fprintf
(
pFile
,
" endcase
\n
"
);
fprintf
(
pFile
,
" end
\n
"
);
fprintf
(
pFile
,
"endmodule
\n
"
);
fprintf
(
pFile
,
"
\n
"
);
}
void
Wlc_WriteTables
(
FILE
*
pFile
,
Wlc_Ntk_t
*
p
)
{
Vec_Int_t
*
vNodes
;
Wlc_Obj_t
*
pObj
,
*
pFanin
;
word
*
pTable
;
int
i
;
if
(
p
->
vTables
==
NULL
||
Vec_PtrSize
(
p
->
vTables
)
==
0
)
return
;
// map tables into their nodes
vNodes
=
Vec_IntStart
(
Vec_PtrSize
(
p
->
vTables
)
);
Wlc_NtkForEachObj
(
p
,
pObj
,
i
)
if
(
pObj
->
Type
==
WLC_OBJ_TABLE
)
Vec_IntWriteEntry
(
vNodes
,
Wlc_ObjTableId
(
pObj
),
i
);
// write tables
Vec_PtrForEachEntry
(
word
*
,
p
->
vTables
,
pTable
,
i
)
{
pObj
=
Wlc_NtkObj
(
p
,
Vec_IntEntry
(
vNodes
,
i
)
);
assert
(
pObj
->
Type
==
WLC_OBJ_TABLE
);
pFanin
=
Wlc_ObjFanin0
(
p
,
pObj
);
Wlc_WriteTableOne
(
pFile
,
Wlc_ObjRange
(
pFanin
),
Wlc_ObjRange
(
pObj
),
pTable
,
i
);
}
Vec_IntFree
(
vNodes
);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void
Wlc_WriteVerIntVec
(
FILE
*
pFile
,
Wlc_Ntk_t
*
p
,
Vec_Int_t
*
vVec
,
int
Start
)
{
char
*
pName
;
...
...
@@ -80,23 +134,50 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p )
if
(
Wlc_NtkPoNum
(
p
)
>
0
)
Wlc_WriteVerIntVec
(
pFile
,
p
,
&
p
->
vPos
,
3
);
fprintf
(
pFile
,
" );
\n
"
);
// mark fanins of rotation shifts
Wlc_NtkForEachObj
(
p
,
pObj
,
i
)
if
(
pObj
->
Type
==
WLC_OBJ_ROTATE_R
||
pObj
->
Type
==
WLC_OBJ_ROTATE_L
)
Wlc_ObjFanin1
(
p
,
pObj
)
->
Mark
=
1
;
Wlc_NtkForEachObj
(
p
,
pObj
,
i
)
{
char
*
pName
=
Wlc_ObjName
(
p
,
i
);
char
*
pName0
=
Wlc_ObjFaninNum
(
pObj
)
?
Wlc_ObjName
(
p
,
Wlc_ObjFaninId0
(
pObj
))
:
NULL
;
int
nDigits
=
Abc_Base10Log
(
pObj
->
End
+
1
)
+
Abc_Base10Log
(
pObj
->
Beg
+
1
);
if
(
pObj
->
Mark
)
{
pObj
->
Mark
=
0
;
continue
;
}
sprintf
(
Range
,
"%s[%d:%d]%*s"
,
pObj
->
Signed
?
"signed "
:
" "
,
pObj
->
End
,
pObj
->
Beg
,
8
-
nDigits
,
""
);
fprintf
(
pFile
,
" "
);
assert
(
pObj
->
Type
!=
WLC_OBJ_TABLE
);
if
(
pObj
->
Type
==
WLC_OBJ_PI
)
fprintf
(
pFile
,
"input wire %s %
-16
s"
,
Range
,
pName
);
fprintf
(
pFile
,
"input wire %s %s"
,
Range
,
pName
);
else
if
(
pObj
->
Type
==
WLC_OBJ_PO
)
fprintf
(
pFile
,
"output wire %s %-16s = %s"
,
Range
,
pName
,
pName0
);
else
if
(
pObj
->
Type
==
WLC_OBJ_TABLE
)
{
// wire [3:0] s4972; table0 s4972_Index(s4971, s4972);
fprintf
(
pFile
,
" wire %s %s ; table%d s%d_Index(%s, %s)"
,
Range
,
pName
,
Wlc_ObjTableId
(
pObj
),
i
,
pName0
,
pName
);
}
else
if
(
pObj
->
Type
==
WLC_OBJ_CONST
)
{
fprintf
(
pFile
,
" wire %s %-16s = %d
\'
%sh"
,
Range
,
pName
,
Wlc_ObjRange
(
pObj
),
pObj
->
Signed
?
"s"
:
""
);
Abc_TtPrintHexArrayRev
(
pFile
,
(
word
*
)
Wlc_ObjConstValue
(
pObj
),
(
Wlc_ObjRange
(
pObj
)
+
3
)
/
4
);
}
else
if
(
pObj
->
Type
==
WLC_OBJ_ROTATE_R
||
pObj
->
Type
==
WLC_OBJ_ROTATE_L
)
{
// wire [27:0] s4960 = (s57 >> 17) | (s57 << 11);
Wlc_Obj_t
*
pShift
=
Wlc_ObjFanin1
(
p
,
pObj
);
int
Num0
=
*
Wlc_ObjConstValue
(
pShift
);
int
Num1
=
Wlc_ObjRange
(
pObj
)
-
Num0
;
assert
(
pShift
->
Type
==
WLC_OBJ_CONST
);
assert
(
Num0
>
0
&&
Num0
<
Wlc_ObjRange
(
pObj
)
);
fprintf
(
pFile
,
" wire %s %-16s = "
,
Range
,
Wlc_ObjName
(
p
,
i
)
);
if
(
pObj
->
Type
==
WLC_OBJ_ROTATE_R
)
fprintf
(
pFile
,
"(%s >> %d) | (%s << %d)"
,
pName0
,
Num0
,
pName0
,
Num1
);
else
fprintf
(
pFile
,
"(%s << %d) | (%s >> %d)"
,
pName0
,
Num0
,
pName0
,
Num1
);
}
else
{
fprintf
(
pFile
,
" wire %s %-16s = "
,
Range
,
Wlc_ObjName
(
p
,
i
)
);
...
...
@@ -150,7 +231,7 @@ void Wlc_WriteVerInt( FILE * pFile, Wlc_Ntk_t * p )
fprintf
(
pFile
,
"||"
);
else
if
(
pObj
->
Type
==
WLC_OBJ_COMP_EQU
)
fprintf
(
pFile
,
"=="
);
else
if
(
pObj
->
Type
==
WLC_OBJ_COMP_NOT
)
else
if
(
pObj
->
Type
==
WLC_OBJ_COMP_NOT
EQU
)
fprintf
(
pFile
,
"!="
);
else
if
(
pObj
->
Type
==
WLC_OBJ_COMP_LESS
)
fprintf
(
pFile
,
"<"
);
...
...
@@ -191,6 +272,7 @@ void Wlc_WriteVer( Wlc_Ntk_t * p, char * pFileName )
}
fprintf
(
pFile
,
"// Benchmark
\"
%s
\"
written by ABC on %s
\n
"
,
p
->
pName
,
Extra_TimeStamp
()
);
fprintf
(
pFile
,
"
\n
"
);
Wlc_WriteTables
(
pFile
,
p
);
Wlc_WriteVerInt
(
pFile
,
p
);
fprintf
(
pFile
,
"
\n
"
);
fclose
(
pFile
);
...
...
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