coriolis/crlcore/python/helpers/analogtechno.py

143 lines
5.3 KiB
Python
Raw Normal View History

Migration towards Python3, first stage: still based on C-Macros. * New: Python/C++ API level: * Write a new C++/template wrapper to get rid of boost::python * The int & long Python type are now merged. So a C/C++ level, it became "PyLong_X" (remove "PyInt_X") and at Python code level, it became "int" (remove "long"). * Change: VLSISAPD finally defunct. * Configuration is now integrated as a Hurricane component, makes use of the new C++/template wrapper. * vlsisapd is now defunct. Keep it in the source for now as some remaining non essential code may have to be ported in the future. * Note: Python code (copy of the migration howto): * New print function syntax print(). * Changed "dict.has_key(k)" for "k" in dict. * Changed "except Exception, e" for "except Exception as e". * The division "/" is now the floating point division, even if both operand are integers. So 3/2 now gives 1.5 and no longer 1. The integer division is now "//" : 1 = 3//2. So have to carefully review the code to update. Most of the time we want to use "//". We must never change to float for long that, in fact, represents DbU (exposed as Python int type). * execfile() must be replaced by exec(open("file").read()). * iter().__next__() becomes iter(x).__next__(). * __getslice__() has been removed, integrated to __getitem__(). * The formating used for str(type(o)) has changed, so In Stratus, have to update them ("<class 'MyClass'>" instead of "MyClass"). * the "types" module no longer supply values for default types like str (types.StringType) or list (types.StringType). Must use "isinstance()" where they were occuring. * Remove the 'L' to indicate "long integer" (like "12L"), now all Python integer are long. * Change in bootstrap: * Ported Coriolis builder (ccb) to Python3. * Ported Coriolis socInstaller.py to Python3. * Note: In PyQt4+Python3, QVariant no longer exists. Use None or directly convert using the python syntax: bool(x), int(x), ... By default, it is a string (str). * Note: PyQt4 bindings & Python3 under SL7. * In order to compile user's must upgrade to my own rebuild of PyQt 4 & 5 bindings 4.19.21-1.el7.soc. * Bug: In cumulus/plugins.block.htree.HTree.splitNet(), set the root buffer of the H-Tree to the original signal (mainly: top clock). Strangely, it was only done when working in full chip mode.
2021-09-19 12:41:24 -05:00
# -*- Mode:Python -*-
#
# This file is part of the Coriolis Software.
Migration towards Python3, first stage: still based on C-Macros. * New: Python/C++ API level: * Write a new C++/template wrapper to get rid of boost::python * The int & long Python type are now merged. So a C/C++ level, it became "PyLong_X" (remove "PyInt_X") and at Python code level, it became "int" (remove "long"). * Change: VLSISAPD finally defunct. * Configuration is now integrated as a Hurricane component, makes use of the new C++/template wrapper. * vlsisapd is now defunct. Keep it in the source for now as some remaining non essential code may have to be ported in the future. * Note: Python code (copy of the migration howto): * New print function syntax print(). * Changed "dict.has_key(k)" for "k" in dict. * Changed "except Exception, e" for "except Exception as e". * The division "/" is now the floating point division, even if both operand are integers. So 3/2 now gives 1.5 and no longer 1. The integer division is now "//" : 1 = 3//2. So have to carefully review the code to update. Most of the time we want to use "//". We must never change to float for long that, in fact, represents DbU (exposed as Python int type). * execfile() must be replaced by exec(open("file").read()). * iter().__next__() becomes iter(x).__next__(). * __getslice__() has been removed, integrated to __getitem__(). * The formating used for str(type(o)) has changed, so In Stratus, have to update them ("<class 'MyClass'>" instead of "MyClass"). * the "types" module no longer supply values for default types like str (types.StringType) or list (types.StringType). Must use "isinstance()" where they were occuring. * Remove the 'L' to indicate "long integer" (like "12L"), now all Python integer are long. * Change in bootstrap: * Ported Coriolis builder (ccb) to Python3. * Ported Coriolis socInstaller.py to Python3. * Note: In PyQt4+Python3, QVariant no longer exists. Use None or directly convert using the python syntax: bool(x), int(x), ... By default, it is a string (str). * Note: PyQt4 bindings & Python3 under SL7. * In order to compile user's must upgrade to my own rebuild of PyQt 4 & 5 bindings 4.19.21-1.el7.soc. * Bug: In cumulus/plugins.block.htree.HTree.splitNet(), set the root buffer of the H-Tree to the original signal (mainly: top clock). Strangely, it was only done when working in full chip mode.
2021-09-19 12:41:24 -05:00
# Copyright (c) Sorbonne Université 2015-2021, All Rights Reserved
#
# +-----------------------------------------------------------------+
# | C O R I O L I S |
# | Alliance / Hurricane Interface |
# | |
# | Author : Jean-Paul CHAPUT |
# | E-mail : Jean-Paul.Chaput@lip6.fr |
# | =============================================================== |
# | Python : "./crlcore/python/helpers/analogtechno.py" |
# +-----------------------------------------------------------------+
import os
import os.path
import sys
import Hurricane
from Hurricane import DbU
from Hurricane import DataBase
from Hurricane import Layer
from helpers.io import ErrorMessage
technoFile = '<technoFile has not been set>'
Length = 0x0001
Area = 0x0002
Asymmetric = 0x0004
Unit = 0x0008
def valueToDbU ( value, unit, lengthType ):
length = DbU.fromPhysical( value, unit )
if lengthType & Length: return length
area = DbU.fromPhysical( float(length), unit )
return area
Enhanced techno rule support. Inspector support bug fix. * Bug: In Hurricane/Commons.h, modify the getRecord<>() templates so that for both vector<Element> and vector<Element*>, the individual record created for each element are donne with pointers. That is, for the vector<Element> case, we take a pointer. As a general policy, except for the POD types, always use pointers or references to data in the records/inspector. Never uses values that can call the copy constructor. Suppress INSPECTOR_PV_SUPPORT() macro, keep only INSPECTOR_PR_SUPPORT(). Provide value support only for getString<>() template. This value & copy constructor problem was causing a crash when trying to inspect Hurricane::AnalogCellExtension. * New: In Hurricane::Technology, change the API of the PhysicalRule, now we can only create/get PhysicalRule, but setting the value of the rule itself must be done on the rule. Enhance PhysicalRule to provide for stepped rules, non isotropic and ratio rules. Merge TwoLayersPhysicalrule in PhysicalRule, much simpler to suppress the management of derived classes. That means that we loose a little memory as some fields are mutually exclusive. Not a problem considering that there will not be so many of thoses objects. * New: In CRL/helpers.analogtechno.py, enhanced DTR support for rules like: ('minSpacing' , 'metal1', ((0.4,20.0), (0.8,1000.0)), Length, 'REF.1') ('minEnclosure', 'metal1', 'cut1', (0.2,0.3) , Length, 'REF.2') ('minDensity' , 'metal1', 0.30 , Unit , 'REF.3') The DTR parser has been updated, but not the oroshi.dtr Rule cache for analog components. Given a rule name, the value used will be the horizontal one of the first step. * Change: In hurricane/doc/hurricane, re-generate the documentation with updated support for Technology & PhysicalRule.
2020-07-21 04:22:04 -05:00
def isStepped ( entry ):
if isinstance(entry,tuple):
for item in entry:
if not isinstance(item,tuple) or len(item) != 2:
return False
return True
return False
def isNonIsotropic ( entry ):
if not isinstance(entry,tuple) or len(entry) != 2: return False
if not isinstance(entry[0],int) and not isinstance(entry[0],float): return False
if not isinstance(entry[1],int) and not isinstance(entry[1],float): return False
return True
def checkEntry ( entry, entryNo ):
if not isinstance(entry,tuple):
Enhanced techno rule support. Inspector support bug fix. * Bug: In Hurricane/Commons.h, modify the getRecord<>() templates so that for both vector<Element> and vector<Element*>, the individual record created for each element are donne with pointers. That is, for the vector<Element> case, we take a pointer. As a general policy, except for the POD types, always use pointers or references to data in the records/inspector. Never uses values that can call the copy constructor. Suppress INSPECTOR_PV_SUPPORT() macro, keep only INSPECTOR_PR_SUPPORT(). Provide value support only for getString<>() template. This value & copy constructor problem was causing a crash when trying to inspect Hurricane::AnalogCellExtension. * New: In Hurricane::Technology, change the API of the PhysicalRule, now we can only create/get PhysicalRule, but setting the value of the rule itself must be done on the rule. Enhance PhysicalRule to provide for stepped rules, non isotropic and ratio rules. Merge TwoLayersPhysicalrule in PhysicalRule, much simpler to suppress the management of derived classes. That means that we loose a little memory as some fields are mutually exclusive. Not a problem considering that there will not be so many of thoses objects. * New: In CRL/helpers.analogtechno.py, enhanced DTR support for rules like: ('minSpacing' , 'metal1', ((0.4,20.0), (0.8,1000.0)), Length, 'REF.1') ('minEnclosure', 'metal1', 'cut1', (0.2,0.3) , Length, 'REF.2') ('minDensity' , 'metal1', 0.30 , Unit , 'REF.3') The DTR parser has been updated, but not the oroshi.dtr Rule cache for analog components. Given a rule name, the value used will be the horizontal one of the first step. * Change: In hurricane/doc/hurricane, re-generate the documentation with updated support for Technology & PhysicalRule.
2020-07-21 04:22:04 -05:00
raise ErrorMessage( 1, [ 'Entry %d is malformed in <analogTechnologyTable>.' % entryNo
, 'Not a tuple (a, b, c, ...) or (a,).'
, str(entry)
] )
if not len(entry) in (4, 5, 6):
Enhanced techno rule support. Inspector support bug fix. * Bug: In Hurricane/Commons.h, modify the getRecord<>() templates so that for both vector<Element> and vector<Element*>, the individual record created for each element are donne with pointers. That is, for the vector<Element> case, we take a pointer. As a general policy, except for the POD types, always use pointers or references to data in the records/inspector. Never uses values that can call the copy constructor. Suppress INSPECTOR_PV_SUPPORT() macro, keep only INSPECTOR_PR_SUPPORT(). Provide value support only for getString<>() template. This value & copy constructor problem was causing a crash when trying to inspect Hurricane::AnalogCellExtension. * New: In Hurricane::Technology, change the API of the PhysicalRule, now we can only create/get PhysicalRule, but setting the value of the rule itself must be done on the rule. Enhance PhysicalRule to provide for stepped rules, non isotropic and ratio rules. Merge TwoLayersPhysicalrule in PhysicalRule, much simpler to suppress the management of derived classes. That means that we loose a little memory as some fields are mutually exclusive. Not a problem considering that there will not be so many of thoses objects. * New: In CRL/helpers.analogtechno.py, enhanced DTR support for rules like: ('minSpacing' , 'metal1', ((0.4,20.0), (0.8,1000.0)), Length, 'REF.1') ('minEnclosure', 'metal1', 'cut1', (0.2,0.3) , Length, 'REF.2') ('minDensity' , 'metal1', 0.30 , Unit , 'REF.3') The DTR parser has been updated, but not the oroshi.dtr Rule cache for analog components. Given a rule name, the value used will be the horizontal one of the first step. * Change: In hurricane/doc/hurricane, re-generate the documentation with updated support for Technology & PhysicalRule.
2020-07-21 04:22:04 -05:00
raise ErrorMessage( 1, [ 'Entry %d is malformed in <analogTechnologyTable>.' % entryNo
, 'Tuple must have *4*, *5* or *6* items only.'
, str(entry)
] )
if not entry[-2] in (Length, Length|Asymmetric, Area, Unit):
Enhanced techno rule support. Inspector support bug fix. * Bug: In Hurricane/Commons.h, modify the getRecord<>() templates so that for both vector<Element> and vector<Element*>, the individual record created for each element are donne with pointers. That is, for the vector<Element> case, we take a pointer. As a general policy, except for the POD types, always use pointers or references to data in the records/inspector. Never uses values that can call the copy constructor. Suppress INSPECTOR_PV_SUPPORT() macro, keep only INSPECTOR_PR_SUPPORT(). Provide value support only for getString<>() template. This value & copy constructor problem was causing a crash when trying to inspect Hurricane::AnalogCellExtension. * New: In Hurricane::Technology, change the API of the PhysicalRule, now we can only create/get PhysicalRule, but setting the value of the rule itself must be done on the rule. Enhance PhysicalRule to provide for stepped rules, non isotropic and ratio rules. Merge TwoLayersPhysicalrule in PhysicalRule, much simpler to suppress the management of derived classes. That means that we loose a little memory as some fields are mutually exclusive. Not a problem considering that there will not be so many of thoses objects. * New: In CRL/helpers.analogtechno.py, enhanced DTR support for rules like: ('minSpacing' , 'metal1', ((0.4,20.0), (0.8,1000.0)), Length, 'REF.1') ('minEnclosure', 'metal1', 'cut1', (0.2,0.3) , Length, 'REF.2') ('minDensity' , 'metal1', 0.30 , Unit , 'REF.3') The DTR parser has been updated, but not the oroshi.dtr Rule cache for analog components. Given a rule name, the value used will be the horizontal one of the first step. * Change: In hurricane/doc/hurricane, re-generate the documentation with updated support for Technology & PhysicalRule.
2020-07-21 04:22:04 -05:00
raise ErrorMessage( 1, [ 'Entry %d is malformed in <analogTechnologyTable>.' % entryNo
, 'Beforelast item is neither Length, Length|Asymmetric nor Area.'
, str(entry)
] )
return
def _loadAnalogTechno ( techno, ruleTable ):
unit = None
entryNo = 0
for entry in ruleTable:
Enhanced techno rule support. Inspector support bug fix. * Bug: In Hurricane/Commons.h, modify the getRecord<>() templates so that for both vector<Element> and vector<Element*>, the individual record created for each element are donne with pointers. That is, for the vector<Element> case, we take a pointer. As a general policy, except for the POD types, always use pointers or references to data in the records/inspector. Never uses values that can call the copy constructor. Suppress INSPECTOR_PV_SUPPORT() macro, keep only INSPECTOR_PR_SUPPORT(). Provide value support only for getString<>() template. This value & copy constructor problem was causing a crash when trying to inspect Hurricane::AnalogCellExtension. * New: In Hurricane::Technology, change the API of the PhysicalRule, now we can only create/get PhysicalRule, but setting the value of the rule itself must be done on the rule. Enhance PhysicalRule to provide for stepped rules, non isotropic and ratio rules. Merge TwoLayersPhysicalrule in PhysicalRule, much simpler to suppress the management of derived classes. That means that we loose a little memory as some fields are mutually exclusive. Not a problem considering that there will not be so many of thoses objects. * New: In CRL/helpers.analogtechno.py, enhanced DTR support for rules like: ('minSpacing' , 'metal1', ((0.4,20.0), (0.8,1000.0)), Length, 'REF.1') ('minEnclosure', 'metal1', 'cut1', (0.2,0.3) , Length, 'REF.2') ('minDensity' , 'metal1', 0.30 , Unit , 'REF.3') The DTR parser has been updated, but not the oroshi.dtr Rule cache for analog components. Given a rule name, the value used will be the horizontal one of the first step. * Change: In hurricane/doc/hurricane, re-generate the documentation with updated support for Technology & PhysicalRule.
2020-07-21 04:22:04 -05:00
entryNo += 1
try:
if entryNo > 1: checkEntry( entry, entryNo )
if entry[0] == 'Header':
unit = entry[2]
techno.setName( entry[1] )
continue
# Zero-layer rule.
if len(entry) == 4:
if entry[2] & Unit:
rule = techno.addUnitRule( entry[0], entry[3] )
rule.addValue( entry[1] )
else:
rule = techno.addPhysicalRule( entry[0], entry[3] )
rule.addValue( valueToDbU(entry[1], unit, entry[2]), 0 )
# One-layer rule.
if len(entry) == 5:
rule = techno.addPhysicalRule( entry[0], entry[1], entry[4] )
if entry[3] & Unit:
rule.addValue( entry[2] )
else:
if isStepped(entry[2]):
for step in entry[2]:
rule.addValue( valueToDbU(step[0], unit, entry[3])
, valueToDbU(step[1], unit, entry[3]) )
elif isNonIsotropic(entry[2]):
rule.addValue( valueToDbU(entry[2][0], unit, entry[3])
, valueToDbU(entry[2][1], unit, entry[3])
, 0 )
else:
rule.addValue( valueToDbU(entry[2], unit, entry[3]), 0 )
# Two-layer rule.
if len(entry) == 6:
symmetric = True
if entry[4] & Asymmetric: symmetric = False
rule = techno.addPhysicalRule( entry[0], entry[1], entry[2], entry[5] )
rule.setSymmetric( symmetric )
if isNonIsotropic(entry[3]):
rule.addValue( valueToDbU(entry[3][0], unit, entry[4])
, valueToDbU(entry[3][1], unit, entry[4])
, 0 )
else:
rule.addValue( valueToDbU(entry[3], unit, entry[4]), 0 )
Migration towards Python3, first stage: still based on C-Macros. * New: Python/C++ API level: * Write a new C++/template wrapper to get rid of boost::python * The int & long Python type are now merged. So a C/C++ level, it became "PyLong_X" (remove "PyInt_X") and at Python code level, it became "int" (remove "long"). * Change: VLSISAPD finally defunct. * Configuration is now integrated as a Hurricane component, makes use of the new C++/template wrapper. * vlsisapd is now defunct. Keep it in the source for now as some remaining non essential code may have to be ported in the future. * Note: Python code (copy of the migration howto): * New print function syntax print(). * Changed "dict.has_key(k)" for "k" in dict. * Changed "except Exception, e" for "except Exception as e". * The division "/" is now the floating point division, even if both operand are integers. So 3/2 now gives 1.5 and no longer 1. The integer division is now "//" : 1 = 3//2. So have to carefully review the code to update. Most of the time we want to use "//". We must never change to float for long that, in fact, represents DbU (exposed as Python int type). * execfile() must be replaced by exec(open("file").read()). * iter().__next__() becomes iter(x).__next__(). * __getslice__() has been removed, integrated to __getitem__(). * The formating used for str(type(o)) has changed, so In Stratus, have to update them ("<class 'MyClass'>" instead of "MyClass"). * the "types" module no longer supply values for default types like str (types.StringType) or list (types.StringType). Must use "isinstance()" where they were occuring. * Remove the 'L' to indicate "long integer" (like "12L"), now all Python integer are long. * Change in bootstrap: * Ported Coriolis builder (ccb) to Python3. * Ported Coriolis socInstaller.py to Python3. * Note: In PyQt4+Python3, QVariant no longer exists. Use None or directly convert using the python syntax: bool(x), int(x), ... By default, it is a string (str). * Note: PyQt4 bindings & Python3 under SL7. * In order to compile user's must upgrade to my own rebuild of PyQt 4 & 5 bindings 4.19.21-1.el7.soc. * Bug: In cumulus/plugins.block.htree.HTree.splitNet(), set the root buffer of the H-Tree to the original signal (mainly: top clock). Strangely, it was only done when working in full chip mode.
2021-09-19 12:41:24 -05:00
except Exception as e:
Enhanced techno rule support. Inspector support bug fix. * Bug: In Hurricane/Commons.h, modify the getRecord<>() templates so that for both vector<Element> and vector<Element*>, the individual record created for each element are donne with pointers. That is, for the vector<Element> case, we take a pointer. As a general policy, except for the POD types, always use pointers or references to data in the records/inspector. Never uses values that can call the copy constructor. Suppress INSPECTOR_PV_SUPPORT() macro, keep only INSPECTOR_PR_SUPPORT(). Provide value support only for getString<>() template. This value & copy constructor problem was causing a crash when trying to inspect Hurricane::AnalogCellExtension. * New: In Hurricane::Technology, change the API of the PhysicalRule, now we can only create/get PhysicalRule, but setting the value of the rule itself must be done on the rule. Enhance PhysicalRule to provide for stepped rules, non isotropic and ratio rules. Merge TwoLayersPhysicalrule in PhysicalRule, much simpler to suppress the management of derived classes. That means that we loose a little memory as some fields are mutually exclusive. Not a problem considering that there will not be so many of thoses objects. * New: In CRL/helpers.analogtechno.py, enhanced DTR support for rules like: ('minSpacing' , 'metal1', ((0.4,20.0), (0.8,1000.0)), Length, 'REF.1') ('minEnclosure', 'metal1', 'cut1', (0.2,0.3) , Length, 'REF.2') ('minDensity' , 'metal1', 0.30 , Unit , 'REF.3') The DTR parser has been updated, but not the oroshi.dtr Rule cache for analog components. Given a rule name, the value used will be the horizontal one of the first step. * Change: In hurricane/doc/hurricane, re-generate the documentation with updated support for Technology & PhysicalRule.
2020-07-21 04:22:04 -05:00
e = ErrorMessage( 1, e )
e.addMessage( 'In {}:<analogTechnologyTable> at index {}.'.format(technoFile,entryNo) )
print( str(e) )
return
def loadAnalogTechno ( table, fromFile ):
global technoFile
technoFile = fromFile
techno = DataBase.getDB().getTechnology()
_loadAnalogTechno( techno, table )
return