diff --git a/cumulus/src/CMakeLists.txt b/cumulus/src/CMakeLists.txt index f8bdc57d..ffef310b 100644 --- a/cumulus/src/CMakeLists.txt +++ b/cumulus/src/CMakeLists.txt @@ -16,6 +16,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/plugins/block.py ${CMAKE_CURRENT_SOURCE_DIR}/plugins/rsave.py ${CMAKE_CURRENT_SOURCE_DIR}/plugins/rsaveall.py + ${CMAKE_CURRENT_SOURCE_DIR}/plugins/checks.py ${CMAKE_CURRENT_SOURCE_DIR}/plugins/s2r.py ${CMAKE_CURRENT_SOURCE_DIR}/plugins/aboutwindow.py ${CMAKE_CURRENT_SOURCE_DIR}/plugins/stats.py diff --git a/cumulus/src/plugins/alpha/core2chip/core2chip.py b/cumulus/src/plugins/alpha/core2chip/core2chip.py index 5ac19a8b..5c1e8ee8 100644 --- a/cumulus/src/plugins/alpha/core2chip/core2chip.py +++ b/cumulus/src/plugins/alpha/core2chip/core2chip.py @@ -47,12 +47,13 @@ from __future__ import print_function from exceptions import NotImplementedError import re from Hurricane import UpdateSession, Net, Instance -from CRL import Catalog, AllianceFramework +from CRL import Catalog, AllianceFramework, Spice from helpers import trace, netDirectionToStr from helpers.overlay import UpdateSession from helpers.io import ErrorMessage, WarningMessage import plugins.chip from plugins.rsave import rsave +from plugins.checks import oneDriver from plugins.alpha.utils import getPlugByName from plugins.alpha.block.block import Block from plugins.alpha.block.configuration import BlockConf, IoPadConf, ConstantsConf @@ -713,4 +714,6 @@ class CoreToChip ( object ): ioPad.udata.createPad() self._connectRing() self._connectClocks() - rsave( self.chip, views=Catalog.State.Logical ) + oneDriver( self.chip ) + rsave( self.chip, views=Catalog.State.Logical, enableSpice=True ) + Spice.clearProperties() diff --git a/cumulus/src/plugins/checks.py b/cumulus/src/plugins/checks.py new file mode 100644 index 00000000..8bc6ab16 --- /dev/null +++ b/cumulus/src/plugins/checks.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +# +# This file is part of the Coriolis Software. +# Copyright (c) SU 2021-2021, All Rights Reserved +# +# +-----------------------------------------------------------------+ +# | C O R I O L I S | +# | C u m u l u s - P y t h o n T o o l s | +# | | +# | Author : Jean-Paul CHAPUT | +# | E-mail : Jean-Paul.Chaput@lip6.fr | +# | =============================================================== | +# | Python : "./plugins/checks.py" | +# +-----------------------------------------------------------------+ + + +from __future__ import print_function +import sys +import traceback +import os.path + +try: + import Cfg + import CRL + import helpers + from helpers.io import ErrorMessage + from helpers.io import WarningMessage + import plugins + from Hurricane import Net, Plug +except Exception, e: + helpers.io.catch( e ) + sys.exit(2) + + +def oneDriver ( cell ): + """ + Checks that all nets have *one and only one* driver. + """ + print( ' o Checks that all nets have exactly one drivers on "{}"'.format(cell.getName()) ) + for net in cell.getNets(): + if net.isGlobal() or net.isSupply(): + continue + drivers = [] + if net.isExternal(): + if net.getDirection() & Net.Direction.IN: + drivers.append( net ) + elif net.getDirection() & Net.Direction.OUT: + pass + else: + print( WarningMessage( [ 'checks.oneDriver(): External net without direction.' + , '{}'.format(net) ] )) + for plug in net.getPlugs(): + masterNet = plug.getMasterNet() + if masterNet.getDirection() & Net.Direction.OUT: + drivers.append( plug ) + #for pin in net.getPins(): + # if len(drivers) == 0: + # drivers.append( pin ) + if len(drivers) == 0: + print( WarningMessage( 'checks.oneDriver(): "{}" has no driver.'.format(net.getName()) ) ) + elif len(drivers) > 1: + message = [ 'checks.oneDriver(): "{}" has more than one drivers.'.format(net.getName()) ] + for driver in drivers: + if isinstance(driver,Plug): + message.append( '* {} {}'.format(driver,driver.getMasterNet()) ) + else: + message.append( '* {}'.format(driver) ) + print( WarningMessage( message )) + return + + +# -------------------------------------------------------------------- +# Plugin hook functions, unicornHook:menus, ScritMain:call + +def unicornHook ( **kw ): + """Hook up rsave plugin into Unicorn/CGT menu tree.""" + plugins.kwUnicornHook( 'tools.checks' + , 'Netlist Checks' + , 'Perform coherency checks on the netlist' + , sys.modules[__name__].__file__ + , **kw + ) + return + + +def scriptMain ( **kw ): + """Called when run as a stand alone script through Unicorn/CGT.""" + try: + #helpers.setTraceLevel( 550 ) + cell, editor = plugins.kwParseMain( **kw ) + if not cell: + print( WarningMessage( 'No Cell loaded in the editor (yet), nothing done.' ) ) + return 0 + oneDriver( cell ) + except Exception, e: + helpers.io.catch( e ) + sys.stdout.flush() + sys.stderr.flush() + return 0