2022-12-31 08:01:37 -06:00
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
from doit.exceptions import TaskFailed
|
|
|
|
from .task import FlowTask
|
|
|
|
|
|
|
|
|
|
|
|
class TargetNotVst ( Exception ): pass
|
|
|
|
|
|
|
|
|
|
|
|
def renameNMigen( occurrence ):
|
|
|
|
masterCell = occurrence.getEntity().getMasterCell()
|
|
|
|
origName = masterCell.getName()
|
|
|
|
replName = origName.replace( '$$', '_unm' )
|
|
|
|
if not masterCell.isTerminalNetlist() and not replName.startswith('cmpt_'):
|
|
|
|
replName = 'cmpt_' + replName
|
|
|
|
#for letter in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
|
|
|
|
# replName = replName.replace(letter, '{}u'.format(letter))
|
|
|
|
if origName != replName:
|
|
|
|
print( ' - "{}" => "{}"'.format(origName,replName) )
|
|
|
|
masterCell.setName( replName )
|
|
|
|
|
|
|
|
|
|
|
|
def renameNMigenUniquify ( topCell ):
|
|
|
|
for occurrence in topCell.getTerminalNetlistInstanceOccurrences():
|
|
|
|
renameNMigen(occurrence)
|
|
|
|
for occurrence in topCell.getNonTerminalNetlistInstanceOccurrences():
|
|
|
|
renameNMigen(occurrence)
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
class Blif2Vst ( FlowTask ):
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def mkRule ( rule, targets, depends=[], flags=0 ):
|
|
|
|
return Blif2Vst( rule, targets, depends, flags )
|
|
|
|
|
|
|
|
def __init__ ( self, rule, targets, depends, flags ):
|
|
|
|
super().__init__( rule, targets, depends )
|
|
|
|
self.flags = flags
|
2023-03-01 16:57:55 -06:00
|
|
|
if not self.targets[0].suffix == '.vst':
|
2022-12-31 08:01:37 -06:00
|
|
|
raise TargetNotVst( 'Blif2Vst.__init__(): First target *must* "{}" be a vst file.' \
|
|
|
|
.format( self.targets[0] ))
|
|
|
|
self.addClean( self.targets )
|
|
|
|
|
|
|
|
def __repr__ ( self ):
|
2023-03-01 16:57:55 -06:00
|
|
|
for d in self.file_dep:
|
|
|
|
print( d )
|
2022-12-31 08:01:37 -06:00
|
|
|
return '<blif2vst {} depends=[{}]>' \
|
2023-03-01 16:57:55 -06:00
|
|
|
.format( self.design, ','.join([f.as_posix() for f in self.file_dep]) )
|
2022-12-31 08:01:37 -06:00
|
|
|
|
|
|
|
@property
|
|
|
|
def design ( self ):
|
2023-03-01 16:57:55 -06:00
|
|
|
if len(self.targets): return self.targets[0].stem
|
2022-12-31 08:01:37 -06:00
|
|
|
return None
|
|
|
|
|
|
|
|
def doTask ( self ):
|
Comprehensive reorganisation of the Python part of Coriolis.
* Move all Python stuff under a common Python namespace "coriolis".
* Instead of having a series subtrees for each tool, integrate
everything in one common tree. So now, all components can be
located either with an absolute path from "coriolis" or, inside
cross-reference themselves through relatives imports.
* As a consequence, we only need to add ".../site-packages/coriolis/"
to the PYTHONPATH, and not a whole bunch of subdirectories.
And nothing, if installed in-system.
* The tree of free technologies configuration files is also moved
below "coriolis/technos" instead of "/etc".
* Supressed "cumulus" level for the plugins.
* All python modules are rewritten using relative imports except
for the configuration files that uses absolute import as they
can be cloned outside of the tree to serve as templates.
* Change: In boostrap/FindPythonSitePackages, include "/coriolis" in
Python_CORIOLISARCH and Python_CORIOLISLIB.
Provide a Python_SITELIB *without* "/coriolis" appended.
* Change: In cumulus/plugins/__init__.loadPlugins(), must prefix modules
read in the plugins directory by "coriolis.plugins.". No longer need
to add their path to sys.path.
* Change: In crlcore/python/technos/nodeX/*/devices.py, the scripts of
the layouts generators must be prefixed by "coriolis.oroshi.".
* Change: In CRL::System CTOR, no longer add the pathes of the various
plugins to sys.path. Only "site-packages/coriolis/".
* New: In Utilities::Path::toPyModePath(), new method to convert a
filesystem path into a python module path.
Examples:
"coriolis/plugins/block" --> "coriolis.plugins.block".
"coriolis/plugins/rsave.py" --> "coriolis.plugins.rsave".
* Change: In katanaEngine::_runKatanaEngine(), rename the hook script
initHook.py. No longer need to modify sys.path.
* Change: In BoraEngine::_runBoraEngine(), rename the hook script
initHook.py. No longer need to modify sys.path.
* Change: In UnicornGui::_runUnicornInit(), rename the hook script
initHook.py. No longer need to modify sys.path.
* Change: In cumulus.plugins.chip.constants, put the constants
outside __init__.py to avoid a loop at initialization.
2023-02-27 15:14:32 -06:00
|
|
|
from ..Hurricane import Cell
|
|
|
|
from .. import CRL
|
|
|
|
from .. import Viewer
|
|
|
|
from ..helpers.io import ErrorMessage
|
|
|
|
from ..plugins import rsave
|
2022-12-31 08:01:37 -06:00
|
|
|
|
|
|
|
print( 'Blif2Vst.doTask() on "{}"'.format( self.design ))
|
|
|
|
views = CRL.Catalog.State.Logical | self.flags
|
2023-03-01 16:57:55 -06:00
|
|
|
cell = CRL.Blif.load( self.file_depend().as_posix() )
|
2022-12-31 08:01:37 -06:00
|
|
|
if cell.getName() == 'top':
|
|
|
|
print( ' o Renaming RTLIL anonymous top cell "top" into "{}".'.format(self.design) )
|
|
|
|
cell.setName( self.design )
|
|
|
|
renameNMigenUniquify( cell )
|
|
|
|
CRL.restoreNetsDirection( cell, Cell.Flags_TerminalNetlist )
|
|
|
|
kw = {}
|
|
|
|
kw['views'] = views
|
|
|
|
kw['cell' ] = cell
|
Comprehensive reorganisation of the Python part of Coriolis.
* Move all Python stuff under a common Python namespace "coriolis".
* Instead of having a series subtrees for each tool, integrate
everything in one common tree. So now, all components can be
located either with an absolute path from "coriolis" or, inside
cross-reference themselves through relatives imports.
* As a consequence, we only need to add ".../site-packages/coriolis/"
to the PYTHONPATH, and not a whole bunch of subdirectories.
And nothing, if installed in-system.
* The tree of free technologies configuration files is also moved
below "coriolis/technos" instead of "/etc".
* Supressed "cumulus" level for the plugins.
* All python modules are rewritten using relative imports except
for the configuration files that uses absolute import as they
can be cloned outside of the tree to serve as templates.
* Change: In boostrap/FindPythonSitePackages, include "/coriolis" in
Python_CORIOLISARCH and Python_CORIOLISLIB.
Provide a Python_SITELIB *without* "/coriolis" appended.
* Change: In cumulus/plugins/__init__.loadPlugins(), must prefix modules
read in the plugins directory by "coriolis.plugins.". No longer need
to add their path to sys.path.
* Change: In crlcore/python/technos/nodeX/*/devices.py, the scripts of
the layouts generators must be prefixed by "coriolis.oroshi.".
* Change: In CRL::System CTOR, no longer add the pathes of the various
plugins to sys.path. Only "site-packages/coriolis/".
* New: In Utilities::Path::toPyModePath(), new method to convert a
filesystem path into a python module path.
Examples:
"coriolis/plugins/block" --> "coriolis.plugins.block".
"coriolis/plugins/rsave.py" --> "coriolis.plugins.rsave".
* Change: In katanaEngine::_runKatanaEngine(), rename the hook script
initHook.py. No longer need to modify sys.path.
* Change: In BoraEngine::_runBoraEngine(), rename the hook script
initHook.py. No longer need to modify sys.path.
* Change: In UnicornGui::_runUnicornInit(), rename the hook script
initHook.py. No longer need to modify sys.path.
* Change: In cumulus.plugins.chip.constants, put the constants
outside __init__.py to avoid a loop at initialization.
2023-02-27 15:14:32 -06:00
|
|
|
rsave.scriptMain( **kw )
|
2022-12-31 08:01:37 -06:00
|
|
|
|
|
|
|
return self.checkTargets( 'Blif2Vst.doTask' )
|
|
|
|
|
|
|
|
def create_doit_tasks ( self ):
|
|
|
|
if self.design: doc = 'Run {}.'.format( self )
|
|
|
|
else: doc = 'Run plain CGT (no loaded design)'
|
|
|
|
return { 'basename' : self.basename
|
|
|
|
, 'actions' : [ self.doTask ]
|
|
|
|
, 'doc' : doc
|
|
|
|
, 'targets' : self.targets
|
|
|
|
, 'file_dep' : self.file_dep
|
|
|
|
}
|
|
|
|
|