Remove Spice extension after use. Checks for non-driven nets.

* New: cumulus/plugins.checks, plugin providing a oneDriver() function
    to check that each net has one and only one driver. This is for
    Cell that are not P&R (in which it is also checked). So, typically
    the chip level.
* New: In cumulus/plugins.chip.core2chip, add a call to oneDriver().
* Bug: In cumulus/plugins.chip.core2chip, clear Spice extensions after
    save. Otherwise we may use an outdated Spice extension after the
    P&R. This is were Net missing Spice::Bit may occur.
This commit is contained in:
Jean-Paul Chaput 2021-06-23 00:07:25 +02:00
parent 0d7e0fa88b
commit 98e95587cf
3 changed files with 105 additions and 2 deletions

View File

@ -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

View File

@ -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()

View File

@ -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