Commit 9b3fa55b by Alan Mishchenko

Version abc50814

parent f2b6b3be
...@@ -301,6 +301,10 @@ SOURCE=.\src\base\io\ioReadBlif.c ...@@ -301,6 +301,10 @@ SOURCE=.\src\base\io\ioReadBlif.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\io\ioReadEdif.c
# End Source File
# Begin Source File
SOURCE=.\src\base\io\ioReadPla.c SOURCE=.\src\base\io\ioReadPla.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
No preview for this file type
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
--------------------Configuration: abc - Win32 Debug-------------------- --------------------Configuration: abc - Win32 Debug--------------------
</h3> </h3>
<h3>Command Lines</h3> <h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP60E.tmp" with contents Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSPBEE.tmp" with contents
[ [
/nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\base\abc" /I "src\base\cmd" /I "src\base\io" /I "src\base\main" /I "src\bdd\cudd" /I "src\bdd\epd" /I "src\bdd\mtr" /I "src\bdd\parse" /I "src\bdd\dsd" /I "src\bdd\reo" /I "src\sop\mvc" /I "src\sop\ft" /I "src\sat\asat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\fxa" /I "src\opt\fxu" /I "src\map\fpga" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\util" /I "src\misc\vec" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /D "HAVE_ASSERT_H" /FR"Debug/" /Fp"Debug/abc.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c /nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\base\abc" /I "src\base\cmd" /I "src\base\io" /I "src\base\main" /I "src\bdd\cudd" /I "src\bdd\epd" /I "src\bdd\mtr" /I "src\bdd\parse" /I "src\bdd\dsd" /I "src\bdd\reo" /I "src\sop\mvc" /I "src\sop\ft" /I "src\sat\asat" /I "src\sat\msat" /I "src\sat\fraig" /I "src\opt\fxa" /I "src\opt\fxu" /I "src\map\fpga" /I "src\map\mapper" /I "src\map\mio" /I "src\map\super" /I "src\misc\extra" /I "src\misc\st" /I "src\misc\util" /I "src\misc\vec" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /D "HAVE_ASSERT_H" /FR"Debug/" /Fp"Debug/abc.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"C:\_projects\abc\src\base\abc\abc.c" "C:\_projects\abc\src\map\mapper\mapperCut.c"
] ]
Creating command line "cl.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP60E.tmp" Creating command line "cl.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSPBEE.tmp"
Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP60F.tmp" with contents Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSPBEF.tmp" with contents
[ [
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/abc.pdb" /debug /machine:I386 /out:"_TEST/abc.exe" /pdbtype:sept kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/abc.pdb" /debug /machine:I386 /out:"_TEST/abc.exe" /pdbtype:sept
.\Debug\abc.obj .\Debug\abc.obj
...@@ -39,6 +39,8 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32 ...@@ -39,6 +39,8 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32
.\Debug\abcRenode.obj .\Debug\abcRenode.obj
.\Debug\abcRes.obj .\Debug\abcRes.obj
.\Debug\abcSat.obj .\Debug\abcSat.obj
.\Debug\abcSeq.obj
.\Debug\abcSeqRetime.obj
.\Debug\abcShow.obj .\Debug\abcShow.obj
.\Debug\abcSop.obj .\Debug\abcSop.obj
.\Debug\abcStrash.obj .\Debug\abcStrash.obj
...@@ -57,6 +59,7 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32 ...@@ -57,6 +59,7 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32
.\Debug\ioRead.obj .\Debug\ioRead.obj
.\Debug\ioReadBench.obj .\Debug\ioReadBench.obj
.\Debug\ioReadBlif.obj .\Debug\ioReadBlif.obj
.\Debug\ioReadEdif.obj
.\Debug\ioReadPla.obj .\Debug\ioReadPla.obj
.\Debug\ioReadVerilog.obj .\Debug\ioReadVerilog.obj
.\Debug\ioUtil.obj .\Debug\ioUtil.obj
...@@ -266,15 +269,14 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32 ...@@ -266,15 +269,14 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32
.\Debug\safe_mem.obj .\Debug\safe_mem.obj
.\Debug\strsav.obj .\Debug\strsav.obj
.\Debug\texpand.obj .\Debug\texpand.obj
.\Debug\abcSeq.obj
.\Debug\abcSeqRetime.obj
] ]
Creating command line "link.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP60F.tmp" Creating command line "link.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSPBEF.tmp"
<h3>Output Window</h3> <h3>Output Window</h3>
Compiling... Compiling...
abc.c mapperCut.c
C:\_projects\abc\src\map\mapper\mapperCut.c(927) : warning C4101: 'Place' : unreferenced local variable
Linking... Linking...
Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP610.tmp" with contents Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSPBF0.tmp" with contents
[ [
/nologo /o"Debug/abc.bsc" /nologo /o"Debug/abc.bsc"
.\Debug\abc.sbr .\Debug\abc.sbr
...@@ -301,6 +303,8 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP610.tmp" with conte ...@@ -301,6 +303,8 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP610.tmp" with conte
.\Debug\abcRenode.sbr .\Debug\abcRenode.sbr
.\Debug\abcRes.sbr .\Debug\abcRes.sbr
.\Debug\abcSat.sbr .\Debug\abcSat.sbr
.\Debug\abcSeq.sbr
.\Debug\abcSeqRetime.sbr
.\Debug\abcShow.sbr .\Debug\abcShow.sbr
.\Debug\abcSop.sbr .\Debug\abcSop.sbr
.\Debug\abcStrash.sbr .\Debug\abcStrash.sbr
...@@ -319,6 +323,7 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP610.tmp" with conte ...@@ -319,6 +323,7 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP610.tmp" with conte
.\Debug\ioRead.sbr .\Debug\ioRead.sbr
.\Debug\ioReadBench.sbr .\Debug\ioReadBench.sbr
.\Debug\ioReadBlif.sbr .\Debug\ioReadBlif.sbr
.\Debug\ioReadEdif.sbr
.\Debug\ioReadPla.sbr .\Debug\ioReadPla.sbr
.\Debug\ioReadVerilog.sbr .\Debug\ioReadVerilog.sbr
.\Debug\ioUtil.sbr .\Debug\ioUtil.sbr
...@@ -527,17 +532,15 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP610.tmp" with conte ...@@ -527,17 +532,15 @@ Creating temporary file "C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP610.tmp" with conte
.\Debug\pathsearch.sbr .\Debug\pathsearch.sbr
.\Debug\safe_mem.sbr .\Debug\safe_mem.sbr
.\Debug\strsav.sbr .\Debug\strsav.sbr
.\Debug\texpand.sbr .\Debug\texpand.sbr]
.\Debug\abcSeq.sbr Creating command line "bscmake.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSPBF0.tmp"
.\Debug\abcSeqRetime.sbr]
Creating command line "bscmake.exe @C:\DOCUME~1\alanmi\LOCALS~1\Temp\RSP610.tmp"
Creating browse info file... Creating browse info file...
<h3>Output Window</h3> <h3>Output Window</h3>
<h3>Results</h3> <h3>Results</h3>
abc.exe - 0 error(s), 0 warning(s) abc.exe - 0 error(s), 1 warning(s)
</pre> </pre>
</body> </body>
</html> </html>
...@@ -3,8 +3,10 @@ alias clp collapse ...@@ -3,8 +3,10 @@ alias clp collapse
alias esd ext_seq_dcs alias esd ext_seq_dcs
alias f fraig alias f fraig
alias fs fraig_sweep alias fs fraig_sweep
alias mu renode -m
alias pf print_factor alias pf print_factor
alias pfan print_fanio alias pfan print_fanio
alias pl print_level
alias pio print_io alias pio print_io
alias ps print_stats alias ps print_stats
alias psu print_supp alias psu print_supp
...@@ -21,10 +23,11 @@ alias so source -x ...@@ -21,10 +23,11 @@ alias so source -x
alias st strash alias st strash
alias u undo alias u undo
alias wb write_blif alias wb write_blif
alias wg write_gate
alias wl write_blif alias wl write_blif
alias wp write_pla alias wp write_pla
alias cnf "st; renode -c; write_cnf" alias cnf "st; renode -c; write_cnf"
alias prove "st; renode -c; sat" alias prove "st; renode -c; sat"
alias opt "st; b; renode; sop; ps" alias opt "st; b; renode; sop; ps"
alias opts "st; b; renode; sop; st; b; ps" alias opts "st; b; renode; sop; st; b; ps"
alias share "st; b; renode -m; fx; st; b; ps"
...@@ -33,6 +33,7 @@ static int Abc_CommandPrintIo ( Abc_Frame_t * pAbc, int argc, char ** argv ...@@ -33,6 +33,7 @@ static int Abc_CommandPrintIo ( Abc_Frame_t * pAbc, int argc, char ** argv
static int Abc_CommandPrintLatch ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintLatch ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPrintFanio ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintFanio ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPrintFactor ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintFactor ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPrintLevel ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPrintSupport ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintSupport ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandShowBdd ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandShowBdd ( Abc_Frame_t * pAbc, int argc, char ** argv );
...@@ -97,6 +98,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) ...@@ -97,6 +98,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Printing", "print_latch", Abc_CommandPrintLatch, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_latch", Abc_CommandPrintLatch, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_fanio", Abc_CommandPrintFanio, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_fanio", Abc_CommandPrintFanio, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_factor", Abc_CommandPrintFactor, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_factor", Abc_CommandPrintFactor, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_level", Abc_CommandPrintLevel, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_supp", Abc_CommandPrintSupport, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_supp", Abc_CommandPrintSupport, 0 );
Cmd_CommandAdd( pAbc, "Printing", "show_bdd", Abc_CommandShowBdd, 0 ); Cmd_CommandAdd( pAbc, "Printing", "show_bdd", Abc_CommandShowBdd, 0 );
...@@ -480,6 +482,88 @@ usage: ...@@ -480,6 +482,88 @@ usage:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Abc_CommandPrintLevel( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk;
Abc_Obj_t * pNode;
int c;
int fProfile;
pNtk = Abc_FrameReadNet(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set defaults
fProfile = 0;
util_getopt_reset();
while ( ( c = util_getopt( argc, argv, "ph" ) ) != EOF )
{
switch ( c )
{
case 'p':
fProfile ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pNtk == NULL )
{
fprintf( pErr, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsAig(pNtk) )
{
fprintf( pErr, "This command works only for AIGs.\n" );
return 1;
}
if ( argc > util_optind + 1 )
{
fprintf( pErr, "Wrong number of auguments.\n" );
goto usage;
}
if ( argc == util_optind + 1 )
{
pNode = Abc_NtkFindNode( pNtk, argv[util_optind] );
if ( pNode == NULL )
{
fprintf( pErr, "Cannot find node \"%s\".\n", argv[util_optind] );
return 1;
}
Abc_NodePrintLevel( pOut, pNode );
return 0;
}
// process all COs
Abc_NtkPrintLevel( pOut, pNtk, fProfile );
return 0;
usage:
fprintf( pErr, "usage: print_level [-ph] <node>\n" );
fprintf( pErr, "\t prints information about node level and cone size\n" );
fprintf( pErr, "\t-p : toggles printing level profile [default = %s]\n", fProfile? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
fprintf( pErr, "\tnode : (optional) one node to consider\n");
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
FILE * pOut, * pErr; FILE * pOut, * pErr;
...@@ -2973,9 +3057,10 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -2973,9 +3057,10 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
int nArgcNew; int nArgcNew;
int c; int c;
int fSat; int fSat;
int fVerbose;
extern void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ); extern void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 );
extern void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ); extern void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fVerbose );
pNtk = Abc_FrameReadNet(pAbc); pNtk = Abc_FrameReadNet(pAbc);
...@@ -2984,14 +3069,18 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -2984,14 +3069,18 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults // set defaults
fSat = 0; fSat = 0;
fVerbose = 0;
util_getopt_reset(); util_getopt_reset();
while ( ( c = util_getopt( argc, argv, "sh" ) ) != EOF ) while ( ( c = util_getopt( argc, argv, "svh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
case 's': case 's':
fSat ^= 1; fSat ^= 1;
break; break;
case 'v':
fVerbose ^= 1;
break;
default: default:
goto usage; goto usage;
} }
...@@ -3006,16 +3095,17 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3006,16 +3095,17 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( fSat ) if ( fSat )
Abc_NtkCecSat( pNtk1, pNtk2 ); Abc_NtkCecSat( pNtk1, pNtk2 );
else else
Abc_NtkCecFraig( pNtk1, pNtk2 ); Abc_NtkCecFraig( pNtk1, pNtk2, fVerbose );
if ( fDelete1 ) Abc_NtkDelete( pNtk1 ); if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
if ( fDelete2 ) Abc_NtkDelete( pNtk2 ); if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
return 0; return 0;
usage: usage:
fprintf( pErr, "usage: cec [-sh] <file1> <file2>\n" ); fprintf( pErr, "usage: cec [-svh] <file1> <file2>\n" );
fprintf( pErr, "\t performs combinational equivalence checking\n" ); fprintf( pErr, "\t performs combinational equivalence checking\n" );
fprintf( pErr, "\t-s : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" ); fprintf( pErr, "\t-s : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t-h : print the command usage\n");
fprintf( pErr, "\tfile1 : (optional) the file with the first network\n"); fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
fprintf( pErr, "\tfile2 : (optional) the file with the second network\n"); fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
......
...@@ -43,26 +43,36 @@ ...@@ -43,26 +43,36 @@
// network types // network types
typedef enum { typedef enum {
ABC_NTK_NONE, // unknown ABC_NTK_NONE, // 0: unknown
ABC_NTK_NETLIST_SOP, // netlist with nodes represented using SOPs ABC_NTK_NETLIST_SOP, // 1: netlist with nodes represented using SOPs
ABC_NTK_NETLIST_MAP, // netlist with nodes represented using gates from the library ABC_NTK_NETLIST_MAP, // 2: netlist with nodes represented using gates from the library
ABC_NTK_LOGIC_SOP, // only SOP logic nodes (similar to SIS network) ABC_NTK_LOGIC_SOP, // 3: only SOP logic nodes (similar to SIS network)
ABC_NTK_LOGIC_BDD, // only BDD logic nodes (similar to BDS network) ABC_NTK_LOGIC_BDD, // 4: only BDD logic nodes (similar to BDS network)
ABC_NTK_LOGIC_MAP, // only mapped logic nodes (similar to mapped SIS network) ABC_NTK_LOGIC_MAP, // 5: only mapped logic nodes (similar to mapped SIS network)
ABC_NTK_AIG, // AIG or FRAIG (two input gates with c-attributes on edges) ABC_NTK_AIG, // 6: AIG or FRAIG (two input gates with c-attributes on edges)
ABC_NTK_SEQ, // sequential AIG (two input gates with c- and latch-attributes on edges) ABC_NTK_SEQ, // 7: sequential AIG (two input gates with c- and latch-attributes on edges)
ABC_NTK_OTHER // unused ABC_NTK_OTHER // 8: unused
} Abc_NtkType_t; } Abc_NtkType_t;
// functionality types
typedef enum {
ABC_FUNC_NONE, // 0: unknown
ABC_FUNC_SOP, // 1: sum-of-products
ABC_FUNC_BDD, // 2: binary decision diagrams
ABC_FUNC_AIG, // 3: and-inverter graphs
ABC_FUNC_MAP, // 4: standard cell library
ABC_FUNC_OTHER // 5: unused
} Abc_FuncType_t;
// object types // object types
typedef enum { typedef enum {
ABC_OBJ_NONE, // unknown ABC_OBJ_NONE, // 0: unknown
ABC_OBJ_NET, // net ABC_OBJ_NET, // 1: net
ABC_OBJ_NODE, // node ABC_OBJ_NODE, // 2: node
ABC_OBJ_LATCH, // latch ABC_OBJ_LATCH, // 3: latch
ABC_OBJ_PI, // terminal ABC_OBJ_PI, // 4: primary input terminal
ABC_OBJ_PO, // terminal ABC_OBJ_PO, // 5: primary output terminal
ABC_OBJ_OTHER // unused ABC_OBJ_OTHER // 6: unused
} Abc_ObjType_t; } Abc_ObjType_t;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -201,6 +211,7 @@ static inline void Abc_NtkSetBackup( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNetBa ...@@ -201,6 +211,7 @@ static inline void Abc_NtkSetBackup( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNetBa
static inline void Abc_NtkSetStep ( Abc_Ntk_t * pNtk, int iStep ) { pNtk->iStep = iStep; } static inline void Abc_NtkSetStep ( Abc_Ntk_t * pNtk, int iStep ) { pNtk->iStep = iStep; }
// getting the number of objects // getting the number of objects
static inline int Abc_NtkObjNumMax( Abc_Ntk_t * pNtk ) { return pNtk->vObjs->nSize; }
static inline int Abc_NtkObjNum( Abc_Ntk_t * pNtk ) { return pNtk->nObjs; } static inline int Abc_NtkObjNum( Abc_Ntk_t * pNtk ) { return pNtk->nObjs; }
static inline int Abc_NtkNetNum( Abc_Ntk_t * pNtk ) { return pNtk->nNets; } static inline int Abc_NtkNetNum( Abc_Ntk_t * pNtk ) { return pNtk->nNets; }
static inline int Abc_NtkNodeNum( Abc_Ntk_t * pNtk ) { return pNtk->nNodes; } static inline int Abc_NtkNodeNum( Abc_Ntk_t * pNtk ) { return pNtk->nNodes; }
...@@ -279,6 +290,7 @@ static inline Abc_Obj_t * Abc_ObjFanin0Ntk( Abc_Obj_t * pObj ) { return Abc_N ...@@ -279,6 +290,7 @@ static inline Abc_Obj_t * Abc_ObjFanin0Ntk( Abc_Obj_t * pObj ) { return Abc_N
static inline bool Abc_ObjFaninC( Abc_Obj_t * pObj, int i ){ return pObj->vFanins.pArray[i].fCompl; } static inline bool Abc_ObjFaninC( Abc_Obj_t * pObj, int i ){ return pObj->vFanins.pArray[i].fCompl; }
static inline bool Abc_ObjFaninC0( Abc_Obj_t * pObj ) { return pObj->vFanins.pArray[0].fCompl; } static inline bool Abc_ObjFaninC0( Abc_Obj_t * pObj ) { return pObj->vFanins.pArray[0].fCompl; }
static inline bool Abc_ObjFaninC1( Abc_Obj_t * pObj ) { return pObj->vFanins.pArray[1].fCompl; } static inline bool Abc_ObjFaninC1( Abc_Obj_t * pObj ) { return pObj->vFanins.pArray[1].fCompl; }
static inline bool Abc_ObjFanoutC( Abc_Obj_t * pObj, Abc_Obj_t * pFanout ) { assert( !Abc_NtkIsLogic(pObj->pNtk) ); return (Abc_ObjFaninId0(pFanout) == (int)pObj->Id)? Abc_ObjFaninC0(pFanout) : Abc_ObjFaninC1(pFanout); }
static inline int Abc_ObjFaninL( Abc_Obj_t * pObj, int i ){ return pObj->vFanins.pArray[i].nLats; } static inline int Abc_ObjFaninL( Abc_Obj_t * pObj, int i ){ return pObj->vFanins.pArray[i].nLats; }
static inline int Abc_ObjFaninL0( Abc_Obj_t * pObj ) { return pObj->vFanins.pArray[0].nLats; } static inline int Abc_ObjFaninL0( Abc_Obj_t * pObj ) { return pObj->vFanins.pArray[0].nLats; }
static inline int Abc_ObjFaninL1( Abc_Obj_t * pObj ) { return pObj->vFanins.pArray[1].nLats; } static inline int Abc_ObjFaninL1( Abc_Obj_t * pObj ) { return pObj->vFanins.pArray[1].nLats; }
...@@ -287,6 +299,10 @@ static inline int Abc_ObjFaninLMax( Abc_Obj_t * pObj ) { assert( Abc_ ...@@ -287,6 +299,10 @@ static inline int Abc_ObjFaninLMax( Abc_Obj_t * pObj ) { assert( Abc_
static inline Abc_Obj_t * Abc_ObjChild( Abc_Obj_t * pObj, int i ) { return Abc_ObjNotCond( Abc_ObjFanin(pObj,i), Abc_ObjFaninC(pObj,i) );} static inline Abc_Obj_t * Abc_ObjChild( Abc_Obj_t * pObj, int i ) { return Abc_ObjNotCond( Abc_ObjFanin(pObj,i), Abc_ObjFaninC(pObj,i) );}
static inline Abc_Obj_t * Abc_ObjChild0( Abc_Obj_t * pObj ) { return Abc_ObjNotCond( Abc_ObjFanin0(pObj), Abc_ObjFaninC0(pObj) ); } static inline Abc_Obj_t * Abc_ObjChild0( Abc_Obj_t * pObj ) { return Abc_ObjNotCond( Abc_ObjFanin0(pObj), Abc_ObjFaninC0(pObj) ); }
static inline Abc_Obj_t * Abc_ObjChild1( Abc_Obj_t * pObj ) { return Abc_ObjNotCond( Abc_ObjFanin1(pObj), Abc_ObjFaninC1(pObj) ); } static inline Abc_Obj_t * Abc_ObjChild1( Abc_Obj_t * pObj ) { return Abc_ObjNotCond( Abc_ObjFanin1(pObj), Abc_ObjFaninC1(pObj) ); }
static inline Abc_Obj_t * Abc_ObjChildCopy( Abc_Obj_t * pObj, int i ) { return Abc_ObjNotCond( Abc_ObjFanin(pObj,i)->pCopy, Abc_ObjFaninC(pObj,i) );}
static inline Abc_Obj_t * Abc_ObjChild0Copy( Abc_Obj_t * pObj ) { return Abc_ObjNotCond( Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) ); }
static inline Abc_Obj_t * Abc_ObjChild1Copy( Abc_Obj_t * pObj ) { return Abc_ObjNotCond( Abc_ObjFanin1(pObj)->pCopy, Abc_ObjFaninC1(pObj) ); }
static inline Abc_Obj_t * Abc_ObjFanoutFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanout ) { assert( !Abc_NtkIsLogic(pObj->pNtk) ); return (Abc_ObjFaninId0(pFanout) == (int)pObj->Id)? Abc_ObjChild0(pFanout) : Abc_ObjChild1(pFanout); }
static inline void Abc_ObjSetFaninC( Abc_Obj_t * pObj, int i ){ pObj->vFanins.pArray[i].fCompl = 1; } static inline void Abc_ObjSetFaninC( Abc_Obj_t * pObj, int i ){ pObj->vFanins.pArray[i].fCompl = 1; }
static inline void Abc_ObjXorFaninC( Abc_Obj_t * pObj, int i ){ pObj->vFanins.pArray[i].fCompl ^= 1; } static inline void Abc_ObjXorFaninC( Abc_Obj_t * pObj, int i ){ pObj->vFanins.pArray[i].fCompl ^= 1; }
static inline void Abc_ObjSetFaninL( Abc_Obj_t * pObj, int i, int nLats ) { pObj->vFanins.pArray[i].nLats = nLats; } static inline void Abc_ObjSetFaninL( Abc_Obj_t * pObj, int i, int nLats ) { pObj->vFanins.pArray[i].nLats = nLats; }
...@@ -302,8 +318,8 @@ extern int Abc_ObjFanoutLMin( Abc_Obj_t * pObj ); ...@@ -302,8 +318,8 @@ extern int Abc_ObjFanoutLMin( Abc_Obj_t * pObj );
extern int Abc_ObjFanoutLMax( Abc_Obj_t * pObj ); extern int Abc_ObjFanoutLMax( Abc_Obj_t * pObj );
// checking the node type // checking the node type
static inline bool Abc_NodeIsAigAnd( Abc_Obj_t * pNode ) { assert(Abc_NtkIsAig(pNode->pNtk)); return Abc_ObjFaninNum(pNode) == 2; } static inline bool Abc_NodeIsAigAnd( Abc_Obj_t * pNode ) { assert(Abc_NtkIsAig(pNode->pNtk) || Abc_NtkIsSeq(pNode->pNtk)); return Abc_ObjFaninNum(pNode) == 2; }
static inline bool Abc_NodeIsAigChoice( Abc_Obj_t * pNode ){ assert(Abc_NtkIsAig(pNode->pNtk)); return pNode->pData != NULL && Abc_ObjFanoutNum(pNode) > 0; } static inline bool Abc_NodeIsAigChoice( Abc_Obj_t * pNode ){ assert(Abc_NtkIsAig(pNode->pNtk) || Abc_NtkIsSeq(pNode->pNtk)); return pNode->pData != NULL && Abc_ObjFanoutNum(pNode) > 0; }
static inline bool Abc_NodeIsConst( Abc_Obj_t * pNode ) { assert(Abc_ObjIsNode(Abc_ObjRegular(pNode))); return Abc_ObjFaninNum(Abc_ObjRegular(pNode)) == 0; } static inline bool Abc_NodeIsConst( Abc_Obj_t * pNode ) { assert(Abc_ObjIsNode(Abc_ObjRegular(pNode))); return Abc_ObjFaninNum(Abc_ObjRegular(pNode)) == 0; }
extern bool Abc_NodeIsConst0( Abc_Obj_t * pNode ); extern bool Abc_NodeIsConst0( Abc_Obj_t * pNode );
extern bool Abc_NodeIsConst1( Abc_Obj_t * pNode ); extern bool Abc_NodeIsConst1( Abc_Obj_t * pNode );
...@@ -317,6 +333,14 @@ static inline void Abc_NodeSetTravIdPrevious( Abc_Obj_t * pNode ) { p ...@@ -317,6 +333,14 @@ static inline void Abc_NodeSetTravIdPrevious( Abc_Obj_t * pNode ) { p
static inline bool Abc_NodeIsTravIdCurrent( Abc_Obj_t * pNode ) { return (bool)(pNode->TravId == pNode->pNtk->nTravIds); } static inline bool Abc_NodeIsTravIdCurrent( Abc_Obj_t * pNode ) { return (bool)(pNode->TravId == pNode->pNtk->nTravIds); }
static inline bool Abc_NodeIsTravIdPrevious( Abc_Obj_t * pNode ) { return (bool)(pNode->TravId == pNode->pNtk->nTravIds - 1); } static inline bool Abc_NodeIsTravIdPrevious( Abc_Obj_t * pNode ) { return (bool)(pNode->TravId == pNode->pNtk->nTravIds - 1); }
// checking initial state of the latches
static inline void Abc_LatchSetInit0( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)0; }
static inline void Abc_LatchSetInit1( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)1; }
static inline void Abc_LatchSetInitDc( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)2; }
static inline bool Abc_LatchIsInit0( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)0; }
static inline bool Abc_LatchIsInit1( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)1; }
static inline bool Abc_LatchIsInitDc( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)2; }
// outputs the runtime in seconds // outputs the runtime in seconds
#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC)) #define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC))
...@@ -369,8 +393,8 @@ static inline bool Abc_NodeIsTravIdPrevious( Abc_Obj_t * pNode ) { r ...@@ -369,8 +393,8 @@ static inline bool Abc_NodeIsTravIdPrevious( Abc_Obj_t * pNode ) { r
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/*=== abcAig.c ==========================================================*/ /*=== abcAig.c ==========================================================*/
extern Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtk, bool fSeq ); extern Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtk );
extern Abc_Aig_t * Abc_AigDup( Abc_Aig_t * pMan, bool fSeq ); extern Abc_Aig_t * Abc_AigDup( Abc_Aig_t * pMan, Abc_Aig_t * pManNew );
extern void Abc_AigFree( Abc_Aig_t * pMan ); extern void Abc_AigFree( Abc_Aig_t * pMan );
extern int Abc_AigCleanup( Abc_Aig_t * pMan ); extern int Abc_AigCleanup( Abc_Aig_t * pMan );
extern bool Abc_AigCheck( Abc_Aig_t * pMan ); extern bool Abc_AigCheck( Abc_Aig_t * pMan );
...@@ -387,6 +411,7 @@ extern bool Abc_AigNodeHasComplFanoutEdgeTrav( Abc_Obj_t * pNode ) ...@@ -387,6 +411,7 @@ extern bool Abc_AigNodeHasComplFanoutEdgeTrav( Abc_Obj_t * pNode )
extern int Abc_NtkAttach( Abc_Ntk_t * pNtk ); extern int Abc_NtkAttach( Abc_Ntk_t * pNtk );
/*=== abcCheck.c ==========================================================*/ /*=== abcCheck.c ==========================================================*/
extern bool Abc_NtkCheck( Abc_Ntk_t * pNtk ); extern bool Abc_NtkCheck( Abc_Ntk_t * pNtk );
extern bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj );
extern bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ); extern bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
/*=== abcCollapse.c ==========================================================*/ /*=== abcCollapse.c ==========================================================*/
extern Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose ); extern Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fVerbose );
...@@ -424,9 +449,9 @@ extern Abc_Obj_t * Abc_NodeCreateOr( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanin ...@@ -424,9 +449,9 @@ extern Abc_Obj_t * Abc_NodeCreateOr( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanin
extern Abc_Obj_t * Abc_NodeCreateMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0 ); extern Abc_Obj_t * Abc_NodeCreateMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0 );
extern Abc_Obj_t * Abc_NodeClone( Abc_Obj_t * pNode ); extern Abc_Obj_t * Abc_NodeClone( Abc_Obj_t * pNode );
/*=== abcDfs.c ==========================================================*/ /*=== abcDfs.c ==========================================================*/
extern Vec_Ptr_t * Abc_NtkDfs( Abc_Ntk_t * pNtk ); extern Vec_Ptr_t * Abc_NtkDfs( Abc_Ntk_t * pNtk, int fCollectAll );
extern Vec_Ptr_t * Abc_NtkDfsNodes( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNodes ); extern Vec_Ptr_t * Abc_NtkDfsNodes( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNodes );
extern Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk ); extern Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk, int fCollectAll );
extern Vec_Ptr_t * Abc_DfsLevelized( Abc_Obj_t * pNode, bool fTfi ); extern Vec_Ptr_t * Abc_DfsLevelized( Abc_Obj_t * pNode, bool fTfi );
extern int Abc_NtkGetLevelNum( Abc_Ntk_t * pNtk ); extern int Abc_NtkGetLevelNum( Abc_Ntk_t * pNtk );
extern bool Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk ); extern bool Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk );
...@@ -490,6 +515,8 @@ extern void Abc_NtkPrintFanio( FILE * pFile, Abc_Ntk_t * pNtk ); ...@@ -490,6 +515,8 @@ extern void Abc_NtkPrintFanio( FILE * pFile, Abc_Ntk_t * pNtk );
extern void Abc_NodePrintFanio( FILE * pFile, Abc_Obj_t * pNode ); extern void Abc_NodePrintFanio( FILE * pFile, Abc_Obj_t * pNode );
extern void Abc_NtkPrintFactor( FILE * pFile, Abc_Ntk_t * pNtk ); extern void Abc_NtkPrintFactor( FILE * pFile, Abc_Ntk_t * pNtk );
extern void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode ); extern void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode );
extern void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile );
extern void Abc_NodePrintLevel( FILE * pFile, Abc_Obj_t * pNode );
/*=== abcRefs.c ==========================================================*/ /*=== abcRefs.c ==========================================================*/
extern int Abc_NodeMffcSize( Abc_Obj_t * pNode ); extern int Abc_NodeMffcSize( Abc_Obj_t * pNode );
extern int Abc_NodeMffcRemove( Abc_Obj_t * pNode ); extern int Abc_NodeMffcRemove( Abc_Obj_t * pNode );
...@@ -588,10 +615,10 @@ extern void Abc_NodeCollectFanins( Abc_Obj_t * pNode, Vec_Ptr_t * ...@@ -588,10 +615,10 @@ extern void Abc_NodeCollectFanins( Abc_Obj_t * pNode, Vec_Ptr_t *
extern void Abc_NodeCollectFanouts( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes ); extern void Abc_NodeCollectFanouts( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes );
extern int Abc_NodeCompareLevelsIncrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 ); extern int Abc_NodeCompareLevelsIncrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 );
extern int Abc_NodeCompareLevelsDecrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 ); extern int Abc_NodeCompareLevelsDecrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 );
extern Vec_Ptr_t * Abc_AigCollectAll( Abc_Ntk_t * pNtk );
extern Vec_Ptr_t * Abc_NodeGetFaninNames( Abc_Obj_t * pNode ); extern Vec_Ptr_t * Abc_NodeGetFaninNames( Abc_Obj_t * pNode );
extern void Abc_NodeFreeFaninNames( Vec_Ptr_t * vNames ); extern void Abc_NodeFreeFaninNames( Vec_Ptr_t * vNames );
extern char ** Abc_NtkCollectCioNames( Abc_Ntk_t * pNtk, int fCollectCos ); extern char ** Abc_NtkCollectCioNames( Abc_Ntk_t * pNtk, int fCollectCos );
extern void Abc_NtkAlphaOrderSignals( Abc_Ntk_t * pNtk, int fComb );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -97,7 +97,7 @@ static void Abc_AigDelete_int( Abc_Aig_t * pMan ); ...@@ -97,7 +97,7 @@ static void Abc_AigDelete_int( Abc_Aig_t * pMan );
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtkAig, bool fSeq ) Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtkAig )
{ {
Abc_Aig_t * pMan; Abc_Aig_t * pMan;
// start the manager // start the manager
...@@ -113,8 +113,11 @@ Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtkAig, bool fSeq ) ...@@ -113,8 +113,11 @@ Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtkAig, bool fSeq )
pMan->vStackReplaceNew = Vec_PtrAlloc( 100 ); pMan->vStackReplaceNew = Vec_PtrAlloc( 100 );
// save the current network // save the current network
pMan->pNtkAig = pNtkAig; pMan->pNtkAig = pNtkAig;
// allocate constant nodes
pMan->pConst1 = Abc_NtkCreateNode( pNtkAig ); pMan->pConst1 = Abc_NtkCreateNode( pNtkAig );
pMan->pReset = fSeq? Abc_NtkCreateNode( pNtkAig ) : NULL; pMan->pReset = Abc_NtkCreateNode( pNtkAig );
// subtract these nodes from the total number
pNtkAig->nNodes -= 2;
return pMan; return pMan;
} }
...@@ -122,19 +125,54 @@ Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtkAig, bool fSeq ) ...@@ -122,19 +125,54 @@ Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtkAig, bool fSeq )
Synopsis [Duplicated the AIG manager.] Synopsis [Duplicated the AIG manager.]
Description [] Description [Assumes that CI/CO nodes are already created.
Transfers the latch attributes on the edges.]
SideEffects [] SideEffects []
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Aig_t * Abc_AigDup( Abc_Aig_t * pMan, bool fSeq ) Abc_Aig_t * Abc_AigDup( Abc_Aig_t * pMan, Abc_Aig_t * pManNew )
{ {
Abc_Aig_t * pManNew; Vec_Ptr_t * vNodes;
pManNew = Abc_AigAlloc( pMan->pNtkAig, fSeq ); Abc_Obj_t * pObj;
int i;
assert( Abc_NtkCiNum(pMan->pNtkAig) == Abc_NtkCiNum(pManNew->pNtkAig) );
assert( Abc_NtkCoNum(pMan->pNtkAig) == Abc_NtkCoNum(pManNew->pNtkAig) );
assert( Abc_NtkLatchNum(pMan->pNtkAig) == Abc_NtkLatchNum(pManNew->pNtkAig) );
// set mapping of the constant nodes
Abc_AigConst1( pMan )->pCopy = Abc_AigConst1( pManNew );
Abc_AigReset( pMan )->pCopy = Abc_AigReset( pManNew );
// set the mapping of CIs/COs
Abc_NtkForEachPi( pMan->pNtkAig, pObj, i )
pObj->pCopy = Abc_NtkPi( pManNew->pNtkAig, i );
Abc_NtkForEachPo( pMan->pNtkAig, pObj, i )
pObj->pCopy = Abc_NtkPo( pManNew->pNtkAig, i );
Abc_NtkForEachLatch( pMan->pNtkAig, pObj, i )
pObj->pCopy = Abc_NtkLatch( pManNew->pNtkAig, i );
// copy internal nodes
vNodes = Abc_AigDfs( pMan->pNtkAig, 1 );
Vec_PtrForEachEntry( vNodes, pObj, i )
{
if ( !Abc_NodeIsAigAnd(pObj) )
continue;
pObj->pCopy = Abc_AigAnd( pManNew, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// transfer latch attributes
Abc_ObjSetFaninL0( pObj->pCopy, Abc_ObjFaninL0(pObj) );
Abc_ObjSetFaninL1( pObj->pCopy, Abc_ObjFaninL1(pObj) );
}
Vec_PtrFree( vNodes );
// relink the CO nodes
Abc_NtkForEachCo( pMan->pNtkAig, pObj, i )
{
Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
Abc_ObjSetFaninL0( pObj->pCopy, Abc_ObjFaninL0(pObj) );
}
// get the number of nodes before and after
if ( Abc_NtkNodeNum(pMan->pNtkAig) != Abc_NtkNodeNum(pManNew->pNtkAig) )
printf( "Warning: Structural hashing reduced %d nodes (should not happen).\n",
Abc_NtkNodeNum(pMan->pNtkAig) - Abc_NtkNodeNum(pManNew->pNtkAig) );
return pManNew; return pManNew;
} }
...@@ -183,7 +221,10 @@ int Abc_AigCleanup( Abc_Aig_t * pMan ) ...@@ -183,7 +221,10 @@ int Abc_AigCleanup( Abc_Aig_t * pMan )
for ( i = 0; i < pMan->nBins; i++ ) for ( i = 0; i < pMan->nBins; i++ )
Abc_AigBinForEachEntry( pMan->pBins[i], pAnd ) Abc_AigBinForEachEntry( pMan->pBins[i], pAnd )
if ( Abc_ObjFanoutNum(pAnd) == 0 ) if ( Abc_ObjFanoutNum(pAnd) == 0 )
{
Vec_PtrPush( pMan->vStackDelete, pAnd ); Vec_PtrPush( pMan->vStackDelete, pAnd );
pAnd->fMarkA = 1;
}
// process the dangling nodes and their MFFCs // process the dangling nodes and their MFFCs
for ( Counter = 0; Vec_PtrSize(pMan->vStackDelete) > 0; Counter++ ) for ( Counter = 0; Vec_PtrSize(pMan->vStackDelete) > 0; Counter++ )
Abc_AigDelete_int( pMan ); Abc_AigDelete_int( pMan );
...@@ -239,7 +280,7 @@ bool Abc_AigCheck( Abc_Aig_t * pMan ) ...@@ -239,7 +280,7 @@ bool Abc_AigCheck( Abc_Aig_t * pMan )
for ( i = 0; i < pMan->nBins; i++ ) for ( i = 0; i < pMan->nBins; i++ )
Abc_AigBinForEachEntry( pMan->pBins[i], pAnd ) Abc_AigBinForEachEntry( pMan->pBins[i], pAnd )
Counter++; Counter++;
if ( Counter + 1 + Abc_NtkIsSeq(pMan->pNtkAig) != Abc_NtkNodeNum(pMan->pNtkAig) ) if ( Counter != Abc_NtkNodeNum(pMan->pNtkAig) )
{ {
printf( "Abc_AigCheck: The number of nodes in the structural hashing table is wrong.\n", Counter ); printf( "Abc_AigCheck: The number of nodes in the structural hashing table is wrong.\n", Counter );
return 0; return 0;
...@@ -329,10 +370,11 @@ Abc_Obj_t * Abc_AigAndCreate( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 ) ...@@ -329,10 +370,11 @@ Abc_Obj_t * Abc_AigAndCreate( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 )
***********************************************************************/ ***********************************************************************/
Abc_Obj_t * Abc_AigAndCreateFrom( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1, Abc_Obj_t * pAnd ) Abc_Obj_t * Abc_AigAndCreateFrom( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1, Abc_Obj_t * pAnd )
{ {
Abc_Obj_t * pTemp;
unsigned Key; unsigned Key;
// order the arguments // order the arguments
if ( Abc_ObjRegular(p0)->Id > Abc_ObjRegular(p1)->Id ) if ( Abc_ObjRegular(p0)->Id > Abc_ObjRegular(p1)->Id )
pAnd = p0, p0 = p1, p1 = pAnd; pTemp = p0, p0 = p1, p1 = pTemp;
// create the new node // create the new node
Abc_ObjAddFanin( pAnd, p0 ); Abc_ObjAddFanin( pAnd, p0 );
Abc_ObjAddFanin( pAnd, p1 ); Abc_ObjAddFanin( pAnd, p1 );
...@@ -384,10 +426,7 @@ Abc_Obj_t * Abc_AigAndLookup( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 ) ...@@ -384,10 +426,7 @@ Abc_Obj_t * Abc_AigAndLookup( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 )
Key = Abc_HashKey2( p0, p1, pMan->nBins ); Key = Abc_HashKey2( p0, p1, pMan->nBins );
// find the mataching node in the table // find the mataching node in the table
Abc_AigBinForEachEntry( pMan->pBins[Key], pAnd ) Abc_AigBinForEachEntry( pMan->pBins[Key], pAnd )
if ( Abc_ObjFanin0(pAnd) == Abc_ObjRegular(p0) && if ( p0 == Abc_ObjChild0(pAnd) && p1 == Abc_ObjChild1(pAnd) )
Abc_ObjFanin1(pAnd) == Abc_ObjRegular(p1) &&
Abc_ObjFaninC0(pAnd) == Abc_ObjIsComplement(p0) &&
Abc_ObjFaninC1(pAnd) == Abc_ObjIsComplement(p1) )
return pAnd; return pAnd;
return NULL; return NULL;
} }
...@@ -408,7 +447,6 @@ void Abc_AigAndDelete( Abc_Aig_t * pMan, Abc_Obj_t * pThis ) ...@@ -408,7 +447,6 @@ void Abc_AigAndDelete( Abc_Aig_t * pMan, Abc_Obj_t * pThis )
Abc_Obj_t * pAnd, ** ppPlace; Abc_Obj_t * pAnd, ** ppPlace;
unsigned Key; unsigned Key;
assert( !Abc_ObjIsComplement(pThis) ); assert( !Abc_ObjIsComplement(pThis) );
assert( Abc_ObjFanoutNum(pThis) == 0 );
assert( pMan->pNtkAig == pThis->pNtk ); assert( pMan->pNtkAig == pThis->pNtk );
// get the hash key for these two nodes // get the hash key for these two nodes
Key = Abc_HashKey2( Abc_ObjChild0(pThis), Abc_ObjChild1(pThis), pMan->nBins ); Key = Abc_HashKey2( Abc_ObjChild0(pThis), Abc_ObjChild1(pThis), pMan->nBins );
...@@ -454,7 +492,7 @@ clk = clock(); ...@@ -454,7 +492,7 @@ clk = clock();
for ( i = 0; i < pMan->nBins; i++ ) for ( i = 0; i < pMan->nBins; i++ )
Abc_AigBinForEachEntrySafe( pMan->pBins[i], pEnt, pEnt2 ) Abc_AigBinForEachEntrySafe( pMan->pBins[i], pEnt, pEnt2 )
{ {
Key = Abc_HashKey2( Abc_ObjFanin(pEnt,0), Abc_ObjFanin(pEnt,1), nBinsNew ); Key = Abc_HashKey2( Abc_ObjChild0(pEnt), Abc_ObjChild1(pEnt), nBinsNew );
pEnt->pNext = pBinsNew[Key]; pEnt->pNext = pBinsNew[Key];
pBinsNew[Key] = pEnt; pBinsNew[Key] = pEnt;
Counter++; Counter++;
...@@ -597,7 +635,7 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan ) ...@@ -597,7 +635,7 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan )
pNew = Vec_PtrPop( pMan->vStackReplaceNew ); pNew = Vec_PtrPop( pMan->vStackReplaceNew );
// make sure the old node is regular and has fanouts // make sure the old node is regular and has fanouts
// the new node can be complemented and can have fanouts // the new node can be complemented and can have fanouts
assert( !Abc_ObjIsComplement(pOld) == 0 ); assert( !Abc_ObjIsComplement(pOld) );
assert( Abc_ObjFanoutNum(pOld) > 0 ); assert( Abc_ObjFanoutNum(pOld) > 0 );
// look at the fanouts of old node // look at the fanouts of old node
Abc_NodeCollectFanouts( pOld, pMan->vNodes ); Abc_NodeCollectFanouts( pOld, pMan->vNodes );
...@@ -632,7 +670,11 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan ) ...@@ -632,7 +670,11 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan )
Abc_AigAndCreateFrom( pMan, pFanin1, pFanin2, pFanout ); Abc_AigAndCreateFrom( pMan, pFanin1, pFanin2, pFanout );
} }
// schedule deletion of the old node // schedule deletion of the old node
if ( Abc_NodeIsAigAnd(pOld) && pOld->fMarkA == 0 )
{
Vec_PtrPush( pMan->vStackDelete, pOld ); Vec_PtrPush( pMan->vStackDelete, pOld );
pOld->fMarkA = 1;
}
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -653,18 +695,21 @@ void Abc_AigDelete_int( Abc_Aig_t * pMan ) ...@@ -653,18 +695,21 @@ void Abc_AigDelete_int( Abc_Aig_t * pMan )
// get the node to delete // get the node to delete
assert( Vec_PtrSize(pMan->vStackDelete) > 0 ); assert( Vec_PtrSize(pMan->vStackDelete) > 0 );
pNode = Vec_PtrPop( pMan->vStackDelete ); pNode = Vec_PtrPop( pMan->vStackDelete );
// make sure the node is regular and dangling // make sure the node is regular and dangling
assert( !Abc_ObjIsComplement(pNode) == 0 ); assert( !Abc_ObjIsComplement(pNode) );
assert( Abc_ObjFanoutNum(pNode) == 0 ); assert( Abc_ObjFanoutNum(pNode) == 0 );
// skip the constant node assert( pNode != pMan->pConst1 );
if ( pNode == pMan->pConst1 )
return;
// schedule fanins for deletion if they dangle // schedule fanins for deletion if they dangle
Abc_ObjForEachFanin( pNode, pFanin, k ) Abc_ObjForEachFanin( pNode, pFanin, k )
{ {
assert( Abc_ObjFanoutNum(pFanin) > 0 ); assert( Abc_ObjFanoutNum(pFanin) > 0 );
if ( Abc_ObjFanoutNum(pFanin) == 1 ) if ( Abc_ObjFanoutNum(pFanin) == 1 )
if ( Abc_NodeIsAigAnd(pFanin) && pFanin->fMarkA == 0 )
{
Vec_PtrPush( pMan->vStackDelete, pFanin ); Vec_PtrPush( pMan->vStackDelete, pFanin );
pFanin->fMarkA = 1;
}
} }
// remove the node from the table // remove the node from the table
Abc_AigAndDelete( pMan, pNode ); Abc_AigAndDelete( pMan, pNode );
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
static bool Abc_NtkCheckNames( Abc_Ntk_t * pNtk ); static bool Abc_NtkCheckNames( Abc_Ntk_t * pNtk );
static bool Abc_NtkCheckPis( Abc_Ntk_t * pNtk ); static bool Abc_NtkCheckPis( Abc_Ntk_t * pNtk );
static bool Abc_NtkCheckPos( Abc_Ntk_t * pNtk ); static bool Abc_NtkCheckPos( Abc_Ntk_t * pNtk );
static bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj ); //static bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj );
static bool Abc_NtkCheckNet( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet ); static bool Abc_NtkCheckNet( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet );
static bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode ); static bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode );
static bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch ); static bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch );
...@@ -57,7 +57,7 @@ bool Abc_NtkCheck( Abc_Ntk_t * pNtk ) ...@@ -57,7 +57,7 @@ bool Abc_NtkCheck( Abc_Ntk_t * pNtk )
Abc_Obj_t * pObj, * pNet, * pNode; Abc_Obj_t * pObj, * pNet, * pNode;
int i; int i;
if ( !Abc_NtkIsNetlist(pNtk) && !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsAig(pNtk) ) if ( !Abc_NtkIsNetlist(pNtk) && !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsAig(pNtk) && !Abc_NtkIsSeq(pNtk) )
{ {
fprintf( stdout, "NetworkCheck: Unknown network type.\n" ); fprintf( stdout, "NetworkCheck: Unknown network type.\n" );
return 0; return 0;
...@@ -110,9 +110,18 @@ bool Abc_NtkCheck( Abc_Ntk_t * pNtk ) ...@@ -110,9 +110,18 @@ bool Abc_NtkCheck( Abc_Ntk_t * pNtk )
} }
// check the nodes // check the nodes
if ( Abc_NtkIsAig(pNtk) || Abc_NtkIsSeq(pNtk) )
{
if ( Abc_NtkIsAig(pNtk) )
Abc_AigCheck( pNtk->pManFunc );
}
else
{
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
if ( !Abc_NtkCheckNode( pNtk, pNode ) ) if ( !Abc_NtkCheckNode( pNtk, pNode ) )
return 0; return 0;
}
// check the latches // check the latches
Abc_NtkForEachLatch( pNtk, pNode, i ) Abc_NtkForEachLatch( pNtk, pNode, i )
if ( !Abc_NtkCheckLatch( pNtk, pNode ) ) if ( !Abc_NtkCheckLatch( pNtk, pNode ) )
...@@ -120,7 +129,7 @@ bool Abc_NtkCheck( Abc_Ntk_t * pNtk ) ...@@ -120,7 +129,7 @@ bool Abc_NtkCheck( Abc_Ntk_t * pNtk )
// finally, check for combinational loops // finally, check for combinational loops
// clk = clock(); // clk = clock();
if ( !Abc_NtkIsAcyclic( pNtk ) ) if ( !Abc_NtkIsSeq( pNtk ) && !Abc_NtkIsAcyclic( pNtk ) )
{ {
fprintf( stdout, "NetworkCheck: Network contains a combinational loop.\n" ); fprintf( stdout, "NetworkCheck: Network contains a combinational loop.\n" );
return 0; return 0;
...@@ -352,7 +361,7 @@ bool Abc_NtkCheckPos( Abc_Ntk_t * pNtk ) ...@@ -352,7 +361,7 @@ bool Abc_NtkCheckPos( Abc_Ntk_t * pNtk )
bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj ) bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj )
{ {
Abc_Obj_t * pFanin, * pFanout; Abc_Obj_t * pFanin, * pFanout;
int i, Value = 1; int i, k, Value = 1;
// check the network // check the network
if ( pObj->pNtk != pNtk ) if ( pObj->pNtk != pNtk )
...@@ -361,7 +370,7 @@ bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj ) ...@@ -361,7 +370,7 @@ bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj )
return 0; return 0;
} }
// check the object ID // check the object ID
if ( pObj->Id < 0 || (int)pObj->Id > pNtk->vObjs->nSize ) if ( pObj->Id < 0 || (int)pObj->Id >= Abc_NtkObjNumMax(pNtk) )
{ {
fprintf( stdout, "NetworkCheck: Object \"%s\" has incorrect ID.\n", Abc_ObjName(pObj) ); fprintf( stdout, "NetworkCheck: Object \"%s\" has incorrect ID.\n", Abc_ObjName(pObj) );
return 0; return 0;
...@@ -386,6 +395,24 @@ bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj ) ...@@ -386,6 +395,24 @@ bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj )
Value = 0; Value = 0;
} }
} }
/*
// make sure fanins are not duplicated
for ( i = 0; i < pObj->vFanins.nSize; i++ )
for ( k = i + 1; k < pObj->vFanins.nSize; k++ )
if ( pObj->vFanins.pArray[k].iFan == pObj->vFanins.pArray[i].iFan )
{
printf( "Warning: Node %s has", Abc_ObjName(pObj) );
printf( " duplicated fanin %s.\n", Abc_ObjName(Abc_ObjFanin(pObj,k)) );
}
// make sure fanouts are not duplicated
for ( i = 0; i < pObj->vFanouts.nSize; i++ )
for ( k = i + 1; k < pObj->vFanouts.nSize; k++ )
if ( pObj->vFanouts.pArray[k].iFan == pObj->vFanouts.pArray[i].iFan )
{
printf( "Warning: Node %s has", Abc_ObjName(pObj) );
printf( " duplicated fanout %s.\n", Abc_ObjName(Abc_ObjFanout(pObj,k)) );
}
*/
return Value; return Value;
} }
...@@ -435,9 +462,9 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode ) ...@@ -435,9 +462,9 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
return 0; return 0;
} }
// the node should have a function assigned unless it is an AIG // the node should have a function assigned unless it is an AIG
if ( pNode->pData == NULL && !Abc_NtkIsAig(pNtk) ) if ( pNode->pData == NULL )
{ {
fprintf( stdout, "NodeCheck: An internal node \"%s\" has no logic function.\n", Abc_ObjName(pNode) ); fprintf( stdout, "NodeCheck: An internal node \"%s\" does not have a logic function.\n", Abc_ObjName(pNode) );
return 0; return 0;
} }
// the netlist and SOP logic network should have SOPs // the netlist and SOP logic network should have SOPs
...@@ -458,7 +485,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode ) ...@@ -458,7 +485,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
return 0; return 0;
} }
} }
else if ( !Abc_NtkIsAig(pNtk) && !Abc_NtkIsLogicMap(pNtk) && !Abc_NtkIsNetlistMap(pNtk) ) else if ( !Abc_NtkIsMapped(pNtk) )
{ {
assert( 0 ); assert( 0 );
} }
...@@ -562,7 +589,7 @@ bool Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ) ...@@ -562,7 +589,7 @@ bool Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
printf( "Networks have different number of primary outputs.\n" ); printf( "Networks have different number of primary outputs.\n" );
return 0; return 0;
} }
// for each PI of pNet1 find corresponding PI of pNet2 and reorder them // for each PO of pNet1 find corresponding PO of pNet2 and reorder them
Abc_NtkForEachPo( pNtk1, pObj1, i ) Abc_NtkForEachPo( pNtk1, pObj1, i )
{ {
if ( strcmp( Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkPo(pNtk2,i)) ) != 0 ) if ( strcmp( Abc_ObjName(pObj1), Abc_ObjName(Abc_NtkPo(pNtk2,i)) ) != 0 )
...@@ -623,12 +650,14 @@ bool Abc_NtkCompareLatches( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ) ...@@ -623,12 +650,14 @@ bool Abc_NtkCompareLatches( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
***********************************************************************/ ***********************************************************************/
bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ) bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
{ {
Abc_NtkAlphaOrderSignals( pNtk1, fComb );
Abc_NtkAlphaOrderSignals( pNtk2, fComb );
if ( !Abc_NtkCompareLatches( pNtk1, pNtk2, fComb ) ) if ( !Abc_NtkCompareLatches( pNtk1, pNtk2, fComb ) )
return 0; return 0;
if ( !Abc_NtkComparePis( pNtk1, pNtk2, fComb ) ) if ( !Abc_NtkComparePis( pNtk1, pNtk2, fComb ) )
return 0; return 0;
// if ( !Abc_NtkComparePos( pNtk1, pNtk2, fComb ) ) if ( !Abc_NtkComparePos( pNtk1, pNtk2, fComb ) )
// return 0; return 0;
return 1; return 1;
} }
......
...@@ -75,10 +75,8 @@ Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type ) ...@@ -75,10 +75,8 @@ Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type )
pNtk->pManFunc = Extra_MmFlexStart(); pNtk->pManFunc = Extra_MmFlexStart();
else if ( Abc_NtkIsLogicBdd(pNtk) ) else if ( Abc_NtkIsLogicBdd(pNtk) )
pNtk->pManFunc = Cudd_Init( 20, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); pNtk->pManFunc = Cudd_Init( 20, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
else if ( Abc_NtkIsAig(pNtk) ) else if ( Abc_NtkIsAig(pNtk) || Abc_NtkIsSeq(pNtk) )
pNtk->pManFunc = Abc_AigAlloc( pNtk, 0 ); pNtk->pManFunc = Abc_AigAlloc( pNtk );
else if ( Abc_NtkIsSeq(pNtk) )
pNtk->pManFunc = Abc_AigAlloc( pNtk, 1 );
else if ( Abc_NtkIsMapped(pNtk) ) else if ( Abc_NtkIsMapped(pNtk) )
pNtk->pManFunc = Abc_FrameReadLibGen(Abc_FrameGetGlobalFrame()); pNtk->pManFunc = Abc_FrameReadLibGen(Abc_FrameGetGlobalFrame());
else else
...@@ -245,27 +243,21 @@ Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk ) ...@@ -245,27 +243,21 @@ Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk )
int i, k; int i, k;
if ( pNtk == NULL ) if ( pNtk == NULL )
return NULL; return NULL;
assert( !Abc_NtkIsSeq(pNtk) );
// start the network // start the network
pNtkNew = Abc_NtkStartFrom( pNtk, pNtk->Type ); pNtkNew = Abc_NtkStartFrom( pNtk, pNtk->Type );
// duplicate the nets and nodes // copy the internal nodes
if ( Abc_NtkIsAig(pNtk) )
Abc_AigDup( pNtk->pManFunc, pNtkNew->pManFunc );
else
{
// duplicate the nets and nodes (CIs/COs/latches already dupped)
Abc_NtkForEachObj( pNtk, pObj, i ) Abc_NtkForEachObj( pNtk, pObj, i )
if ( pObj->pCopy == NULL ) if ( pObj->pCopy == NULL )
Abc_NtkDupObj(pNtkNew, pObj); Abc_NtkDupObj(pNtkNew, pObj);
// connect the objects // reconnect all objects (no need to transfer attributes on edges)
Abc_NtkForEachObj( pNtk, pObj, i ) Abc_NtkForEachObj( pNtk, pObj, i )
Abc_ObjForEachFanin( pObj, pFanin, k ) Abc_ObjForEachFanin( pObj, pFanin, k )
Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy ); Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
// for AIGs copy the complemented attributes
if ( Abc_NtkIsAig(pNtk) )
{
// set the data pointers and complemented attributes
Abc_NtkForEachObj( pNtk, pObj, i )
Abc_ObjForEachFanin( pObj, pFanin, k )
if ( Abc_ObjFaninC( pObj, k ) )
Abc_ObjSetFaninC( pObj->pCopy, k );
// add the nodes to the structural hashing table
// TODO ???
} }
// duplicate the EXDC Ntk // duplicate the EXDC Ntk
if ( pNtk->pExdc ) if ( pNtk->pExdc )
...@@ -324,9 +316,7 @@ Abc_Ntk_t * Abc_NtkSplitOutput( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, int fUseAll ...@@ -324,9 +316,7 @@ Abc_Ntk_t * Abc_NtkSplitOutput( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, int fUseAll
// if it is an AIG, add to the hash table // if it is an AIG, add to the hash table
if ( Abc_NtkIsAig(pNtk) ) if ( Abc_NtkIsAig(pNtk) )
{ {
pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
Abc_ObjNotCond( Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) ),
Abc_ObjNotCond( Abc_ObjFanin1(pObj)->pCopy, Abc_ObjFaninC1(pObj) ) );
} }
else else
{ {
...@@ -415,7 +405,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk ) ...@@ -415,7 +405,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
Extra_MmFlexStop( pNtk->pManFunc, 0 ); Extra_MmFlexStop( pNtk->pManFunc, 0 );
else if ( Abc_NtkIsLogicBdd(pNtk) ) else if ( Abc_NtkIsLogicBdd(pNtk) )
Extra_StopManager( pNtk->pManFunc ); Extra_StopManager( pNtk->pManFunc );
else if ( Abc_NtkIsAig(pNtk) ) else if ( Abc_NtkIsAig(pNtk) || Abc_NtkIsSeq(pNtk) )
Abc_AigFree( pNtk->pManFunc ); Abc_AigFree( pNtk->pManFunc );
else if ( !Abc_NtkIsMapped(pNtk) ) else if ( !Abc_NtkIsMapped(pNtk) )
assert( 0 ); assert( 0 );
...@@ -598,7 +588,7 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj ) ...@@ -598,7 +588,7 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
pObjNew->pData = Cudd_bddTransfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData), Cudd_Ref(pObjNew->pData); pObjNew->pData = Cudd_bddTransfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData), Cudd_Ref(pObjNew->pData);
else if ( Abc_NtkIsMapped(pNtkNew) ) else if ( Abc_NtkIsMapped(pNtkNew) )
pObjNew->pData = pObj->pData; pObjNew->pData = pObj->pData;
else if ( !Abc_NtkIsAig(pNtkNew) ) else if ( !Abc_NtkIsAig(pNtkNew) && !Abc_NtkIsSeq(pNtkNew) )
assert( 0 ); assert( 0 );
} }
} }
...@@ -626,9 +616,10 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj ) ...@@ -626,9 +616,10 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
Abc_Obj_t * Abc_NtkDupConst1( Abc_Ntk_t * pNtkAig, Abc_Ntk_t * pNtkNew ) Abc_Obj_t * Abc_NtkDupConst1( Abc_Ntk_t * pNtkAig, Abc_Ntk_t * pNtkNew )
{ {
Abc_Obj_t * pConst1; Abc_Obj_t * pConst1;
assert( Abc_NtkIsAig(pNtkAig) ); assert( Abc_NtkIsAig(pNtkAig) || Abc_NtkIsSeq(pNtkAig) );
assert( Abc_NtkIsLogicSop(pNtkNew) );
pConst1 = Abc_AigConst1(pNtkAig->pManFunc); pConst1 = Abc_AigConst1(pNtkAig->pManFunc);
if ( Abc_ObjFanoutNum( pConst1 ) > 0 ) if ( Abc_ObjFanoutNum(pConst1) > 0 )
pConst1->pCopy = Abc_NodeCreateConst1( pNtkNew ); pConst1->pCopy = Abc_NodeCreateConst1( pNtkNew );
return pConst1->pCopy; return pConst1->pCopy;
} }
...@@ -647,16 +638,16 @@ Abc_Obj_t * Abc_NtkDupConst1( Abc_Ntk_t * pNtkAig, Abc_Ntk_t * pNtkNew ) ...@@ -647,16 +638,16 @@ Abc_Obj_t * Abc_NtkDupConst1( Abc_Ntk_t * pNtkAig, Abc_Ntk_t * pNtkNew )
Abc_Obj_t * Abc_NtkDupReset( Abc_Ntk_t * pNtkAig, Abc_Ntk_t * pNtkNew ) Abc_Obj_t * Abc_NtkDupReset( Abc_Ntk_t * pNtkAig, Abc_Ntk_t * pNtkNew )
{ {
Abc_Obj_t * pReset, * pConst1; Abc_Obj_t * pReset, * pConst1;
assert( Abc_NtkIsAig(pNtkAig) ); assert( Abc_NtkIsAig(pNtkAig) || Abc_NtkIsSeq(pNtkAig) );
assert( Abc_NtkIsLogicSop(pNtkNew) ); assert( Abc_NtkIsLogicSop(pNtkNew) );
pReset = Abc_AigReset(pNtkAig->pManFunc); pReset = Abc_AigReset(pNtkAig->pManFunc);
if ( Abc_ObjFanoutNum( pReset ) > 0 ) if ( Abc_ObjFanoutNum(pReset) > 0 )
{ {
// create new latch with reset value 0 // create new latch with reset value 0
pReset->pCopy = Abc_NtkCreateLatch( pNtkNew ); pReset->pCopy = Abc_NtkCreateLatch( pNtkNew );
// add constant node fanin to the latch // add constant node fanin to the latch
pConst1 = Abc_AigConst1(pNtkAig->pManFunc); pConst1 = Abc_NodeCreateConst1( pNtkNew );
Abc_ObjAddFanin( pReset->pCopy, pConst1->pCopy ); Abc_ObjAddFanin( pReset->pCopy, pConst1 );
} }
return pReset->pCopy; return pReset->pCopy;
} }
...@@ -712,7 +703,6 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj ) ...@@ -712,7 +703,6 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj )
else if ( Abc_ObjIsLatch(pObj) ) else if ( Abc_ObjIsLatch(pObj) )
{ {
pNtk->nLatches--; pNtk->nLatches--;
assert( 0 ); // currently do not allow removing latches
} }
else else
assert( 0 ); assert( 0 );
...@@ -772,7 +762,7 @@ Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName ) ...@@ -772,7 +762,7 @@ Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName )
return NULL; return NULL;
} }
Num = atoi( pName + 1 ); Num = atoi( pName + 1 );
if ( Num < 0 || Num > Abc_NtkObjNum(pNtk) ) if ( Num < 0 || Num >= Abc_NtkObjNumMax(pNtk) )
{ {
printf( "The node \"%s\" with ID %d is not in the current network.\n", pName, Num ); printf( "The node \"%s\" with ID %d is not in the current network.\n", pName, Num );
return NULL; return NULL;
......
...@@ -46,7 +46,7 @@ static bool Abc_NtkIsAcyclic_rec( Abc_Obj_t * pNode ); ...@@ -46,7 +46,7 @@ static bool Abc_NtkIsAcyclic_rec( Abc_Obj_t * pNode );
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Vec_Ptr_t * Abc_NtkDfs( Abc_Ntk_t * pNtk ) Vec_Ptr_t * Abc_NtkDfs( Abc_Ntk_t * pNtk, int fCollectAll )
{ {
Vec_Ptr_t * vNodes; Vec_Ptr_t * vNodes;
Abc_Obj_t * pNode; Abc_Obj_t * pNode;
...@@ -60,6 +60,13 @@ Vec_Ptr_t * Abc_NtkDfs( Abc_Ntk_t * pNtk ) ...@@ -60,6 +60,13 @@ Vec_Ptr_t * Abc_NtkDfs( Abc_Ntk_t * pNtk )
Abc_NodeSetTravIdCurrent( pNode ); Abc_NodeSetTravIdCurrent( pNode );
Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(pNode)), vNodes ); Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(pNode)), vNodes );
} }
// collect dangling nodes if asked to
if ( fCollectAll )
{
Abc_NtkForEachNode( pNtk, pNode, i )
if ( !Abc_NodeIsTravIdCurrent(pNode) )
Abc_NtkDfs_rec( pNode, vNodes );
}
return vNodes; return vNodes;
} }
...@@ -141,12 +148,12 @@ void Abc_NtkDfs_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes ) ...@@ -141,12 +148,12 @@ void Abc_NtkDfs_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk ) Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk, int fCollectAll )
{ {
Vec_Ptr_t * vNodes; Vec_Ptr_t * vNodes;
Abc_Obj_t * pNode; Abc_Obj_t * pNode;
int i; int i;
assert( Abc_NtkIsAig(pNtk) ); assert( Abc_NtkIsAig(pNtk) || Abc_NtkIsSeq(pNtk) );
// set the traversal ID // set the traversal ID
Abc_NtkIncrementTravId( pNtk ); Abc_NtkIncrementTravId( pNtk );
// start the array of nodes // start the array of nodes
...@@ -157,6 +164,13 @@ Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk ) ...@@ -157,6 +164,13 @@ Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk )
Abc_NodeSetTravIdCurrent( pNode ); Abc_NodeSetTravIdCurrent( pNode );
Abc_AigDfs_rec( Abc_ObjFanin0(pNode), vNodes ); Abc_AigDfs_rec( Abc_ObjFanin0(pNode), vNodes );
} }
// collect dangling nodes if asked to
if ( fCollectAll )
{
Abc_NtkForEachNode( pNtk, pNode, i )
if ( !Abc_NodeIsTravIdCurrent(pNode) )
Abc_AigDfs_rec( pNode, vNodes );
}
return vNodes; return vNodes;
} }
...@@ -308,7 +322,7 @@ int Abc_NtkGetLevelNum( Abc_Ntk_t * pNtk ) ...@@ -308,7 +322,7 @@ int Abc_NtkGetLevelNum( Abc_Ntk_t * pNtk )
int Abc_NtkGetLevelNum_rec( Abc_Obj_t * pNode ) int Abc_NtkGetLevelNum_rec( Abc_Obj_t * pNode )
{ {
Abc_Obj_t * pFanin; Abc_Obj_t * pFanin;
int i; int i, Level;
assert( !Abc_ObjIsNet(pNode) ); assert( !Abc_ObjIsNet(pNode) );
// skip the PI // skip the PI
if ( Abc_ObjIsCi(pNode) ) if ( Abc_ObjIsCi(pNode) )
...@@ -323,9 +337,9 @@ int Abc_NtkGetLevelNum_rec( Abc_Obj_t * pNode ) ...@@ -323,9 +337,9 @@ int Abc_NtkGetLevelNum_rec( Abc_Obj_t * pNode )
pNode->Level = 0; pNode->Level = 0;
Abc_ObjForEachFanin( pNode, pFanin, i ) Abc_ObjForEachFanin( pNode, pFanin, i )
{ {
Abc_NtkGetLevelNum_rec( Abc_ObjFanin0Ntk(pFanin) ); Level = Abc_NtkGetLevelNum_rec( Abc_ObjFanin0Ntk(pFanin) );
if ( pNode->Level < pFanin->Level ) if ( pNode->Level < (unsigned)Level )
pNode->Level = pFanin->Level; pNode->Level = Level;
} }
pNode->Level++; pNode->Level++;
return pNode->Level; return pNode->Level;
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#define ABC_LARGE_ID ((1<<24)-1) // should correspond to value in "vecFan.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS /// /// FUNCTION DEFITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -45,8 +47,8 @@ void Abc_ObjAddFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin ) ...@@ -45,8 +47,8 @@ void Abc_ObjAddFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin )
assert( !Abc_ObjIsComplement(pObj) ); assert( !Abc_ObjIsComplement(pObj) );
assert( pObj->pNtk == pFaninR->pNtk ); assert( pObj->pNtk == pFaninR->pNtk );
assert( pObj->Id >= 0 && pFaninR->Id >= 0 ); assert( pObj->Id >= 0 && pFaninR->Id >= 0 );
assert( pObj->Id < (1<<26)-1 ); // created but forgot to add it to the network? assert( pObj->Id < ABC_LARGE_ID ); // created but forgot to add it to the network?
assert( pFaninR->Id < (1<<26)-1 ); // created but forgot to add it to the network? assert( pFaninR->Id < ABC_LARGE_ID ); // created but forgot to add it to the network?
Vec_FanPush( pObj->pNtk->pMmStep, &pObj->vFanins, Vec_Int2Fan(pFaninR->Id) ); Vec_FanPush( pObj->pNtk->pMmStep, &pObj->vFanins, Vec_Int2Fan(pFaninR->Id) );
Vec_FanPush( pObj->pNtk->pMmStep, &pFaninR->vFanouts, Vec_Int2Fan(pObj->Id) ); Vec_FanPush( pObj->pNtk->pMmStep, &pFaninR->vFanouts, Vec_Int2Fan(pObj->Id) );
if ( Abc_ObjIsComplement(pFanin) ) if ( Abc_ObjIsComplement(pFanin) )
...@@ -71,8 +73,8 @@ void Abc_ObjDeleteFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin ) ...@@ -71,8 +73,8 @@ void Abc_ObjDeleteFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin )
assert( !Abc_ObjIsComplement(pFanin) ); assert( !Abc_ObjIsComplement(pFanin) );
assert( pObj->pNtk == pFanin->pNtk ); assert( pObj->pNtk == pFanin->pNtk );
assert( pObj->Id >= 0 && pFanin->Id >= 0 ); assert( pObj->Id >= 0 && pFanin->Id >= 0 );
assert( pObj->Id < (1<<26)-1 ); // created but forgot to add it to the network? assert( pObj->Id < ABC_LARGE_ID ); // created but forgot to add it to the network?
assert( pFanin->Id < (1<<26)-1 ); // created but forgot to add it to the network? assert( pFanin->Id < ABC_LARGE_ID ); // created but forgot to add it to the network?
if ( !Vec_FanDeleteEntry( &pObj->vFanins, pFanin->Id ) ) if ( !Vec_FanDeleteEntry( &pObj->vFanins, pFanin->Id ) )
{ {
printf( "The obj %d is not found among the fanins of obj %d ...\n", pFanin->Id, pObj->Id ); printf( "The obj %d is not found among the fanins of obj %d ...\n", pFanin->Id, pObj->Id );
...@@ -128,29 +130,36 @@ void Abc_ObjRemoveFanins( Abc_Obj_t * pObj ) ...@@ -128,29 +130,36 @@ void Abc_ObjRemoveFanins( Abc_Obj_t * pObj )
void Abc_ObjPatchFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFaninOld, Abc_Obj_t * pFaninNew ) void Abc_ObjPatchFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFaninOld, Abc_Obj_t * pFaninNew )
{ {
Abc_Obj_t * pFaninNewR = Abc_ObjRegular(pFaninNew); Abc_Obj_t * pFaninNewR = Abc_ObjRegular(pFaninNew);
int iFanin, fCompl; int iFanin, fCompl, nLats;
assert( !Abc_ObjIsComplement(pObj) ); assert( !Abc_ObjIsComplement(pObj) );
assert( !Abc_ObjIsComplement(pFaninOld) ); assert( !Abc_ObjIsComplement(pFaninOld) );
assert( pFaninOld != pFaninNewR ); assert( pFaninOld != pFaninNewR );
// assert( pObj != pFaninOld );
// assert( pObj != pFaninNewR );
assert( pObj->pNtk == pFaninOld->pNtk ); assert( pObj->pNtk == pFaninOld->pNtk );
assert( pObj->pNtk == pFaninNewR->pNtk ); assert( pObj->pNtk == pFaninNewR->pNtk );
if ( (iFanin = Vec_FanFindEntry( &pObj->vFanins, pFaninOld->Id )) == -1 ) if ( (iFanin = Vec_FanFindEntry( &pObj->vFanins, pFaninOld->Id )) == -1 )
{ {
printf( "Fanin node %d is not among the fanins of node %d...\n", pFaninOld->Id, pObj->Id ); printf( "Node %s is not among", Abc_ObjName(pFaninOld) );
printf( " the fanins of node %s...\n", Abc_ObjName(pObj) );
return; return;
} }
// remember the polarity of the old fanin // remember the attributes of the old fanin
fCompl = Abc_ObjFaninC(pObj, iFanin); fCompl = Abc_ObjFaninC(pObj, iFanin);
// replace the old fanin entry by the new fanin entry (removes polarity) nLats = Abc_ObjFaninL(pObj, iFanin);
// replace the old fanin entry by the new fanin entry (removes attributes)
Vec_FanWriteEntry( &pObj->vFanins, iFanin, Vec_Int2Fan(pFaninNewR->Id) ); Vec_FanWriteEntry( &pObj->vFanins, iFanin, Vec_Int2Fan(pFaninNewR->Id) );
// set the polarity of the new fanin // set the attributes of the new fanin
if ( fCompl ^ Abc_ObjIsComplement(pFaninNew) ) if ( fCompl ^ Abc_ObjIsComplement(pFaninNew) )
Abc_ObjSetFaninC( pObj, iFanin ); Abc_ObjSetFaninC( pObj, iFanin );
if ( nLats )
Abc_ObjSetFaninL( pObj, iFanin, nLats );
// update the fanout of the fanin // update the fanout of the fanin
if ( !Vec_FanDeleteEntry( &pFaninOld->vFanouts, pObj->Id ) ) if ( !Vec_FanDeleteEntry( &pFaninOld->vFanouts, pObj->Id ) )
{ {
printf( "The node %d is not among the fanouts of its old fanin %d...\n", pObj->Id, pFaninOld->Id ); printf( "Node %s is not among", Abc_ObjName(pObj) );
return; printf( " the fanouts of its old fanin %s...\n", Abc_ObjName(pFaninOld) );
// return;
} }
Vec_FanPush( pObj->pNtk->pMmStep, &pFaninNewR->vFanouts, Vec_Int2Fan(pObj->Id) ); Vec_FanPush( pObj->pNtk->pMmStep, &pFaninNewR->vFanouts, Vec_Int2Fan(pObj->Id) );
} }
......
...@@ -121,13 +121,12 @@ Fpga_Man_t * Abc_NtkToFpga( Abc_Ntk_t * pNtk, int fRecovery, int fVerbose ) ...@@ -121,13 +121,12 @@ Fpga_Man_t * Abc_NtkToFpga( Abc_Ntk_t * pNtk, int fRecovery, int fVerbose )
pNode->pCopy = (Abc_Obj_t *)Fpga_ManReadInputs(pMan)[i]; pNode->pCopy = (Abc_Obj_t *)Fpga_ManReadInputs(pMan)[i];
// load the AIG into the mapper // load the AIG into the mapper
vNodes = Abc_AigDfs( pNtk ); vNodes = Abc_AigDfs( pNtk, 0 );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize ); pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
for ( i = 0; i < vNodes->nSize; i++ ) Vec_PtrForEachEntry( vNodes, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
// consider the case of a constant // consider the case of a constant
pNode = vNodes->pArray[i];
if ( Abc_NodeIsConst(pNode) ) if ( Abc_NodeIsConst(pNode) )
{ {
Abc_AigConst1(pNtk->pManFunc)->pCopy = (Abc_Obj_t *)Fpga_ManReadConst1(pMan); Abc_AigConst1(pNtk->pManFunc)->pCopy = (Abc_Obj_t *)Fpga_ManReadConst1(pMan);
......
...@@ -104,15 +104,11 @@ Fraig_Man_t * Abc_NtkToFraig( Abc_Ntk_t * pNtk, Fraig_Params_t * pParams, int fA ...@@ -104,15 +104,11 @@ Fraig_Man_t * Abc_NtkToFraig( Abc_Ntk_t * pNtk, Fraig_Params_t * pParams, int fA
pConst1 = Abc_AigConst1( pNtk->pManFunc ); pConst1 = Abc_AigConst1( pNtk->pManFunc );
// perform strashing // perform strashing
if ( fAllNodes ) vNodes = Abc_AigDfs( pNtk, fAllNodes );
vNodes = Abc_AigCollectAll( pNtk );
else
vNodes = Abc_AigDfs( pNtk );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize ); pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
for ( i = 0; i < vNodes->nSize; i++ ) Vec_PtrForEachEntry( vNodes, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
pNode = vNodes->pArray[i];
if ( pNode == pConst1 ) if ( pNode == pConst1 )
pNodeFraig = Fraig_ManReadConst1(pMan); pNodeFraig = Fraig_ManReadConst1(pMan);
else else
...@@ -328,13 +324,12 @@ void Abc_NtkFraigTrustOne( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew ) ...@@ -328,13 +324,12 @@ void Abc_NtkFraigTrustOne( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
int i; int i;
// perform strashing // perform strashing
vNodes = Abc_NtkDfs( pNtk ); vNodes = Abc_NtkDfs( pNtk, 0 );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize ); pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
for ( i = 0; i < vNodes->nSize; i++ ) Vec_PtrForEachEntry( vNodes, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
// get the node // get the node
pNode = vNodes->pArray[i];
assert( Abc_ObjIsNode(pNode) ); assert( Abc_ObjIsNode(pNode) );
// strash the node // strash the node
pNodeNew = Abc_NodeFraigTrust( pMan, pNode ); pNodeNew = Abc_NodeFraigTrust( pMan, pNode );
......
...@@ -143,10 +143,10 @@ void Abc_NtkFxuCollectInfo( Abc_Ntk_t * pNtk, Fxu_Data_t * p ) ...@@ -143,10 +143,10 @@ void Abc_NtkFxuCollectInfo( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
p->vFanins = Vec_PtrAlloc(0); p->vFanins = Vec_PtrAlloc(0);
p->vSopsNew = Vec_PtrAlloc(0); p->vSopsNew = Vec_PtrAlloc(0);
p->vFaninsNew = Vec_PtrAlloc(0); p->vFaninsNew = Vec_PtrAlloc(0);
Vec_PtrFill( p->vSops, pNtk->vObjs->nSize, NULL ); Vec_PtrFill( p->vSops, Abc_NtkObjNumMax(pNtk), NULL );
Vec_PtrFill( p->vFanins, pNtk->vObjs->nSize, NULL ); Vec_PtrFill( p->vFanins, Abc_NtkObjNumMax(pNtk), NULL );
Vec_PtrFill( p->vSopsNew, pNtk->vObjs->nSize + p->nNodesExt, NULL ); Vec_PtrFill( p->vSopsNew, Abc_NtkObjNumMax(pNtk) + p->nNodesExt, NULL );
Vec_PtrFill( p->vFaninsNew, pNtk->vObjs->nSize + p->nNodesExt, NULL ); Vec_PtrFill( p->vFaninsNew, Abc_NtkObjNumMax(pNtk) + p->nNodesExt, NULL );
// add SOPs and fanin array // add SOPs and fanin array
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
{ {
...@@ -157,7 +157,7 @@ void Abc_NtkFxuCollectInfo( Abc_Ntk_t * pNtk, Fxu_Data_t * p ) ...@@ -157,7 +157,7 @@ void Abc_NtkFxuCollectInfo( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
p->vSops->pArray[i] = pNode->pData; p->vSops->pArray[i] = pNode->pData;
p->vFanins->pArray[i] = &pNode->vFanins; p->vFanins->pArray[i] = &pNode->vFanins;
} }
p->nNodesOld = pNtk->vObjs->nSize; p->nNodesOld = Abc_NtkObjNumMax(pNtk);
} }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -32,7 +32,6 @@ static Abc_Ntk_t * Abc_NtkFromMap( Map_Man_t * pMan, Abc_Ntk_t * pNtk ); ...@@ -32,7 +32,6 @@ static Abc_Ntk_t * Abc_NtkFromMap( Map_Man_t * pMan, Abc_Ntk_t * pNtk );
static Abc_Obj_t * Abc_NodeFromMap_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap, int fPhase ); static Abc_Obj_t * Abc_NodeFromMap_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap, int fPhase );
static Abc_Obj_t * Abc_NodeFromMapPhase_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap, int fPhase ); static Abc_Obj_t * Abc_NodeFromMapPhase_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap, int fPhase );
static Abc_Obj_t * Abc_NodeFromMapSuper_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap, Map_Super_t * pSuper, Abc_Obj_t * pNodePis[], int nNodePis ); static Abc_Obj_t * Abc_NodeFromMapSuper_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap, Map_Super_t * pSuper, Abc_Obj_t * pNodePis[], int nNodePis );
static Abc_Obj_t * Abc_NtkFixCiDriver( Abc_Obj_t * pNode );
static Abc_Ntk_t * Abc_NtkFromMapSuperChoice( Map_Man_t * pMan, Abc_Ntk_t * pNtk ); static Abc_Ntk_t * Abc_NtkFromMapSuperChoice( Map_Man_t * pMan, Abc_Ntk_t * pNtk );
static void Abc_NodeSuperChoice( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode ); static void Abc_NodeSuperChoice( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode );
...@@ -148,13 +147,12 @@ Map_Man_t * Abc_NtkToMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, i ...@@ -148,13 +147,12 @@ Map_Man_t * Abc_NtkToMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, i
pNode->pCopy = (Abc_Obj_t *)Map_ManReadInputs(pMan)[i]; pNode->pCopy = (Abc_Obj_t *)Map_ManReadInputs(pMan)[i];
// load the AIG into the mapper // load the AIG into the mapper
vNodes = Abc_AigDfs( pNtk ); vNodes = Abc_AigDfs( pNtk, 0 );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize ); pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
for ( i = 0; i < vNodes->nSize; i++ ) Vec_PtrForEachEntry( vNodes, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
// consider the case of a constant // consider the case of a constant
pNode = vNodes->pArray[i];
if ( Abc_NodeIsConst(pNode) ) if ( Abc_NodeIsConst(pNode) )
{ {
Abc_AigConst1(pNtk->pManFunc)->pCopy = (Abc_Obj_t *)Map_ManReadConst1(pMan); Abc_AigConst1(pNtk->pManFunc)->pCopy = (Abc_Obj_t *)Map_ManReadConst1(pMan);
...@@ -221,8 +219,6 @@ Abc_Ntk_t * Abc_NtkFromMap( Map_Man_t * pMan, Abc_Ntk_t * pNtk ) ...@@ -221,8 +219,6 @@ Abc_Ntk_t * Abc_NtkFromMap( Map_Man_t * pMan, Abc_Ntk_t * pNtk )
pNodeMap = Map_ManReadOutputs(pMan)[i]; pNodeMap = Map_ManReadOutputs(pMan)[i];
pNodeNew = Abc_NodeFromMap_rec( pNtkNew, Map_Regular(pNodeMap), !Map_IsComplement(pNodeMap) ); pNodeNew = Abc_NodeFromMap_rec( pNtkNew, Map_Regular(pNodeMap), !Map_IsComplement(pNodeMap) );
assert( !Abc_ObjIsComplement(pNodeNew) ); assert( !Abc_ObjIsComplement(pNodeNew) );
if ( !Abc_ObjIsNode(pNodeNew) )
pNodeNew = Abc_NtkFixCiDriver( pNodeNew );
Abc_ObjAddFanin( pNode->pCopy, pNodeNew ); Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
} }
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
...@@ -408,36 +404,6 @@ int Abc_NtkUnmap( Abc_Ntk_t * pNtk ) ...@@ -408,36 +404,6 @@ int Abc_NtkUnmap( Abc_Ntk_t * pNtk )
} }
/**Function*************************************************************
Synopsis [Add buffer when the CO driver is a CI.]
Description [Hack: If the PO has the same name as the PI, it will still count
as the buffer but this node will not be written into file during writing]
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Obj_t * Abc_NtkFixCiDriver( Abc_Obj_t * pNode )
{
Mio_Gate_t * pGateBuffer = Mio_LibraryReadBuf(Abc_FrameReadLibGen(Abc_FrameGetGlobalFrame()));
Mio_Gate_t * pGateInv = Mio_LibraryReadInv(Abc_FrameReadLibGen(Abc_FrameGetGlobalFrame()));
// add the buffer
if ( pGateBuffer )
return Abc_NodeCreateBuf( pNode->pNtk, pNode );
// add two inverters
if ( pGateInv )
return Abc_NodeCreateInv( pNode->pNtk, Abc_NodeCreateInv(pNode->pNtk, pNode) );
assert( 0 );
return NULL;
}
/**Function************************************************************* /**Function*************************************************************
...@@ -561,7 +527,7 @@ Abc_Ntk_t * Abc_NtkFromMapSuperChoice( Map_Man_t * pMan, Abc_Ntk_t * pNtk ) ...@@ -561,7 +527,7 @@ Abc_Ntk_t * Abc_NtkFromMapSuperChoice( Map_Man_t * pMan, Abc_Ntk_t * pNtk )
} }
// assign the mapping of the required phase to the POs // assign the mapping of the required phase to the POs
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
......
...@@ -51,17 +51,14 @@ Abc_Ntk_t * Abc_NtkMiter( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb ) ...@@ -51,17 +51,14 @@ Abc_Ntk_t * Abc_NtkMiter( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
{ {
Abc_Ntk_t * pTemp = NULL; Abc_Ntk_t * pTemp = NULL;
int fRemove1, fRemove2; int fRemove1, fRemove2;
// check that the networks have the same PIs/POs/latches
if ( !Abc_NtkCompareSignals( pNtk1, pNtk2, fComb ) )
return NULL;
// make sure the circuits are strashed // make sure the circuits are strashed
fRemove1 = (!Abc_NtkIsAig(pNtk1)) && (pNtk1 = Abc_NtkStrash(pNtk1, 0)); fRemove1 = (!Abc_NtkIsAig(pNtk1)) && (pNtk1 = Abc_NtkStrash(pNtk1, 0));
fRemove2 = (!Abc_NtkIsAig(pNtk2)) && (pNtk2 = Abc_NtkStrash(pNtk2, 0)); fRemove2 = (!Abc_NtkIsAig(pNtk2)) && (pNtk2 = Abc_NtkStrash(pNtk2, 0));
if ( pNtk1 && pNtk2 ) if ( pNtk1 && pNtk2 )
{
// check that the networks have the same PIs/POs/latches
// reorder PIs/POs/latches of pNtk2 according to pNtk1
// compute the miter of two strashed sequential networks
if ( Abc_NtkCompareSignals( pNtk1, pNtk2, fComb ) )
pTemp = Abc_NtkMiterInt( pNtk1, pNtk2, fComb ); pTemp = Abc_NtkMiterInt( pNtk1, pNtk2, fComb );
}
if ( fRemove1 ) Abc_NtkDelete( pNtk1 ); if ( fRemove1 ) Abc_NtkDelete( pNtk1 );
if ( fRemove2 ) Abc_NtkDelete( pNtk2 ); if ( fRemove2 ) Abc_NtkDelete( pNtk2 );
return pTemp; return pTemp;
...@@ -196,25 +193,21 @@ void Abc_NtkMiterAddOne( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkMiter ) ...@@ -196,25 +193,21 @@ void Abc_NtkMiterAddOne( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkMiter )
{ {
ProgressBar * pProgress; ProgressBar * pProgress;
Vec_Ptr_t * vNodes; Vec_Ptr_t * vNodes;
Abc_Obj_t * pNode, * pNodeNew, * pConst1, * pConst1New; Abc_Obj_t * pNode, * pConst1, * pConst1New;
int i; int i;
// get the constant nodes // get the constant nodes
pConst1 = Abc_AigConst1( pNtk->pManFunc ); pConst1 = Abc_AigConst1( pNtk->pManFunc );
pConst1New = Abc_AigConst1( pNtkMiter->pManFunc ); pConst1New = Abc_AigConst1( pNtkMiter->pManFunc );
// perform strashing // perform strashing
vNodes = Abc_NtkDfs( pNtk ); vNodes = Abc_NtkDfs( pNtk, 0 );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize ); pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
for ( i = 0; i < vNodes->nSize; i++ ) Vec_PtrForEachEntry( vNodes, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
pNode = vNodes->pArray[i];
if ( pNode == pConst1 ) if ( pNode == pConst1 )
pNodeNew = pConst1New; pNode->pCopy = pConst1New;
else else
pNodeNew = Abc_AigAnd( pNtkMiter->pManFunc, pNode->pCopy = Abc_AigAnd( pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ),
Abc_ObjNotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) ) );
pNode->pCopy = pNodeNew;
} }
Vec_PtrFree( vNodes ); Vec_PtrFree( vNodes );
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
...@@ -247,9 +240,7 @@ void Abc_NtkMiterAddOneNode( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkMiter, Abc_Obj_t ...@@ -247,9 +240,7 @@ void Abc_NtkMiterAddOneNode( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkMiter, Abc_Obj_t
if ( pNode == pConst1 ) if ( pNode == pConst1 )
pNodeNew = pConst1New; pNodeNew = pConst1New;
else else
pNodeNew = Abc_AigAnd( pNtkMiter->pManFunc, pNodeNew = Abc_AigAnd( pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ),
Abc_ObjNotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) ) );
pNode->pCopy = pNodeNew; pNode->pCopy = pNodeNew;
} }
Vec_PtrFree( vNodes ); Vec_PtrFree( vNodes );
...@@ -270,7 +261,7 @@ void Abc_NtkMiterAddOneNode( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkMiter, Abc_Obj_t ...@@ -270,7 +261,7 @@ void Abc_NtkMiterAddOneNode( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkMiter, Abc_Obj_t
void Abc_NtkMiterFinalize( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Abc_Ntk_t * pNtkMiter, int fComb ) void Abc_NtkMiterFinalize( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Abc_Ntk_t * pNtkMiter, int fComb )
{ {
Vec_Ptr_t * vPairs; Vec_Ptr_t * vPairs;
Abc_Obj_t * pDriverNew, * pMiter, * pNode; Abc_Obj_t * pMiter, * pNode;
int i; int i;
// collect the PO pairs from both networks // collect the PO pairs from both networks
vPairs = Vec_PtrAlloc( 100 ); vPairs = Vec_PtrAlloc( 100 );
...@@ -279,11 +270,9 @@ void Abc_NtkMiterFinalize( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Abc_Ntk_t * pNt ...@@ -279,11 +270,9 @@ void Abc_NtkMiterFinalize( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Abc_Ntk_t * pNt
// collect the CO nodes for the miter // collect the CO nodes for the miter
Abc_NtkForEachCo( pNtk1, pNode, i ) Abc_NtkForEachCo( pNtk1, pNode, i )
{ {
pDriverNew = Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ); Vec_PtrPush( vPairs, Abc_ObjChild0Copy(pNode) );
Vec_PtrPush( vPairs, pDriverNew );
pNode = Abc_NtkCo( pNtk2, i ); pNode = Abc_NtkCo( pNtk2, i );
pDriverNew = Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ); Vec_PtrPush( vPairs, Abc_ObjChild0Copy(pNode) );
Vec_PtrPush( vPairs, pDriverNew );
} }
} }
else else
...@@ -291,23 +280,15 @@ void Abc_NtkMiterFinalize( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Abc_Ntk_t * pNt ...@@ -291,23 +280,15 @@ void Abc_NtkMiterFinalize( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Abc_Ntk_t * pNt
// collect the PO nodes for the miter // collect the PO nodes for the miter
Abc_NtkForEachPo( pNtk1, pNode, i ) Abc_NtkForEachPo( pNtk1, pNode, i )
{ {
pDriverNew = Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ); Vec_PtrPush( vPairs, Abc_ObjChild0Copy(pNode) );
Vec_PtrPush( vPairs, pDriverNew );
pNode = Abc_NtkPo( pNtk2, i ); pNode = Abc_NtkPo( pNtk2, i );
pDriverNew = Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ); Vec_PtrPush( vPairs, Abc_ObjChild0Copy(pNode) );
Vec_PtrPush( vPairs, pDriverNew );
} }
// connect new latches // connect new latches
Abc_NtkForEachLatch( pNtk1, pNode, i ) Abc_NtkForEachLatch( pNtk1, pNode, i )
{ Abc_ObjAddFanin( pNode->pCopy, Abc_ObjChild0Copy(pNode) );
pDriverNew = Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) );
Abc_ObjAddFanin( pNode->pCopy, pDriverNew );
}
Abc_NtkForEachLatch( pNtk2, pNode, i ) Abc_NtkForEachLatch( pNtk2, pNode, i )
{ Abc_ObjAddFanin( pNode->pCopy, Abc_ObjChild0Copy(pNode) );
pDriverNew = Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) );
Abc_ObjAddFanin( pNode->pCopy, pDriverNew );
}
} }
// add the miter // add the miter
pMiter = Abc_AigMiter( pNtkMiter->pManFunc, vPairs ); pMiter = Abc_AigMiter( pNtkMiter->pManFunc, vPairs );
...@@ -347,7 +328,7 @@ Abc_Ntk_t * Abc_NtkMiterOne( Abc_Ntk_t * pNtk, int Out, int In1, int In2 ) ...@@ -347,7 +328,7 @@ Abc_Ntk_t * Abc_NtkMiterOne( Abc_Ntk_t * pNtk, int Out, int In1, int In2 )
pNtkMiter->pName = util_strsav(Buffer); pNtkMiter->pName = util_strsav(Buffer);
// get the root output // get the root output
pRoot = Abc_NtkCo(pNtk,Out); pRoot = Abc_NtkCo( pNtk, Out );
// perform strashing // perform strashing
Abc_NtkMiterPrepare( pNtk, pNtk, pNtkMiter, 1 ); Abc_NtkMiterPrepare( pNtk, pNtk, pNtkMiter, 1 );
...@@ -410,7 +391,7 @@ int Abc_NtkMiterIsConstant( Abc_Ntk_t * pMiter ) ...@@ -410,7 +391,7 @@ int Abc_NtkMiterIsConstant( Abc_Ntk_t * pMiter )
Abc_NtkForEachPo( pMiter, pNodePo, i ) Abc_NtkForEachPo( pMiter, pNodePo, i )
{ {
pChild = Abc_ObjChild0( Abc_NtkPo(pMiter,i) ); pChild = Abc_ObjChild0( Abc_NtkPo(pMiter,i) );
if ( Abc_NodeIsConst(pChild) ) if ( Abc_ObjIsNode(Abc_ObjRegular(pChild)) && Abc_NodeIsConst(pChild) )
{ {
assert( Abc_ObjRegular(pChild) == Abc_AigConst1(pMiter->pManFunc) ); assert( Abc_ObjRegular(pChild) == Abc_AigConst1(pMiter->pManFunc) );
if ( !Abc_ObjIsComplement(pChild) ) if ( !Abc_ObjIsComplement(pChild) )
...@@ -446,7 +427,7 @@ void Abc_NtkMiterReport( Abc_Ntk_t * pMiter ) ...@@ -446,7 +427,7 @@ void Abc_NtkMiterReport( Abc_Ntk_t * pMiter )
if ( Abc_NtkPoNum(pMiter) == 1 ) if ( Abc_NtkPoNum(pMiter) == 1 )
{ {
pChild = Abc_ObjChild0( Abc_NtkPo(pMiter,0) ); pChild = Abc_ObjChild0( Abc_NtkPo(pMiter,0) );
if ( Abc_NodeIsConst(Abc_ObjRegular(pChild)) ) if ( Abc_ObjIsNode(Abc_ObjRegular(pChild)) && Abc_NodeIsConst(pChild) )
{ {
if ( Abc_ObjIsComplement(pChild) ) if ( Abc_ObjIsComplement(pChild) )
printf( "Unsatisfiable.\n" ); printf( "Unsatisfiable.\n" );
...@@ -462,7 +443,7 @@ void Abc_NtkMiterReport( Abc_Ntk_t * pMiter ) ...@@ -462,7 +443,7 @@ void Abc_NtkMiterReport( Abc_Ntk_t * pMiter )
{ {
pChild = Abc_ObjChild0( Abc_NtkPo(pMiter,i) ); pChild = Abc_ObjChild0( Abc_NtkPo(pMiter,i) );
printf( "Output #%2d : ", i ); printf( "Output #%2d : ", i );
if ( Abc_NodeIsConst(Abc_ObjRegular(pChild)) ) if ( Abc_ObjIsNode(Abc_ObjRegular(pChild)) && Abc_NodeIsConst(pChild) )
{ {
if ( Abc_ObjIsComplement(pChild) ) if ( Abc_ObjIsComplement(pChild) )
printf( "Unsatisfiable.\n" ); printf( "Unsatisfiable.\n" );
...@@ -478,7 +459,7 @@ void Abc_NtkMiterReport( Abc_Ntk_t * pMiter ) ...@@ -478,7 +459,7 @@ void Abc_NtkMiterReport( Abc_Ntk_t * pMiter )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Derives the time frames of the network.] Synopsis [Derives the timeframes of the network.]
Description [] Description []
...@@ -495,7 +476,7 @@ Abc_Ntk_t * Abc_NtkFrames( Abc_Ntk_t * pNtk, int nFrames, int fInitial ) ...@@ -495,7 +476,7 @@ Abc_Ntk_t * Abc_NtkFrames( Abc_Ntk_t * pNtk, int nFrames, int fInitial )
Abc_Ntk_t * pNtkFrames; Abc_Ntk_t * pNtkFrames;
Vec_Ptr_t * vNodes; Vec_Ptr_t * vNodes;
Abc_Obj_t * pLatch, * pLatchNew; Abc_Obj_t * pLatch, * pLatchNew;
int i; int i, Counter;
assert( nFrames > 0 ); assert( nFrames > 0 );
assert( Abc_NtkIsAig(pNtk) ); assert( Abc_NtkIsAig(pNtk) );
// start the new network // start the new network
...@@ -510,12 +491,24 @@ Abc_Ntk_t * Abc_NtkFrames( Abc_Ntk_t * pNtk, int nFrames, int fInitial ) ...@@ -510,12 +491,24 @@ Abc_Ntk_t * Abc_NtkFrames( Abc_Ntk_t * pNtk, int nFrames, int fInitial )
} }
else else
{ {
Counter = 0;
Abc_NtkForEachLatch( pNtk, pLatch, i ) Abc_NtkForEachLatch( pNtk, pLatch, i )
pLatch->pCopy = Abc_ObjNotCond( Abc_AigConst1(pNtkFrames->pManFunc), ((int)pLatch->pData)!=1 ); {
if ( Abc_LatchIsInitDc(pLatch) ) // don't-care initial value - create a new PI
{
pLatch->pCopy = Abc_NtkCreatePi(pNtkFrames);
Abc_NtkLogicStoreName( pLatch->pCopy, Abc_ObjName(pLatch) );
Counter++;
}
else
pLatch->pCopy = Abc_ObjNotCond( Abc_AigConst1(pNtkFrames->pManFunc), Abc_LatchIsInit0(pLatch) );
}
if ( Counter )
printf( "Warning: %d uninitialized latches are replaced by free variables.\n", Counter );
} }
// create the timeframes // create the timeframes
vNodes = Abc_NtkDfs( pNtk ); vNodes = Abc_NtkDfs( pNtk, 0 );
pProgress = Extra_ProgressBarStart( stdout, nFrames ); pProgress = Extra_ProgressBarStart( stdout, nFrames );
for ( i = 0; i < nFrames; i++ ) for ( i = 0; i < nFrames; i++ )
{ {
...@@ -579,27 +572,24 @@ void Abc_NtkAddFrame( Abc_Ntk_t * pNtkFrames, Abc_Ntk_t * pNtk, int iFrame, Vec_ ...@@ -579,27 +572,24 @@ void Abc_NtkAddFrame( Abc_Ntk_t * pNtkFrames, Abc_Ntk_t * pNtk, int iFrame, Vec_
Abc_NtkLogicStoreNamePlus( pNodeNew, Abc_ObjName(pNode), Buffer ); Abc_NtkLogicStoreNamePlus( pNodeNew, Abc_ObjName(pNode), Buffer );
} }
// add the internal nodes // add the internal nodes
for ( i = 0; i < vNodes->nSize; i++ ) Vec_PtrForEachEntry( vNodes, pNode, i )
{ {
pNode = vNodes->pArray[i];
if ( pNode == pConst1 ) if ( pNode == pConst1 )
pNodeNew = pConst1New; pNodeNew = pConst1New;
else else
pNodeNew = Abc_AigAnd( pNtkFrames->pManFunc, pNodeNew = Abc_AigAnd( pNtkFrames->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ),
Abc_ObjNotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) ) );
pNode->pCopy = pNodeNew; pNode->pCopy = pNodeNew;
} }
// add the new POs // add the new POs
Abc_NtkForEachPo( pNtk, pNode, i ) Abc_NtkForEachPo( pNtk, pNode, i )
{ {
pNodeNew = Abc_NtkDupObj( pNtkFrames, pNode ); pNodeNew = Abc_NtkDupObj( pNtkFrames, pNode );
Abc_ObjAddFanin( pNodeNew, Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ) ); Abc_ObjAddFanin( pNodeNew, Abc_ObjChild0Copy(pNode) );
Abc_NtkLogicStoreNamePlus( pNodeNew, Abc_ObjName(pNode), Buffer ); Abc_NtkLogicStoreNamePlus( pNodeNew, Abc_ObjName(pNode), Buffer );
} }
// transfer the implementation of the latch drivers to the latches // transfer the implementation of the latch drivers to the latches
Abc_NtkForEachLatch( pNtk, pLatch, i ) Abc_NtkForEachLatch( pNtk, pLatch, i )
pLatch->pCopy = Abc_ObjNotCond( Abc_ObjFanin0(pLatch)->pCopy, Abc_ObjFaninC0(pLatch) ); pLatch->pCopy = Abc_ObjChild0Copy(pLatch);
} }
......
...@@ -108,7 +108,7 @@ char * Abc_ObjName( Abc_Obj_t * pObj ) ...@@ -108,7 +108,7 @@ char * Abc_ObjName( Abc_Obj_t * pObj )
{ {
// in a logic network, PI/PO/latch names are stored in the hash table // in a logic network, PI/PO/latch names are stored in the hash table
// internal nodes have made up names // internal nodes have made up names
assert( Abc_ObjIsNode(pObj) ); assert( Abc_ObjIsNode(pObj) || Abc_ObjIsLatch(pObj) );
sprintf( Buffer, "[%d]", pObj->Id ); sprintf( Buffer, "[%d]", pObj->Id );
} }
return Buffer; return Buffer;
......
...@@ -84,19 +84,25 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk ) ...@@ -84,19 +84,25 @@ Abc_Ntk_t * Abc_NtkNetlistToLogic( Abc_Ntk_t * pNtk )
Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk ) Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk )
{ {
Abc_Ntk_t * pNtkNew, * pNtkTemp; Abc_Ntk_t * pNtkNew, * pNtkTemp;
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsAig(pNtk) ); assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsAig(pNtk) || Abc_NtkIsSeq(pNtk) );
if ( Abc_NtkIsLogicBdd(pNtk) ) if ( Abc_NtkIsAig(pNtk) )
{ {
Abc_NtkBddToSop(pNtk); pNtkTemp = Abc_NtkAigToLogicSop(pNtk);
pNtkNew = Abc_NtkLogicSopToNetlist( pNtk ); pNtkNew = Abc_NtkLogicSopToNetlist( pNtkTemp );
Abc_NtkSopToBdd(pNtk); Abc_NtkDelete( pNtkTemp );
} }
else if ( Abc_NtkIsAig(pNtk) ) else if ( Abc_NtkIsSeq(pNtk) )
{ {
pNtkTemp = Abc_NtkAigToLogicSop(pNtk); pNtkTemp = Abc_NtkSeqToLogicSop(pNtk);
pNtkNew = Abc_NtkLogicSopToNetlist( pNtkTemp ); pNtkNew = Abc_NtkLogicSopToNetlist( pNtkTemp );
Abc_NtkDelete( pNtkTemp ); Abc_NtkDelete( pNtkTemp );
} }
else if ( Abc_NtkIsLogicBdd(pNtk) )
{
Abc_NtkBddToSop(pNtk);
pNtkNew = Abc_NtkLogicSopToNetlist( pNtk );
Abc_NtkSopToBdd(pNtk);
}
else else
pNtkNew = Abc_NtkLogicSopToNetlist( pNtk ); pNtkNew = Abc_NtkLogicSopToNetlist( pNtk );
return pNtkNew; return pNtkNew;
...@@ -261,10 +267,12 @@ Abc_Ntk_t * Abc_NtkAigToLogicSop( Abc_Ntk_t * pNtk ) ...@@ -261,10 +267,12 @@ Abc_Ntk_t * Abc_NtkAigToLogicSop( Abc_Ntk_t * pNtk )
// set the new node // set the new node
pObj->pCopy = pNodeNew; pObj->pCopy = pNodeNew;
} }
// connect the objects, including the COs // connect the internal nodes
Abc_NtkForEachObj( pNtk, pObj, i ) Abc_NtkForEachNode( pNtk, pObj, i )
Abc_ObjForEachFanin( pObj, pFanin, k ) Abc_ObjForEachFanin( pObj, pFanin, k )
Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy ); Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
// connect the COs
Abc_NtkFinalize( pNtk, pNtkNew );
// fix the problem with complemented and duplicated CO edges // fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 ); Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
// duplicate the EXDC Ntk // duplicate the EXDC Ntk
...@@ -306,7 +314,7 @@ Abc_Ntk_t * Abc_NtkAigToLogicSopBench( Abc_Ntk_t * pNtk ) ...@@ -306,7 +314,7 @@ Abc_Ntk_t * Abc_NtkAigToLogicSopBench( Abc_Ntk_t * pNtk )
// create the constant node // create the constant node
Abc_NtkDupConst1( pNtk, pNtkNew ); Abc_NtkDupConst1( pNtk, pNtkNew );
// collect the nodes to be used (marks all nodes with current TravId) // collect the nodes to be used (marks all nodes with current TravId)
vNodes = Abc_NtkDfs( pNtk ); vNodes = Abc_NtkDfs( pNtk, 0 );
// create inverters for the CI and remember them // create inverters for the CI and remember them
Abc_NtkForEachCi( pNtk, pObj, i ) Abc_NtkForEachCi( pNtk, pObj, i )
if ( Abc_AigNodeHasComplFanoutEdgeTrav(pObj) ) if ( Abc_AigNodeHasComplFanoutEdgeTrav(pObj) )
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored ) void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
{ {
fprintf( pFile, "%-15s:", pNtk->pName ); fprintf( pFile, "%-15s:", pNtk->pName );
fprintf( pFile, " i/o = %3d/%3d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) ); fprintf( pFile, " i/o = %4d/%4d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) );
if ( !Abc_NtkIsSeq(pNtk) ) if ( !Abc_NtkIsSeq(pNtk) )
fprintf( pFile, " lat = %4d", Abc_NtkLatchNum(pNtk) ); fprintf( pFile, " lat = %4d", Abc_NtkLatchNum(pNtk) );
...@@ -65,7 +65,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored ) ...@@ -65,7 +65,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
else else
fprintf( pFile, " nd = %5d", Abc_NtkNodeNum(pNtk) ); fprintf( pFile, " nd = %5d", Abc_NtkNodeNum(pNtk) );
if ( Abc_NtkIsLogicSop(pNtk) ) if ( Abc_NtkIsLogicSop(pNtk) || Abc_NtkIsNetlistSop(pNtk) )
{ {
fprintf( pFile, " cube = %5d", Abc_NtkGetCubeNum(pNtk) ); fprintf( pFile, " cube = %5d", Abc_NtkGetCubeNum(pNtk) );
// fprintf( pFile, " lit(sop) = %5d", Abc_NtkGetLitNum(pNtk) ); // fprintf( pFile, " lit(sop) = %5d", Abc_NtkGetLitNum(pNtk) );
...@@ -74,7 +74,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored ) ...@@ -74,7 +74,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
} }
else if ( Abc_NtkIsLogicBdd(pNtk) ) else if ( Abc_NtkIsLogicBdd(pNtk) )
fprintf( pFile, " bdd = %5d", Abc_NtkGetBddNodeNum(pNtk) ); fprintf( pFile, " bdd = %5d", Abc_NtkGetBddNodeNum(pNtk) );
else if ( Abc_NtkIsLogicMap(pNtk) ) else if ( Abc_NtkIsLogicMap(pNtk) || Abc_NtkIsNetlistMap(pNtk) )
{ {
fprintf( pFile, " area = %5.2f", Abc_NtkGetMappedArea(pNtk) ); fprintf( pFile, " area = %5.2f", Abc_NtkGetMappedArea(pNtk) );
fprintf( pFile, " delay = %5.2f", Abc_NtkDelayTrace(pNtk) ); fprintf( pFile, " delay = %5.2f", Abc_NtkDelayTrace(pNtk) );
...@@ -85,7 +85,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored ) ...@@ -85,7 +85,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
} }
if ( !Abc_NtkIsSeq(pNtk) ) if ( !Abc_NtkIsSeq(pNtk) )
fprintf( pFile, " lev = %2d", Abc_NtkGetLevelNum(pNtk) ); fprintf( pFile, " lev = %3d", Abc_NtkGetLevelNum(pNtk) );
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
} }
...@@ -135,7 +135,7 @@ void Abc_NtkPrintIo( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -135,7 +135,7 @@ void Abc_NtkPrintIo( FILE * pFile, Abc_Ntk_t * pNtk )
***********************************************************************/ ***********************************************************************/
void Abc_NtkPrintLatch( FILE * pFile, Abc_Ntk_t * pNtk ) void Abc_NtkPrintLatch( FILE * pFile, Abc_Ntk_t * pNtk )
{ {
Abc_Obj_t * pLatch; Abc_Obj_t * pLatch, * pFanin;
int i, Counter0, Counter1, Counter2; int i, Counter0, Counter1, Counter2;
int Init0, Init1, Init2; int Init0, Init1, Init2;
...@@ -152,38 +152,46 @@ void Abc_NtkPrintLatch( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -152,38 +152,46 @@ void Abc_NtkPrintLatch( FILE * pFile, Abc_Ntk_t * pNtk )
Abc_NtkForEachLatch( pNtk, pLatch, i ) Abc_NtkForEachLatch( pNtk, pLatch, i )
{ {
if ( pLatch->pData == (void *)0 ) if ( Abc_LatchIsInit0(pLatch) )
Init0++; Init0++;
else if ( pLatch->pData == (void *)1 ) else if ( Abc_LatchIsInit1(pLatch) )
Init1++; Init1++;
else if ( pLatch->pData == (void *)2 ) else if ( Abc_LatchIsInitDc(pLatch) )
Init2++; Init2++;
else else
assert( 0 ); assert( 0 );
if ( Abc_ObjFaninNum( Abc_ObjFanin0(pLatch) ) == 0 ) pFanin = Abc_ObjFanin0(pLatch);
{ if ( !Abc_ObjIsNode(pFanin) || !Abc_NodeIsConst(pFanin) )
continue;
// the latch input is a constant node
Counter0++; Counter0++;
if ( pLatch->pData == (void *)2 ) if ( Abc_LatchIsInitDc(pLatch) )
Counter1++;
else
{ {
Counter1++;
continue;
}
// count the number of cases when the constant is equal to the initial value
if ( Abc_NtkIsAig(pNtk) ) if ( Abc_NtkIsAig(pNtk) )
{ {
if ( (pLatch->pData == (void *)1) ^ Abc_ObjFaninC0(pLatch) ) if ( Abc_LatchIsInit1(pLatch) == !Abc_ObjFaninC0(pLatch) )
Counter2++; Counter2++;
} }
else else
{ {
if ( (pLatch->pData == (void *)1) ^ Abc_NodeIsConst0(pLatch) ) if ( Abc_LatchIsInit1(pLatch) == Abc_NodeIsConst1(pLatch) )
Counter2++; Counter2++;
} }
} }
} // fprintf( pFile, "%-15s: ", pNtk->pName );
} // fprintf( pFile, "L = %5d: 0 = %4d. 1 = %3d. DC = %4d. ", Abc_NtkLatchNum(pNtk), Init0, Init1, Init2 );
fprintf( pFile, "Latches = %5d: Init 0 = %5d. Init 1 = %5d. Init any = %5d.\n", Abc_NtkLatchNum(pNtk), Init0, Init1, Init2 ); // fprintf( pFile, "Con = %3d. DC = %3d. Mat = %3d. ", Counter0, Counter1, Counter2 );
fprintf( pFile, "Constant driver = %4d. Init any = %4d. Init match = %4d.\n", Counter0, Counter1, Counter2 ); // fprintf( pFile, "SFeed = %2d.\n", Abc_NtkCountSelfFeedLatches(pNtk) );
fprintf( pFile, "The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtk) ); fprintf( pFile, "%-15s: ", pNtk->pName );
fprintf( pFile, "Lat = %5d: 0 = %4d. 1 = %3d. DC = %4d. \n", Abc_NtkLatchNum(pNtk), Init0, Init1, Init2 );
fprintf( pFile, "Con = %3d. DC = %3d. Mat = %3d. ", Counter0, Counter1, Counter2 );
fprintf( pFile, "SFeed = %2d.\n", Abc_NtkCountSelfFeedLatches(pNtk) );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -270,21 +278,17 @@ void Abc_NodePrintFanio( FILE * pFile, Abc_Obj_t * pNode ) ...@@ -270,21 +278,17 @@ void Abc_NodePrintFanio( FILE * pFile, Abc_Obj_t * pNode )
if ( Abc_ObjIsPo(pNode) ) if ( Abc_ObjIsPo(pNode) )
pNode = Abc_ObjFanin0(pNode); pNode = Abc_ObjFanin0(pNode);
fprintf( pFile, "Node %s", Abc_ObjName(pNode) );
fprintf( pFile, "\n" );
fprintf( pFile, "Fanins (%d): ", Abc_ObjFaninNum(pNode) ); fprintf( pFile, "Fanins (%d): ", Abc_ObjFaninNum(pNode) );
Abc_ObjForEachFanin( pNode, pNode2, i ) Abc_ObjForEachFanin( pNode, pNode2, i )
{
pNode2->pCopy = NULL;
fprintf( pFile, " %s", Abc_ObjName(pNode2) ); fprintf( pFile, " %s", Abc_ObjName(pNode2) );
}
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
fprintf( pFile, "\n" );
fprintf( pFile, "Fanouts (%d): ", Abc_ObjFaninNum(pNode) ); fprintf( pFile, "Fanouts (%d): ", Abc_ObjFaninNum(pNode) );
Abc_ObjForEachFanout( pNode, pNode2, i ) Abc_ObjForEachFanout( pNode, pNode2, i )
{
pNode2->pCopy = NULL;
fprintf( pFile, " %s", Abc_ObjName(pNode2) ); fprintf( pFile, " %s", Abc_ObjName(pNode2) );
}
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
} }
...@@ -326,21 +330,122 @@ void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode ) ...@@ -326,21 +330,122 @@ void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode )
pNode = Abc_ObjFanin0(pNode); pNode = Abc_ObjFanin0(pNode);
if ( Abc_ObjIsPi(pNode) ) if ( Abc_ObjIsPi(pNode) )
{ {
printf( "Skipping the PI node.\n" ); fprintf( pFile, "Skipping the PI node.\n" );
return; return;
} }
if ( Abc_ObjIsLatch(pNode) ) if ( Abc_ObjIsLatch(pNode) )
{ {
printf( "Skipping the latch.\n" ); fprintf( pFile, "Skipping the latch.\n" );
return; return;
} }
assert( Abc_ObjIsNode(pNode) ); assert( Abc_ObjIsNode(pNode) );
vFactor = Ft_Factor( pNode->pData ); vFactor = Ft_Factor( pNode->pData );
pNode->pCopy = NULL;
Ft_FactorPrint( stdout, vFactor, NULL, Abc_ObjName(pNode) ); Ft_FactorPrint( stdout, vFactor, NULL, Abc_ObjName(pNode) );
Vec_IntFree( vFactor ); Vec_IntFree( vFactor );
} }
/**Function*************************************************************
Synopsis [Prints the level stats of the PO node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile )
{
Abc_Obj_t * pNode;
int i, Length;
assert( Abc_NtkIsAig(pNtk) );
// print the delay profile
if ( fProfile )
{
int LevelMax, * pLevelCounts;
int nOutsSum, nOutsTotal;
LevelMax = 0;
Abc_NtkForEachCo( pNtk, pNode, i )
if ( LevelMax < (int)Abc_ObjFanin0(pNode)->Level )
LevelMax = Abc_ObjFanin0(pNode)->Level;
pLevelCounts = ALLOC( int, LevelMax + 1 );
memset( pLevelCounts, 0, sizeof(int) * (LevelMax + 1) );
Abc_NtkForEachCo( pNtk, pNode, i )
pLevelCounts[Abc_ObjFanin0(pNode)->Level]++;
nOutsSum = 0;
nOutsTotal = Abc_NtkCoNum(pNtk);
for ( i = 0; i <= LevelMax; i++ )
if ( pLevelCounts[i] )
{
nOutsSum += pLevelCounts[i];
printf( "Level = %4d. COs = %4d. %5.1f %%\n", i, pLevelCounts[i], 100.0 * nOutsSum/nOutsTotal );
}
return;
}
// find the longest name
Length = 0;
Abc_NtkForEachCo( pNtk, pNode, i )
if ( Length < (int)strlen(Abc_ObjName(pNode)) )
Length = strlen(Abc_ObjName(pNode));
if ( Length < 5 )
Length = 5;
// print stats for each output
Abc_NtkForEachCo( pNtk, pNode, i )
{
fprintf( pFile, "CO %4d : %*s ", i, Length, Abc_ObjName(pNode) );
Abc_NodePrintLevel( pFile, pNode );
}
}
/**Function*************************************************************
Synopsis [Prints the factored form of one node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NodePrintLevel( FILE * pFile, Abc_Obj_t * pNode )
{
Abc_Obj_t * pDriver;
Vec_Ptr_t * vNodes;
pDriver = Abc_ObjIsCo(pNode)? Abc_ObjFanin0(pNode) : pNode;
if ( Abc_ObjIsPi(pDriver) )
{
fprintf( pFile, "Primary input.\n" );
return;
}
if ( Abc_ObjIsLatch(pDriver) )
{
fprintf( pFile, "Latch.\n" );
return;
}
if ( Abc_NodeIsConst(pDriver) )
{
fprintf( pFile, "Constant %d.\n", !Abc_ObjFaninC0(pNode) );
return;
}
// print the level
fprintf( pFile, "Level = %3d. ", pDriver->Level );
// print the size of MFFC
fprintf( pFile, "Mffc = %5d. ", Abc_NodeMffcSize(pDriver) );
// print the size of the shole cone
vNodes = Abc_NtkDfsNodes( pNode->pNtk, &pDriver, 1 );
fprintf( pFile, "Cone = %5d. ", Vec_PtrSize(vNodes) );
Vec_PtrFree( vNodes );
fprintf( pFile, "\n" );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -79,7 +79,7 @@ int Abc_NtkAigResynthesize( Abc_Ntk_t * pNtk, Abc_ManRes_t * p ) ...@@ -79,7 +79,7 @@ int Abc_NtkAigResynthesize( Abc_Ntk_t * pNtk, Abc_ManRes_t * p )
pProgress = Extra_ProgressBarStart( stdout, 100 ); pProgress = Extra_ProgressBarStart( stdout, 100 );
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
{ {
Approx = (int)(100.0 * i / pNtk->vObjs->nSize ); Approx = (int)(100.0 * i / Abc_NtkObjNumMax(pNtk) );
Extra_ProgressBarUpdate( pProgress, Approx, NULL ); Extra_ProgressBarUpdate( pProgress, Approx, NULL );
p->pNode = pNode; p->pNode = pNode;
Abc_NodeResyn( p ); Abc_NodeResyn( p );
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
in addition to the complemented attibutes. in addition to the complemented attibutes.
The sets of PIs/POs remain the same as in logic network. The sets of PIs/POs remain the same as in logic network.
Constant 1 node can only be used as a fanin of a PO node and reset node. Constant 1 node can only be used as a fanin of a PO node and the reset node.
The reset node producing sequence (01111...) is used to create the The reset node produces sequence (01111...). It is used to create the
initialization logic of all latches. initialization logic of all latches.
The latches do not have explicit initial state but they are implicitly The latches do not have explicit initial state but they are implicitly
reset by the reset node. reset by the reset node.
...@@ -60,10 +60,124 @@ static void Abc_NodeSeqCreateLatches( Abc_Obj_t * pObj, int nLatches ); ...@@ -60,10 +60,124 @@ static void Abc_NodeSeqCreateLatches( Abc_Obj_t * pObj, int nLatches );
***********************************************************************/ ***********************************************************************/
Abc_Ntk_t * Abc_NtkAigToSeq( Abc_Ntk_t * pNtk ) Abc_Ntk_t * Abc_NtkAigToSeq( Abc_Ntk_t * pNtk )
{ {
int fCheck = 1;
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
Abc_Aig_t * pManNew;
Vec_Ptr_t * vNodes;
Abc_Obj_t * pObj, * pConst, * pFanout, * pFaninNew, * pLatch;
int i, k, fChange, Counter;
assert( Abc_NtkIsAig(pNtk) ); assert( Abc_NtkIsAig(pNtk) );
// start the network // start the network
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_SEQ ); pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_SEQ );
pManNew = pNtkNew->pManFunc;
// set mapping of the constant nodes
Abc_AigConst1(pNtk->pManFunc)->pCopy = Abc_AigConst1( pManNew );
Abc_AigReset(pNtk->pManFunc)->pCopy = Abc_AigReset( pManNew );
// get rid of initial states
Abc_NtkForEachLatch( pNtk, pObj, i )
{
pObj->pNext = pObj->pCopy;
if ( Abc_LatchIsInit0(pObj) )
pObj->pCopy = Abc_AigAnd( pManNew, pObj->pCopy, Abc_AigReset(pManNew) );
else if ( Abc_LatchIsInit1(pObj) )
pObj->pCopy = Abc_AigOr( pManNew, pObj->pCopy, Abc_ObjNot( Abc_AigReset(pManNew) ) );
}
// copy internal nodes
vNodes = Abc_AigDfs( pNtk, 1 );
Vec_PtrForEachEntry( vNodes, pObj, i )
if ( Abc_ObjFaninNum(pObj) == 2 )
pObj->pCopy = Abc_AigAnd( pManNew, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
Vec_PtrFree( vNodes );
// relink the CO nodes
Abc_NtkForEachPo( pNtk, pObj, i )
Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
Abc_NtkForEachLatch( pNtk, pObj, i )
Abc_ObjAddFanin( pObj->pNext, Abc_ObjChild0Copy(pObj) );
// propagate constant input latches in the new network
Counter = 0;
fChange = 1;
while ( fChange )
{
fChange = 0;
Abc_NtkForEachLatch( pNtkNew, pLatch, i )
{
if ( Abc_ObjFanoutNum(pLatch) == 0 )
continue;
pFaninNew = Abc_ObjFanin0(pLatch);
if ( Abc_ObjIsCi(pFaninNew) || !Abc_NodeIsConst(pFaninNew) )
continue;
pConst = Abc_ObjNotCond( Abc_AigConst1(pManNew), Abc_ObjFaninC0(pLatch) );
Abc_AigReplace( pManNew, pLatch, pConst );
fChange = 1;
Counter++;
}
}
if ( Counter )
fprintf( stdout, "Latch sweeping removed %d latches (out of %d).\n", Counter, Abc_NtkLatchNum(pNtk) );
// redirect fanouts of each latch to the latch fanins
vNodes = Vec_PtrAlloc( 100 );
Abc_NtkForEachLatch( pNtkNew, pLatch, i )
{
//printf( "Latch %s. Fanouts = %d.\n", Abc_ObjName(pLatch), Abc_ObjFanoutNum(pLatch) );
Abc_NodeCollectFanouts( pLatch, vNodes );
Vec_PtrForEachEntry( vNodes, pFanout, k )
{
if ( Abc_ObjFaninId0(pFanout) == Abc_ObjFaninId1(pFanout))
printf( " ******* Identical fanins!!! ******* \n" );
if ( Abc_ObjFaninId0(pFanout) == (int)pLatch->Id )
{
// pFaninNew = Abc_ObjNotCond( Abc_ObjChild0(pLatch), Abc_ObjFaninC0(pFanout) );
pFaninNew = Abc_ObjChild0(pLatch);
Abc_ObjPatchFanin( pFanout, pLatch, pFaninNew );
Abc_ObjAddFaninL0( pFanout, 1 );
}
else if ( Abc_ObjFaninId1(pFanout) == (int)pLatch->Id )
{
// pFaninNew = Abc_ObjNotCond( Abc_ObjChild0(pLatch), Abc_ObjFaninC1(pFanout) );
pFaninNew = Abc_ObjChild0(pLatch);
Abc_ObjPatchFanin( pFanout, pLatch, pFaninNew );
Abc_ObjAddFaninL1( pFanout, 1 );
}
else
assert( 0 );
}
assert( Abc_ObjFanoutNum(pLatch) == 0 );
Abc_NtkDeleteObj( pLatch );
}
Vec_PtrFree( vNodes );
// get rid of latches altogether
// Abc_NtkForEachLatch( pNtkNew, pObj, i )
// Abc_NtkDeleteObj( pObj );
assert( pNtkNew->nLatches == 0 );
Vec_PtrClear( pNtkNew->vLats );
Vec_PtrShrink( pNtkNew->vCis, pNtk->nPis );
Vec_PtrShrink( pNtkNew->vCos, pNtk->nPos );
/*
/////////////////////////////////////////////
Abc_NtkForEachNode( pNtkNew, pObj, i )
if ( !Abc_NodeIsConst(pObj) )
if ( Abc_ObjFaninL0(pObj) + Abc_ObjFaninL1(pObj) > 20 )
printf( "(%d,%d) ", Abc_ObjFaninL0(pObj), Abc_ObjFaninL1(pObj) );
Abc_NtkForEachCo( pNtkNew, pObj, i )
printf( "(%d) ", Abc_ObjFaninL0(pObj) );
/////////////////////////////////////////////
printf( "\n" );
*/
if ( pNtk->pExdc )
fprintf( stdout, "Warning: EXDC is dropped when converting to sequential AIG.\n" );
if ( fCheck && !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkAigToSeq(): Network check has failed.\n" );
return pNtkNew; return pNtkNew;
} }
...@@ -83,7 +197,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk ) ...@@ -83,7 +197,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk )
int fCheck = 1; int fCheck = 1;
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pObj, * pFanin, * pFaninNew; Abc_Obj_t * pObj, * pFanin, * pFaninNew;
int i, k; int i, k, c;
assert( Abc_NtkIsSeq(pNtk) ); assert( Abc_NtkIsSeq(pNtk) );
// start the network // start the network
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC_SOP ); pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC_SOP );
...@@ -106,10 +220,14 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk ) ...@@ -106,10 +220,14 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk )
{ {
// find the fanin // find the fanin
pFaninNew = pFanin->pCopy; pFaninNew = pFanin->pCopy;
for ( i = 0; i < Abc_ObjFaninL(pObj, k); i++ ) for ( c = 0; c < Abc_ObjFaninL(pObj, k); c++ )
pFaninNew = pFaninNew->pCopy; pFaninNew = pFaninNew->pCopy;
Abc_ObjAddFanin( pObj->pCopy, pFaninNew ); Abc_ObjAddFanin( pObj->pCopy, pFaninNew );
} }
// set the complemented attributed of CO edges (to be fixed by making simple COs)
Abc_NtkForEachPo( pNtk, pObj, i )
if ( Abc_ObjFaninC0(pObj) )
Abc_ObjSetFaninC( pObj->pCopy, 0 );
// fix the problem with complemented and duplicated CO edges // fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 ); Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
// duplicate the EXDC network // duplicate the EXDC network
...@@ -142,7 +260,7 @@ Vec_Int_t * Abc_NtkSeqCountLatches( Abc_Ntk_t * pNtk ) ...@@ -142,7 +260,7 @@ Vec_Int_t * Abc_NtkSeqCountLatches( Abc_Ntk_t * pNtk )
assert( Abc_NtkIsSeq( pNtk ) ); assert( Abc_NtkIsSeq( pNtk ) );
// start the array of counters // start the array of counters
vNumbers = Vec_IntAlloc( 0 ); vNumbers = Vec_IntAlloc( 0 );
Vec_IntFill( vNumbers, Abc_NtkObjNum(pNtk), 0 ); Vec_IntFill( vNumbers, Abc_NtkObjNumMax(pNtk), 0 );
// count for each edge // count for each edge
Abc_NtkForEachObj( pNtk, pObj, i ) Abc_NtkForEachObj( pNtk, pObj, i )
Abc_NodeSeqCountLatches( pObj, vNumbers ); Abc_NodeSeqCountLatches( pObj, vNumbers );
...@@ -197,7 +315,11 @@ void Abc_NtkSeqCreateLatches( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew ) ...@@ -197,7 +315,11 @@ void Abc_NtkSeqCreateLatches( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
// create latches for each new object according to the counters // create latches for each new object according to the counters
vNumbers = Abc_NtkSeqCountLatches( pNtk ); vNumbers = Abc_NtkSeqCountLatches( pNtk );
Abc_NtkForEachObj( pNtk, pObj, i ) Abc_NtkForEachObj( pNtk, pObj, i )
Abc_NodeSeqCreateLatches( pObj->pCopy, Vec_IntEntry(vNumbers, pObj->Id) ); {
if ( pObj->pCopy == NULL )
continue;
Abc_NodeSeqCreateLatches( pObj->pCopy, Vec_IntEntry(vNumbers, (int)pObj->Id) );
}
Vec_IntFree( vNumbers ); Vec_IntFree( vNumbers );
// add latch to the PI/PO lists, create latch names // add latch to the PI/PO lists, create latch names
Abc_NtkFinalizeLatches( pNtkNew ); Abc_NtkFinalizeLatches( pNtkNew );
...@@ -224,6 +346,7 @@ void Abc_NodeSeqCreateLatches( Abc_Obj_t * pObj, int nLatches ) ...@@ -224,6 +346,7 @@ void Abc_NodeSeqCreateLatches( Abc_Obj_t * pObj, int nLatches )
for ( i = 0, pFanin = pObj; i < nLatches; pFanin = pLatch, i++ ) for ( i = 0, pFanin = pObj; i < nLatches; pFanin = pLatch, i++ )
{ {
pLatch = Abc_NtkCreateLatch( pNtk ); pLatch = Abc_NtkCreateLatch( pNtk );
Abc_LatchSetInitDc(pLatch);
Abc_ObjAddFanin( pLatch, pFanin ); Abc_ObjAddFanin( pLatch, pFanin );
pFanin->pCopy = pLatch; pFanin->pCopy = pLatch;
} }
...@@ -249,12 +372,21 @@ int Abc_NtkSeqLatchNum( Abc_Ntk_t * pNtk ) ...@@ -249,12 +372,21 @@ int Abc_NtkSeqLatchNum( Abc_Ntk_t * pNtk )
// create latches for each new object according to the counters // create latches for each new object according to the counters
Counter = 0; Counter = 0;
vNumbers = Abc_NtkSeqCountLatches( pNtk ); vNumbers = Abc_NtkSeqCountLatches( pNtk );
Abc_NtkForEachObj( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
{ {
assert( Abc_ObjFanoutLMax(pObj) == Vec_IntEntry(vNumbers, pObj->Id) ); assert( Abc_ObjFanoutLMax(pObj) == Vec_IntEntry(vNumbers, (int)pObj->Id) );
Counter += Vec_IntEntry(vNumbers, pObj->Id); Counter += Vec_IntEntry(vNumbers, (int)pObj->Id);
}
Abc_NtkForEachNode( pNtk, pObj, i )
{
if ( Abc_NodeIsConst(pObj) )
continue;
assert( Abc_ObjFanoutLMax(pObj) == Vec_IntEntry(vNumbers, (int)pObj->Id) );
Counter += Vec_IntEntry(vNumbers, (int)pObj->Id);
} }
Vec_IntFree( vNumbers ); Vec_IntFree( vNumbers );
if ( Abc_ObjFanoutNum( Abc_AigReset(pNtk->pManFunc) ) > 0 )
Counter++;
return Counter; return Counter;
} }
...@@ -284,12 +416,15 @@ void Abc_NtkSeqRetimeForward( Abc_Ntk_t * pNtk ) ...@@ -284,12 +416,15 @@ void Abc_NtkSeqRetimeForward( Abc_Ntk_t * pNtk )
vNodes = Vec_PtrAlloc( 100 ); vNodes = Vec_PtrAlloc( 100 );
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
{ {
if ( Abc_NodeIsConst(pNode) )
continue;
Vec_PtrPush( vNodes, pNode ); Vec_PtrPush( vNodes, pNode );
pNode->fMarkA = 1; pNode->fMarkA = 1;
} }
// process the nodes // process the nodes
Vec_PtrForEachEntry( vNodes, pNode, i ) Vec_PtrForEachEntry( vNodes, pNode, i )
{ {
// printf( "(%d,%d) ", Abc_ObjFaninL0(pNode), Abc_ObjFaninL0(pNode) );
// get the number of latches to retime // get the number of latches to retime
nLatches = Abc_ObjFaninLMin(pNode); nLatches = Abc_ObjFaninLMin(pNode);
if ( nLatches == 0 ) if ( nLatches == 0 )
...@@ -316,6 +451,8 @@ void Abc_NtkSeqRetimeForward( Abc_Ntk_t * pNtk ) ...@@ -316,6 +451,8 @@ void Abc_NtkSeqRetimeForward( Abc_Ntk_t * pNtk )
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
{ {
pNode->fMarkA = 0; pNode->fMarkA = 0;
if ( Abc_NodeIsConst(pNode) )
continue;
assert( Abc_ObjFaninLMin(pNode) == 0 ); assert( Abc_ObjFaninLMin(pNode) == 0 );
} }
} }
...@@ -341,6 +478,8 @@ void Abc_NtkSeqRetimeBackward( Abc_Ntk_t * pNtk ) ...@@ -341,6 +478,8 @@ void Abc_NtkSeqRetimeBackward( Abc_Ntk_t * pNtk )
vNodes = Vec_PtrAlloc( 100 ); vNodes = Vec_PtrAlloc( 100 );
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
{ {
if ( Abc_NodeIsConst(pNode) )
continue;
Vec_PtrPush( vNodes, pNode ); Vec_PtrPush( vNodes, pNode );
pNode->fMarkA = 1; pNode->fMarkA = 1;
} }
...@@ -359,6 +498,8 @@ void Abc_NtkSeqRetimeBackward( Abc_Ntk_t * pNtk ) ...@@ -359,6 +498,8 @@ void Abc_NtkSeqRetimeBackward( Abc_Ntk_t * pNtk )
Abc_ObjForEachFanin( pNode, pFanin, k ) Abc_ObjForEachFanin( pNode, pFanin, k )
{ {
Abc_ObjAddFaninL( pNode, k, nLatches ); Abc_ObjAddFaninL( pNode, k, nLatches );
if ( Abc_ObjIsPi(pFanin) || Abc_NodeIsConst(pFanin) )
continue;
if ( pFanin->fMarkA == 0 ) if ( pFanin->fMarkA == 0 )
{ // schedule the node for updating { // schedule the node for updating
Vec_PtrPush( vNodes, pFanin ); Vec_PtrPush( vNodes, pFanin );
...@@ -373,7 +514,9 @@ void Abc_NtkSeqRetimeBackward( Abc_Ntk_t * pNtk ) ...@@ -373,7 +514,9 @@ void Abc_NtkSeqRetimeBackward( Abc_Ntk_t * pNtk )
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
{ {
pNode->fMarkA = 0; pNode->fMarkA = 0;
assert( Abc_ObjFanoutLMin(pNode) == 0 ); if ( Abc_NodeIsConst(pNode) )
continue;
// assert( Abc_ObjFanoutLMin(pNode) == 0 );
} }
} }
...@@ -394,9 +537,9 @@ void Abc_NtkSeqRetimeBackward( Abc_Ntk_t * pNtk ) ...@@ -394,9 +537,9 @@ void Abc_NtkSeqRetimeBackward( Abc_Ntk_t * pNtk )
int Abc_ObjFanoutL( Abc_Obj_t * pObj, Abc_Obj_t * pFanout ) int Abc_ObjFanoutL( Abc_Obj_t * pObj, Abc_Obj_t * pFanout )
{ {
assert( Abc_NtkIsSeq(pObj->pNtk) ); assert( Abc_NtkIsSeq(pObj->pNtk) );
if ( Abc_ObjFanin0(pFanout) == pObj ) if ( Abc_ObjFaninId0(pFanout) == (int)pObj->Id )
return Abc_ObjFaninL0(pFanout); return Abc_ObjFaninL0(pFanout);
else if ( Abc_ObjFanin1(pFanout) == pObj ) else if ( Abc_ObjFaninId1(pFanout) == (int)pObj->Id )
return Abc_ObjFaninL1(pFanout); return Abc_ObjFaninL1(pFanout);
else else
assert( 0 ); assert( 0 );
...@@ -417,9 +560,9 @@ int Abc_ObjFanoutL( Abc_Obj_t * pObj, Abc_Obj_t * pFanout ) ...@@ -417,9 +560,9 @@ int Abc_ObjFanoutL( Abc_Obj_t * pObj, Abc_Obj_t * pFanout )
void Abc_ObjSetFanoutL( Abc_Obj_t * pObj, Abc_Obj_t * pFanout, int nLats ) void Abc_ObjSetFanoutL( Abc_Obj_t * pObj, Abc_Obj_t * pFanout, int nLats )
{ {
assert( Abc_NtkIsSeq(pObj->pNtk) ); assert( Abc_NtkIsSeq(pObj->pNtk) );
if ( Abc_ObjFanin0(pFanout) == pObj ) if ( Abc_ObjFaninId0(pFanout) == (int)pObj->Id )
Abc_ObjSetFaninL0(pFanout, nLats); Abc_ObjSetFaninL0(pFanout, nLats);
else if ( Abc_ObjFanin1(pFanout) == pObj ) else if ( Abc_ObjFaninId1(pFanout) == (int)pObj->Id )
Abc_ObjSetFaninL1(pFanout, nLats); Abc_ObjSetFaninL1(pFanout, nLats);
else else
assert( 0 ); assert( 0 );
...@@ -439,9 +582,9 @@ void Abc_ObjSetFanoutL( Abc_Obj_t * pObj, Abc_Obj_t * pFanout, int nLats ) ...@@ -439,9 +582,9 @@ void Abc_ObjSetFanoutL( Abc_Obj_t * pObj, Abc_Obj_t * pFanout, int nLats )
void Abc_ObjAddFanoutL( Abc_Obj_t * pObj, Abc_Obj_t * pFanout, int nLats ) void Abc_ObjAddFanoutL( Abc_Obj_t * pObj, Abc_Obj_t * pFanout, int nLats )
{ {
assert( Abc_NtkIsSeq(pObj->pNtk) ); assert( Abc_NtkIsSeq(pObj->pNtk) );
if ( Abc_ObjFanin0(pFanout) == pObj ) if ( Abc_ObjFaninId0(pFanout) == (int)pObj->Id )
Abc_ObjAddFaninL0(pFanout, nLats); Abc_ObjAddFaninL0(pFanout, nLats);
else if ( Abc_ObjFanin1(pFanout) == pObj ) else if ( Abc_ObjFaninId1(pFanout) == (int)pObj->Id )
Abc_ObjAddFaninL1(pFanout, nLats); Abc_ObjAddFaninL1(pFanout, nLats);
else else
assert( 0 ); assert( 0 );
...@@ -462,7 +605,7 @@ int Abc_ObjFanoutLMax( Abc_Obj_t * pObj ) ...@@ -462,7 +605,7 @@ int Abc_ObjFanoutLMax( Abc_Obj_t * pObj )
{ {
Abc_Obj_t * pFanout; Abc_Obj_t * pFanout;
int i, nLatch, nLatchRes; int i, nLatch, nLatchRes;
nLatchRes = -1; nLatchRes = 0;
Abc_ObjForEachFanout( pObj, pFanout, i ) Abc_ObjForEachFanout( pObj, pFanout, i )
if ( nLatchRes < (nLatch = Abc_ObjFanoutL(pObj, pFanout)) ) if ( nLatchRes < (nLatch = Abc_ObjFanoutL(pObj, pFanout)) )
nLatchRes = nLatch; nLatchRes = nLatch;
...@@ -494,7 +637,6 @@ int Abc_ObjFanoutLMin( Abc_Obj_t * pObj ) ...@@ -494,7 +637,6 @@ int Abc_ObjFanoutLMin( Abc_Obj_t * pObj )
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -121,7 +121,7 @@ int Abc_NtkRetimeForPeriod( Abc_Ntk_t * pNtk, int Fi ) ...@@ -121,7 +121,7 @@ int Abc_NtkRetimeForPeriod( Abc_Ntk_t * pNtk, int Fi )
int RetValue, i, k; int RetValue, i, k;
// set l-values of all nodes to be minus infinity // set l-values of all nodes to be minus infinity
Vec_IntFill( pNtk->pData, Abc_NtkObjNum(pNtk), -ABC_INFINITY ); Vec_IntFill( pNtk->pData, Abc_NtkObjNumMax(pNtk), -ABC_INFINITY );
// start the frontier by including PI fanouts // start the frontier by including PI fanouts
vFrontier = Vec_PtrAlloc( 100 ); vFrontier = Vec_PtrAlloc( 100 );
......
...@@ -57,6 +57,8 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes ) ...@@ -57,6 +57,8 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes )
{ {
int fCheck = 1; int fCheck = 1;
Abc_Ntk_t * pNtkAig; Abc_Ntk_t * pNtkAig;
int nNodes;
assert( !Abc_NtkIsNetlist(pNtk) ); assert( !Abc_NtkIsNetlist(pNtk) );
if ( Abc_NtkIsLogicBdd(pNtk) ) if ( Abc_NtkIsLogicBdd(pNtk) )
{ {
...@@ -73,6 +75,8 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes ) ...@@ -73,6 +75,8 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, bool fAllNodes )
// print warning about self-feed latches // print warning about self-feed latches
if ( Abc_NtkCountSelfFeedLatches(pNtkAig) ) if ( Abc_NtkCountSelfFeedLatches(pNtkAig) )
printf( "The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtkAig) ); printf( "The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtkAig) );
if ( nNodes = Abc_AigCleanup(pNtkAig->pManFunc) )
printf( "Cleanup has removed %d nodes.\n", nNodes );
// duplicate EXDC // duplicate EXDC
if ( pNtk->pExdc ) if ( pNtk->pExdc )
pNtkAig->pExdc = Abc_NtkStrash( pNtk->pExdc, 0 ); pNtkAig->pExdc = Abc_NtkStrash( pNtk->pExdc, 0 );
...@@ -106,16 +110,12 @@ void Abc_NtkStrashPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, bool fAllNodes ...@@ -106,16 +110,12 @@ void Abc_NtkStrashPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, bool fAllNodes
int i; int i;
// perform strashing // perform strashing
if ( fAllNodes ) vNodes = Abc_NtkDfs( pNtk, fAllNodes );
vNodes = Abc_AigCollectAll( pNtk );
else
vNodes = Abc_NtkDfs( pNtk );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize ); pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
for ( i = 0; i < vNodes->nSize; i++ ) Vec_PtrForEachEntry( vNodes, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
// get the node // get the node
pNode = vNodes->pArray[i];
assert( Abc_ObjIsNode(pNode) ); assert( Abc_ObjIsNode(pNode) );
// strash the node // strash the node
pNodeNew = Abc_NodeStrash( pMan, pNode ); pNodeNew = Abc_NodeStrash( pMan, pNode );
...@@ -159,9 +159,7 @@ Abc_Obj_t * Abc_NodeStrash( Abc_Aig_t * pMan, Abc_Obj_t * pNode ) ...@@ -159,9 +159,7 @@ Abc_Obj_t * Abc_NodeStrash( Abc_Aig_t * pMan, Abc_Obj_t * pNode )
// pChild1 = Abc_ObjFanin1(pNode); // pChild1 = Abc_ObjFanin1(pNode);
if ( Abc_NodeIsConst(pNode) ) if ( Abc_NodeIsConst(pNode) )
return Abc_AigConst1(pMan); return Abc_AigConst1(pMan);
return Abc_AigAnd( pMan, return Abc_AigAnd( pMan, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ),
Abc_ObjNotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) ) );
} }
// get the SOP of the node // get the SOP of the node
...@@ -471,7 +469,6 @@ Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, bool ...@@ -471,7 +469,6 @@ Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, bool
***********************************************************************/ ***********************************************************************/
int Abc_NodeBalanceCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, bool fFirst, bool fDuplicate ) int Abc_NodeBalanceCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, bool fFirst, bool fDuplicate )
{ {
Abc_Obj_t * p0, * p1;
int RetValue1, RetValue2, i; int RetValue1, RetValue2, i;
// check if the node is visited // check if the node is visited
if ( Abc_ObjRegular(pNode)->fMarkB ) if ( Abc_ObjRegular(pNode)->fMarkB )
...@@ -496,12 +493,9 @@ int Abc_NodeBalanceCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, bool fFirst, ...@@ -496,12 +493,9 @@ int Abc_NodeBalanceCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, bool fFirst,
} }
assert( !Abc_ObjIsComplement(pNode) ); assert( !Abc_ObjIsComplement(pNode) );
assert( Abc_ObjIsNode(pNode) ); assert( Abc_ObjIsNode(pNode) );
// get the children
p0 = Abc_ObjNotCond( Abc_ObjFanin0(pNode), Abc_ObjFaninC0(pNode) );
p1 = Abc_ObjNotCond( Abc_ObjFanin1(pNode), Abc_ObjFaninC1(pNode) );
// go through the branches // go through the branches
RetValue1 = Abc_NodeBalanceCone_rec( p0, vSuper, 0, fDuplicate ); RetValue1 = Abc_NodeBalanceCone_rec( Abc_ObjChild0(pNode), vSuper, 0, fDuplicate );
RetValue2 = Abc_NodeBalanceCone_rec( p1, vSuper, 0, fDuplicate ); RetValue2 = Abc_NodeBalanceCone_rec( Abc_ObjChild1(pNode), vSuper, 0, fDuplicate );
if ( RetValue1 == -1 || RetValue2 == -1 ) if ( RetValue1 == -1 || RetValue2 == -1 )
return -1; return -1;
// return 1 if at least one branch has a duplicate // return 1 if at least one branch has a duplicate
......
...@@ -395,7 +395,7 @@ int Abc_NtkCleanup( Abc_Ntk_t * pNtk, int fVerbose ) ...@@ -395,7 +395,7 @@ int Abc_NtkCleanup( Abc_Ntk_t * pNtk, int fVerbose )
Abc_Obj_t * pNode; Abc_Obj_t * pNode;
int i, Counter; int i, Counter;
// mark the nodes reachable from the POs // mark the nodes reachable from the POs
vNodes = Abc_NtkDfs( pNtk ); vNodes = Abc_NtkDfs( pNtk, 0 );
for ( i = 0; i < vNodes->nSize; i++ ) for ( i = 0; i < vNodes->nSize; i++ )
{ {
pNode = vNodes->pArray[i]; pNode = vNodes->pArray[i];
......
...@@ -235,7 +235,7 @@ void Abc_NtkTimeInitialize( Abc_Ntk_t * pNtk ) ...@@ -235,7 +235,7 @@ void Abc_NtkTimeInitialize( Abc_Ntk_t * pNtk )
int i; int i;
if ( pNtk->pManTime == NULL ) if ( pNtk->pManTime == NULL )
return; return;
Abc_ManTimeExpand( pNtk->pManTime, Abc_NtkObjNum(pNtk), 0 ); Abc_ManTimeExpand( pNtk->pManTime, Abc_NtkObjNumMax(pNtk), 0 );
// set the default timing // set the default timing
ppTimes = (Abc_Time_t **)pNtk->pManTime->vArrs->pArray; ppTimes = (Abc_Time_t **)pNtk->pManTime->vArrs->pArray;
Abc_NtkForEachPi( pNtk, pObj, i ) Abc_NtkForEachPi( pNtk, pObj, i )
...@@ -287,7 +287,7 @@ void Abc_NtkTimePrepare( Abc_Ntk_t * pNtk ) ...@@ -287,7 +287,7 @@ void Abc_NtkTimePrepare( Abc_Ntk_t * pNtk )
return; return;
} }
// if timing manager is given, expand it if necessary // if timing manager is given, expand it if necessary
Abc_ManTimeExpand( pNtk->pManTime, Abc_NtkObjNum(pNtk), 0 ); Abc_ManTimeExpand( pNtk->pManTime, Abc_NtkObjNumMax(pNtk), 0 );
// clean arrivals except for PIs // clean arrivals except for PIs
ppTimes = (Abc_Time_t **)pNtk->pManTime->vArrs->pArray; ppTimes = (Abc_Time_t **)pNtk->pManTime->vArrs->pArray;
Abc_NtkForEachNode( pNtk, pObj, i ) Abc_NtkForEachNode( pNtk, pObj, i )
...@@ -376,7 +376,7 @@ void Abc_ManTimeDup( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew ) ...@@ -376,7 +376,7 @@ void Abc_ManTimeDup( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew )
assert( Abc_NtkLatchNum(pNtkOld) == Abc_NtkLatchNum(pNtkNew) ); assert( Abc_NtkLatchNum(pNtkOld) == Abc_NtkLatchNum(pNtkNew) );
// create the new timing manager // create the new timing manager
pNtkNew->pManTime = Abc_ManTimeStart(); pNtkNew->pManTime = Abc_ManTimeStart();
Abc_ManTimeExpand( pNtkNew->pManTime, Abc_NtkObjNum(pNtkNew), 0 ); Abc_ManTimeExpand( pNtkNew->pManTime, Abc_NtkObjNumMax(pNtkNew), 0 );
// set the default timing // set the default timing
pNtkNew->pManTime->tArrDef = pNtkOld->pManTime->tArrDef; pNtkNew->pManTime->tArrDef = pNtkOld->pManTime->tArrDef;
pNtkNew->pManTime->tReqDef = pNtkOld->pManTime->tReqDef; pNtkNew->pManTime->tReqDef = pNtkOld->pManTime->tReqDef;
...@@ -556,7 +556,7 @@ float Abc_NtkDelayTrace( Abc_Ntk_t * pNtk ) ...@@ -556,7 +556,7 @@ float Abc_NtkDelayTrace( Abc_Ntk_t * pNtk )
assert( Abc_NtkIsLogicMap(pNtk) ); assert( Abc_NtkIsLogicMap(pNtk) );
Abc_NtkTimePrepare( pNtk ); Abc_NtkTimePrepare( pNtk );
vNodes = Abc_NtkDfs( pNtk ); vNodes = Abc_NtkDfs( pNtk, 1 );
for ( i = 0; i < vNodes->nSize; i++ ) for ( i = 0; i < vNodes->nSize; i++ )
Abc_NodeDelayTraceArrival( vNodes->pArray[i] ); Abc_NodeDelayTraceArrival( vNodes->pArray[i] );
Vec_PtrFree( vNodes ); Vec_PtrFree( vNodes );
......
...@@ -190,7 +190,7 @@ DdNode * Abc_NtkInitStateAndVarMap( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbo ...@@ -190,7 +190,7 @@ DdNode * Abc_NtkInitStateAndVarMap( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbo
pbVarsX[i] = dd->vars[ Abc_NtkPiNum(pNtk) + i ]; pbVarsX[i] = dd->vars[ Abc_NtkPiNum(pNtk) + i ];
pbVarsY[i] = dd->vars[ Abc_NtkCiNum(pNtk) + i ]; pbVarsY[i] = dd->vars[ Abc_NtkCiNum(pNtk) + i ];
// get the initial value of the latch // get the initial value of the latch
bVar = Cudd_NotCond( pbVarsX[i], (((int)pLatch->pData) != 1) ); bVar = Cudd_NotCond( pbVarsX[i], !Abc_LatchIsInit1(pLatch) );
bProd = Cudd_bddAnd( dd, bTemp = bProd, bVar ); Cudd_Ref( bProd ); bProd = Cudd_bddAnd( dd, bTemp = bProd, bVar ); Cudd_Ref( bProd );
Cudd_RecursiveDeref( dd, bTemp ); Cudd_RecursiveDeref( dd, bTemp );
} }
......
...@@ -640,6 +640,12 @@ int Abc_NtkPrepareCommand( FILE * pErr, Abc_Ntk_t * pNtk, char ** argv, int argc ...@@ -640,6 +640,12 @@ int Abc_NtkPrepareCommand( FILE * pErr, Abc_Ntk_t * pNtk, char ** argv, int argc
else else
fclose( pFile ); fclose( pFile );
if ( Abc_NtkIsSeq(pNtk) )
{
pNtk1 = Abc_NtkSeqToLogicSop(pNtk);
*pfDelete1 = 1;
}
else
pNtk1 = pNtk; pNtk1 = pNtk;
pNtk2 = Io_Read( pNtk->pSpec, fCheck ); pNtk2 = Io_Read( pNtk->pSpec, fCheck );
if ( pNtk2 == NULL ) if ( pNtk2 == NULL )
...@@ -653,6 +659,12 @@ int Abc_NtkPrepareCommand( FILE * pErr, Abc_Ntk_t * pNtk, char ** argv, int argc ...@@ -653,6 +659,12 @@ int Abc_NtkPrepareCommand( FILE * pErr, Abc_Ntk_t * pNtk, char ** argv, int argc
fprintf( pErr, "Empty current network.\n" ); fprintf( pErr, "Empty current network.\n" );
return 0; return 0;
} }
if ( Abc_NtkIsSeq(pNtk) )
{
pNtk1 = Abc_NtkSeqToLogicSop(pNtk);
*pfDelete1 = 1;
}
else
pNtk1 = pNtk; pNtk1 = pNtk;
pNtk2 = Io_Read( argv[util_optind], fCheck ); pNtk2 = Io_Read( argv[util_optind], fCheck );
if ( pNtk2 == NULL ) if ( pNtk2 == NULL )
...@@ -766,10 +778,9 @@ int Abc_NodeCompareLevelsDecrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 ) ...@@ -766,10 +778,9 @@ int Abc_NodeCompareLevelsDecrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 )
return 0; return 0;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Collect all nodes by level.] Synopsis [Procedure used for sorting the nodes in decreasing order of levels.]
Description [] Description []
...@@ -778,23 +789,17 @@ int Abc_NodeCompareLevelsDecrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 ) ...@@ -778,23 +789,17 @@ int Abc_NodeCompareLevelsDecrease( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Vec_Ptr_t * Abc_AigCollectAll( Abc_Ntk_t * pNtk ) int Abc_NodeCompareNames( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 )
{ {
Vec_Ptr_t * vNodes; int Diff = strcmp( (char *)(*pp1)->pCopy, (char *)(*pp2)->pCopy );
Abc_Obj_t * pNode; if ( Diff < 0 )
int i; return -1;
vNodes = Vec_PtrAlloc( 100 ); if ( Diff > 0 )
Abc_NtkForEachNode( pNtk, pNode, i ) return 1;
Vec_PtrPush( vNodes, pNode ); return 0;
// works only if the levels are set!!!
if ( !Abc_NtkIsAig(pNtk) )
Abc_NtkGetLevelNum(pNtk);
Vec_PtrSort( vNodes, Abc_NodeCompareLevelsIncrease );
return vNodes;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Gets fanin node names.] Synopsis [Gets fanin node names.]
...@@ -867,6 +872,53 @@ char ** Abc_NtkCollectCioNames( Abc_Ntk_t * pNtk, int fCollectCos ) ...@@ -867,6 +872,53 @@ char ** Abc_NtkCollectCioNames( Abc_Ntk_t * pNtk, int fCollectCos )
return ppNames; return ppNames;
} }
/**Function*************************************************************
Synopsis [Orders PIs/POs/latches alphabetically.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkAlphaOrderSignals( Abc_Ntk_t * pNtk, int fComb )
{
Abc_Obj_t * pObj;
int i;
// temporarily store the names in the copy field
Abc_NtkForEachPi( pNtk, pObj, i )
pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
Abc_NtkForEachPo( pNtk, pObj, i )
pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
Abc_NtkForEachLatch( pNtk, pObj, i )
pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
// order objects alphabetically
qsort( pNtk->vCis->pArray, pNtk->nPis, sizeof(Abc_Obj_t *),
(int (*)(const void *, const void *)) Abc_NodeCompareNames );
qsort( pNtk->vCos->pArray, pNtk->nPos, sizeof(Abc_Obj_t *),
(int (*)(const void *, const void *)) Abc_NodeCompareNames );
// if the comparison if combinational (latches as PIs/POs), order them too
if ( fComb )
{
qsort( pNtk->vLats->pArray, pNtk->nLatches, sizeof(Abc_Obj_t *),
(int (*)(const void *, const void *)) Abc_NodeCompareNames );
// add latches to make COs
Abc_NtkForEachLatch( pNtk, pObj, i )
{
Vec_PtrWriteEntry( pNtk->vCis, pNtk->nPis + i, pObj );
Vec_PtrWriteEntry( pNtk->vCos, pNtk->nPos + i, pObj );
}
}
// clean the copy fields
Abc_NtkForEachPi( pNtk, pObj, i )
pObj->pCopy = NULL;
Abc_NtkForEachPo( pNtk, pObj, i )
pObj->pCopy = NULL;
Abc_NtkForEachLatch( pNtk, pObj, i )
pObj->pCopy = NULL;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -57,7 +57,7 @@ void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) ...@@ -57,7 +57,7 @@ void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
if ( RetValue == 1 ) if ( RetValue == 1 )
{ {
Abc_NtkDelete( pMiter ); Abc_NtkDelete( pMiter );
printf( "Networks are not equivalent.\n" ); printf( "Networks are NOT EQUIVALENT after structural hashing.\n" );
return; return;
} }
if ( RetValue == 0 ) if ( RetValue == 0 )
...@@ -78,9 +78,9 @@ void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) ...@@ -78,9 +78,9 @@ void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
// solve the CNF using the SAT solver // solve the CNF using the SAT solver
if ( Abc_NtkMiterSat( pCnf, 0 ) ) if ( Abc_NtkMiterSat( pCnf, 0 ) )
printf( "Networks are not equivalent.\n" ); printf( "Networks are NOT EQUIVALENT after SAT.\n" );
else else
printf( "Networks are equivalent.\n" ); printf( "Networks are equivalent after SAT.\n" );
Abc_NtkDelete( pCnf ); Abc_NtkDelete( pCnf );
} }
...@@ -96,7 +96,7 @@ void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) ...@@ -96,7 +96,7 @@ void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fVerbose )
{ {
Fraig_Params_t Params; Fraig_Params_t Params;
Abc_Ntk_t * pMiter; Abc_Ntk_t * pMiter;
...@@ -114,7 +114,7 @@ void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) ...@@ -114,7 +114,7 @@ void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
if ( RetValue == 1 ) if ( RetValue == 1 )
{ {
Abc_NtkDelete( pMiter ); Abc_NtkDelete( pMiter );
printf( "Networks are not equivalent.\n" ); printf( "Networks are NOT EQUIVALENT after structural hashing.\n" );
return; return;
} }
if ( RetValue == 0 ) if ( RetValue == 0 )
...@@ -126,6 +126,7 @@ void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) ...@@ -126,6 +126,7 @@ void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
// convert the miter into a FRAIG // convert the miter into a FRAIG
Fraig_ParamsSetDefault( &Params ); Fraig_ParamsSetDefault( &Params );
Params.fVerbose = fVerbose;
pFraig = Abc_NtkFraig( pMiter, &Params, 0 ); pFraig = Abc_NtkFraig( pMiter, &Params, 0 );
Abc_NtkDelete( pMiter ); Abc_NtkDelete( pMiter );
if ( pFraig == NULL ) if ( pFraig == NULL )
...@@ -140,7 +141,7 @@ void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) ...@@ -140,7 +141,7 @@ void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
printf( "Networks are equivalent after fraiging.\n" ); printf( "Networks are equivalent after fraiging.\n" );
return; return;
} }
printf( "Networks are not equivalent.\n" ); printf( "Networks are NOT EQUIVALENT after fraiging.\n" );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -172,7 +173,7 @@ void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames ) ...@@ -172,7 +173,7 @@ void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames )
if ( RetValue == 1 ) if ( RetValue == 1 )
{ {
Abc_NtkDelete( pMiter ); Abc_NtkDelete( pMiter );
printf( "Networks are not equivalent.\n" ); printf( "Networks are NOT EQUIVALENT after structural hashing.\n" );
return; return;
} }
if ( RetValue == 0 ) if ( RetValue == 0 )
...@@ -194,7 +195,7 @@ void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames ) ...@@ -194,7 +195,7 @@ void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames )
if ( RetValue == 1 ) if ( RetValue == 1 )
{ {
Abc_NtkDelete( pFrames ); Abc_NtkDelete( pFrames );
printf( "Networks are not equivalent.\n" ); printf( "Networks are NOT EQUIVALENT after framing.\n" );
return; return;
} }
if ( RetValue == 0 ) if ( RetValue == 0 )
...@@ -215,9 +216,9 @@ void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames ) ...@@ -215,9 +216,9 @@ void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames )
// solve the CNF using the SAT solver // solve the CNF using the SAT solver
if ( Abc_NtkMiterSat( pCnf, 0 ) ) if ( Abc_NtkMiterSat( pCnf, 0 ) )
printf( "Networks are not equivalent.\n" ); printf( "Networks are NOT EQUIVALENT after SAT.\n" );
else else
printf( "Networks are equivalent.\n" ); printf( "Networks are equivalent after SAT.\n" );
Abc_NtkDelete( pCnf ); Abc_NtkDelete( pCnf );
} }
...@@ -251,7 +252,7 @@ void Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames ) ...@@ -251,7 +252,7 @@ void Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames )
if ( RetValue == 1 ) if ( RetValue == 1 )
{ {
Abc_NtkDelete( pMiter ); Abc_NtkDelete( pMiter );
printf( "Networks are not equivalent.\n" ); printf( "Networks are NOT EQUIVALENT after structural hashing.\n" );
return; return;
} }
if ( RetValue == 0 ) if ( RetValue == 0 )
...@@ -273,7 +274,7 @@ void Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames ) ...@@ -273,7 +274,7 @@ void Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames )
if ( RetValue == 1 ) if ( RetValue == 1 )
{ {
Abc_NtkDelete( pFrames ); Abc_NtkDelete( pFrames );
printf( "Networks are not equivalent.\n" ); printf( "Networks are NOT EQUIVALENT after framing.\n" );
return; return;
} }
if ( RetValue == 0 ) if ( RetValue == 0 )
...@@ -285,7 +286,7 @@ void Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames ) ...@@ -285,7 +286,7 @@ void Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames )
// convert the miter into a FRAIG // convert the miter into a FRAIG
Fraig_ParamsSetDefault( &Params ); Fraig_ParamsSetDefault( &Params );
pFraig = Abc_NtkFraig( pMiter, &Params, 0 ); pFraig = Abc_NtkFraig( pFrames, &Params, 0 );
Abc_NtkDelete( pFrames ); Abc_NtkDelete( pFrames );
if ( pFraig == NULL ) if ( pFraig == NULL )
{ {
...@@ -299,7 +300,7 @@ void Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames ) ...@@ -299,7 +300,7 @@ void Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames )
printf( "Networks are equivalent after fraiging.\n" ); printf( "Networks are equivalent after fraiging.\n" );
return; return;
} }
printf( "Networks are not equivalent.\n" ); printf( "Networks are NOT EQUIVALENT after fraiging.\n" );
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
static int IoCommandRead ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandRead ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadBlif ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadBlif ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadBench ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadBench ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadEdif ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadVerilog ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadVerilog ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadPla ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadPla ( Abc_Frame_t * pAbc, int argc, char **argv );
...@@ -56,6 +57,7 @@ void Io_Init( Abc_Frame_t * pAbc ) ...@@ -56,6 +57,7 @@ void Io_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "I/O", "read", IoCommandRead, 1 ); Cmd_CommandAdd( pAbc, "I/O", "read", IoCommandRead, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_blif", IoCommandReadBlif, 1 ); Cmd_CommandAdd( pAbc, "I/O", "read_blif", IoCommandReadBlif, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_bench", IoCommandReadBench, 1 ); Cmd_CommandAdd( pAbc, "I/O", "read_bench", IoCommandReadBench, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_edif", IoCommandReadEdif, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_verilog", IoCommandReadVerilog, 1 ); Cmd_CommandAdd( pAbc, "I/O", "read_verilog", IoCommandReadVerilog, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_pla", IoCommandReadPla, 1 ); Cmd_CommandAdd( pAbc, "I/O", "read_pla", IoCommandReadPla, 1 );
...@@ -232,6 +234,7 @@ usage: ...@@ -232,6 +234,7 @@ usage:
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" ); fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
return 1; return 1;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis []
...@@ -323,6 +326,86 @@ usage: ...@@ -323,6 +326,86 @@ usage:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int IoCommandReadEdif( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk, * pTemp;
char * FileName;
FILE * pFile;
int fCheck;
int c;
fCheck = 1;
util_getopt_reset();
while ( ( c = util_getopt( argc, argv, "ch" ) ) != EOF )
{
switch ( c )
{
case 'c':
fCheck ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( argc != util_optind + 1 )
{
goto usage;
}
// get the input file name
FileName = argv[util_optind];
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".mvpla", NULL ) )
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
pNtk = Io_ReadEdif( FileName, fCheck );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Reading network from EDIF file has failed.\n" );
return 1;
}
pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk );
Abc_NtkDelete( pTemp );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Converting to logic network after reading has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_edif [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in EDIF (works only for ISCAS benchmarks)\n" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv ) int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
Abc_Ntk_t * pNtk, * pTemp; Abc_Ntk_t * pNtk, * pTemp;
...@@ -521,12 +604,13 @@ int IoCommandWriteBlif( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -521,12 +604,13 @@ int IoCommandWriteBlif( Abc_Frame_t * pAbc, int argc, char **argv )
FileName = argv[util_optind]; FileName = argv[util_optind];
// check the network type // check the network type
if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsAig(pNtk) ) if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsAig(pNtk) && !Abc_NtkIsSeq(pNtk) )
{ {
fprintf( pAbc->Out, "Currently can only write logic networks and AIGs.\n" ); fprintf( pAbc->Out, "Currently can only write logic networks, AIGs, and seq AIGs.\n" );
return 0; return 0;
} }
Io_WriteBlifLogic( pNtk, FileName, fWriteLatches ); Io_WriteBlifLogic( pNtk, FileName, fWriteLatches );
// Io_WriteBlif( pNtk, FileName, fWriteLatches );
return 0; return 0;
usage: usage:
......
...@@ -51,6 +51,8 @@ extern Abc_Ntk_t * Io_Read( char * pFileName, int fCheck ); ...@@ -51,6 +51,8 @@ extern Abc_Ntk_t * Io_Read( char * pFileName, int fCheck );
extern Abc_Ntk_t * Io_ReadBlif( char * pFileName, int fCheck ); extern Abc_Ntk_t * Io_ReadBlif( char * pFileName, int fCheck );
/*=== abcReadBench.c ==========================================================*/ /*=== abcReadBench.c ==========================================================*/
extern Abc_Ntk_t * Io_ReadBench( char * pFileName, int fCheck ); extern Abc_Ntk_t * Io_ReadBench( char * pFileName, int fCheck );
/*=== abcReadEdif.c ==========================================================*/
extern Abc_Ntk_t * Io_ReadEdif( char * pFileName, int fCheck );
/*=== abcReadVerilog.c ==========================================================*/ /*=== abcReadVerilog.c ==========================================================*/
extern Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck ); extern Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck );
/*=== abcReadPla.c ==========================================================*/ /*=== abcReadPla.c ==========================================================*/
......
...@@ -49,6 +49,8 @@ Abc_Ntk_t * Io_Read( char * pFileName, int fCheck ) ...@@ -49,6 +49,8 @@ Abc_Ntk_t * Io_Read( char * pFileName, int fCheck )
pNtk = Io_ReadVerilog( pFileName, fCheck ); pNtk = Io_ReadVerilog( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "bench" ) ) else if ( Extra_FileNameCheckExtension( pFileName, "bench" ) )
pNtk = Io_ReadBench( pFileName, fCheck ); pNtk = Io_ReadBench( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "edf" ) )
pNtk = Io_ReadEdif( pFileName, fCheck );
else if ( Extra_FileNameCheckExtension( pFileName, "pla" ) ) else if ( Extra_FileNameCheckExtension( pFileName, "pla" ) )
pNtk = Io_ReadPla( pFileName, fCheck ); pNtk = Io_ReadPla( pFileName, fCheck );
else else
...@@ -58,6 +60,7 @@ Abc_Ntk_t * Io_Read( char * pFileName, int fCheck ) ...@@ -58,6 +60,7 @@ Abc_Ntk_t * Io_Read( char * pFileName, int fCheck )
} }
if ( pNtk == NULL ) if ( pNtk == NULL )
return NULL; return NULL;
pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk ); pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk );
Abc_NtkDelete( pTemp ); Abc_NtkDelete( pTemp );
if ( pNtk == NULL ) if ( pNtk == NULL )
......
...@@ -32,9 +32,9 @@ static Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p ); ...@@ -32,9 +32,9 @@ static Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p );
/**Function************************************************************* /**Function*************************************************************
Synopsis [Read the network from BENCH file.] Synopsis [Reads the network from a BENCH file.]
Description [Currently works only for the miter cone.] Description []
SideEffects [] SideEffects []
...@@ -68,9 +68,9 @@ Abc_Ntk_t * Io_ReadBench( char * pFileName, int fCheck ) ...@@ -68,9 +68,9 @@ Abc_Ntk_t * Io_ReadBench( char * pFileName, int fCheck )
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Read the network from BENCH file.] Synopsis []
Description [Currently works only for the miter cone.] Description []
SideEffects [] SideEffects []
......
...@@ -66,9 +66,9 @@ static int Io_ReadBlifNetworkDefaultInputArrival( Io_ReadBlif_t * p, Vec_Ptr_t * ...@@ -66,9 +66,9 @@ static int Io_ReadBlifNetworkDefaultInputArrival( Io_ReadBlif_t * p, Vec_Ptr_t *
/**Function************************************************************* /**Function*************************************************************
Synopsis [Read the network from BLIF file.] Synopsis [Reads the network from a BLIF file.]
Description [] Description [Works only for flat (non-hierarchical) BLIF.]
SideEffects [] SideEffects []
......
/**CFile****************************************************************
FileName [ioReadEdif.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Command processing package.]
Synopsis [Procedure to read ISCAS benchmarks in EDIF.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: ioReadEdif.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "io.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static Abc_Ntk_t * Io_ReadEdifNetwork( Extra_FileReader_t * p );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Reads the network from an EDIF file.]
Description [Works only for the ISCAS benchmarks.]
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Io_ReadEdif( char * pFileName, int fCheck )
{
Extra_FileReader_t * p;
Abc_Ntk_t * pNtk;
// start the file
p = Extra_FileReaderAlloc( pFileName, "#", "\n", " \t\r()" );
if ( p == NULL )
return NULL;
// read the network
pNtk = Io_ReadEdifNetwork( p );
Extra_FileReaderFree( p );
if ( pNtk == NULL )
return NULL;
// make sure that everything is okay with the network structure
if ( fCheck && !Abc_NtkCheck( pNtk ) )
{
printf( "Io_ReadEdif: The network check has failed.\n" );
Abc_NtkDelete( pNtk );
return NULL;
}
return pNtk;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Ntk_t * Io_ReadEdifNetwork( Extra_FileReader_t * p )
{
ProgressBar * pProgress;
Vec_Ptr_t * vTokens;
Abc_Ntk_t * pNtk;
Abc_Obj_t * pNet, * pObj, * pFanout;
char * pGateName, * pNetName;
int fTokensReady, iLine, i;
// read the first line
vTokens = Extra_FileReaderGetTokens(p);
if ( strcmp( vTokens->pArray[0], "edif" ) != 0 )
{
printf( "%s: Wrong input file format.\n", Extra_FileReaderGetFileName(p) );
return NULL;
}
// allocate the empty network
pNtk = Abc_NtkStartRead( Extra_FileReaderGetFileName(p) );
// go through the lines of the file
fTokensReady = 0;
pProgress = Extra_ProgressBarStart( stdout, Extra_FileReaderGetFileSize(p) );
for ( iLine = 1; fTokensReady || (vTokens = Extra_FileReaderGetTokens(p)); iLine++ )
{
Extra_ProgressBarUpdate( pProgress, Extra_FileReaderGetCurPosition(p), NULL );
// get the type of the line
fTokensReady = 0;
if ( strcmp( vTokens->pArray[0], "instance" ) == 0 )
{
pNetName = vTokens->pArray[1];
pNet = Abc_NtkFindOrCreateNet( pNtk, pNetName );
vTokens = Extra_FileReaderGetTokens(p);
vTokens = Extra_FileReaderGetTokens(p);
pGateName = vTokens->pArray[1];
if ( strncmp( pGateName, "Flip", 4 ) == 0 )
pObj = Abc_NtkCreateLatch( pNtk );
else
{
pObj = Abc_NtkCreateNode( pNtk );
pObj->pData = Abc_NtkRegisterName( pNtk, pGateName );
}
Abc_ObjAddFanin( pNet, pObj );
}
else if ( strcmp( vTokens->pArray[0], "net" ) == 0 )
{
pNetName = vTokens->pArray[1];
if ( strcmp( pNetName, "CK" ) == 0 || strcmp( pNetName, "RESET" ) == 0 )
continue;
if ( strcmp( pNetName + strlen(pNetName) - 4, "_out" ) == 0 )
pNetName[strlen(pNetName) - 4] = 0;
pNet = Abc_NtkFindNet( pNtk, pNetName );
assert( pNet );
vTokens = Extra_FileReaderGetTokens(p);
vTokens = Extra_FileReaderGetTokens(p);
vTokens = Extra_FileReaderGetTokens(p);
while ( strcmp( vTokens->pArray[0], "portRef" ) == 0 )
{
if ( strcmp( pNetName, vTokens->pArray[3] ) != 0 )
{
pFanout = Abc_NtkFindNet( pNtk, vTokens->pArray[3] );
Abc_ObjAddFanin( Abc_ObjFanin0(pFanout), pNet );
}
vTokens = Extra_FileReaderGetTokens(p);
}
fTokensReady = 1;
}
else if ( strcmp( vTokens->pArray[0], "library" ) == 0 )
{
vTokens = Extra_FileReaderGetTokens(p);
vTokens = Extra_FileReaderGetTokens(p);
vTokens = Extra_FileReaderGetTokens(p);
vTokens = Extra_FileReaderGetTokens(p);
vTokens = Extra_FileReaderGetTokens(p);
while ( strcmp( vTokens->pArray[0], "port" ) == 0 )
{
pNetName = vTokens->pArray[1];
if ( strcmp( pNetName, "CK" ) == 0 || strcmp( pNetName, "RESET" ) == 0 )
{
vTokens = Extra_FileReaderGetTokens(p);
continue;
}
if ( strcmp( pNetName + strlen(pNetName) - 3, "_PO" ) == 0 )
pNetName[strlen(pNetName) - 3] = 0;
if ( strcmp( vTokens->pArray[3], "INPUT" ) == 0 )
Io_ReadCreatePi( pNtk, vTokens->pArray[1] );
else if ( strcmp( vTokens->pArray[3], "OUTPUT" ) == 0 )
Io_ReadCreatePo( pNtk, vTokens->pArray[1] );
else
{
printf( "%s (line %d): Wrong interface specification.\n", Extra_FileReaderGetFileName(p), iLine );
Abc_NtkDelete( pNtk );
return NULL;
}
vTokens = Extra_FileReaderGetTokens(p);
}
}
else if ( strcmp( vTokens->pArray[0], "design" ) == 0 )
{
free( pNtk->pName );
pNtk->pName = util_strsav( vTokens->pArray[3] );
break;
}
}
Extra_ProgressBarStop( pProgress );
// assign logic functions
Abc_NtkForEachNode( pNtk, pObj, i )
{
if ( strncmp( pObj->pData, "And", 3 ) == 0 )
Abc_ObjSetData( pObj, Abc_SopCreateAnd(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
else if ( strncmp( pObj->pData, "Or", 2 ) == 0 )
Abc_ObjSetData( pObj, Abc_SopCreateOr(pNtk->pManFunc, Abc_ObjFaninNum(pObj), NULL) );
else if ( strncmp( pObj->pData, "Nand", 4 ) == 0 )
Abc_ObjSetData( pObj, Abc_SopCreateNand(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
else if ( strncmp( pObj->pData, "Nor", 3 ) == 0 )
Abc_ObjSetData( pObj, Abc_SopCreateNor(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
else if ( strncmp( pObj->pData, "Exor", 4 ) == 0 )
Abc_ObjSetData( pObj, Abc_SopCreateXor(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
else if ( strncmp( pObj->pData, "Exnor", 5 ) == 0 )
Abc_ObjSetData( pObj, Abc_SopCreateNxor(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
else if ( strncmp( pObj->pData, "Inv", 3 ) == 0 )
Abc_ObjSetData( pObj, Abc_SopCreateInv(pNtk->pManFunc) );
else if ( strncmp( pObj->pData, "Buf", 3 ) == 0 )
Abc_ObjSetData( pObj, Abc_SopCreateBuf(pNtk->pManFunc) );
else
{
printf( "%s: Unknown gate type \"%s\".\n", Extra_FileReaderGetFileName(p), pObj->pData );
Abc_NtkDelete( pNtk );
return NULL;
}
}
// check if constants have been added
// if ( pNet = Abc_NtkFindNet( pNtk, "VDD" ) )
// Io_ReadCreateConst( pNtk, "VDD", 1 );
// if ( pNet = Abc_NtkFindNet( pNtk, "GND" ) )
// Io_ReadCreateConst( pNtk, "GND", 0 );
Abc_NtkFinalizeRead( pNtk );
return pNtk;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...@@ -32,9 +32,9 @@ static Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p ); ...@@ -32,9 +32,9 @@ static Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p );
/**Function************************************************************* /**Function*************************************************************
Synopsis [Read the network from BENCH file.] Synopsis [Reads the network from a PLA file.]
Description [Currently works only for the miter cone.] Description []
SideEffects [] SideEffects []
...@@ -68,9 +68,9 @@ Abc_Ntk_t * Io_ReadPla( char * pFileName, int fCheck ) ...@@ -68,9 +68,9 @@ Abc_Ntk_t * Io_ReadPla( char * pFileName, int fCheck )
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Read the network from BENCH file.] Synopsis []
Description [Currently works only for the miter cone.] Description []
SideEffects [] SideEffects []
......
...@@ -124,9 +124,9 @@ static void Io_ReadVerFree( Io_ReadVer_t * p ); ...@@ -124,9 +124,9 @@ static void Io_ReadVerFree( Io_ReadVer_t * p );
/**Function************************************************************* /**Function*************************************************************
Synopsis [Read the network from BENCH file.] Synopsis [Reads the network from a Verilog file.]
Description [Currently works only for the miter cone.] Description [Works only for IWLS 2005 benchmarks.]
SideEffects [] SideEffects []
...@@ -633,9 +633,13 @@ bool Io_ReadVerNetworkGateComplex( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t ...@@ -633,9 +633,13 @@ bool Io_ReadVerNetworkGateComplex( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t
bool Io_ReadVerNetworkLatch( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vTokens ) bool Io_ReadVerNetworkLatch( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vTokens )
{ {
Abc_Obj_t * pLatch, * pNet; Abc_Obj_t * pLatch, * pNet;
char * pLatchName;
char * pToken, * pToken2, * pTokenRN, * pTokenSN, * pTokenSI, * pTokenSE, * pTokenD, * pTokenQ, * pTokenQN; char * pToken, * pToken2, * pTokenRN, * pTokenSN, * pTokenSI, * pTokenSE, * pTokenD, * pTokenQ, * pTokenQN;
int k, fRN1, fSN1; int k, fRN1, fSN1;
// get the latch name
pLatchName = vTokens->pArray[1];
// collect the FF signals // collect the FF signals
pTokenRN = pTokenSN = pTokenSI = pTokenSE = pTokenD = pTokenQ = pTokenQN = NULL; pTokenRN = pTokenSN = pTokenSI = pTokenSE = pTokenD = pTokenQ = pTokenQN = NULL;
for ( k = 2; k < vTokens->nSize-1; k++ ) for ( k = 2; k < vTokens->nSize-1; k++ )
...@@ -666,21 +670,21 @@ bool Io_ReadVerNetworkLatch( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vTo ...@@ -666,21 +670,21 @@ bool Io_ReadVerNetworkLatch( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vTo
if ( pTokenD == NULL ) if ( pTokenD == NULL )
{ {
p->LineCur = Extra_FileReaderGetLineNumber( p->pReader, 1 ); p->LineCur = Extra_FileReaderGetLineNumber( p->pReader, 1 );
sprintf( p->sError, "Cannot read pin D of the latch \"%s\".", vTokens->pArray[1] ); sprintf( p->sError, "Cannot read pin D of the latch \"%s\".", pLatchName );
Io_ReadVerPrintErrorMessage( p ); Io_ReadVerPrintErrorMessage( p );
return 0; return 0;
} }
if ( pTokenQ == NULL && pTokenQN == NULL ) if ( pTokenQ == NULL && pTokenQN == NULL )
{ {
p->LineCur = Extra_FileReaderGetLineNumber( p->pReader, 1 ); p->LineCur = Extra_FileReaderGetLineNumber( p->pReader, 1 );
sprintf( p->sError, "Cannot read pins Q/QN of the latch \"%s\".", vTokens->pArray[1] ); sprintf( p->sError, "Cannot read pins Q/QN of the latch \"%s\".", pLatchName );
Io_ReadVerPrintErrorMessage( p ); Io_ReadVerPrintErrorMessage( p );
return 0; return 0;
} }
if ( (pTokenRN == NULL) ^ (pTokenSN == NULL) ) if ( (pTokenRN == NULL) ^ (pTokenSN == NULL) )
{ {
p->LineCur = Extra_FileReaderGetLineNumber( p->pReader, 1 ); p->LineCur = Extra_FileReaderGetLineNumber( p->pReader, 1 );
sprintf( p->sError, "Cannot read pins RN/SN of the latch \"%s\".", vTokens->pArray[1] ); sprintf( p->sError, "Cannot read pins RN/SN of the latch \"%s\".", pLatchName );
Io_ReadVerPrintErrorMessage( p ); Io_ReadVerPrintErrorMessage( p );
return 0; return 0;
} }
...@@ -693,7 +697,7 @@ bool Io_ReadVerNetworkLatch( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vTo ...@@ -693,7 +697,7 @@ bool Io_ReadVerNetworkLatch( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vTo
} }
// create the latch // create the latch
pLatch = Io_ReadCreateLatch( pNtk, pTokenD, vTokens->pArray[1] ); pLatch = Io_ReadCreateLatch( pNtk, pTokenD, pLatchName );
// create the buffer if Q signal is available // create the buffer if Q signal is available
if ( pTokenQ ) if ( pTokenQ )
...@@ -706,7 +710,7 @@ bool Io_ReadVerNetworkLatch( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vTo ...@@ -706,7 +710,7 @@ bool Io_ReadVerNetworkLatch( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vTo
Io_ReadVerPrintErrorMessage( p ); Io_ReadVerPrintErrorMessage( p );
return 0; return 0;
} }
Io_ReadCreateBuf( pNtk, vTokens->pArray[1], pTokenQ ); Io_ReadCreateBuf( pNtk, pLatchName, pTokenQ );
} }
if ( pTokenQN ) if ( pTokenQN )
{ {
...@@ -718,26 +722,26 @@ bool Io_ReadVerNetworkLatch( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vTo ...@@ -718,26 +722,26 @@ bool Io_ReadVerNetworkLatch( Io_ReadVer_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vTo
Io_ReadVerPrintErrorMessage( p ); Io_ReadVerPrintErrorMessage( p );
return 0; return 0;
} }
Io_ReadCreateInv( pNtk, vTokens->pArray[1], pTokenQN ); Io_ReadCreateInv( pNtk, pLatchName, pTokenQN );
} }
// set the initial value // set the initial value
if ( pTokenRN == NULL && pTokenSN == NULL ) if ( pTokenRN == NULL && pTokenSN == NULL )
Abc_ObjSetData( pLatch, (char *)2 ); Abc_LatchSetInitDc( pLatch );
else else
{ {
fRN1 = (strcmp( pTokenRN, "1'b1" ) == 0); fRN1 = (strcmp( pTokenRN, "1'b1" ) == 0);
fSN1 = (strcmp( pTokenSN, "1'b1" ) == 0); fSN1 = (strcmp( pTokenSN, "1'b1" ) == 0);
if ( fRN1 && fSN1 ) if ( fRN1 && fSN1 )
Abc_ObjSetData( pLatch, (char *)2 ); Abc_LatchSetInitDc( pLatch );
else if ( fRN1 ) else if ( fRN1 )
Abc_ObjSetData( pLatch, (char *)1 ); Abc_LatchSetInit1( pLatch );
else if ( fSN1 ) else if ( fSN1 )
Abc_ObjSetData( pLatch, (char *)0 ); Abc_LatchSetInit0( pLatch );
else else
{ {
p->LineCur = Extra_FileReaderGetLineNumber( p->pReader, 0 ); p->LineCur = Extra_FileReaderGetLineNumber( p->pReader, 0 );
sprintf( p->sError, "Cannot read the initial value of latch \"%s\".", vTokens->pArray[1] ); sprintf( p->sError, "Cannot read the initial value of latch \"%s\".", pLatchName );
Io_ReadVerPrintErrorMessage( p ); Io_ReadVerPrintErrorMessage( p );
return 0; return 0;
} }
......
...@@ -92,7 +92,7 @@ int Io_WriteBenchOne( FILE * pFile, Abc_Ntk_t * pNtk ) ...@@ -92,7 +92,7 @@ int Io_WriteBenchOne( FILE * pFile, Abc_Ntk_t * pNtk )
Abc_ObjName(pNode), Abc_ObjName(Abc_ObjFanin0(pNode)) ); Abc_ObjName(pNode), Abc_ObjName(Abc_ObjFanin0(pNode)) );
// write internal nodes // write internal nodes
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
......
...@@ -86,6 +86,7 @@ void Io_WriteBlif( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches ) ...@@ -86,6 +86,7 @@ void Io_WriteBlif( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches )
return; return;
} }
// write the model name // write the model name
fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
fprintf( pFile, ".model %s\n", Abc_NtkName(pNtk) ); fprintf( pFile, ".model %s\n", Abc_NtkName(pNtk) );
// write the network // write the network
Io_NtkWriteOne( pFile, pNtk, fWriteLatches ); Io_NtkWriteOne( pFile, pNtk, fWriteLatches );
...@@ -145,7 +146,7 @@ void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches ) ...@@ -145,7 +146,7 @@ void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches )
} }
// write each internal node // write each internal node
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkNodeNum(pNtk) ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
{ {
Extra_ProgressBarUpdate( pProgress, i, NULL ); Extra_ProgressBarUpdate( pProgress, i, NULL );
......
...@@ -32,7 +32,7 @@ static int Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk ); ...@@ -32,7 +32,7 @@ static int Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk );
/**Function************************************************************* /**Function*************************************************************
Synopsis [Writes the network in BENCH format.] Synopsis [Writes the network in PLA format.]
Description [] Description []
...@@ -69,7 +69,7 @@ int Io_WritePla( Abc_Ntk_t * pNtk, char * pFileName ) ...@@ -69,7 +69,7 @@ int Io_WritePla( Abc_Ntk_t * pNtk, char * pFileName )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Writes the network in BENCH format.] Synopsis [Writes the network in PLA format.]
Description [] Description []
......
...@@ -926,6 +926,7 @@ Map_Cut_t * Map_CutTableConsider( Map_Man_t * pMan, Map_CutTable_t * p, Map_Node ...@@ -926,6 +926,7 @@ Map_Cut_t * Map_CutTableConsider( Map_Man_t * pMan, Map_CutTable_t * p, Map_Node
Map_Cut_t * pCut; Map_Cut_t * pCut;
int Place, i; int Place, i;
// int clk; // int clk;
/*
// check the cut // check the cut
Place = Map_CutTableLookup( p, ppNodes, nNodes ); Place = Map_CutTableLookup( p, ppNodes, nNodes );
if ( Place == -1 ) if ( Place == -1 )
...@@ -933,6 +934,7 @@ Map_Cut_t * Map_CutTableConsider( Map_Man_t * pMan, Map_CutTable_t * p, Map_Node ...@@ -933,6 +934,7 @@ Map_Cut_t * Map_CutTableConsider( Map_Man_t * pMan, Map_CutTable_t * p, Map_Node
assert( nNodes > 0 ); assert( nNodes > 0 );
// create the new cut // create the new cut
//clk = clock(); //clk = clock();
*/
pCut = Map_CutAlloc( pMan ); pCut = Map_CutAlloc( pMan );
//pMan->time1 += clock() - clk; //pMan->time1 += clock() - clk;
pCut->nLeaves = nNodes; pCut->nLeaves = nNodes;
...@@ -942,12 +944,15 @@ Map_Cut_t * Map_CutTableConsider( Map_Man_t * pMan, Map_CutTable_t * p, Map_Node ...@@ -942,12 +944,15 @@ Map_Cut_t * Map_CutTableConsider( Map_Man_t * pMan, Map_CutTable_t * p, Map_Node
pCut->ppLeaves[i] = ppNodes[i]; pCut->ppLeaves[i] = ppNodes[i];
// pCut->fLevel += ppNodes[i]->Level; // pCut->fLevel += ppNodes[i]->Level;
} }
/*
// pCut->fLevel /= nNodes; // pCut->fLevel /= nNodes;
// add the cut to the table // add the cut to the table
assert( p->pBins[Place] == NULL ); assert( p->pBins[Place] == NULL );
p->pBins[Place] = pCut; p->pBins[Place] = pCut;
// add the cut to the new list // add the cut to the new list
p->pCuts[ p->nCuts++ ] = Place; p->pCuts[ p->nCuts++ ] = Place;
*/
return pCut; return pCut;
} }
......
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
typedef struct Abc_Fan_t_ Abc_Fan_t; typedef struct Abc_Fan_t_ Abc_Fan_t;
struct Abc_Fan_t_ // 1 word struct Abc_Fan_t_ // 1 word
{ {
unsigned iFan : 26; // the ID of the object unsigned iFan : 24; // the ID of the object
unsigned nLats : 5; // the number of latches (up to 31) unsigned nLats : 7; // the number of latches (up to 31)
unsigned fCompl : 1; // the complemented attribute unsigned fCompl : 1; // the complemented attribute
}; };
...@@ -279,6 +279,7 @@ static inline int Vec_FanFindEntry( Vec_Fan_t * p, unsigned iFan ) ...@@ -279,6 +279,7 @@ static inline int Vec_FanFindEntry( Vec_Fan_t * p, unsigned iFan )
***********************************************************************/ ***********************************************************************/
static inline int Vec_FanDeleteEntry( Vec_Fan_t * p, unsigned iFan ) static inline int Vec_FanDeleteEntry( Vec_Fan_t * p, unsigned iFan )
{ {
/*
int i, k, fFound = 0; int i, k, fFound = 0;
for ( i = k = 0; i < p->nSize; i++ ) for ( i = k = 0; i < p->nSize; i++ )
{ {
...@@ -289,6 +290,17 @@ static inline int Vec_FanDeleteEntry( Vec_Fan_t * p, unsigned iFan ) ...@@ -289,6 +290,17 @@ static inline int Vec_FanDeleteEntry( Vec_Fan_t * p, unsigned iFan )
} }
p->nSize = k; p->nSize = k;
return fFound; return fFound;
*/
int i;
for ( i = 0; i < p->nSize; i++ )
if ( p->pArray[i].iFan == iFan )
break;
if ( i == p->nSize )
return 0;
for ( i++; i < p->nSize; i++ )
p->pArray[i-1] = p->pArray[i];
p->nSize--;
return 1;
} }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -51,12 +51,12 @@ Sim_Man_t * Sim_ManStart( Abc_Ntk_t * pNtk ) ...@@ -51,12 +51,12 @@ Sim_Man_t * Sim_ManStart( Abc_Ntk_t * pNtk )
// internal simulation information // internal simulation information
p->nSimBits = 2048; p->nSimBits = 2048;
p->nSimWords = SIM_NUM_WORDS(p->nSimBits); p->nSimWords = SIM_NUM_WORDS(p->nSimBits);
p->vSim0 = Sim_UtilInfoAlloc( pNtk->vObjs->nSize, p->nSimWords, 0 ); p->vSim0 = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSimWords, 0 );
p->vSim1 = Sim_UtilInfoAlloc( pNtk->vObjs->nSize, p->nSimWords, 0 ); p->vSim1 = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSimWords, 0 );
// support information // support information
p->nSuppBits = Abc_NtkCiNum(pNtk); p->nSuppBits = Abc_NtkCiNum(pNtk);
p->nSuppWords = SIM_NUM_WORDS(p->nSuppBits); p->nSuppWords = SIM_NUM_WORDS(p->nSuppBits);
p->vSuppStr = Sim_UtilInfoAlloc( pNtk->vObjs->nSize, p->nSuppWords, 1 ); p->vSuppStr = Sim_UtilInfoAlloc( Abc_NtkObjNumMax(pNtk), p->nSuppWords, 1 );
p->vSuppFun = Sim_UtilInfoAlloc( Abc_NtkCoNum(p->pNtk), p->nSuppWords, 1 ); p->vSuppFun = Sim_UtilInfoAlloc( Abc_NtkCoNum(p->pNtk), p->nSuppWords, 1 );
// other data // other data
p->pMmPat = Extra_MmFixedStart( sizeof(Sim_Pat_t) + p->nSuppWords * sizeof(unsigned) ); p->pMmPat = Extra_MmFixedStart( sizeof(Sim_Pat_t) + p->nSuppWords * sizeof(unsigned) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment