diff --git a/cumulus/src/plugins/rsave.py b/cumulus/src/plugins/rsave.py index 0199d379..6e5d79f4 100644 --- a/cumulus/src/plugins/rsave.py +++ b/cumulus/src/plugins/rsave.py @@ -14,10 +14,12 @@ # +-----------------------------------------------------------------+ +from __future__ import print_function +import sys +import traceback +import os.path + try: - import sys - import traceback - import os.path import Cfg import CRL import helpers @@ -29,48 +31,54 @@ except Exception, e: sys.exit(2) -# Write back layout to disk if everything has gone fine. -# Must write all the sub-blocks of the core but *not* the -# standard cell (mainly the feed-through). -# -# If the model has been uniquified, in the case of a merging -# of abutment box for placement, the netlist view must also -# be saved. - def rsave ( cell, views=CRL.Catalog.State.Physical, depth=0 ): - if cell.isTerminal(): return - - framework = CRL.AllianceFramework.get() - if depth == 0: print ' o Recursive Save-Cell.' - - sviews = '' - if views & CRL.Catalog.State.Logical: - sviews += 'netlist' - if views & CRL.Catalog.State.VstUseConcat: - if sviews: sviews += ',' - sviews += ' uses &' - if views & CRL.Catalog.State.VstNoLowerCase: - if sviews: sviews += ', no lowercase' - sviews += '' - if views & CRL.Catalog.State.Physical: - if sviews: sviews += ',' - sviews += 'layout' - - print ' %s+ %s (%s).' % ( ' '*(depth*2), cell.getName(), sviews ) - if cell.isUniquified(): views |= CRL.Catalog.State.Logical - framework.saveCell( cell, views ) - - for instance in cell.getInstances(): - masterCell = instance.getMasterCell() - if not masterCell.isTerminal(): - rsave( masterCell, views, depth+1 ) - return + """ + Write back layout to disk if everything has gone fine. + Must write all the sub-blocks of the core but *not* the + standard cell (mainly the feed-through). + + If the model has been uniquified, in the case of a merging + of abutment box for placement, the netlist view must also + be saved. + """ + framework = CRL.AllianceFramework.get() + if depth == 0: print( ' o Recursive Save-Cell.' ) + + sviews = '' + if views & CRL.Catalog.State.Logical: + sviews += 'netlist' + if views & CRL.Catalog.State.VstUseConcat: + if sviews: sviews += ',' + sviews += ' uses &' + if views & CRL.Catalog.State.VstNoLowerCase: + if sviews: sviews += ', no lowercase' + if views & CRL.Catalog.State.VstNoLinkage: + if sviews: sviews += ', no linkage' + sviews += '' + if views & CRL.Catalog.State.Physical: + if sviews: sviews += ',' + sviews += 'layout' + + print( ' {}+ {} ({}).'.format(' '*(depth*2), cell.getName(), sviews) ) + if cell.isUniquified(): views |= CRL.Catalog.State.Logical + framework.saveCell( cell, views ) + + for instance in cell.getInstances(): + #print( ' {}| {}.'.format(' '*(depth*2), instance) ) + masterCell = instance.getMasterCell() + + if not masterCell.isTerminalNetlist(): + rsave( masterCell, views, depth+1 ) + #else: + # print( ' {}| Master cell is terminal netlist {}.'.format(' '*(depth*2), instance.getMasterCell()) ) + return # -------------------------------------------------------------------- # Plugin hook functions, unicornHook:menus, ScritMain:call def unicornHook ( **kw ): + """Hook up rsave plugin into Unicorn/CGT menu tree.""" plugins.kwUnicornHook( 'tools.rsave' , 'Recursive Save (layout)' , 'Recursively save layout of the top cell and it\'s instances' @@ -81,25 +89,22 @@ def unicornHook ( **kw ): def scriptMain ( **kw ): - try: - #helpers.setTraceLevel( 550 ) - - cell, editor = plugins.kwParseMain( **kw ) - - views = CRL.Catalog.State.Physical - if kw.has_key('views'): views = kw['views'] - - if not cell: - print WarningMessage( 'No Cell loaded in the editor (yet), nothing done.' ) - return 0 - - rsave( cell, views ) - CRL.destroyAllVHDL() - - except Exception, e: - helpers.io.catch( e ) - - sys.stdout.flush() - sys.stderr.flush() - - return 0 + """Called when run as a stand alone script through Unicorn/CGT.""" + try: + #helpers.setTraceLevel( 550 ) + cell, editor = plugins.kwParseMain( **kw ) + views = CRL.Catalog.State.Physical + if kw.has_key('views'): views = kw['views'] + if not cell: + print( WarningMessage( 'No Cell loaded in the editor (yet), nothing done.' ) ) + return 0 + rsave( cell, views ) + CRL.destroyAllVHDL() + + except Exception, e: + helpers.io.catch( e ) + + sys.stdout.flush() + sys.stderr.flush() + + return 0