Upgraded gen_elhal.py to reference child HAL objects as derived classes (as opposed to the straight auto-generated base classes) on a command line switch (-D). This allows the construction of derived classes with higher level functionality added on top of the basic register and bit field accesses of the base class. When selected, derived classes will be needed for all the hierarchical class structure, whether adding functionality or not. The default behaviour is unchanged.
This commit is contained in:
parent
520d7000bf
commit
c9039fac77
1 changed files with 14 additions and 3 deletions
|
|
@ -38,7 +38,13 @@ class MemMapperElHal(MemMapperBase):
|
|||
print('MemMapperElHal')
|
||||
self.__useByteAddrs = False
|
||||
self.__enableTag = ''
|
||||
self.__classSuffix = 'Auto'
|
||||
MemMapperBase.__init__(self)
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# ---------------------------------------------------------
|
||||
def setDerivedClassOn(self):
|
||||
self.__classSuffix = ''
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Configure the byte address output mode
|
||||
|
|
@ -144,7 +150,7 @@ class MemMapperElHal(MemMapperBase):
|
|||
processStr = subBlocks[sb][attr.PROCESS]
|
||||
if processStr == 'enabled' or self.__enableTag in processStr:
|
||||
if sb.split(':')[0] not in sbList and sb != 'local' :
|
||||
wfp.write('#include "C' + self._underScore2CamelCase(sb.split(':')[0]) + 'Auto.h"\n')
|
||||
wfp.write('#include "C' + self._underScore2CamelCase(sb.split(':')[0]) + self.__classSuffix + '.h"\n')
|
||||
sbList.append(sb.split(':')[0])
|
||||
|
||||
if tagStr == 'CLASS':
|
||||
|
|
@ -339,7 +345,7 @@ class MemMapperElHal(MemMapperBase):
|
|||
if sb != 'local' and bus == 'csr' and (processStr == 'enabled' or self.__enableTag in processStr) :
|
||||
sbRoot = sb.split(':')[0]
|
||||
instance = subBlocks[sb][attr.INSTANCE]
|
||||
opStr += ' p' + self._underScore2CamelCase(sbRoot) + self._underScore2CamelCase(instance) + ' = new C' + self._underScore2CamelCase(sbRoot) + 'Auto('
|
||||
opStr += ' p' + self._underScore2CamelCase(sbRoot) + self._underScore2CamelCase(instance) + ' = new C' + self._underScore2CamelCase(sbRoot) + self.__classSuffix + '('
|
||||
firstLoop = False
|
||||
|
||||
for busName in sbDict[sb] :
|
||||
|
|
@ -372,7 +378,7 @@ class MemMapperElHal(MemMapperBase):
|
|||
instance = subBlocks[sb][attr.INSTANCE]
|
||||
processStr = subBlocks[sb][attr.PROCESS]
|
||||
if processStr == 'enabled' or self.__enableTag in processStr:
|
||||
opStr = ' C' + self._underScore2CamelCase(sb.split(':')[0]) + 'Auto* p' + \
|
||||
opStr = ' C' + self._underScore2CamelCase(sb.split(':')[0]) + self.__classSuffix + '* p' + \
|
||||
self._underScore2CamelCase(sb.split(':')[0]) + \
|
||||
self._underScore2CamelCase(instance) + ';\n'
|
||||
wfp.write(opStr)
|
||||
|
|
@ -412,6 +418,9 @@ def processCmdLine():
|
|||
# Process common command line options with inherited static base class method
|
||||
MemMapperElHal.processCmdLine(parser)
|
||||
|
||||
# Specific command line options added here
|
||||
parser.add_argument('-D', '--derived_classes', dest='devClasses', default=False, action='store_true', help='Use derived classes as class types of child objects (default false)')
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
# ###############################################################
|
||||
|
|
@ -430,6 +439,8 @@ if __name__ == '__main__':
|
|||
# Do initialisation for text object specific configurations
|
||||
memMap.setByteAddrMode(True)
|
||||
memMap.setEnableTag(enTag)
|
||||
if cmdArgs.devClasses:
|
||||
memMap.setDerivedClassOn()
|
||||
memMapHdrs.setByteAddrMode(True)
|
||||
memMapHdrs.setHeadersMode(True)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue