00001
00021 #include "abc.h"
00022 #include "mainInt.h"
00023 #include "fraig.h"
00024 #include "fxu.h"
00025 #include "cut.h"
00026 #include "fpga.h"
00027 #include "if.h"
00028 #include "res.h"
00029 #include "lpk.h"
00030 #include "aig.h"
00031 #include "dar.h"
00032
00036
00037 static int Abc_CommandPrintStats ( Abc_Frame_t * pAbc, int argc, char ** argv );
00038 static int Abc_CommandPrintExdc ( Abc_Frame_t * pAbc, int argc, char ** argv );
00039 static int Abc_CommandPrintIo ( Abc_Frame_t * pAbc, int argc, char ** argv );
00040 static int Abc_CommandPrintLatch ( Abc_Frame_t * pAbc, int argc, char ** argv );
00041 static int Abc_CommandPrintFanio ( Abc_Frame_t * pAbc, int argc, char ** argv );
00042 static int Abc_CommandPrintMffc ( Abc_Frame_t * pAbc, int argc, char ** argv );
00043 static int Abc_CommandPrintFactor ( Abc_Frame_t * pAbc, int argc, char ** argv );
00044 static int Abc_CommandPrintLevel ( Abc_Frame_t * pAbc, int argc, char ** argv );
00045 static int Abc_CommandPrintSupport ( Abc_Frame_t * pAbc, int argc, char ** argv );
00046 static int Abc_CommandPrintSymms ( Abc_Frame_t * pAbc, int argc, char ** argv );
00047 static int Abc_CommandPrintUnate ( Abc_Frame_t * pAbc, int argc, char ** argv );
00048 static int Abc_CommandPrintAuto ( Abc_Frame_t * pAbc, int argc, char ** argv );
00049 static int Abc_CommandPrintKMap ( Abc_Frame_t * pAbc, int argc, char ** argv );
00050 static int Abc_CommandPrintGates ( Abc_Frame_t * pAbc, int argc, char ** argv );
00051 static int Abc_CommandPrintSharing ( Abc_Frame_t * pAbc, int argc, char ** argv );
00052 static int Abc_CommandPrintXCut ( Abc_Frame_t * pAbc, int argc, char ** argv );
00053 static int Abc_CommandPrintDsd ( Abc_Frame_t * pAbc, int argc, char ** argv );
00054
00055 static int Abc_CommandShow ( Abc_Frame_t * pAbc, int argc, char ** argv );
00056 static int Abc_CommandShowBdd ( Abc_Frame_t * pAbc, int argc, char ** argv );
00057 static int Abc_CommandShowCut ( Abc_Frame_t * pAbc, int argc, char ** argv );
00058
00059 static int Abc_CommandCollapse ( Abc_Frame_t * pAbc, int argc, char ** argv );
00060 static int Abc_CommandStrash ( Abc_Frame_t * pAbc, int argc, char ** argv );
00061 static int Abc_CommandBalance ( Abc_Frame_t * pAbc, int argc, char ** argv );
00062 static int Abc_CommandMulti ( Abc_Frame_t * pAbc, int argc, char ** argv );
00063 static int Abc_CommandRenode ( Abc_Frame_t * pAbc, int argc, char ** argv );
00064 static int Abc_CommandCleanup ( Abc_Frame_t * pAbc, int argc, char ** argv );
00065 static int Abc_CommandSweep ( Abc_Frame_t * pAbc, int argc, char ** argv );
00066 static int Abc_CommandFastExtract ( Abc_Frame_t * pAbc, int argc, char ** argv );
00067 static int Abc_CommandDisjoint ( Abc_Frame_t * pAbc, int argc, char ** argv );
00068 static int Abc_CommandImfs ( Abc_Frame_t * pAbc, int argc, char ** argv );
00069 static int Abc_CommandLutpack ( Abc_Frame_t * pAbc, int argc, char ** argv );
00070
00071 static int Abc_CommandRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv );
00072 static int Abc_CommandRefactor ( Abc_Frame_t * pAbc, int argc, char ** argv );
00073 static int Abc_CommandRestructure ( Abc_Frame_t * pAbc, int argc, char ** argv );
00074 static int Abc_CommandResubstitute ( Abc_Frame_t * pAbc, int argc, char ** argv );
00075 static int Abc_CommandRr ( Abc_Frame_t * pAbc, int argc, char ** argv );
00076 static int Abc_CommandCascade ( Abc_Frame_t * pAbc, int argc, char ** argv );
00077
00078 static int Abc_CommandLogic ( Abc_Frame_t * pAbc, int argc, char ** argv );
00079 static int Abc_CommandComb ( Abc_Frame_t * pAbc, int argc, char ** argv );
00080 static int Abc_CommandMiter ( Abc_Frame_t * pAbc, int argc, char ** argv );
00081 static int Abc_CommandDemiter ( Abc_Frame_t * pAbc, int argc, char ** argv );
00082 static int Abc_CommandOrPos ( Abc_Frame_t * pAbc, int argc, char ** argv );
00083 static int Abc_CommandAndPos ( Abc_Frame_t * pAbc, int argc, char ** argv );
00084 static int Abc_CommandAppend ( Abc_Frame_t * pAbc, int argc, char ** argv );
00085 static int Abc_CommandFrames ( Abc_Frame_t * pAbc, int argc, char ** argv );
00086 static int Abc_CommandSop ( Abc_Frame_t * pAbc, int argc, char ** argv );
00087 static int Abc_CommandBdd ( Abc_Frame_t * pAbc, int argc, char ** argv );
00088 static int Abc_CommandAig ( Abc_Frame_t * pAbc, int argc, char ** argv );
00089 static int Abc_CommandReorder ( Abc_Frame_t * pAbc, int argc, char ** argv );
00090 static int Abc_CommandOrder ( Abc_Frame_t * pAbc, int argc, char ** argv );
00091 static int Abc_CommandMuxes ( Abc_Frame_t * pAbc, int argc, char ** argv );
00092 static int Abc_CommandExtSeqDcs ( Abc_Frame_t * pAbc, int argc, char ** argv );
00093 static int Abc_CommandCone ( Abc_Frame_t * pAbc, int argc, char ** argv );
00094 static int Abc_CommandNode ( Abc_Frame_t * pAbc, int argc, char ** argv );
00095 static int Abc_CommandTopmost ( Abc_Frame_t * pAbc, int argc, char ** argv );
00096 static int Abc_CommandTrim ( Abc_Frame_t * pAbc, int argc, char ** argv );
00097 static int Abc_CommandShortNames ( Abc_Frame_t * pAbc, int argc, char ** argv );
00098 static int Abc_CommandExdcFree ( Abc_Frame_t * pAbc, int argc, char ** argv );
00099 static int Abc_CommandExdcGet ( Abc_Frame_t * pAbc, int argc, char ** argv );
00100 static int Abc_CommandExdcSet ( Abc_Frame_t * pAbc, int argc, char ** argv );
00101 static int Abc_CommandCut ( Abc_Frame_t * pAbc, int argc, char ** argv );
00102 static int Abc_CommandEspresso ( Abc_Frame_t * pAbc, int argc, char ** argv );
00103 static int Abc_CommandGen ( Abc_Frame_t * pAbc, int argc, char ** argv );
00104
00105 static int Abc_CommandDouble ( Abc_Frame_t * pAbc, int argc, char ** argv );
00106 static int Abc_CommandTest ( Abc_Frame_t * pAbc, int argc, char ** argv );
00107
00108 static int Abc_CommandQuaVar ( Abc_Frame_t * pAbc, int argc, char ** argv );
00109 static int Abc_CommandQuaRel ( Abc_Frame_t * pAbc, int argc, char ** argv );
00110 static int Abc_CommandQuaReach ( Abc_Frame_t * pAbc, int argc, char ** argv );
00111
00112 static int Abc_CommandIStrash ( Abc_Frame_t * pAbc, int argc, char ** argv );
00113 static int Abc_CommandICut ( Abc_Frame_t * pAbc, int argc, char ** argv );
00114 static int Abc_CommandIRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv );
00115 static int Abc_CommandDRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv );
00116 static int Abc_CommandDRefactor ( Abc_Frame_t * pAbc, int argc, char ** argv );
00117 static int Abc_CommandDCompress2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
00118 static int Abc_CommandDChoice ( Abc_Frame_t * pAbc, int argc, char ** argv );
00119 static int Abc_CommandDrwsat ( Abc_Frame_t * pAbc, int argc, char ** argv );
00120 static int Abc_CommandIRewriteSeq ( Abc_Frame_t * pAbc, int argc, char ** argv );
00121 static int Abc_CommandIResyn ( Abc_Frame_t * pAbc, int argc, char ** argv );
00122 static int Abc_CommandISat ( Abc_Frame_t * pAbc, int argc, char ** argv );
00123 static int Abc_CommandIFraig ( Abc_Frame_t * pAbc, int argc, char ** argv );
00124 static int Abc_CommandDFraig ( Abc_Frame_t * pAbc, int argc, char ** argv );
00125 static int Abc_CommandCSweep ( Abc_Frame_t * pAbc, int argc, char ** argv );
00126 static int Abc_CommandIProve ( Abc_Frame_t * pAbc, int argc, char ** argv );
00127 static int Abc_CommandDProve ( Abc_Frame_t * pAbc, int argc, char ** argv );
00128 static int Abc_CommandHaig ( Abc_Frame_t * pAbc, int argc, char ** argv );
00129 static int Abc_CommandMini ( Abc_Frame_t * pAbc, int argc, char ** argv );
00130 static int Abc_CommandBmc ( Abc_Frame_t * pAbc, int argc, char ** argv );
00131 static int Abc_CommandQbf ( Abc_Frame_t * pAbc, int argc, char ** argv );
00132
00133 static int Abc_CommandFraig ( Abc_Frame_t * pAbc, int argc, char ** argv );
00134 static int Abc_CommandFraigTrust ( Abc_Frame_t * pAbc, int argc, char ** argv );
00135 static int Abc_CommandFraigStore ( Abc_Frame_t * pAbc, int argc, char ** argv );
00136 static int Abc_CommandFraigRestore ( Abc_Frame_t * pAbc, int argc, char ** argv );
00137 static int Abc_CommandFraigClean ( Abc_Frame_t * pAbc, int argc, char ** argv );
00138 static int Abc_CommandFraigSweep ( Abc_Frame_t * pAbc, int argc, char ** argv );
00139 static int Abc_CommandFraigDress ( Abc_Frame_t * pAbc, int argc, char ** argv );
00140
00141 static int Abc_CommandHaigStart ( Abc_Frame_t * pAbc, int argc, char ** argv );
00142 static int Abc_CommandHaigStop ( Abc_Frame_t * pAbc, int argc, char ** argv );
00143 static int Abc_CommandHaigUse ( Abc_Frame_t * pAbc, int argc, char ** argv );
00144
00145 static int Abc_CommandRecStart ( Abc_Frame_t * pAbc, int argc, char ** argv );
00146 static int Abc_CommandRecStop ( Abc_Frame_t * pAbc, int argc, char ** argv );
00147 static int Abc_CommandRecAdd ( Abc_Frame_t * pAbc, int argc, char ** argv );
00148 static int Abc_CommandRecPs ( Abc_Frame_t * pAbc, int argc, char ** argv );
00149 static int Abc_CommandRecUse ( Abc_Frame_t * pAbc, int argc, char ** argv );
00150
00151 static int Abc_CommandMap ( Abc_Frame_t * pAbc, int argc, char ** argv );
00152 static int Abc_CommandUnmap ( Abc_Frame_t * pAbc, int argc, char ** argv );
00153 static int Abc_CommandAttach ( Abc_Frame_t * pAbc, int argc, char ** argv );
00154 static int Abc_CommandSuperChoice ( Abc_Frame_t * pAbc, int argc, char ** argv );
00155 static int Abc_CommandSuperChoiceLut ( Abc_Frame_t * pAbc, int argc, char ** argv );
00156
00157 static int Abc_CommandFpga ( Abc_Frame_t * pAbc, int argc, char ** argv );
00158 static int Abc_CommandFpgaFast ( Abc_Frame_t * pAbc, int argc, char ** argv );
00159 static int Abc_CommandIf ( Abc_Frame_t * pAbc, int argc, char ** argv );
00160
00161 static int Abc_CommandScut ( Abc_Frame_t * pAbc, int argc, char ** argv );
00162 static int Abc_CommandInit ( Abc_Frame_t * pAbc, int argc, char ** argv );
00163 static int Abc_CommandZero ( Abc_Frame_t * pAbc, int argc, char ** argv );
00164 static int Abc_CommandUndc ( Abc_Frame_t * pAbc, int argc, char ** argv );
00165 static int Abc_CommandPipe ( Abc_Frame_t * pAbc, int argc, char ** argv );
00166 static int Abc_CommandSeq ( Abc_Frame_t * pAbc, int argc, char ** argv );
00167 static int Abc_CommandUnseq ( Abc_Frame_t * pAbc, int argc, char ** argv );
00168 static int Abc_CommandRetime ( Abc_Frame_t * pAbc, int argc, char ** argv );
00169 static int Abc_CommandSeqFpga ( Abc_Frame_t * pAbc, int argc, char ** argv );
00170 static int Abc_CommandSeqMap ( Abc_Frame_t * pAbc, int argc, char ** argv );
00171 static int Abc_CommandSeqSweep ( Abc_Frame_t * pAbc, int argc, char ** argv );
00172 static int Abc_CommandLcorr ( Abc_Frame_t * pAbc, int argc, char ** argv );
00173 static int Abc_CommandSeqCleanup ( Abc_Frame_t * pAbc, int argc, char ** argv );
00174 static int Abc_CommandCycle ( Abc_Frame_t * pAbc, int argc, char ** argv );
00175 static int Abc_CommandXsim ( Abc_Frame_t * pAbc, int argc, char ** argv );
00176
00177 static int Abc_CommandCec ( Abc_Frame_t * pAbc, int argc, char ** argv );
00178 static int Abc_CommandSec ( Abc_Frame_t * pAbc, int argc, char ** argv );
00179 static int Abc_CommandDSec ( Abc_Frame_t * pAbc, int argc, char ** argv );
00180 static int Abc_CommandSat ( Abc_Frame_t * pAbc, int argc, char ** argv );
00181 static int Abc_CommandDSat ( Abc_Frame_t * pAbc, int argc, char ** argv );
00182 static int Abc_CommandProve ( Abc_Frame_t * pAbc, int argc, char ** argv );
00183 static int Abc_CommandDebug ( Abc_Frame_t * pAbc, int argc, char ** argv );
00184
00185 static int Abc_CommandTraceStart ( Abc_Frame_t * pAbc, int argc, char ** argv );
00186 static int Abc_CommandTraceCheck ( Abc_Frame_t * pAbc, int argc, char ** argv );
00187
00191
00203 void Abc_Init( Abc_Frame_t * pAbc )
00204 {
00205
00206
00207 Cmd_CommandAdd( pAbc, "Printing", "print_stats", Abc_CommandPrintStats, 0 );
00208 Cmd_CommandAdd( pAbc, "Printing", "print_exdc", Abc_CommandPrintExdc, 0 );
00209 Cmd_CommandAdd( pAbc, "Printing", "print_io", Abc_CommandPrintIo, 0 );
00210 Cmd_CommandAdd( pAbc, "Printing", "print_latch", Abc_CommandPrintLatch, 0 );
00211 Cmd_CommandAdd( pAbc, "Printing", "print_fanio", Abc_CommandPrintFanio, 0 );
00212 Cmd_CommandAdd( pAbc, "Printing", "print_mffc", Abc_CommandPrintMffc, 0 );
00213 Cmd_CommandAdd( pAbc, "Printing", "print_factor", Abc_CommandPrintFactor, 0 );
00214 Cmd_CommandAdd( pAbc, "Printing", "print_level", Abc_CommandPrintLevel, 0 );
00215 Cmd_CommandAdd( pAbc, "Printing", "print_supp", Abc_CommandPrintSupport, 0 );
00216 Cmd_CommandAdd( pAbc, "Printing", "print_symm", Abc_CommandPrintSymms, 0 );
00217 Cmd_CommandAdd( pAbc, "Printing", "print_unate", Abc_CommandPrintUnate, 0 );
00218 Cmd_CommandAdd( pAbc, "Printing", "print_auto", Abc_CommandPrintAuto, 0 );
00219 Cmd_CommandAdd( pAbc, "Printing", "print_kmap", Abc_CommandPrintKMap, 0 );
00220 Cmd_CommandAdd( pAbc, "Printing", "print_gates", Abc_CommandPrintGates, 0 );
00221 Cmd_CommandAdd( pAbc, "Printing", "print_sharing", Abc_CommandPrintSharing, 0 );
00222 Cmd_CommandAdd( pAbc, "Printing", "print_xcut", Abc_CommandPrintXCut, 0 );
00223 Cmd_CommandAdd( pAbc, "Printing", "print_dsd", Abc_CommandPrintDsd, 0 );
00224
00225 Cmd_CommandAdd( pAbc, "Printing", "show", Abc_CommandShow, 0 );
00226 Cmd_CommandAdd( pAbc, "Printing", "show_bdd", Abc_CommandShowBdd, 0 );
00227 Cmd_CommandAdd( pAbc, "Printing", "show_cut", Abc_CommandShowCut, 0 );
00228
00229 Cmd_CommandAdd( pAbc, "Synthesis", "collapse", Abc_CommandCollapse, 1 );
00230 Cmd_CommandAdd( pAbc, "Synthesis", "strash", Abc_CommandStrash, 1 );
00231 Cmd_CommandAdd( pAbc, "Synthesis", "balance", Abc_CommandBalance, 1 );
00232 Cmd_CommandAdd( pAbc, "Synthesis", "multi", Abc_CommandMulti, 1 );
00233 Cmd_CommandAdd( pAbc, "Synthesis", "renode", Abc_CommandRenode, 1 );
00234 Cmd_CommandAdd( pAbc, "Synthesis", "cleanup", Abc_CommandCleanup, 1 );
00235 Cmd_CommandAdd( pAbc, "Synthesis", "sweep", Abc_CommandSweep, 1 );
00236 Cmd_CommandAdd( pAbc, "Synthesis", "fx", Abc_CommandFastExtract, 1 );
00237 Cmd_CommandAdd( pAbc, "Synthesis", "dsd", Abc_CommandDisjoint, 1 );
00238 Cmd_CommandAdd( pAbc, "Synthesis", "imfs", Abc_CommandImfs, 1 );
00239 Cmd_CommandAdd( pAbc, "Synthesis", "lutpack", Abc_CommandLutpack, 1 );
00240
00241 Cmd_CommandAdd( pAbc, "Synthesis", "rewrite", Abc_CommandRewrite, 1 );
00242 Cmd_CommandAdd( pAbc, "Synthesis", "refactor", Abc_CommandRefactor, 1 );
00243
00244 Cmd_CommandAdd( pAbc, "Synthesis", "resub", Abc_CommandResubstitute, 1 );
00245 Cmd_CommandAdd( pAbc, "Synthesis", "rr", Abc_CommandRr, 1 );
00246 Cmd_CommandAdd( pAbc, "Synthesis", "cascade", Abc_CommandCascade, 1 );
00247
00248 Cmd_CommandAdd( pAbc, "Various", "logic", Abc_CommandLogic, 1 );
00249 Cmd_CommandAdd( pAbc, "Various", "comb", Abc_CommandComb, 1 );
00250 Cmd_CommandAdd( pAbc, "Various", "miter", Abc_CommandMiter, 1 );
00251 Cmd_CommandAdd( pAbc, "Various", "demiter", Abc_CommandDemiter, 1 );
00252 Cmd_CommandAdd( pAbc, "Various", "orpos", Abc_CommandOrPos, 1 );
00253 Cmd_CommandAdd( pAbc, "Various", "andpos", Abc_CommandAndPos, 1 );
00254 Cmd_CommandAdd( pAbc, "Various", "append", Abc_CommandAppend, 1 );
00255 Cmd_CommandAdd( pAbc, "Various", "frames", Abc_CommandFrames, 1 );
00256 Cmd_CommandAdd( pAbc, "Various", "sop", Abc_CommandSop, 0 );
00257 Cmd_CommandAdd( pAbc, "Various", "bdd", Abc_CommandBdd, 0 );
00258 Cmd_CommandAdd( pAbc, "Various", "aig", Abc_CommandAig, 0 );
00259 Cmd_CommandAdd( pAbc, "Various", "reorder", Abc_CommandReorder, 0 );
00260 Cmd_CommandAdd( pAbc, "Various", "order", Abc_CommandOrder, 0 );
00261 Cmd_CommandAdd( pAbc, "Various", "muxes", Abc_CommandMuxes, 1 );
00262 Cmd_CommandAdd( pAbc, "Various", "ext_seq_dcs", Abc_CommandExtSeqDcs, 0 );
00263 Cmd_CommandAdd( pAbc, "Various", "cone", Abc_CommandCone, 1 );
00264 Cmd_CommandAdd( pAbc, "Various", "node", Abc_CommandNode, 1 );
00265 Cmd_CommandAdd( pAbc, "Various", "topmost", Abc_CommandTopmost, 1 );
00266 Cmd_CommandAdd( pAbc, "Various", "trim", Abc_CommandTrim, 1 );
00267 Cmd_CommandAdd( pAbc, "Various", "short_names", Abc_CommandShortNames, 0 );
00268 Cmd_CommandAdd( pAbc, "Various", "exdc_free", Abc_CommandExdcFree, 1 );
00269 Cmd_CommandAdd( pAbc, "Various", "exdc_get", Abc_CommandExdcGet, 1 );
00270 Cmd_CommandAdd( pAbc, "Various", "exdc_set", Abc_CommandExdcSet, 1 );
00271 Cmd_CommandAdd( pAbc, "Various", "cut", Abc_CommandCut, 0 );
00272 Cmd_CommandAdd( pAbc, "Various", "espresso", Abc_CommandEspresso, 1 );
00273 Cmd_CommandAdd( pAbc, "Various", "gen", Abc_CommandGen, 0 );
00274
00275 Cmd_CommandAdd( pAbc, "Various", "double", Abc_CommandDouble, 1 );
00276 Cmd_CommandAdd( pAbc, "Various", "test", Abc_CommandTest, 0 );
00277
00278 Cmd_CommandAdd( pAbc, "Various", "qvar", Abc_CommandQuaVar, 1 );
00279 Cmd_CommandAdd( pAbc, "Various", "qrel", Abc_CommandQuaRel, 1 );
00280 Cmd_CommandAdd( pAbc, "Various", "qreach", Abc_CommandQuaReach, 1 );
00281
00282 Cmd_CommandAdd( pAbc, "New AIG", "istrash", Abc_CommandIStrash, 1 );
00283 Cmd_CommandAdd( pAbc, "New AIG", "icut", Abc_CommandICut, 0 );
00284 Cmd_CommandAdd( pAbc, "New AIG", "irw", Abc_CommandIRewrite, 1 );
00285 Cmd_CommandAdd( pAbc, "New AIG", "drw", Abc_CommandDRewrite, 1 );
00286 Cmd_CommandAdd( pAbc, "New AIG", "drf", Abc_CommandDRefactor, 1 );
00287 Cmd_CommandAdd( pAbc, "New AIG", "dcompress2", Abc_CommandDCompress2, 1 );
00288 Cmd_CommandAdd( pAbc, "New AIG", "dchoice", Abc_CommandDChoice, 1 );
00289 Cmd_CommandAdd( pAbc, "New AIG", "drwsat", Abc_CommandDrwsat, 1 );
00290 Cmd_CommandAdd( pAbc, "New AIG", "irws", Abc_CommandIRewriteSeq, 1 );
00291 Cmd_CommandAdd( pAbc, "New AIG", "iresyn", Abc_CommandIResyn, 1 );
00292 Cmd_CommandAdd( pAbc, "New AIG", "isat", Abc_CommandISat, 1 );
00293 Cmd_CommandAdd( pAbc, "New AIG", "ifraig", Abc_CommandIFraig, 1 );
00294 Cmd_CommandAdd( pAbc, "New AIG", "dfraig", Abc_CommandDFraig, 1 );
00295 Cmd_CommandAdd( pAbc, "New AIG", "csweep", Abc_CommandCSweep, 1 );
00296 Cmd_CommandAdd( pAbc, "New AIG", "iprove", Abc_CommandIProve, 1 );
00297 Cmd_CommandAdd( pAbc, "New AIG", "haig", Abc_CommandHaig, 1 );
00298 Cmd_CommandAdd( pAbc, "New AIG", "mini", Abc_CommandMini, 1 );
00299 Cmd_CommandAdd( pAbc, "New AIG", "_bmc", Abc_CommandBmc, 0 );
00300 Cmd_CommandAdd( pAbc, "New AIG", "qbf", Abc_CommandQbf, 0 );
00301
00302 Cmd_CommandAdd( pAbc, "Fraiging", "fraig", Abc_CommandFraig, 1 );
00303 Cmd_CommandAdd( pAbc, "Fraiging", "fraig_trust", Abc_CommandFraigTrust, 1 );
00304 Cmd_CommandAdd( pAbc, "Fraiging", "fraig_store", Abc_CommandFraigStore, 0 );
00305 Cmd_CommandAdd( pAbc, "Fraiging", "fraig_restore", Abc_CommandFraigRestore, 1 );
00306 Cmd_CommandAdd( pAbc, "Fraiging", "fraig_clean", Abc_CommandFraigClean, 0 );
00307 Cmd_CommandAdd( pAbc, "Fraiging", "fraig_sweep", Abc_CommandFraigSweep, 1 );
00308 Cmd_CommandAdd( pAbc, "Fraiging", "dress", Abc_CommandFraigDress, 1 );
00309
00310 Cmd_CommandAdd( pAbc, "Choicing", "haig_start", Abc_CommandHaigStart, 0 );
00311 Cmd_CommandAdd( pAbc, "Choicing", "haig_stop", Abc_CommandHaigStop, 0 );
00312 Cmd_CommandAdd( pAbc, "Choicing", "haig_use", Abc_CommandHaigUse, 1 );
00313
00314 Cmd_CommandAdd( pAbc, "Choicing", "rec_start", Abc_CommandRecStart, 0 );
00315 Cmd_CommandAdd( pAbc, "Choicing", "rec_stop", Abc_CommandRecStop, 0 );
00316 Cmd_CommandAdd( pAbc, "Choicing", "rec_add", Abc_CommandRecAdd, 0 );
00317 Cmd_CommandAdd( pAbc, "Choicing", "rec_ps", Abc_CommandRecPs, 0 );
00318 Cmd_CommandAdd( pAbc, "Choicing", "rec_use", Abc_CommandRecUse, 1 );
00319
00320 Cmd_CommandAdd( pAbc, "SC mapping", "map", Abc_CommandMap, 1 );
00321 Cmd_CommandAdd( pAbc, "SC mapping", "unmap", Abc_CommandUnmap, 1 );
00322 Cmd_CommandAdd( pAbc, "SC mapping", "attach", Abc_CommandAttach, 1 );
00323 Cmd_CommandAdd( pAbc, "SC mapping", "sc", Abc_CommandSuperChoice, 1 );
00324 Cmd_CommandAdd( pAbc, "SC mapping", "scl", Abc_CommandSuperChoiceLut, 1 );
00325
00326 Cmd_CommandAdd( pAbc, "FPGA mapping", "fpga", Abc_CommandFpga, 1 );
00327 Cmd_CommandAdd( pAbc, "FPGA mapping", "ffpga", Abc_CommandFpgaFast, 1 );
00328 Cmd_CommandAdd( pAbc, "FPGA mapping", "if", Abc_CommandIf, 1 );
00329
00330
00331 Cmd_CommandAdd( pAbc, "Sequential", "init", Abc_CommandInit, 1 );
00332 Cmd_CommandAdd( pAbc, "Sequential", "zero", Abc_CommandZero, 1 );
00333 Cmd_CommandAdd( pAbc, "Sequential", "undc", Abc_CommandUndc, 1 );
00334
00335 Cmd_CommandAdd( pAbc, "Sequential", "retime", Abc_CommandRetime, 1 );
00336
00337
00338 Cmd_CommandAdd( pAbc, "Sequential", "ssweep", Abc_CommandSeqSweep, 1 );
00339 Cmd_CommandAdd( pAbc, "Sequential", "lcorr", Abc_CommandLcorr, 1 );
00340 Cmd_CommandAdd( pAbc, "Sequential", "scleanup", Abc_CommandSeqCleanup, 1 );
00341 Cmd_CommandAdd( pAbc, "Sequential", "cycle", Abc_CommandCycle, 1 );
00342 Cmd_CommandAdd( pAbc, "Sequential", "xsim", Abc_CommandXsim, 0 );
00343
00344 Cmd_CommandAdd( pAbc, "Verification", "cec", Abc_CommandCec, 0 );
00345 Cmd_CommandAdd( pAbc, "Verification", "sec", Abc_CommandSec, 0 );
00346 Cmd_CommandAdd( pAbc, "Verification", "dsec", Abc_CommandDSec, 0 );
00347 Cmd_CommandAdd( pAbc, "Verification", "dprove", Abc_CommandDProve, 0 );
00348 Cmd_CommandAdd( pAbc, "Verification", "sat", Abc_CommandSat, 0 );
00349 Cmd_CommandAdd( pAbc, "Verification", "dsat", Abc_CommandDSat, 0 );
00350 Cmd_CommandAdd( pAbc, "Verification", "prove", Abc_CommandProve, 1 );
00351 Cmd_CommandAdd( pAbc, "Verification", "debug", Abc_CommandDebug, 0 );
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364 {
00365 extern void Dar_LibStart();
00366 Dar_LibStart();
00367 }
00368 }
00369
00381 void Abc_End()
00382 {
00383
00384
00385 {
00386 extern void Cnf_ClearMemory();
00387 Cnf_ClearMemory();
00388 }
00389 {
00390 extern void Dar_LibStop();
00391 Dar_LibStop();
00392 }
00393
00394 Abc_NtkFraigStoreClean();
00395
00396
00397 }
00398
00410 int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv )
00411 {
00412 FILE * pOut, * pErr;
00413 Abc_Ntk_t * pNtk;
00414 bool fShort;
00415 int c;
00416 int fFactor;
00417
00418 pNtk = Abc_FrameReadNtk(pAbc);
00419 pOut = Abc_FrameReadOut(pAbc);
00420 pErr = Abc_FrameReadErr(pAbc);
00421
00422
00423 fShort = 1;
00424 fFactor = 0;
00425 Extra_UtilGetoptReset();
00426 while ( ( c = Extra_UtilGetopt( argc, argv, "sfh" ) ) != EOF )
00427 {
00428 switch ( c )
00429 {
00430 case 's':
00431 fShort ^= 1;
00432 break;
00433 case 'f':
00434 fFactor ^= 1;
00435 break;
00436 case 'h':
00437 goto usage;
00438 default:
00439 goto usage;
00440 }
00441 }
00442
00443 if ( pNtk == NULL )
00444 {
00445 fprintf( Abc_FrameReadErr(pAbc), "Empty network.\n" );
00446 return 1;
00447 }
00448 Abc_NtkPrintStats( pOut, pNtk, fFactor );
00449 return 0;
00450
00451 usage:
00452 fprintf( pErr, "usage: print_stats [-fh]\n" );
00453 fprintf( pErr, "\t prints the network statistics\n" );
00454 fprintf( pErr, "\t-f : toggles printing the literal count in the factored forms [default = %s]\n", fFactor? "yes": "no" );
00455 fprintf( pErr, "\t-h : print the command usage\n");
00456 return 1;
00457 }
00458
00470 int Abc_CommandPrintExdc( Abc_Frame_t * pAbc, int argc, char ** argv )
00471 {
00472 FILE * pOut, * pErr;
00473 Abc_Ntk_t * pNtk, * pNtkTemp;
00474 double Percentage;
00475 bool fShort;
00476 int c;
00477 int fPrintDc;
00478
00479 extern double Abc_NtkSpacePercentage( Abc_Obj_t * pNode );
00480
00481 pNtk = Abc_FrameReadNtk(pAbc);
00482 pOut = Abc_FrameReadOut(pAbc);
00483 pErr = Abc_FrameReadErr(pAbc);
00484
00485
00486 fShort = 1;
00487 fPrintDc = 0;
00488 Extra_UtilGetoptReset();
00489 while ( ( c = Extra_UtilGetopt( argc, argv, "sdh" ) ) != EOF )
00490 {
00491 switch ( c )
00492 {
00493 case 's':
00494 fShort ^= 1;
00495 break;
00496 case 'd':
00497 fPrintDc ^= 1;
00498 break;
00499 case 'h':
00500 goto usage;
00501 default:
00502 goto usage;
00503 }
00504 }
00505
00506 if ( pNtk == NULL )
00507 {
00508 fprintf( Abc_FrameReadErr(pAbc), "Empty network.\n" );
00509 return 1;
00510 }
00511 if ( pNtk->pExdc == NULL )
00512 {
00513 fprintf( Abc_FrameReadErr(pAbc), "Network has no EXDC.\n" );
00514 return 1;
00515 }
00516
00517 if ( fPrintDc )
00518 {
00519 if ( !Abc_NtkIsStrash(pNtk->pExdc) )
00520 {
00521 pNtkTemp = Abc_NtkStrash(pNtk->pExdc, 0, 0, 0);
00522 Percentage = Abc_NtkSpacePercentage( Abc_ObjChild0( Abc_NtkPo(pNtkTemp, 0) ) );
00523 Abc_NtkDelete( pNtkTemp );
00524 }
00525 else
00526 Percentage = Abc_NtkSpacePercentage( Abc_ObjChild0( Abc_NtkPo(pNtk->pExdc, 0) ) );
00527
00528 printf( "EXDC network statistics: " );
00529 printf( "(" );
00530 if ( Percentage > 0.05 && Percentage < 99.95 )
00531 printf( "%.2f", Percentage );
00532 else if ( Percentage > 0.000005 && Percentage < 99.999995 )
00533 printf( "%.6f", Percentage );
00534 else
00535 printf( "%f", Percentage );
00536 printf( " %% don't-cares)\n" );
00537 }
00538 else
00539 printf( "EXDC network statistics: \n" );
00540 Abc_NtkPrintStats( pOut, pNtk->pExdc, 0 );
00541 return 0;
00542
00543 usage:
00544 fprintf( pErr, "usage: print_exdc [-dh]\n" );
00545 fprintf( pErr, "\t prints the EXDC network statistics\n" );
00546 fprintf( pErr, "\t-d : toggles printing don't-care percentage [default = %s]\n", fPrintDc? "yes": "no" );
00547 fprintf( pErr, "\t-h : print the command usage\n");
00548 return 1;
00549 }
00550
00562 int Abc_CommandPrintIo( Abc_Frame_t * pAbc, int argc, char ** argv )
00563 {
00564 FILE * pOut, * pErr;
00565 Abc_Ntk_t * pNtk;
00566 Abc_Obj_t * pNode;
00567 int c;
00568
00569 pNtk = Abc_FrameReadNtk(pAbc);
00570 pOut = Abc_FrameReadOut(pAbc);
00571 pErr = Abc_FrameReadErr(pAbc);
00572
00573
00574 Extra_UtilGetoptReset();
00575 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00576 {
00577 switch ( c )
00578 {
00579 case 'h':
00580 goto usage;
00581 default:
00582 goto usage;
00583 }
00584 }
00585
00586 if ( pNtk == NULL )
00587 {
00588 fprintf( pErr, "Empty network.\n" );
00589 return 1;
00590 }
00591
00592 if ( argc > globalUtilOptind + 1 )
00593 {
00594 fprintf( pErr, "Wrong number of auguments.\n" );
00595 goto usage;
00596 }
00597
00598 if ( argc == globalUtilOptind + 1 )
00599 {
00600 pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
00601 if ( pNode == NULL )
00602 {
00603 fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
00604 return 1;
00605 }
00606 Abc_NodePrintFanio( pOut, pNode );
00607 return 0;
00608 }
00609
00610 Abc_NtkPrintIo( pOut, pNtk );
00611 return 0;
00612
00613 usage:
00614 fprintf( pErr, "usage: print_io [-h] <node>\n" );
00615 fprintf( pErr, "\t prints the PIs/POs or fanins/fanouts of a node\n" );
00616 fprintf( pErr, "\t-h : print the command usage\n");
00617 fprintf( pErr, "\tnode : the node to print fanins/fanouts\n");
00618 return 1;
00619 }
00620
00632 int Abc_CommandPrintLatch( Abc_Frame_t * pAbc, int argc, char ** argv )
00633 {
00634 FILE * pOut, * pErr;
00635 Abc_Ntk_t * pNtk;
00636 int c;
00637
00638 pNtk = Abc_FrameReadNtk(pAbc);
00639 pOut = Abc_FrameReadOut(pAbc);
00640 pErr = Abc_FrameReadErr(pAbc);
00641
00642
00643 Extra_UtilGetoptReset();
00644 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00645 {
00646 switch ( c )
00647 {
00648 case 'h':
00649 goto usage;
00650 default:
00651 goto usage;
00652 }
00653 }
00654
00655 if ( pNtk == NULL )
00656 {
00657 fprintf( pErr, "Empty network.\n" );
00658 return 1;
00659 }
00660
00661 Abc_NtkPrintLatch( pOut, pNtk );
00662 return 0;
00663
00664 usage:
00665 fprintf( pErr, "usage: print_latch [-h]\n" );
00666 fprintf( pErr, "\t prints information about latches\n" );
00667 fprintf( pErr, "\t-h : print the command usage\n");
00668 return 1;
00669 }
00670
00682 int Abc_CommandPrintFanio( Abc_Frame_t * pAbc, int argc, char ** argv )
00683 {
00684 FILE * pOut, * pErr;
00685 Abc_Ntk_t * pNtk;
00686 int c;
00687
00688 pNtk = Abc_FrameReadNtk(pAbc);
00689 pOut = Abc_FrameReadOut(pAbc);
00690 pErr = Abc_FrameReadErr(pAbc);
00691
00692
00693 Extra_UtilGetoptReset();
00694 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00695 {
00696 switch ( c )
00697 {
00698 case 'h':
00699 goto usage;
00700 default:
00701 goto usage;
00702 }
00703 }
00704
00705 if ( pNtk == NULL )
00706 {
00707 fprintf( pErr, "Empty network.\n" );
00708 return 1;
00709 }
00710
00711
00712 Abc_NtkPrintFanio( pOut, pNtk );
00713 return 0;
00714
00715 usage:
00716 fprintf( pErr, "usage: print_fanio [-h]\n" );
00717 fprintf( pErr, "\t prints the statistics about fanins/fanouts of all nodes\n" );
00718 fprintf( pErr, "\t-h : print the command usage\n");
00719 return 1;
00720 }
00721
00733 int Abc_CommandPrintMffc( Abc_Frame_t * pAbc, int argc, char ** argv )
00734 {
00735 FILE * pOut, * pErr;
00736 Abc_Ntk_t * pNtk;
00737 int c;
00738 extern void Abc_NtkPrintMffc( FILE * pFile, Abc_Ntk_t * pNtk );
00739
00740 pNtk = Abc_FrameReadNtk(pAbc);
00741 pOut = Abc_FrameReadOut(pAbc);
00742 pErr = Abc_FrameReadErr(pAbc);
00743
00744
00745 Extra_UtilGetoptReset();
00746 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00747 {
00748 switch ( c )
00749 {
00750 case 'h':
00751 goto usage;
00752 default:
00753 goto usage;
00754 }
00755 }
00756
00757 if ( pNtk == NULL )
00758 {
00759 fprintf( pErr, "Empty network.\n" );
00760 return 1;
00761 }
00762
00763
00764 Abc_NtkPrintMffc( pOut, pNtk );
00765 return 0;
00766
00767 usage:
00768 fprintf( pErr, "usage: print_mffc [-h]\n" );
00769 fprintf( pErr, "\t prints the MFFC of each node in the network\n" );
00770 fprintf( pErr, "\t-h : print the command usage\n");
00771 return 1;
00772 }
00773
00785 int Abc_CommandPrintFactor( Abc_Frame_t * pAbc, int argc, char ** argv )
00786 {
00787 FILE * pOut, * pErr;
00788 Abc_Ntk_t * pNtk;
00789 Abc_Obj_t * pNode;
00790 int c;
00791 int fUseRealNames;
00792
00793 pNtk = Abc_FrameReadNtk(pAbc);
00794 pOut = Abc_FrameReadOut(pAbc);
00795 pErr = Abc_FrameReadErr(pAbc);
00796
00797
00798 fUseRealNames = 1;
00799 Extra_UtilGetoptReset();
00800 while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
00801 {
00802 switch ( c )
00803 {
00804 case 'n':
00805 fUseRealNames ^= 1;
00806 break;
00807 case 'h':
00808 goto usage;
00809 default:
00810 goto usage;
00811 }
00812 }
00813
00814 if ( pNtk == NULL )
00815 {
00816 fprintf( pErr, "Empty network.\n" );
00817 return 1;
00818 }
00819
00820 if ( !Abc_NtkIsSopLogic(pNtk) )
00821 {
00822 fprintf( pErr, "Printing factored forms can be done for SOP networks.\n" );
00823 return 1;
00824 }
00825
00826 if ( argc > globalUtilOptind + 1 )
00827 {
00828 fprintf( pErr, "Wrong number of auguments.\n" );
00829 goto usage;
00830 }
00831
00832 if ( argc == globalUtilOptind + 1 )
00833 {
00834 pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
00835 if ( pNode == NULL )
00836 {
00837 fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
00838 return 1;
00839 }
00840 Abc_NodePrintFactor( pOut, pNode, fUseRealNames );
00841 return 0;
00842 }
00843
00844 Abc_NtkPrintFactor( pOut, pNtk, fUseRealNames );
00845 return 0;
00846
00847 usage:
00848 fprintf( pErr, "usage: print_factor [-nh] <node>\n" );
00849 fprintf( pErr, "\t prints the factored forms of nodes\n" );
00850 fprintf( pErr, "\t-n : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
00851 fprintf( pErr, "\t-h : print the command usage\n");
00852 fprintf( pErr, "\tnode : (optional) one node to consider\n");
00853 return 1;
00854 }
00855
00867 int Abc_CommandPrintLevel( Abc_Frame_t * pAbc, int argc, char ** argv )
00868 {
00869 FILE * pOut, * pErr;
00870 Abc_Ntk_t * pNtk;
00871 Abc_Obj_t * pNode;
00872 int c;
00873 int fListNodes;
00874 int fProfile;
00875
00876 pNtk = Abc_FrameReadNtk(pAbc);
00877 pOut = Abc_FrameReadOut(pAbc);
00878 pErr = Abc_FrameReadErr(pAbc);
00879
00880
00881 fListNodes = 0;
00882 fProfile = 1;
00883 Extra_UtilGetoptReset();
00884 while ( ( c = Extra_UtilGetopt( argc, argv, "nph" ) ) != EOF )
00885 {
00886 switch ( c )
00887 {
00888 case 'n':
00889 fListNodes ^= 1;
00890 break;
00891 case 'p':
00892 fProfile ^= 1;
00893 break;
00894 case 'h':
00895 goto usage;
00896 default:
00897 goto usage;
00898 }
00899 }
00900
00901 if ( pNtk == NULL )
00902 {
00903 fprintf( pErr, "Empty network.\n" );
00904 return 1;
00905 }
00906
00907 if ( !fProfile && !Abc_NtkIsStrash(pNtk) )
00908 {
00909 fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" );
00910 return 1;
00911 }
00912
00913 if ( argc > globalUtilOptind + 1 )
00914 {
00915 fprintf( pErr, "Wrong number of auguments.\n" );
00916 goto usage;
00917 }
00918
00919 if ( argc == globalUtilOptind + 1 )
00920 {
00921 pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
00922 if ( pNode == NULL )
00923 {
00924 fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
00925 return 1;
00926 }
00927 Abc_NodePrintLevel( pOut, pNode );
00928 return 0;
00929 }
00930
00931 Abc_NtkPrintLevel( pOut, pNtk, fProfile, fListNodes );
00932 return 0;
00933
00934 usage:
00935 fprintf( pErr, "usage: print_level [-nph] <node>\n" );
00936 fprintf( pErr, "\t prints information about node level and cone size\n" );
00937 fprintf( pErr, "\t-n : toggles printing nodes by levels [default = %s]\n", fListNodes? "yes": "no" );
00938 fprintf( pErr, "\t-p : toggles printing level profile [default = %s]\n", fProfile? "yes": "no" );
00939 fprintf( pErr, "\t-h : print the command usage\n");
00940 fprintf( pErr, "\tnode : (optional) one node to consider\n");
00941 return 1;
00942 }
00943
00955 int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv )
00956 {
00957 Vec_Ptr_t * vSuppFun;
00958 FILE * pOut, * pErr;
00959 Abc_Ntk_t * pNtk;
00960 int c;
00961 int fStruct;
00962 int fVerbose;
00963 extern Vec_Ptr_t * Sim_ComputeFunSupp( Abc_Ntk_t * pNtk, int fVerbose );
00964 extern void Abc_NtkPrintStrSupports( Abc_Ntk_t * pNtk );
00965
00966 pNtk = Abc_FrameReadNtk(pAbc);
00967 pOut = Abc_FrameReadOut(pAbc);
00968 pErr = Abc_FrameReadErr(pAbc);
00969
00970
00971 fStruct = 1;
00972 fVerbose = 0;
00973 Extra_UtilGetoptReset();
00974 while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
00975 {
00976 switch ( c )
00977 {
00978 case 's':
00979 fStruct ^= 1;
00980 break;
00981 case 'v':
00982 fVerbose ^= 1;
00983 break;
00984 case 'h':
00985 goto usage;
00986 default:
00987 goto usage;
00988 }
00989 }
00990
00991 if ( pNtk == NULL )
00992 {
00993 fprintf( pErr, "Empty network.\n" );
00994 return 1;
00995 }
00996
00997
00998 if ( fStruct )
00999 {
01000 Abc_NtkPrintStrSupports( pNtk );
01001 return 0;
01002 }
01003
01004 if ( !Abc_NtkIsComb(pNtk) )
01005 {
01006 fprintf( pErr, "This command works only for combinational networks (run \"comb\").\n" );
01007 return 1;
01008 }
01009 if ( !Abc_NtkIsStrash(pNtk) )
01010 {
01011 fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" );
01012 return 1;
01013 }
01014 vSuppFun = Sim_ComputeFunSupp( pNtk, fVerbose );
01015 free( vSuppFun->pArray[0] );
01016 Vec_PtrFree( vSuppFun );
01017 return 0;
01018
01019 usage:
01020 fprintf( pErr, "usage: print_supp [-svh]\n" );
01021 fprintf( pErr, "\t prints the supports of the CO nodes\n" );
01022 fprintf( pErr, "\t-s : toggle printing structural support only [default = %s].\n", fStruct? "yes": "no" );
01023 fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
01024 fprintf( pErr, "\t-h : print the command usage\n");
01025 return 1;
01026 }
01027
01039 int Abc_CommandPrintSymms( Abc_Frame_t * pAbc, int argc, char ** argv )
01040 {
01041 FILE * pOut, * pErr;
01042 Abc_Ntk_t * pNtk;
01043 int c;
01044 int fUseBdds;
01045 int fNaive;
01046 int fReorder;
01047 int fVerbose;
01048 extern void Abc_NtkSymmetries( Abc_Ntk_t * pNtk, int fUseBdds, int fNaive, int fReorder, int fVerbose );
01049
01050 pNtk = Abc_FrameReadNtk(pAbc);
01051 pOut = Abc_FrameReadOut(pAbc);
01052 pErr = Abc_FrameReadErr(pAbc);
01053
01054
01055 fUseBdds = 0;
01056 fNaive = 0;
01057 fReorder = 1;
01058 fVerbose = 0;
01059 Extra_UtilGetoptReset();
01060 while ( ( c = Extra_UtilGetopt( argc, argv, "bnrvh" ) ) != EOF )
01061 {
01062 switch ( c )
01063 {
01064 case 'b':
01065 fUseBdds ^= 1;
01066 break;
01067 case 'n':
01068 fNaive ^= 1;
01069 break;
01070 case 'r':
01071 fReorder ^= 1;
01072 break;
01073 case 'v':
01074 fVerbose ^= 1;
01075 break;
01076 case 'h':
01077 goto usage;
01078 default:
01079 goto usage;
01080 }
01081 }
01082 if ( pNtk == NULL )
01083 {
01084 fprintf( pErr, "Empty network.\n" );
01085 return 1;
01086 }
01087 if ( !Abc_NtkIsComb(pNtk) )
01088 {
01089 fprintf( pErr, "This command works only for combinational networks (run \"comb\").\n" );
01090 return 1;
01091 }
01092 if ( Abc_NtkIsStrash(pNtk) )
01093 Abc_NtkSymmetries( pNtk, fUseBdds, fNaive, fReorder, fVerbose );
01094 else
01095 {
01096 pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
01097 Abc_NtkSymmetries( pNtk, fUseBdds, fNaive, fReorder, fVerbose );
01098 Abc_NtkDelete( pNtk );
01099 }
01100 return 0;
01101
01102 usage:
01103 fprintf( pErr, "usage: print_symm [-bnrvh]\n" );
01104 fprintf( pErr, "\t computes symmetries of the PO functions\n" );
01105 fprintf( pErr, "\t-b : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" );
01106 fprintf( pErr, "\t-n : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" );
01107 fprintf( pErr, "\t-r : enable dynamic BDD variable reordering [default = %s].\n", fReorder? "yes": "no" );
01108 fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
01109 fprintf( pErr, "\t-h : print the command usage\n");
01110 return 1;
01111 }
01112
01124 int Abc_CommandPrintUnate( Abc_Frame_t * pAbc, int argc, char ** argv )
01125 {
01126 FILE * pOut, * pErr;
01127 Abc_Ntk_t * pNtk;
01128 int c;
01129 int fUseBdds;
01130 int fUseNaive;
01131 int fVerbose;
01132 extern void Abc_NtkPrintUnate( Abc_Ntk_t * pNtk, int fUseBdds, int fUseNaive, int fVerbose );
01133
01134 pNtk = Abc_FrameReadNtk(pAbc);
01135 pOut = Abc_FrameReadOut(pAbc);
01136 pErr = Abc_FrameReadErr(pAbc);
01137
01138
01139 fUseBdds = 1;
01140 fUseNaive = 0;
01141 fVerbose = 0;
01142 Extra_UtilGetoptReset();
01143 while ( ( c = Extra_UtilGetopt( argc, argv, "bnvh" ) ) != EOF )
01144 {
01145 switch ( c )
01146 {
01147 case 'b':
01148 fUseBdds ^= 1;
01149 break;
01150 case 'n':
01151 fUseNaive ^= 1;
01152 break;
01153 case 'v':
01154 fVerbose ^= 1;
01155 break;
01156 case 'h':
01157 goto usage;
01158 default:
01159 goto usage;
01160 }
01161 }
01162 if ( pNtk == NULL )
01163 {
01164 fprintf( pErr, "Empty network.\n" );
01165 return 1;
01166 }
01167 if ( !Abc_NtkIsStrash(pNtk) )
01168 {
01169 fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" );
01170 return 1;
01171 }
01172 Abc_NtkPrintUnate( pNtk, fUseBdds, fUseNaive, fVerbose );
01173 return 0;
01174
01175 usage:
01176 fprintf( pErr, "usage: print_unate [-bnvh]\n" );
01177 fprintf( pErr, "\t computes unate variables of the PO functions\n" );
01178 fprintf( pErr, "\t-b : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" );
01179 fprintf( pErr, "\t-n : toggle naive BDD-based computation [default = %s].\n", fUseNaive? "yes": "no" );
01180 fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
01181 fprintf( pErr, "\t-h : print the command usage\n");
01182 return 1;
01183 }
01184
01196 int Abc_CommandPrintAuto( Abc_Frame_t * pAbc, int argc, char ** argv )
01197 {
01198 FILE * pOut, * pErr;
01199 Abc_Ntk_t * pNtk;
01200 int c;
01201 int Output;
01202 int fNaive;
01203 int fVerbose;
01204 extern void Abc_NtkAutoPrint( Abc_Ntk_t * pNtk, int Output, int fNaive, int fVerbose );
01205
01206 pNtk = Abc_FrameReadNtk(pAbc);
01207 pOut = Abc_FrameReadOut(pAbc);
01208 pErr = Abc_FrameReadErr(pAbc);
01209
01210
01211 Output = -1;
01212 fNaive = 0;
01213 fVerbose = 0;
01214 Extra_UtilGetoptReset();
01215 while ( ( c = Extra_UtilGetopt( argc, argv, "Onvh" ) ) != EOF )
01216 {
01217 switch ( c )
01218 {
01219 case 'O':
01220 if ( globalUtilOptind >= argc )
01221 {
01222 fprintf( pErr, "Command line switch \"-O\" should be followed by an integer.\n" );
01223 goto usage;
01224 }
01225 Output = atoi(argv[globalUtilOptind]);
01226 globalUtilOptind++;
01227 if ( Output < 0 )
01228 goto usage;
01229 break;
01230 case 'n':
01231 fNaive ^= 1;
01232 break;
01233 case 'v':
01234 fVerbose ^= 1;
01235 break;
01236 case 'h':
01237 goto usage;
01238 default:
01239 goto usage;
01240 }
01241 }
01242 if ( pNtk == NULL )
01243 {
01244 fprintf( pErr, "Empty network.\n" );
01245 return 1;
01246 }
01247 if ( !Abc_NtkIsStrash(pNtk) )
01248 {
01249 fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" );
01250 return 1;
01251 }
01252
01253
01254 Abc_NtkAutoPrint( pNtk, Output, fNaive, fVerbose );
01255 return 0;
01256
01257 usage:
01258 fprintf( pErr, "usage: print_auto [-O num] [-nvh]\n" );
01259 fprintf( pErr, "\t computes autosymmetries of the PO functions\n" );
01260 fprintf( pErr, "\t-O num : (optional) the 0-based number of the output [default = all]\n");
01261 fprintf( pErr, "\t-n : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" );
01262 fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
01263 fprintf( pErr, "\t-h : print the command usage\n");
01264 return 1;
01265 }
01266
01278 int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv )
01279 {
01280 FILE * pOut, * pErr;
01281 Abc_Ntk_t * pNtk;
01282 Abc_Obj_t * pNode;
01283 int c;
01284 int fUseRealNames;
01285
01286 extern void Abc_NodePrintKMap( Abc_Obj_t * pNode, int fUseRealNames );
01287
01288 pNtk = Abc_FrameReadNtk(pAbc);
01289 pOut = Abc_FrameReadOut(pAbc);
01290 pErr = Abc_FrameReadErr(pAbc);
01291
01292
01293 fUseRealNames = 1;
01294 Extra_UtilGetoptReset();
01295 while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
01296 {
01297 switch ( c )
01298 {
01299 case 'n':
01300 fUseRealNames ^= 1;
01301 break;
01302 case 'h':
01303 goto usage;
01304 default:
01305 goto usage;
01306 }
01307 }
01308
01309 if ( pNtk == NULL )
01310 {
01311 fprintf( pErr, "Empty network.\n" );
01312 return 1;
01313 }
01314
01315 if ( !Abc_NtkIsLogic(pNtk) )
01316 {
01317 fprintf( pErr, "Visualization of Karnaugh maps works for logic networks.\n" );
01318 return 1;
01319 }
01320 if ( argc > globalUtilOptind + 1 )
01321 {
01322 fprintf( pErr, "Wrong number of auguments.\n" );
01323 goto usage;
01324 }
01325 if ( argc == globalUtilOptind )
01326 {
01327 pNode = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
01328 if ( !Abc_ObjIsNode(pNode) )
01329 {
01330 fprintf( pErr, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) );
01331 return 1;
01332 }
01333 }
01334 else
01335 {
01336 pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
01337 if ( pNode == NULL )
01338 {
01339 fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
01340 return 1;
01341 }
01342 }
01343 Abc_NtkToBdd(pNtk);
01344 Abc_NodePrintKMap( pNode, fUseRealNames );
01345 return 0;
01346
01347 usage:
01348 fprintf( pErr, "usage: print_kmap [-nh] <node>\n" );
01349 fprintf( pErr, " shows the truth table of the node\n" );
01350 fprintf( pErr, "\t-n : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
01351 fprintf( pErr, "\t-h : print the command usage\n");
01352 fprintf( pErr, "\tnode : the node to consider (default = the driver of the first PO)\n");
01353 return 1;
01354 }
01355
01367 int Abc_CommandPrintGates( Abc_Frame_t * pAbc, int argc, char ** argv )
01368 {
01369 FILE * pOut, * pErr;
01370 Abc_Ntk_t * pNtk;
01371 int c;
01372 int fUseLibrary;
01373
01374 extern void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary );
01375
01376 pNtk = Abc_FrameReadNtk(pAbc);
01377 pOut = Abc_FrameReadOut(pAbc);
01378 pErr = Abc_FrameReadErr(pAbc);
01379
01380
01381 fUseLibrary = 1;
01382 Extra_UtilGetoptReset();
01383 while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
01384 {
01385 switch ( c )
01386 {
01387 case 'l':
01388 fUseLibrary ^= 1;
01389 break;
01390 case 'h':
01391 goto usage;
01392 default:
01393 goto usage;
01394 }
01395 }
01396
01397 if ( pNtk == NULL )
01398 {
01399 fprintf( pErr, "Empty network.\n" );
01400 return 1;
01401 }
01402 if ( Abc_NtkHasAig(pNtk) )
01403 {
01404 fprintf( pErr, "Printing gates does not work for AIGs and sequential AIGs.\n" );
01405 return 1;
01406 }
01407
01408 Abc_NtkPrintGates( pNtk, fUseLibrary );
01409 return 0;
01410
01411 usage:
01412 fprintf( pErr, "usage: print_gates [-lh]\n" );
01413 fprintf( pErr, "\t prints statistics about gates used in the network\n" );
01414 fprintf( pErr, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
01415 fprintf( pErr, "\t-h : print the command usage\n");
01416 return 1;
01417 }
01418
01430 int Abc_CommandPrintSharing( Abc_Frame_t * pAbc, int argc, char ** argv )
01431 {
01432 FILE * pOut, * pErr;
01433 Abc_Ntk_t * pNtk;
01434 int c;
01435 int fUseLibrary;
01436
01437 extern void Abc_NtkPrintSharing( Abc_Ntk_t * pNtk );
01438
01439 pNtk = Abc_FrameReadNtk(pAbc);
01440 pOut = Abc_FrameReadOut(pAbc);
01441 pErr = Abc_FrameReadErr(pAbc);
01442
01443
01444 fUseLibrary = 1;
01445 Extra_UtilGetoptReset();
01446 while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
01447 {
01448 switch ( c )
01449 {
01450 case 'l':
01451 fUseLibrary ^= 1;
01452 break;
01453 case 'h':
01454 goto usage;
01455 default:
01456 goto usage;
01457 }
01458 }
01459
01460 if ( pNtk == NULL )
01461 {
01462 fprintf( pErr, "Empty network.\n" );
01463 return 1;
01464 }
01465 Abc_NtkPrintSharing( pNtk );
01466 return 0;
01467
01468 usage:
01469 fprintf( pErr, "usage: print_sharing [-h]\n" );
01470 fprintf( pErr, "\t prints the number of shared nodes in the TFI cones of the COs\n" );
01471
01472 fprintf( pErr, "\t-h : print the command usage\n");
01473 return 1;
01474 }
01475
01487 int Abc_CommandPrintXCut( Abc_Frame_t * pAbc, int argc, char ** argv )
01488 {
01489 FILE * pOut, * pErr;
01490 Abc_Ntk_t * pNtk;
01491 int c;
01492 int fUseLibrary;
01493
01494 extern int Abc_NtkCrossCut( Abc_Ntk_t * pNtk );
01495
01496 pNtk = Abc_FrameReadNtk(pAbc);
01497 pOut = Abc_FrameReadOut(pAbc);
01498 pErr = Abc_FrameReadErr(pAbc);
01499
01500
01501 fUseLibrary = 1;
01502 Extra_UtilGetoptReset();
01503 while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
01504 {
01505 switch ( c )
01506 {
01507 case 'l':
01508 fUseLibrary ^= 1;
01509 break;
01510 case 'h':
01511 goto usage;
01512 default:
01513 goto usage;
01514 }
01515 }
01516
01517 if ( pNtk == NULL )
01518 {
01519 fprintf( pErr, "Empty network.\n" );
01520 return 1;
01521 }
01522 Abc_NtkCrossCut( pNtk );
01523 return 0;
01524
01525 usage:
01526 fprintf( pErr, "usage: print_xcut [-h]\n" );
01527 fprintf( pErr, "\t prints the size of the cross cut of the current network\n" );
01528
01529 fprintf( pErr, "\t-h : print the command usage\n");
01530 return 1;
01531 }
01532
01544 int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
01545 {
01546 FILE * pOut, * pErr;
01547 Abc_Ntk_t * pNtk;
01548 int c;
01549 int fCofactor;
01550 int nCofLevel;
01551
01552 extern void Kit_DsdTest( unsigned * pTruth, int nVars );
01553 extern void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVerbose );
01554
01555 pNtk = Abc_FrameReadNtk(pAbc);
01556 pOut = Abc_FrameReadOut(pAbc);
01557 pErr = Abc_FrameReadErr(pAbc);
01558
01559
01560 nCofLevel = 1;
01561 fCofactor = 0;
01562 Extra_UtilGetoptReset();
01563 while ( ( c = Extra_UtilGetopt( argc, argv, "Nch" ) ) != EOF )
01564 {
01565 switch ( c )
01566 {
01567 case 'N':
01568 if ( globalUtilOptind >= argc )
01569 {
01570 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
01571 goto usage;
01572 }
01573 nCofLevel = atoi(argv[globalUtilOptind]);
01574 globalUtilOptind++;
01575 if ( nCofLevel < 0 )
01576 goto usage;
01577 break;
01578 case 'c':
01579 fCofactor ^= 1;
01580 break;
01581 case 'h':
01582 goto usage;
01583 default:
01584 goto usage;
01585 }
01586 }
01587
01588 if ( pNtk == NULL )
01589 {
01590 fprintf( pErr, "Empty network.\n" );
01591 return 1;
01592 }
01593
01594 if ( !Abc_NtkIsLogic(pNtk) )
01595 {
01596 fprintf( pErr, "Currently works only for logic networks.\n" );
01597 return 1;
01598 }
01599 Abc_NtkToAig( pNtk );
01600
01601 {
01602 Abc_Obj_t * pObj = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
01603 Vec_Int_t * vMemory = Vec_IntAlloc(0);
01604 unsigned * pTruth;
01605 if ( !Abc_ObjIsNode(pObj) )
01606 {
01607 fprintf( pErr, "The fanin of the first PO node does not have a logic function.\n" );
01608 return 1;
01609 }
01610 if ( Abc_ObjFaninNum(pObj) > 16 )
01611 {
01612 fprintf( pErr, "Currently works only for up to 16 inputs.\n" );
01613 return 1;
01614 }
01615 pTruth = Abc_ConvertAigToTruth( pNtk->pManFunc, Hop_Regular(pObj->pData), Abc_ObjFaninNum(pObj), vMemory, 0 );
01616 if ( Hop_IsComplement(pObj->pData) )
01617 Extra_TruthNot( pTruth, pTruth, Abc_ObjFaninNum(pObj) );
01618 Extra_PrintBinary( stdout, pTruth, 1 << Abc_ObjFaninNum(pObj) );
01619 printf( "\n" );
01620 if ( fCofactor )
01621 Kit_DsdPrintCofactors( pTruth, Abc_ObjFaninNum(pObj), nCofLevel, 1 );
01622 else
01623 Kit_DsdTest( pTruth, Abc_ObjFaninNum(pObj) );
01624 Vec_IntFree( vMemory );
01625 }
01626 return 0;
01627
01628 usage:
01629 fprintf( pErr, "usage: print_dsd [-ch] [-N num]\n" );
01630 fprintf( pErr, "\t print DSD formula for a single-output function with less than 16 variables\n" );
01631 fprintf( pErr, "\t-c : toggle recursive cofactoring [default = %s]\n", fCofactor? "yes": "no" );
01632 fprintf( pErr, "\t-N num : the number of levels to cofactor [default = %d]\n", nCofLevel );
01633 fprintf( pErr, "\t-h : print the command usage\n");
01634 return 1;
01635 }
01636
01637
01649 int Abc_CommandShow( Abc_Frame_t * pAbc, int argc, char ** argv )
01650 {
01651 FILE * pOut, * pErr;
01652 Abc_Ntk_t * pNtk;
01653 int c;
01654 int fSeq;
01655 int fGateNames;
01656 int fUseReverse;
01657 extern void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames, int fSeq, int fUseReverse );
01658
01659 pNtk = Abc_FrameReadNtk(pAbc);
01660 pOut = Abc_FrameReadOut(pAbc);
01661 pErr = Abc_FrameReadErr(pAbc);
01662
01663
01664 fSeq = 0;
01665 fGateNames = 0;
01666 fUseReverse = 1;
01667 Extra_UtilGetoptReset();
01668 while ( ( c = Extra_UtilGetopt( argc, argv, "rsgh" ) ) != EOF )
01669 {
01670 switch ( c )
01671 {
01672 case 'r':
01673 fUseReverse ^= 1;
01674 break;
01675 case 's':
01676 fSeq ^= 1;
01677 break;
01678 case 'g':
01679 fGateNames ^= 1;
01680 break;
01681 default:
01682 goto usage;
01683 }
01684 }
01685
01686 if ( pNtk == NULL )
01687 {
01688 fprintf( pErr, "Empty network.\n" );
01689 return 1;
01690 }
01691
01692 Abc_NtkShow( pNtk, fGateNames, fSeq, fUseReverse );
01693 return 0;
01694
01695 usage:
01696 fprintf( pErr, "usage: show [-srgh]\n" );
01697 fprintf( pErr, " visualizes the network structure using DOT and GSVIEW\n" );
01698 #ifdef WIN32
01699 fprintf( pErr, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
01700 fprintf( pErr, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
01701 #endif
01702 fprintf( pErr, "\t-s : toggles visualization of sequential networks [default = %s].\n", fSeq? "yes": "no" );
01703 fprintf( pErr, "\t-r : toggles ordering nodes in reverse order [default = %s].\n", fUseReverse? "yes": "no" );
01704 fprintf( pErr, "\t-g : toggles printing gate names for mapped network [default = %s].\n", fGateNames? "yes": "no" );
01705 fprintf( pErr, "\t-h : print the command usage\n");
01706 return 1;
01707 }
01708
01720 int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
01721 {
01722 FILE * pOut, * pErr;
01723 Abc_Ntk_t * pNtk;
01724 Abc_Obj_t * pNode;
01725 int c;
01726 extern void Abc_NodeShowBdd( Abc_Obj_t * pNode );
01727
01728 pNtk = Abc_FrameReadNtk(pAbc);
01729 pOut = Abc_FrameReadOut(pAbc);
01730 pErr = Abc_FrameReadErr(pAbc);
01731
01732
01733 Extra_UtilGetoptReset();
01734 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01735 {
01736 switch ( c )
01737 {
01738 case 'h':
01739 goto usage;
01740 default:
01741 goto usage;
01742 }
01743 }
01744
01745 if ( pNtk == NULL )
01746 {
01747 fprintf( pErr, "Empty network.\n" );
01748 return 1;
01749 }
01750
01751 if ( !Abc_NtkIsBddLogic(pNtk) )
01752 {
01753 fprintf( pErr, "Visualizing BDDs can only be done for logic BDD networks (run \"bdd\").\n" );
01754 return 1;
01755 }
01756
01757 if ( argc > globalUtilOptind + 1 )
01758 {
01759 fprintf( pErr, "Wrong number of auguments.\n" );
01760 goto usage;
01761 }
01762 if ( argc == globalUtilOptind )
01763 {
01764 pNode = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
01765 if ( !Abc_ObjIsNode(pNode) )
01766 {
01767 fprintf( pErr, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) );
01768 return 1;
01769 }
01770 }
01771 else
01772 {
01773 pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
01774 if ( pNode == NULL )
01775 {
01776 fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
01777 return 1;
01778 }
01779 }
01780 Abc_NodeShowBdd( pNode );
01781 return 0;
01782
01783 usage:
01784 fprintf( pErr, "usage: show_bdd [-h] <node>\n" );
01785 fprintf( pErr, " visualizes the BDD of a node using DOT and GSVIEW\n" );
01786 #ifdef WIN32
01787 fprintf( pErr, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
01788 fprintf( pErr, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
01789 #endif
01790 fprintf( pErr, "\tnode : the node to consider [default = the driver of the first PO]\n");
01791 fprintf( pErr, "\t-h : print the command usage\n");
01792 return 1;
01793 }
01794
01806 int Abc_CommandShowCut( Abc_Frame_t * pAbc, int argc, char ** argv )
01807 {
01808 FILE * pOut, * pErr;
01809 Abc_Ntk_t * pNtk;
01810 Abc_Obj_t * pNode;
01811 int c;
01812 int nNodeSizeMax;
01813 int nConeSizeMax;
01814 extern void Abc_NodeShowCut( Abc_Obj_t * pNode, int nNodeSizeMax, int nConeSizeMax );
01815
01816 pNtk = Abc_FrameReadNtk(pAbc);
01817 pOut = Abc_FrameReadOut(pAbc);
01818 pErr = Abc_FrameReadErr(pAbc);
01819
01820
01821 nNodeSizeMax = 10;
01822 nConeSizeMax = ABC_INFINITY;
01823 Extra_UtilGetoptReset();
01824 while ( ( c = Extra_UtilGetopt( argc, argv, "NCh" ) ) != EOF )
01825 {
01826 switch ( c )
01827 {
01828 case 'N':
01829 if ( globalUtilOptind >= argc )
01830 {
01831 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
01832 goto usage;
01833 }
01834 nNodeSizeMax = atoi(argv[globalUtilOptind]);
01835 globalUtilOptind++;
01836 if ( nNodeSizeMax < 0 )
01837 goto usage;
01838 break;
01839 case 'C':
01840 if ( globalUtilOptind >= argc )
01841 {
01842 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
01843 goto usage;
01844 }
01845 nConeSizeMax = atoi(argv[globalUtilOptind]);
01846 globalUtilOptind++;
01847 if ( nConeSizeMax < 0 )
01848 goto usage;
01849 break;
01850 case 'h':
01851 goto usage;
01852 default:
01853 goto usage;
01854 }
01855 }
01856
01857 if ( pNtk == NULL )
01858 {
01859 fprintf( pErr, "Empty network.\n" );
01860 return 1;
01861 }
01862
01863 if ( !Abc_NtkIsStrash(pNtk) )
01864 {
01865 fprintf( pErr, "Visualizing cuts only works for AIGs (run \"strash\").\n" );
01866 return 1;
01867 }
01868 if ( argc != globalUtilOptind + 1 )
01869 {
01870 fprintf( pErr, "Wrong number of auguments.\n" );
01871 goto usage;
01872 }
01873
01874 pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
01875 if ( pNode == NULL )
01876 {
01877 fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
01878 return 1;
01879 }
01880 Abc_NodeShowCut( pNode, nNodeSizeMax, nConeSizeMax );
01881 return 0;
01882
01883 usage:
01884 fprintf( pErr, "usage: show_cut [-N num] [-C num] [-h] <node>\n" );
01885 fprintf( pErr, " visualizes the cut of a node using DOT and GSVIEW\n" );
01886 #ifdef WIN32
01887 fprintf( pErr, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
01888 fprintf( pErr, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
01889 #endif
01890 fprintf( pErr, "\t-N num : the max size of the cut to be computed [default = %d]\n", nNodeSizeMax );
01891 fprintf( pErr, "\t-C num : the max support of the containing cone [default = %d]\n", nConeSizeMax );
01892 fprintf( pErr, "\tnode : the node to consider\n");
01893 fprintf( pErr, "\t-h : print the command usage\n");
01894 return 1;
01895 }
01896
01897
01909 int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
01910 {
01911 FILE * pOut, * pErr;
01912 Abc_Ntk_t * pNtk, * pNtkRes;
01913 int fVerbose;
01914 int fBddSizeMax;
01915 int fDualRail;
01916 int fReorder;
01917 int c;
01918
01919 pNtk = Abc_FrameReadNtk(pAbc);
01920 pOut = Abc_FrameReadOut(pAbc);
01921 pErr = Abc_FrameReadErr(pAbc);
01922
01923
01924 fVerbose = 1;
01925 fReorder = 1;
01926 fDualRail = 0;
01927 fBddSizeMax = 50000000;
01928 Extra_UtilGetoptReset();
01929 while ( ( c = Extra_UtilGetopt( argc, argv, "Brdvh" ) ) != EOF )
01930 {
01931 switch ( c )
01932 {
01933 case 'B':
01934 if ( globalUtilOptind >= argc )
01935 {
01936 fprintf( pErr, "Command line switch \"-B\" should be followed by an integer.\n" );
01937 goto usage;
01938 }
01939 fBddSizeMax = atoi(argv[globalUtilOptind]);
01940 globalUtilOptind++;
01941 if ( fBddSizeMax < 0 )
01942 goto usage;
01943 break;
01944 case 'd':
01945 fDualRail ^= 1;
01946 break;
01947 case 'v':
01948 fVerbose ^= 1;
01949 break;
01950 case 'r':
01951 fReorder ^= 1;
01952 break;
01953 case 'h':
01954 goto usage;
01955 default:
01956 goto usage;
01957 }
01958 }
01959
01960 if ( pNtk == NULL )
01961 {
01962 fprintf( pErr, "Empty network.\n" );
01963 return 1;
01964 }
01965
01966 if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
01967 {
01968 fprintf( pErr, "Can only collapse a logic network or an AIG.\n" );
01969 return 1;
01970 }
01971
01972
01973 if ( Abc_NtkIsStrash(pNtk) )
01974 pNtkRes = Abc_NtkCollapse( pNtk, fBddSizeMax, fDualRail, fReorder, fVerbose );
01975 else
01976 {
01977 pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
01978 pNtkRes = Abc_NtkCollapse( pNtk, fBddSizeMax, fDualRail, fReorder, fVerbose );
01979 Abc_NtkDelete( pNtk );
01980 }
01981 if ( pNtkRes == NULL )
01982 {
01983 fprintf( pErr, "Collapsing has failed.\n" );
01984 return 1;
01985 }
01986
01987 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
01988 return 0;
01989
01990 usage:
01991 fprintf( pErr, "usage: collapse [-B num] [-rdvh]\n" );
01992 fprintf( pErr, "\t collapses the network by constructing global BDDs\n" );
01993 fprintf( pErr, "\t-B num : limit on live BDD nodes during collapsing [default = %d]\n", fBddSizeMax );
01994 fprintf( pErr, "\t-r : toggles dynamic variable reordering [default = %s]\n", fReorder? "yes": "no" );
01995 fprintf( pErr, "\t-d : toggles dual-rail collapsing mode [default = %s]\n", fDualRail? "yes": "no" );
01996 fprintf( pErr, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
01997 fprintf( pErr, "\t-h : print the command usage\n");
01998 return 1;
01999 }
02000
02001
02013 int Abc_CommandStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
02014 {
02015 FILE * pOut, * pErr;
02016 Abc_Ntk_t * pNtk, * pNtkRes;
02017 int c;
02018 int fAllNodes;
02019 int fRecord;
02020 int fCleanup;
02021
02022 pNtk = Abc_FrameReadNtk(pAbc);
02023 pOut = Abc_FrameReadOut(pAbc);
02024 pErr = Abc_FrameReadErr(pAbc);
02025
02026
02027 fAllNodes = 0;
02028 fCleanup = 1;
02029 fRecord = 0;
02030 Extra_UtilGetoptReset();
02031 while ( ( c = Extra_UtilGetopt( argc, argv, "acrh" ) ) != EOF )
02032 {
02033 switch ( c )
02034 {
02035 case 'a':
02036 fAllNodes ^= 1;
02037 break;
02038 case 'c':
02039 fCleanup ^= 1;
02040 break;
02041 case 'r':
02042 fRecord ^= 1;
02043 break;
02044 case 'h':
02045 goto usage;
02046 default:
02047 goto usage;
02048 }
02049 }
02050
02051 if ( pNtk == NULL )
02052 {
02053 fprintf( pErr, "Empty network.\n" );
02054 return 1;
02055 }
02056
02057
02058 pNtkRes = Abc_NtkStrash( pNtk, fAllNodes, fCleanup, fRecord );
02059 if ( pNtkRes == NULL )
02060 {
02061 fprintf( pErr, "Strashing has failed.\n" );
02062 return 1;
02063 }
02064
02065 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
02066 return 0;
02067
02068 usage:
02069 fprintf( pErr, "usage: strash [-acrh]\n" );
02070 fprintf( pErr, "\t transforms combinational logic into an AIG\n" );
02071 fprintf( pErr, "\t-a : toggles between using all nodes and DFS nodes [default = %s]\n", fAllNodes? "all": "DFS" );
02072 fprintf( pErr, "\t-c : toggles cleanup to remove the dagling AIG nodes [default = %s]\n", fCleanup? "all": "DFS" );
02073 fprintf( pErr, "\t-r : enables using the record of AIG subgraphs [default = %s]\n", fRecord? "yes": "no" );
02074 fprintf( pErr, "\t-h : print the command usage\n");
02075 return 1;
02076 }
02077
02089 int Abc_CommandBalance( Abc_Frame_t * pAbc, int argc, char ** argv )
02090 {
02091 FILE * pOut, * pErr;
02092 Abc_Ntk_t * pNtk, * pNtkRes, * pNtkTemp;
02093 int c;
02094 bool fDuplicate;
02095 bool fSelective;
02096 bool fUpdateLevel;
02097
02098 pNtk = Abc_FrameReadNtk(pAbc);
02099 pOut = Abc_FrameReadOut(pAbc);
02100 pErr = Abc_FrameReadErr(pAbc);
02101
02102
02103 fDuplicate = 0;
02104 fSelective = 0;
02105 fUpdateLevel = 1;
02106 Extra_UtilGetoptReset();
02107 while ( ( c = Extra_UtilGetopt( argc, argv, "ldsh" ) ) != EOF )
02108 {
02109 switch ( c )
02110 {
02111 case 'l':
02112 fUpdateLevel ^= 1;
02113 break;
02114 case 'd':
02115 fDuplicate ^= 1;
02116 break;
02117 case 's':
02118 fSelective ^= 1;
02119 break;
02120 case 'h':
02121 goto usage;
02122 default:
02123 goto usage;
02124 }
02125 }
02126
02127 if ( pNtk == NULL )
02128 {
02129 fprintf( pErr, "Empty network.\n" );
02130 return 1;
02131 }
02132
02133 if ( Abc_NtkIsStrash(pNtk) )
02134 {
02135 pNtkRes = Abc_NtkBalance( pNtk, fDuplicate, fSelective, fUpdateLevel );
02136 }
02137 else
02138 {
02139 pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
02140 if ( pNtkTemp == NULL )
02141 {
02142 fprintf( pErr, "Strashing before balancing has failed.\n" );
02143 return 1;
02144 }
02145 pNtkRes = Abc_NtkBalance( pNtkTemp, fDuplicate, fSelective, fUpdateLevel );
02146 Abc_NtkDelete( pNtkTemp );
02147 }
02148
02149
02150 if ( pNtkRes == NULL )
02151 {
02152 fprintf( pErr, "Balancing has failed.\n" );
02153 return 1;
02154 }
02155
02156 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
02157 return 0;
02158
02159 usage:
02160 fprintf( pErr, "usage: balance [-ldsh]\n" );
02161 fprintf( pErr, "\t transforms the current network into a well-balanced AIG\n" );
02162 fprintf( pErr, "\t-l : toggle minimizing the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
02163 fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
02164 fprintf( pErr, "\t-s : toggle duplication on the critical paths [default = %s]\n", fSelective? "yes": "no" );
02165 fprintf( pErr, "\t-h : print the command usage\n");
02166 return 1;
02167 }
02168
02180 int Abc_CommandMulti( Abc_Frame_t * pAbc, int argc, char ** argv )
02181 {
02182 FILE * pOut, * pErr;
02183 Abc_Ntk_t * pNtk, * pNtkRes;
02184 int nThresh, nFaninMax, c;
02185 int fCnf;
02186 int fMulti;
02187 int fSimple;
02188 int fFactor;
02189 extern Abc_Ntk_t * Abc_NtkMulti( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple, int fFactor );
02190
02191 pNtk = Abc_FrameReadNtk(pAbc);
02192 pOut = Abc_FrameReadOut(pAbc);
02193 pErr = Abc_FrameReadErr(pAbc);
02194
02195
02196 nThresh = 1;
02197 nFaninMax = 20;
02198 fCnf = 0;
02199 fMulti = 1;
02200 fSimple = 0;
02201 fFactor = 0;
02202 Extra_UtilGetoptReset();
02203 while ( ( c = Extra_UtilGetopt( argc, argv, "TFmcsfh" ) ) != EOF )
02204 {
02205 switch ( c )
02206 {
02207 case 'T':
02208 if ( globalUtilOptind >= argc )
02209 {
02210 fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" );
02211 goto usage;
02212 }
02213 nThresh = atoi(argv[globalUtilOptind]);
02214 globalUtilOptind++;
02215 if ( nThresh < 0 )
02216 goto usage;
02217 break;
02218 case 'F':
02219 if ( globalUtilOptind >= argc )
02220 {
02221 fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
02222 goto usage;
02223 }
02224 nFaninMax = atoi(argv[globalUtilOptind]);
02225 globalUtilOptind++;
02226 if ( nFaninMax < 0 )
02227 goto usage;
02228 break;
02229 case 'c':
02230 fCnf ^= 1;
02231 break;
02232 case 'm':
02233 fMulti ^= 1;
02234 break;
02235 case 's':
02236 fSimple ^= 1;
02237 break;
02238 case 'f':
02239 fFactor ^= 1;
02240 break;
02241 case 'h':
02242 goto usage;
02243 default:
02244 goto usage;
02245 }
02246 }
02247
02248 if ( pNtk == NULL )
02249 {
02250 fprintf( pErr, "Empty network.\n" );
02251 return 1;
02252 }
02253 if ( !Abc_NtkIsStrash(pNtk) )
02254 {
02255 fprintf( pErr, "Cannot renode a network that is not an AIG (run \"strash\").\n" );
02256 return 1;
02257 }
02258
02259
02260 pNtkRes = Abc_NtkMulti( pNtk, nThresh, nFaninMax, fCnf, fMulti, fSimple, fFactor );
02261 if ( pNtkRes == NULL )
02262 {
02263 fprintf( pErr, "Renoding has failed.\n" );
02264 return 1;
02265 }
02266
02267 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
02268 return 0;
02269
02270 usage:
02271 fprintf( pErr, "usage: multi [-T num] [-F num] [-msfch]\n" );
02272 fprintf( pErr, "\t transforms an AIG into a logic network by creating larger nodes\n" );
02273 fprintf( pErr, "\t-F num : the maximum fanin size after renoding [default = %d]\n", nFaninMax );
02274 fprintf( pErr, "\t-T num : the threshold for AIG node duplication [default = %d]\n", nThresh );
02275 fprintf( pErr, "\t (an AIG node is the root of a new node after renoding\n" );
02276 fprintf( pErr, "\t if this leads to duplication of no more than %d AIG nodes,\n", nThresh );
02277 fprintf( pErr, "\t that is, if [(numFanouts(Node)-1) * size(MFFC(Node))] <= %d)\n", nThresh );
02278 fprintf( pErr, "\t-m : creates multi-input AND graph [default = %s]\n", fMulti? "yes": "no" );
02279 fprintf( pErr, "\t-s : creates a simple AIG (no renoding) [default = %s]\n", fSimple? "yes": "no" );
02280 fprintf( pErr, "\t-f : creates a factor-cut network [default = %s]\n", fFactor? "yes": "no" );
02281 fprintf( pErr, "\t-c : performs renoding to derive the CNF [default = %s]\n", fCnf? "yes": "no" );
02282 fprintf( pErr, "\t-h : print the command usage\n");
02283 return 1;
02284 }
02285
02297 int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
02298 {
02299 FILE * pOut, * pErr;
02300 Abc_Ntk_t * pNtk, * pNtkRes;
02301 int nLutSize, nCutsMax, c;
02302 int nFlowIters, nAreaIters;
02303 int fArea;
02304 int fUseBdds;
02305 int fUseSops;
02306 int fUseCnfs;
02307 int fUseMv;
02308 int fVerbose;
02309 extern Abc_Ntk_t * Abc_NtkRenode( Abc_Ntk_t * pNtk, int nLutSize, int nCutsMax, int nFlowIters, int nAreaIters, int fArea, int fUseBdds, int fUseSops, int fUseCnfs, int fUseMv, int fVerbose );
02310
02311 pNtk = Abc_FrameReadNtk(pAbc);
02312 pOut = Abc_FrameReadOut(pAbc);
02313 pErr = Abc_FrameReadErr(pAbc);
02314
02315
02316 nLutSize = 8;
02317 nCutsMax = 4;
02318 nFlowIters = 1;
02319 nAreaIters = 1;
02320 fArea = 0;
02321 fUseBdds = 0;
02322 fUseSops = 0;
02323 fUseCnfs = 0;
02324 fUseMv = 0;
02325 fVerbose = 0;
02326 Extra_UtilGetoptReset();
02327 while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAabscivh" ) ) != EOF )
02328 {
02329 switch ( c )
02330 {
02331 case 'K':
02332 if ( globalUtilOptind >= argc )
02333 {
02334 fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
02335 goto usage;
02336 }
02337 nLutSize = atoi(argv[globalUtilOptind]);
02338 globalUtilOptind++;
02339 if ( nLutSize < 0 )
02340 goto usage;
02341 break;
02342 case 'C':
02343 if ( globalUtilOptind >= argc )
02344 {
02345 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
02346 goto usage;
02347 }
02348 nCutsMax = atoi(argv[globalUtilOptind]);
02349 globalUtilOptind++;
02350 if ( nCutsMax < 0 )
02351 goto usage;
02352 break;
02353 case 'F':
02354 if ( globalUtilOptind >= argc )
02355 {
02356 fprintf( pErr, "Command line switch \"-F\" should be followed by a positive integer.\n" );
02357 goto usage;
02358 }
02359 nFlowIters = atoi(argv[globalUtilOptind]);
02360 globalUtilOptind++;
02361 if ( nFlowIters < 0 )
02362 goto usage;
02363 break;
02364 case 'A':
02365 if ( globalUtilOptind >= argc )
02366 {
02367 fprintf( pErr, "Command line switch \"-A\" should be followed by a positive integer.\n" );
02368 goto usage;
02369 }
02370 nAreaIters = atoi(argv[globalUtilOptind]);
02371 globalUtilOptind++;
02372 if ( nAreaIters < 0 )
02373 goto usage;
02374 break;
02375 case 'a':
02376 fArea ^= 1;
02377 break;
02378 case 'b':
02379 fUseBdds ^= 1;
02380 break;
02381 case 's':
02382 fUseSops ^= 1;
02383 break;
02384 case 'c':
02385 fUseCnfs ^= 1;
02386 break;
02387 case 'i':
02388 fUseMv ^= 1;
02389 break;
02390 case 'v':
02391 fVerbose ^= 1;
02392 break;
02393 case 'h':
02394 goto usage;
02395 default:
02396 goto usage;
02397 }
02398 }
02399
02400 if ( fUseBdds + fUseSops + fUseCnfs + fUseMv > 1 )
02401 {
02402 fprintf( pErr, "Cannot optimize two parameters at the same time.\n" );
02403 return 1;
02404 }
02405
02406 if ( nLutSize < 3 || nLutSize > IF_MAX_FUNC_LUTSIZE )
02407 {
02408 fprintf( pErr, "Incorrect LUT size (%d).\n", nLutSize );
02409 return 1;
02410 }
02411
02412 if ( nCutsMax < 1 || nCutsMax >= (1<<12) )
02413 {
02414 fprintf( pErr, "Incorrect number of cuts.\n" );
02415 return 1;
02416 }
02417
02418 if ( pNtk == NULL )
02419 {
02420 fprintf( pErr, "Empty network.\n" );
02421 return 1;
02422 }
02423 if ( !Abc_NtkIsStrash(pNtk) )
02424 {
02425 fprintf( pErr, "Cannot renode a network that is not an AIG (run \"strash\").\n" );
02426 return 1;
02427 }
02428
02429
02430 pNtkRes = Abc_NtkRenode( pNtk, nLutSize, nCutsMax, nFlowIters, nAreaIters, fArea, fUseBdds, fUseSops, fUseCnfs, fUseMv, fVerbose );
02431 if ( pNtkRes == NULL )
02432 {
02433 fprintf( pErr, "Renoding has failed.\n" );
02434 return 1;
02435 }
02436
02437 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
02438 return 0;
02439
02440 usage:
02441 fprintf( pErr, "usage: renode [-K num] [-C num] [-F num] [-A num] [-sbciav]\n" );
02442 fprintf( pErr, "\t transforms the AIG into a logic network with larger nodes\n" );
02443 fprintf( pErr, "\t while minimizing the number of FF literals of the node SOPs\n" );
02444 fprintf( pErr, "\t-K num : the max cut size for renoding (2 < num < %d) [default = %d]\n", IF_MAX_FUNC_LUTSIZE+1, nLutSize );
02445 fprintf( pErr, "\t-C num : the max number of cuts used at a node (0 < num < 2^12) [default = %d]\n", nCutsMax );
02446 fprintf( pErr, "\t-F num : the number of area flow recovery iterations (num >= 0) [default = %d]\n", nFlowIters );
02447 fprintf( pErr, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", nAreaIters );
02448 fprintf( pErr, "\t-s : toggles minimizing SOP cubes instead of FF lits [default = %s]\n", fUseSops? "yes": "no" );
02449 fprintf( pErr, "\t-b : toggles minimizing BDD nodes instead of FF lits [default = %s]\n", fUseBdds? "yes": "no" );
02450 fprintf( pErr, "\t-c : toggles minimizing CNF clauses instead of FF lits [default = %s]\n", fUseCnfs? "yes": "no" );
02451 fprintf( pErr, "\t-i : toggles minimizing MV-SOP instead of FF lits [default = %s]\n", fUseMv? "yes": "no" );
02452 fprintf( pErr, "\t-a : toggles area-oriented mapping [default = %s]\n", fArea? "yes": "no" );
02453 fprintf( pErr, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
02454 fprintf( pErr, "\t-h : print the command usage\n");
02455 return 1;
02456 }
02457
02469 int Abc_CommandCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
02470 {
02471 FILE * pOut, * pErr;
02472 Abc_Ntk_t * pNtk;
02473 int c;
02474
02475 pNtk = Abc_FrameReadNtk(pAbc);
02476 pOut = Abc_FrameReadOut(pAbc);
02477 pErr = Abc_FrameReadErr(pAbc);
02478
02479
02480 Extra_UtilGetoptReset();
02481 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
02482 {
02483 switch ( c )
02484 {
02485 case 'h':
02486 goto usage;
02487 default:
02488 goto usage;
02489 }
02490 }
02491
02492 if ( pNtk == NULL )
02493 {
02494 fprintf( pErr, "Empty network.\n" );
02495 return 1;
02496 }
02497 if ( Abc_NtkIsStrash(pNtk) )
02498 {
02499 fprintf( pErr, "Cleanup cannot be performed on the AIG.\n" );
02500 return 1;
02501 }
02502
02503 Abc_NtkCleanup( pNtk, 1 );
02504 return 0;
02505
02506 usage:
02507 fprintf( pErr, "usage: cleanup [-h]\n" );
02508 fprintf( pErr, "\t removes dangling nodes\n" );
02509 fprintf( pErr, "\t-h : print the command usage\n");
02510 return 1;
02511 }
02512
02524 int Abc_CommandSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
02525 {
02526 FILE * pOut, * pErr;
02527 Abc_Ntk_t * pNtk;
02528 int c;
02529
02530 pNtk = Abc_FrameReadNtk(pAbc);
02531 pOut = Abc_FrameReadOut(pAbc);
02532 pErr = Abc_FrameReadErr(pAbc);
02533
02534
02535 Extra_UtilGetoptReset();
02536 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
02537 {
02538 switch ( c )
02539 {
02540 case 'h':
02541 goto usage;
02542 default:
02543 goto usage;
02544 }
02545 }
02546
02547 if ( pNtk == NULL )
02548 {
02549 fprintf( pErr, "Empty network.\n" );
02550 return 1;
02551 }
02552 if ( !Abc_NtkIsLogic(pNtk) )
02553 {
02554 fprintf( pErr, "The classical (SIS-like) sweep can only be performed on a logic network.\n" );
02555 return 1;
02556 }
02557
02558 Abc_NtkSweep( pNtk, 0 );
02559 return 0;
02560
02561 usage:
02562 fprintf( pErr, "usage: sweep [-h]\n" );
02563 fprintf( pErr, "\t removes dangling nodes; propagates constant, buffers, inverters\n" );
02564 fprintf( pErr, "\t-h : print the command usage\n");
02565 return 1;
02566 }
02567
02568
02580 int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
02581 {
02582 Abc_Ntk_t * pNtk;
02583 FILE * pOut, * pErr;
02584 Fxu_Data_t * p = NULL;
02585 int c;
02586 extern bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p );
02587 extern void Abc_NtkFxuFreeInfo( Fxu_Data_t * p );
02588
02589 pNtk = Abc_FrameReadNtk(pAbc);
02590 pOut = Abc_FrameReadOut(pAbc);
02591 pErr = Abc_FrameReadErr(pAbc);
02592
02593
02594 p = ALLOC( Fxu_Data_t, 1 );
02595 memset( p, 0, sizeof(Fxu_Data_t) );
02596
02597 p->nSingleMax = 20000;
02598 p->nPairsMax = 30000;
02599 p->nNodesExt = 10000;
02600 p->fOnlyS = 0;
02601 p->fOnlyD = 0;
02602 p->fUse0 = 0;
02603 p->fUseCompl = 1;
02604 p->fVerbose = 0;
02605 Extra_UtilGetoptReset();
02606 while ( (c = Extra_UtilGetopt(argc, argv, "SDNsdzcvh")) != EOF )
02607 {
02608 switch (c)
02609 {
02610 case 'S':
02611 if ( globalUtilOptind >= argc )
02612 {
02613 fprintf( pErr, "Command line switch \"-S\" should be followed by an integer.\n" );
02614 goto usage;
02615 }
02616 p->nSingleMax = atoi(argv[globalUtilOptind]);
02617 globalUtilOptind++;
02618 if ( p->nSingleMax < 0 )
02619 goto usage;
02620 break;
02621 case 'D':
02622 if ( globalUtilOptind >= argc )
02623 {
02624 fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
02625 goto usage;
02626 }
02627 p->nPairsMax = atoi(argv[globalUtilOptind]);
02628 globalUtilOptind++;
02629 if ( p->nPairsMax < 0 )
02630 goto usage;
02631 break;
02632 case 'N':
02633 if ( globalUtilOptind >= argc )
02634 {
02635 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
02636 goto usage;
02637 }
02638 p->nNodesExt = atoi(argv[globalUtilOptind]);
02639 globalUtilOptind++;
02640 if ( p->nNodesExt < 0 )
02641 goto usage;
02642 break;
02643 case 's':
02644 p->fOnlyS ^= 1;
02645 break;
02646 case 'd':
02647 p->fOnlyD ^= 1;
02648 break;
02649 case 'z':
02650 p->fUse0 ^= 1;
02651 break;
02652 case 'c':
02653 p->fUseCompl ^= 1;
02654 break;
02655 case 'v':
02656 p->fVerbose ^= 1;
02657 break;
02658 case 'h':
02659 goto usage;
02660 break;
02661 default:
02662 goto usage;
02663 }
02664 }
02665
02666 if ( pNtk == NULL )
02667 {
02668 fprintf( pErr, "Empty network.\n" );
02669 Abc_NtkFxuFreeInfo( p );
02670 return 1;
02671 }
02672
02673 if ( Abc_NtkNodeNum(pNtk) == 0 )
02674 {
02675 fprintf( pErr, "The network does not have internal nodes.\n" );
02676 Abc_NtkFxuFreeInfo( p );
02677 return 1;
02678 }
02679
02680 if ( !Abc_NtkIsLogic(pNtk) )
02681 {
02682 fprintf( pErr, "Fast extract can only be applied to a logic network (run \"renode\").\n" );
02683 Abc_NtkFxuFreeInfo( p );
02684 return 1;
02685 }
02686
02687
02688
02689 Abc_NtkFastExtract( pNtk, p );
02690 Abc_NtkFxuFreeInfo( p );
02691 return 0;
02692
02693 usage:
02694 fprintf( pErr, "usage: fx [-S num] [-D num] [-N num] [-sdzcvh]\n");
02695 fprintf( pErr, "\t performs unate fast extract on the current network\n");
02696 fprintf( pErr, "\t-S num : max number of single-cube divisors to consider [default = %d]\n", p->nSingleMax );
02697 fprintf( pErr, "\t-D num : max number of double-cube divisors to consider [default = %d]\n", p->nPairsMax );
02698 fprintf( pErr, "\t-N num : the maximum number of divisors to extract [default = %d]\n", p->nNodesExt );
02699 fprintf( pErr, "\t-s : use only single-cube divisors [default = %s]\n", p->fOnlyS? "yes": "no" );
02700 fprintf( pErr, "\t-d : use only double-cube divisors [default = %s]\n", p->fOnlyD? "yes": "no" );
02701 fprintf( pErr, "\t-z : use zero-weight divisors [default = %s]\n", p->fUse0? "yes": "no" );
02702 fprintf( pErr, "\t-c : use complement in the binary case [default = %s]\n", p->fUseCompl? "yes": "no" );
02703 fprintf( pErr, "\t-v : print verbose information [default = %s]\n", p->fVerbose? "yes": "no" );
02704 fprintf( pErr, "\t-h : print the command usage\n");
02705 Abc_NtkFxuFreeInfo( p );
02706 return 1;
02707 }
02708
02720 int Abc_CommandDisjoint( Abc_Frame_t * pAbc, int argc, char ** argv )
02721 {
02722 FILE * pOut, * pErr;
02723 Abc_Ntk_t * pNtk, * pNtkRes, * pNtkNew;
02724 int fGlobal, fRecursive, fVerbose, fPrint, fShort, c;
02725
02726 extern Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort );
02727 extern int Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, bool fVerbose, bool fRecursive );
02728
02729 pNtk = Abc_FrameReadNtk(pAbc);
02730 pOut = Abc_FrameReadOut(pAbc);
02731 pErr = Abc_FrameReadErr(pAbc);
02732
02733
02734 fGlobal = 1;
02735 fRecursive = 0;
02736 fVerbose = 0;
02737 fPrint = 0;
02738 fShort = 0;
02739 Extra_UtilGetoptReset();
02740 while ( ( c = Extra_UtilGetopt( argc, argv, "grvpsh" ) ) != EOF )
02741 {
02742 switch ( c )
02743 {
02744 case 'g':
02745 fGlobal ^= 1;
02746 break;
02747 case 'r':
02748 fRecursive ^= 1;
02749 break;
02750 case 'v':
02751 fVerbose ^= 1;
02752 break;
02753 case 'p':
02754 fPrint ^= 1;
02755 break;
02756 case 's':
02757 fShort ^= 1;
02758 break;
02759 case 'h':
02760 goto usage;
02761 break;
02762 default:
02763 goto usage;
02764 }
02765 }
02766
02767 if ( pNtk == NULL )
02768 {
02769 fprintf( pErr, "Empty network.\n" );
02770 return 1;
02771 }
02772
02773 if ( fGlobal )
02774 {
02775
02776
02777 if ( !Abc_NtkIsStrash(pNtk) )
02778 {
02779 pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
02780 pNtkRes = Abc_NtkDsdGlobal( pNtkNew, fVerbose, fPrint, fShort );
02781 Abc_NtkDelete( pNtkNew );
02782 }
02783 else
02784 {
02785 pNtkRes = Abc_NtkDsdGlobal( pNtk, fVerbose, fPrint, fShort );
02786 }
02787 if ( pNtkRes == NULL )
02788 {
02789 fprintf( pErr, "Global DSD has failed.\n" );
02790 return 1;
02791 }
02792
02793 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
02794 }
02795 else if ( fRecursive )
02796 {
02797 if ( !Abc_NtkIsBddLogic( pNtk ) )
02798 {
02799 fprintf( pErr, "This command is only applicable to logic BDD networks.\n" );
02800 return 1;
02801 }
02802 fprintf( stdout, "Performing recursive DSD and MUX decomposition of local functions.\n" );
02803 if ( !Abc_NtkDsdLocal( pNtk, fVerbose, fRecursive ) )
02804 fprintf( pErr, "Recursive DSD has failed.\n" );
02805 }
02806 else
02807 {
02808 if ( !Abc_NtkIsBddLogic( pNtk ) )
02809 {
02810 fprintf( pErr, "This command is only applicable to logic BDD networks (run \"bdd\").\n" );
02811 return 1;
02812 }
02813 fprintf( stdout, "Performing simple non-recursive DSD of local functions.\n" );
02814 if ( !Abc_NtkDsdLocal( pNtk, fVerbose, fRecursive ) )
02815 fprintf( pErr, "Simple DSD of local functions has failed.\n" );
02816 }
02817 return 0;
02818
02819 usage:
02820 fprintf( pErr, "usage: dsd [-grvpsh]\n" );
02821 fprintf( pErr, "\t decomposes the network using disjoint-support decomposition\n" );
02822 fprintf( pErr, "\t-g : toggle DSD of global and local functions [default = %s]\n", fGlobal? "global": "local" );
02823 fprintf( pErr, "\t-r : toggle recursive DSD/MUX and simple DSD [default = %s]\n", fRecursive? "recursive DSD/MUX": "simple DSD" );
02824 fprintf( pErr, "\t-v : prints DSD statistics and runtime [default = %s]\n", fVerbose? "yes": "no" );
02825 fprintf( pErr, "\t-p : prints DSD structure to the standard output [default = %s]\n", fPrint? "yes": "no" );
02826 fprintf( pErr, "\t-s : use short PI names when printing DSD structure [default = %s]\n", fShort? "yes": "no" );
02827 fprintf( pErr, "\t-h : print the command usage\n");
02828 return 1;
02829 }
02830
02842 int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv )
02843 {
02844 FILE * pOut, * pErr;
02845 Abc_Ntk_t * pNtk;
02846 Res_Par_t Pars, * pPars = &Pars;
02847 int c;
02848
02849
02850
02851
02852 pNtk = Abc_FrameReadNtk(pAbc);
02853 pOut = Abc_FrameReadOut(pAbc);
02854 pErr = Abc_FrameReadErr(pAbc);
02855
02856
02857 pPars->nWindow = 62;
02858 pPars->nGrowthLevel = 1;
02859 pPars->nCands = 5;
02860 pPars->nSimWords = 4;
02861 pPars->fArea = 0;
02862 pPars->fVerbose = 0;
02863 pPars->fVeryVerbose = 0;
02864 Extra_UtilGetoptReset();
02865 while ( ( c = Extra_UtilGetopt( argc, argv, "WSCLavwh" ) ) != EOF )
02866 {
02867 switch ( c )
02868 {
02869 case 'W':
02870 if ( globalUtilOptind >= argc )
02871 {
02872 fprintf( pErr, "Command line switch \"-W\" should be followed by an integer.\n" );
02873 goto usage;
02874 }
02875 pPars->nWindow = atoi(argv[globalUtilOptind]);
02876 globalUtilOptind++;
02877 if ( pPars->nWindow < 1 || pPars->nWindow > 99 )
02878 goto usage;
02879 break;
02880 case 'S':
02881 if ( globalUtilOptind >= argc )
02882 {
02883 fprintf( pErr, "Command line switch \"-S\" should be followed by an integer.\n" );
02884 goto usage;
02885 }
02886 pPars->nSimWords = atoi(argv[globalUtilOptind]);
02887 globalUtilOptind++;
02888 if ( pPars->nSimWords < 1 || pPars->nSimWords > 256 )
02889 goto usage;
02890 break;
02891 case 'C':
02892 if ( globalUtilOptind >= argc )
02893 {
02894 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
02895 goto usage;
02896 }
02897 pPars->nCands = atoi(argv[globalUtilOptind]);
02898 globalUtilOptind++;
02899 if ( pPars->nCands < 0 || pPars->nCands > ABC_INFINITY )
02900 goto usage;
02901 break;
02902 case 'L':
02903 if ( globalUtilOptind >= argc )
02904 {
02905 fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
02906 goto usage;
02907 }
02908 pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
02909 globalUtilOptind++;
02910 if ( pPars->nGrowthLevel < 0 || pPars->nGrowthLevel > ABC_INFINITY )
02911 goto usage;
02912 break;
02913 case 'a':
02914 pPars->fArea ^= 1;
02915 break;
02916 case 'v':
02917 pPars->fVerbose ^= 1;
02918 break;
02919 case 'w':
02920 pPars->fVeryVerbose ^= 1;
02921 break;
02922 case 'h':
02923 goto usage;
02924 default:
02925 goto usage;
02926 }
02927 }
02928
02929 if ( pNtk == NULL )
02930 {
02931 fprintf( pErr, "Empty network.\n" );
02932 return 1;
02933 }
02934 if ( !Abc_NtkIsLogic(pNtk) )
02935 {
02936 fprintf( pErr, "This command can only be applied to a logic network.\n" );
02937 return 1;
02938 }
02939
02940
02941 if ( !Abc_NtkResynthesize( pNtk, pPars ) )
02942 {
02943 fprintf( pErr, "Resynthesis has failed.\n" );
02944 return 1;
02945 }
02946 return 0;
02947
02948 usage:
02949 fprintf( pErr, "usage: imfs [-W <NM>] [-L <num>] [-C <num>] [-S <num>] [-avwh]\n" );
02950 fprintf( pErr, "\t performs resubstitution-based resynthesis with interpolation\n" );
02951 fprintf( pErr, "\t-W <NM> : fanin/fanout levels (NxM) of the window (00 <= NM <= 99) [default = %d%d]\n", pPars->nWindow/10, pPars->nWindow%10 );
02952 fprintf( pErr, "\t-L <num> : the largest increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
02953 fprintf( pErr, "\t-C <num> : the max number of resub candidates (1 <= n) [default = %d]\n", pPars->nCands );
02954 fprintf( pErr, "\t-S <num> : the number of simulation words (1 <= n <= 256) [default = %d]\n", pPars->nSimWords );
02955 fprintf( pErr, "\t-a : toggle optimization for area only [default = %s]\n", pPars->fArea? "yes": "no" );
02956 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
02957 fprintf( pErr, "\t-w : toggle printout subgraph statistics [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
02958 fprintf( pErr, "\t-h : print the command usage\n");
02959 return 1;
02960 }
02961
02973 int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
02974 {
02975 FILE * pOut, * pErr;
02976 Abc_Ntk_t * pNtk;
02977 Lpk_Par_t Pars, * pPars = &Pars;
02978 int c;
02979
02980 pNtk = Abc_FrameReadNtk(pAbc);
02981 pOut = Abc_FrameReadOut(pAbc);
02982 pErr = Abc_FrameReadErr(pAbc);
02983
02984
02985 memset( pPars, 0, sizeof(Lpk_Par_t) );
02986 pPars->nLutsMax = 4;
02987 pPars->nLutsOver = 3;
02988 pPars->nVarsShared = 0;
02989 pPars->nGrowthLevel = 0;
02990 pPars->fSatur = 1;
02991 pPars->fZeroCost = 0;
02992 pPars->fFirst = 0;
02993 pPars->fOldAlgo = 0;
02994 pPars->fVerbose = 0;
02995 pPars->fVeryVerbose = 0;
02996 Extra_UtilGetoptReset();
02997 while ( ( c = Extra_UtilGetopt( argc, argv, "NQSLszfovwh" ) ) != EOF )
02998 {
02999 switch ( c )
03000 {
03001 case 'N':
03002 if ( globalUtilOptind >= argc )
03003 {
03004 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
03005 goto usage;
03006 }
03007 pPars->nLutsMax = atoi(argv[globalUtilOptind]);
03008 globalUtilOptind++;
03009 if ( pPars->nLutsMax < 2 || pPars->nLutsMax > 8 )
03010 goto usage;
03011 break;
03012 case 'Q':
03013 if ( globalUtilOptind >= argc )
03014 {
03015 fprintf( pErr, "Command line switch \"-Q\" should be followed by an integer.\n" );
03016 goto usage;
03017 }
03018 pPars->nLutsOver = atoi(argv[globalUtilOptind]);
03019 globalUtilOptind++;
03020 if ( pPars->nLutsOver < 0 || pPars->nLutsOver > 8 )
03021 goto usage;
03022 break;
03023 case 'S':
03024 if ( globalUtilOptind >= argc )
03025 {
03026 fprintf( pErr, "Command line switch \"-S\" should be followed by an integer.\n" );
03027 goto usage;
03028 }
03029 pPars->nVarsShared = atoi(argv[globalUtilOptind]);
03030 globalUtilOptind++;
03031 if ( pPars->nVarsShared < 0 || pPars->nVarsShared > 4 )
03032 goto usage;
03033 break;
03034 case 'L':
03035 if ( globalUtilOptind >= argc )
03036 {
03037 fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
03038 goto usage;
03039 }
03040 pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
03041 globalUtilOptind++;
03042 if ( pPars->nGrowthLevel < 0 || pPars->nGrowthLevel > ABC_INFINITY )
03043 goto usage;
03044 break;
03045 case 's':
03046 pPars->fSatur ^= 1;
03047 break;
03048 case 'z':
03049 pPars->fZeroCost ^= 1;
03050 break;
03051 case 'f':
03052 pPars->fFirst ^= 1;
03053 break;
03054 case 'o':
03055 pPars->fOldAlgo ^= 1;
03056 break;
03057 case 'v':
03058 pPars->fVerbose ^= 1;
03059 break;
03060 case 'w':
03061 pPars->fVeryVerbose ^= 1;
03062 break;
03063 case 'h':
03064 goto usage;
03065 default:
03066 goto usage;
03067 }
03068 }
03069
03070 if ( pNtk == NULL )
03071 {
03072 fprintf( pErr, "Empty network.\n" );
03073 return 1;
03074 }
03075 if ( !Abc_NtkIsLogic(pNtk) )
03076 {
03077 fprintf( pErr, "This command can only be applied to a logic network.\n" );
03078 return 1;
03079 }
03080 if ( pPars->nVarsShared < 0 || pPars->nVarsShared > 3 )
03081 {
03082 fprintf( pErr, "The number of shared variables (%d) is not in the range 0 <= S <= 3.\n", pPars->nVarsShared );
03083 return 1;
03084 }
03085
03086
03087 if ( !Lpk_Resynthesize( pNtk, pPars ) )
03088 {
03089 fprintf( pErr, "Resynthesis has failed.\n" );
03090 return 1;
03091 }
03092 return 0;
03093
03094 usage:
03095 fprintf( pErr, "usage: lutpack [-N <num>] [-Q <num>] [-S <num>] [-L <num>] [-szfovwh]\n" );
03096 fprintf( pErr, "\t performs \"rewriting\" for LUT networks\n" );
03097 fprintf( pErr, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax );
03098 fprintf( pErr, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver );
03099 fprintf( pErr, "\t-S <num> : the max number of LUT inputs shared (0 <= num <= 3) [default = %d]\n", pPars->nVarsShared );
03100 fprintf( pErr, "\t-L <num> : max level increase after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
03101 fprintf( pErr, "\t-s : toggle iteration till saturation [default = %s]\n", pPars->fSatur? "yes": "no" );
03102 fprintf( pErr, "\t-z : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" );
03103 fprintf( pErr, "\t-f : toggle using only first node and first cut [default = %s]\n", pPars->fFirst? "yes": "no" );
03104 fprintf( pErr, "\t-o : toggle using old implementation [default = %s]\n", pPars->fOldAlgo? "yes": "no" );
03105 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
03106 fprintf( pErr, "\t-w : toggle detailed printout of decomposed functions [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
03107 fprintf( pErr, "\t-h : print the command usage\n");
03108 return 1;
03109 }
03110
03111
03123 int Abc_CommandRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
03124 {
03125 FILE * pOut, * pErr;
03126 Abc_Ntk_t * pNtk;
03127 int c;
03128 bool fUpdateLevel;
03129 bool fPrecompute;
03130 bool fUseZeros;
03131 bool fVerbose;
03132 bool fVeryVerbose;
03133 bool fPlaceEnable;
03134
03135 extern void Rwr_Precompute();
03136
03137 pNtk = Abc_FrameReadNtk(pAbc);
03138 pOut = Abc_FrameReadOut(pAbc);
03139 pErr = Abc_FrameReadErr(pAbc);
03140
03141
03142 fUpdateLevel = 1;
03143 fPrecompute = 0;
03144 fUseZeros = 0;
03145 fVerbose = 0;
03146 fVeryVerbose = 0;
03147 fPlaceEnable = 0;
03148 Extra_UtilGetoptReset();
03149 while ( ( c = Extra_UtilGetopt( argc, argv, "lxzvwh" ) ) != EOF )
03150 {
03151 switch ( c )
03152 {
03153 case 'l':
03154 fUpdateLevel ^= 1;
03155 break;
03156 case 'x':
03157 fPrecompute ^= 1;
03158 break;
03159 case 'z':
03160 fUseZeros ^= 1;
03161 break;
03162 case 'v':
03163 fVerbose ^= 1;
03164 break;
03165 case 'w':
03166 fVeryVerbose ^= 1;
03167 break;
03168 case 'p':
03169 fPlaceEnable ^= 1;
03170 break;
03171 case 'h':
03172 goto usage;
03173 default:
03174 goto usage;
03175 }
03176 }
03177
03178 if ( fPrecompute )
03179 {
03180 Rwr_Precompute();
03181 return 0;
03182 }
03183
03184 if ( pNtk == NULL )
03185 {
03186 fprintf( pErr, "Empty network.\n" );
03187 return 1;
03188 }
03189 if ( !Abc_NtkIsStrash(pNtk) )
03190 {
03191 fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" );
03192 return 1;
03193 }
03194 if ( Abc_NtkGetChoiceNum(pNtk) )
03195 {
03196 fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
03197 return 1;
03198 }
03199
03200
03201 if ( !Abc_NtkRewrite( pNtk, fUpdateLevel, fUseZeros, fVerbose, fVeryVerbose, fPlaceEnable ) )
03202 {
03203 fprintf( pErr, "Rewriting has failed.\n" );
03204 return 1;
03205 }
03206 return 0;
03207
03208 usage:
03209 fprintf( pErr, "usage: rewrite [-lzvwh]\n" );
03210 fprintf( pErr, "\t performs technology-independent rewriting of the AIG\n" );
03211 fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
03212 fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
03213 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
03214 fprintf( pErr, "\t-w : toggle printout subgraph statistics [default = %s]\n", fVeryVerbose? "yes": "no" );
03215
03216 fprintf( pErr, "\t-h : print the command usage\n");
03217 return 1;
03218 }
03219
03231 int Abc_CommandRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
03232 {
03233 FILE * pOut, * pErr;
03234 Abc_Ntk_t * pNtk;
03235 int c;
03236 int nNodeSizeMax;
03237 int nConeSizeMax;
03238 bool fUpdateLevel;
03239 bool fUseZeros;
03240 bool fUseDcs;
03241 bool fVerbose;
03242 extern int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool fUpdateLevel, bool fUseZeros, bool fUseDcs, bool fVerbose );
03243
03244 pNtk = Abc_FrameReadNtk(pAbc);
03245 pOut = Abc_FrameReadOut(pAbc);
03246 pErr = Abc_FrameReadErr(pAbc);
03247
03248
03249 nNodeSizeMax = 10;
03250 nConeSizeMax = 16;
03251 fUpdateLevel = 1;
03252 fUseZeros = 0;
03253 fUseDcs = 0;
03254 fVerbose = 0;
03255 Extra_UtilGetoptReset();
03256 while ( ( c = Extra_UtilGetopt( argc, argv, "NClzdvh" ) ) != EOF )
03257 {
03258 switch ( c )
03259 {
03260 case 'N':
03261 if ( globalUtilOptind >= argc )
03262 {
03263 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
03264 goto usage;
03265 }
03266 nNodeSizeMax = atoi(argv[globalUtilOptind]);
03267 globalUtilOptind++;
03268 if ( nNodeSizeMax < 0 )
03269 goto usage;
03270 break;
03271 case 'C':
03272 if ( globalUtilOptind >= argc )
03273 {
03274 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
03275 goto usage;
03276 }
03277 nConeSizeMax = atoi(argv[globalUtilOptind]);
03278 globalUtilOptind++;
03279 if ( nConeSizeMax < 0 )
03280 goto usage;
03281 break;
03282 case 'l':
03283 fUpdateLevel ^= 1;
03284 break;
03285 case 'z':
03286 fUseZeros ^= 1;
03287 break;
03288 case 'd':
03289 fUseDcs ^= 1;
03290 break;
03291 case 'v':
03292 fVerbose ^= 1;
03293 break;
03294 case 'h':
03295 goto usage;
03296 default:
03297 goto usage;
03298 }
03299 }
03300
03301 if ( pNtk == NULL )
03302 {
03303 fprintf( pErr, "Empty network.\n" );
03304 return 1;
03305 }
03306 if ( !Abc_NtkIsStrash(pNtk) )
03307 {
03308 fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" );
03309 return 1;
03310 }
03311 if ( Abc_NtkGetChoiceNum(pNtk) )
03312 {
03313 fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
03314 return 1;
03315 }
03316
03317 if ( fUseDcs && nNodeSizeMax >= nConeSizeMax )
03318 {
03319 fprintf( pErr, "For don't-care to work, containing cone should be larger than collapsed node.\n" );
03320 return 1;
03321 }
03322
03323
03324 if ( !Abc_NtkRefactor( pNtk, nNodeSizeMax, nConeSizeMax, fUpdateLevel, fUseZeros, fUseDcs, fVerbose ) )
03325 {
03326 fprintf( pErr, "Refactoring has failed.\n" );
03327 return 1;
03328 }
03329 return 0;
03330
03331 usage:
03332 fprintf( pErr, "usage: refactor [-N num] [-C num] [-lzdvh]\n" );
03333 fprintf( pErr, "\t performs technology-independent refactoring of the AIG\n" );
03334 fprintf( pErr, "\t-N num : the max support of the collapsed node [default = %d]\n", nNodeSizeMax );
03335 fprintf( pErr, "\t-C num : the max support of the containing cone [default = %d]\n", nConeSizeMax );
03336 fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
03337 fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
03338 fprintf( pErr, "\t-d : toggle using don't-cares [default = %s]\n", fUseDcs? "yes": "no" );
03339 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
03340 fprintf( pErr, "\t-h : print the command usage\n");
03341 return 1;
03342 }
03343
03355 int Abc_CommandRestructure( Abc_Frame_t * pAbc, int argc, char ** argv )
03356 {
03357 FILE * pOut, * pErr;
03358 Abc_Ntk_t * pNtk;
03359 int c;
03360 int nCutsMax;
03361 bool fUpdateLevel;
03362 bool fUseZeros;
03363 bool fVerbose;
03364 extern int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutsMax, bool fUpdateLevel, bool fUseZeros, bool fVerbose );
03365
03366 pNtk = Abc_FrameReadNtk(pAbc);
03367 pOut = Abc_FrameReadOut(pAbc);
03368 pErr = Abc_FrameReadErr(pAbc);
03369
03370
03371 nCutsMax = 5;
03372 fUpdateLevel = 0;
03373 fUseZeros = 0;
03374 fVerbose = 0;
03375 Extra_UtilGetoptReset();
03376 while ( ( c = Extra_UtilGetopt( argc, argv, "Klzvh" ) ) != EOF )
03377 {
03378 switch ( c )
03379 {
03380 case 'K':
03381 if ( globalUtilOptind >= argc )
03382 {
03383 fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
03384 goto usage;
03385 }
03386 nCutsMax = atoi(argv[globalUtilOptind]);
03387 globalUtilOptind++;
03388 if ( nCutsMax < 0 )
03389 goto usage;
03390 break;
03391 case 'l':
03392 fUpdateLevel ^= 1;
03393 break;
03394 case 'z':
03395 fUseZeros ^= 1;
03396 break;
03397 case 'v':
03398 fVerbose ^= 1;
03399 break;
03400 case 'h':
03401 goto usage;
03402 default:
03403 goto usage;
03404 }
03405 }
03406
03407 if ( pNtk == NULL )
03408 {
03409 fprintf( pErr, "Empty network.\n" );
03410 return 1;
03411 }
03412 if ( nCutsMax < 4 || nCutsMax > CUT_SIZE_MAX )
03413 {
03414 fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", 4, CUT_SIZE_MAX );
03415 return 1;
03416 }
03417 if ( !Abc_NtkIsStrash(pNtk) )
03418 {
03419 fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" );
03420 return 1;
03421 }
03422 if ( Abc_NtkGetChoiceNum(pNtk) )
03423 {
03424 fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
03425 return 1;
03426 }
03427
03428
03429 if ( !Abc_NtkRestructure( pNtk, nCutsMax, fUpdateLevel, fUseZeros, fVerbose ) )
03430 {
03431 fprintf( pErr, "Refactoring has failed.\n" );
03432 return 1;
03433 }
03434 return 0;
03435
03436 usage:
03437 fprintf( pErr, "usage: restructure [-K num] [-lzvh]\n" );
03438 fprintf( pErr, "\t performs technology-independent restructuring of the AIG\n" );
03439 fprintf( pErr, "\t-K num : the max cut size (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, nCutsMax );
03440 fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
03441 fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
03442 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
03443 fprintf( pErr, "\t-h : print the command usage\n");
03444 return 1;
03445 }
03446
03458 int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
03459 {
03460 FILE * pOut, * pErr;
03461 Abc_Ntk_t * pNtk;
03462 int RS_CUT_MIN = 4;
03463 int RS_CUT_MAX = 16;
03464 int c;
03465 int nCutsMax;
03466 int nNodesMax;
03467 int nLevelsOdc;
03468 bool fUpdateLevel;
03469 bool fUseZeros;
03470 bool fVerbose;
03471 bool fVeryVerbose;
03472 extern int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutsMax, int nNodesMax, int nLevelsOdc, bool fUpdateLevel, bool fVerbose, bool fVeryVerbose );
03473
03474 pNtk = Abc_FrameReadNtk(pAbc);
03475 pOut = Abc_FrameReadOut(pAbc);
03476 pErr = Abc_FrameReadErr(pAbc);
03477
03478
03479 nCutsMax = 8;
03480 nNodesMax = 1;
03481 nLevelsOdc = 0;
03482 fUpdateLevel = 1;
03483 fUseZeros = 0;
03484 fVerbose = 0;
03485 fVeryVerbose = 0;
03486 Extra_UtilGetoptReset();
03487 while ( ( c = Extra_UtilGetopt( argc, argv, "KNFlzvwh" ) ) != EOF )
03488 {
03489 switch ( c )
03490 {
03491 case 'K':
03492 if ( globalUtilOptind >= argc )
03493 {
03494 fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
03495 goto usage;
03496 }
03497 nCutsMax = atoi(argv[globalUtilOptind]);
03498 globalUtilOptind++;
03499 if ( nCutsMax < 0 )
03500 goto usage;
03501 break;
03502 case 'N':
03503 if ( globalUtilOptind >= argc )
03504 {
03505 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
03506 goto usage;
03507 }
03508 nNodesMax = atoi(argv[globalUtilOptind]);
03509 globalUtilOptind++;
03510 if ( nNodesMax < 0 )
03511 goto usage;
03512 break;
03513 case 'F':
03514 if ( globalUtilOptind >= argc )
03515 {
03516 fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
03517 goto usage;
03518 }
03519 nLevelsOdc = atoi(argv[globalUtilOptind]);
03520 globalUtilOptind++;
03521 if ( nLevelsOdc < 0 )
03522 goto usage;
03523 break;
03524 case 'l':
03525 fUpdateLevel ^= 1;
03526 break;
03527 case 'z':
03528 fUseZeros ^= 1;
03529 break;
03530 case 'v':
03531 fVerbose ^= 1;
03532 break;
03533 case 'w':
03534 fVeryVerbose ^= 1;
03535 break;
03536 case 'h':
03537 goto usage;
03538 default:
03539 goto usage;
03540 }
03541 }
03542
03543 if ( pNtk == NULL )
03544 {
03545 fprintf( pErr, "Empty network.\n" );
03546 return 1;
03547 }
03548 if ( nCutsMax < RS_CUT_MIN || nCutsMax > RS_CUT_MAX )
03549 {
03550 fprintf( pErr, "Can only compute cuts for %d <= K <= %d.\n", RS_CUT_MIN, RS_CUT_MAX );
03551 return 1;
03552 }
03553 if ( nNodesMax < 0 || nNodesMax > 3 )
03554 {
03555 fprintf( pErr, "Can only resubstitute at most 3 nodes.\n" );
03556 return 1;
03557 }
03558 if ( !Abc_NtkIsStrash(pNtk) )
03559 {
03560 fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" );
03561 return 1;
03562 }
03563 if ( Abc_NtkGetChoiceNum(pNtk) )
03564 {
03565 fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
03566 return 1;
03567 }
03568
03569
03570 if ( !Abc_NtkResubstitute( pNtk, nCutsMax, nNodesMax, nLevelsOdc, fUpdateLevel, fVerbose, fVeryVerbose ) )
03571 {
03572 fprintf( pErr, "Refactoring has failed.\n" );
03573 return 1;
03574 }
03575 return 0;
03576
03577 usage:
03578 fprintf( pErr, "usage: resub [-K num] [-N num] [-F num] [-lzvwh]\n" );
03579 fprintf( pErr, "\t performs technology-independent restructuring of the AIG\n" );
03580 fprintf( pErr, "\t-K num : the max cut size (%d <= num <= %d) [default = %d]\n", RS_CUT_MIN, RS_CUT_MAX, nCutsMax );
03581 fprintf( pErr, "\t-N num : the max number of nodes to add (0 <= num <= 3) [default = %d]\n", nNodesMax );
03582 fprintf( pErr, "\t-F num : the number of fanout levels for ODC computation [default = %d]\n", nLevelsOdc );
03583 fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
03584 fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
03585 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
03586 fprintf( pErr, "\t-w : toggle verbose printout of ODC computation [default = %s]\n", fVeryVerbose? "yes": "no" );
03587 fprintf( pErr, "\t-h : print the command usage\n");
03588 return 1;
03589 }
03590
03602 int Abc_CommandRr( Abc_Frame_t * pAbc, int argc, char ** argv )
03603 {
03604 FILE * pOut, * pErr;
03605 Abc_Ntk_t * pNtk;
03606 int c, Window;
03607 int nFaninLevels;
03608 int nFanoutLevels;
03609 int fUseFanouts;
03610 int fVerbose;
03611 extern int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFanouts, int fVerbose );
03612
03613 pNtk = Abc_FrameReadNtk(pAbc);
03614 pOut = Abc_FrameReadOut(pAbc);
03615 pErr = Abc_FrameReadErr(pAbc);
03616
03617
03618 nFaninLevels = 3;
03619 nFanoutLevels = 3;
03620 fUseFanouts = 0;
03621 fVerbose = 0;
03622 Extra_UtilGetoptReset();
03623 while ( ( c = Extra_UtilGetopt( argc, argv, "Wfvh" ) ) != EOF )
03624 {
03625 switch ( c )
03626 {
03627 case 'W':
03628 if ( globalUtilOptind >= argc )
03629 {
03630 fprintf( pErr, "Command line switch \"-W\" should be followed by an integer.\n" );
03631 goto usage;
03632 }
03633 Window = atoi(argv[globalUtilOptind]);
03634 globalUtilOptind++;
03635 if ( Window < 0 )
03636 goto usage;
03637 nFaninLevels = Window / 10;
03638 nFanoutLevels = Window % 10;
03639 break;
03640 case 'f':
03641 fUseFanouts ^= 1;
03642 break;
03643 case 'v':
03644 fVerbose ^= 1;
03645 break;
03646 case 'h':
03647 goto usage;
03648 default:
03649 goto usage;
03650 }
03651 }
03652
03653 if ( pNtk == NULL )
03654 {
03655 fprintf( pErr, "Empty network.\n" );
03656 return 1;
03657 }
03658 if ( !Abc_NtkIsStrash(pNtk) )
03659 {
03660 fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" );
03661 return 1;
03662 }
03663 if ( Abc_NtkGetChoiceNum(pNtk) )
03664 {
03665 fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
03666 return 1;
03667 }
03668
03669
03670 if ( !Abc_NtkRR( pNtk, nFaninLevels, nFanoutLevels, fUseFanouts, fVerbose ) )
03671 {
03672 fprintf( pErr, "Redundancy removal has failed.\n" );
03673 return 1;
03674 }
03675 return 0;
03676
03677 usage:
03678 fprintf( pErr, "usage: rr [-W NM] [-fvh]\n" );
03679 fprintf( pErr, "\t removes combinational redundancies in the current network\n" );
03680 fprintf( pErr, "\t-W NM : window size: TFI (N) and TFO (M) logic levels [default = %d%d]\n", nFaninLevels, nFanoutLevels );
03681 fprintf( pErr, "\t-f : toggle RR w.r.t. fanouts [default = %s]\n", fUseFanouts? "yes": "no" );
03682 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
03683 fprintf( pErr, "\t-h : print the command usage\n");
03684 return 1;
03685 }
03686
03698 int Abc_CommandCascade( Abc_Frame_t * pAbc, int argc, char ** argv )
03699 {
03700 FILE * pOut, * pErr;
03701 Abc_Ntk_t * pNtk, * pNtkRes;
03702 int c, nLutSize;
03703 int fCheck;
03704 int fVerbose;
03705 extern Abc_Ntk_t * Abc_NtkCascade( Abc_Ntk_t * pNtk, int nLutSize, int fCheck, int fVerbose );
03706
03707 pNtk = Abc_FrameReadNtk(pAbc);
03708 pOut = Abc_FrameReadOut(pAbc);
03709 pErr = Abc_FrameReadErr(pAbc);
03710
03711
03712 nLutSize = 12;
03713 fCheck = 0;
03714 fVerbose = 0;
03715 Extra_UtilGetoptReset();
03716 while ( ( c = Extra_UtilGetopt( argc, argv, "Kcvh" ) ) != EOF )
03717 {
03718 switch ( c )
03719 {
03720 case 'K':
03721 if ( globalUtilOptind >= argc )
03722 {
03723 fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
03724 goto usage;
03725 }
03726 nLutSize = atoi(argv[globalUtilOptind]);
03727 globalUtilOptind++;
03728 if ( nLutSize < 0 )
03729 goto usage;
03730 break;
03731 case 'c':
03732 fCheck ^= 1;
03733 break;
03734 case 'v':
03735 fVerbose ^= 1;
03736 break;
03737 case 'h':
03738 goto usage;
03739 default:
03740 goto usage;
03741 }
03742 }
03743
03744 if ( pNtk == NULL )
03745 {
03746 fprintf( pErr, "Empty network.\n" );
03747 return 1;
03748 }
03749
03750 if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
03751 {
03752 fprintf( pErr, "Can only collapse a logic network or an AIG.\n" );
03753 return 1;
03754 }
03755
03756
03757 if ( Abc_NtkIsStrash(pNtk) )
03758 pNtkRes = Abc_NtkCascade( pNtk, nLutSize, fCheck, fVerbose );
03759 else
03760 {
03761 pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
03762 pNtkRes = Abc_NtkCascade( pNtk, nLutSize, fCheck, fVerbose );
03763 Abc_NtkDelete( pNtk );
03764 }
03765 if ( pNtkRes == NULL )
03766 {
03767 fprintf( pErr, "Cascade synthesis has failed.\n" );
03768 return 1;
03769 }
03770
03771 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
03772 return 0;
03773
03774 usage:
03775 fprintf( pErr, "usage: cascade [-K <num>] [-cvh]\n" );
03776 fprintf( pErr, "\t performs LUT cascade synthesis for the current network\n" );
03777 fprintf( pErr, "\t-K num : the number of LUT inputs [default = %d]\n", nLutSize );
03778 fprintf( pErr, "\t-c : check equivalence after synthesis [default = %s]\n", fCheck? "yes": "no" );
03779 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
03780 fprintf( pErr, "\t-h : print the command usage\n");
03781 fprintf( pErr, "\t \n");
03782 fprintf( pErr, " A lookup-table cascade is a programmable architecture developed by\n");
03783 fprintf( pErr, " Professor Tsutomu Sasao (sasao@cse.kyutech.ac.jp) at Kyushu Institute\n");
03784 fprintf( pErr, " of Technology. This work received Takeda Techno-Entrepreneurship Award:\n");
03785 fprintf( pErr, " http://www.lsi-cad.com/sasao/photo/takeda.html\n");
03786 fprintf( pErr, "\t \n");
03787 return 1;
03788 }
03789
03790
03802 int Abc_CommandLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
03803 {
03804 FILE * pOut, * pErr;
03805 Abc_Ntk_t * pNtk, * pNtkRes;
03806 int c;
03807
03808 pNtk = Abc_FrameReadNtk(pAbc);
03809 pOut = Abc_FrameReadOut(pAbc);
03810 pErr = Abc_FrameReadErr(pAbc);
03811
03812
03813 Extra_UtilGetoptReset();
03814 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
03815 {
03816 switch ( c )
03817 {
03818 case 'h':
03819 goto usage;
03820 default:
03821 goto usage;
03822 }
03823 }
03824
03825 if ( pNtk == NULL )
03826 {
03827 fprintf( pErr, "Empty network.\n" );
03828 return 1;
03829 }
03830
03831 if ( !Abc_NtkIsStrash( pNtk ) )
03832 {
03833 fprintf( pErr, "This command is only applicable to strashed networks.\n" );
03834 return 1;
03835 }
03836
03837
03838 pNtkRes = Abc_NtkToLogic( pNtk );
03839 if ( pNtkRes == NULL )
03840 {
03841 fprintf( pErr, "Converting to a logic network has failed.\n" );
03842 return 1;
03843 }
03844
03845 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
03846 return 0;
03847
03848 usage:
03849 fprintf( pErr, "usage: logic [-h]\n" );
03850 fprintf( pErr, "\t transforms an AIG into a logic network with SOPs\n" );
03851 fprintf( pErr, "\t-h : print the command usage\n");
03852 return 1;
03853 }
03854
03866 int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv )
03867 {
03868 FILE * pOut, * pErr;
03869 Abc_Ntk_t * pNtk, * pNtkRes;
03870 int c;
03871
03872 pNtk = Abc_FrameReadNtk(pAbc);
03873 pOut = Abc_FrameReadOut(pAbc);
03874 pErr = Abc_FrameReadErr(pAbc);
03875
03876
03877 Extra_UtilGetoptReset();
03878 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
03879 {
03880 switch ( c )
03881 {
03882 case 'h':
03883 goto usage;
03884 default:
03885 goto usage;
03886 }
03887 }
03888
03889 if ( pNtk == NULL )
03890 {
03891 fprintf( pErr, "Empty network.\n" );
03892 return 1;
03893 }
03894 if ( Abc_NtkIsComb(pNtk) )
03895 {
03896 fprintf( pErr, "The network is already combinational.\n" );
03897 return 0;
03898 }
03899
03900
03901 pNtkRes = Abc_NtkDup( pNtk );
03902 Abc_NtkMakeComb( pNtkRes );
03903
03904 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
03905 return 0;
03906
03907 usage:
03908 fprintf( pErr, "usage: comb [-h]\n" );
03909 fprintf( pErr, "\t makes the current network combinational by replacing latches by PI/PO pairs\n" );
03910 fprintf( pErr, "\t-h : print the command usage\n");
03911 return 1;
03912 }
03913
03925 int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
03926 {
03927 char Buffer[32];
03928 FILE * pOut, * pErr;
03929 Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes;
03930 int fDelete1, fDelete2;
03931 char ** pArgvNew;
03932 int nArgcNew;
03933 int c;
03934 int fCheck;
03935 int fComb;
03936 int nPartSize;
03937
03938 pNtk = Abc_FrameReadNtk(pAbc);
03939 pOut = Abc_FrameReadOut(pAbc);
03940 pErr = Abc_FrameReadErr(pAbc);
03941
03942
03943 fComb = 1;
03944 fCheck = 1;
03945 nPartSize = 0;
03946 Extra_UtilGetoptReset();
03947 while ( ( c = Extra_UtilGetopt( argc, argv, "Pch" ) ) != EOF )
03948 {
03949 switch ( c )
03950 {
03951 case 'P':
03952 if ( globalUtilOptind >= argc )
03953 {
03954 fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
03955 goto usage;
03956 }
03957 nPartSize = atoi(argv[globalUtilOptind]);
03958 globalUtilOptind++;
03959 if ( nPartSize < 0 )
03960 goto usage;
03961 break;
03962 case 'c':
03963 fComb ^= 1;
03964 break;
03965 default:
03966 goto usage;
03967 }
03968 }
03969
03970 pArgvNew = argv + globalUtilOptind;
03971 nArgcNew = argc - globalUtilOptind;
03972 if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
03973 return 1;
03974
03975
03976 pNtkRes = Abc_NtkMiter( pNtk1, pNtk2, fComb, nPartSize );
03977 if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
03978 if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
03979
03980
03981 if ( pNtkRes == NULL )
03982 {
03983 fprintf( pErr, "Miter computation has failed.\n" );
03984 return 1;
03985 }
03986
03987 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
03988 return 0;
03989
03990 usage:
03991 if ( nPartSize == 0 )
03992 strcpy( Buffer, "unused" );
03993 else
03994 sprintf( Buffer, "%d", nPartSize );
03995 fprintf( pErr, "usage: miter [-P num] [-ch] <file1> <file2>\n" );
03996 fprintf( pErr, "\t computes the miter of the two circuits\n" );
03997 fprintf( pErr, "\t-P num : output partition size [default = %s]\n", Buffer );
03998 fprintf( pErr, "\t-c : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
03999 fprintf( pErr, "\t-h : print the command usage\n");
04000 fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
04001 fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
04002 fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
04003 fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
04004 return 1;
04005 }
04006
04018 int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
04019 {
04020 FILE * pOut, * pErr;
04021 Abc_Ntk_t * pNtk;
04022 int fComb;
04023 int c;
04024 extern int Abc_NtkDemiter( Abc_Ntk_t * pNtk );
04025
04026 pNtk = Abc_FrameReadNtk(pAbc);
04027 pOut = Abc_FrameReadOut(pAbc);
04028 pErr = Abc_FrameReadErr(pAbc);
04029
04030
04031 Extra_UtilGetoptReset();
04032 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
04033 {
04034 switch ( c )
04035 {
04036 case 'c':
04037 fComb ^= 1;
04038 break;
04039 default:
04040 goto usage;
04041 }
04042 }
04043
04044 if ( !Abc_NtkIsStrash(pNtk) )
04045 {
04046 fprintf( pErr, "The network is not strashed.\n" );
04047 return 1;
04048 }
04049
04050 if ( Abc_NtkPoNum(pNtk) != 1 )
04051 {
04052 fprintf( pErr, "The network is not a miter.\n" );
04053 return 1;
04054 }
04055
04056 if ( !Abc_NodeIsExorType(Abc_ObjFanin0(Abc_NtkPo(pNtk,0))) )
04057 {
04058 fprintf( pErr, "The miter's PO is not an EXOR.\n" );
04059 return 1;
04060 }
04061
04062
04063 if ( !Abc_NtkDemiter( pNtk ) )
04064 {
04065 fprintf( pErr, "Demitering has failed.\n" );
04066 return 1;
04067 }
04068
04069
04070 return 0;
04071
04072 usage:
04073 fprintf( pErr, "usage: demiter [-h]\n" );
04074 fprintf( pErr, "\t removes topmost EXOR from the miter to create two POs\n" );
04075
04076 fprintf( pErr, "\t-h : print the command usage\n");
04077 return 1;
04078 }
04079
04091 int Abc_CommandOrPos( Abc_Frame_t * pAbc, int argc, char ** argv )
04092 {
04093 FILE * pOut, * pErr;
04094 Abc_Ntk_t * pNtk;
04095 int fComb;
04096 int c;
04097 extern int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd );
04098
04099 pNtk = Abc_FrameReadNtk(pAbc);
04100 pOut = Abc_FrameReadOut(pAbc);
04101 pErr = Abc_FrameReadErr(pAbc);
04102
04103
04104 Extra_UtilGetoptReset();
04105 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
04106 {
04107 switch ( c )
04108 {
04109 case 'c':
04110 fComb ^= 1;
04111 break;
04112 default:
04113 goto usage;
04114 }
04115 }
04116
04117 if ( !Abc_NtkIsStrash(pNtk) )
04118 {
04119 fprintf( pErr, "The network is not strashed.\n" );
04120 return 1;
04121 }
04122
04123
04124
04125
04126
04127
04128
04129
04130
04131
04132
04133
04134
04135
04136
04137 if ( !Abc_NtkCombinePos( pNtk, 0 ) )
04138 {
04139 fprintf( pErr, "ORing the POs has failed.\n" );
04140 return 1;
04141 }
04142
04143
04144 return 0;
04145
04146 usage:
04147 fprintf( pErr, "usage: orpos [-h]\n" );
04148 fprintf( pErr, "\t creates single-output miter by ORing the POs of the current network\n" );
04149
04150 fprintf( pErr, "\t-h : print the command usage\n");
04151 return 1;
04152 }
04153
04165 int Abc_CommandAndPos( Abc_Frame_t * pAbc, int argc, char ** argv )
04166 {
04167 FILE * pOut, * pErr;
04168 Abc_Ntk_t * pNtk;
04169 int fComb;
04170 int c;
04171 extern int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd );
04172
04173 pNtk = Abc_FrameReadNtk(pAbc);
04174 pOut = Abc_FrameReadOut(pAbc);
04175 pErr = Abc_FrameReadErr(pAbc);
04176
04177
04178 Extra_UtilGetoptReset();
04179 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
04180 {
04181 switch ( c )
04182 {
04183 case 'c':
04184 fComb ^= 1;
04185 break;
04186 default:
04187 goto usage;
04188 }
04189 }
04190
04191 if ( !Abc_NtkIsStrash(pNtk) )
04192 {
04193 fprintf( pErr, "The network is not strashed.\n" );
04194 return 1;
04195 }
04196
04197 if ( Abc_NtkPoNum(pNtk) == 1 )
04198 {
04199 fprintf( pErr, "The network already has one PO.\n" );
04200 return 1;
04201 }
04202
04203 if ( Abc_NtkLatchNum(pNtk) )
04204 {
04205 fprintf( pErr, "The miter has latches. ORing is not performed.\n" );
04206 return 1;
04207 }
04208
04209
04210 if ( !Abc_NtkCombinePos( pNtk, 1 ) )
04211 {
04212 fprintf( pErr, "ANDing the POs has failed.\n" );
04213 return 1;
04214 }
04215
04216
04217 return 0;
04218
04219 usage:
04220 fprintf( pErr, "usage: andpos [-h]\n" );
04221 fprintf( pErr, "\t creates single-output miter by ANDing the POs of the current network\n" );
04222
04223 fprintf( pErr, "\t-h : print the command usage\n");
04224 return 1;
04225 }
04226
04238 int Abc_CommandAppend( Abc_Frame_t * pAbc, int argc, char ** argv )
04239 {
04240 FILE * pOut, * pErr;
04241 Abc_Ntk_t * pNtk, * pNtk2;
04242 char * FileName;
04243 int fComb;
04244 int c;
04245
04246 pNtk = Abc_FrameReadNtk(pAbc);
04247 pOut = Abc_FrameReadOut(pAbc);
04248 pErr = Abc_FrameReadErr(pAbc);
04249
04250
04251 Extra_UtilGetoptReset();
04252 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
04253 {
04254 switch ( c )
04255 {
04256 case 'c':
04257 fComb ^= 1;
04258 break;
04259 default:
04260 goto usage;
04261 }
04262 }
04263
04264
04265 if ( argc != globalUtilOptind + 1 )
04266 {
04267 fprintf( pErr, "The network to append is not given.\n" );
04268 return 1;
04269 }
04270
04271 if ( !Abc_NtkIsStrash(pNtk) )
04272 {
04273 fprintf( pErr, "The base network should be strashed for the appending to work.\n" );
04274 return 1;
04275 }
04276
04277
04278 FileName = argv[globalUtilOptind];
04279 pNtk2 = Io_Read( FileName, Io_ReadFileType(FileName), 1 );
04280 if ( pNtk2 == NULL )
04281 return 1;
04282
04283
04284 if ( Abc_NtkLatchNum(pNtk2) )
04285 {
04286 fprintf( pErr, "The second network has latches. Appending does not work for such networks.\n" );
04287 return 1;
04288 }
04289
04290
04291 if ( !Abc_NtkAppend( pNtk, pNtk2, 1 ) )
04292 {
04293 Abc_NtkDelete( pNtk2 );
04294 fprintf( pErr, "Appending the networks failed.\n" );
04295 return 1;
04296 }
04297 Abc_NtkDelete( pNtk2 );
04298
04299 Abc_AigCleanup( pNtk->pManFunc );
04300
04301
04302 return 0;
04303
04304 usage:
04305 fprintf( pErr, "usage: append [-h] <file>\n" );
04306 fprintf( pErr, "\t appends a combinational network on top of the current network\n" );
04307
04308 fprintf( pErr, "\t-h : print the command usage\n");
04309 fprintf( pErr, "\t<file> : file name with the second network\n");
04310 return 1;
04311 }
04312
04324 int Abc_CommandFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
04325 {
04326 FILE * pOut, * pErr;
04327 Abc_Ntk_t * pNtk, * pNtkTemp, * pNtkRes;
04328 int fInitial;
04329 int nFrames;
04330 int c;
04331
04332 pNtk = Abc_FrameReadNtk(pAbc);
04333 pOut = Abc_FrameReadOut(pAbc);
04334 pErr = Abc_FrameReadErr(pAbc);
04335
04336
04337 fInitial = 0;
04338 nFrames = 5;
04339 Extra_UtilGetoptReset();
04340 while ( ( c = Extra_UtilGetopt( argc, argv, "Fih" ) ) != EOF )
04341 {
04342 switch ( c )
04343 {
04344 case 'F':
04345 if ( globalUtilOptind >= argc )
04346 {
04347 fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
04348 goto usage;
04349 }
04350 nFrames = atoi(argv[globalUtilOptind]);
04351 globalUtilOptind++;
04352 if ( nFrames <= 0 )
04353 goto usage;
04354 break;
04355 case 'i':
04356 fInitial ^= 1;
04357 break;
04358 case 'h':
04359 goto usage;
04360 default:
04361 goto usage;
04362 }
04363 }
04364
04365 if ( pNtk == NULL )
04366 {
04367 fprintf( pErr, "Empty network.\n" );
04368 return 1;
04369 }
04370
04371
04372 if ( !Abc_NtkIsStrash(pNtk) )
04373 {
04374 pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
04375 pNtkRes = Abc_NtkFrames( pNtkTemp, nFrames, fInitial );
04376 Abc_NtkDelete( pNtkTemp );
04377 }
04378 else
04379 pNtkRes = Abc_NtkFrames( pNtk, nFrames, fInitial );
04380 if ( pNtkRes == NULL )
04381 {
04382 fprintf( pErr, "Unrolling the network has failed.\n" );
04383 return 1;
04384 }
04385
04386 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
04387 return 0;
04388
04389 usage:
04390 fprintf( pErr, "usage: frames [-F num] [-ih]\n" );
04391 fprintf( pErr, "\t unrolls the network for a number of time frames\n" );
04392 fprintf( pErr, "\t-F num : the number of frames to unroll [default = %d]\n", nFrames );
04393 fprintf( pErr, "\t-i : toggles initializing the first frame [default = %s]\n", fInitial? "yes": "no" );
04394 fprintf( pErr, "\t-h : print the command usage\n");
04395 return 1;
04396 }
04397
04398
04410 int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv )
04411 {
04412 FILE * pOut, * pErr;
04413 Abc_Ntk_t * pNtk;
04414 int fDirect;
04415 int c;
04416
04417 pNtk = Abc_FrameReadNtk(pAbc);
04418 pOut = Abc_FrameReadOut(pAbc);
04419 pErr = Abc_FrameReadErr(pAbc);
04420
04421
04422 fDirect = 0;
04423 Extra_UtilGetoptReset();
04424 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
04425 {
04426 switch ( c )
04427 {
04428 case 'd':
04429 fDirect ^= 1;
04430 break;
04431 case 'h':
04432 goto usage;
04433 default:
04434 goto usage;
04435 }
04436 }
04437 if ( pNtk == NULL )
04438 {
04439 fprintf( pErr, "Empty network.\n" );
04440 return 1;
04441 }
04442 if ( !Abc_NtkIsLogic(pNtk) )
04443 {
04444 fprintf( pErr, "Converting to SOP is possible only for logic networks.\n" );
04445 return 1;
04446 }
04447 if ( !Abc_NtkToSop(pNtk, fDirect) )
04448 {
04449 fprintf( pErr, "Converting to SOP has failed.\n" );
04450 return 1;
04451 }
04452 return 0;
04453
04454 usage:
04455 fprintf( pErr, "usage: sop [-dh]\n" );
04456 fprintf( pErr, "\t converts node functions to SOP\n" );
04457 fprintf( pErr, "\t-d : toggles using both phases or only positive [default = %s]\n", fDirect? "direct": "both" );
04458 fprintf( pErr, "\t-h : print the command usage\n");
04459 return 1;
04460 }
04461
04473 int Abc_CommandBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
04474 {
04475 FILE * pOut, * pErr;
04476 Abc_Ntk_t * pNtk;
04477 int c;
04478
04479 pNtk = Abc_FrameReadNtk(pAbc);
04480 pOut = Abc_FrameReadOut(pAbc);
04481 pErr = Abc_FrameReadErr(pAbc);
04482
04483
04484 Extra_UtilGetoptReset();
04485 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
04486 {
04487 switch ( c )
04488 {
04489 case 'h':
04490 goto usage;
04491 default:
04492 goto usage;
04493 }
04494 }
04495 if ( pNtk == NULL )
04496 {
04497 fprintf( pErr, "Empty network.\n" );
04498 return 1;
04499 }
04500 if ( !Abc_NtkIsLogic(pNtk) )
04501 {
04502 fprintf( pErr, "Converting to BDD is possible only for logic networks.\n" );
04503 return 1;
04504 }
04505 if ( Abc_NtkIsBddLogic(pNtk) )
04506 {
04507 fprintf( pOut, "The logic network is already in the BDD form.\n" );
04508 return 0;
04509 }
04510 if ( !Abc_NtkToBdd(pNtk) )
04511 {
04512 fprintf( pErr, "Converting to BDD has failed.\n" );
04513 return 1;
04514 }
04515 return 0;
04516
04517 usage:
04518 fprintf( pErr, "usage: bdd [-h]\n" );
04519 fprintf( pErr, "\t converts node functions to BDD\n" );
04520 fprintf( pErr, "\t-h : print the command usage\n");
04521 return 1;
04522 }
04523
04535 int Abc_CommandAig( Abc_Frame_t * pAbc, int argc, char ** argv )
04536 {
04537 FILE * pOut, * pErr;
04538 Abc_Ntk_t * pNtk;
04539 int c;
04540
04541 pNtk = Abc_FrameReadNtk(pAbc);
04542 pOut = Abc_FrameReadOut(pAbc);
04543 pErr = Abc_FrameReadErr(pAbc);
04544
04545
04546 Extra_UtilGetoptReset();
04547 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
04548 {
04549 switch ( c )
04550 {
04551 case 'h':
04552 goto usage;
04553 default:
04554 goto usage;
04555 }
04556 }
04557 if ( pNtk == NULL )
04558 {
04559 fprintf( pErr, "Empty network.\n" );
04560 return 1;
04561 }
04562 if ( !Abc_NtkIsLogic(pNtk) )
04563 {
04564 fprintf( pErr, "Converting to AIG is possible only for logic networks.\n" );
04565 return 1;
04566 }
04567 if ( Abc_NtkIsAigLogic(pNtk) )
04568 {
04569 fprintf( pOut, "The logic network is already in the AIG form.\n" );
04570 return 0;
04571 }
04572 if ( !Abc_NtkToAig(pNtk) )
04573 {
04574 fprintf( pErr, "Converting to AIG has failed.\n" );
04575 return 1;
04576 }
04577 return 0;
04578
04579 usage:
04580 fprintf( pErr, "usage: aig [-h]\n" );
04581 fprintf( pErr, "\t converts node functions to AIG\n" );
04582 fprintf( pErr, "\t-h : print the command usage\n");
04583 return 1;
04584 }
04585
04597 int Abc_CommandReorder( Abc_Frame_t * pAbc, int argc, char ** argv )
04598 {
04599 FILE * pOut, * pErr;
04600 Abc_Ntk_t * pNtk;
04601 int c;
04602 int fVerbose;
04603 extern void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose );
04604
04605 pNtk = Abc_FrameReadNtk(pAbc);
04606 pOut = Abc_FrameReadOut(pAbc);
04607 pErr = Abc_FrameReadErr(pAbc);
04608
04609
04610 fVerbose = 0;
04611 Extra_UtilGetoptReset();
04612 while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
04613 {
04614 switch ( c )
04615 {
04616 case 'v':
04617 fVerbose ^= 1;
04618 break;
04619 case 'h':
04620 goto usage;
04621 default:
04622 goto usage;
04623 }
04624 }
04625
04626 if ( pNtk == NULL )
04627 {
04628 fprintf( pErr, "Empty network.\n" );
04629 return 1;
04630 }
04631
04632
04633 if ( !Abc_NtkIsBddLogic(pNtk) )
04634 {
04635 fprintf( pErr, "Variable reordering is possible when node functions are BDDs (run \"bdd\").\n" );
04636 return 1;
04637 }
04638 Abc_NtkBddReorder( pNtk, fVerbose );
04639 return 0;
04640
04641 usage:
04642 fprintf( pErr, "usage: reorder [-vh]\n" );
04643 fprintf( pErr, "\t reorders local functions of the nodes using sifting\n" );
04644 fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
04645 fprintf( pErr, "\t-h : print the command usage\n");
04646 return 1;
04647 }
04648
04660 int Abc_CommandOrder( Abc_Frame_t * pAbc, int argc, char ** argv )
04661 {
04662 FILE * pOut, * pErr, * pFile;
04663 Abc_Ntk_t * pNtk;
04664 char * pFileName;
04665 int c;
04666 int fReverse;
04667 int fVerbose;
04668 extern void Abc_NtkImplementCiOrder( Abc_Ntk_t * pNtk, char * pFileName, int fReverse, int fVerbose );
04669 extern void Abc_NtkFindCiOrder( Abc_Ntk_t * pNtk, int fReverse, int fVerbose );
04670
04671 pNtk = Abc_FrameReadNtk(pAbc);
04672 pOut = Abc_FrameReadOut(pAbc);
04673 pErr = Abc_FrameReadErr(pAbc);
04674
04675
04676 fReverse = 0;
04677 fVerbose = 0;
04678 Extra_UtilGetoptReset();
04679 while ( ( c = Extra_UtilGetopt( argc, argv, "rvh" ) ) != EOF )
04680 {
04681 switch ( c )
04682 {
04683 case 'r':
04684 fReverse ^= 1;
04685 break;
04686 case 'v':
04687 fVerbose ^= 1;
04688 break;
04689 case 'h':
04690 goto usage;
04691 default:
04692 goto usage;
04693 }
04694 }
04695
04696 if ( pNtk == NULL )
04697 {
04698 fprintf( pErr, "Empty network.\n" );
04699 return 1;
04700 }
04701
04702
04703
04704
04705
04706
04707
04708 pFileName = NULL;
04709 if ( argc == globalUtilOptind + 1 )
04710 {
04711 pFileName = argv[globalUtilOptind];
04712 pFile = fopen( pFileName, "r" );
04713 if ( pFile == NULL )
04714 {
04715 fprintf( pErr, "Cannot open file \"%s\" with the BDD variable order.\n", pFileName );
04716 return 1;
04717 }
04718 fclose( pFile );
04719 }
04720 if ( pFileName )
04721 Abc_NtkImplementCiOrder( pNtk, pFileName, fReverse, fVerbose );
04722 else
04723 Abc_NtkFindCiOrder( pNtk, fReverse, fVerbose );
04724 return 0;
04725
04726 usage:
04727 fprintf( pErr, "usage: order [-rvh] <file>\n" );
04728 fprintf( pErr, "\t computes a good static CI variable order\n" );
04729 fprintf( pErr, "\t-r : toggle reverse ordering [default = %s]\n", fReverse? "yes": "no" );
04730 fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
04731 fprintf( pErr, "\t-h : print the command usage\n");
04732 fprintf( pErr, "\t<file> : (optional) file with the given variable order\n" );
04733 return 1;
04734 }
04735
04747 int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv )
04748 {
04749 FILE * pOut, * pErr;
04750 Abc_Ntk_t * pNtk, * pNtkRes;
04751 int c;
04752
04753 pNtk = Abc_FrameReadNtk(pAbc);
04754 pOut = Abc_FrameReadOut(pAbc);
04755 pErr = Abc_FrameReadErr(pAbc);
04756
04757
04758 Extra_UtilGetoptReset();
04759 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
04760 {
04761 switch ( c )
04762 {
04763 case 'h':
04764 goto usage;
04765 default:
04766 goto usage;
04767 }
04768 }
04769
04770 if ( pNtk == NULL )
04771 {
04772 fprintf( pErr, "Empty network.\n" );
04773 return 1;
04774 }
04775
04776 if ( !Abc_NtkIsBddLogic(pNtk) )
04777 {
04778 fprintf( pErr, "Only a BDD logic network can be converted to MUXes.\n" );
04779 return 1;
04780 }
04781
04782
04783 pNtkRes = Abc_NtkBddToMuxes( pNtk );
04784 if ( pNtkRes == NULL )
04785 {
04786 fprintf( pErr, "Converting to MUXes has failed.\n" );
04787 return 1;
04788 }
04789
04790 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
04791 return 0;
04792
04793 usage:
04794 fprintf( pErr, "usage: muxes [-h]\n" );
04795 fprintf( pErr, "\t converts the current network by a network derived by\n" );
04796 fprintf( pErr, "\t replacing all nodes by DAGs isomorphic to the local BDDs\n" );
04797 fprintf( pErr, "\t-h : print the command usage\n");
04798 return 1;
04799 }
04800
04801
04813 int Abc_CommandExtSeqDcs( Abc_Frame_t * pAbc, int argc, char ** argv )
04814 {
04815 FILE * pOut, * pErr;
04816 Abc_Ntk_t * pNtk;
04817 int c;
04818 int fVerbose;
04819 extern int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNet, bool fVerbose );
04820
04821 pNtk = Abc_FrameReadNtk(pAbc);
04822 pOut = Abc_FrameReadOut(pAbc);
04823 pErr = Abc_FrameReadErr(pAbc);
04824
04825
04826 fVerbose = 0;
04827 Extra_UtilGetoptReset();
04828 while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
04829 {
04830 switch ( c )
04831 {
04832 case 'v':
04833 fVerbose ^= 1;
04834 break;
04835 case 'h':
04836 goto usage;
04837 default:
04838 goto usage;
04839 }
04840 }
04841
04842 if ( pNtk == NULL )
04843 {
04844 fprintf( pErr, "Empty network.\n" );
04845 return 1;
04846 }
04847 if ( Abc_NtkLatchNum(pNtk) == 0 )
04848 {
04849 fprintf( stdout, "The current network has no latches.\n" );
04850 return 0;
04851 }
04852 if ( !Abc_NtkIsStrash(pNtk) )
04853 {
04854 fprintf( stdout, "Extracting sequential don't-cares works only for AIGs (run \"strash\").\n" );
04855 return 0;
04856 }
04857 if ( !Abc_NtkExtractSequentialDcs( pNtk, fVerbose ) )
04858 {
04859 fprintf( stdout, "Extracting sequential don't-cares has failed.\n" );
04860 return 1;
04861 }
04862 return 0;
04863
04864 usage:
04865 fprintf( pErr, "usage: ext_seq_dcs [-vh]\n" );
04866 fprintf( pErr, "\t create EXDC network using unreachable states\n" );
04867 fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
04868 fprintf( pErr, "\t-h : print the command usage\n");
04869 return 1;
04870 }
04871
04883 int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
04884 {
04885 FILE * pOut, * pErr;
04886 Abc_Ntk_t * pNtk, * pNtkRes;
04887 Abc_Obj_t * pNode, * pNodeCo;
04888 int c;
04889 int fUseAllCis;
04890 int fUseMffc;
04891 int Output;
04892
04893 pNtk = Abc_FrameReadNtk(pAbc);
04894 pOut = Abc_FrameReadOut(pAbc);
04895 pErr = Abc_FrameReadErr(pAbc);
04896
04897
04898 fUseAllCis = 0;
04899 fUseMffc = 0;
04900 Output = -1;
04901 Extra_UtilGetoptReset();
04902 while ( ( c = Extra_UtilGetopt( argc, argv, "Omah" ) ) != EOF )
04903 {
04904 switch ( c )
04905 {
04906 case 'O':
04907 if ( globalUtilOptind >= argc )
04908 {
04909 fprintf( pErr, "Command line switch \"-O\" should be followed by an integer.\n" );
04910 goto usage;
04911 }
04912 Output = atoi(argv[globalUtilOptind]);
04913 globalUtilOptind++;
04914 if ( Output < 0 )
04915 goto usage;
04916 break;
04917 case 'm':
04918 fUseMffc ^= 1;
04919 case 'a':
04920 fUseAllCis ^= 1;
04921 break;
04922 case 'h':
04923 goto usage;
04924 default:
04925 goto usage;
04926 }
04927 }
04928
04929 if ( pNtk == NULL )
04930 {
04931 fprintf( pErr, "Empty network.\n" );
04932 return 1;
04933 }
04934
04935 if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
04936 {
04937 fprintf( pErr, "Currently can only be applied to the logic network or an AIG.\n" );
04938 return 1;
04939 }
04940
04941 if ( argc > globalUtilOptind + 1 )
04942 {
04943 fprintf( pErr, "Wrong number of auguments.\n" );
04944 goto usage;
04945 }
04946
04947 pNodeCo = NULL;
04948 if ( argc == globalUtilOptind + 1 )
04949 {
04950 pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
04951 if ( pNode == NULL )
04952 {
04953 fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
04954 return 1;
04955 }
04956 if ( fUseMffc )
04957 pNtkRes = Abc_NtkCreateMffc( pNtk, pNode, argv[globalUtilOptind] );
04958 else
04959 pNtkRes = Abc_NtkCreateCone( pNtk, pNode, argv[globalUtilOptind], fUseAllCis );
04960 }
04961 else
04962 {
04963 if ( Output == -1 )
04964 {
04965 fprintf( pErr, "The node is not specified.\n" );
04966 return 1;
04967 }
04968 if ( Output >= Abc_NtkCoNum(pNtk) )
04969 {
04970 fprintf( pErr, "The 0-based output number (%d) is larger than the number of outputs (%d).\n", Output, Abc_NtkCoNum(pNtk) );
04971 return 1;
04972 }
04973 pNodeCo = Abc_NtkCo( pNtk, Output );
04974 if ( fUseMffc )
04975 pNtkRes = Abc_NtkCreateMffc( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo) );
04976 else
04977 pNtkRes = Abc_NtkCreateCone( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo), fUseAllCis );
04978 }
04979 if ( pNodeCo && Abc_ObjFaninC0(pNodeCo) )
04980 printf( "The extracted cone represents the complement function of the CO.\n" );
04981 if ( pNtkRes == NULL )
04982 {
04983 fprintf( pErr, "Writing the logic cone of one node has failed.\n" );
04984 return 1;
04985 }
04986
04987 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
04988 return 0;
04989
04990 usage:
04991 fprintf( pErr, "usage: cone [-O num] [-amh] <name>\n" );
04992 fprintf( pErr, "\t replaces the current network by one logic cone\n" );
04993 fprintf( pErr, "\t-a : toggle writing all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" );
04994 fprintf( pErr, "\t-m : toggle writing only MFFC or complete TFI cone [default = %s]\n", fUseMffc? "MFFC": "TFI cone" );
04995 fprintf( pErr, "\t-h : print the command usage\n");
04996 fprintf( pErr, "\t-O num : (optional) the 0-based number of the CO to extract\n");
04997 fprintf( pErr, "\tname : (optional) the name of the node to extract\n");
04998 return 1;
04999 }
05000
05012 int Abc_CommandNode( Abc_Frame_t * pAbc, int argc, char ** argv )
05013 {
05014 FILE * pOut, * pErr;
05015 Abc_Ntk_t * pNtk, * pNtkRes;
05016 Abc_Obj_t * pNode;
05017 int c;
05018
05019 pNtk = Abc_FrameReadNtk(pAbc);
05020 pOut = Abc_FrameReadOut(pAbc);
05021 pErr = Abc_FrameReadErr(pAbc);
05022
05023
05024 Extra_UtilGetoptReset();
05025 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
05026 {
05027 switch ( c )
05028 {
05029 case 'h':
05030 goto usage;
05031 default:
05032 goto usage;
05033 }
05034 }
05035
05036 if ( pNtk == NULL )
05037 {
05038 fprintf( pErr, "Empty network.\n" );
05039 return 1;
05040 }
05041
05042 if ( !Abc_NtkIsLogic(pNtk) )
05043 {
05044 fprintf( pErr, "Currently can only be applied to a logic network.\n" );
05045 return 1;
05046 }
05047
05048 if ( argc != globalUtilOptind + 1 )
05049 {
05050 fprintf( pErr, "Wrong number of auguments.\n" );
05051 goto usage;
05052 }
05053
05054 pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
05055 if ( pNode == NULL )
05056 {
05057 fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
05058 return 1;
05059 }
05060
05061 pNtkRes = Abc_NtkCreateFromNode( pNtk, pNode );
05062
05063 if ( pNtkRes == NULL )
05064 {
05065 fprintf( pErr, "Splitting one node has failed.\n" );
05066 return 1;
05067 }
05068
05069 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
05070 return 0;
05071
05072 usage:
05073 fprintf( pErr, "usage: node [-h] <name>\n" );
05074 fprintf( pErr, "\t replaces the current network by the network composed of one node\n" );
05075 fprintf( pErr, "\t-h : print the command usage\n");
05076 fprintf( pErr, "\tname : the node name\n");
05077 return 1;
05078 }
05079
05080
05092 int Abc_CommandTopmost( Abc_Frame_t * pAbc, int argc, char ** argv )
05093 {
05094 FILE * pOut, * pErr;
05095 Abc_Ntk_t * pNtk, * pNtkRes;
05096 int c, nLevels;
05097 extern Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels );
05098
05099 pNtk = Abc_FrameReadNtk(pAbc);
05100 pOut = Abc_FrameReadOut(pAbc);
05101 pErr = Abc_FrameReadErr(pAbc);
05102
05103
05104 nLevels = 10;
05105 Extra_UtilGetoptReset();
05106 while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
05107 {
05108 switch ( c )
05109 {
05110 case 'N':
05111 if ( globalUtilOptind >= argc )
05112 {
05113 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
05114 goto usage;
05115 }
05116 nLevels = atoi(argv[globalUtilOptind]);
05117 globalUtilOptind++;
05118 if ( nLevels < 0 )
05119 goto usage;
05120 break;
05121 case 'h':
05122 goto usage;
05123 default:
05124 goto usage;
05125 }
05126 }
05127
05128 if ( pNtk == NULL )
05129 {
05130 fprintf( pErr, "Empty network.\n" );
05131 return 1;
05132 }
05133
05134 if ( !Abc_NtkIsStrash(pNtk) )
05135 {
05136 fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
05137 return 0;
05138 }
05139
05140 if ( Abc_NtkLatchNum(pNtk) > 0 )
05141 {
05142 fprintf( stdout, "Currently can only works for combinational circuits.\n" );
05143 return 0;
05144 }
05145 if ( Abc_NtkPoNum(pNtk) != 1 )
05146 {
05147 fprintf( stdout, "Currently expects a single-output miter.\n" );
05148 return 0;
05149 }
05150
05151 pNtkRes = Abc_NtkTopmost( pNtk, nLevels );
05152 if ( pNtkRes == NULL )
05153 {
05154 fprintf( pErr, "The command has failed.\n" );
05155 return 1;
05156 }
05157
05158 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
05159 return 0;
05160
05161 usage:
05162 fprintf( pErr, "usage: topmost [-N num] [-h]\n" );
05163 fprintf( pErr, "\t replaces the current network by several of its topmost levels\n" );
05164 fprintf( pErr, "\t-N num : max number of levels [default = %d]\n", nLevels );
05165 fprintf( pErr, "\t-h : print the command usage\n");
05166 fprintf( pErr, "\tname : the node name\n");
05167 return 1;
05168 }
05169
05181 int Abc_CommandTrim( Abc_Frame_t * pAbc, int argc, char ** argv )
05182 {
05183 FILE * pOut, * pErr;
05184 Abc_Ntk_t * pNtk, * pNtkRes;
05185 int c, nLevels;
05186 extern Abc_Ntk_t * Abc_NtkTrim( Abc_Ntk_t * pNtk );
05187
05188 pNtk = Abc_FrameReadNtk(pAbc);
05189 pOut = Abc_FrameReadOut(pAbc);
05190 pErr = Abc_FrameReadErr(pAbc);
05191
05192
05193 nLevels = 10;
05194 Extra_UtilGetoptReset();
05195 while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
05196 {
05197 switch ( c )
05198 {
05199
05200
05201
05202
05203
05204
05205
05206
05207
05208
05209
05210
05211
05212 case 'h':
05213 goto usage;
05214 default:
05215 goto usage;
05216 }
05217 }
05218
05219 if ( pNtk == NULL )
05220 {
05221 fprintf( pErr, "Empty network.\n" );
05222 return 1;
05223 }
05224 if ( Abc_NtkIsStrash(pNtk) )
05225 {
05226 fprintf( stdout, "Currently only works for logic circuits.\n" );
05227 return 0;
05228 }
05229
05230 pNtkRes = Abc_NtkTrim( pNtk );
05231 if ( pNtkRes == NULL )
05232 {
05233 fprintf( pErr, "The command has failed.\n" );
05234 return 1;
05235 }
05236
05237 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
05238 return 0;
05239
05240 usage:
05241 fprintf( pErr, "usage: trim [-h]\n" );
05242 fprintf( pErr, "\t removes POs fed by PIs and constants, and PIs w/o fanout\n" );
05243
05244 fprintf( pErr, "\t-h : print the command usage\n");
05245 return 1;
05246 }
05247
05248
05260 int Abc_CommandShortNames( Abc_Frame_t * pAbc, int argc, char ** argv )
05261 {
05262 FILE * pOut, * pErr;
05263 Abc_Ntk_t * pNtk;
05264 int c;
05265
05266 pNtk = Abc_FrameReadNtk(pAbc);
05267 pOut = Abc_FrameReadOut(pAbc);
05268 pErr = Abc_FrameReadErr(pAbc);
05269
05270
05271 Extra_UtilGetoptReset();
05272 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
05273 {
05274 switch ( c )
05275 {
05276 case 'h':
05277 goto usage;
05278 default:
05279 goto usage;
05280 }
05281 }
05282
05283 if ( pNtk == NULL )
05284 {
05285 fprintf( pErr, "Empty network.\n" );
05286 return 1;
05287 }
05288 Abc_NtkShortNames( pNtk );
05289 return 0;
05290
05291 usage:
05292 fprintf( pErr, "usage: short_names [-h]\n" );
05293 fprintf( pErr, "\t replaces PI/PO/latch names by short char strings\n" );
05294 fprintf( pErr, "\t-h : print the command usage\n");
05295 return 1;
05296 }
05297
05309 int Abc_CommandExdcFree( Abc_Frame_t * pAbc, int argc, char ** argv )
05310 {
05311 FILE * pOut, * pErr;
05312 Abc_Ntk_t * pNtk, * pNtkRes;
05313 int c;
05314
05315 pNtk = Abc_FrameReadNtk(pAbc);
05316 pOut = Abc_FrameReadOut(pAbc);
05317 pErr = Abc_FrameReadErr(pAbc);
05318
05319
05320 Extra_UtilGetoptReset();
05321 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
05322 {
05323 switch ( c )
05324 {
05325 case 'h':
05326 goto usage;
05327 default:
05328 goto usage;
05329 }
05330 }
05331
05332 if ( pNtk == NULL )
05333 {
05334 fprintf( pErr, "Empty network.\n" );
05335 return 1;
05336 }
05337 if ( pNtk->pExdc == NULL )
05338 {
05339 fprintf( pErr, "The network has no EXDC.\n" );
05340 return 1;
05341 }
05342
05343 Abc_NtkDelete( pNtk->pExdc );
05344 pNtk->pExdc = NULL;
05345
05346
05347 pNtkRes = Abc_NtkDup( pNtk );
05348 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
05349 return 0;
05350
05351 usage:
05352 fprintf( pErr, "usage: exdc_free [-h]\n" );
05353 fprintf( pErr, "\t frees the EXDC network of the current network\n" );
05354 fprintf( pErr, "\t-h : print the command usage\n");
05355 return 1;
05356 }
05357
05369 int Abc_CommandExdcGet( Abc_Frame_t * pAbc, int argc, char ** argv )
05370 {
05371 FILE * pOut, * pErr;
05372 Abc_Ntk_t * pNtk, * pNtkRes;
05373 int c;
05374
05375 pNtk = Abc_FrameReadNtk(pAbc);
05376 pOut = Abc_FrameReadOut(pAbc);
05377 pErr = Abc_FrameReadErr(pAbc);
05378
05379
05380 Extra_UtilGetoptReset();
05381 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
05382 {
05383 switch ( c )
05384 {
05385 case 'h':
05386 goto usage;
05387 default:
05388 goto usage;
05389 }
05390 }
05391
05392 if ( pNtk == NULL )
05393 {
05394 fprintf( pErr, "Empty network.\n" );
05395 return 1;
05396 }
05397 if ( pNtk->pExdc == NULL )
05398 {
05399 fprintf( pErr, "The network has no EXDC.\n" );
05400 return 1;
05401 }
05402
05403
05404 pNtkRes = Abc_NtkDup( pNtk->pExdc );
05405 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
05406 return 0;
05407
05408 usage:
05409 fprintf( pErr, "usage: exdc_get [-h]\n" );
05410 fprintf( pErr, "\t replaces the current network by the EXDC of the current network\n" );
05411 fprintf( pErr, "\t-h : print the command usage\n");
05412 return 1;
05413 }
05414
05426 int Abc_CommandExdcSet( Abc_Frame_t * pAbc, int argc, char ** argv )
05427 {
05428 FILE * pOut, * pErr, * pFile;
05429 Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
05430 char * FileName;
05431 int c;
05432
05433 pNtk = Abc_FrameReadNtk(pAbc);
05434 pOut = Abc_FrameReadOut(pAbc);
05435 pErr = Abc_FrameReadErr(pAbc);
05436
05437
05438 Extra_UtilGetoptReset();
05439 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
05440 {
05441 switch ( c )
05442 {
05443 case 'h':
05444 goto usage;
05445 default:
05446 goto usage;
05447 }
05448 }
05449
05450 if ( pNtk == NULL )
05451 {
05452 fprintf( pErr, "Empty network.\n" );
05453 return 1;
05454 }
05455
05456 if ( argc != globalUtilOptind + 1 )
05457 {
05458 goto usage;
05459 }
05460
05461
05462 FileName = argv[globalUtilOptind];
05463 if ( (pFile = fopen( FileName, "r" )) == NULL )
05464 {
05465 fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
05466 if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
05467 fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
05468 fprintf( pAbc->Err, "\n" );
05469 return 1;
05470 }
05471 fclose( pFile );
05472
05473
05474 pNtkNew = Io_Read( FileName, Io_ReadFileType(FileName), 1 );
05475 if ( pNtkNew == NULL )
05476 {
05477 fprintf( pAbc->Err, "Reading network from file has failed.\n" );
05478 return 1;
05479 }
05480
05481
05482 if ( pNtk->pExdc )
05483 {
05484 Abc_NtkDelete( pNtk->pExdc );
05485 pNtk->pExdc = NULL;
05486 }
05487 pNtkRes = Abc_NtkDup( pNtk );
05488 pNtkRes->pExdc = pNtkNew;
05489
05490
05491 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
05492 return 0;
05493
05494 usage:
05495 fprintf( pErr, "usage: exdc_set [-h] <file>\n" );
05496 fprintf( pErr, "\t sets the network from file as EXDC for the current network\n" );
05497 fprintf( pErr, "\t-h : print the command usage\n");
05498 fprintf( pErr, "\t<file> : file with the new EXDC network\n");
05499 return 1;
05500 }
05501
05513 int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
05514 {
05515 Cut_Params_t Params, * pParams = &Params;
05516 Cut_Man_t * pCutMan;
05517 Cut_Oracle_t * pCutOracle;
05518 FILE * pOut, * pErr;
05519 Abc_Ntk_t * pNtk;
05520 int c;
05521 int fOracle;
05522 extern Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams );
05523 extern void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * pCutOracle );
05524
05525 pNtk = Abc_FrameReadNtk(pAbc);
05526 pOut = Abc_FrameReadOut(pAbc);
05527 pErr = Abc_FrameReadErr(pAbc);
05528
05529
05530 fOracle = 0;
05531 memset( pParams, 0, sizeof(Cut_Params_t) );
05532 pParams->nVarsMax = 5;
05533 pParams->nKeepMax = 1000;
05534 pParams->fTruth = 0;
05535 pParams->fFilter = 1;
05536 pParams->fDrop = 0;
05537 pParams->fDag = 0;
05538 pParams->fTree = 0;
05539 pParams->fGlobal = 0;
05540 pParams->fLocal = 0;
05541 pParams->fFancy = 0;
05542 pParams->fMap = 0;
05543 pParams->fVerbose = 0;
05544 Extra_UtilGetoptReset();
05545 while ( ( c = Extra_UtilGetopt( argc, argv, "KMtfdxyglzmvoh" ) ) != EOF )
05546 {
05547 switch ( c )
05548 {
05549 case 'K':
05550 if ( globalUtilOptind >= argc )
05551 {
05552 fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
05553 goto usage;
05554 }
05555 pParams->nVarsMax = atoi(argv[globalUtilOptind]);
05556 globalUtilOptind++;
05557 if ( pParams->nVarsMax < 0 )
05558 goto usage;
05559 break;
05560 case 'M':
05561 if ( globalUtilOptind >= argc )
05562 {
05563 fprintf( pErr, "Command line switch \"-M\" should be followed by an integer.\n" );
05564 goto usage;
05565 }
05566 pParams->nKeepMax = atoi(argv[globalUtilOptind]);
05567 globalUtilOptind++;
05568 if ( pParams->nKeepMax < 0 )
05569 goto usage;
05570 break;
05571 case 't':
05572 pParams->fTruth ^= 1;
05573 break;
05574 case 'f':
05575 pParams->fFilter ^= 1;
05576 break;
05577 case 'd':
05578 pParams->fDrop ^= 1;
05579 break;
05580 case 'x':
05581 pParams->fDag ^= 1;
05582 break;
05583 case 'y':
05584 pParams->fTree ^= 1;
05585 break;
05586 case 'g':
05587 pParams->fGlobal ^= 1;
05588 break;
05589 case 'l':
05590 pParams->fLocal ^= 1;
05591 break;
05592 case 'z':
05593 pParams->fFancy ^= 1;
05594 break;
05595 case 'm':
05596 pParams->fMap ^= 1;
05597 break;
05598 case 'v':
05599 pParams->fVerbose ^= 1;
05600 break;
05601 case 'o':
05602 fOracle ^= 1;
05603 break;
05604 case 'h':
05605 goto usage;
05606 default:
05607 goto usage;
05608 }
05609 }
05610
05611 if ( pNtk == NULL )
05612 {
05613 fprintf( pErr, "Empty network.\n" );
05614 return 1;
05615 }
05616 if ( !Abc_NtkIsStrash(pNtk) )
05617 {
05618 fprintf( pErr, "Cut computation is available only for AIGs (run \"strash\").\n" );
05619 return 1;
05620 }
05621 if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX )
05622 {
05623 fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
05624 return 1;
05625 }
05626 if ( pParams->fDag && pParams->fTree )
05627 {
05628 fprintf( pErr, "Cannot compute both DAG cuts and tree cuts at the same time.\n" );
05629 return 1;
05630 }
05631
05632 if ( fOracle )
05633 pParams->fRecord = 1;
05634 pCutMan = Abc_NtkCuts( pNtk, pParams );
05635 if ( fOracle )
05636 pCutOracle = Cut_OracleStart( pCutMan );
05637 Cut_ManStop( pCutMan );
05638 if ( fOracle )
05639 {
05640 Abc_NtkCutsOracle( pNtk, pCutOracle );
05641 Cut_OracleStop( pCutOracle );
05642 }
05643 return 0;
05644
05645 usage:
05646 fprintf( pErr, "usage: cut [-K num] [-M num] [-tfdxyzmvh]\n" );
05647 fprintf( pErr, "\t computes k-feasible cuts for the AIG\n" );
05648 fprintf( pErr, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
05649 fprintf( pErr, "\t-M num : max number of cuts stored at a node [default = %d]\n", pParams->nKeepMax );
05650 fprintf( pErr, "\t-t : toggle truth table computation [default = %s]\n", pParams->fTruth? "yes": "no" );
05651 fprintf( pErr, "\t-f : toggle filtering of duplicated/dominated [default = %s]\n", pParams->fFilter? "yes": "no" );
05652 fprintf( pErr, "\t-d : toggle dropping when fanouts are done [default = %s]\n", pParams->fDrop? "yes": "no" );
05653 fprintf( pErr, "\t-x : toggle computing only DAG cuts [default = %s]\n", pParams->fDag? "yes": "no" );
05654 fprintf( pErr, "\t-y : toggle computing only tree cuts [default = %s]\n", pParams->fTree? "yes": "no" );
05655 fprintf( pErr, "\t-g : toggle computing only global cuts [default = %s]\n", pParams->fGlobal? "yes": "no" );
05656 fprintf( pErr, "\t-l : toggle computing only local cuts [default = %s]\n", pParams->fLocal? "yes": "no" );
05657 fprintf( pErr, "\t-z : toggle fancy computations [default = %s]\n", pParams->fFancy? "yes": "no" );
05658 fprintf( pErr, "\t-m : toggle delay-oriented FPGA mapping [default = %s]\n", pParams->fMap? "yes": "no" );
05659 fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
05660 fprintf( pErr, "\t-h : print the command usage\n");
05661 return 1;
05662 }
05663
05675 int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv )
05676 {
05677 Cut_Params_t Params, * pParams = &Params;
05678 Cut_Man_t * pCutMan;
05679 FILE * pOut, * pErr;
05680 Abc_Ntk_t * pNtk;
05681 int c;
05682 extern Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams );
05683
05684 pNtk = Abc_FrameReadNtk(pAbc);
05685 pOut = Abc_FrameReadOut(pAbc);
05686 pErr = Abc_FrameReadErr(pAbc);
05687
05688
05689 memset( pParams, 0, sizeof(Cut_Params_t) );
05690 pParams->nVarsMax = 5;
05691 pParams->nKeepMax = 1000;
05692 pParams->fTruth = 0;
05693 pParams->fFilter = 1;
05694 pParams->fSeq = 1;
05695 pParams->fVerbose = 0;
05696 Extra_UtilGetoptReset();
05697 while ( ( c = Extra_UtilGetopt( argc, argv, "KMtvh" ) ) != EOF )
05698 {
05699 switch ( c )
05700 {
05701 case 'K':
05702 if ( globalUtilOptind >= argc )
05703 {
05704 fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
05705 goto usage;
05706 }
05707 pParams->nVarsMax = atoi(argv[globalUtilOptind]);
05708 globalUtilOptind++;
05709 if ( pParams->nVarsMax < 0 )
05710 goto usage;
05711 break;
05712 case 'M':
05713 if ( globalUtilOptind >= argc )
05714 {
05715 fprintf( pErr, "Command line switch \"-M\" should be followed by an integer.\n" );
05716 goto usage;
05717 }
05718 pParams->nKeepMax = atoi(argv[globalUtilOptind]);
05719 globalUtilOptind++;
05720 if ( pParams->nKeepMax < 0 )
05721 goto usage;
05722 break;
05723 case 't':
05724 pParams->fTruth ^= 1;
05725 break;
05726 case 'v':
05727 pParams->fVerbose ^= 1;
05728 break;
05729 case 'h':
05730 goto usage;
05731 default:
05732 goto usage;
05733 }
05734 }
05735
05736 if ( pNtk == NULL )
05737 {
05738 fprintf( pErr, "Empty network.\n" );
05739 return 1;
05740 }
05741
05742
05743
05744
05745
05746
05747
05748 if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX )
05749 {
05750 fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
05751 return 1;
05752 }
05753
05754 pCutMan = Abc_NtkSeqCuts( pNtk, pParams );
05755 Cut_ManStop( pCutMan );
05756 return 0;
05757
05758 usage:
05759 fprintf( pErr, "usage: scut [-K num] [-M num] [-tvh]\n" );
05760 fprintf( pErr, "\t computes k-feasible cuts for the sequential AIG\n" );
05761 fprintf( pErr, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
05762 fprintf( pErr, "\t-M num : max number of cuts stored at a node [default = %d]\n", pParams->nKeepMax );
05763 fprintf( pErr, "\t-t : toggle truth table computation [default = %s]\n", pParams->fTruth? "yes": "no" );
05764 fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
05765 fprintf( pErr, "\t-h : print the command usage\n");
05766 return 1;
05767 }
05768
05780 int Abc_CommandEspresso( Abc_Frame_t * pAbc, int argc, char ** argv )
05781 {
05782 FILE * pOut, * pErr;
05783 Abc_Ntk_t * pNtk;
05784 int c;
05785 int fVerbose;
05786 extern void Abc_NtkEspresso( Abc_Ntk_t * pNtk, int fVerbose );
05787
05788 pNtk = Abc_FrameReadNtk(pAbc);
05789 pOut = Abc_FrameReadOut(pAbc);
05790 pErr = Abc_FrameReadErr(pAbc);
05791
05792
05793 fVerbose = 0;
05794 Extra_UtilGetoptReset();
05795 while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
05796 {
05797 switch ( c )
05798 {
05799 case 'v':
05800 fVerbose ^= 1;
05801 break;
05802 case 'h':
05803 goto usage;
05804 default:
05805 goto usage;
05806 }
05807 }
05808 if ( pNtk == NULL )
05809 {
05810 fprintf( pErr, "Empty network.\n" );
05811 return 1;
05812 }
05813 if ( !Abc_NtkIsLogic(pNtk) )
05814 {
05815 fprintf( pErr, "SOP minimization is possible for logic networks (run \"renode\").\n" );
05816 return 1;
05817 }
05818 Abc_NtkEspresso( pNtk, fVerbose );
05819 return 0;
05820
05821 usage:
05822 fprintf( pErr, "usage: espresso [-vh]\n" );
05823 fprintf( pErr, "\t minimizes SOPs of the local functions using Espresso\n" );
05824 fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
05825 fprintf( pErr, "\t-h : print the command usage\n");
05826 return 1;
05827 }
05828
05840 int Abc_CommandGen( Abc_Frame_t * pAbc, int argc, char ** argv )
05841 {
05842 FILE * pOut, * pErr;
05843 Abc_Ntk_t * pNtk;
05844 int c;
05845 int nVars;
05846 int fAdder;
05847 int fSorter;
05848 int fMesh;
05849 int fFpga;
05850 int fVerbose;
05851 char * FileName;
05852 extern void Abc_GenAdder( char * pFileName, int nVars );
05853 extern void Abc_GenSorter( char * pFileName, int nVars );
05854 extern void Abc_GenMesh( char * pFileName, int nVars );
05855 extern void Abc_GenFpga( char * pFileName, int nLutSize, int nLuts, int nVars );
05856
05857
05858 pNtk = Abc_FrameReadNtk(pAbc);
05859 pOut = Abc_FrameReadOut(pAbc);
05860 pErr = Abc_FrameReadErr(pAbc);
05861
05862
05863 nVars = 8;
05864 fAdder = 0;
05865 fSorter = 0;
05866 fMesh = 0;
05867 fFpga = 0;
05868 fVerbose = 0;
05869 Extra_UtilGetoptReset();
05870 while ( ( c = Extra_UtilGetopt( argc, argv, "Nasmfvh" ) ) != EOF )
05871 {
05872 switch ( c )
05873 {
05874 case 'N':
05875 if ( globalUtilOptind >= argc )
05876 {
05877 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
05878 goto usage;
05879 }
05880 nVars = atoi(argv[globalUtilOptind]);
05881 globalUtilOptind++;
05882 if ( nVars < 0 )
05883 goto usage;
05884 break;
05885 case 'a':
05886 fAdder ^= 1;
05887 break;
05888 case 's':
05889 fSorter ^= 1;
05890 break;
05891 case 'm':
05892 fMesh ^= 1;
05893 break;
05894 case 'f':
05895 fFpga ^= 1;
05896 break;
05897 case 'v':
05898 fVerbose ^= 1;
05899 break;
05900 case 'h':
05901 goto usage;
05902 default:
05903 goto usage;
05904 }
05905 }
05906
05907 if ( argc != globalUtilOptind + 1 )
05908 {
05909 goto usage;
05910 }
05911
05912
05913 FileName = argv[globalUtilOptind];
05914 if ( fAdder )
05915 Abc_GenAdder( FileName, nVars );
05916 else if ( fSorter )
05917 Abc_GenSorter( FileName, nVars );
05918 else if ( fMesh )
05919 Abc_GenMesh( FileName, nVars );
05920 else if ( fFpga )
05921 Abc_GenFpga( FileName, 4, 3, 10 );
05922
05923
05924 else
05925 printf( "Type of circuit is not specified.\n" );
05926 return 0;
05927
05928 usage:
05929 fprintf( pErr, "usage: gen [-N] [-asmfvh] <file>\n" );
05930 fprintf( pErr, "\t generates simple circuits\n" );
05931 fprintf( pErr, "\t-N num : the number of variables [default = %d]\n", nVars );
05932 fprintf( pErr, "\t-a : generate ripple-carry adder [default = %s]\n", fAdder? "yes": "no" );
05933 fprintf( pErr, "\t-s : generate a sorter [default = %s]\n", fSorter? "yes": "no" );
05934 fprintf( pErr, "\t-m : generate a mesh [default = %s]\n", fMesh? "yes": "no" );
05935 fprintf( pErr, "\t-f : generate a LUT FPGA structure [default = %s]\n", fFpga? "yes": "no" );
05936 fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
05937 fprintf( pErr, "\t-h : print the command usage\n");
05938 fprintf( pErr, "\t<file> : output file name\n");
05939 return 1;
05940 }
05941
05942
05954 int Abc_CommandXyz( Abc_Frame_t * pAbc, int argc, char ** argv )
05955 {
05956 FILE * pOut, * pErr;
05957 Abc_Ntk_t * pNtk, * pNtkRes;
05958 int c;
05959 int nLutMax;
05960 int nPlaMax;
05961 int RankCost;
05962 int fFastMode;
05963 int fRewriting;
05964 int fSynthesis;
05965 int fVerbose;
05966
05967 extern void * Abc_NtkPlayer( void * pNtk, int nLutMax, int nPlaMax, int RankCost, int fFastMode, int fRewriting, int fSynthesis, int fVerbose );
05968
05969 pNtk = Abc_FrameReadNtk(pAbc);
05970 pOut = Abc_FrameReadOut(pAbc);
05971 pErr = Abc_FrameReadErr(pAbc);
05972
05973
05974 nLutMax = 8;
05975 nPlaMax = 128;
05976 RankCost = 96000;
05977 fFastMode = 1;
05978 fRewriting = 0;
05979 fSynthesis = 0;
05980 fVerbose = 0;
05981 Extra_UtilGetoptReset();
05982 while ( ( c = Extra_UtilGetopt( argc, argv, "LPRfrsvh" ) ) != EOF )
05983 {
05984 switch ( c )
05985 {
05986 case 'L':
05987 if ( globalUtilOptind >= argc )
05988 {
05989 fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
05990 goto usage;
05991 }
05992 nLutMax = atoi(argv[globalUtilOptind]);
05993 globalUtilOptind++;
05994 if ( nLutMax < 0 )
05995 goto usage;
05996 break;
05997 case 'P':
05998 if ( globalUtilOptind >= argc )
05999 {
06000 fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
06001 goto usage;
06002 }
06003 nPlaMax = atoi(argv[globalUtilOptind]);
06004 globalUtilOptind++;
06005 if ( nPlaMax < 0 )
06006 goto usage;
06007 break;
06008 case 'R':
06009 if ( globalUtilOptind >= argc )
06010 {
06011 fprintf( pErr, "Command line switch \"-R\" should be followed by an integer.\n" );
06012 goto usage;
06013 }
06014 RankCost = atoi(argv[globalUtilOptind]);
06015 globalUtilOptind++;
06016 if ( RankCost < 0 )
06017 goto usage;
06018 break;
06019 case 'f':
06020 fFastMode ^= 1;
06021 break;
06022 case 'r':
06023 fRewriting ^= 1;
06024 break;
06025 case 's':
06026 fSynthesis ^= 1;
06027 break;
06028 case 'v':
06029 fVerbose ^= 1;
06030 break;
06031 case 'h':
06032 goto usage;
06033 default:
06034 goto usage;
06035 }
06036 }
06037 if ( pNtk == NULL )
06038 {
06039 fprintf( pErr, "Empty network.\n" );
06040 return 1;
06041 }
06042
06043 if ( !Abc_NtkIsStrash(pNtk) )
06044 {
06045 fprintf( pErr, "Only works for strashed networks.\n" );
06046 return 1;
06047 }
06048
06049
06050
06051
06052
06053
06054
06055
06056
06057
06058
06059
06060
06061
06062
06063
06064
06065
06066
06067 pNtkRes = NULL;
06068 if ( pNtkRes == NULL )
06069 {
06070 fprintf( pErr, "Command has failed.\n" );
06071 return 0;
06072 }
06073
06074 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
06075 return 0;
06076
06077 usage:
06078 fprintf( pErr, "usage: xyz [-L num] [-P num] [-R num] [-frsvh]\n" );
06079 fprintf( pErr, "\t specilized LUT/PLA decomposition\n" );
06080 fprintf( pErr, "\t-L num : maximum number of LUT inputs (2<=num<=8) [default = %d]\n", nLutMax );
06081 fprintf( pErr, "\t-P num : maximum number of PLA inputs/cubes (8<=num<=128) [default = %d]\n", nPlaMax );
06082 fprintf( pErr, "\t-R num : maximum are of one decomposition rank [default = %d]\n", RankCost );
06083 fprintf( pErr, "\t-f : toggle using fast LUT mapping mode [default = %s]\n", fFastMode? "yes": "no" );
06084 fprintf( pErr, "\t-r : toggle using one pass of AIG rewriting [default = %s]\n", fRewriting? "yes": "no" );
06085 fprintf( pErr, "\t-s : toggle using synthesis by AIG rewriting [default = %s]\n", fSynthesis? "yes": "no" );
06086 fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
06087 fprintf( pErr, "\t-h : print the command usage\n");
06088 return 1;
06089 }
06090
06091
06103 int Abc_CommandDouble( Abc_Frame_t * pAbc, int argc, char ** argv )
06104 {
06105 FILE * pOut, * pErr;
06106 Abc_Ntk_t * pNtk, * pNtkRes;
06107 int c;
06108 int nFrames;
06109 int fVerbose;
06110 extern Abc_Ntk_t * Abc_NtkDouble( Abc_Ntk_t * pNtk );
06111
06112 pNtk = Abc_FrameReadNtk(pAbc);
06113 pOut = Abc_FrameReadOut(pAbc);
06114 pErr = Abc_FrameReadErr(pAbc);
06115
06116
06117 nFrames = 50;
06118 fVerbose = 0;
06119 Extra_UtilGetoptReset();
06120 while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
06121 {
06122 switch ( c )
06123 {
06124 case 'F':
06125 if ( globalUtilOptind >= argc )
06126 {
06127 fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
06128 goto usage;
06129 }
06130 nFrames = atoi(argv[globalUtilOptind]);
06131 globalUtilOptind++;
06132 if ( nFrames < 0 )
06133 goto usage;
06134 break;
06135 case 'v':
06136 fVerbose ^= 1;
06137 break;
06138 case 'h':
06139 goto usage;
06140 default:
06141 goto usage;
06142 }
06143 }
06144 if ( pNtk == NULL )
06145 {
06146 fprintf( pErr, "Empty network.\n" );
06147 return 1;
06148 }
06149
06150 if ( !Abc_NtkIsSopLogic(pNtk) )
06151 {
06152 fprintf( pErr, "Only works for logic SOP networks.\n" );
06153 return 1;
06154 }
06155
06156 pNtkRes = Abc_NtkDouble( pNtk );
06157 if ( pNtkRes == NULL )
06158 {
06159 fprintf( pErr, "Command has failed.\n" );
06160 return 0;
06161 }
06162 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
06163 return 0;
06164
06165 usage:
06166 fprintf( pErr, "usage: double [-vh]\n" );
06167 fprintf( pErr, "\t puts together two parallel copies of the current network\n" );
06168
06169 fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
06170 fprintf( pErr, "\t-h : print the command usage\n");
06171 return 1;
06172 }
06173
06185 int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
06186 {
06187 FILE * pOut, * pErr;
06188 Abc_Ntk_t * pNtk, * pNtkRes;
06189 int c;
06190 int nLevels;
06191 int fVerbose;
06192
06193
06194
06195
06196 extern void Abc_NtkCompareSupports( Abc_Ntk_t * pNtk );
06197 extern void Abc_NtkCompareCones( Abc_Ntk_t * pNtk );
06198 extern Abc_Ntk_t * Abc_NtkDar( Abc_Ntk_t * pNtk );
06199 extern Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName );
06200 extern Abc_Ntk_t * Abc_NtkFilter( Abc_Ntk_t * pNtk );
06201 extern Abc_Ntk_t * Abc_NtkDarRetime( Abc_Ntk_t * pNtk, int nStepsMax, int fVerbose );
06202 extern Abc_Ntk_t * Abc_NtkPcmTest( Abc_Ntk_t * pNtk, int fVerbose );
06203
06204 pNtk = Abc_FrameReadNtk(pAbc);
06205 pOut = Abc_FrameReadOut(pAbc);
06206 pErr = Abc_FrameReadErr(pAbc);
06207
06208
06209 fVerbose = 0;
06210 nLevels = 1000;
06211 Extra_UtilGetoptReset();
06212 while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
06213 {
06214 switch ( c )
06215 {
06216 case 'N':
06217 if ( globalUtilOptind >= argc )
06218 {
06219 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
06220 goto usage;
06221 }
06222 nLevels = atoi(argv[globalUtilOptind]);
06223 globalUtilOptind++;
06224 if ( nLevels < 0 )
06225 goto usage;
06226 break;
06227 case 'v':
06228 fVerbose ^= 1;
06229 break;
06230 case 'h':
06231 goto usage;
06232 default:
06233 goto usage;
06234 }
06235 }
06236
06237
06238
06239
06240
06241
06242
06243
06244
06245
06246
06247
06248
06249
06250
06251
06252
06253
06254
06255
06256
06257
06258
06259
06260
06261
06262
06263
06264
06265
06266
06267
06268
06269
06270
06271
06272
06273
06274
06275
06276
06277
06278
06279
06280
06281
06282
06283
06284
06285
06286
06287
06288
06289
06290
06291
06292
06293
06294
06295
06296
06297
06298
06299
06300
06301
06302
06303
06304
06305
06306
06307
06308
06309
06310
06311
06312
06313
06314
06315
06316
06317
06318
06319
06320
06321
06322
06323
06324
06325
06326
06327
06328
06329
06330 if ( Abc_NtkIsStrash(pNtk) )
06331 {
06332 fprintf( stdout, "Currently only works for logic circuits.\n" );
06333 return 0;
06334 }
06335
06336
06337
06338
06339 pNtkRes = NULL;
06340 if ( pNtkRes == NULL )
06341 {
06342 fprintf( pErr, "Command has failed.\n" );
06343 return 1;
06344 }
06345
06346 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
06347 return 0;
06348 usage:
06349 fprintf( pErr, "usage: test [-h]\n" );
06350 fprintf( pErr, "\t testbench for new procedures\n" );
06351 fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
06352 fprintf( pErr, "\t-h : print the command usage\n");
06353 return 1;
06354 }
06355
06367 int Abc_CommandQuaVar( Abc_Frame_t * pAbc, int argc, char ** argv )
06368 {
06369 FILE * pOut, * pErr;
06370 Abc_Ntk_t * pNtk, * pNtkRes;
06371 int c, iVar, fUniv, fVerbose, RetValue;
06372 extern int Abc_NtkQuantify( Abc_Ntk_t * pNtk, int fUniv, int iVar, int fVerbose );
06373
06374 pNtk = Abc_FrameReadNtk(pAbc);
06375 pOut = Abc_FrameReadOut(pAbc);
06376 pErr = Abc_FrameReadErr(pAbc);
06377
06378
06379 iVar = 0;
06380 fUniv = 0;
06381 fVerbose = 0;
06382 Extra_UtilGetoptReset();
06383 while ( ( c = Extra_UtilGetopt( argc, argv, "Iuvh" ) ) != EOF )
06384 {
06385 switch ( c )
06386 {
06387 case 'I':
06388 if ( globalUtilOptind >= argc )
06389 {
06390 fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
06391 goto usage;
06392 }
06393 iVar = atoi(argv[globalUtilOptind]);
06394 globalUtilOptind++;
06395 if ( iVar < 0 )
06396 goto usage;
06397 break;
06398 case 'u':
06399 fUniv ^= 1;
06400 break;
06401 case 'v':
06402 fVerbose ^= 1;
06403 break;
06404 case 'h':
06405 goto usage;
06406 default:
06407 goto usage;
06408 }
06409 }
06410 if ( pNtk == NULL )
06411 {
06412 fprintf( pErr, "Empty network.\n" );
06413 return 1;
06414 }
06415 if ( Abc_NtkGetChoiceNum( pNtk ) )
06416 {
06417 fprintf( pErr, "This command cannot be applied to an AIG with choice nodes.\n" );
06418 return 1;
06419 }
06420
06421
06422 pNtkRes = Abc_NtkStrash( pNtk, 0, 1, 0 );
06423 RetValue = Abc_NtkQuantify( pNtkRes, fUniv, iVar, fVerbose );
06424
06425 Abc_NtkCleanData( pNtkRes );
06426 Abc_AigCleanup( pNtkRes->pManFunc );
06427
06428 if ( !RetValue )
06429 {
06430 fprintf( pErr, "Command has failed.\n" );
06431 return 0;
06432 }
06433
06434 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
06435 return 0;
06436
06437 usage:
06438 fprintf( pErr, "usage: qvar [-I num] [-uvh]\n" );
06439 fprintf( pErr, "\t quantifies one variable using the AIG\n" );
06440 fprintf( pErr, "\t-I num : the zero-based index of a variable to quantify [default = %d]\n", iVar );
06441 fprintf( pErr, "\t-u : toggle universal quantification [default = %s]\n", fUniv? "yes": "no" );
06442 fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
06443 fprintf( pErr, "\t-h : print the command usage\n");
06444 return 1;
06445 }
06446
06458 int Abc_CommandQuaRel( Abc_Frame_t * pAbc, int argc, char ** argv )
06459 {
06460 FILE * pOut, * pErr;
06461 Abc_Ntk_t * pNtk, * pNtkRes;
06462 int c, iVar, fInputs, fVerbose;
06463 extern Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose );
06464
06465 pNtk = Abc_FrameReadNtk(pAbc);
06466 pOut = Abc_FrameReadOut(pAbc);
06467 pErr = Abc_FrameReadErr(pAbc);
06468
06469
06470 iVar = 0;
06471 fInputs = 1;
06472 fVerbose = 0;
06473 Extra_UtilGetoptReset();
06474 while ( ( c = Extra_UtilGetopt( argc, argv, "Iqvh" ) ) != EOF )
06475 {
06476 switch ( c )
06477 {
06478 case 'I':
06479 if ( globalUtilOptind >= argc )
06480 {
06481 fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
06482 goto usage;
06483 }
06484 iVar = atoi(argv[globalUtilOptind]);
06485 globalUtilOptind++;
06486 if ( iVar < 0 )
06487 goto usage;
06488 break;
06489 case 'q':
06490 fInputs ^= 1;
06491 break;
06492 case 'v':
06493 fVerbose ^= 1;
06494 break;
06495 case 'h':
06496 goto usage;
06497 default:
06498 goto usage;
06499 }
06500 }
06501 if ( pNtk == NULL )
06502 {
06503 fprintf( pErr, "Empty network.\n" );
06504 return 1;
06505 }
06506 if ( Abc_NtkGetChoiceNum( pNtk ) )
06507 {
06508 fprintf( pErr, "This command cannot be applied to an AIG with choice nodes.\n" );
06509 return 1;
06510 }
06511 if ( Abc_NtkIsComb(pNtk) )
06512 {
06513 fprintf( pErr, "This command works only for sequential circuits.\n" );
06514 return 1;
06515 }
06516
06517
06518 if ( !Abc_NtkIsStrash(pNtk) )
06519 {
06520 pNtk = Abc_NtkStrash( pNtk, 0, 1, 0 );
06521 pNtkRes = Abc_NtkTransRel( pNtk, fInputs, fVerbose );
06522 Abc_NtkDelete( pNtk );
06523 }
06524 else
06525 pNtkRes = Abc_NtkTransRel( pNtk, fInputs, fVerbose );
06526
06527 if ( pNtkRes == NULL )
06528 {
06529 fprintf( pErr, "Command has failed.\n" );
06530 return 0;
06531 }
06532
06533 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
06534 return 0;
06535
06536 usage:
06537 fprintf( pErr, "usage: qrel [-qvh]\n" );
06538 fprintf( pErr, "\t computes transition relation of the sequential network\n" );
06539
06540 fprintf( pErr, "\t-q : perform quantification of inputs [default = %s]\n", fInputs? "yes": "no" );
06541 fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
06542 fprintf( pErr, "\t-h : print the command usage\n");
06543 return 1;
06544 }
06545
06557 int Abc_CommandQuaReach( Abc_Frame_t * pAbc, int argc, char ** argv )
06558 {
06559 FILE * pOut, * pErr;
06560 Abc_Ntk_t * pNtk, * pNtkRes;
06561 int c, nIters, fVerbose;
06562 extern Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtk, int nIters, int fVerbose );
06563
06564 pNtk = Abc_FrameReadNtk(pAbc);
06565 pOut = Abc_FrameReadOut(pAbc);
06566 pErr = Abc_FrameReadErr(pAbc);
06567
06568
06569 nIters = 256;
06570 fVerbose = 0;
06571 Extra_UtilGetoptReset();
06572 while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF )
06573 {
06574 switch ( c )
06575 {
06576 case 'I':
06577 if ( globalUtilOptind >= argc )
06578 {
06579 fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
06580 goto usage;
06581 }
06582 nIters = atoi(argv[globalUtilOptind]);
06583 globalUtilOptind++;
06584 if ( nIters < 0 )
06585 goto usage;
06586 break;
06587 case 'v':
06588 fVerbose ^= 1;
06589 break;
06590 case 'h':
06591 goto usage;
06592 default:
06593 goto usage;
06594 }
06595 }
06596 if ( pNtk == NULL )
06597 {
06598 fprintf( pErr, "Empty network.\n" );
06599 return 1;
06600 }
06601 if ( Abc_NtkGetChoiceNum( pNtk ) )
06602 {
06603 fprintf( pErr, "This command cannot be applied to an AIG with choice nodes.\n" );
06604 return 1;
06605 }
06606 if ( !Abc_NtkIsComb(pNtk) )
06607 {
06608 fprintf( pErr, "This command works only for combinational transition relations.\n" );
06609 return 1;
06610 }
06611 if ( !Abc_NtkIsStrash(pNtk) )
06612 {
06613 fprintf( pErr, "This command works only for strashed networks.\n" );
06614 return 1;
06615 }
06616 if ( Abc_NtkPoNum(pNtk) > 1 )
06617 {
06618 fprintf( pErr, "The transition relation should have one output.\n" );
06619 return 1;
06620 }
06621 if ( Abc_NtkPiNum(pNtk) % 2 != 0 )
06622 {
06623 fprintf( pErr, "The transition relation should have an even number of inputs.\n" );
06624 return 1;
06625 }
06626
06627 pNtkRes = Abc_NtkReachability( pNtk, nIters, fVerbose );
06628 if ( pNtkRes == NULL )
06629 {
06630 fprintf( pErr, "Command has failed.\n" );
06631 return 0;
06632 }
06633
06634 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
06635 return 0;
06636
06637 usage:
06638 fprintf( pErr, "usage: qreach [-I num] [-vh]\n" );
06639 fprintf( pErr, "\t computes unreachable states using AIG-based quantification\n" );
06640 fprintf( pErr, "\t assumes that the current network is a transition relation\n" );
06641 fprintf( pErr, "\t assumes that the initial state is composed of all zeros\n" );
06642 fprintf( pErr, "\t-I num : the number of image computations to perform [default = %d]\n", nIters );
06643 fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
06644 fprintf( pErr, "\t-h : print the command usage\n");
06645 return 1;
06646 }
06647
06648
06660 int Abc_CommandIStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
06661 {
06662 FILE * pOut, * pErr;
06663 Abc_Ntk_t * pNtk, * pNtkRes, * pNtkTemp;
06664 int c;
06665 extern Abc_Ntk_t * Abc_NtkIvyStrash( Abc_Ntk_t * pNtk );
06666
06667 pNtk = Abc_FrameReadNtk(pAbc);
06668 pOut = Abc_FrameReadOut(pAbc);
06669 pErr = Abc_FrameReadErr(pAbc);
06670
06671
06672 Extra_UtilGetoptReset();
06673 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
06674 {
06675 switch ( c )
06676 {
06677 case 'h':
06678 goto usage;
06679 default:
06680 goto usage;
06681 }
06682 }
06683 if ( pNtk == NULL )
06684 {
06685 fprintf( pErr, "Empty network.\n" );
06686 return 1;
06687 }
06688 if ( !Abc_NtkIsStrash(pNtk) )
06689 {
06690 pNtkTemp = Abc_NtkStrash( pNtk, 0, 1, 0 );
06691 pNtkRes = Abc_NtkIvyStrash( pNtkTemp );
06692 Abc_NtkDelete( pNtkTemp );
06693 }
06694 else
06695 pNtkRes = Abc_NtkIvyStrash( pNtk );
06696 if ( pNtkRes == NULL )
06697 {
06698 fprintf( pErr, "Command has failed.\n" );
06699 return 0;
06700 }
06701
06702 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
06703 return 0;
06704
06705 usage:
06706 fprintf( pErr, "usage: istrash [-h]\n" );
06707 fprintf( pErr, "\t perform sequential structural hashing\n" );
06708 fprintf( pErr, "\t-h : print the command usage\n");
06709 return 1;
06710 }
06711
06723 int Abc_CommandICut( Abc_Frame_t * pAbc, int argc, char ** argv )
06724 {
06725 FILE * pOut, * pErr;
06726 Abc_Ntk_t * pNtk;
06727 int c, nInputs;
06728 extern void Abc_NtkIvyCuts( Abc_Ntk_t * pNtk, int nInputs );
06729
06730 pNtk = Abc_FrameReadNtk(pAbc);
06731 pOut = Abc_FrameReadOut(pAbc);
06732 pErr = Abc_FrameReadErr(pAbc);
06733
06734
06735 nInputs = 5;
06736 Extra_UtilGetoptReset();
06737 while ( ( c = Extra_UtilGetopt( argc, argv, "Kh" ) ) != EOF )
06738 {
06739 switch ( c )
06740 {
06741 case 'K':
06742 if ( globalUtilOptind >= argc )
06743 {
06744 fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
06745 goto usage;
06746 }
06747 nInputs = atoi(argv[globalUtilOptind]);
06748 globalUtilOptind++;
06749 if ( nInputs < 0 )
06750 goto usage;
06751 break;
06752 case 'h':
06753 goto usage;
06754 default:
06755 goto usage;
06756 }
06757 }
06758 if ( pNtk == NULL )
06759 {
06760 fprintf( pErr, "Empty network.\n" );
06761 return 1;
06762 }
06763 if ( !Abc_NtkIsStrash(pNtk) )
06764 {
06765 fprintf( pErr, "This command works only for strashed networks.\n" );
06766 return 1;
06767 }
06768
06769 Abc_NtkIvyCuts( pNtk, nInputs );
06770 return 0;
06771
06772 usage:
06773 fprintf( pErr, "usage: icut [-K num] [-h]\n" );
06774 fprintf( pErr, "\t computes sequential cuts of the given size\n" );
06775 fprintf( pErr, "\t-K num : the number of cut inputs (2 <= num <= 6) [default = %d]\n", nInputs );
06776 fprintf( pErr, "\t-h : print the command usage\n");
06777 return 1;
06778 }
06779
06791 int Abc_CommandIRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
06792 {
06793 FILE * pOut, * pErr;
06794 Abc_Ntk_t * pNtk, * pNtkRes;
06795 int c, fUpdateLevel, fUseZeroCost, fVerbose;
06796 extern Abc_Ntk_t * Abc_NtkIvyRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeroCost, int fVerbose );
06797
06798 pNtk = Abc_FrameReadNtk(pAbc);
06799 pOut = Abc_FrameReadOut(pAbc);
06800 pErr = Abc_FrameReadErr(pAbc);
06801
06802
06803 fUpdateLevel = 1;
06804 fUseZeroCost = 0;
06805 fVerbose = 0;
06806 Extra_UtilGetoptReset();
06807 while ( ( c = Extra_UtilGetopt( argc, argv, "lzvh" ) ) != EOF )
06808 {
06809 switch ( c )
06810 {
06811 case 'l':
06812 fUpdateLevel ^= 1;
06813 break;
06814 case 'z':
06815 fUseZeroCost ^= 1;
06816 break;
06817 case 'v':
06818 fVerbose ^= 1;
06819 break;
06820 case 'h':
06821 goto usage;
06822 default:
06823 goto usage;
06824 }
06825 }
06826 if ( pNtk == NULL )
06827 {
06828 fprintf( pErr, "Empty network.\n" );
06829 return 1;
06830 }
06831 if ( !Abc_NtkIsStrash(pNtk) )
06832 {
06833 fprintf( pErr, "This command works only for strashed networks.\n" );
06834 return 1;
06835 }
06836
06837 pNtkRes = Abc_NtkIvyRewrite( pNtk, fUpdateLevel, fUseZeroCost, fVerbose );
06838 if ( pNtkRes == NULL )
06839 {
06840 fprintf( pErr, "Command has failed.\n" );
06841 return 0;
06842 }
06843
06844 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
06845 return 0;
06846
06847 usage:
06848 fprintf( pErr, "usage: irw [-lzvh]\n" );
06849 fprintf( pErr, "\t perform combinational AIG rewriting\n" );
06850 fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
06851 fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
06852 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
06853 fprintf( pErr, "\t-h : print the command usage\n");
06854 return 1;
06855 }
06856
06868 int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
06869 {
06870 FILE * pOut, * pErr;
06871 Abc_Ntk_t * pNtk, * pNtkRes;
06872 Dar_RwrPar_t Pars, * pPars = &Pars;
06873 int c;
06874
06875 extern Abc_Ntk_t * Abc_NtkDRewrite( Abc_Ntk_t * pNtk, Dar_RwrPar_t * pPars );
06876
06877 pNtk = Abc_FrameReadNtk(pAbc);
06878 pOut = Abc_FrameReadOut(pAbc);
06879 pErr = Abc_FrameReadErr(pAbc);
06880
06881
06882 Dar_ManDefaultRwrParams( pPars );
06883 Extra_UtilGetoptReset();
06884 while ( ( c = Extra_UtilGetopt( argc, argv, "CNflzvwh" ) ) != EOF )
06885 {
06886 switch ( c )
06887 {
06888 case 'C':
06889 if ( globalUtilOptind >= argc )
06890 {
06891 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
06892 goto usage;
06893 }
06894 pPars->nCutsMax = atoi(argv[globalUtilOptind]);
06895 globalUtilOptind++;
06896 if ( pPars->nCutsMax < 0 )
06897 goto usage;
06898 break;
06899 case 'N':
06900 if ( globalUtilOptind >= argc )
06901 {
06902 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
06903 goto usage;
06904 }
06905 pPars->nSubgMax = atoi(argv[globalUtilOptind]);
06906 globalUtilOptind++;
06907 if ( pPars->nSubgMax < 0 )
06908 goto usage;
06909 break;
06910 case 'f':
06911 pPars->fFanout ^= 1;
06912 break;
06913 case 'l':
06914 pPars->fUpdateLevel ^= 1;
06915 break;
06916 case 'z':
06917 pPars->fUseZeros ^= 1;
06918 break;
06919 case 'v':
06920 pPars->fVerbose ^= 1;
06921 break;
06922 case 'w':
06923 pPars->fVeryVerbose ^= 1;
06924 break;
06925 case 'h':
06926 goto usage;
06927 default:
06928 goto usage;
06929 }
06930 }
06931 if ( pNtk == NULL )
06932 {
06933 fprintf( pErr, "Empty network.\n" );
06934 return 1;
06935 }
06936 if ( !Abc_NtkIsStrash(pNtk) )
06937 {
06938 fprintf( pErr, "This command works only for strashed networks.\n" );
06939 return 1;
06940 }
06941 pNtkRes = Abc_NtkDRewrite( pNtk, pPars );
06942 if ( pNtkRes == NULL )
06943 {
06944 fprintf( pErr, "Command has failed.\n" );
06945 return 0;
06946 }
06947
06948 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
06949 return 0;
06950
06951 usage:
06952 fprintf( pErr, "usage: drw [-C num] [-N num] [-flzvwh]\n" );
06953 fprintf( pErr, "\t performs combinational AIG rewriting\n" );
06954 fprintf( pErr, "\t-C num : the max number of cuts at a node [default = %d]\n", pPars->nCutsMax );
06955 fprintf( pErr, "\t-N num : the max number of subgraphs tried [default = %d]\n", pPars->nSubgMax );
06956 fprintf( pErr, "\t-f : toggle representing fanouts [default = %s]\n", pPars->fFanout? "yes": "no" );
06957 fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
06958 fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
06959 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
06960 fprintf( pErr, "\t-w : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
06961 fprintf( pErr, "\t-h : print the command usage\n");
06962 return 1;
06963 }
06964
06976 int Abc_CommandDRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
06977 {
06978 FILE * pOut, * pErr;
06979 Abc_Ntk_t * pNtk, * pNtkRes;
06980 Dar_RefPar_t Pars, * pPars = &Pars;
06981 int c;
06982
06983 extern Abc_Ntk_t * Abc_NtkDRefactor( Abc_Ntk_t * pNtk, Dar_RefPar_t * pPars );
06984
06985 pNtk = Abc_FrameReadNtk(pAbc);
06986 pOut = Abc_FrameReadOut(pAbc);
06987 pErr = Abc_FrameReadErr(pAbc);
06988
06989
06990 Dar_ManDefaultRefParams( pPars );
06991 Extra_UtilGetoptReset();
06992 while ( ( c = Extra_UtilGetopt( argc, argv, "MKCelzvwh" ) ) != EOF )
06993 {
06994 switch ( c )
06995 {
06996 case 'M':
06997 if ( globalUtilOptind >= argc )
06998 {
06999 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
07000 goto usage;
07001 }
07002 pPars->nMffcMin = atoi(argv[globalUtilOptind]);
07003 globalUtilOptind++;
07004 if ( pPars->nMffcMin < 0 )
07005 goto usage;
07006 break;
07007 case 'K':
07008 if ( globalUtilOptind >= argc )
07009 {
07010 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
07011 goto usage;
07012 }
07013 pPars->nLeafMax = atoi(argv[globalUtilOptind]);
07014 globalUtilOptind++;
07015 if ( pPars->nLeafMax < 0 )
07016 goto usage;
07017 break;
07018 case 'C':
07019 if ( globalUtilOptind >= argc )
07020 {
07021 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
07022 goto usage;
07023 }
07024 pPars->nCutsMax = atoi(argv[globalUtilOptind]);
07025 globalUtilOptind++;
07026 if ( pPars->nCutsMax < 0 )
07027 goto usage;
07028 break;
07029 case 'e':
07030 pPars->fExtend ^= 1;
07031 break;
07032 case 'l':
07033 pPars->fUpdateLevel ^= 1;
07034 break;
07035 case 'z':
07036 pPars->fUseZeros ^= 1;
07037 break;
07038 case 'v':
07039 pPars->fVerbose ^= 1;
07040 break;
07041 case 'w':
07042 pPars->fVeryVerbose ^= 1;
07043 break;
07044 case 'h':
07045 goto usage;
07046 default:
07047 goto usage;
07048 }
07049 }
07050 if ( pNtk == NULL )
07051 {
07052 fprintf( pErr, "Empty network.\n" );
07053 return 1;
07054 }
07055 if ( !Abc_NtkIsStrash(pNtk) )
07056 {
07057 fprintf( pErr, "This command works only for strashed networks.\n" );
07058 return 1;
07059 }
07060 if ( pPars->nLeafMax < 4 || pPars->nLeafMax > 15 )
07061 {
07062 fprintf( pErr, "This command only works for cut sizes 4 <= K <= 15.\n" );
07063 return 1;
07064 }
07065 pNtkRes = Abc_NtkDRefactor( pNtk, pPars );
07066 if ( pNtkRes == NULL )
07067 {
07068 fprintf( pErr, "Command has failed.\n" );
07069 return 0;
07070 }
07071
07072 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
07073 return 0;
07074
07075 usage:
07076 fprintf( pErr, "usage: drf [-M num] [-K num] [-C num] [-elzvwh]\n" );
07077 fprintf( pErr, "\t performs combinational AIG refactoring\n" );
07078 fprintf( pErr, "\t-M num : the min MFFC size to attempt refactoring [default = %d]\n", pPars->nMffcMin );
07079 fprintf( pErr, "\t-K num : the max number of cuts leaves [default = %d]\n", pPars->nLeafMax );
07080 fprintf( pErr, "\t-C num : the max number of cuts to try at a node [default = %d]\n", pPars->nCutsMax );
07081 fprintf( pErr, "\t-e : toggle extending tbe cut below MFFC [default = %s]\n", pPars->fExtend? "yes": "no" );
07082 fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
07083 fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
07084 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
07085 fprintf( pErr, "\t-w : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
07086 fprintf( pErr, "\t-h : print the command usage\n");
07087 return 1;
07088 }
07089
07101 int Abc_CommandDCompress2( Abc_Frame_t * pAbc, int argc, char ** argv )
07102 {
07103 FILE * pOut, * pErr;
07104 Abc_Ntk_t * pNtk, * pNtkRes;
07105 int fBalance, fVerbose, fUpdateLevel, c;
07106
07107 extern Abc_Ntk_t * Abc_NtkDCompress2( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, int fVerbose );
07108
07109 pNtk = Abc_FrameReadNtk(pAbc);
07110 pOut = Abc_FrameReadOut(pAbc);
07111 pErr = Abc_FrameReadErr(pAbc);
07112
07113
07114 fBalance = 0;
07115 fVerbose = 0;
07116 fUpdateLevel = 0;
07117 Extra_UtilGetoptReset();
07118 while ( ( c = Extra_UtilGetopt( argc, argv, "blvh" ) ) != EOF )
07119 {
07120 switch ( c )
07121 {
07122 case 'b':
07123 fBalance ^= 1;
07124 break;
07125 case 'l':
07126 fUpdateLevel ^= 1;
07127 break;
07128 case 'v':
07129 fVerbose ^= 1;
07130 break;
07131 case 'h':
07132 goto usage;
07133 default:
07134 goto usage;
07135 }
07136 }
07137 if ( pNtk == NULL )
07138 {
07139 fprintf( pErr, "Empty network.\n" );
07140 return 1;
07141 }
07142 if ( !Abc_NtkIsStrash(pNtk) )
07143 {
07144 fprintf( pErr, "This command works only for strashed networks.\n" );
07145 return 1;
07146 }
07147 pNtkRes = Abc_NtkDCompress2( pNtk, fBalance, fUpdateLevel, fVerbose );
07148 if ( pNtkRes == NULL )
07149 {
07150 fprintf( pErr, "Command has failed.\n" );
07151 return 0;
07152 }
07153
07154 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
07155 return 0;
07156
07157 usage:
07158 fprintf( pErr, "usage: dcompress2 [-blvh]\n" );
07159 fprintf( pErr, "\t performs combinational AIG optimization\n" );
07160 fprintf( pErr, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
07161 fprintf( pErr, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
07162 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
07163 fprintf( pErr, "\t-h : print the command usage\n");
07164 return 1;
07165 }
07166
07167
07179 int Abc_CommandDChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
07180 {
07181 FILE * pOut, * pErr;
07182 Abc_Ntk_t * pNtk, * pNtkRes;
07183 int fBalance, fVerbose, fUpdateLevel, c;
07184
07185 extern Abc_Ntk_t * Abc_NtkDChoice( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, int fVerbose );
07186
07187 pNtk = Abc_FrameReadNtk(pAbc);
07188 pOut = Abc_FrameReadOut(pAbc);
07189 pErr = Abc_FrameReadErr(pAbc);
07190
07191
07192 fBalance = 1;
07193 fUpdateLevel = 1;
07194 fVerbose = 0;
07195 Extra_UtilGetoptReset();
07196 while ( ( c = Extra_UtilGetopt( argc, argv, "blvh" ) ) != EOF )
07197 {
07198 switch ( c )
07199 {
07200 case 'b':
07201 fBalance ^= 1;
07202 break;
07203 case 'l':
07204 fUpdateLevel ^= 1;
07205 break;
07206 case 'v':
07207 fVerbose ^= 1;
07208 break;
07209 case 'h':
07210 goto usage;
07211 default:
07212 goto usage;
07213 }
07214 }
07215 if ( pNtk == NULL )
07216 {
07217 fprintf( pErr, "Empty network.\n" );
07218 return 1;
07219 }
07220 if ( !Abc_NtkIsStrash(pNtk) )
07221 {
07222 fprintf( pErr, "This command works only for strashed networks.\n" );
07223 return 1;
07224 }
07225 pNtkRes = Abc_NtkDChoice( pNtk, fBalance, fUpdateLevel, fVerbose );
07226 if ( pNtkRes == NULL )
07227 {
07228 fprintf( pErr, "Command has failed.\n" );
07229 return 0;
07230 }
07231
07232 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
07233 return 0;
07234
07235 usage:
07236 fprintf( pErr, "usage: dchoice [-blvh]\n" );
07237 fprintf( pErr, "\t performs partitioned choicing using a new AIG package\n" );
07238 fprintf( pErr, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
07239 fprintf( pErr, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
07240 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
07241 fprintf( pErr, "\t-h : print the command usage\n");
07242 return 1;
07243 }
07244
07256 int Abc_CommandDrwsat( Abc_Frame_t * pAbc, int argc, char ** argv )
07257 {
07258 FILE * pOut, * pErr;
07259 Abc_Ntk_t * pNtk, * pNtkRes;
07260 int fBalance, fVerbose, c;
07261
07262 extern Abc_Ntk_t * Abc_NtkDrwsat( Abc_Ntk_t * pNtk, int fBalance, int fVerbose );
07263
07264 pNtk = Abc_FrameReadNtk(pAbc);
07265 pOut = Abc_FrameReadOut(pAbc);
07266 pErr = Abc_FrameReadErr(pAbc);
07267
07268
07269 fBalance = 0;
07270 fVerbose = 0;
07271 Extra_UtilGetoptReset();
07272 while ( ( c = Extra_UtilGetopt( argc, argv, "bvh" ) ) != EOF )
07273 {
07274 switch ( c )
07275 {
07276 case 'b':
07277 fBalance ^= 1;
07278 break;
07279 case 'v':
07280 fVerbose ^= 1;
07281 break;
07282 case 'h':
07283 goto usage;
07284 default:
07285 goto usage;
07286 }
07287 }
07288 if ( pNtk == NULL )
07289 {
07290 fprintf( pErr, "Empty network.\n" );
07291 return 1;
07292 }
07293 if ( !Abc_NtkIsStrash(pNtk) )
07294 {
07295 fprintf( pErr, "This command works only for strashed networks.\n" );
07296 return 1;
07297 }
07298 pNtkRes = Abc_NtkDrwsat( pNtk, fBalance, fVerbose );
07299 if ( pNtkRes == NULL )
07300 {
07301 fprintf( pErr, "Command has failed.\n" );
07302 return 0;
07303 }
07304
07305 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
07306 return 0;
07307
07308 usage:
07309 fprintf( pErr, "usage: drwsat [-bvh]\n" );
07310 fprintf( pErr, "\t performs combinational AIG optimization for SAT\n" );
07311 fprintf( pErr, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
07312 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
07313 fprintf( pErr, "\t-h : print the command usage\n");
07314 return 1;
07315 }
07316
07328 int Abc_CommandIRewriteSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
07329 {
07330 FILE * pOut, * pErr;
07331 Abc_Ntk_t * pNtk, * pNtkRes;
07332 int c, fUpdateLevel, fUseZeroCost, fVerbose;
07333 extern Abc_Ntk_t * Abc_NtkIvyRewriteSeq( Abc_Ntk_t * pNtk, int fUseZeroCost, int fVerbose );
07334
07335 pNtk = Abc_FrameReadNtk(pAbc);
07336 pOut = Abc_FrameReadOut(pAbc);
07337 pErr = Abc_FrameReadErr(pAbc);
07338
07339
07340 fUpdateLevel = 0;
07341 fUseZeroCost = 0;
07342 fVerbose = 0;
07343 Extra_UtilGetoptReset();
07344 while ( ( c = Extra_UtilGetopt( argc, argv, "lzvh" ) ) != EOF )
07345 {
07346 switch ( c )
07347 {
07348 case 'l':
07349 fUpdateLevel ^= 1;
07350 break;
07351 case 'z':
07352 fUseZeroCost ^= 1;
07353 break;
07354 case 'v':
07355 fVerbose ^= 1;
07356 break;
07357 case 'h':
07358 goto usage;
07359 default:
07360 goto usage;
07361 }
07362 }
07363 if ( pNtk == NULL )
07364 {
07365 fprintf( pErr, "Empty network.\n" );
07366 return 1;
07367 }
07368 if ( !Abc_NtkIsStrash(pNtk) )
07369 {
07370 fprintf( pErr, "This command works only for strashed networks.\n" );
07371 return 1;
07372 }
07373
07374 pNtkRes = Abc_NtkIvyRewriteSeq( pNtk, fUseZeroCost, fVerbose );
07375 if ( pNtkRes == NULL )
07376 {
07377 fprintf( pErr, "Command has failed.\n" );
07378 return 0;
07379 }
07380
07381 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
07382 return 0;
07383
07384 usage:
07385 fprintf( pErr, "usage: irws [-zvh]\n" );
07386 fprintf( pErr, "\t perform sequential AIG rewriting\n" );
07387
07388 fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
07389 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
07390 fprintf( pErr, "\t-h : print the command usage\n");
07391 return 1;
07392 }
07393
07405 int Abc_CommandIResyn( Abc_Frame_t * pAbc, int argc, char ** argv )
07406 {
07407 FILE * pOut, * pErr;
07408 Abc_Ntk_t * pNtk, * pNtkRes;
07409 int c, fUpdateLevel, fVerbose;
07410 extern Abc_Ntk_t * Abc_NtkIvyResyn( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose );
07411
07412 pNtk = Abc_FrameReadNtk(pAbc);
07413 pOut = Abc_FrameReadOut(pAbc);
07414 pErr = Abc_FrameReadErr(pAbc);
07415
07416
07417 fUpdateLevel = 1;
07418 fVerbose = 0;
07419 Extra_UtilGetoptReset();
07420 while ( ( c = Extra_UtilGetopt( argc, argv, "lzvh" ) ) != EOF )
07421 {
07422 switch ( c )
07423 {
07424 case 'l':
07425 fUpdateLevel ^= 1;
07426 break;
07427 case 'v':
07428 fVerbose ^= 1;
07429 break;
07430 case 'h':
07431 goto usage;
07432 default:
07433 goto usage;
07434 }
07435 }
07436 if ( pNtk == NULL )
07437 {
07438 fprintf( pErr, "Empty network.\n" );
07439 return 1;
07440 }
07441 if ( !Abc_NtkIsStrash(pNtk) )
07442 {
07443 fprintf( pErr, "This command works only for strashed networks.\n" );
07444 return 1;
07445 }
07446
07447 pNtkRes = Abc_NtkIvyResyn( pNtk, fUpdateLevel, fVerbose );
07448 if ( pNtkRes == NULL )
07449 {
07450 fprintf( pErr, "Command has failed.\n" );
07451 return 0;
07452 }
07453
07454 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
07455 return 0;
07456
07457 usage:
07458 fprintf( pErr, "usage: iresyn [-lvh]\n" );
07459 fprintf( pErr, "\t performs combinational resynthesis\n" );
07460 fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
07461 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
07462 fprintf( pErr, "\t-h : print the command usage\n");
07463 return 1;
07464 }
07465
07477 int Abc_CommandISat( Abc_Frame_t * pAbc, int argc, char ** argv )
07478 {
07479 FILE * pOut, * pErr;
07480 Abc_Ntk_t * pNtk, * pNtkRes;
07481 int c, fUpdateLevel, fVerbose;
07482 int nConfLimit;
07483
07484 extern Abc_Ntk_t * Abc_NtkIvySat( Abc_Ntk_t * pNtk, int nConfLimit, int fVerbose );
07485
07486 pNtk = Abc_FrameReadNtk(pAbc);
07487 pOut = Abc_FrameReadOut(pAbc);
07488 pErr = Abc_FrameReadErr(pAbc);
07489
07490
07491 nConfLimit = 100000;
07492 fUpdateLevel = 1;
07493 fVerbose = 0;
07494 Extra_UtilGetoptReset();
07495 while ( ( c = Extra_UtilGetopt( argc, argv, "Clzvh" ) ) != EOF )
07496 {
07497 switch ( c )
07498 {
07499 case 'C':
07500 if ( globalUtilOptind >= argc )
07501 {
07502 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
07503 goto usage;
07504 }
07505 nConfLimit = atoi(argv[globalUtilOptind]);
07506 globalUtilOptind++;
07507 if ( nConfLimit < 0 )
07508 goto usage;
07509 break;
07510 case 'l':
07511 fUpdateLevel ^= 1;
07512 break;
07513 case 'v':
07514 fVerbose ^= 1;
07515 break;
07516 case 'h':
07517 goto usage;
07518 default:
07519 goto usage;
07520 }
07521 }
07522 if ( pNtk == NULL )
07523 {
07524 fprintf( pErr, "Empty network.\n" );
07525 return 1;
07526 }
07527 if ( !Abc_NtkIsStrash(pNtk) )
07528 {
07529 fprintf( pErr, "This command works only for strashed networks.\n" );
07530 return 1;
07531 }
07532
07533 pNtkRes = Abc_NtkIvySat( pNtk, nConfLimit, fVerbose );
07534 if ( pNtkRes == NULL )
07535 {
07536 fprintf( pErr, "Command has failed.\n" );
07537 return 0;
07538 }
07539
07540 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
07541 return 0;
07542
07543 usage:
07544 fprintf( pErr, "usage: isat [-C num] [-vh]\n" );
07545 fprintf( pErr, "\t tries to prove the miter constant 0\n" );
07546 fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
07547
07548 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
07549 fprintf( pErr, "\t-h : print the command usage\n");
07550 return 1;
07551 }
07552
07564 int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
07565 {
07566 FILE * pOut, * pErr;
07567 Abc_Ntk_t * pNtk, * pNtkRes;
07568 int c, fProve, fVerbose, fDoSparse;
07569 int nConfLimit;
07570
07571 extern Abc_Ntk_t * Abc_NtkIvyFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fVerbose );
07572
07573 pNtk = Abc_FrameReadNtk(pAbc);
07574 pOut = Abc_FrameReadOut(pAbc);
07575 pErr = Abc_FrameReadErr(pAbc);
07576
07577
07578 nConfLimit = 100;
07579 fDoSparse = 0;
07580 fProve = 0;
07581 fVerbose = 0;
07582 Extra_UtilGetoptReset();
07583 while ( ( c = Extra_UtilGetopt( argc, argv, "Cspvh" ) ) != EOF )
07584 {
07585 switch ( c )
07586 {
07587 case 'C':
07588 if ( globalUtilOptind >= argc )
07589 {
07590 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
07591 goto usage;
07592 }
07593 nConfLimit = atoi(argv[globalUtilOptind]);
07594 globalUtilOptind++;
07595 if ( nConfLimit < 0 )
07596 goto usage;
07597 break;
07598 case 's':
07599 fDoSparse ^= 1;
07600 break;
07601 case 'p':
07602 fProve ^= 1;
07603 break;
07604 case 'v':
07605 fVerbose ^= 1;
07606 break;
07607 case 'h':
07608 goto usage;
07609 default:
07610 goto usage;
07611 }
07612 }
07613 if ( pNtk == NULL )
07614 {
07615 fprintf( pErr, "Empty network.\n" );
07616 return 1;
07617 }
07618 if ( !Abc_NtkIsStrash(pNtk) )
07619 {
07620 fprintf( pErr, "This command works only for strashed networks.\n" );
07621 return 1;
07622 }
07623
07624 pNtkRes = Abc_NtkIvyFraig( pNtk, nConfLimit, fDoSparse, fProve, 0, fVerbose );
07625 if ( pNtkRes == NULL )
07626 {
07627 fprintf( pErr, "Command has failed.\n" );
07628 return 0;
07629 }
07630
07631 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
07632 return 0;
07633
07634 usage:
07635 fprintf( pErr, "usage: ifraig [-C num] [-spvh]\n" );
07636 fprintf( pErr, "\t performs fraiging using a new method\n" );
07637 fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
07638 fprintf( pErr, "\t-s : toggle considering sparse functions [default = %s]\n", fDoSparse? "yes": "no" );
07639 fprintf( pErr, "\t-p : toggle proving the miter outputs [default = %s]\n", fProve? "yes": "no" );
07640 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
07641 fprintf( pErr, "\t-h : print the command usage\n");
07642 return 1;
07643 }
07644
07656 int Abc_CommandDFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
07657 {
07658 FILE * pOut, * pErr;
07659 Abc_Ntk_t * pNtk, * pNtkRes;
07660 int c, nConfLimit, fDoSparse, fProve, fSpeculate, fChoicing, fVerbose;
07661
07662 extern Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fSpeculate, int fChoicing, int fVerbose );
07663
07664 pNtk = Abc_FrameReadNtk(pAbc);
07665 pOut = Abc_FrameReadOut(pAbc);
07666 pErr = Abc_FrameReadErr(pAbc);
07667
07668
07669 nConfLimit = 100;
07670 fDoSparse = 1;
07671 fProve = 0;
07672 fSpeculate = 0;
07673 fChoicing = 0;
07674 fVerbose = 0;
07675 Extra_UtilGetoptReset();
07676 while ( ( c = Extra_UtilGetopt( argc, argv, "Csprcvh" ) ) != EOF )
07677 {
07678 switch ( c )
07679 {
07680 case 'C':
07681 if ( globalUtilOptind >= argc )
07682 {
07683 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
07684 goto usage;
07685 }
07686 nConfLimit = atoi(argv[globalUtilOptind]);
07687 globalUtilOptind++;
07688 if ( nConfLimit < 0 )
07689 goto usage;
07690 break;
07691 case 's':
07692 fDoSparse ^= 1;
07693 break;
07694 case 'p':
07695 fProve ^= 1;
07696 break;
07697 case 'r':
07698 fSpeculate ^= 1;
07699 break;
07700 case 'c':
07701 fChoicing ^= 1;
07702 break;
07703 case 'v':
07704 fVerbose ^= 1;
07705 break;
07706 case 'h':
07707 goto usage;
07708 default:
07709 goto usage;
07710 }
07711 }
07712 if ( pNtk == NULL )
07713 {
07714 fprintf( pErr, "Empty network.\n" );
07715 return 1;
07716 }
07717 if ( !Abc_NtkIsStrash(pNtk) )
07718 {
07719 fprintf( pErr, "This command works only for strashed networks.\n" );
07720 return 1;
07721 }
07722
07723 pNtkRes = Abc_NtkDarFraig( pNtk, nConfLimit, fDoSparse, fProve, 0, fSpeculate, fChoicing, fVerbose );
07724 if ( pNtkRes == NULL )
07725 {
07726 fprintf( pErr, "Command has failed.\n" );
07727 return 0;
07728 }
07729
07730 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
07731 return 0;
07732
07733 usage:
07734 fprintf( pErr, "usage: dfraig [-C num] [-sprcvh]\n" );
07735 fprintf( pErr, "\t performs fraiging using a new method\n" );
07736 fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
07737 fprintf( pErr, "\t-s : toggle considering sparse functions [default = %s]\n", fDoSparse? "yes": "no" );
07738 fprintf( pErr, "\t-p : toggle proving the miter outputs [default = %s]\n", fProve? "yes": "no" );
07739 fprintf( pErr, "\t-r : toggle speculative reduction [default = %s]\n", fSpeculate? "yes": "no" );
07740 fprintf( pErr, "\t-c : toggle accumulation of choices [default = %s]\n", fChoicing? "yes": "no" );
07741 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
07742 fprintf( pErr, "\t-h : print the command usage\n");
07743 return 1;
07744 }
07745
07757 int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
07758 {
07759 FILE * pOut, * pErr;
07760 Abc_Ntk_t * pNtk, * pNtkRes;
07761 int c, nCutsMax, nLeafMax, fVerbose;
07762
07763 extern Abc_Ntk_t * Abc_NtkCSweep( Abc_Ntk_t * pNtk, int nCutsMax, int nLeafMax, int fVerbose );
07764
07765 pNtk = Abc_FrameReadNtk(pAbc);
07766 pOut = Abc_FrameReadOut(pAbc);
07767 pErr = Abc_FrameReadErr(pAbc);
07768
07769
07770 nCutsMax = 8;
07771 nLeafMax = 6;
07772 fVerbose = 0;
07773 Extra_UtilGetoptReset();
07774 while ( ( c = Extra_UtilGetopt( argc, argv, "CKvh" ) ) != EOF )
07775 {
07776 switch ( c )
07777 {
07778 case 'C':
07779 if ( globalUtilOptind >= argc )
07780 {
07781 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
07782 goto usage;
07783 }
07784 nCutsMax = atoi(argv[globalUtilOptind]);
07785 globalUtilOptind++;
07786 if ( nCutsMax < 0 )
07787 goto usage;
07788 break;
07789 case 'K':
07790 if ( globalUtilOptind >= argc )
07791 {
07792 fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
07793 goto usage;
07794 }
07795 nLeafMax = atoi(argv[globalUtilOptind]);
07796 globalUtilOptind++;
07797 if ( nLeafMax < 0 )
07798 goto usage;
07799 break;
07800 case 'v':
07801 fVerbose ^= 1;
07802 break;
07803 case 'h':
07804 goto usage;
07805 default:
07806 goto usage;
07807 }
07808 }
07809 if ( pNtk == NULL )
07810 {
07811 fprintf( pErr, "Empty network.\n" );
07812 return 1;
07813 }
07814
07815 if ( nCutsMax < 2 )
07816 {
07817 fprintf( pErr, "The number of cuts cannot be less than 2.\n" );
07818 return 1;
07819 }
07820
07821 if ( nLeafMax < 3 || nLeafMax > 16 )
07822 {
07823 fprintf( pErr, "The number of leaves is infeasible.\n" );
07824 return 1;
07825 }
07826 if ( !Abc_NtkIsStrash(pNtk) )
07827 {
07828 fprintf( pErr, "This command works only for strashed networks.\n" );
07829 return 1;
07830 }
07831
07832 pNtkRes = Abc_NtkCSweep( pNtk, nCutsMax, nLeafMax, fVerbose );
07833 if ( pNtkRes == NULL )
07834 {
07835 fprintf( pErr, "Command has failed.\n" );
07836 return 0;
07837 }
07838
07839 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
07840 return 0;
07841
07842 usage:
07843 fprintf( pErr, "usage: csweep [-C num] [-K num] [-vh]\n" );
07844 fprintf( pErr, "\t performs cut sweeping using a new method\n" );
07845 fprintf( pErr, "\t-C num : limit on the number of cuts (C >= 2) [default = %d]\n", nCutsMax );
07846 fprintf( pErr, "\t-K num : limit on the cut size (3 <= K <= 16) [default = %d]\n", nLeafMax );
07847 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
07848 fprintf( pErr, "\t-h : print the command usage\n");
07849 return 1;
07850 }
07851
07863 int Abc_CommandIProve( Abc_Frame_t * pAbc, int argc, char ** argv )
07864 {
07865 Prove_Params_t Params, * pParams = &Params;
07866 FILE * pOut, * pErr;
07867 Abc_Ntk_t * pNtk, * pNtkTemp;
07868 int c, clk, RetValue;
07869
07870 extern int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars );
07871
07872 pNtk = Abc_FrameReadNtk(pAbc);
07873 pOut = Abc_FrameReadOut(pAbc);
07874 pErr = Abc_FrameReadErr(pAbc);
07875
07876
07877 Prove_ParamsSetDefault( pParams );
07878 pParams->fUseRewriting = 1;
07879 pParams->fVerbose = 0;
07880 Extra_UtilGetoptReset();
07881 while ( ( c = Extra_UtilGetopt( argc, argv, "rvh" ) ) != EOF )
07882 {
07883 switch ( c )
07884 {
07885 case 'r':
07886 pParams->fUseRewriting ^= 1;
07887 break;
07888 case 'v':
07889 pParams->fVerbose ^= 1;
07890 break;
07891 case 'h':
07892 goto usage;
07893 default:
07894 goto usage;
07895 }
07896 }
07897 if ( pNtk == NULL )
07898 {
07899 fprintf( pErr, "Empty network.\n" );
07900 return 1;
07901 }
07902
07903 clk = clock();
07904
07905 if ( Abc_NtkIsStrash(pNtk) )
07906 pNtkTemp = Abc_NtkDup( pNtk );
07907 else
07908 pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
07909
07910 RetValue = Abc_NtkIvyProve( &pNtkTemp, pParams );
07911
07912
07913 if ( RetValue == 0 )
07914 {
07915 int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtkTemp->pModel );
07916 if ( pSimInfo[0] != 1 )
07917 printf( "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
07918 free( pSimInfo );
07919 }
07920
07921 if ( RetValue == -1 )
07922 printf( "UNDECIDED " );
07923 else if ( RetValue == 0 )
07924 printf( "SATISFIABLE " );
07925 else
07926 printf( "UNSATISFIABLE " );
07927
07928
07929 PRT( "Time", clock() - clk );
07930
07931 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp );
07932 return 0;
07933
07934 usage:
07935 fprintf( pErr, "usage: iprove [-rvh]\n" );
07936 fprintf( pErr, "\t performs CEC using a new method\n" );
07937 fprintf( pErr, "\t-r : toggle AIG rewriting [default = %s]\n", pParams->fUseRewriting? "yes": "no" );
07938 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pParams->fVerbose? "yes": "no" );
07939 fprintf( pErr, "\t-h : print the command usage\n");
07940 return 1;
07941 }
07942
07954 int Abc_CommandHaig( Abc_Frame_t * pAbc, int argc, char ** argv )
07955 {
07956 FILE * pOut, * pErr;
07957 Abc_Ntk_t * pNtk, * pNtkRes;
07958 int c, fUseZeroCost, fVerbose, nIters;
07959 extern Abc_Ntk_t * Abc_NtkIvyHaig( Abc_Ntk_t * pNtk, int nIters, int fUseZeroCost, int fVerbose );
07960
07961 pNtk = Abc_FrameReadNtk(pAbc);
07962 pOut = Abc_FrameReadOut(pAbc);
07963 pErr = Abc_FrameReadErr(pAbc);
07964
07965
07966 nIters = 2;
07967 fUseZeroCost = 0;
07968 fVerbose = 1;
07969 Extra_UtilGetoptReset();
07970 while ( ( c = Extra_UtilGetopt( argc, argv, "Izvh" ) ) != EOF )
07971 {
07972 switch ( c )
07973 {
07974 case 'I':
07975 if ( globalUtilOptind >= argc )
07976 {
07977 fprintf( pErr, "Command line switch \"-I\" should be followed by a positive integer.\n" );
07978 goto usage;
07979 }
07980 nIters = atoi(argv[globalUtilOptind]);
07981 globalUtilOptind++;
07982 if ( nIters < 0 )
07983 goto usage;
07984 break;
07985 case 'z':
07986 fUseZeroCost ^= 1;
07987 break;
07988 case 'v':
07989 fVerbose ^= 1;
07990 break;
07991 case 'h':
07992 goto usage;
07993 default:
07994 goto usage;
07995 }
07996 }
07997 if ( pNtk == NULL )
07998 {
07999 fprintf( pErr, "Empty network.\n" );
08000 return 1;
08001 }
08002 if ( !Abc_NtkIsStrash(pNtk) )
08003 {
08004 fprintf( pErr, "This command works only for strashed networks.\n" );
08005 return 1;
08006 }
08007
08008 pNtkRes = Abc_NtkIvyHaig( pNtk, nIters, fUseZeroCost, fVerbose );
08009 if ( pNtkRes == NULL )
08010 {
08011 fprintf( pErr, "Command has failed.\n" );
08012 return 0;
08013 }
08014
08015 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
08016 return 0;
08017
08018 usage:
08019 fprintf( pErr, "usage: haig [-Izvh]\n" );
08020 fprintf( pErr, "\t prints HAIG stats after sequential rewriting\n" );
08021 fprintf( pErr, "\t-I num : the number of rewriting iterations [default = %d]\n", nIters );
08022 fprintf( pErr, "\t-z : toggle zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
08023 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
08024 fprintf( pErr, "\t-h : print the command usage\n");
08025 return 1;
08026 }
08027
08039 int Abc_CommandMini( Abc_Frame_t * pAbc, int argc, char ** argv )
08040 {
08041 FILE * pOut, * pErr;
08042 Abc_Ntk_t * pNtk, * pNtkRes;
08043 int c;
08044 extern Abc_Ntk_t * Abc_NtkMiniBalance( Abc_Ntk_t * pNtk );
08045
08046 pNtk = Abc_FrameReadNtk(pAbc);
08047 pOut = Abc_FrameReadOut(pAbc);
08048 pErr = Abc_FrameReadErr(pAbc);
08049
08050
08051 Extra_UtilGetoptReset();
08052 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
08053 {
08054 switch ( c )
08055 {
08056 case 'h':
08057 goto usage;
08058 default:
08059 goto usage;
08060 }
08061 }
08062 if ( pNtk == NULL )
08063 {
08064 fprintf( pErr, "Empty network.\n" );
08065 return 1;
08066 }
08067 if ( !Abc_NtkIsStrash(pNtk) )
08068 {
08069 fprintf( pErr, "Only works for combinatinally strashed AIG networks.\n" );
08070 return 1;
08071 }
08072
08073 pNtkRes = Abc_NtkMiniBalance( pNtk );
08074 if ( pNtkRes == NULL )
08075 {
08076 fprintf( pErr, "Command has failed.\n" );
08077 return 0;
08078 }
08079
08080 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
08081 return 0;
08082
08083 usage:
08084 fprintf( pErr, "usage: mini [-h]\n" );
08085 fprintf( pErr, "\t perform balancing using new package\n" );
08086 fprintf( pErr, "\t-h : print the command usage\n");
08087 return 1;
08088 }
08089
08101 int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
08102 {
08103 FILE * pOut, * pErr;
08104 Abc_Ntk_t * pNtk;
08105 int c;
08106 int nFrames;
08107 int fInit;
08108 int fVerbose;
08109
08110 extern void Abc_NtkBmc( Abc_Ntk_t * pNtk, int nFrames, int fInit, int fVerbose );
08111
08112 pNtk = Abc_FrameReadNtk(pAbc);
08113 pOut = Abc_FrameReadOut(pAbc);
08114 pErr = Abc_FrameReadErr(pAbc);
08115
08116
08117 nFrames = 5;
08118 fInit = 0;
08119 fVerbose = 1;
08120 Extra_UtilGetoptReset();
08121 while ( ( c = Extra_UtilGetopt( argc, argv, "Kivh" ) ) != EOF )
08122 {
08123 switch ( c )
08124 {
08125 case 'K':
08126 if ( globalUtilOptind >= argc )
08127 {
08128 fprintf( pErr, "Command line switch \"-R\" should be followed by an integer.\n" );
08129 goto usage;
08130 }
08131 nFrames = atoi(argv[globalUtilOptind]);
08132 globalUtilOptind++;
08133 if ( nFrames < 0 )
08134 goto usage;
08135 break;
08136 case 'i':
08137 fInit ^= 1;
08138 break;
08139 case 'v':
08140 fVerbose ^= 1;
08141 break;
08142 case 'h':
08143 goto usage;
08144 default:
08145 goto usage;
08146 }
08147 }
08148 if ( pNtk == NULL )
08149 {
08150 fprintf( pErr, "Empty network.\n" );
08151 return 1;
08152 }
08153 if ( Abc_NtkIsStrash(pNtk) )
08154 Abc_NtkBmc( pNtk, nFrames, fInit, fVerbose );
08155 else
08156 {
08157 pNtk = Abc_NtkStrash( pNtk, 0, 1, 0 );
08158 Abc_NtkBmc( pNtk, nFrames, fInit, fVerbose );
08159 Abc_NtkDelete( pNtk );
08160 }
08161 return 0;
08162
08163 usage:
08164 fprintf( pErr, "usage: _bmc [-K num] [-ivh]\n" );
08165 fprintf( pErr, "\t perform bounded model checking\n" );
08166 fprintf( pErr, "\t-K num : number of time frames [default = %d]\n", nFrames );
08167 fprintf( pErr, "\t-i : toggle initialization of the first frame [default = %s]\n", fInit? "yes": "no" );
08168 fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
08169 fprintf( pErr, "\t-h : print the command usage\n");
08170 return 1;
08171 }
08172
08184 int Abc_CommandQbf( Abc_Frame_t * pAbc, int argc, char ** argv )
08185 {
08186 FILE * pOut, * pErr;
08187 Abc_Ntk_t * pNtk;
08188 int c;
08189 int nPars;
08190 int fVerbose;
08191
08192 extern void Abc_NtkQbf( Abc_Ntk_t * pNtk, int nPars, int fVerbose );
08193
08194 pNtk = Abc_FrameReadNtk(pAbc);
08195 pOut = Abc_FrameReadOut(pAbc);
08196 pErr = Abc_FrameReadErr(pAbc);
08197
08198
08199 nPars = -1;
08200 fVerbose = 1;
08201 Extra_UtilGetoptReset();
08202 while ( ( c = Extra_UtilGetopt( argc, argv, "Pvh" ) ) != EOF )
08203 {
08204 switch ( c )
08205 {
08206 case 'P':
08207 if ( globalUtilOptind >= argc )
08208 {
08209 fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
08210 goto usage;
08211 }
08212 nPars = atoi(argv[globalUtilOptind]);
08213 globalUtilOptind++;
08214 if ( nPars < 0 )
08215 goto usage;
08216 break;
08217 case 'v':
08218 fVerbose ^= 1;
08219 break;
08220 case 'h':
08221 goto usage;
08222 default:
08223 goto usage;
08224 }
08225 }
08226 if ( pNtk == NULL )
08227 {
08228 fprintf( pErr, "Empty network.\n" );
08229 return 1;
08230 }
08231 if ( !Abc_NtkIsComb(pNtk) )
08232 {
08233 fprintf( pErr, "Works only for combinational networks.\n" );
08234 return 1;
08235 }
08236 if ( Abc_NtkPoNum(pNtk) != 1 )
08237 {
08238 fprintf( pErr, "The miter should have one primary output.\n" );
08239 return 1;
08240 }
08241 if ( !(nPars > 0 && nPars < Abc_NtkPiNum(pNtk)) )
08242 {
08243 fprintf( pErr, "The number of paramter variables is invalid (should be > 0 and < PI num).\n" );
08244 return 1;
08245 }
08246 if ( Abc_NtkIsStrash(pNtk) )
08247 Abc_NtkQbf( pNtk, nPars, fVerbose );
08248 else
08249 {
08250 pNtk = Abc_NtkStrash( pNtk, 0, 1, 0 );
08251 Abc_NtkQbf( pNtk, nPars, fVerbose );
08252 Abc_NtkDelete( pNtk );
08253 }
08254 return 0;
08255
08256 usage:
08257 fprintf( pErr, "usage: qbf [-P num] [-vh]\n" );
08258 fprintf( pErr, "\t solves a quantified boolean formula problem EpVxM(p,x)\n" );
08259 fprintf( pErr, "\t-P num : number of paramters (should be the first PIs) [default = %d]\n", nPars );
08260 fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
08261 fprintf( pErr, "\t-h : print the command usage\n");
08262 return 1;
08263 }
08264
08265
08277 int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
08278 {
08279 char Buffer[100];
08280 Fraig_Params_t Params, * pParams = &Params;
08281 FILE * pOut, * pErr;
08282 Abc_Ntk_t * pNtk, * pNtkRes;
08283 int fAllNodes;
08284 int fExdc;
08285 int c;
08286 int fPartition = 0;
08287 extern void Abc_NtkFraigPartitionedTime( Abc_Ntk_t * pNtk, void * pParams );
08288
08289 pNtk = Abc_FrameReadNtk(pAbc);
08290 pOut = Abc_FrameReadOut(pAbc);
08291 pErr = Abc_FrameReadErr(pAbc);
08292
08293
08294 fExdc = 0;
08295 fAllNodes = 0;
08296 memset( pParams, 0, sizeof(Fraig_Params_t) );
08297 pParams->nPatsRand = 2048;
08298 pParams->nPatsDyna = 2048;
08299 pParams->nBTLimit = 100;
08300 pParams->fFuncRed = 1;
08301 pParams->fFeedBack = 1;
08302 pParams->fDist1Pats = 1;
08303 pParams->fDoSparse = 1;
08304 pParams->fChoicing = 0;
08305 pParams->fTryProve = 0;
08306 pParams->fVerbose = 0;
08307 pParams->fVerboseP = 0;
08308 Extra_UtilGetoptReset();
08309 while ( ( c = Extra_UtilGetopt( argc, argv, "RDCrscptvaeh" ) ) != EOF )
08310 {
08311 switch ( c )
08312 {
08313 case 'R':
08314 if ( globalUtilOptind >= argc )
08315 {
08316 fprintf( pErr, "Command line switch \"-R\" should be followed by an integer.\n" );
08317 goto usage;
08318 }
08319 pParams->nPatsRand = atoi(argv[globalUtilOptind]);
08320 globalUtilOptind++;
08321 if ( pParams->nPatsRand < 0 )
08322 goto usage;
08323 break;
08324 case 'D':
08325 if ( globalUtilOptind >= argc )
08326 {
08327 fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
08328 goto usage;
08329 }
08330 pParams->nPatsDyna = atoi(argv[globalUtilOptind]);
08331 globalUtilOptind++;
08332 if ( pParams->nPatsDyna < 0 )
08333 goto usage;
08334 break;
08335 case 'C':
08336 if ( globalUtilOptind >= argc )
08337 {
08338 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
08339 goto usage;
08340 }
08341 pParams->nBTLimit = atoi(argv[globalUtilOptind]);
08342 globalUtilOptind++;
08343 if ( pParams->nBTLimit < 0 )
08344 goto usage;
08345 break;
08346
08347 case 'r':
08348 pParams->fFuncRed ^= 1;
08349 break;
08350 case 's':
08351 pParams->fDoSparse ^= 1;
08352 break;
08353 case 'c':
08354 pParams->fChoicing ^= 1;
08355 break;
08356 case 'p':
08357 pParams->fTryProve ^= 1;
08358 break;
08359 case 'v':
08360 pParams->fVerbose ^= 1;
08361 break;
08362 case 't':
08363 fPartition ^= 1;
08364 break;
08365 case 'a':
08366 fAllNodes ^= 1;
08367 break;
08368 case 'e':
08369 fExdc ^= 1;
08370 break;
08371 case 'h':
08372 goto usage;
08373 default:
08374 goto usage;
08375 }
08376 }
08377
08378 if ( pNtk == NULL )
08379 {
08380 fprintf( pErr, "Empty network.\n" );
08381 return 1;
08382 }
08383 if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
08384 {
08385 fprintf( pErr, "Can only fraig a logic network or an AIG.\n" );
08386 return 1;
08387 }
08388
08389
08390 pParams->fVerboseP = pParams->fTryProve;
08391
08392
08393 if ( fPartition )
08394 {
08395 pNtkRes = Abc_NtkDup( pNtk );
08396 if ( Abc_NtkIsStrash(pNtk) )
08397 Abc_NtkFraigPartitionedTime( pNtk, &Params );
08398 else
08399 {
08400 pNtk = Abc_NtkStrash( pNtk, fAllNodes, !fAllNodes, 0 );
08401 Abc_NtkFraigPartitionedTime( pNtk, &Params );
08402 Abc_NtkDelete( pNtk );
08403 }
08404 }
08405 else
08406 {
08407 if ( Abc_NtkIsStrash(pNtk) )
08408 pNtkRes = Abc_NtkFraig( pNtk, &Params, fAllNodes, fExdc );
08409 else
08410 {
08411 pNtk = Abc_NtkStrash( pNtk, fAllNodes, !fAllNodes, 0 );
08412 pNtkRes = Abc_NtkFraig( pNtk, &Params, fAllNodes, fExdc );
08413 Abc_NtkDelete( pNtk );
08414 }
08415 }
08416 if ( pNtkRes == NULL )
08417 {
08418 fprintf( pErr, "Fraiging has failed.\n" );
08419 return 1;
08420 }
08421
08422 if ( pParams->fTryProve )
08423 Abc_NtkMiterReport( pNtkRes );
08424
08425
08426 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
08427 return 0;
08428
08429 usage:
08430 sprintf( Buffer, "%d", pParams->nBTLimit );
08431 fprintf( pErr, "usage: fraig [-R num] [-D num] [-C num] [-rscpvtah]\n" );
08432 fprintf( pErr, "\t transforms a logic network into a functionally reduced AIG\n" );
08433 fprintf( pErr, "\t-R num : number of random patterns (127 < num < 32769) [default = %d]\n", pParams->nPatsRand );
08434 fprintf( pErr, "\t-D num : number of systematic patterns (127 < num < 32769) [default = %d]\n", pParams->nPatsDyna );
08435 fprintf( pErr, "\t-C num : number of backtracks for one SAT problem [default = %s]\n", pParams->nBTLimit==-1? "infinity" : Buffer );
08436 fprintf( pErr, "\t-r : toggle functional reduction [default = %s]\n", pParams->fFuncRed? "yes": "no" );
08437 fprintf( pErr, "\t-s : toggle considering sparse functions [default = %s]\n", pParams->fDoSparse? "yes": "no" );
08438 fprintf( pErr, "\t-c : toggle accumulation of choices [default = %s]\n", pParams->fChoicing? "yes": "no" );
08439 fprintf( pErr, "\t-p : toggle proving the miter outputs [default = %s]\n", pParams->fTryProve? "yes": "no" );
08440 fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", pParams->fVerbose? "yes": "no" );
08441 fprintf( pErr, "\t-e : toggle functional sweeping using EXDC [default = %s]\n", fExdc? "yes": "no" );
08442 fprintf( pErr, "\t-a : toggle between all nodes and DFS nodes [default = %s]\n", fAllNodes? "all": "dfs" );
08443 fprintf( pErr, "\t-t : toggle using partitioned representation [default = %s]\n", fPartition? "yes": "no" );
08444 fprintf( pErr, "\t-h : print the command usage\n");
08445 return 1;
08446 }
08447
08459 int Abc_CommandFraigTrust( Abc_Frame_t * pAbc, int argc, char ** argv )
08460 {
08461 FILE * pOut, * pErr;
08462 Abc_Ntk_t * pNtk, * pNtkRes;
08463 int c;
08464 int fDuplicate;
08465
08466 pNtk = Abc_FrameReadNtk(pAbc);
08467 pOut = Abc_FrameReadOut(pAbc);
08468 pErr = Abc_FrameReadErr(pAbc);
08469
08470
08471 fDuplicate = 0;
08472 Extra_UtilGetoptReset();
08473 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
08474 {
08475 switch ( c )
08476 {
08477 case 'd':
08478 fDuplicate ^= 1;
08479 break;
08480 case 'h':
08481 goto usage;
08482 default:
08483 goto usage;
08484 }
08485 }
08486
08487 if ( pNtk == NULL )
08488 {
08489 fprintf( pErr, "Empty network.\n" );
08490 return 1;
08491 }
08492
08493
08494 pNtkRes = Abc_NtkFraigTrust( pNtk );
08495 if ( pNtkRes == NULL )
08496 {
08497 fprintf( pErr, "Fraiging in the trust mode has failed.\n" );
08498 return 1;
08499 }
08500
08501 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
08502 return 0;
08503
08504 usage:
08505 fprintf( pErr, "usage: fraig_trust [-h]\n" );
08506 fprintf( pErr, "\t transforms the current network into an AIG assuming it is FRAIG with choices\n" );
08507
08508 fprintf( pErr, "\t-h : print the command usage\n");
08509 return 1;
08510 }
08511
08523 int Abc_CommandFraigStore( Abc_Frame_t * pAbc, int argc, char ** argv )
08524 {
08525 FILE * pOut, * pErr;
08526 Abc_Ntk_t * pNtk;
08527 int c;
08528 int fDuplicate;
08529
08530 pNtk = Abc_FrameReadNtk(pAbc);
08531 pOut = Abc_FrameReadOut(pAbc);
08532 pErr = Abc_FrameReadErr(pAbc);
08533
08534
08535 fDuplicate = 0;
08536 Extra_UtilGetoptReset();
08537 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
08538 {
08539 switch ( c )
08540 {
08541 case 'd':
08542 fDuplicate ^= 1;
08543 break;
08544 case 'h':
08545 goto usage;
08546 default:
08547 goto usage;
08548 }
08549 }
08550
08551 if ( pNtk == NULL )
08552 {
08553 fprintf( pErr, "Empty network.\n" );
08554 return 1;
08555 }
08556
08557
08558 if ( !Abc_NtkFraigStore( pNtk ) )
08559 {
08560 fprintf( pErr, "Fraig storing has failed.\n" );
08561 return 1;
08562 }
08563 return 0;
08564
08565 usage:
08566 fprintf( pErr, "usage: fraig_store [-h]\n" );
08567 fprintf( pErr, "\t saves the current network in the AIG database\n" );
08568
08569 fprintf( pErr, "\t-h : print the command usage\n");
08570 return 1;
08571 }
08572
08584 int Abc_CommandFraigRestore( Abc_Frame_t * pAbc, int argc, char ** argv )
08585 {
08586 FILE * pOut, * pErr;
08587 Abc_Ntk_t * pNtk, * pNtkRes;
08588 int c;
08589 int fDuplicate;
08590
08591 pNtk = Abc_FrameReadNtk(pAbc);
08592 pOut = Abc_FrameReadOut(pAbc);
08593 pErr = Abc_FrameReadErr(pAbc);
08594
08595
08596 fDuplicate = 0;
08597 Extra_UtilGetoptReset();
08598 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
08599 {
08600 switch ( c )
08601 {
08602 case 'd':
08603 fDuplicate ^= 1;
08604 break;
08605 case 'h':
08606 goto usage;
08607 default:
08608 goto usage;
08609 }
08610 }
08611
08612 if ( pNtk == NULL )
08613 {
08614 fprintf( pErr, "Empty network.\n" );
08615 return 1;
08616 }
08617
08618
08619 pNtkRes = Abc_NtkFraigRestore();
08620 if ( pNtkRes == NULL )
08621 {
08622 fprintf( pErr, "Fraig restoring has failed.\n" );
08623 return 1;
08624 }
08625
08626 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
08627 return 0;
08628
08629 usage:
08630 fprintf( pErr, "usage: fraig_restore [-h]\n" );
08631 fprintf( pErr, "\t makes the current network by fraiging the AIG database\n" );
08632
08633 fprintf( pErr, "\t-h : print the command usage\n");
08634 return 1;
08635 }
08636
08648 int Abc_CommandFraigClean( Abc_Frame_t * pAbc, int argc, char ** argv )
08649 {
08650 FILE * pOut, * pErr;
08651 Abc_Ntk_t * pNtk;
08652 int c;
08653 int fDuplicate;
08654
08655 pNtk = Abc_FrameReadNtk(pAbc);
08656 pOut = Abc_FrameReadOut(pAbc);
08657 pErr = Abc_FrameReadErr(pAbc);
08658
08659
08660 fDuplicate = 0;
08661 Extra_UtilGetoptReset();
08662 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
08663 {
08664 switch ( c )
08665 {
08666 case 'd':
08667 fDuplicate ^= 1;
08668 break;
08669 case 'h':
08670 goto usage;
08671 default:
08672 goto usage;
08673 }
08674 }
08675 Abc_NtkFraigStoreClean();
08676 return 0;
08677
08678 usage:
08679 fprintf( pErr, "usage: fraig_clean [-h]\n" );
08680 fprintf( pErr, "\t cleans the internal FRAIG storage\n" );
08681
08682 fprintf( pErr, "\t-h : print the command usage\n");
08683 return 1;
08684 }
08685
08697 int Abc_CommandFraigSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
08698 {
08699 FILE * pOut, * pErr;
08700 Abc_Ntk_t * pNtk;
08701 int c;
08702 int fUseInv;
08703 int fExdc;
08704 int fVerbose;
08705 int fVeryVerbose;
08706 extern bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
08707
08708 pNtk = Abc_FrameReadNtk(pAbc);
08709 pOut = Abc_FrameReadOut(pAbc);
08710 pErr = Abc_FrameReadErr(pAbc);
08711
08712
08713 fUseInv = 1;
08714 fExdc = 0;
08715 fVerbose = 0;
08716 fVeryVerbose = 0;
08717 Extra_UtilGetoptReset();
08718 while ( ( c = Extra_UtilGetopt( argc, argv, "ievwh" ) ) != EOF )
08719 {
08720 switch ( c )
08721 {
08722 case 'i':
08723 fUseInv ^= 1;
08724 break;
08725 case 'e':
08726 fExdc ^= 1;
08727 break;
08728 case 'v':
08729 fVerbose ^= 1;
08730 break;
08731 case 'w':
08732 fVeryVerbose ^= 1;
08733 break;
08734 case 'h':
08735 goto usage;
08736 default:
08737 goto usage;
08738 }
08739 }
08740
08741 if ( pNtk == NULL )
08742 {
08743 fprintf( pErr, "Empty network.\n" );
08744 return 1;
08745 }
08746 if ( Abc_NtkIsStrash(pNtk) )
08747 {
08748 fprintf( pErr, "Cannot sweep AIGs (use \"fraig\").\n" );
08749 return 1;
08750 }
08751 if ( !Abc_NtkIsLogic(pNtk) )
08752 {
08753 fprintf( pErr, "Transform the current network into a logic network.\n" );
08754 return 1;
08755 }
08756
08757 if ( !Abc_NtkFraigSweep( pNtk, fUseInv, fExdc, fVerbose, fVeryVerbose ) )
08758 {
08759 fprintf( pErr, "Sweeping has failed.\n" );
08760 return 1;
08761 }
08762 return 0;
08763
08764 usage:
08765 fprintf( pErr, "usage: fraig_sweep [-evwh]\n" );
08766 fprintf( pErr, "\t performs technology-dependent sweep\n" );
08767 fprintf( pErr, "\t-e : toggle functional sweeping using EXDC [default = %s]\n", fExdc? "yes": "no" );
08768 fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
08769 fprintf( pErr, "\t-w : prints equivalence class information [default = %s]\n", fVeryVerbose? "yes": "no" );
08770 fprintf( pErr, "\t-h : print the command usage\n");
08771 return 1;
08772 }
08773
08785 int Abc_CommandFraigDress( Abc_Frame_t * pAbc, int argc, char ** argv )
08786 {
08787 FILE * pOut, * pErr;
08788 Abc_Ntk_t * pNtk;
08789 char * pFileName;
08790 int c;
08791 int fVerbose;
08792 extern void Abc_NtkDress( Abc_Ntk_t * pNtk, char * pFileName, int fVerbose );
08793
08794 pNtk = Abc_FrameReadNtk(pAbc);
08795 pOut = Abc_FrameReadOut(pAbc);
08796 pErr = Abc_FrameReadErr(pAbc);
08797
08798
08799 fVerbose = 0;
08800 Extra_UtilGetoptReset();
08801 while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
08802 {
08803 switch ( c )
08804 {
08805 case 'v':
08806 fVerbose ^= 1;
08807 break;
08808 case 'h':
08809 goto usage;
08810 default:
08811 goto usage;
08812 }
08813 }
08814 if ( pNtk == NULL )
08815 {
08816 fprintf( pErr, "Empty network.\n" );
08817 return 1;
08818 }
08819 if ( Abc_NtkIsStrash(pNtk) )
08820 {
08821 fprintf( pErr, "This command works only for logic networks.\n" );
08822 return 1;
08823 }
08824 if ( argc != globalUtilOptind && argc != globalUtilOptind + 1 )
08825 goto usage;
08826 if ( argc == globalUtilOptind && Abc_NtkSpec(pNtk) == NULL )
08827 {
08828 fprintf( pErr, "The current network has no spec.\n" );
08829 return 1;
08830 }
08831
08832 pFileName = (argc == globalUtilOptind + 1) ? argv[globalUtilOptind] : Abc_NtkSpec(pNtk);
08833
08834 Abc_NtkDress( pNtk, pFileName, fVerbose );
08835 return 0;
08836
08837 usage:
08838 fprintf( pErr, "usage: dress [-vh] <file>\n" );
08839 fprintf( pErr, "\t transfers internal node names from file to the current network\n" );
08840 fprintf( pErr, "\t<file> : network with names (if not given, the current network spec is used)\n" );
08841 fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
08842 fprintf( pErr, "\t-h : print the command usage\n");
08843 return 1;
08844 }
08845
08846
08858 int Abc_CommandHaigStart( Abc_Frame_t * pAbc, int argc, char ** argv )
08859 {
08860 FILE * pOut, * pErr;
08861 Abc_Ntk_t * pNtk;
08862 int c;
08863
08864 pNtk = Abc_FrameReadNtk(pAbc);
08865 pOut = Abc_FrameReadOut(pAbc);
08866 pErr = Abc_FrameReadErr(pAbc);
08867
08868
08869 Extra_UtilGetoptReset();
08870 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
08871 {
08872 switch ( c )
08873 {
08874 case 'h':
08875 goto usage;
08876 default:
08877 goto usage;
08878 }
08879 }
08880 if ( !Abc_NtkIsStrash(pNtk) )
08881 {
08882 fprintf( pErr, "This command works only for AIGs; run strashing (\"st\").\n" );
08883 return 0;
08884 }
08885 Abc_NtkHaigStart( pNtk );
08886 return 0;
08887
08888 usage:
08889 fprintf( pErr, "usage: haig_start [-h]\n" );
08890 fprintf( pErr, "\t starts constructive accumulation of combinational choices\n" );
08891 fprintf( pErr, "\t-h : print the command usage\n");
08892 return 1;
08893 }
08894
08906 int Abc_CommandHaigStop( Abc_Frame_t * pAbc, int argc, char ** argv )
08907 {
08908 FILE * pOut, * pErr;
08909 Abc_Ntk_t * pNtk;
08910 int c;
08911
08912 pNtk = Abc_FrameReadNtk(pAbc);
08913 pOut = Abc_FrameReadOut(pAbc);
08914 pErr = Abc_FrameReadErr(pAbc);
08915
08916
08917 Extra_UtilGetoptReset();
08918 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
08919 {
08920 switch ( c )
08921 {
08922 case 'h':
08923 goto usage;
08924 default:
08925 goto usage;
08926 }
08927 }
08928 if ( !Abc_NtkIsStrash(pNtk) )
08929 {
08930 fprintf( pErr, "This command works only for AIGs; run strashing (\"st\").\n" );
08931 return 0;
08932 }
08933 Abc_NtkHaigStop( pNtk );
08934 return 0;
08935
08936 usage:
08937 fprintf( pErr, "usage: haig_stop [-h]\n" );
08938 fprintf( pErr, "\t cleans the internal storage for combinational choices\n" );
08939 fprintf( pErr, "\t-h : print the command usage\n");
08940 return 1;
08941 }
08942
08954 int Abc_CommandHaigUse( Abc_Frame_t * pAbc, int argc, char ** argv )
08955 {
08956 FILE * pOut, * pErr;
08957 Abc_Ntk_t * pNtk, * pNtkRes;
08958 int c;
08959
08960 pNtk = Abc_FrameReadNtk(pAbc);
08961 pOut = Abc_FrameReadOut(pAbc);
08962 pErr = Abc_FrameReadErr(pAbc);
08963
08964
08965 Extra_UtilGetoptReset();
08966 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
08967 {
08968 switch ( c )
08969 {
08970 case 'h':
08971 goto usage;
08972 default:
08973 goto usage;
08974 }
08975 }
08976 if ( !Abc_NtkIsStrash(pNtk) )
08977 {
08978 fprintf( pErr, "This command works only for AIGs; run strashing (\"st\").\n" );
08979 return 0;
08980 }
08981
08982 pNtkRes = Abc_NtkHaigUse( pNtk );
08983 if ( pNtkRes == NULL )
08984 {
08985 fprintf( pErr, "Transforming internal storage into AIG with choices has failed.\n" );
08986 return 1;
08987 }
08988
08989 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
08990 return 0;
08991
08992 usage:
08993 fprintf( pErr, "usage: haig_use [-h]\n" );
08994 fprintf( pErr, "\t transforms internal storage into an AIG with choices\n" );
08995 fprintf( pErr, "\t-h : print the command usage\n");
08996 return 1;
08997 }
08998
08999
09000
09012 int Abc_CommandRecStart( Abc_Frame_t * pAbc, int argc, char ** argv )
09013 {
09014 FILE * pOut, * pErr;
09015 Abc_Ntk_t * pNtk;
09016 int c;
09017 int nVars;
09018 int nCuts;
09019
09020 pNtk = Abc_FrameReadNtk(pAbc);
09021 pOut = Abc_FrameReadOut(pAbc);
09022 pErr = Abc_FrameReadErr(pAbc);
09023
09024
09025 nVars = 4;
09026 nCuts = 8;
09027 Extra_UtilGetoptReset();
09028 while ( ( c = Extra_UtilGetopt( argc, argv, "KCh" ) ) != EOF )
09029 {
09030 switch ( c )
09031 {
09032 case 'K':
09033 if ( globalUtilOptind >= argc )
09034 {
09035 fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
09036 goto usage;
09037 }
09038 nVars = atoi(argv[globalUtilOptind]);
09039 globalUtilOptind++;
09040 if ( nVars < 1 )
09041 goto usage;
09042 break;
09043 case 'C':
09044 if ( globalUtilOptind >= argc )
09045 {
09046 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
09047 goto usage;
09048 }
09049 nCuts = atoi(argv[globalUtilOptind]);
09050 globalUtilOptind++;
09051 if ( nCuts < 1 )
09052 goto usage;
09053 break;
09054 case 'h':
09055 goto usage;
09056 default:
09057 goto usage;
09058 }
09059 }
09060 if ( !(nVars >= 3 && nVars <= 16) )
09061 {
09062 fprintf( pErr, "The range of allowed values is 3 <= K <= 16.\n" );
09063 return 0;
09064 }
09065 if ( Abc_NtkRecIsRunning() )
09066 {
09067 fprintf( pErr, "The AIG subgraph recording is already started.\n" );
09068 return 0;
09069 }
09070 if ( pNtk && !Abc_NtkIsStrash(pNtk) )
09071 {
09072 fprintf( pErr, "This command works only for AIGs; run strashing (\"st\").\n" );
09073 return 0;
09074 }
09075 Abc_NtkRecStart( pNtk, nVars, nCuts );
09076 return 0;
09077
09078 usage:
09079 fprintf( pErr, "usage: rec_start [-K num] [-C num] [-h]\n" );
09080 fprintf( pErr, "\t starts recording AIG subgraphs (should be called for\n" );
09081 fprintf( pErr, "\t an empty network or after reading in a previous record)\n" );
09082 fprintf( pErr, "\t-K num : the largest number of inputs [default = %d]\n", nVars );
09083 fprintf( pErr, "\t-C num : the max number of cuts used at a node (0 < num < 2^12) [default = %d]\n", nCuts );
09084 fprintf( pErr, "\t-h : print the command usage\n");
09085 return 1;
09086 }
09087
09099 int Abc_CommandRecStop( Abc_Frame_t * pAbc, int argc, char ** argv )
09100 {
09101 FILE * pOut, * pErr;
09102 Abc_Ntk_t * pNtk;
09103 int c;
09104
09105 pNtk = Abc_FrameReadNtk(pAbc);
09106 pOut = Abc_FrameReadOut(pAbc);
09107 pErr = Abc_FrameReadErr(pAbc);
09108
09109
09110 Extra_UtilGetoptReset();
09111 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
09112 {
09113 switch ( c )
09114 {
09115 case 'h':
09116 goto usage;
09117 default:
09118 goto usage;
09119 }
09120 }
09121 if ( !Abc_NtkRecIsRunning() )
09122 {
09123 fprintf( pErr, "This command works only after calling \"rec_start\".\n" );
09124 return 0;
09125 }
09126 Abc_NtkRecStop();
09127 return 0;
09128
09129 usage:
09130 fprintf( pErr, "usage: rec_stop [-h]\n" );
09131 fprintf( pErr, "\t cleans the internal storage for AIG subgraphs\n" );
09132 fprintf( pErr, "\t-h : print the command usage\n");
09133 return 1;
09134 }
09135
09147 int Abc_CommandRecAdd( Abc_Frame_t * pAbc, int argc, char ** argv )
09148 {
09149 FILE * pOut, * pErr;
09150 Abc_Ntk_t * pNtk;
09151 int c;
09152
09153 pNtk = Abc_FrameReadNtk(pAbc);
09154 pOut = Abc_FrameReadOut(pAbc);
09155 pErr = Abc_FrameReadErr(pAbc);
09156
09157
09158 Extra_UtilGetoptReset();
09159 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
09160 {
09161 switch ( c )
09162 {
09163 case 'h':
09164 goto usage;
09165 default:
09166 goto usage;
09167 }
09168 }
09169 if ( !Abc_NtkIsStrash(pNtk) )
09170 {
09171 fprintf( pErr, "This command works for AIGs.\n" );
09172 return 0;
09173 }
09174 if ( !Abc_NtkRecIsRunning() )
09175 {
09176 fprintf( pErr, "This command works for AIGs after calling \"rec_start\".\n" );
09177 return 0;
09178 }
09179 Abc_NtkRecAdd( pNtk );
09180 return 0;
09181
09182 usage:
09183 fprintf( pErr, "usage: rec_add [-h]\n" );
09184 fprintf( pErr, "\t adds subgraphs from the current network to the set\n" );
09185 fprintf( pErr, "\t-h : print the command usage\n");
09186 return 1;
09187 }
09188
09200 int Abc_CommandRecPs( Abc_Frame_t * pAbc, int argc, char ** argv )
09201 {
09202 FILE * pOut, * pErr;
09203 Abc_Ntk_t * pNtk;
09204 int c;
09205
09206 pNtk = Abc_FrameReadNtk(pAbc);
09207 pOut = Abc_FrameReadOut(pAbc);
09208 pErr = Abc_FrameReadErr(pAbc);
09209
09210
09211 Extra_UtilGetoptReset();
09212 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
09213 {
09214 switch ( c )
09215 {
09216 case 'h':
09217 goto usage;
09218 default:
09219 goto usage;
09220 }
09221 }
09222 if ( !Abc_NtkRecIsRunning() )
09223 {
09224 fprintf( pErr, "This command works for AIGs only after calling \"rec_start\".\n" );
09225 return 0;
09226 }
09227 Abc_NtkRecPs();
09228 return 0;
09229
09230 usage:
09231 fprintf( pErr, "usage: rec_ps [-h]\n" );
09232 fprintf( pErr, "\t prints statistics about the recorded AIG subgraphs\n" );
09233 fprintf( pErr, "\t-h : print the command usage\n");
09234 return 1;
09235 }
09236
09248 int Abc_CommandRecUse( Abc_Frame_t * pAbc, int argc, char ** argv )
09249 {
09250 FILE * pOut, * pErr;
09251 Abc_Ntk_t * pNtk, * pNtkRes;
09252 int c;
09253
09254 pNtk = Abc_FrameReadNtk(pAbc);
09255 pOut = Abc_FrameReadOut(pAbc);
09256 pErr = Abc_FrameReadErr(pAbc);
09257
09258
09259 Extra_UtilGetoptReset();
09260 while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
09261 {
09262 switch ( c )
09263 {
09264 case 'h':
09265 goto usage;
09266 default:
09267 goto usage;
09268 }
09269 }
09270 if ( !Abc_NtkRecIsRunning() )
09271 {
09272 fprintf( pErr, "This command works for AIGs only after calling \"rec_start\".\n" );
09273 return 0;
09274 }
09275
09276 pNtkRes = Abc_NtkRecUse();
09277 if ( pNtkRes == NULL )
09278 {
09279 fprintf( pErr, "Transforming internal AIG subgraphs into an AIG with choices has failed.\n" );
09280 return 1;
09281 }
09282
09283 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
09284 return 0;
09285
09286 usage:
09287 fprintf( pErr, "usage: rec_use [-h]\n" );
09288 fprintf( pErr, "\t transforms internal storage into an AIG with choices\n" );
09289 fprintf( pErr, "\t-h : print the command usage\n");
09290 return 1;
09291 }
09292
09293
09294
09306 int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
09307 {
09308 FILE * pOut, * pErr;
09309 Abc_Ntk_t * pNtk, * pNtkRes;
09310 char Buffer[100];
09311 double DelayTarget;
09312 int fRecovery;
09313 int fSweep;
09314 int fSwitching;
09315 int fVerbose;
09316 int c;
09317 extern Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, int fSwitching, int fVerbose );
09318 extern bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
09319
09320 pNtk = Abc_FrameReadNtk(pAbc);
09321 pOut = Abc_FrameReadOut(pAbc);
09322 pErr = Abc_FrameReadErr(pAbc);
09323
09324
09325 DelayTarget =-1;
09326 fRecovery = 1;
09327 fSweep = 1;
09328 fSwitching = 0;
09329 fVerbose = 0;
09330 Extra_UtilGetoptReset();
09331 while ( ( c = Extra_UtilGetopt( argc, argv, "Daspvh" ) ) != EOF )
09332 {
09333 switch ( c )
09334 {
09335 case 'D':
09336 if ( globalUtilOptind >= argc )
09337 {
09338 fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" );
09339 goto usage;
09340 }
09341 DelayTarget = (float)atof(argv[globalUtilOptind]);
09342 globalUtilOptind++;
09343 if ( DelayTarget <= 0.0 )
09344 goto usage;
09345 break;
09346 case 'a':
09347 fRecovery ^= 1;
09348 break;
09349 case 's':
09350 fSweep ^= 1;
09351 break;
09352 case 'p':
09353 fSwitching ^= 1;
09354 break;
09355 case 'v':
09356 fVerbose ^= 1;
09357 break;
09358 case 'h':
09359 goto usage;
09360 default:
09361 goto usage;
09362 }
09363 }
09364
09365 if ( pNtk == NULL )
09366 {
09367 fprintf( pErr, "Empty network.\n" );
09368 return 1;
09369 }
09370
09371 if ( !Abc_NtkIsStrash(pNtk) )
09372 {
09373 pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
09374 if ( pNtk == NULL )
09375 {
09376 fprintf( pErr, "Strashing before mapping has failed.\n" );
09377 return 1;
09378 }
09379 pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
09380 Abc_NtkDelete( pNtkRes );
09381 if ( pNtk == NULL )
09382 {
09383 fprintf( pErr, "Balancing before mapping has failed.\n" );
09384 return 1;
09385 }
09386 fprintf( pOut, "The network was strashed and balanced before mapping.\n" );
09387
09388 pNtkRes = Abc_NtkMap( pNtk, DelayTarget, fRecovery, fSwitching, fVerbose );
09389 if ( pNtkRes == NULL )
09390 {
09391 Abc_NtkDelete( pNtk );
09392 fprintf( pErr, "Mapping has failed.\n" );
09393 return 1;
09394 }
09395 Abc_NtkDelete( pNtk );
09396 }
09397 else
09398 {
09399
09400 pNtkRes = Abc_NtkMap( pNtk, DelayTarget, fRecovery, fSwitching, fVerbose );
09401 if ( pNtkRes == NULL )
09402 {
09403 fprintf( pErr, "Mapping has failed.\n" );
09404 return 1;
09405 }
09406 }
09407
09408 if ( fSweep )
09409 Abc_NtkFraigSweep( pNtkRes, 0, 0, 0, 0 );
09410
09411
09412 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
09413 return 0;
09414
09415 usage:
09416 if ( DelayTarget == -1 )
09417 sprintf( Buffer, "not used" );
09418 else
09419 sprintf( Buffer, "%.3f", DelayTarget );
09420 fprintf( pErr, "usage: map [-D float] [-aspvh]\n" );
09421 fprintf( pErr, "\t performs standard cell mapping of the current network\n" );
09422 fprintf( pErr, "\t-D float : sets the global required times [default = %s]\n", Buffer );
09423 fprintf( pErr, "\t-a : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
09424 fprintf( pErr, "\t-s : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" );
09425 fprintf( pErr, "\t-p : optimizes power by minimizing switching [default = %s]\n", fSwitching? "yes": "no" );
09426 fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
09427 fprintf( pErr, "\t-h : print the command usage\n");
09428 return 1;
09429 }
09430
09431
09443 int Abc_CommandUnmap( Abc_Frame_t * pAbc, int argc, char ** argv )
09444 {
09445 FILE * pOut, * pErr;
09446 Abc_Ntk_t * pNtk;
09447 int c;
09448
09449 pNtk = Abc_FrameReadNtk(pAbc);
09450 pOut = Abc_FrameReadOut(pAbc);
09451 pErr = Abc_FrameReadErr(pAbc);
09452
09453
09454 Extra_UtilGetoptReset();
09455 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
09456 {
09457 switch ( c )
09458 {
09459 case 'h':
09460 goto usage;
09461 default:
09462 goto usage;
09463 }
09464 }
09465
09466 if ( pNtk == NULL )
09467 {
09468 fprintf( pErr, "Empty network.\n" );
09469 return 1;
09470 }
09471 if ( !Abc_NtkHasMapping(pNtk) )
09472 {
09473 fprintf( pErr, "Cannot unmap the network that is not mapped.\n" );
09474 return 1;
09475 }
09476
09477
09478 if ( !Abc_NtkMapToSop( pNtk ) )
09479 {
09480 fprintf( pErr, "Unmapping has failed.\n" );
09481 return 1;
09482 }
09483 return 0;
09484
09485 usage:
09486 fprintf( pErr, "usage: unmap [-h]\n" );
09487 fprintf( pErr, "\t replaces the library gates by the logic nodes represented using SOPs\n" );
09488 fprintf( pErr, "\t-h : print the command usage\n");
09489 return 1;
09490 }
09491
09503 int Abc_CommandAttach( Abc_Frame_t * pAbc, int argc, char ** argv )
09504 {
09505 FILE * pOut, * pErr;
09506 Abc_Ntk_t * pNtk;
09507 int c;
09508
09509 pNtk = Abc_FrameReadNtk(pAbc);
09510 pOut = Abc_FrameReadOut(pAbc);
09511 pErr = Abc_FrameReadErr(pAbc);
09512
09513
09514 Extra_UtilGetoptReset();
09515 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
09516 {
09517 switch ( c )
09518 {
09519 case 'h':
09520 goto usage;
09521 default:
09522 goto usage;
09523 }
09524 }
09525
09526 if ( pNtk == NULL )
09527 {
09528 fprintf( pErr, "Empty network.\n" );
09529 return 1;
09530 }
09531
09532 if ( !Abc_NtkIsSopLogic(pNtk) )
09533 {
09534 fprintf( pErr, "Can only attach gates if the nodes have SOP representations.\n" );
09535 return 1;
09536 }
09537
09538
09539 if ( !Abc_NtkAttach( pNtk ) )
09540 {
09541 fprintf( pErr, "Attaching gates has failed.\n" );
09542 return 1;
09543 }
09544 return 0;
09545
09546 usage:
09547 fprintf( pErr, "usage: attach [-h]\n" );
09548 fprintf( pErr, "\t replaces the SOP functions by the gates from the library\n" );
09549 fprintf( pErr, "\t-h : print the command usage\n");
09550 return 1;
09551 }
09552
09553
09565 int Abc_CommandSuperChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
09566 {
09567 FILE * pOut, * pErr;
09568 Abc_Ntk_t * pNtk, * pNtkRes;
09569 int c;
09570 extern Abc_Ntk_t * Abc_NtkSuperChoice( Abc_Ntk_t * pNtk );
09571
09572 pNtk = Abc_FrameReadNtk(pAbc);
09573 pOut = Abc_FrameReadOut(pAbc);
09574 pErr = Abc_FrameReadErr(pAbc);
09575
09576
09577 Extra_UtilGetoptReset();
09578 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
09579 {
09580 switch ( c )
09581 {
09582 case 'h':
09583 goto usage;
09584 default:
09585 goto usage;
09586 }
09587 }
09588
09589 if ( pNtk == NULL )
09590 {
09591 fprintf( pErr, "Empty network.\n" );
09592 return 1;
09593 }
09594
09595 if ( !Abc_NtkIsStrash(pNtk) )
09596 {
09597 fprintf( pErr, "Superchoicing works only for the AIG representation (run \"strash\").\n" );
09598 return 1;
09599 }
09600
09601
09602 pNtkRes = Abc_NtkSuperChoice( pNtk );
09603 if ( pNtkRes == NULL )
09604 {
09605 fprintf( pErr, "Superchoicing has failed.\n" );
09606 return 1;
09607 }
09608
09609 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
09610 return 0;
09611
09612 usage:
09613 fprintf( pErr, "usage: sc [-h]\n" );
09614 fprintf( pErr, "\t performs superchoicing\n" );
09615 fprintf( pErr, "\t (accumulate: \"r file.blif; rsup; b; sc; f -ac; wb file_sc.blif\")\n" );
09616 fprintf( pErr, "\t (map without supergate library: \"r file_sc.blif; ft; map\")\n" );
09617 fprintf( pErr, "\t-h : print the command usage\n");
09618 return 1;
09619 }
09620
09632 int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
09633 {
09634 FILE * pOut, * pErr;
09635 Abc_Ntk_t * pNtk, * pNtkRes;
09636 int c;
09637 int nLutSize;
09638 int nCutSizeMax;
09639 int fVerbose;
09640 extern int Abc_NtkSuperChoiceLut( Abc_Ntk_t * pNtk, int nLutSize, int nCutSizeMax, int fVerbose );
09641
09642 pNtk = Abc_FrameReadNtk(pAbc);
09643 pOut = Abc_FrameReadOut(pAbc);
09644 pErr = Abc_FrameReadErr(pAbc);
09645
09646
09647 fVerbose = 1;
09648 nLutSize = 4;
09649 nCutSizeMax = 10;
09650 Extra_UtilGetoptReset();
09651 while ( ( c = Extra_UtilGetopt( argc, argv, "KNh" ) ) != EOF )
09652 {
09653 switch ( c )
09654 {
09655 case 'K':
09656 if ( globalUtilOptind >= argc )
09657 {
09658 fprintf( pErr, "Command line switch \"-K\" should be followed by a positive integer.\n" );
09659 goto usage;
09660 }
09661 nLutSize = atoi(argv[globalUtilOptind]);
09662 globalUtilOptind++;
09663 if ( nLutSize < 0 )
09664 goto usage;
09665 break;
09666 case 'N':
09667 if ( globalUtilOptind >= argc )
09668 {
09669 fprintf( pErr, "Command line switch \"-N\" should be followed by a positive integer.\n" );
09670 goto usage;
09671 }
09672 nCutSizeMax = atoi(argv[globalUtilOptind]);
09673 globalUtilOptind++;
09674 if ( nCutSizeMax < 0 )
09675 goto usage;
09676 break;
09677 case 'v':
09678 fVerbose ^= 1;
09679 break;
09680 case 'h':
09681 goto usage;
09682 default:
09683 goto usage;
09684 }
09685 }
09686
09687 if ( pNtk == NULL )
09688 {
09689 fprintf( pErr, "Empty network.\n" );
09690 return 1;
09691 }
09692
09693 if ( !Abc_NtkIsStrash(pNtk) )
09694 {
09695 fprintf( pErr, "Superchoicing works only for the AIG representation (run \"strash\").\n" );
09696 return 1;
09697 }
09698
09699
09700 pNtkRes = Abc_NtkToLogic( pNtk );
09701
09702
09703 if ( !Abc_NtkSuperChoiceLut( pNtkRes, nLutSize, nCutSizeMax, fVerbose ) )
09704 {
09705 Abc_NtkDelete( pNtkRes );
09706 fprintf( pErr, "Superchoicing has failed.\n" );
09707 return 1;
09708 }
09709
09710 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
09711 return 0;
09712
09713 usage:
09714 fprintf( pErr, "usage: scl [-K num] [-N num] [-vh]\n" );
09715 fprintf( pErr, "\t performs superchoicing for K-LUTs\n" );
09716 fprintf( pErr, "\t (accumulate: \"r file.blif; b; scl; f -ac; wb file_sc.blif\")\n" );
09717 fprintf( pErr, "\t (FPGA map: \"r file_sc.blif; ft; read_lut lutlibK; fpga\")\n" );
09718 fprintf( pErr, "\t-K num : the number of LUT inputs [default = %d]\n", nLutSize );
09719 fprintf( pErr, "\t-N num : the max size of the cut [default = %d]\n", nCutSizeMax );
09720 fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
09721 fprintf( pErr, "\t-h : print the command usage\n");
09722 return 1;
09723 }
09724
09736 int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
09737 {
09738 char Buffer[100];
09739 char LutSize[100];
09740 FILE * pOut, * pErr;
09741 Abc_Ntk_t * pNtk, * pNtkRes;
09742 int c;
09743 int fRecovery;
09744 int fSwitching;
09745 int fLatchPaths;
09746 int fVerbose;
09747 int nLutSize;
09748 float DelayTarget;
09749
09750 extern Abc_Ntk_t * Abc_NtkFpga( Abc_Ntk_t * pNtk, float DelayTarget, int fRecovery, int fSwitching, int fLatchPaths, int fVerbose );
09751
09752 pNtk = Abc_FrameReadNtk(pAbc);
09753 pOut = Abc_FrameReadOut(pAbc);
09754 pErr = Abc_FrameReadErr(pAbc);
09755
09756
09757 fRecovery = 1;
09758 fSwitching = 0;
09759 fLatchPaths = 0;
09760 fVerbose = 0;
09761 DelayTarget =-1;
09762 nLutSize =-1;
09763 Extra_UtilGetoptReset();
09764 while ( ( c = Extra_UtilGetopt( argc, argv, "aplvhDK" ) ) != EOF )
09765 {
09766 switch ( c )
09767 {
09768 case 'a':
09769 fRecovery ^= 1;
09770 break;
09771 case 'p':
09772 fSwitching ^= 1;
09773 break;
09774 case 'l':
09775 fLatchPaths ^= 1;
09776 break;
09777 case 'v':
09778 fVerbose ^= 1;
09779 break;
09780 case 'h':
09781 goto usage;
09782 case 'D':
09783 if ( globalUtilOptind >= argc )
09784 {
09785 fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" );
09786 goto usage;
09787 }
09788 DelayTarget = (float)atof(argv[globalUtilOptind]);
09789 globalUtilOptind++;
09790 if ( DelayTarget <= 0.0 )
09791 goto usage;
09792 break;
09793 case 'K':
09794 if ( globalUtilOptind >= argc )
09795 {
09796 fprintf( pErr, "Command line switch \"-K\" should be followed by a positive integer.\n" );
09797 goto usage;
09798 }
09799 nLutSize = atoi(argv[globalUtilOptind]);
09800 globalUtilOptind++;
09801 if ( nLutSize < 0 )
09802 goto usage;
09803 break;
09804 default:
09805 goto usage;
09806 }
09807 }
09808
09809 if ( pNtk == NULL )
09810 {
09811 fprintf( pErr, "Empty network.\n" );
09812 return 1;
09813 }
09814
09815
09816 if ( nLutSize >= 3 && nLutSize <= 10 )
09817 Fpga_SetSimpleLutLib( nLutSize );
09818
09819
09820
09821
09822
09823
09824
09825 if ( !Abc_NtkIsStrash(pNtk) )
09826 {
09827
09828 pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
09829 if ( pNtk == NULL )
09830 {
09831 fprintf( pErr, "Strashing before FPGA mapping has failed.\n" );
09832 return 1;
09833 }
09834 pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
09835 Abc_NtkDelete( pNtkRes );
09836 if ( pNtk == NULL )
09837 {
09838 fprintf( pErr, "Balancing before FPGA mapping has failed.\n" );
09839 return 1;
09840 }
09841 fprintf( pOut, "The network was strashed and balanced before FPGA mapping.\n" );
09842
09843 pNtkRes = Abc_NtkFpga( pNtk, DelayTarget, fRecovery, fSwitching, fLatchPaths, fVerbose );
09844 if ( pNtkRes == NULL )
09845 {
09846 Abc_NtkDelete( pNtk );
09847 fprintf( pErr, "FPGA mapping has failed.\n" );
09848 return 1;
09849 }
09850 Abc_NtkDelete( pNtk );
09851 }
09852 else
09853 {
09854
09855 pNtkRes = Abc_NtkFpga( pNtk, DelayTarget, fRecovery, fSwitching, fLatchPaths, fVerbose );
09856 if ( pNtkRes == NULL )
09857 {
09858 fprintf( pErr, "FPGA mapping has failed.\n" );
09859 return 1;
09860 }
09861 }
09862
09863 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
09864 return 0;
09865
09866 usage:
09867 if ( DelayTarget == -1 )
09868 sprintf( Buffer, "best possible" );
09869 else
09870 sprintf( Buffer, "%.2f", DelayTarget );
09871 if ( nLutSize == -1 )
09872 sprintf( LutSize, "library" );
09873 else
09874 sprintf( LutSize, "%d", nLutSize );
09875 fprintf( pErr, "usage: fpga [-D float] [-K num] [-aplvh]\n" );
09876 fprintf( pErr, "\t performs FPGA mapping of the current network\n" );
09877 fprintf( pErr, "\t-a : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
09878 fprintf( pErr, "\t-p : optimizes power by minimizing switching activity [default = %s]\n", fSwitching? "yes": "no" );
09879 fprintf( pErr, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", fLatchPaths? "yes": "no" );
09880 fprintf( pErr, "\t-D float : sets the required time for the mapping [default = %s]\n", Buffer );
09881 fprintf( pErr, "\t-K num : the number of LUT inputs (2 < num < 11) [default = %s]%s\n", LutSize, (nLutSize == -1 ? " (type \"print_lut\")" : "") );
09882 fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
09883 fprintf( pErr, "\t-h : prints the command usage\n");
09884 return 1;
09885 }
09886
09898 int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
09899 {
09900 char Buffer[100];
09901 FILE * pOut, * pErr;
09902 Abc_Ntk_t * pNtk, * pNtkRes;
09903 int c;
09904 int fRecovery;
09905 int fVerbose;
09906 int nLutSize;
09907 float DelayTarget;
09908
09909 extern Abc_Ntk_t * Abc_NtkFpgaFast( Abc_Ntk_t * pNtk, int nLutSize, int fRecovery, int fVerbose );
09910
09911 pNtk = Abc_FrameReadNtk(pAbc);
09912 pOut = Abc_FrameReadOut(pAbc);
09913 pErr = Abc_FrameReadErr(pAbc);
09914
09915
09916 fRecovery = 1;
09917 fVerbose = 0;
09918 DelayTarget =-1;
09919 nLutSize = 5;
09920 Extra_UtilGetoptReset();
09921 while ( ( c = Extra_UtilGetopt( argc, argv, "avhDK" ) ) != EOF )
09922 {
09923 switch ( c )
09924 {
09925 case 'a':
09926 fRecovery ^= 1;
09927 break;
09928 case 'v':
09929 fVerbose ^= 1;
09930 break;
09931 case 'h':
09932 goto usage;
09933 case 'D':
09934 if ( globalUtilOptind >= argc )
09935 {
09936 fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" );
09937 goto usage;
09938 }
09939 DelayTarget = (float)atof(argv[globalUtilOptind]);
09940 globalUtilOptind++;
09941 if ( DelayTarget <= 0.0 )
09942 goto usage;
09943 break;
09944 case 'K':
09945 if ( globalUtilOptind >= argc )
09946 {
09947 fprintf( pErr, "Command line switch \"-K\" should be followed by a positive integer.\n" );
09948 goto usage;
09949 }
09950 nLutSize = atoi(argv[globalUtilOptind]);
09951 globalUtilOptind++;
09952 if ( nLutSize < 0 )
09953 goto usage;
09954 break;
09955 default:
09956 goto usage;
09957 }
09958 }
09959
09960 if ( pNtk == NULL )
09961 {
09962 fprintf( pErr, "Empty network.\n" );
09963 return 1;
09964 }
09965
09966 if ( !Abc_NtkIsStrash(pNtk) )
09967 {
09968
09969 pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
09970 if ( pNtk == NULL )
09971 {
09972 fprintf( pErr, "Strashing before FPGA mapping has failed.\n" );
09973 return 1;
09974 }
09975 pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
09976 Abc_NtkDelete( pNtkRes );
09977 if ( pNtk == NULL )
09978 {
09979 fprintf( pErr, "Balancing before FPGA mapping has failed.\n" );
09980 return 1;
09981 }
09982 fprintf( pOut, "The network was strashed and balanced before FPGA mapping.\n" );
09983
09984 pNtkRes = Abc_NtkFpgaFast( pNtk, nLutSize, fRecovery, fVerbose );
09985 if ( pNtkRes == NULL )
09986 {
09987 Abc_NtkDelete( pNtk );
09988 fprintf( pErr, "FPGA mapping has failed.\n" );
09989 return 1;
09990 }
09991 Abc_NtkDelete( pNtk );
09992 }
09993 else
09994 {
09995
09996 pNtkRes = Abc_NtkFpgaFast( pNtk, nLutSize, fRecovery, fVerbose );
09997 if ( pNtkRes == NULL )
09998 {
09999 fprintf( pErr, "FPGA mapping has failed.\n" );
10000 return 1;
10001 }
10002 }
10003
10004 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
10005 return 0;
10006
10007 usage:
10008 if ( DelayTarget == -1 )
10009 sprintf( Buffer, "not used" );
10010 else
10011 sprintf( Buffer, "%.2f", DelayTarget );
10012 fprintf( pErr, "usage: ffpga [-K num] [-avh]\n" );
10013 fprintf( pErr, "\t performs fast FPGA mapping of the current network\n" );
10014 fprintf( pErr, "\t-a : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
10015
10016 fprintf( pErr, "\t-K num : the number of LUT inputs (2 < num < 32) [default = %d]\n", nLutSize );
10017 fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
10018 fprintf( pErr, "\t-h : prints the command usage\n");
10019 return 1;
10020 }
10021
10033 int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
10034 {
10035 char Buffer[100];
10036 char LutSize[100];
10037 FILE * pOut, * pErr;
10038 Abc_Ntk_t * pNtk, * pNtkRes;
10039 If_Par_t Pars, * pPars = &Pars;
10040 int c;
10041 extern Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars );
10042
10043 pNtk = Abc_FrameReadNtk(pAbc);
10044 pOut = Abc_FrameReadOut(pAbc);
10045 pErr = Abc_FrameReadErr(pAbc);
10046
10047
10048 memset( pPars, 0, sizeof(If_Par_t) );
10049
10050 pPars->nLutSize = -1;
10051 pPars->nCutsMax = 8;
10052 pPars->nFlowIters = 1;
10053 pPars->nAreaIters = 2;
10054 pPars->DelayTarget = -1;
10055 pPars->fPreprocess = 1;
10056 pPars->fArea = 0;
10057 pPars->fFancy = 0;
10058 pPars->fExpRed = 1;
10059 pPars->fLatchPaths = 0;
10060 pPars->fSeqMap = 0;
10061 pPars->fVerbose = 0;
10062
10063 pPars->fTruth = 0;
10064 pPars->nLatches = pNtk? Abc_NtkLatchNum(pNtk) : 0;
10065 pPars->fLiftLeaves = 0;
10066 pPars->pLutLib = Abc_FrameReadLibLut();
10067 pPars->pTimesArr = NULL;
10068 pPars->pTimesArr = NULL;
10069 pPars->pFuncCost = NULL;
10070
10071 Extra_UtilGetoptReset();
10072 while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADpaflrstvh" ) ) != EOF )
10073 {
10074 switch ( c )
10075 {
10076 case 'K':
10077 if ( globalUtilOptind >= argc )
10078 {
10079 fprintf( pErr, "Command line switch \"-K\" should be followed by a positive integer.\n" );
10080 goto usage;
10081 }
10082 pPars->nLutSize = atoi(argv[globalUtilOptind]);
10083 globalUtilOptind++;
10084 if ( pPars->nLutSize < 0 )
10085 goto usage;
10086
10087 pPars->pLutLib = NULL;
10088 break;
10089 case 'C':
10090 if ( globalUtilOptind >= argc )
10091 {
10092 fprintf( pErr, "Command line switch \"-C\" should be followed by a positive integer.\n" );
10093 goto usage;
10094 }
10095 pPars->nCutsMax = atoi(argv[globalUtilOptind]);
10096 globalUtilOptind++;
10097 if ( pPars->nCutsMax < 0 )
10098 goto usage;
10099 break;
10100 case 'F':
10101 if ( globalUtilOptind >= argc )
10102 {
10103 fprintf( pErr, "Command line switch \"-F\" should be followed by a positive integer.\n" );
10104 goto usage;
10105 }
10106 pPars->nFlowIters = atoi(argv[globalUtilOptind]);
10107 globalUtilOptind++;
10108 if ( pPars->nFlowIters < 0 )
10109 goto usage;
10110 break;
10111 case 'A':
10112 if ( globalUtilOptind >= argc )
10113 {
10114 fprintf( pErr, "Command line switch \"-A\" should be followed by a positive integer.\n" );
10115 goto usage;
10116 }
10117 pPars->nAreaIters = atoi(argv[globalUtilOptind]);
10118 globalUtilOptind++;
10119 if ( pPars->nAreaIters < 0 )
10120 goto usage;
10121 break;
10122 case 'D':
10123 if ( globalUtilOptind >= argc )
10124 {
10125 fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" );
10126 goto usage;
10127 }
10128 pPars->DelayTarget = (float)atof(argv[globalUtilOptind]);
10129 globalUtilOptind++;
10130 if ( pPars->DelayTarget <= 0.0 )
10131 goto usage;
10132 break;
10133 case 'p':
10134 pPars->fPreprocess ^= 1;
10135 break;
10136 case 'a':
10137 pPars->fArea ^= 1;
10138 break;
10139 case 'f':
10140 pPars->fFancy ^= 1;
10141 break;
10142 case 'l':
10143 pPars->fLatchPaths ^= 1;
10144 break;
10145 case 'r':
10146 pPars->fExpRed ^= 1;
10147 break;
10148 case 's':
10149 pPars->fSeqMap ^= 1;
10150 break;
10151 case 't':
10152 pPars->fLiftLeaves ^= 1;
10153 break;
10154 case 'v':
10155 pPars->fVerbose ^= 1;
10156 break;
10157 case 'h':
10158 default:
10159 goto usage;
10160 }
10161 }
10162
10163 if ( pNtk == NULL )
10164 {
10165 fprintf( pErr, "Empty network.\n" );
10166 return 1;
10167 }
10168
10169 if ( pPars->fSeqMap && pPars->nLatches == 0 )
10170 {
10171 fprintf( pErr, "The network has no latches. Use combinational mapping instead of sequential.\n" );
10172 return 1;
10173 }
10174
10175 if ( pPars->nLutSize == -1 )
10176 {
10177 if ( pPars->pLutLib == NULL )
10178 {
10179 fprintf( pErr, "The LUT library is not given.\n" );
10180 return 1;
10181 }
10182
10183 pPars->nLutSize = pPars->pLutLib->LutMax;
10184 }
10185
10186 if ( pPars->nLutSize < 3 || pPars->nLutSize > IF_MAX_LUTSIZE )
10187 {
10188 fprintf( pErr, "Incorrect LUT size (%d).\n", pPars->nLutSize );
10189 return 1;
10190 }
10191
10192 if ( pPars->nCutsMax < 1 || pPars->nCutsMax >= (1<<12) )
10193 {
10194 fprintf( pErr, "Incorrect number of cuts.\n" );
10195 return 1;
10196 }
10197
10198 if ( Abc_NtkGetChoiceNum( pNtk ) )
10199 {
10200 printf( "Performing FPGA mapping with choices.\n" );
10201
10202 pPars->fTruth = 1;
10203
10204 }
10205
10206 if ( pPars->fTruth && pPars->nLutSize > IF_MAX_FUNC_LUTSIZE )
10207 {
10208 fprintf( pErr, "Mapping with choices requires computing truth tables. In this case, the LUT size cannot be more than %d.\n", IF_MAX_FUNC_LUTSIZE );
10209 return 1;
10210 }
10211
10212 if ( !Abc_NtkIsStrash(pNtk) )
10213 {
10214
10215 pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
10216 if ( pNtk == NULL )
10217 {
10218 fprintf( pErr, "Strashing before FPGA mapping has failed.\n" );
10219 return 1;
10220 }
10221 pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
10222 Abc_NtkDelete( pNtkRes );
10223 if ( pNtk == NULL )
10224 {
10225 fprintf( pErr, "Balancing before FPGA mapping has failed.\n" );
10226 return 1;
10227 }
10228 fprintf( pOut, "The network was strashed and balanced before FPGA mapping.\n" );
10229
10230 pNtkRes = Abc_NtkIf( pNtk, pPars );
10231 if ( pNtkRes == NULL )
10232 {
10233 Abc_NtkDelete( pNtk );
10234 fprintf( pErr, "FPGA mapping has failed.\n" );
10235 return 0;
10236 }
10237 Abc_NtkDelete( pNtk );
10238 }
10239 else
10240 {
10241
10242 pNtkRes = Abc_NtkIf( pNtk, pPars );
10243 if ( pNtkRes == NULL )
10244 {
10245 fprintf( pErr, "FPGA mapping has failed.\n" );
10246 return 0;
10247 }
10248 }
10249
10250 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
10251 return 0;
10252
10253 usage:
10254 if ( pPars->DelayTarget == -1 )
10255 sprintf( Buffer, "best possible" );
10256 else
10257 sprintf( Buffer, "%.2f", pPars->DelayTarget );
10258 if ( pPars->nLutSize == -1 )
10259 sprintf( LutSize, "library" );
10260 else
10261 sprintf( LutSize, "%d", pPars->nLutSize );
10262 fprintf( pErr, "usage: if [-K num] [-C num] [-F num] [-A num] [-D float] [-pafrsvh]\n" );
10263 fprintf( pErr, "\t performs FPGA technology mapping of the network\n" );
10264 fprintf( pErr, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
10265 fprintf( pErr, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
10266 fprintf( pErr, "\t-F num : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
10267 fprintf( pErr, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
10268 fprintf( pErr, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
10269 fprintf( pErr, "\t-p : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
10270 fprintf( pErr, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
10271
10272 fprintf( pErr, "\t-r : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
10273 fprintf( pErr, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
10274 fprintf( pErr, "\t-s : toggles sequential mapping [default = %s]\n", pPars->fSeqMap? "yes": "no" );
10275
10276 fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
10277 fprintf( pErr, "\t-h : prints the command usage\n");
10278 return 1;
10279 }
10280
10281
10282
10294 int Abc_CommandInit( Abc_Frame_t * pAbc, int argc, char ** argv )
10295 {
10296 FILE * pOut, * pErr;
10297 Abc_Ntk_t * pNtk;
10298 Abc_Obj_t * pObj;
10299 int c, i;
10300 int fZeros;
10301 int fOnes;
10302 int fRandom;
10303 int fDontCare;
10304
10305 pNtk = Abc_FrameReadNtk(pAbc);
10306 pOut = Abc_FrameReadOut(pAbc);
10307 pErr = Abc_FrameReadErr(pAbc);
10308
10309
10310 fZeros = 0;
10311 fOnes = 0;
10312 fRandom = 0;
10313 fDontCare = 0;
10314 Extra_UtilGetoptReset();
10315 while ( ( c = Extra_UtilGetopt( argc, argv, "zordh" ) ) != EOF )
10316 {
10317 switch ( c )
10318 {
10319 case 'z':
10320 fZeros ^= 1;
10321 break;
10322 case 'o':
10323 fOnes ^= 1;
10324 break;
10325 case 'r':
10326 fRandom ^= 1;
10327 break;
10328 case 'd':
10329 fDontCare ^= 1;
10330 break;
10331 case 'h':
10332 goto usage;
10333 default:
10334 goto usage;
10335 }
10336 }
10337
10338 if ( pNtk == NULL )
10339 {
10340 fprintf( pErr, "Empty network.\n" );
10341 return 1;
10342 }
10343
10344 if ( Abc_NtkIsComb(pNtk) )
10345 {
10346 fprintf( pErr, "The current network is combinational.\n" );
10347 return 0;
10348 }
10349
10350 if ( fZeros )
10351 {
10352 Abc_NtkForEachLatch( pNtk, pObj, i )
10353 Abc_LatchSetInit0( pObj );
10354 }
10355 else if ( fOnes )
10356 {
10357 Abc_NtkForEachLatch( pNtk, pObj, i )
10358 Abc_LatchSetInit1( pObj );
10359 }
10360 else if ( fRandom )
10361 {
10362 Abc_NtkForEachLatch( pNtk, pObj, i )
10363 if ( rand() & 1 )
10364 Abc_LatchSetInit1( pObj );
10365 else
10366 Abc_LatchSetInit0( pObj );
10367 }
10368 else if ( fDontCare )
10369 {
10370 Abc_NtkForEachLatch( pNtk, pObj, i )
10371 Abc_LatchSetInitDc( pObj );
10372 }
10373 else
10374 printf( "The initial states remain unchanged.\n" );
10375 return 0;
10376
10377 usage:
10378 fprintf( pErr, "usage: init [-zordh]\n" );
10379 fprintf( pErr, "\t resets initial states of all latches\n" );
10380 fprintf( pErr, "\t-z : set zeros initial states [default = %s]\n", fZeros? "yes": "no" );
10381 fprintf( pErr, "\t-o : set ones initial states [default = %s]\n", fOnes? "yes": "no" );
10382 fprintf( pErr, "\t-d : set don't-care initial states [default = %s]\n", fDontCare? "yes": "no" );
10383 fprintf( pErr, "\t-r : set random initial states [default = %s]\n", fRandom? "yes": "no" );
10384 fprintf( pErr, "\t-h : print the command usage\n");
10385 return 1;
10386 }
10387
10399 int Abc_CommandZero( Abc_Frame_t * pAbc, int argc, char ** argv )
10400 {
10401 FILE * pOut, * pErr;
10402 Abc_Ntk_t * pNtk, * pNtkRes;
10403 int c;
10404
10405 extern Abc_Ntk_t * Abc_NtkRestrashZero( Abc_Ntk_t * pNtk, bool fCleanup );
10406
10407 pNtk = Abc_FrameReadNtk(pAbc);
10408 pOut = Abc_FrameReadOut(pAbc);
10409 pErr = Abc_FrameReadErr(pAbc);
10410
10411
10412 Extra_UtilGetoptReset();
10413 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
10414 {
10415 switch ( c )
10416 {
10417 case 'h':
10418 goto usage;
10419 default:
10420 goto usage;
10421 }
10422 }
10423
10424 if ( pNtk == NULL )
10425 {
10426 fprintf( pErr, "Empty network.\n" );
10427 return 1;
10428 }
10429
10430 if ( Abc_NtkIsComb(pNtk) )
10431 {
10432 fprintf( pErr, "The current network is combinational.\n" );
10433 return 0;
10434 }
10435
10436 if ( !Abc_NtkIsStrash(pNtk) )
10437 {
10438 fprintf( pErr, "This command works only for AIGs.\n" );
10439 return 0;
10440 }
10441
10442
10443 pNtkRes = Abc_NtkRestrashZero( pNtk, 0 );
10444 if ( pNtkRes == NULL )
10445 {
10446 fprintf( pErr, "Converting to sequential AIG has failed.\n" );
10447 return 1;
10448 }
10449
10450 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
10451 return 0;
10452
10453 usage:
10454 fprintf( pErr, "usage: zero [-h]\n" );
10455 fprintf( pErr, "\t converts latches to have const-0 initial value\n" );
10456 fprintf( pErr, "\t-h : print the command usage\n");
10457 return 1;
10458 }
10459
10471 int Abc_CommandUndc( Abc_Frame_t * pAbc, int argc, char ** argv )
10472 {
10473 FILE * pOut, * pErr;
10474 Abc_Ntk_t * pNtk;
10475 int c;
10476
10477 pNtk = Abc_FrameReadNtk(pAbc);
10478 pOut = Abc_FrameReadOut(pAbc);
10479 pErr = Abc_FrameReadErr(pAbc);
10480
10481
10482 Extra_UtilGetoptReset();
10483 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
10484 {
10485 switch ( c )
10486 {
10487 case 'h':
10488 goto usage;
10489 default:
10490 goto usage;
10491 }
10492 }
10493
10494 if ( pNtk == NULL )
10495 {
10496 fprintf( pErr, "Empty network.\n" );
10497 return 1;
10498 }
10499
10500 if ( Abc_NtkIsComb(pNtk) )
10501 {
10502 fprintf( pErr, "The current network is combinational.\n" );
10503 return 0;
10504 }
10505
10506 if ( !Abc_NtkIsLogic(pNtk) )
10507 {
10508 fprintf( pErr, "This command works only for logic networks.\n" );
10509 return 0;
10510 }
10511
10512
10513 Abc_NtkConvertDcLatches( pNtk );
10514 return 0;
10515
10516 usage:
10517 fprintf( pErr, "usage: undc [-h]\n" );
10518 fprintf( pErr, "\t converts latches with DC init values into free PIs\n" );
10519 fprintf( pErr, "\t-h : print the command usage\n");
10520 return 1;
10521 }
10522
10534 int Abc_CommandPipe( Abc_Frame_t * pAbc, int argc, char ** argv )
10535 {
10536 FILE * pOut, * pErr;
10537 Abc_Ntk_t * pNtk;
10538 int c;
10539 int nLatches;
10540 extern void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches );
10541
10542 pNtk = Abc_FrameReadNtk(pAbc);
10543 pOut = Abc_FrameReadOut(pAbc);
10544 pErr = Abc_FrameReadErr(pAbc);
10545
10546
10547 nLatches = 5;
10548 Extra_UtilGetoptReset();
10549 while ( ( c = Extra_UtilGetopt( argc, argv, "Lh" ) ) != EOF )
10550 {
10551 switch ( c )
10552 {
10553 case 'L':
10554 if ( globalUtilOptind >= argc )
10555 {
10556 fprintf( pErr, "Command line switch \"-L\" should be followed by a positive integer.\n" );
10557 goto usage;
10558 }
10559 nLatches = atoi(argv[globalUtilOptind]);
10560 globalUtilOptind++;
10561 if ( nLatches < 0 )
10562 goto usage;
10563 break;
10564 case 'h':
10565 goto usage;
10566 default:
10567 goto usage;
10568 }
10569 }
10570
10571 if ( pNtk == NULL )
10572 {
10573 fprintf( pErr, "Empty network.\n" );
10574 return 1;
10575 }
10576
10577 if ( Abc_NtkIsComb(pNtk) )
10578 {
10579 fprintf( pErr, "The current network is combinational.\n" );
10580 return 1;
10581 }
10582
10583
10584 Abc_NtkLatchPipe( pNtk, nLatches );
10585 return 0;
10586
10587 usage:
10588 fprintf( pErr, "usage: pipe [-L num] [-h]\n" );
10589 fprintf( pErr, "\t inserts the given number of latches at each PI for pipelining\n" );
10590 fprintf( pErr, "\t-L num : the number of latches to insert [default = %d]\n", nLatches );
10591 fprintf( pErr, "\t-h : print the command usage\n");
10592 return 1;
10593 }
10594
10606 int Abc_CommandSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
10607 {
10608 FILE * pOut, * pErr;
10609 Abc_Ntk_t * pNtk, * pNtkRes;
10610 int c;
10611
10612 pNtk = Abc_FrameReadNtk(pAbc);
10613 pOut = Abc_FrameReadOut(pAbc);
10614 pErr = Abc_FrameReadErr(pAbc);
10615
10616
10617 Extra_UtilGetoptReset();
10618 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
10619 {
10620 switch ( c )
10621 {
10622 case 'h':
10623 goto usage;
10624 default:
10625 goto usage;
10626 }
10627 }
10628
10629 if ( pNtk == NULL )
10630 {
10631 fprintf( pErr, "Empty network.\n" );
10632 return 1;
10633 }
10634
10635 if ( Abc_NtkLatchNum(pNtk) == 0 )
10636 {
10637 fprintf( pErr, "The network has no latches.\n" );
10638 return 0;
10639 }
10640
10641 if ( !Abc_NtkIsStrash(pNtk) )
10642 {
10643 fprintf( pErr, "Conversion to sequential AIG works only for combinational AIGs (run \"strash\").\n" );
10644 return 1;
10645 }
10646
10647
10648
10649 pNtkRes = NULL;
10650 if ( pNtkRes == NULL )
10651 {
10652 fprintf( pErr, "Converting to sequential AIG has failed.\n" );
10653 return 1;
10654 }
10655
10656 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
10657 return 0;
10658
10659 usage:
10660 fprintf( pErr, "usage: seq [-h]\n" );
10661 fprintf( pErr, "\t converts AIG into sequential AIG\n" );
10662 fprintf( pErr, "\t-h : print the command usage\n");
10663 return 1;
10664 }
10665
10677 int Abc_CommandUnseq( Abc_Frame_t * pAbc, int argc, char ** argv )
10678 {
10679 FILE * pOut, * pErr;
10680 Abc_Ntk_t * pNtk, * pNtkRes;
10681 int c;
10682 int fShare;
10683
10684 pNtk = Abc_FrameReadNtk(pAbc);
10685 pOut = Abc_FrameReadOut(pAbc);
10686 pErr = Abc_FrameReadErr(pAbc);
10687
10688
10689 fShare = 1;
10690 Extra_UtilGetoptReset();
10691 while ( ( c = Extra_UtilGetopt( argc, argv, "sh" ) ) != EOF )
10692 {
10693 switch ( c )
10694 {
10695 case 's':
10696 fShare ^= 1;
10697 break;
10698 case 'h':
10699 goto usage;
10700 default:
10701 goto usage;
10702 }
10703 }
10704
10705 if ( pNtk == NULL )
10706 {
10707 fprintf( pErr, "Empty network.\n" );
10708 return 1;
10709 }
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723 pNtkRes = NULL;
10724 if ( pNtkRes == NULL )
10725 {
10726 fprintf( pErr, "Converting sequential AIG into an SOP logic network has failed.\n" );
10727 return 1;
10728 }
10729
10730 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
10731 return 0;
10732
10733 usage:
10734 fprintf( pErr, "usage: unseq [-sh]\n" );
10735 fprintf( pErr, "\t converts sequential AIG into an SOP logic network\n" );
10736 fprintf( pErr, "\t-s : toggle sharing latches [default = %s]\n", fShare? "yes": "no" );
10737 fprintf( pErr, "\t-h : print the command usage\n");
10738 return 1;
10739 }
10740
10752 int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
10753 {
10754 FILE * pOut, * pErr;
10755 Abc_Ntk_t * pNtk, * pNtkRes;
10756 int c, nMaxIters;
10757 int fForward;
10758 int fBackward;
10759 int fOneStep;
10760 int fVerbose;
10761 int Mode;
10762 extern int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose );
10763
10764 pNtk = Abc_FrameReadNtk(pAbc);
10765 pOut = Abc_FrameReadOut(pAbc);
10766 pErr = Abc_FrameReadErr(pAbc);
10767
10768
10769 Mode = 5;
10770 fForward = 0;
10771 fBackward = 0;
10772 fOneStep = 0;
10773 fVerbose = 0;
10774 nMaxIters = 15;
10775 Extra_UtilGetoptReset();
10776 while ( ( c = Extra_UtilGetopt( argc, argv, "Mfbsvh" ) ) != EOF )
10777 {
10778 switch ( c )
10779 {
10780 case 'M':
10781 if ( globalUtilOptind >= argc )
10782 {
10783 fprintf( pErr, "Command line switch \"-M\" should be followed by a positive integer.\n" );
10784 goto usage;
10785 }
10786 Mode = atoi(argv[globalUtilOptind]);
10787 globalUtilOptind++;
10788 if ( Mode < 0 )
10789 goto usage;
10790 break;
10791 case 'f':
10792 fForward ^= 1;
10793 break;
10794 case 'b':
10795 fBackward ^= 1;
10796 break;
10797 case 's':
10798 fOneStep ^= 1;
10799 break;
10800 case 'v':
10801 fVerbose ^= 1;
10802 break;
10803 case 'h':
10804 goto usage;
10805 default:
10806 goto usage;
10807 }
10808 }
10809
10810 if ( pNtk == NULL )
10811 {
10812 fprintf( pErr, "Empty network.\n" );
10813 return 1;
10814 }
10815
10816 if ( fForward && fBackward )
10817 {
10818 fprintf( pErr, "Only one switch \"-f\" or \"-b\" can be selected at a time.\n" );
10819 return 1;
10820 }
10821
10822 if ( !Abc_NtkLatchNum(pNtk) )
10823 {
10824 fprintf( pErr, "The network has no latches. Retiming is not performed.\n" );
10825 return 0;
10826 }
10827
10828 if ( Mode < 0 || Mode > 6 )
10829 {
10830 fprintf( pErr, "The mode (%d) is incorrect. Retiming is not performed.\n", Mode );
10831 return 0;
10832 }
10833
10834 if ( Abc_NtkIsStrash(pNtk) )
10835 {
10836 if ( Abc_NtkGetChoiceNum(pNtk) )
10837 {
10838 fprintf( pErr, "Retiming with choice nodes is not implemented.\n" );
10839 return 0;
10840 }
10841
10842 pNtkRes = Abc_NtkToLogic( pNtk );
10843
10844 Abc_NtkRetime( pNtkRes, Mode, fForward, fBackward, fOneStep, fVerbose );
10845
10846 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
10847 return 0;
10848 }
10849
10850
10851 if ( !Abc_NtkToSop(pNtk, 0) )
10852 {
10853 printf( "Converting to SOPs has failed.\n" );
10854 return 0;
10855 }
10856
10857 if ( !Abc_NtkIsLogic(pNtk) )
10858 {
10859 fprintf( pErr, "The network is not a logic network. Retiming is not performed.\n" );
10860 return 0;
10861 }
10862
10863
10864 Abc_NtkRetime( pNtk, Mode, fForward, fBackward, fOneStep, fVerbose );
10865 return 0;
10866
10867 usage:
10868 fprintf( pErr, "usage: retime [-M num] [-fbvh]\n" );
10869 fprintf( pErr, "\t retimes the current network using one of the algorithms:\n" );
10870 fprintf( pErr, "\t 1: most forward retiming\n" );
10871 fprintf( pErr, "\t 2: most backward retiming\n" );
10872 fprintf( pErr, "\t 3: forward and backward min-area retiming\n" );
10873 fprintf( pErr, "\t 4: forward and backward min-delay retiming\n" );
10874 fprintf( pErr, "\t 5: mode 3 followed by mode 4\n" );
10875 fprintf( pErr, "\t 6: Pan's optimum-delay retiming using binary search\n" );
10876 fprintf( pErr, "\t-M num : the retiming algorithm to use [default = %d]\n", Mode );
10877 fprintf( pErr, "\t-f : enables forward-only retiming in modes 3,4,5 [default = %s]\n", fForward? "yes": "no" );
10878 fprintf( pErr, "\t-b : enables backward-only retiming in modes 3,4,5 [default = %s]\n", fBackward? "yes": "no" );
10879 fprintf( pErr, "\t-s : enables retiming one step only in mode 4 [default = %s]\n", fOneStep? "yes": "no" );
10880 fprintf( pErr, "\t-v : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
10881 fprintf( pErr, "\t-h : print the command usage\n");
10882 return 1;
10883
10884
10885
10886
10887 }
10888
10900 int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
10901 {
10902 FILE * pOut, * pErr;
10903 Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
10904 int c, nMaxIters;
10905 int fVerbose;
10906
10907 pNtk = Abc_FrameReadNtk(pAbc);
10908 pOut = Abc_FrameReadOut(pAbc);
10909 pErr = Abc_FrameReadErr(pAbc);
10910
10911
10912 nMaxIters = 15;
10913 fVerbose = 0;
10914 Extra_UtilGetoptReset();
10915 while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF )
10916 {
10917 switch ( c )
10918 {
10919 case 'I':
10920 if ( globalUtilOptind >= argc )
10921 {
10922 fprintf( pErr, "Command line switch \"-I\" should be followed by a positive integer.\n" );
10923 goto usage;
10924 }
10925 nMaxIters = atoi(argv[globalUtilOptind]);
10926 globalUtilOptind++;
10927 if ( nMaxIters < 0 )
10928 goto usage;
10929 break;
10930 case 'v':
10931 fVerbose ^= 1;
10932 break;
10933 case 'h':
10934 goto usage;
10935 default:
10936 goto usage;
10937 }
10938 }
10939
10940 if ( pNtk == NULL )
10941 {
10942 fprintf( pErr, "Empty network.\n" );
10943 return 1;
10944 }
10945
10946 if ( Abc_NtkHasAig(pNtk) )
10947 {
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960 pNtkNew = NULL;
10961 }
10962 else
10963 {
10964
10965 pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
10966 if ( pNtkNew == NULL )
10967 {
10968 fprintf( pErr, "Strashing before FPGA mapping/retiming has failed.\n" );
10969 return 1;
10970 }
10971
10972 pNtkNew = Abc_NtkBalance( pNtkRes = pNtkNew, 0, 0, 1 );
10973 Abc_NtkDelete( pNtkRes );
10974 if ( pNtkNew == NULL )
10975 {
10976 fprintf( pErr, "Balancing before FPGA mapping has failed.\n" );
10977 return 1;
10978 }
10979
10980
10981
10982 pNtkNew = NULL;
10983 Abc_NtkDelete( pNtkRes );
10984 if ( pNtkNew == NULL )
10985 {
10986 fprintf( pErr, "Converting into a seq AIG before FPGA mapping/retiming has failed.\n" );
10987 return 1;
10988 }
10989
10990 fprintf( pOut, "The network was strashed and balanced before FPGA mapping/retiming.\n" );
10991 }
10992
10993
10994
10995 pNtkRes = NULL;
10996 if ( pNtkRes == NULL )
10997 {
10998
10999 Abc_NtkDelete( pNtkNew );
11000 return 0;
11001 }
11002 Abc_NtkDelete( pNtkNew );
11003
11004 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
11005 return 0;
11006
11007 usage:
11008 fprintf( pErr, "usage: sfpga [-I num] [-vh]\n" );
11009 fprintf( pErr, "\t performs integrated sequential FPGA mapping/retiming\n" );
11010 fprintf( pErr, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
11011 fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
11012 fprintf( pErr, "\t-h : print the command usage\n");
11013 return 1;
11014 }
11015
11027 int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
11028 {
11029 FILE * pOut, * pErr;
11030 Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
11031 int c, nMaxIters;
11032 int fVerbose;
11033
11034 pNtk = Abc_FrameReadNtk(pAbc);
11035 pOut = Abc_FrameReadOut(pAbc);
11036 pErr = Abc_FrameReadErr(pAbc);
11037
11038
11039 nMaxIters = 15;
11040 fVerbose = 0;
11041 Extra_UtilGetoptReset();
11042 while ( ( c = Extra_UtilGetopt( argc, argv, "Ivh" ) ) != EOF )
11043 {
11044 switch ( c )
11045 {
11046 case 'I':
11047 if ( globalUtilOptind >= argc )
11048 {
11049 fprintf( pErr, "Command line switch \"-I\" should be followed by a positive integer.\n" );
11050 goto usage;
11051 }
11052 nMaxIters = atoi(argv[globalUtilOptind]);
11053 globalUtilOptind++;
11054 if ( nMaxIters < 0 )
11055 goto usage;
11056 break;
11057 case 'v':
11058 fVerbose ^= 1;
11059 break;
11060 case 'h':
11061 goto usage;
11062 default:
11063 goto usage;
11064 }
11065 }
11066
11067 if ( pNtk == NULL )
11068 {
11069 fprintf( pErr, "Empty network.\n" );
11070 return 1;
11071 }
11072
11073 if ( Abc_NtkHasAig(pNtk) )
11074 {
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087 pNtkNew = NULL;
11088 }
11089 else
11090 {
11091
11092 pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
11093 if ( pNtkNew == NULL )
11094 {
11095 fprintf( pErr, "Strashing before SC mapping/retiming has failed.\n" );
11096 return 1;
11097 }
11098
11099 pNtkNew = Abc_NtkBalance( pNtkRes = pNtkNew, 0, 0, 1 );
11100 Abc_NtkDelete( pNtkRes );
11101 if ( pNtkNew == NULL )
11102 {
11103 fprintf( pErr, "Balancing before SC mapping/retiming has failed.\n" );
11104 return 1;
11105 }
11106
11107
11108
11109 pNtkNew = NULL;
11110 Abc_NtkDelete( pNtkRes );
11111 if ( pNtkNew == NULL )
11112 {
11113 fprintf( pErr, "Converting into a seq AIG before SC mapping/retiming has failed.\n" );
11114 return 1;
11115 }
11116
11117 fprintf( pOut, "The network was strashed and balanced before SC mapping/retiming.\n" );
11118 }
11119
11120
11121
11122 pNtkRes = NULL;
11123 if ( pNtkRes == NULL )
11124 {
11125
11126 Abc_NtkDelete( pNtkNew );
11127 return 0;
11128 }
11129 Abc_NtkDelete( pNtkNew );
11130
11131
11132 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
11133 return 0;
11134
11135 usage:
11136 fprintf( pErr, "usage: smap [-I num] [-vh]\n" );
11137 fprintf( pErr, "\t performs integrated sequential standard-cell mapping/retiming\n" );
11138 fprintf( pErr, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
11139 fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
11140 fprintf( pErr, "\t-h : print the command usage\n");
11141 return 1;
11142 }
11143
11155 int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
11156 {
11157 FILE * pOut, * pErr;
11158 Abc_Ntk_t * pNtk, * pNtkRes;
11159 int c;
11160 int nFramesP;
11161 int nFramesK;
11162 int nMaxImps;
11163 int fUseImps;
11164 int fRewrite;
11165 int fLatchCorr;
11166 int fWriteImps;
11167 int fVerbose;
11168 extern Abc_Ntk_t * Abc_NtkDarSeqSweep( Abc_Ntk_t * pNtk, int nFramesP, int nFrames, int nMaxImps, int fRewrite, int fUseImps, int fLatchCorr, int fWriteImps, int fVerbose );
11169
11170 pNtk = Abc_FrameReadNtk(pAbc);
11171 pOut = Abc_FrameReadOut(pAbc);
11172 pErr = Abc_FrameReadErr(pAbc);
11173
11174
11175 nFramesP = 0;
11176 nFramesK = 1;
11177 nMaxImps = 5000;
11178 fUseImps = 0;
11179 fRewrite = 0;
11180 fLatchCorr = 0;
11181 fWriteImps = 0;
11182 fVerbose = 0;
11183 Extra_UtilGetoptReset();
11184 while ( ( c = Extra_UtilGetopt( argc, argv, "PFIirlevh" ) ) != EOF )
11185 {
11186 switch ( c )
11187 {
11188 case 'P':
11189 if ( globalUtilOptind >= argc )
11190 {
11191 fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
11192 goto usage;
11193 }
11194 nFramesP = atoi(argv[globalUtilOptind]);
11195 globalUtilOptind++;
11196 if ( nFramesP < 0 )
11197 goto usage;
11198 break;
11199 case 'F':
11200 if ( globalUtilOptind >= argc )
11201 {
11202 fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
11203 goto usage;
11204 }
11205 nFramesK = atoi(argv[globalUtilOptind]);
11206 globalUtilOptind++;
11207 if ( nFramesK <= 0 )
11208 goto usage;
11209 break;
11210 case 'I':
11211 if ( globalUtilOptind >= argc )
11212 {
11213 fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
11214 goto usage;
11215 }
11216 nMaxImps = atoi(argv[globalUtilOptind]);
11217 globalUtilOptind++;
11218 if ( nMaxImps <= 0 )
11219 goto usage;
11220 break;
11221 case 'i':
11222 fUseImps ^= 1;
11223 break;
11224 case 'r':
11225 fRewrite ^= 1;
11226 break;
11227 case 'l':
11228 fLatchCorr ^= 1;
11229 break;
11230 case 'e':
11231 fWriteImps ^= 1;
11232 break;
11233 case 'v':
11234 fVerbose ^= 1;
11235 break;
11236 case 'h':
11237 goto usage;
11238 default:
11239 goto usage;
11240 }
11241 }
11242
11243 if ( pNtk == NULL )
11244 {
11245 fprintf( pErr, "Empty network.\n" );
11246 return 1;
11247 }
11248
11249 if ( Abc_NtkIsComb(pNtk) )
11250 {
11251 fprintf( pErr, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
11252 return 1;
11253 }
11254
11255 if ( !Abc_NtkIsStrash(pNtk) )
11256 {
11257 printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
11258 return 0;
11259 }
11260
11261
11262 pNtkRes = Abc_NtkDarSeqSweep( pNtk, nFramesP, nFramesK, nMaxImps, fRewrite, fUseImps, fLatchCorr, fWriteImps, fVerbose );
11263 if ( pNtkRes == NULL )
11264 {
11265 fprintf( pErr, "Sequential sweeping has failed.\n" );
11266 return 1;
11267 }
11268
11269 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
11270 return 0;
11271
11272 usage:
11273 fprintf( pErr, "usage: ssweep [-P num] [-F num] [-I num] [-ilrevh]\n" );
11274 fprintf( pErr, "\t performs sequential sweep using K-step induction\n" );
11275 fprintf( pErr, "\t-P num : number of time frames to use as the prefix [default = %d]\n", nFramesP );
11276 fprintf( pErr, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", nFramesK );
11277 fprintf( pErr, "\t-I num : max number of implications to consider [default = %d]\n", nMaxImps );
11278 fprintf( pErr, "\t-i : toggle using implications [default = %s]\n", fUseImps? "yes": "no" );
11279 fprintf( pErr, "\t-l : toggle latch correspondence only [default = %s]\n", fLatchCorr? "yes": "no" );
11280 fprintf( pErr, "\t-r : toggle AIG rewriting [default = %s]\n", fRewrite? "yes": "no" );
11281 fprintf( pErr, "\t-e : toggle writing implications as assertions [default = %s]\n", fWriteImps? "yes": "no" );
11282 fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
11283 fprintf( pErr, "\t-h : print the command usage\n");
11284 return 1;
11285 }
11286
11298 int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
11299 {
11300 FILE * pOut, * pErr;
11301 Abc_Ntk_t * pNtk, * pNtkRes;
11302 int c;
11303 int nFramesP;
11304 int nConfMax;
11305 int fVerbose;
11306 extern Abc_Ntk_t * Abc_NtkDarLcorr( Abc_Ntk_t * pNtk, int nFramesP, int nConfMax, int fVerbose );
11307
11308 pNtk = Abc_FrameReadNtk(pAbc);
11309 pOut = Abc_FrameReadOut(pAbc);
11310 pErr = Abc_FrameReadErr(pAbc);
11311
11312
11313 nFramesP = 0;
11314 nConfMax = 10000;
11315 fVerbose = 0;
11316 Extra_UtilGetoptReset();
11317 while ( ( c = Extra_UtilGetopt( argc, argv, "PCvh" ) ) != EOF )
11318 {
11319 switch ( c )
11320 {
11321 case 'P':
11322 if ( globalUtilOptind >= argc )
11323 {
11324 fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
11325 goto usage;
11326 }
11327 nFramesP = atoi(argv[globalUtilOptind]);
11328 globalUtilOptind++;
11329 if ( nFramesP < 0 )
11330 goto usage;
11331 break;
11332 case 'C':
11333 if ( globalUtilOptind >= argc )
11334 {
11335 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
11336 goto usage;
11337 }
11338 nConfMax = atoi(argv[globalUtilOptind]);
11339 globalUtilOptind++;
11340 if ( nConfMax < 0 )
11341 goto usage;
11342 break;
11343 case 'v':
11344 fVerbose ^= 1;
11345 break;
11346 case 'h':
11347 goto usage;
11348 default:
11349 goto usage;
11350 }
11351 }
11352
11353 if ( pNtk == NULL )
11354 {
11355 fprintf( pErr, "Empty network.\n" );
11356 return 1;
11357 }
11358
11359 if ( Abc_NtkIsComb(pNtk) )
11360 {
11361 fprintf( pErr, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
11362 return 1;
11363 }
11364
11365 if ( !Abc_NtkIsStrash(pNtk) )
11366 {
11367 printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
11368 return 0;
11369 }
11370
11371
11372 pNtkRes = Abc_NtkDarLcorr( pNtk, nFramesP, nConfMax, fVerbose );
11373 if ( pNtkRes == NULL )
11374 {
11375 fprintf( pErr, "Sequential sweeping has failed.\n" );
11376 return 1;
11377 }
11378
11379 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
11380 return 0;
11381
11382 usage:
11383 fprintf( pErr, "usage: lcorr [-P num] [-C num] [-vh]\n" );
11384 fprintf( pErr, "\t computes latch correspondence using 1-step induction\n" );
11385 fprintf( pErr, "\t-P num : number of time frames to use as the prefix [default = %d]\n", nFramesP );
11386 fprintf( pErr, "\t-C num : max conflict number when proving latch equivalence [default = %d]\n", nConfMax );
11387 fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
11388 fprintf( pErr, "\t-h : print the command usage\n");
11389 return 1;
11390 }
11391
11403 int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
11404 {
11405 FILE * pOut, * pErr;
11406 Abc_Ntk_t * pNtk, * pNtkRes;
11407 int c;
11408 int fLatchSweep;
11409 int fAutoSweep;
11410 int fVerbose;
11411 extern Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchSweep, int fVerbose );
11412
11413 pNtk = Abc_FrameReadNtk(pAbc);
11414 pOut = Abc_FrameReadOut(pAbc);
11415 pErr = Abc_FrameReadErr(pAbc);
11416
11417
11418 fLatchSweep = 0;
11419 fAutoSweep = 0;
11420 fVerbose = 0;
11421 Extra_UtilGetoptReset();
11422 while ( ( c = Extra_UtilGetopt( argc, argv, "lavh" ) ) != EOF )
11423 {
11424 switch ( c )
11425 {
11426 case 'l':
11427 fLatchSweep ^= 1;
11428 break;
11429 case 'a':
11430 fAutoSweep ^= 1;
11431 break;
11432 case 'v':
11433 fVerbose ^= 1;
11434 break;
11435 case 'h':
11436 goto usage;
11437 default:
11438 goto usage;
11439 }
11440 }
11441 if ( pNtk == NULL )
11442 {
11443 fprintf( pErr, "Empty network.\n" );
11444 return 1;
11445 }
11446 if ( !Abc_NtkIsStrash(pNtk) )
11447 {
11448 fprintf( pErr, "Only works for structrally hashed networks.\n" );
11449 return 1;
11450 }
11451 if ( !Abc_NtkLatchNum(pNtk) )
11452 {
11453 fprintf( pErr, "Only works for sequential networks.\n" );
11454 return 1;
11455 }
11456
11457 pNtkRes = Abc_NtkDarLatchSweep( pNtk, fLatchSweep, fVerbose );
11458 if ( pNtkRes == NULL )
11459 {
11460 fprintf( pErr, "Sequential cleanup has failed.\n" );
11461 return 1;
11462 }
11463
11464 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
11465 return 0;
11466
11467 usage:
11468 fprintf( pErr, "usage: scleanup [-lvh]\n" );
11469 fprintf( pErr, "\t performs sequential cleanup\n" );
11470 fprintf( pErr, "\t - removes nodes/latches that do not feed into POs\n" );
11471 fprintf( pErr, "\t - removes stuck-at and identical latches (latch sweep)\n" );
11472
11473 fprintf( pErr, "\t (the latter may change sequential behaviour)\n" );
11474 fprintf( pErr, "\t-l : toggle sweeping latches [default = %s]\n", fLatchSweep? "yes": "no" );
11475
11476 fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
11477 fprintf( pErr, "\t-h : print the command usage\n");
11478 return 1;
11479 }
11480
11492 int Abc_CommandCycle( Abc_Frame_t * pAbc, int argc, char ** argv )
11493 {
11494 FILE * pOut, * pErr;
11495 Abc_Ntk_t * pNtk;
11496 int c;
11497 int nFrames;
11498 int fVerbose;
11499 extern void Abc_NtkCycleInitState( Abc_Ntk_t * pNtk, int nFrames, int fVerbose );
11500 extern void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose );
11501
11502 pNtk = Abc_FrameReadNtk(pAbc);
11503 pOut = Abc_FrameReadOut(pAbc);
11504 pErr = Abc_FrameReadErr(pAbc);
11505
11506
11507 nFrames = 100;
11508 fVerbose = 0;
11509 Extra_UtilGetoptReset();
11510 while ( ( c = Extra_UtilGetopt( argc, argv, "Fvh" ) ) != EOF )
11511 {
11512 switch ( c )
11513 {
11514 case 'F':
11515 if ( globalUtilOptind >= argc )
11516 {
11517 fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
11518 goto usage;
11519 }
11520 nFrames = atoi(argv[globalUtilOptind]);
11521 globalUtilOptind++;
11522 if ( nFrames < 0 )
11523 goto usage;
11524 break;
11525 case 'v':
11526 fVerbose ^= 1;
11527 break;
11528 case 'h':
11529 goto usage;
11530 default:
11531 goto usage;
11532 }
11533 }
11534 if ( pNtk == NULL )
11535 {
11536 fprintf( pErr, "Empty network.\n" );
11537 return 1;
11538 }
11539
11540 if ( !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsSopLogic(pNtk) )
11541 {
11542 fprintf( pErr, "Only works for strashed networks or logic SOP networks.\n" );
11543 return 1;
11544 }
11545 if ( !Abc_NtkLatchNum(pNtk) )
11546 {
11547 fprintf( pErr, "Only works for sequential networks.\n" );
11548 return 1;
11549 }
11550
11551 if ( Abc_NtkIsStrash(pNtk) )
11552 Abc_NtkCycleInitState( pNtk, nFrames, fVerbose );
11553 else
11554 Abc_NtkCycleInitStateSop( pNtk, nFrames, fVerbose );
11555 return 0;
11556
11557 usage:
11558 fprintf( pErr, "usage: cycle [-F num] [-vh]\n" );
11559 fprintf( pErr, "\t cycles sequiential circuit for the given number of timeframes\n" );
11560 fprintf( pErr, "\t to derive a new initial state (which may be on the envelope)\n" );
11561 fprintf( pErr, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
11562 fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
11563 fprintf( pErr, "\t-h : print the command usage\n");
11564 return 1;
11565 }
11566
11578 int Abc_CommandXsim( Abc_Frame_t * pAbc, int argc, char ** argv )
11579 {
11580 FILE * pOut, * pErr;
11581 Abc_Ntk_t * pNtk;
11582 int c;
11583 int nFrames;
11584 int fXInputs;
11585 int fXState;
11586 int fVerbose;
11587 extern void Abc_NtkXValueSimulate( Abc_Ntk_t * pNtk, int nFrames, int fXInputs, int fXState, int fVerbose );
11588
11589 pNtk = Abc_FrameReadNtk(pAbc);
11590 pOut = Abc_FrameReadOut(pAbc);
11591 pErr = Abc_FrameReadErr(pAbc);
11592
11593
11594 nFrames = 10;
11595 fXInputs = 0;
11596 fXState = 0;
11597 fVerbose = 0;
11598 Extra_UtilGetoptReset();
11599 while ( ( c = Extra_UtilGetopt( argc, argv, "Fisvh" ) ) != EOF )
11600 {
11601 switch ( c )
11602 {
11603 case 'F':
11604 if ( globalUtilOptind >= argc )
11605 {
11606 fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
11607 goto usage;
11608 }
11609 nFrames = atoi(argv[globalUtilOptind]);
11610 globalUtilOptind++;
11611 if ( nFrames < 0 )
11612 goto usage;
11613 break;
11614 case 'i':
11615 fXInputs ^= 1;
11616 break;
11617 case 's':
11618 fXState ^= 1;
11619 break;
11620 case 'v':
11621 fVerbose ^= 1;
11622 break;
11623 case 'h':
11624 goto usage;
11625 default:
11626 goto usage;
11627 }
11628 }
11629 if ( pNtk == NULL )
11630 {
11631 fprintf( pErr, "Empty network.\n" );
11632 return 1;
11633 }
11634
11635 if ( !Abc_NtkIsStrash(pNtk) )
11636 {
11637 fprintf( pErr, "Only works for strashed networks.\n" );
11638 return 1;
11639 }
11640 if ( !Abc_NtkLatchNum(pNtk) )
11641 {
11642 fprintf( pErr, "Only works for sequential networks.\n" );
11643 return 1;
11644 }
11645 Abc_NtkXValueSimulate( pNtk, nFrames, fXInputs, fXState, fVerbose );
11646 return 0;
11647
11648 usage:
11649 fprintf( pErr, "usage: xsim [-F num] [-isvh]\n" );
11650 fprintf( pErr, "\t performs X-valued simulation of the AIG\n" );
11651 fprintf( pErr, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
11652 fprintf( pErr, "\t-i : toggle X-valued representation of inputs [default = %s]\n", fXInputs? "yes": "no" );
11653 fprintf( pErr, "\t-s : toggle X-valued representation of state [default = %s]\n", fXState? "yes": "no" );
11654 fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
11655 fprintf( pErr, "\t-h : print the command usage\n");
11656 return 1;
11657 }
11658
11659
11660
11672 int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
11673 {
11674 char Buffer[16];
11675 FILE * pOut, * pErr;
11676 Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
11677 int fDelete1, fDelete2;
11678 char ** pArgvNew;
11679 int nArgcNew;
11680 int c;
11681 int fSat;
11682 int fVerbose;
11683 int nSeconds;
11684 int nPartSize;
11685 int nConfLimit;
11686 int nInsLimit;
11687 int fPartition;
11688
11689 extern void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nInsLimit );
11690 extern void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fVerbose );
11691 extern void Abc_NtkCecFraigPart( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nPartSize, int fVerbose );
11692 extern void Abc_NtkCecFraigPartAuto( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fVerbose );
11693
11694 pNtk = Abc_FrameReadNtk(pAbc);
11695 pOut = Abc_FrameReadOut(pAbc);
11696 pErr = Abc_FrameReadErr(pAbc);
11697
11698
11699 fSat = 0;
11700 fVerbose = 0;
11701 nSeconds = 20;
11702 nPartSize = 0;
11703 nConfLimit = 10000;
11704 nInsLimit = 0;
11705 fPartition = 0;
11706 Extra_UtilGetoptReset();
11707 while ( ( c = Extra_UtilGetopt( argc, argv, "TCIPpsvh" ) ) != EOF )
11708 {
11709 switch ( c )
11710 {
11711 case 'T':
11712 if ( globalUtilOptind >= argc )
11713 {
11714 fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" );
11715 goto usage;
11716 }
11717 nSeconds = atoi(argv[globalUtilOptind]);
11718 globalUtilOptind++;
11719 if ( nSeconds < 0 )
11720 goto usage;
11721 break;
11722 case 'C':
11723 if ( globalUtilOptind >= argc )
11724 {
11725 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
11726 goto usage;
11727 }
11728 nConfLimit = atoi(argv[globalUtilOptind]);
11729 globalUtilOptind++;
11730 if ( nConfLimit < 0 )
11731 goto usage;
11732 break;
11733 case 'I':
11734 if ( globalUtilOptind >= argc )
11735 {
11736 fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
11737 goto usage;
11738 }
11739 nInsLimit = atoi(argv[globalUtilOptind]);
11740 globalUtilOptind++;
11741 if ( nInsLimit < 0 )
11742 goto usage;
11743 break;
11744 case 'P':
11745 if ( globalUtilOptind >= argc )
11746 {
11747 fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
11748 goto usage;
11749 }
11750 nPartSize = atoi(argv[globalUtilOptind]);
11751 globalUtilOptind++;
11752 if ( nPartSize < 0 )
11753 goto usage;
11754 break;
11755 case 'p':
11756 fPartition ^= 1;
11757 break;
11758 case 's':
11759 fSat ^= 1;
11760 break;
11761 case 'v':
11762 fVerbose ^= 1;
11763 break;
11764 default:
11765 goto usage;
11766 }
11767 }
11768
11769 pArgvNew = argv + globalUtilOptind;
11770 nArgcNew = argc - globalUtilOptind;
11771 if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
11772 return 1;
11773
11774
11775 if ( fPartition )
11776 Abc_NtkCecFraigPartAuto( pNtk1, pNtk2, nSeconds, fVerbose );
11777 else if ( nPartSize )
11778 Abc_NtkCecFraigPart( pNtk1, pNtk2, nSeconds, nPartSize, fVerbose );
11779 else if ( fSat )
11780 Abc_NtkCecSat( pNtk1, pNtk2, nConfLimit, nInsLimit );
11781 else
11782 Abc_NtkCecFraig( pNtk1, pNtk2, nSeconds, fVerbose );
11783
11784 if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
11785 if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
11786 return 0;
11787
11788 usage:
11789 if ( nPartSize == 0 )
11790 strcpy( Buffer, "unused" );
11791 else
11792 sprintf( Buffer, "%d", nPartSize );
11793 fprintf( pErr, "usage: cec [-T num] [-C num] [-I num] [-P num] [-psvh] <file1> <file2>\n" );
11794 fprintf( pErr, "\t performs combinational equivalence checking\n" );
11795 fprintf( pErr, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
11796 fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
11797 fprintf( pErr, "\t-I num : limit on the number of clause inspections [default = %d]\n", nInsLimit );
11798 fprintf( pErr, "\t-P num : partition size for multi-output networks [default = %s]\n", Buffer );
11799 fprintf( pErr, "\t-p : toggle automatic partitioning [default = %s]\n", fPartition? "yes": "no" );
11800 fprintf( pErr, "\t-s : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
11801 fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
11802 fprintf( pErr, "\t-h : print the command usage\n");
11803 fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
11804 fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
11805 fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
11806 fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
11807 return 1;
11808 }
11809
11821 int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
11822 {
11823 FILE * pOut, * pErr;
11824 Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
11825 int fDelete1, fDelete2;
11826 char ** pArgvNew;
11827 int nArgcNew;
11828 int c;
11829 int fRetime;
11830 int fSat;
11831 int fVerbose;
11832 int nFrames;
11833 int nSeconds;
11834 int nConfLimit;
11835 int nInsLimit;
11836
11837 extern void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nInsLimit, int nFrames );
11838 extern int Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFrames, int fVerbose );
11839 extern void Abc_NtkSecRetime( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 );
11840
11841
11842 pNtk = Abc_FrameReadNtk(pAbc);
11843 pOut = Abc_FrameReadOut(pAbc);
11844 pErr = Abc_FrameReadErr(pAbc);
11845
11846
11847 fRetime = 0;
11848 fSat = 0;
11849 fVerbose = 0;
11850 nFrames = 5;
11851 nSeconds = 20;
11852 nConfLimit = 10000;
11853 nInsLimit = 0;
11854 Extra_UtilGetoptReset();
11855 while ( ( c = Extra_UtilGetopt( argc, argv, "FTCIsrvh" ) ) != EOF )
11856 {
11857 switch ( c )
11858 {
11859 case 'F':
11860 if ( globalUtilOptind >= argc )
11861 {
11862 fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
11863 goto usage;
11864 }
11865 nFrames = atoi(argv[globalUtilOptind]);
11866 globalUtilOptind++;
11867 if ( nFrames <= 0 )
11868 goto usage;
11869 break;
11870 case 'T':
11871 if ( globalUtilOptind >= argc )
11872 {
11873 fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" );
11874 goto usage;
11875 }
11876 nSeconds = atoi(argv[globalUtilOptind]);
11877 globalUtilOptind++;
11878 if ( nSeconds < 0 )
11879 goto usage;
11880 break;
11881 case 'C':
11882 if ( globalUtilOptind >= argc )
11883 {
11884 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
11885 goto usage;
11886 }
11887 nConfLimit = atoi(argv[globalUtilOptind]);
11888 globalUtilOptind++;
11889 if ( nConfLimit < 0 )
11890 goto usage;
11891 break;
11892 case 'I':
11893 if ( globalUtilOptind >= argc )
11894 {
11895 fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
11896 goto usage;
11897 }
11898 nInsLimit = atoi(argv[globalUtilOptind]);
11899 globalUtilOptind++;
11900 if ( nInsLimit < 0 )
11901 goto usage;
11902 break;
11903 case 'r':
11904 fRetime ^= 1;
11905 break;
11906 case 'v':
11907 fVerbose ^= 1;
11908 break;
11909 case 's':
11910 fSat ^= 1;
11911 break;
11912 default:
11913 goto usage;
11914 }
11915 }
11916
11917 pArgvNew = argv + globalUtilOptind;
11918 nArgcNew = argc - globalUtilOptind;
11919 if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
11920 return 1;
11921
11922 if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
11923 {
11924 printf( "The network has no latches. Used combinational command \"cec\".\n" );
11925 return 0;
11926 }
11927
11928
11929 if ( fRetime )
11930 Abc_NtkSecRetime( pNtk1, pNtk2 );
11931 else if ( fSat )
11932 Abc_NtkSecSat( pNtk1, pNtk2, nConfLimit, nInsLimit, nFrames );
11933 else
11934 Abc_NtkSecFraig( pNtk1, pNtk2, nSeconds, nFrames, fVerbose );
11935
11936 if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
11937 if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
11938 return 0;
11939
11940 usage:
11941 fprintf( pErr, "usage: sec [-F num] [-T num] [-C num] [-I num] [-srvh] <file1> <file2>\n" );
11942 fprintf( pErr, "\t performs bounded sequential equivalence checking\n" );
11943 fprintf( pErr, "\t-s : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
11944 fprintf( pErr, "\t-r : toggles retiming verification [default = %s]\n", fVerbose? "yes": "no" );
11945 fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
11946 fprintf( pErr, "\t-h : print the command usage\n");
11947 fprintf( pErr, "\t-F num : the number of time frames to use [default = %d]\n", nFrames );
11948 fprintf( pErr, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
11949 fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
11950 fprintf( pErr, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
11951 fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
11952 fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
11953 fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
11954 fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
11955 return 1;
11956 }
11957
11969 int Abc_CommandDSec( Abc_Frame_t * pAbc, int argc, char ** argv )
11970 {
11971 FILE * pOut, * pErr;
11972 Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
11973 int fDelete1, fDelete2;
11974 char ** pArgvNew;
11975 int nArgcNew;
11976 int c;
11977 int fRetimeFirst;
11978 int fVerbose;
11979 int fVeryVerbose;
11980 int nFrames;
11981
11982 extern int Abc_NtkDarSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames, int fRetimeFirst, int fVerbose, int fVeryVerbose );
11983
11984 pNtk = Abc_FrameReadNtk(pAbc);
11985 pOut = Abc_FrameReadOut(pAbc);
11986 pErr = Abc_FrameReadErr(pAbc);
11987
11988
11989 nFrames =16;
11990 fRetimeFirst = 1;
11991 fVerbose = 0;
11992 fVeryVerbose = 0;
11993 Extra_UtilGetoptReset();
11994 while ( ( c = Extra_UtilGetopt( argc, argv, "Krwvh" ) ) != EOF )
11995 {
11996 switch ( c )
11997 {
11998 case 'K':
11999 if ( globalUtilOptind >= argc )
12000 {
12001 fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
12002 goto usage;
12003 }
12004 nFrames = atoi(argv[globalUtilOptind]);
12005 globalUtilOptind++;
12006 if ( nFrames < 0 )
12007 goto usage;
12008 break;
12009 case 'r':
12010 fRetimeFirst ^= 1;
12011 break;
12012 case 'w':
12013 fVeryVerbose ^= 1;
12014 break;
12015 case 'v':
12016 fVerbose ^= 1;
12017 break;
12018 default:
12019 goto usage;
12020 }
12021 }
12022
12023 pArgvNew = argv + globalUtilOptind;
12024 nArgcNew = argc - globalUtilOptind;
12025 if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
12026 return 1;
12027
12028 if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
12029 {
12030 printf( "The network has no latches. Used combinational command \"cec\".\n" );
12031 return 0;
12032 }
12033
12034
12035 Abc_NtkDarSec( pNtk1, pNtk2, nFrames, fRetimeFirst, fVerbose, fVeryVerbose );
12036
12037 if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
12038 if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
12039 return 0;
12040
12041 usage:
12042 fprintf( pErr, "usage: dsec [-K num] [-rwvh] <file1> <file2>\n" );
12043 fprintf( pErr, "\t performs inductive sequential equivalence checking\n" );
12044 fprintf( pErr, "\t-K num : the limit on the depth of induction [default = %d]\n", nFrames );
12045 fprintf( pErr, "\t-r : toggles forward retiming at the beginning [default = %s]\n", fRetimeFirst? "yes": "no" );
12046 fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
12047 fprintf( pErr, "\t-w : toggles additional verbose output [default = %s]\n", fVeryVerbose? "yes": "no" );
12048 fprintf( pErr, "\t-h : print the command usage\n");
12049 fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
12050 fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
12051 fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
12052 fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
12053 return 1;
12054 }
12055
12067 int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
12068 {
12069 FILE * pOut, * pErr;
12070 Abc_Ntk_t * pNtk;
12071 int c;
12072 int fRetimeFirst;
12073 int fVerbose;
12074 int fVeryVerbose;
12075 int nFrames;
12076
12077 extern int Abc_NtkDarProve( Abc_Ntk_t * pNtk, int nFrames, int fRetimeFirst, int fVerbose, int fVeryVerbose );
12078
12079 pNtk = Abc_FrameReadNtk(pAbc);
12080 pOut = Abc_FrameReadOut(pAbc);
12081 pErr = Abc_FrameReadErr(pAbc);
12082
12083
12084 nFrames = 16;
12085 fRetimeFirst = 1;
12086 fVerbose = 0;
12087 fVeryVerbose = 0;
12088 Extra_UtilGetoptReset();
12089 while ( ( c = Extra_UtilGetopt( argc, argv, "Krwvh" ) ) != EOF )
12090 {
12091 switch ( c )
12092 {
12093 case 'K':
12094 if ( globalUtilOptind >= argc )
12095 {
12096 fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
12097 goto usage;
12098 }
12099 nFrames = atoi(argv[globalUtilOptind]);
12100 globalUtilOptind++;
12101 if ( nFrames < 0 )
12102 goto usage;
12103 break;
12104 case 'r':
12105 fRetimeFirst ^= 1;
12106 break;
12107 case 'w':
12108 fVeryVerbose ^= 1;
12109 break;
12110 case 'v':
12111 fVerbose ^= 1;
12112 break;
12113 default:
12114 goto usage;
12115 }
12116 }
12117
12118 if ( Abc_NtkLatchNum(pNtk) == 0 )
12119 {
12120 printf( "The network has no latches. Used combinational command \"iprove\".\n" );
12121 return 0;
12122 }
12123 if ( !Abc_NtkIsStrash(pNtk) )
12124 {
12125 printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
12126 return 0;
12127 }
12128
12129
12130 Abc_NtkDarProve( pNtk, nFrames, fRetimeFirst, fVerbose, fVeryVerbose );
12131 return 0;
12132
12133 usage:
12134 fprintf( pErr, "usage: dprove [-K num] [-rwvh]\n" );
12135 fprintf( pErr, "\t performs SEC on the sequential miter\n" );
12136 fprintf( pErr, "\t-K num : the limit on the depth of induction [default = %d]\n", nFrames );
12137 fprintf( pErr, "\t-r : toggles forward retiming at the beginning [default = %s]\n", fRetimeFirst? "yes": "no" );
12138 fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
12139 fprintf( pErr, "\t-w : toggles additional verbose output [default = %s]\n", fVeryVerbose? "yes": "no" );
12140 fprintf( pErr, "\t-h : print the command usage\n");
12141 return 1;
12142 }
12143
12155 int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv )
12156 {
12157 FILE * pOut, * pErr;
12158 Abc_Ntk_t * pNtk;
12159 int c;
12160 int RetValue;
12161 int fVerbose;
12162 int nConfLimit;
12163 int nInsLimit;
12164 int clk;
12165
12166 pNtk = Abc_FrameReadNtk(pAbc);
12167 pOut = Abc_FrameReadOut(pAbc);
12168 pErr = Abc_FrameReadErr(pAbc);
12169
12170
12171 fVerbose = 0;
12172 nConfLimit = 100000;
12173 nInsLimit = 0;
12174 Extra_UtilGetoptReset();
12175 while ( ( c = Extra_UtilGetopt( argc, argv, "CIvh" ) ) != EOF )
12176 {
12177 switch ( c )
12178 {
12179 case 'C':
12180 if ( globalUtilOptind >= argc )
12181 {
12182 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
12183 goto usage;
12184 }
12185 nConfLimit = atoi(argv[globalUtilOptind]);
12186 globalUtilOptind++;
12187 if ( nConfLimit < 0 )
12188 goto usage;
12189 break;
12190 case 'I':
12191 if ( globalUtilOptind >= argc )
12192 {
12193 fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
12194 goto usage;
12195 }
12196 nInsLimit = atoi(argv[globalUtilOptind]);
12197 globalUtilOptind++;
12198 if ( nInsLimit < 0 )
12199 goto usage;
12200 break;
12201 case 'v':
12202 fVerbose ^= 1;
12203 break;
12204 case 'h':
12205 goto usage;
12206 default:
12207 goto usage;
12208 }
12209 }
12210
12211 if ( pNtk == NULL )
12212 {
12213 fprintf( pErr, "Empty network.\n" );
12214 return 1;
12215 }
12216 if ( Abc_NtkLatchNum(pNtk) > 0 )
12217 {
12218 fprintf( stdout, "Currently can only solve the miter for combinational circuits.\n" );
12219 return 0;
12220 }
12221
12222 clk = clock();
12223 if ( Abc_NtkIsStrash(pNtk) )
12224 {
12225 RetValue = Abc_NtkMiterSat( pNtk, (sint64)nConfLimit, (sint64)nInsLimit, fVerbose, NULL, NULL );
12226 }
12227 else
12228 {
12229 assert( Abc_NtkIsLogic(pNtk) );
12230 Abc_NtkToBdd( pNtk );
12231 RetValue = Abc_NtkMiterSat( pNtk, (sint64)nConfLimit, (sint64)nInsLimit, fVerbose, NULL, NULL );
12232 }
12233
12234
12235 if ( RetValue == 0 && Abc_NtkPoNum(pNtk) == 1 )
12236 {
12237
12238
12239 int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
12240 if ( pSimInfo[0] != 1 )
12241 printf( "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
12242 free( pSimInfo );
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253 }
12254
12255 if ( RetValue == -1 )
12256 printf( "UNDECIDED " );
12257 else if ( RetValue == 0 )
12258 printf( "SATISFIABLE " );
12259 else
12260 printf( "UNSATISFIABLE " );
12261
12262 PRT( "Time", clock() - clk );
12263 return 0;
12264
12265 usage:
12266 fprintf( pErr, "usage: sat [-C num] [-I num] [-vh]\n" );
12267 fprintf( pErr, "\t solves the combinational miter using SAT solver MiniSat-1.14\n" );
12268 fprintf( pErr, "\t derives CNF from the current network and leave it unchanged\n" );
12269 fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
12270 fprintf( pErr, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
12271 fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
12272 fprintf( pErr, "\t-h : print the command usage\n");
12273 return 1;
12274 }
12275
12287 int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
12288 {
12289 FILE * pOut, * pErr;
12290 Abc_Ntk_t * pNtk;
12291 int c;
12292 int RetValue;
12293 int fVerbose;
12294 int nConfLimit;
12295 int nInsLimit;
12296 int clk;
12297
12298 extern int Abc_NtkDSat( Abc_Ntk_t * pNtk, sint64 nConfLimit, sint64 nInsLimit, int fVerbose );
12299
12300
12301 pNtk = Abc_FrameReadNtk(pAbc);
12302 pOut = Abc_FrameReadOut(pAbc);
12303 pErr = Abc_FrameReadErr(pAbc);
12304
12305
12306 fVerbose = 0;
12307 nConfLimit = 100000;
12308 nInsLimit = 0;
12309 Extra_UtilGetoptReset();
12310 while ( ( c = Extra_UtilGetopt( argc, argv, "CIvh" ) ) != EOF )
12311 {
12312 switch ( c )
12313 {
12314 case 'C':
12315 if ( globalUtilOptind >= argc )
12316 {
12317 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
12318 goto usage;
12319 }
12320 nConfLimit = atoi(argv[globalUtilOptind]);
12321 globalUtilOptind++;
12322 if ( nConfLimit < 0 )
12323 goto usage;
12324 break;
12325 case 'I':
12326 if ( globalUtilOptind >= argc )
12327 {
12328 fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
12329 goto usage;
12330 }
12331 nInsLimit = atoi(argv[globalUtilOptind]);
12332 globalUtilOptind++;
12333 if ( nInsLimit < 0 )
12334 goto usage;
12335 break;
12336 case 'v':
12337 fVerbose ^= 1;
12338 break;
12339 case 'h':
12340 goto usage;
12341 default:
12342 goto usage;
12343 }
12344 }
12345
12346 if ( pNtk == NULL )
12347 {
12348 fprintf( pErr, "Empty network.\n" );
12349 return 1;
12350 }
12351 if ( Abc_NtkLatchNum(pNtk) > 0 )
12352 {
12353 fprintf( stdout, "Currently can only solve the miter for combinational circuits.\n" );
12354 return 0;
12355 }
12356 if ( Abc_NtkPoNum(pNtk) != 1 )
12357 {
12358 fprintf( stdout, "Currently expects a single-output miter.\n" );
12359 return 0;
12360 }
12361
12362 if ( !Abc_NtkIsStrash(pNtk) )
12363 {
12364 fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
12365 return 0;
12366 }
12367
12368 clk = clock();
12369 RetValue = Abc_NtkDSat( pNtk, (sint64)nConfLimit, (sint64)nInsLimit, fVerbose );
12370
12371 if ( RetValue == 0 && Abc_NtkPoNum(pNtk) == 1 )
12372 {
12373
12374
12375 int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
12376 if ( pSimInfo[0] != 1 )
12377 printf( "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
12378 free( pSimInfo );
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389 }
12390
12391 if ( RetValue == -1 )
12392 printf( "UNDECIDED " );
12393 else if ( RetValue == 0 )
12394 printf( "SATISFIABLE " );
12395 else
12396 printf( "UNSATISFIABLE " );
12397
12398 PRT( "Time", clock() - clk );
12399 return 0;
12400
12401 usage:
12402 fprintf( pErr, "usage: dsat [-C num] [-I num] [-vh]\n" );
12403 fprintf( pErr, "\t solves the combinational miter using SAT solver MiniSat-1.14\n" );
12404 fprintf( pErr, "\t derives CNF from the current network and leave it unchanged\n" );
12405 fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
12406 fprintf( pErr, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
12407 fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
12408 fprintf( pErr, "\t-h : print the command usage\n");
12409 return 1;
12410 }
12411
12423 int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
12424 {
12425 FILE * pOut, * pErr;
12426 Abc_Ntk_t * pNtk, * pNtkTemp;
12427 Prove_Params_t Params, * pParams = &Params;
12428 int c, clk, RetValue;
12429
12430 pNtk = Abc_FrameReadNtk(pAbc);
12431 pOut = Abc_FrameReadOut(pAbc);
12432 pErr = Abc_FrameReadErr(pAbc);
12433
12434
12435 Prove_ParamsSetDefault( pParams );
12436 Extra_UtilGetoptReset();
12437 while ( ( c = Extra_UtilGetopt( argc, argv, "NCFLIrfbvh" ) ) != EOF )
12438 {
12439 switch ( c )
12440 {
12441 case 'N':
12442 if ( globalUtilOptind >= argc )
12443 {
12444 fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
12445 goto usage;
12446 }
12447 pParams->nItersMax = atoi(argv[globalUtilOptind]);
12448 globalUtilOptind++;
12449 if ( pParams->nItersMax < 0 )
12450 goto usage;
12451 break;
12452 case 'C':
12453 if ( globalUtilOptind >= argc )
12454 {
12455 fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
12456 goto usage;
12457 }
12458 pParams->nMiteringLimitStart = atoi(argv[globalUtilOptind]);
12459 globalUtilOptind++;
12460 if ( pParams->nMiteringLimitStart < 0 )
12461 goto usage;
12462 break;
12463 case 'F':
12464 if ( globalUtilOptind >= argc )
12465 {
12466 fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
12467 goto usage;
12468 }
12469 pParams->nFraigingLimitStart = atoi(argv[globalUtilOptind]);
12470 globalUtilOptind++;
12471 if ( pParams->nFraigingLimitStart < 0 )
12472 goto usage;
12473 break;
12474 case 'L':
12475 if ( globalUtilOptind >= argc )
12476 {
12477 fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
12478 goto usage;
12479 }
12480 pParams->nMiteringLimitLast = atoi(argv[globalUtilOptind]);
12481 globalUtilOptind++;
12482 if ( pParams->nMiteringLimitLast < 0 )
12483 goto usage;
12484 break;
12485 case 'I':
12486 if ( globalUtilOptind >= argc )
12487 {
12488 fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
12489 goto usage;
12490 }
12491 pParams->nTotalInspectLimit = atoi(argv[globalUtilOptind]);
12492 globalUtilOptind++;
12493 if ( pParams->nTotalInspectLimit < 0 )
12494 goto usage;
12495 break;
12496 case 'r':
12497 pParams->fUseRewriting ^= 1;
12498 break;
12499 case 'f':
12500 pParams->fUseFraiging ^= 1;
12501 break;
12502 case 'b':
12503 pParams->fUseBdds ^= 1;
12504 break;
12505 case 'v':
12506 pParams->fVerbose ^= 1;
12507 break;
12508 case 'h':
12509 goto usage;
12510 default:
12511 goto usage;
12512 }
12513 }
12514
12515 if ( pNtk == NULL )
12516 {
12517 fprintf( pErr, "Empty network.\n" );
12518 return 1;
12519 }
12520 if ( Abc_NtkLatchNum(pNtk) > 0 )
12521 {
12522 fprintf( stdout, "Currently can only solve the miter for combinational circuits.\n" );
12523 return 0;
12524 }
12525 if ( Abc_NtkCoNum(pNtk) != 1 )
12526 {
12527 fprintf( stdout, "Currently can only solve the miter with one output.\n" );
12528 return 0;
12529 }
12530 clk = clock();
12531
12532 if ( Abc_NtkIsStrash(pNtk) )
12533 pNtkTemp = Abc_NtkDup( pNtk );
12534 else
12535 pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
12536
12537 RetValue = Abc_NtkMiterProve( &pNtkTemp, pParams );
12538
12539
12540 if ( RetValue == 0 )
12541 {
12542 int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtkTemp->pModel );
12543 if ( pSimInfo[0] != 1 )
12544 printf( "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
12545 free( pSimInfo );
12546 }
12547
12548 if ( RetValue == -1 )
12549 printf( "UNDECIDED " );
12550 else if ( RetValue == 0 )
12551 printf( "SATISFIABLE " );
12552 else
12553 printf( "UNSATISFIABLE " );
12554
12555
12556 PRT( "Time", clock() - clk );
12557
12558 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp );
12559 return 0;
12560
12561 usage:
12562 fprintf( pErr, "usage: prove [-N num] [-C num] [-F num] [-L num] [-I num] [-rfbvh]\n" );
12563 fprintf( pErr, "\t solves combinational miter by rewriting, FRAIGing, and SAT\n" );
12564 fprintf( pErr, "\t replaces the current network by the cone modified by rewriting\n" );
12565 fprintf( pErr, "\t-N num : max number of iterations [default = %d]\n", pParams->nItersMax );
12566 fprintf( pErr, "\t-C num : max starting number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitStart );
12567 fprintf( pErr, "\t-F num : max starting number of conflicts in fraiging [default = %d]\n", pParams->nFraigingLimitStart );
12568 fprintf( pErr, "\t-L num : max last-gasp number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitLast );
12569 fprintf( pErr, "\t-I num : max number of clause inspections in all SAT calls [default = %d]\n", (int)pParams->nTotalInspectLimit );
12570 fprintf( pErr, "\t-r : toggle the use of rewriting [default = %s]\n", pParams->fUseRewriting? "yes": "no" );
12571 fprintf( pErr, "\t-f : toggle the use of FRAIGing [default = %s]\n", pParams->fUseFraiging? "yes": "no" );
12572 fprintf( pErr, "\t-b : toggle the use of BDDs [default = %s]\n", pParams->fUseBdds? "yes": "no" );
12573 fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
12574 fprintf( pErr, "\t-h : print the command usage\n");
12575 return 1;
12576 }
12577
12589 int Abc_CommandDebug( Abc_Frame_t * pAbc, int argc, char ** argv )
12590 {
12591 FILE * pOut, * pErr;
12592 Abc_Ntk_t * pNtk;
12593 int c;
12594 extern void Abc_NtkAutoDebug( Abc_Ntk_t * pNtk, int (*pFuncError) (Abc_Ntk_t *) );
12595 extern int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk );
12596
12597 pNtk = Abc_FrameReadNtk(pAbc);
12598 pOut = Abc_FrameReadOut(pAbc);
12599 pErr = Abc_FrameReadErr(pAbc);
12600
12601
12602 Extra_UtilGetoptReset();
12603 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
12604 {
12605 switch ( c )
12606 {
12607 case 'h':
12608 goto usage;
12609 default:
12610 goto usage;
12611 }
12612 }
12613
12614 if ( pNtk == NULL )
12615 {
12616 fprintf( pErr, "Empty network.\n" );
12617 return 1;
12618 }
12619 if ( !Abc_NtkIsLogic(pNtk) )
12620 {
12621 fprintf( pErr, "This command is applicable to logic networks.\n" );
12622 return 1;
12623 }
12624
12625 Abc_NtkAutoDebug( pNtk, Abc_NtkRetimeDebug );
12626 return 0;
12627
12628 usage:
12629 fprintf( pErr, "usage: debug [-h]\n" );
12630 fprintf( pErr, "\t performs automated debugging of the given procedure\n" );
12631 fprintf( pErr, "\t-h : print the command usage\n");
12632 return 1;
12633 }
12634
12635
12647 int Abc_CommandTraceStart( Abc_Frame_t * pAbc, int argc, char ** argv )
12648 {
12649 FILE * pOut, * pErr;
12650 Abc_Ntk_t * pNtk;
12651 int c;
12652
12653 pNtk = Abc_FrameReadNtk(pAbc);
12654 pOut = Abc_FrameReadOut(pAbc);
12655 pErr = Abc_FrameReadErr(pAbc);
12656
12657
12658 Extra_UtilGetoptReset();
12659 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
12660 {
12661 switch ( c )
12662 {
12663 case 'h':
12664 goto usage;
12665 default:
12666 goto usage;
12667 }
12668 }
12669
12670 if ( pNtk == NULL )
12671 {
12672 fprintf( pErr, "Empty network.\n" );
12673 return 1;
12674 }
12675 if ( !Abc_NtkIsStrash(pNtk) )
12676 {
12677 fprintf( pErr, "This command is applicable to AIGs.\n" );
12678 return 1;
12679 }
12680
12681
12682
12683
12684
12685
12686
12687
12688 return 0;
12689
12690 usage:
12691 fprintf( pErr, "usage: trace_start [-h]\n" );
12692 fprintf( pErr, "\t starts verification tracing\n" );
12693 fprintf( pErr, "\t-h : print the command usage\n");
12694 return 1;
12695 }
12696
12708 int Abc_CommandTraceCheck( Abc_Frame_t * pAbc, int argc, char ** argv )
12709 {
12710 FILE * pOut, * pErr;
12711 Abc_Ntk_t * pNtk;
12712 int c;
12713
12714 pNtk = Abc_FrameReadNtk(pAbc);
12715 pOut = Abc_FrameReadOut(pAbc);
12716 pErr = Abc_FrameReadErr(pAbc);
12717
12718
12719 Extra_UtilGetoptReset();
12720 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
12721 {
12722 switch ( c )
12723 {
12724 case 'h':
12725 goto usage;
12726 default:
12727 goto usage;
12728 }
12729 }
12730
12731 if ( pNtk == NULL )
12732 {
12733 fprintf( pErr, "Empty network.\n" );
12734 return 1;
12735 }
12736 if ( !Abc_NtkIsStrash(pNtk) )
12737 {
12738 fprintf( pErr, "This command is applicable to AIGs.\n" );
12739 return 1;
12740 }
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752 return 0;
12753
12754 usage:
12755 fprintf( pErr, "usage: trace_check [-h]\n" );
12756 fprintf( pErr, "\t checks the current network using verification trace\n" );
12757 fprintf( pErr, "\t-h : print the command usage\n");
12758 return 1;
12759 }
12760
12764
12765