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
ddc574a9
Commit
ddc574a9
authored
Aug 05, 2021
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Supporting simple operators in NDR.
parent
ab29dad7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
13 deletions
+53
-13
src/aig/miniaig/abcOper.h
+20
-0
src/aig/miniaig/ndr.h
+29
-9
src/base/wlc/wlcNdr.c
+2
-2
src/base/wln/wlnNdr.c
+2
-2
No files found.
src/aig/miniaig/abcOper.h
View file @
ddc574a9
...
@@ -232,6 +232,26 @@ static inline const char * Abc_OperName( int Type )
...
@@ -232,6 +232,26 @@ static inline const char * Abc_OperName( int Type )
return
NULL
;
return
NULL
;
}
}
// printing operator types
static
inline
const
char
*
Abc_OperNameSimple
(
int
Type
)
{
if
(
Type
==
ABC_OPER_NONE
)
return
NULL
;
if
(
Type
==
ABC_OPER_CONST_F
)
return
"buf"
;
if
(
Type
==
ABC_OPER_CONST_T
)
return
"buf"
;
if
(
Type
==
ABC_OPER_CONST_X
)
return
"buf"
;
if
(
Type
==
ABC_OPER_CONST_Z
)
return
"buf"
;
if
(
Type
==
ABC_OPER_BIT_BUF
)
return
"buf"
;
if
(
Type
==
ABC_OPER_BIT_INV
)
return
"not"
;
if
(
Type
==
ABC_OPER_BIT_AND
)
return
"and"
;
if
(
Type
==
ABC_OPER_BIT_OR
)
return
"or"
;
if
(
Type
==
ABC_OPER_BIT_XOR
)
return
"xor"
;
if
(
Type
==
ABC_OPER_BIT_NAND
)
return
"nand"
;
if
(
Type
==
ABC_OPER_BIT_NOR
)
return
"nor"
;
if
(
Type
==
ABC_OPER_BIT_NXOR
)
return
"xnor"
;
assert
(
0
);
return
NULL
;
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
...
...
src/aig/miniaig/ndr.h
View file @
ddc574a9
...
@@ -334,7 +334,7 @@ static inline int Ndr_DataObjNum( Ndr_Data_t * p, int Mod )
...
@@ -334,7 +334,7 @@ static inline int Ndr_DataObjNum( Ndr_Data_t * p, int Mod )
}
}
// to write signal names, this procedure takes a mapping of name IDs into actual char-strings (pNames)
// to write signal names, this procedure takes a mapping of name IDs into actual char-strings (pNames)
static
inline
void
Ndr_WriteVerilogModule
(
FILE
*
pFile
,
void
*
pDesign
,
int
Mod
,
char
**
pNames
)
static
inline
void
Ndr_WriteVerilogModule
(
FILE
*
pFile
,
void
*
pDesign
,
int
Mod
,
char
**
pNames
,
int
fSimple
)
{
{
Ndr_Data_t
*
p
=
(
Ndr_Data_t
*
)
pDesign
;
Ndr_Data_t
*
p
=
(
Ndr_Data_t
*
)
pDesign
;
int
*
pOuts
=
NDR_ALLOC
(
int
,
Ndr_DataCoNum
(
p
,
Mod
)
);
int
*
pOuts
=
NDR_ALLOC
(
int
,
Ndr_DataCoNum
(
p
,
Mod
)
);
...
@@ -377,6 +377,8 @@ static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod
...
@@ -377,6 +377,8 @@ static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod
break
;
break
;
if
(
k
<
i
)
if
(
k
<
i
)
continue
;
continue
;
if
(
Ndr_ObjReadOutName
(
p
,
Obj
,
pNames
)[
0
]
==
'1'
)
continue
;
fprintf
(
pFile
,
" wire "
);
fprintf
(
pFile
,
" wire "
);
Ndr_ObjWriteRange
(
p
,
Obj
,
pFile
,
1
);
Ndr_ObjWriteRange
(
p
,
Obj
,
pFile
,
1
);
fprintf
(
pFile
,
" %s;
\n
"
,
Ndr_ObjReadOutName
(
p
,
Obj
,
pNames
)
);
fprintf
(
pFile
,
" %s;
\n
"
,
Ndr_ObjReadOutName
(
p
,
Obj
,
pNames
)
);
...
@@ -459,6 +461,24 @@ static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod
...
@@ -459,6 +461,24 @@ static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod
fprintf
(
pFile
,
");
\n
"
);
fprintf
(
pFile
,
");
\n
"
);
continue
;
continue
;
}
}
if
(
fSimple
)
{
if
(
Ndr_ObjReadOutName
(
p
,
Obj
,
pNames
)[
0
]
==
'1'
)
continue
;
nArray
=
Ndr_ObjReadArray
(
p
,
Obj
,
NDR_INPUT
,
&
pArray
);
fprintf
(
pFile
,
" %s ( %s"
,
Abc_OperNameSimple
(
Type
),
Ndr_ObjReadOutName
(
p
,
Obj
,
pNames
)
);
if
(
nArray
==
0
)
fprintf
(
pFile
,
", %s );
\n
"
,
(
char
*
)
Ndr_ObjReadBodyP
(
p
,
Obj
,
NDR_FUNCTION
)
);
else
if
(
nArray
==
1
&&
Ndr_ObjReadBody
(
p
,
Obj
,
NDR_OPERTYPE
)
==
ABC_OPER_BIT_BUF
)
fprintf
(
pFile
,
", %s );
\n
"
,
pNames
[
pArray
[
0
]]
);
else
{
for
(
i
=
0
;
i
<
nArray
;
i
++
)
fprintf
(
pFile
,
", %s"
,
pNames
[
pArray
[
i
]]
);
fprintf
(
pFile
,
" );
\n
"
);
}
continue
;
}
fprintf
(
pFile
,
" assign %s = "
,
Ndr_ObjReadOutName
(
p
,
Obj
,
pNames
)
);
fprintf
(
pFile
,
" assign %s = "
,
Ndr_ObjReadOutName
(
p
,
Obj
,
pNames
)
);
nArray
=
Ndr_ObjReadArray
(
p
,
Obj
,
NDR_INPUT
,
&
pArray
);
nArray
=
Ndr_ObjReadArray
(
p
,
Obj
,
NDR_INPUT
,
&
pArray
);
if
(
nArray
==
0
)
if
(
nArray
==
0
)
...
@@ -492,7 +512,7 @@ static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod
...
@@ -492,7 +512,7 @@ static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod
}
}
// to write signal names, this procedure takes a mapping of name IDs into actual char-strings (pNames)
// to write signal names, this procedure takes a mapping of name IDs into actual char-strings (pNames)
static
inline
void
Ndr_WriteVerilog
(
char
*
pFileName
,
void
*
pDesign
,
char
**
pNames
)
static
inline
void
Ndr_WriteVerilog
(
char
*
pFileName
,
void
*
pDesign
,
char
**
pNames
,
int
fSimple
)
{
{
Ndr_Data_t
*
p
=
(
Ndr_Data_t
*
)
pDesign
;
int
Mod
;
Ndr_Data_t
*
p
=
(
Ndr_Data_t
*
)
pDesign
;
int
Mod
;
...
@@ -500,7 +520,7 @@ static inline void Ndr_WriteVerilog( char * pFileName, void * pDesign, char ** p
...
@@ -500,7 +520,7 @@ static inline void Ndr_WriteVerilog( char * pFileName, void * pDesign, char ** p
if
(
pFile
==
NULL
)
{
printf
(
"Cannot open file
\"
%s
\"
for writing.
\n
"
,
pFileName
);
return
;
}
if
(
pFile
==
NULL
)
{
printf
(
"Cannot open file
\"
%s
\"
for writing.
\n
"
,
pFileName
);
return
;
}
Ndr_DesForEachMod
(
p
,
Mod
)
Ndr_DesForEachMod
(
p
,
Mod
)
Ndr_WriteVerilogModule
(
pFile
,
p
,
Mod
,
pNames
);
Ndr_WriteVerilogModule
(
pFile
,
p
,
Mod
,
pNames
,
fSimple
);
if
(
pFileName
)
fclose
(
pFile
);
if
(
pFileName
)
fclose
(
pFile
);
}
}
...
@@ -656,7 +676,7 @@ static inline void Ndr_ModuleTest()
...
@@ -656,7 +676,7 @@ static inline void Ndr_ModuleTest()
Ndr_AddObject
(
pDesign
,
ModuleID
,
ABC_OPER_CO
,
0
,
3
,
0
,
0
,
1
,
&
NameIdS
,
0
,
NULL
,
NULL
);
// fanin is a
Ndr_AddObject
(
pDesign
,
ModuleID
,
ABC_OPER_CO
,
0
,
3
,
0
,
0
,
1
,
&
NameIdS
,
0
,
NULL
,
NULL
);
// fanin is a
// write Verilog for verification
// write Verilog for verification
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
);
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
,
0
);
Ndr_Write
(
"add4.ndr"
,
pDesign
);
Ndr_Write
(
"add4.ndr"
,
pDesign
);
Ndr_Delete
(
pDesign
);
Ndr_Delete
(
pDesign
);
}
}
...
@@ -744,7 +764,7 @@ static inline void Ndr_ModuleTestAdder()
...
@@ -744,7 +764,7 @@ static inline void Ndr_ModuleTestAdder()
Ndr_AddObject
(
pDesign
,
ModuleID
,
ABC_OPER_CO
,
0
,
0
,
0
,
0
,
1
,
&
FaninCO
,
0
,
NULL
,
NULL
);
Ndr_AddObject
(
pDesign
,
ModuleID
,
ABC_OPER_CO
,
0
,
0
,
0
,
0
,
1
,
&
FaninCO
,
0
,
NULL
,
NULL
);
// write Verilog for verification
// write Verilog for verification
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
);
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
,
0
);
Ndr_Write
(
"add8.ndr"
,
pDesign
);
Ndr_Write
(
"add8.ndr"
,
pDesign
);
Ndr_Delete
(
pDesign
);
Ndr_Delete
(
pDesign
);
...
@@ -830,7 +850,7 @@ static inline void Ndr_ModuleTestHierarchy()
...
@@ -830,7 +850,7 @@ static inline void Ndr_ModuleTestHierarchy()
Ndr_AddObject
(
pDesign
,
Module41
,
ABC_OPER_CO
,
0
,
3
,
0
,
0
,
1
,
&
FaninOut
,
0
,
NULL
,
NULL
);
Ndr_AddObject
(
pDesign
,
Module41
,
ABC_OPER_CO
,
0
,
3
,
0
,
0
,
1
,
&
FaninOut
,
0
,
NULL
,
NULL
);
// write Verilog for verification
// write Verilog for verification
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
);
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
,
0
);
Ndr_Write
(
"mux41w.ndr"
,
pDesign
);
Ndr_Write
(
"mux41w.ndr"
,
pDesign
);
Ndr_Delete
(
pDesign
);
Ndr_Delete
(
pDesign
);
}
}
...
@@ -919,7 +939,7 @@ static inline void Ndr_ModuleTestMemory()
...
@@ -919,7 +939,7 @@ static inline void Ndr_ModuleTestMemory()
Ndr_AddObject
(
pDesign
,
ModuleID
,
ABC_OPER_COMP_NOTEQU
,
0
,
0
,
0
,
0
,
2
,
FaninsComp
,
1
,
&
NameIdComp
,
NULL
);
Ndr_AddObject
(
pDesign
,
ModuleID
,
ABC_OPER_COMP_NOTEQU
,
0
,
0
,
0
,
0
,
2
,
FaninsComp
,
1
,
&
NameIdComp
,
NULL
);
// write Verilog for verification
// write Verilog for verification
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
);
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
,
0
);
Ndr_Write
(
"memtest.ndr"
,
pDesign
);
Ndr_Write
(
"memtest.ndr"
,
pDesign
);
Ndr_Delete
(
pDesign
);
Ndr_Delete
(
pDesign
);
}
}
...
@@ -968,7 +988,7 @@ static inline void Ndr_ModuleTestFlop()
...
@@ -968,7 +988,7 @@ static inline void Ndr_ModuleTestFlop()
Ndr_AddObject
(
pDesign
,
ModuleID
,
ABC_OPER_CO
,
0
,
3
,
0
,
0
,
1
,
&
NameIdQ
,
0
,
NULL
,
NULL
);
Ndr_AddObject
(
pDesign
,
ModuleID
,
ABC_OPER_CO
,
0
,
3
,
0
,
0
,
1
,
&
NameIdQ
,
0
,
NULL
,
NULL
);
// write Verilog for verification
// write Verilog for verification
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
);
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
,
0
);
Ndr_Write
(
"flop.ndr"
,
pDesign
);
Ndr_Write
(
"flop.ndr"
,
pDesign
);
Ndr_Delete
(
pDesign
);
Ndr_Delete
(
pDesign
);
}
}
...
@@ -1022,7 +1042,7 @@ static inline void Ndr_ModuleTestSelSel()
...
@@ -1022,7 +1042,7 @@ static inline void Ndr_ModuleTestSelSel()
Ndr_AddObject
(
pDesign
,
ModuleID
,
ABC_OPER_CO
,
0
,
2
,
0
,
0
,
1
,
&
NameIdOut
,
0
,
NULL
,
NULL
);
Ndr_AddObject
(
pDesign
,
ModuleID
,
ABC_OPER_CO
,
0
,
2
,
0
,
0
,
1
,
&
NameIdOut
,
0
,
NULL
,
NULL
);
// write Verilog for verification
// write Verilog for verification
//Ndr_WriteVerilog( NULL, pDesign, ppNames );
//Ndr_WriteVerilog( NULL, pDesign, ppNames
, 0
);
Ndr_Write
(
"sel.ndr"
,
pDesign
);
Ndr_Write
(
"sel.ndr"
,
pDesign
);
Ndr_Delete
(
pDesign
);
Ndr_Delete
(
pDesign
);
}
}
...
...
src/base/wlc/wlcNdr.c
View file @
ddc574a9
...
@@ -263,7 +263,7 @@ void Wlc_NtkToNdrTest( Wlc_Ntk_t * pNtk )
...
@@ -263,7 +263,7 @@ void Wlc_NtkToNdrTest( Wlc_Ntk_t * pNtk )
ppNames
[
i
]
=
Wlc_ObjName
(
pNtk
,
i
);
ppNames
[
i
]
=
Wlc_ObjName
(
pNtk
,
i
);
// verify by writing Verilog
// verify by writing Verilog
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
);
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
,
0
);
Ndr_Write
(
"test.ndr"
,
pDesign
);
Ndr_Write
(
"test.ndr"
,
pDesign
);
// cleanup
// cleanup
...
@@ -535,7 +535,7 @@ Wlc_Ntk_t * Wlc_ReadNdr( char * pFileName )
...
@@ -535,7 +535,7 @@ Wlc_Ntk_t * Wlc_ReadNdr( char * pFileName )
void
*
pData
=
Ndr_Read
(
pFileName
);
void
*
pData
=
Ndr_Read
(
pFileName
);
Wlc_Ntk_t
*
pNtk
=
Wlc_NtkFromNdr
(
pData
);
Wlc_Ntk_t
*
pNtk
=
Wlc_NtkFromNdr
(
pData
);
//char * ppNames[10] = { NULL, "a", "b", "c", "d", "e", "f", "g", "h", "i" };
//char * ppNames[10] = { NULL, "a", "b", "c", "d", "e", "f", "g", "h", "i" };
//Ndr_WriteVerilog( NULL, pData, ppNames );
//Ndr_WriteVerilog( NULL, pData, ppNames
, 0
);
//Ndr_Delete( pData );
//Ndr_Delete( pData );
Abc_FrameInputNdr
(
Abc_FrameGetGlobalFrame
(),
pData
);
Abc_FrameInputNdr
(
Abc_FrameGetGlobalFrame
(),
pData
);
return
pNtk
;
return
pNtk
;
...
...
src/base/wln/wlnNdr.c
View file @
ddc574a9
...
@@ -96,7 +96,7 @@ void Wln_NtkToNdrTest( Wln_Ntk_t * p )
...
@@ -96,7 +96,7 @@ void Wln_NtkToNdrTest( Wln_Ntk_t * p )
ppNames
[
i
]
=
Abc_UtilStrsav
(
Wln_ObjName
(
p
,
i
));
ppNames
[
i
]
=
Abc_UtilStrsav
(
Wln_ObjName
(
p
,
i
));
// verify by writing Verilog
// verify by writing Verilog
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
);
Ndr_WriteVerilog
(
NULL
,
pDesign
,
ppNames
,
0
);
Ndr_Write
(
"test.ndr"
,
pDesign
);
Ndr_Write
(
"test.ndr"
,
pDesign
);
// cleanup
// cleanup
...
@@ -301,7 +301,7 @@ Wln_Ntk_t * Wln_ReadNdr( char * pFileName )
...
@@ -301,7 +301,7 @@ Wln_Ntk_t * Wln_ReadNdr( char * pFileName )
Wln_Ntk_t
*
pNtk
=
pData
?
Wln_NtkFromNdr
(
pData
,
0
)
:
NULL
;
Wln_Ntk_t
*
pNtk
=
pData
?
Wln_NtkFromNdr
(
pData
,
0
)
:
NULL
;
if
(
pNtk
)
return
NULL
;
if
(
pNtk
)
return
NULL
;
//char * ppNames[10] = { NULL, "a", "b", "c", "d", "e", "f", "g", "h", "i" };
//char * ppNames[10] = { NULL, "a", "b", "c", "d", "e", "f", "g", "h", "i" };
//Ndr_WriteVerilog( NULL, pData, ppNames );
//Ndr_WriteVerilog( NULL, pData, ppNames
, 0
);
Ndr_Delete
(
pData
);
Ndr_Delete
(
pData
);
return
pNtk
;
return
pNtk
;
}
}
...
...
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