diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 88753520e..8c8555c44 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -182,6 +182,7 @@ static int Abc_CommandSwapPos ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandRemovePo ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandDropSat ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAddPi ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAddFlop ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAppend ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPutOnTop ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandFrames ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -981,6 +982,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Various", "removepo", Abc_CommandRemovePo, 1 ); Cmd_CommandAdd( pAbc, "Various", "dropsat", Abc_CommandDropSat, 1 ); Cmd_CommandAdd( pAbc, "Various", "addpi", Abc_CommandAddPi, 1 ); + Cmd_CommandAdd( pAbc, "Various", "addflop", Abc_CommandAddFlop, 1 ); Cmd_CommandAdd( pAbc, "Various", "append", Abc_CommandAppend, 1 ); Cmd_CommandAdd( pAbc, "Various", "putontop", Abc_CommandPutOnTop, 1 ); Cmd_CommandAdd( pAbc, "Various", "frames", Abc_CommandFrames, 1 ); @@ -11176,7 +11178,7 @@ usage: ***********************************************************************/ int Abc_CommandAddPi( Abc_Frame_t * pAbc, int argc, char ** argv ) { - Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes; + Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); int c; // set defaults @@ -11198,14 +11200,14 @@ int Abc_CommandAddPi( Abc_Frame_t * pAbc, int argc, char ** argv ) } // get the new network - pNtkRes = Abc_NtkDup( pNtk ); - if ( Abc_NtkPiNum(pNtkRes) == 0 ) + if ( Abc_NtkPiNum(pNtk) == 0 ) { + Abc_Ntk_t * pNtkRes = Abc_NtkDup( pNtk ); Abc_Obj_t * pObj = Abc_NtkCreatePi( pNtkRes ); Abc_ObjAssignName( pObj, "dummy_pi", NULL ); Abc_NtkOrderCisCos( pNtkRes ); + Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); } - Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: @@ -11215,6 +11217,59 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAddFlop( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); + int c; + + // set defaults + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + default: + goto usage; + } + } + if ( pNtk == NULL ) + { + Abc_Print( -1, "Empty network.\n" ); + return 1; + } + if ( !Abc_NtkIsStrash(pNtk) ) + { + Abc_Print( -2, "The current network is not an AIG (run \"strash\").\n"); + return 0; + } + // get the new network + if ( Abc_NtkLatchNum(pNtk) == 0 ) + { + Abc_Ntk_t * pNtkRes = Abc_NtkDup( pNtk ); + Abc_NtkAddLatch( pNtkRes, Abc_AigConst1(pNtkRes), ABC_INIT_ONE ); + Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); + } + return 0; + +usage: + Abc_Print( -2, "usage: addflop [-h]\n" ); + Abc_Print( -2, "\t if the network has no flops, add one dummy flop\n" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + /**Function************************************************************* Synopsis [] @@ -41414,7 +41469,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv ) goto usage; } } - + if ( pAbc->pGia == NULL ) { if ( !Abc_FrameReadFlag("silentmode") ) @@ -52958,13 +53013,16 @@ int Abc_CommandAbc9AddFlop( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9AddFlop(): There is no AIG.\n" ); return 0; } - pTemp = Gia_ManDupAddFlop( pAbc->pGia ); - Abc_FrameUpdateGia( pAbc, pTemp ); + if ( Gia_ManRegNum(pAbc->pGia) == 0 ) + { + pTemp = Gia_ManDupAddFlop( pAbc->pGia ); + Abc_FrameUpdateGia( pAbc, pTemp ); + } return 0; usage: Abc_Print( -2, "usage: &addflop [-vh]\n" ); - Abc_Print( -2, "\t adds one flop to the design\n" ); + Abc_Print( -2, "\t if the design has no flops, adds one flop to the design\n" ); Abc_Print( -2, "\t-v : toggles printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; diff --git a/test.ps b/test.ps new file mode 100644 index 000000000..7634275b2 --- /dev/null +++ b/test.ps @@ -0,0 +1,388 @@ +%!PS-Adobe-3.0 +%%Creator: graphviz version 2.43.0 (0) +%%Title: network +%%Pages: (atend) +%%BoundingBox: (atend) +%%EndComments +save +%%BeginProlog +/DotDict 200 dict def +DotDict begin + +/setupLatin1 { +mark +/EncodingVector 256 array def + EncodingVector 0 + +ISOLatin1Encoding 0 255 getinterval putinterval +EncodingVector 45 /hyphen put + +% Set up ISO Latin 1 character encoding +/starnetISO { + dup dup findfont dup length dict begin + { 1 index /FID ne { def }{ pop pop } ifelse + } forall + /Encoding EncodingVector def + currentdict end definefont +} def +/Times-Roman starnetISO def +/Times-Italic starnetISO def +/Times-Bold starnetISO def +/Times-BoldItalic starnetISO def +/Helvetica starnetISO def +/Helvetica-Oblique starnetISO def +/Helvetica-Bold starnetISO def +/Helvetica-BoldOblique starnetISO def +/Courier starnetISO def +/Courier-Oblique starnetISO def +/Courier-Bold starnetISO def +/Courier-BoldOblique starnetISO def +cleartomark +} bind def + +%%BeginResource: procset graphviz 0 0 +/coord-font-family /Times-Roman def +/default-font-family /Times-Roman def +/coordfont coord-font-family findfont 8 scalefont def + +/InvScaleFactor 1.0 def +/set_scale { + dup 1 exch div /InvScaleFactor exch def + scale +} bind def + +% styles +/solid { [] 0 setdash } bind def +/dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def +/dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def +/invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def +/bold { 2 setlinewidth } bind def +/filled { } bind def +/unfilled { } bind def +/rounded { } bind def +/diagonals { } bind def +/tapered { } bind def + +% hooks for setting color +/nodecolor { sethsbcolor } bind def +/edgecolor { sethsbcolor } bind def +/graphcolor { sethsbcolor } bind def +/nopcolor {pop pop pop} bind def + +/beginpage { % i j npages + /npages exch def + /j exch def + /i exch def + /str 10 string def + npages 1 gt { + gsave + coordfont setfont + 0 0 moveto + (\() show i str cvs show (,) show j str cvs show (\)) show + grestore + } if +} bind def + +/set_font { + findfont exch + scalefont setfont +} def + +% draw text fitted to its expected width +/alignedtext { % width text + /text exch def + /width exch def + gsave + width 0 gt { + [] 0 setdash + text stringwidth pop width exch sub text length div 0 text ashow + } if + grestore +} def + +/boxprim { % xcorner ycorner xsize ysize + 4 2 roll + moveto + 2 copy + exch 0 rlineto + 0 exch rlineto + pop neg 0 rlineto + closepath +} bind def + +/ellipse_path { + /ry exch def + /rx exch def + /y exch def + /x exch def + matrix currentmatrix + newpath + x y translate + rx ry scale + 0 0 1 0 360 arc + setmatrix +} bind def + +/endpage { showpage } bind def +/showpage { } def + +/layercolorseq + [ % layer color sequence - darkest to lightest + [0 0 0] + [.2 .8 .8] + [.4 .8 .8] + [.6 .8 .8] + [.8 .8 .8] + ] +def + +/layerlen layercolorseq length def + +/setlayer {/maxlayer exch def /curlayer exch def + layercolorseq curlayer 1 sub layerlen mod get + aload pop sethsbcolor + /nodecolor {nopcolor} def + /edgecolor {nopcolor} def + /graphcolor {nopcolor} def +} bind def + +/onlayer { curlayer ne {invis} if } def + +/onlayers { + /myupper exch def + /mylower exch def + curlayer mylower lt + curlayer myupper gt + or + {invis} if +} def + +/curlayer 0 def + +%%EndResource +%%EndProlog +%%BeginSetup +14 default-font-family set_font +% /arrowlength 10 def +% /arrowwidth 5 def + +% make sure pdfmark is harmless for PS-interpreters other than Distiller +/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse +% make '<<' and '>>' safe on PS Level 1 devices +/languagelevel where {pop languagelevel}{1} ifelse +2 lt { + userdict (<<) cvn ([) cvn load put + userdict (>>) cvn ([) cvn load put +} if + +%%EndSetup +setupLatin1 +%%Page: 1 1 +%%PageBoundingBox: 37 212 575 580 +%%PageOrientation: Portrait +0 0 1 beginpage +gsave +37 212 538 368 boxprim clip newpath +1 1 set_scale 0 rotate 41 216 translate +% LevelTitle1 +gsave +grestore +% LevelTitle2 +gsave +grestore +% LevelTitle1->LevelTitle2 +% Level2 +gsave +grestore +% LevelTitle2->Level2 +% Level1 +gsave +grestore +% Level2->Level1 +% Level0 +gsave +grestore +% Level1->Level0 +% title1 +gsave +0 0 0 nodecolor +20 /Times-Roman set_font +151.5 340 moveto 299 (Network structure visualized by ABC) alignedtext +0 0 0 nodecolor +20 /Times-Roman set_font +80 318 moveto 442 (Benchmark "test". Time was Fri Sep 6 06:13:38 2024. ) alignedtext +grestore +% title2 +gsave +0 0 0 nodecolor +18 /Times-Roman set_font +119 249.6 moveto 364 (The network contains 1 logic nodes and 0 latches.) alignedtext +grestore +% title1->title2 +% Node4 +gsave +1 setlinewidth +0.043137 0.68627 1 nodecolor +newpath 263 154 moveto +290.0966 188.5 lineto +235.9034 188.5 lineto +closepath stroke +0 0 0 nodecolor +14 /Times-Roman set_font +260.5 173.3 moveto 5 (f) alignedtext +grestore +% title2->Node4 +% Node5 +gsave +1 setlinewidth +0.043137 0.68627 1 nodecolor +newpath 338 154 moveto +367.795 188.5 lineto +308.205 188.5 lineto +closepath stroke +0 0 0 nodecolor +14 /Times-Roman set_font +334.5 173.3 moveto 7 (g) alignedtext +grestore +% title2->Node5 +% Node4->Node5 +% Node6 +gsave +1 setlinewidth +0 0 0 nodecolor +300 100 27 18 ellipse_path stroke +0 0 0 nodecolor +14 /Times-Roman set_font +296.5 96.3 moveto 7 (6) alignedtext +grestore +% Node4->Node6 +gsave +1 setlinewidth +solid +0 0 0 edgecolor +newpath 274.2701 153.1552 moveto +279.9849 141.5712 286.7919 127.7731 291.9687 117.2797 curveto +stroke +0 0 0 edgecolor +newpath 271.0718 151.7273 moveto +269.7864 162.2438 lineto +277.3495 154.8243 lineto +closepath fill +1 setlinewidth +solid +0 0 0 edgecolor +newpath 271.0718 151.7273 moveto +269.7864 162.2438 lineto +277.3495 154.8243 lineto +closepath stroke +grestore +% Node5->Node6 +gsave +1 setlinewidth +solid +0 0 0 edgecolor +newpath 326.2775 152.8634 moveto +320.4603 141.3822 313.571 127.785 308.3062 117.3939 curveto +stroke +0 0 0 edgecolor +newpath 323.2107 154.5546 moveto +330.8525 161.8931 lineto +329.4549 151.3908 lineto +closepath fill +1 setlinewidth +solid +0 0 0 edgecolor +newpath 323.2107 154.5546 moveto +330.8525 161.8931 lineto +329.4549 151.3908 lineto +closepath stroke +grestore +% Node1 +gsave +1 setlinewidth +0.043137 0.68627 1 nodecolor +newpath 261 46 moveto +231.205 11.5 lineto +290.795 11.5 lineto +closepath stroke +0 0 0 nodecolor +14 /Times-Roman set_font +257.5 19.3 moveto 7 (a) alignedtext +grestore +% Node6->Node1 +gsave +1 setlinewidth +solid +0 0 0 edgecolor +newpath 286.8586 73.7282 moveto +280.7027 61.8898 273.5973 48.2257 268.3944 38.2199 curveto +stroke +0 0 0 edgecolor +newpath 283.8187 75.4687 moveto +291.5376 82.7261 lineto +290.0293 72.2392 lineto +closepath fill +1 setlinewidth +solid +0 0 0 edgecolor +newpath 283.8187 75.4687 moveto +291.5376 82.7261 lineto +290.0293 72.2392 lineto +closepath stroke +grestore +% Node2 +gsave +1 setlinewidth +0.043137 0.68627 1 nodecolor +newpath 339 46 moveto +309.205 11.5 lineto +368.795 11.5 lineto +closepath stroke +0 0 0 nodecolor +14 /Times-Roman set_font +335.5 19.3 moveto 7 (b) alignedtext +grestore +% Node6->Node2 +gsave +1 setlinewidth +solid +0 0 0 edgecolor +newpath 313.1414 73.7282 moveto +319.2973 61.8898 326.4027 48.2257 331.6056 38.2199 curveto +stroke +0 0 0 edgecolor +newpath 309.9707 72.2392 moveto +308.4624 82.7261 lineto +316.1813 75.4687 lineto +closepath fill +1 setlinewidth +solid +0 0 0 edgecolor +newpath 309.9707 72.2392 moveto +308.4624 82.7261 lineto +316.1813 75.4687 lineto +closepath stroke +grestore +% Node3 +gsave +1 setlinewidth +0.043137 0.68627 1 nodecolor +newpath 417 46 moveto +387.205 11.5 lineto +446.795 11.5 lineto +closepath stroke +0 0 0 nodecolor +14 /Times-Roman set_font +413.5 19.3 moveto 7 (c) alignedtext +grestore +endpage +showpage +grestore +%%PageTrailer +%%EndPage: 1 +%%Trailer +%%Pages: 1 +%%BoundingBox: 37 212 575 580 +end +restore +%%EOF