GIS-6905 HDL generation script updated to allow overriding of default output directory, support for mix of sub-block hierarchy and register definitions, and fix for w0 register/field of multi-bit width.

This commit is contained in:
Simon Southwell 2018-01-18 08:37:14 +00:00
commit 5d815ac46e

View file

@ -377,6 +377,12 @@ class MemMapperHdl(MemMapperBase) :
opStr += resetStr
elif modifierStr == 'avs':
opStr += 'avs_writedata(' + str(upBit) + ' downto ' + str(loBit) + ')'
elif modifierStr == 'w0default' :
if (upBit - loBit) == 0 :
opStr += '\'0\''
else :
opStr += '(others => \'0\')'
else :
opStr += modifierStr
@ -624,8 +630,11 @@ class MemMapperHdl(MemMapperBase) :
# Get the dictionary associated with this sub-block and construct a port name
# from the sub-block's name, and the instance parameter
sbDict = subBlockDict[subBlockEntry]
instance = sbDict[attr.INSTANCE]
portName = subBlock + '_' + instance
if sbDict[attr.INSTANCE] == '' :
instance = ''
else :
instance = '_' + sbDict[attr.INSTANCE]
portName = subBlock + instance
# Append the port name to the list, for later
portNameList.append(portName)
@ -637,13 +646,13 @@ class MemMapperHdl(MemMapperBase) :
wfp.write(' ' + portName + ': out std_logic;\n')
# Output the read pulse port definition
portName = subBlock + '_' + instance + '_read'
portName = subBlock + instance + '_read'
if len(portName) < colWidth:
portName += ' ' * (colWidth - len(portName))
wfp.write(' ' + portName + ': out std_logic;\n')
# Output the readdata port definition
portName = subBlock + '_' + instance + '_readdata'
portName = subBlock + instance + '_readdata'
if len(portName) < colWidth:
portName += ' ' * (colWidth - len(portName))
wfp.write(' ' + portName + ': in std_logic_vector(31 downto 0);\n')
@ -657,12 +666,19 @@ class MemMapperHdl(MemMapperBase) :
wfp.write(' avs_readdata <= ')
# Loop thorugh the sub-blocks to add their readdata busses to the assignment
for subBlock in subBlockDict :
for subBlockEntry in subBlockDict :
# Remove any key uniquifying tag
subBlock = subBlockEntry.split(':')[0]
# Construct and output the particular sub-block's readdata signal
sbDict = subBlockDict[subBlock]
instance = sbDict[attr.INSTANCE]
sbDict = subBlockDict[subBlockEntry]
if sbDict[attr.INSTANCE] == '' :
instance = ''
else :
instance = '_' + sbDict[attr.INSTANCE]
sbCount -= 1
wfp.write(subBlock + '_' + instance + '_readdata')
wfp.write(subBlock + instance + '_readdata')
# Follow the readdata signal name by either an 'or', or ';' if last entry
if sbCount == 0 :
@ -690,25 +706,31 @@ class MemMapperHdl(MemMapperBase) :
elif tagStr == 'DECODE_CASE_STATEMENTS' :
# Loop through the sub-blocks and construct the main decode case statement entries
for subBlock in subBlockDict :
for subBlockEntry in subBlockDict :
# Remove any key uniquifying tag
subBlock = subBlockEntry.split(':')[0]
# Get theparticular sub-block data dictionary, and extract the instance and
# (as an integer) offset values adjusted for given start bit
sbDict = subBlockDict[subBlock]
instance = sbDict[attr.INSTANCE]
sbDict = subBlockDict[subBlockEntry]
if sbDict[attr.INSTANCE] == '' :
instance = ''
else :
instance = '_' + sbDict[attr.INSTANCE]
offset = int(sbDict[attr.OFFSET], 0) >> addrLoBit
# Output the 'when' statement, with adjusted offset value
wfp.write(' when std_logic_vector(to_unsigned(' + str(offset) + ', ' + str(addrWidth) + ')) =>\n')
# Output the port's write strobe assignment to the bus write strobe port
portName = subBlock + '_' + instance + '_write'
portName = subBlock + instance + '_write'
if len(portName) < colWidth-4 :
portName += ' ' * (colWidth-4 - len(portName))
wfp.write(' ' + portName + ' <= avs_write;\n')
# Output the port's read strobe assignment to the bus read strobe port
portName = subBlock + '_' + instance + '_read'
portName = subBlock + instance + '_read'
if len(portName) < colWidth-4:
portName += ' ' * (colWidth-4 - len(portName))
wfp.write(' ' + portName + ' <= avs_read;\n\n')
@ -721,7 +743,7 @@ class MemMapperHdl(MemMapperBase) :
# Overload base classes virtual function with specific
# output generation (VHDL package)
# ---------------------------------------------------------
def genOutput(self, ip) :
def genOutput(self, ip, opDir) :
# Fetch the JSON path and the dictionary with the parsed data
jsonPath, jsonDict = self._getModel(ip)
@ -733,7 +755,10 @@ class MemMapperHdl(MemMapperBase) :
sep = os.sep
# Generate specific output. Assumes src/ exists (or will be created) in level above JSON file location.
srcDir = sep.join(jsonPath.split(sep)[:-2]) + sep + 'src'
if opDir == '':
srcDir = sep.join(jsonPath.split(sep)[:-2]) + sep + 'src'
else:
srcDir = opDir
# Check destination directory exists, and create it if not
if not os.path.exists(srcDir) :
@ -747,7 +772,9 @@ class MemMapperHdl(MemMapperBase) :
# If a hierarchy block, skip
if attr.SUB_BLOCKS in jsonBusDict:
self.__processSubBlocks(jsonBusDict, srcDir, bus, ip, sep)
continue
if attr.REGISTERS not in jsonBusDict :
continue
writeFileName = srcDir + sep + ip + '_' + bus + '_regs.vhd'
wfp = open(writeFileName, 'w')
@ -836,7 +863,7 @@ class MemMapperHdl(MemMapperBase) :
self.__opSignalAssignment(wfp, catDict, regtype.WRITE, '_reg', ' next_')
elif tagStr == 'WRITE_CLR0_NEXT_DEFAULTS' :
self.__opSignalAssignment(wfp, catDict, regtype.WRITE_CLR0, '\'0\'', ' next_')
self.__opSignalAssignment(wfp, catDict, regtype.WRITE_CLR0, 'w0default', ' next_')
elif tagStr == 'WRITE_PULSE_OUTPUTS_DEFAULT_0' :
self.__opSignalAssignment(wfp, catDict, regtype.WRITE_PULSE, '\'0\'', ' ',
@ -905,5 +932,5 @@ if __name__ == '__main__' :
memMapPkg = MemMapperPkg()
# Run the program for the package generation
memMapPkg.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir)
memMapPkg.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir, cmdArgs.opDir)
del memMapPkg