Added some sub-block support for sub-blocks not referenced from QSYS file, but instantiated in the hierarchy of the FPGA code.
This commit is contained in:
parent
29956ede8f
commit
834598ac95
6 changed files with 336 additions and 206 deletions
|
|
@ -63,6 +63,10 @@ class MemMapperCpp(MemMapperBase):
|
|||
# iterate through each bus dictionary
|
||||
for jsonBusDict in jsonDict :
|
||||
|
||||
# If a hierarchy block, skip
|
||||
if attr.SUB_BLOCKS in jsonBusDict:
|
||||
return
|
||||
|
||||
# Get the bus name from th dictionary
|
||||
bus = jsonBusDict[attr.BUS]
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ from gen_pkg import MemMapperPkg
|
|||
class MemMapperHdl(MemMapperBase) :
|
||||
|
||||
# Define 'constant' values for the class
|
||||
outputNameWidth = 25
|
||||
outputNameWidth = 30
|
||||
tabSpaces = 2
|
||||
|
||||
# ---------------------------------------------------------
|
||||
|
|
@ -86,10 +86,17 @@ class MemMapperHdl(MemMapperBase) :
|
|||
# Create a when statement for an address
|
||||
# ---------------------------------------------------------
|
||||
@staticmethod
|
||||
def __createWhenStr(bus, regName):
|
||||
def __createWhenStr(bus, regName, addrRange=''):
|
||||
|
||||
addrName = MemMapperHdl.createPkgTag(bus, regName)
|
||||
return '\n when ' + addrName + ' =>\n'
|
||||
|
||||
# If no address range given...
|
||||
if addrRange == '' :
|
||||
opStr = '\n when ' + addrName + ' =>\n'
|
||||
# Address range specified
|
||||
else :
|
||||
opStr = '\n when ' + addrName + ' to (' + addrName + ' + std_logic_vector(to_unsigned(' + addrRange + ', 32))) =>\n'
|
||||
return opStr
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Create a pulse assignment
|
||||
|
|
@ -123,49 +130,57 @@ class MemMapperHdl(MemMapperBase) :
|
|||
# Get the bus name from the dictionary
|
||||
bus = jsonBusDict[attr.BUS]
|
||||
|
||||
regDict = jsonBusDict[attr.REGISTERS]
|
||||
regKeys = regDict.keys()
|
||||
# Only process this IP if it has a "registers" entry
|
||||
if attr.REGISTERS in jsonBusDict :
|
||||
|
||||
# Loop through all the registers
|
||||
for regName in regKeys :
|
||||
regDict = jsonBusDict[attr.REGISTERS]
|
||||
regKeys = regDict.keys()
|
||||
|
||||
# If there are sub-fields, process them here
|
||||
if attr.FIELDS in regDict[regName] :
|
||||
# Loop through all the registers
|
||||
for regName in regKeys :
|
||||
|
||||
# Extract the fields dictionary from the register
|
||||
fields = regDict[regName][attr.FIELDS]
|
||||
if attr.ADDR_RANGE in regDict[regName] :
|
||||
addrRange = regDict[regName][attr.ADDR_RANGE]
|
||||
else :
|
||||
addrRange = ''
|
||||
|
||||
# Keep a bit position count, initialised to 0
|
||||
bitStart = 0
|
||||
# If there are sub-fields, process them here
|
||||
if attr.FIELDS in regDict[regName] :
|
||||
|
||||
# Loop through the fields
|
||||
for fieldName in fields :
|
||||
# Extract the fields dictionary from the register
|
||||
fields = regDict[regName][attr.FIELDS]
|
||||
|
||||
# Extract the field bit length, and calculate the top and bottom bit positions
|
||||
fieldLen = int(fields[fieldName][attr.BIT_LEN], 0)
|
||||
# Keep a bit position count, initialised to 0
|
||||
bitStart = 0
|
||||
|
||||
# Don't process reserved fields (but still need above bit calculations to skip them)
|
||||
if fields[fieldName][attr.TYPE] != regtype.RESERVED :
|
||||
# Loop through the fields
|
||||
for fieldName in fields :
|
||||
|
||||
# Construct a tuple of the entry's data for adding to the appropriate
|
||||
# list in the dictionary of types.
|
||||
regTuple = (bus, regName, fieldName,
|
||||
bitStart + fieldLen - 1, bitStart,
|
||||
fields[fieldName][attr.RESET])
|
||||
# Extract the field bit length, and calculate the top and bottom bit positions
|
||||
fieldLen = int(fields[fieldName][attr.BIT_LEN], 0)
|
||||
|
||||
# Add the field data tuples to the dictionary, depending on type
|
||||
typeDict[fields[fieldName][attr.TYPE]].append(regTuple)
|
||||
# Don't process reserved fields (but still need above bit calculations to skip them)
|
||||
if fields[fieldName][attr.TYPE] != regtype.RESERVED :
|
||||
|
||||
# Increment the bit start position to be the bit after current field
|
||||
bitStart += fieldLen
|
||||
else :
|
||||
# When no sub-fields, add the straight register name (with no suffix), and mark
|
||||
# the field name as 'NoFields' in the tuple of the register's data.
|
||||
width = int(regDict[regName][attr.WIDTH], 0)
|
||||
regTuple = (bus, regName, 'NoFields', width-1, 0, regDict[regName][attr.RESET])
|
||||
# Construct a tuple of the entry's data for adding to the appropriate
|
||||
# list in the dictionary of types.
|
||||
regTuple = (bus, regName, fieldName,
|
||||
bitStart + fieldLen - 1, bitStart,
|
||||
fields[fieldName][attr.RESET], addrRange)
|
||||
|
||||
# Add the register data tuples to the dictionary, depending on type
|
||||
typeDict[regDict[regName][attr.TYPE]].append(regTuple)
|
||||
# Add the field data tuples to the dictionary, depending on type
|
||||
typeDict[fields[fieldName][attr.TYPE]].append(regTuple)
|
||||
|
||||
# Increment the bit start position to be the bit after current field
|
||||
bitStart += fieldLen
|
||||
else :
|
||||
# When no sub-fields, add the straight register name (with no suffix), and mark
|
||||
# the field name as 'NoFields' in the tuple of the register's data.
|
||||
width = int(regDict[regName][attr.WIDTH], 0)
|
||||
regTuple = (bus, regName, 'NoFields', width-1, 0, regDict[regName][attr.RESET], addrRange)
|
||||
|
||||
# Add the register data tuples to the dictionary, depending on type
|
||||
typeDict[regDict[regName][attr.TYPE]].append(regTuple)
|
||||
|
||||
# Return the dictionary of types with their populated lists
|
||||
return typeDict
|
||||
|
|
@ -201,12 +216,48 @@ class MemMapperHdl(MemMapperBase) :
|
|||
# Output the string
|
||||
wfp.write(prefixStr + opStr + '\n')
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Output generics (if any needed)
|
||||
# ---------------------------------------------------------
|
||||
@staticmethod
|
||||
def __opGenerics(wfp, catDict, colWidth = None) :
|
||||
|
||||
# If no colWidth parameter defined, use default
|
||||
if colWidth is None:
|
||||
colWidth = MemMapperHdl.outputNameWidth
|
||||
|
||||
# Initialise lists maintained over main loop
|
||||
seenRegList = []
|
||||
|
||||
# Add all the write types categories to the category list
|
||||
catDictAll = []
|
||||
for regType in MemMapperHdl.validTypes:
|
||||
catDictAll += catDict[regType]
|
||||
|
||||
# Loop over all the categories
|
||||
for wreg in catDictAll :
|
||||
|
||||
# Get the elements of the tuple into meaningful names
|
||||
bus, regName, fieldName, upBit, loBit, resetStr, addrRange = wreg
|
||||
|
||||
# If this is a new register, do one-off processing
|
||||
if regName not in seenRegList :
|
||||
|
||||
if addrRange != '' :
|
||||
if len(addrRange) < colWidth:
|
||||
addrRange += ' ' * (colWidth - len(addrRange))
|
||||
wfp.write(' ' + addrRange + ' : integer range 0 to 65536 := 0;\n')
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Output port declarations for the given type and direction
|
||||
# ---------------------------------------------------------
|
||||
def __opPortDeclaration(self, wfp, catDict, regType, typeIsPulse=False, dirIsOp=True,
|
||||
colWidth=None) :
|
||||
|
||||
# If no colWidth parameter defined, use default
|
||||
if colWidth is None:
|
||||
colWidth = MemMapperHdl.outputNameWidth
|
||||
|
||||
# Initialise lists maintained over main loop
|
||||
seenRegList = []
|
||||
|
||||
|
|
@ -214,7 +265,7 @@ class MemMapperHdl(MemMapperBase) :
|
|||
for wreg in catDict[regType]:
|
||||
|
||||
# Get the elements of the tuple into meaningful names
|
||||
bus, regName, fieldName, upBit, loBit, resetStr = wreg
|
||||
bus, regName, fieldName, upBit, loBit, resetStr, addrRange = wreg
|
||||
|
||||
# If this is the first time we've processed this register, output the pulse
|
||||
# signal declaration, and add to list of seen registers. This ensure just one pulse
|
||||
|
|
@ -242,13 +293,17 @@ class MemMapperHdl(MemMapperBase) :
|
|||
# ---------------------------------------------------------
|
||||
|
||||
def __opSignalDeclaration(self, wfp, catDict, prefixStr = 'signal ', suffixStr = '',
|
||||
colWidth=None):
|
||||
colWidth=None) :
|
||||
|
||||
# If no colWidth parameter defined, use default
|
||||
if colWidth is None:
|
||||
colWidth = MemMapperHdl.outputNameWidth
|
||||
|
||||
# Loop over all the writeable categories
|
||||
for wreg in catDict[regtype.WRITE] + catDict[regtype.WRITE_CLR0]:
|
||||
|
||||
# Get the elements of the tuple into meaningful names
|
||||
bus, regName, fieldName, upBit, loBit, resetStr = wreg
|
||||
bus, regName, fieldName, upBit, loBit, resetStr, addrRange = wreg
|
||||
|
||||
# Get a unique name for this port
|
||||
opStr = MemMapperHdl.__uniquifyName(regName, fieldName)
|
||||
|
|
@ -274,7 +329,7 @@ class MemMapperHdl(MemMapperBase) :
|
|||
for wreg in catDict[regType]:
|
||||
|
||||
# Get the elements of the tuple into meaningful names
|
||||
bus, regName, fieldName, upBit, loBit, resetStr = wreg
|
||||
bus, regName, fieldName, upBit, loBit, resetStr, addrRange = wreg
|
||||
|
||||
# Get a unique name for this port
|
||||
sigNameStr = MemMapperHdl.__uniquifyName(regName, fieldName)
|
||||
|
|
@ -308,6 +363,8 @@ class MemMapperHdl(MemMapperBase) :
|
|||
width = upBit - loBit + 1
|
||||
resetStr = MemMapperBase.valToStdLogic(resetVal, width)
|
||||
opStr += resetStr
|
||||
elif modifierStr == 'avs':
|
||||
opStr += 'avs_writedata(' + str(upBit) + ' downto ' + str(loBit) + ')'
|
||||
else :
|
||||
opStr += modifierStr
|
||||
|
||||
|
|
@ -336,7 +393,7 @@ class MemMapperHdl(MemMapperBase) :
|
|||
for wreg in catDictWrites :
|
||||
|
||||
# Get the elements of the tuple into meaningful names
|
||||
bus, regName, fieldName, upBit, loBit, resetStr = wreg
|
||||
bus, regName, fieldName, upBit, loBit, resetStr, addrRange = wreg
|
||||
|
||||
# Set flags to sub-catagorise this particular entry
|
||||
isPulse = False
|
||||
|
|
@ -365,26 +422,26 @@ class MemMapperHdl(MemMapperBase) :
|
|||
if not isPulse :
|
||||
sigNameStr = 'next_' + sigNameStr
|
||||
|
||||
# Pad the signal name to be the column width
|
||||
if len(sigNameStr) < colWidth :
|
||||
sigNameStr += ' ' * (colWidth - len(sigNameStr))
|
||||
# Pad the signal name to be the column width
|
||||
if len(sigNameStr) < colWidth :
|
||||
sigNameStr += ' ' * (colWidth - len(sigNameStr))
|
||||
|
||||
# Indentations
|
||||
opStr = ' ' * 5 * MemMapperHdl.tabSpaces
|
||||
# Indentations
|
||||
opStr = ' ' * 5 * MemMapperHdl.tabSpaces
|
||||
|
||||
# Add the write data signal from the bus to the output string
|
||||
opStr += sigNameStr + ' <= avs_writedata('
|
||||
# Add the write data signal from the bus to the output string
|
||||
opStr += sigNameStr + ' <= avs_writedata('
|
||||
|
||||
# If only a bit wide, add an indexed reference to the write data signal
|
||||
if upBit == loBit :
|
||||
opStr += str(upBit)
|
||||
# For multi-bit , append a bit slice
|
||||
else :
|
||||
opStr += str(upBit) + ' downto ' + str(loBit)
|
||||
# If only a bit wide, add an indexed reference to the write data signal
|
||||
if upBit == loBit :
|
||||
opStr += str(upBit)
|
||||
# For multi-bit , append a bit slice
|
||||
else :
|
||||
opStr += str(upBit) + ' downto ' + str(loBit)
|
||||
|
||||
# Finish off the output string and output
|
||||
opStr += ');\n'
|
||||
wfp.write(opStr)
|
||||
# Finish off the output string and output
|
||||
opStr += ');\n'
|
||||
wfp.write(opStr)
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Method to output read register cases entries (for both
|
||||
|
|
@ -417,7 +474,7 @@ class MemMapperHdl(MemMapperBase) :
|
|||
for rreg in catDictReads :
|
||||
|
||||
# Get the elements of the tuple into meaningful names
|
||||
bus, regName, fieldName, upBit, loBit, resetStr = rreg
|
||||
bus, regName, fieldName, upBit, loBit, resetStr, addrRange = rreg
|
||||
|
||||
# Set flags to sub-categorise this particular entry
|
||||
isWrPulse = rreg in catDict[regtype.WRITE_PULSE]
|
||||
|
|
@ -486,6 +543,9 @@ class MemMapperHdl(MemMapperBase) :
|
|||
# Fetch the JSON path and the dictionary with the parsed data
|
||||
jsonPath, jsonDict = self._getModel(ip)
|
||||
|
||||
if attr.SUB_BLOCKS in jsonDict :
|
||||
return
|
||||
|
||||
# Parse the model and sort the registers into categories
|
||||
catDict = self.__categoriseModel(jsonDict)
|
||||
|
||||
|
|
@ -501,6 +561,10 @@ class MemMapperHdl(MemMapperBase) :
|
|||
|
||||
for jsonBusDict in jsonDict :
|
||||
|
||||
# If a hierarchy block, skip
|
||||
if attr.SUB_BLOCKS in jsonBusDict:
|
||||
return
|
||||
|
||||
# Get the bus name from the dictionary
|
||||
bus = jsonBusDict[attr.BUS]
|
||||
|
||||
|
|
@ -514,7 +578,7 @@ class MemMapperHdl(MemMapperBase) :
|
|||
# Read in each line of the template, looking for tags
|
||||
for line in tfp :
|
||||
|
||||
# If the line has no tags, send straighht to output, unmodified
|
||||
# If the line has no tags, send straight to output, unmodified
|
||||
if '%%' not in line :
|
||||
wfp.write(line)
|
||||
|
||||
|
|
@ -549,6 +613,9 @@ class MemMapperHdl(MemMapperBase) :
|
|||
elif tagStr == 'REG_BLOCK' :
|
||||
wfp.write(tagLineSplit[0] + ip + '_' + bus + '_regs' + tagLineSplit[2])
|
||||
|
||||
elif tagStr == 'GENERICS' :
|
||||
self.__opGenerics(wfp, catDict)
|
||||
|
||||
elif tagStr == 'PORTLIST' :
|
||||
|
||||
# output internal write registers/fields
|
||||
|
|
@ -571,8 +638,13 @@ class MemMapperHdl(MemMapperBase) :
|
|||
self.__opSignalDeclaration(wfp, catDict, 'signal next_', '', MemMapperHdl.outputNameWidth-5)
|
||||
|
||||
elif tagStr == 'INTERNAL_WRITE_REG_EXPORTS' :
|
||||
# Export write regs to ports
|
||||
self.__opSignalAssignment(wfp, catDict, regtype.WRITE, '_reg')
|
||||
|
||||
# Export write pulse ports from avs_writedata bus
|
||||
wfp.write('\n -- Export AVS write bus to write pulse register ports\n')
|
||||
self.__opSignalAssignment(wfp, catDict, regtype.WRITE_PULSE, 'avs')
|
||||
|
||||
elif tagStr == 'INTERNAL_WRITE_REG_NEXT_DEFAULTS' :
|
||||
self.__opSignalAssignment(wfp, catDict, regtype.WRITE, '_reg', ' next_')
|
||||
|
||||
|
|
|
|||
|
|
@ -86,12 +86,17 @@ class MemMapperPkg(MemMapperBase) :
|
|||
wfp.write('-- Block name: ' + jsonDict[0][attr.IP_NAME] + '\n')
|
||||
wfp.write('-- And now for some register addresses...\n')
|
||||
wfp.write('library ieee;\n')
|
||||
wfp.write('use ieee.std_logic_1164.all;\n\n')
|
||||
wfp.write('use ieee.std_logic_1164.all;\n')
|
||||
wfp.write('use ieee.std_logic_arith.all;\n\n')
|
||||
wfp.write('package ' + ip + '_pkg is\n\n')
|
||||
|
||||
# Iterate through each bus dictionary
|
||||
for jsonBusDict in jsonDict :
|
||||
|
||||
# If a hierarchy block, skip
|
||||
if attr.SUB_BLOCKS in jsonBusDict:
|
||||
return
|
||||
|
||||
# Get the bus name from the dictionary
|
||||
bus = jsonBusDict[attr.BUS]
|
||||
|
||||
|
|
@ -104,20 +109,27 @@ class MemMapperPkg(MemMapperBase) :
|
|||
for regName in regKeys :
|
||||
|
||||
# An '_ADDR' suffix for the register address definition
|
||||
regFullName = MemMapperBase.createPkgTag(bus, regName)
|
||||
regFullName = MemMapperBase.createPkgTag(bus, regName)
|
||||
regFullUsName = regFullName + '_US'
|
||||
|
||||
# Pad the output string to a fixed value
|
||||
regFullName = MemMapperPkg.__padString(regFullName, MemMapperPkg.outputNameWidth)
|
||||
regFullName = MemMapperPkg.__padString(regFullName, MemMapperPkg.outputNameWidth)
|
||||
regFullUsName = MemMapperPkg.__padString(regFullUsName, MemMapperPkg.outputNameWidth)
|
||||
|
||||
# Output the address declaration for this register
|
||||
wfp.write(' constant ' + regFullName + ' : std_logic_vector(31 downto 0) := x\"')
|
||||
opStr = ' constant ' + regFullName + ' : std_logic_vector(31 downto 0) := x\"'
|
||||
|
||||
# Get the address value form the dictionary, and convert to an integer value
|
||||
addrVal = int(str(regDict[regName][attr.ADDRESS]), 0)
|
||||
|
||||
# Generate a hex string for the value (without a leading '0x') and output
|
||||
addrValHex = format(addrVal, '08x')
|
||||
wfp.write(addrValHex + '\";\n')
|
||||
opStr += addrValHex + '\";\n'
|
||||
wfp.write(opStr)
|
||||
|
||||
opStr = ' constant ' + regFullUsName + ' : unsigned(31 downto 0) := x\"'
|
||||
opStr += addrValHex + '\";\n'
|
||||
wfp.write(opStr)
|
||||
|
||||
# If there are sub-fields, process them here
|
||||
if attr.FIELDS in regDict[regName] :
|
||||
|
|
|
|||
|
|
@ -221,6 +221,10 @@ class MemMapperTxt(MemMapperBase):
|
|||
# Iterate through each bus dictionary
|
||||
for jsonBusDict in jsonDict :
|
||||
|
||||
# If a hierarchy block, skip
|
||||
if attr.SUB_BLOCKS in jsonBusDict:
|
||||
return
|
||||
|
||||
# Get the bus name from the dictionary
|
||||
bus = jsonBusDict[attr.BUS]
|
||||
|
||||
|
|
|
|||
|
|
@ -34,13 +34,14 @@ class attr :
|
|||
BUS = 'bus'
|
||||
REGISTERS = 'registers'
|
||||
ADDRESS = 'address'
|
||||
ADDR_RANGE = 'addr_range'
|
||||
TYPE = 'type'
|
||||
RESET = 'reset'
|
||||
WIDTH = 'width'
|
||||
DESCRIPTION = 'description'
|
||||
FIELDS = 'fields'
|
||||
BIT_LEN = 'bit_len'
|
||||
SUB_BLOCK = 'sub_block'
|
||||
SUB_BLOCKS = 'sub_blocks'
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# class to define string literals for valid registers types
|
||||
|
|
@ -194,10 +195,10 @@ class MemMapperBase :
|
|||
return os.path.abspath(totalPath)
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Go through the IP list and find the directories for all the JSON files.
|
||||
# (private method)
|
||||
# Go through the IP list and find the directories for
|
||||
# the JSON files. (private method)
|
||||
# ---------------------------------------------------------
|
||||
def __getAllJsonPaths(self, jsonPaths, ipArray):
|
||||
def __getJsonPaths(self, jsonPaths, ipArray):
|
||||
|
||||
for directory in self.docDirs:
|
||||
fileList = os.listdir(directory)
|
||||
|
|
@ -306,6 +307,30 @@ class MemMapperBase :
|
|||
for ip in ipArray:
|
||||
self.genOutput(ip) # Virtual function, not defined in this base class
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Process all the sub-blocks and add to ipArray the entries
|
||||
# not already present
|
||||
# ---------------------------------------------------------
|
||||
def __processSubBlocks(self, ipArray) :
|
||||
|
||||
subBlockArray = []
|
||||
|
||||
for ip in ipArray :
|
||||
|
||||
# Fetch the JSON path and the dictionary with the parsed data
|
||||
jsonPath, jsonDict = self._getModel(ip)
|
||||
|
||||
for jsonBusDict in jsonDict :
|
||||
|
||||
if attr.SUB_BLOCKS in jsonBusDict :
|
||||
subBlocks = jsonBusDict[attr.SUB_BLOCKS]
|
||||
|
||||
for ipName in subBlocks :
|
||||
if subBlocks[ipName] == 'process' :
|
||||
subBlockArray.append(ipName)
|
||||
ipArray += subBlockArray
|
||||
return
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Get the model data (protected method)
|
||||
# ---------------------------------------------------------
|
||||
|
|
@ -335,177 +360,183 @@ class MemMapperBase :
|
|||
# Get the bus name from the dictionary
|
||||
bus = jsonBusDict[attr.BUS]
|
||||
|
||||
regDict = jsonBusDict[attr.REGISTERS]
|
||||
regKeys = regDict.keys()
|
||||
seenRegNames = []
|
||||
seenAddresses = []
|
||||
|
||||
for regName in regKeys :
|
||||
|
||||
# All registers entries must have an address
|
||||
if attr.ADDRESS not in regDict[regName]:
|
||||
print('***Error: no address found for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
if attr.REGISTERS not in jsonBusDict :
|
||||
# If no registers, must have a sub-block list
|
||||
if attr.SUB_BLOCKS not in jsonBusDict :
|
||||
errorsFound = True
|
||||
else :
|
||||
# No repeated addresses
|
||||
addrVal = int(regDict[regName][attr.ADDRESS], 0)
|
||||
if addrVal in seenAddresses:
|
||||
print('***Error: seen repeated register address ' + regDict[regName][attr.ADDRESS] +
|
||||
else :
|
||||
|
||||
regDict = jsonBusDict[attr.REGISTERS]
|
||||
regKeys = regDict.keys()
|
||||
seenRegNames = []
|
||||
seenAddresses = []
|
||||
|
||||
for regName in regKeys :
|
||||
|
||||
# All registers entries must have an address
|
||||
if attr.ADDRESS not in regDict[regName]:
|
||||
print('***Error: no address found for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
else:
|
||||
seenAddresses.append(addrVal)
|
||||
|
||||
# All registers entries must have a description
|
||||
if attr.DESCRIPTION not in regDict[regName]:
|
||||
print('***Error: no description found for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# All registers entries must have a width and it must be in the range 1 to 32
|
||||
if attr.WIDTH not in regDict[regName]:
|
||||
print('***Error: no width attribute found for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
else :
|
||||
widthVal = int(regDict[regName][attr.WIDTH], 0)
|
||||
if widthVal < 1 or widthVal > 32 :
|
||||
print('***Error: width value (' + regDict[regName][attr.WIDTH] +
|
||||
') out of range for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
|
||||
# No repeated register names in this block
|
||||
if regName in seenRegNames :
|
||||
print('***Error: seen repeated register name ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
else :
|
||||
seenRegNames.append(regName)
|
||||
|
||||
# If there are sub-fields, process them here
|
||||
if attr.FIELDS in regDict[regName] :
|
||||
|
||||
# If a fields attribute present, register must not have a type
|
||||
if attr.TYPE in regDict[regName] :
|
||||
print('***Error: register has type definition when fields attribute present ' +
|
||||
' for ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# If a fields attribute present, register must not have a reset attribute
|
||||
if attr.RESET in regDict[regName]:
|
||||
print('***Error: register has reset definition when fields attribute present ' +
|
||||
' for ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# Extract the fields dictionary from the register
|
||||
fields = regDict[regName][attr.FIELDS]
|
||||
|
||||
# There must be more than one field, if fields defined
|
||||
if not len(fields) > 1 :
|
||||
print('***Error: less than two fields in fields section defined for ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# Initialise some state to be sticky or accumulated through the fieldName loop
|
||||
seenWrType = False
|
||||
seenRdType = False
|
||||
bitCount = 0
|
||||
|
||||
# Loop through the fields
|
||||
for fieldName in fields :
|
||||
|
||||
# All fields must have a description
|
||||
if attr.DESCRIPTION not in fields[fieldName] :
|
||||
print('***Error: no description attribute found for ' + fieldName +
|
||||
' of register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# All fields must have a type
|
||||
if attr.TYPE not in fields[fieldName] :
|
||||
print('***Error: no type attribute found for ' + fieldName +
|
||||
' of register ' + regName +
|
||||
else :
|
||||
# No repeated addresses
|
||||
addrVal = int(regDict[regName][attr.ADDRESS], 0)
|
||||
if addrVal in seenAddresses:
|
||||
print('***Error: seen repeated register address ' + regDict[regName][attr.ADDRESS] +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
else :
|
||||
# The type must be a valid value
|
||||
if fields[fieldName][attr.TYPE] not in MemMapperBase.validTypes :
|
||||
print('***Error: bad type attribute (' + fields[fieldName][attr.TYPE] + ') found for ' + fieldName +
|
||||
else:
|
||||
seenAddresses.append(addrVal)
|
||||
|
||||
# All registers entries must have a description
|
||||
if attr.DESCRIPTION not in regDict[regName]:
|
||||
print('***Error: no description found for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# All registers entries must have a width and it must be in the range 1 to 32
|
||||
if attr.WIDTH not in regDict[regName]:
|
||||
print('***Error: no width attribute found for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
else :
|
||||
widthVal = int(regDict[regName][attr.WIDTH], 0)
|
||||
if widthVal < 1 or widthVal > 32 :
|
||||
print('***Error: width value (' + regDict[regName][attr.WIDTH] +
|
||||
') out of range for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
|
||||
# No repeated register names in this block
|
||||
if regName in seenRegNames :
|
||||
print('***Error: seen repeated register name ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
else :
|
||||
seenRegNames.append(regName)
|
||||
|
||||
# If there are sub-fields, process them here
|
||||
if attr.FIELDS in regDict[regName] :
|
||||
|
||||
# If a fields attribute present, register must not have a type
|
||||
if attr.TYPE in regDict[regName] :
|
||||
print('***Error: register has type definition when fields attribute present ' +
|
||||
' for ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# If a fields attribute present, register must not have a reset attribute
|
||||
if attr.RESET in regDict[regName]:
|
||||
print('***Error: register has reset definition when fields attribute present ' +
|
||||
' for ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# Extract the fields dictionary from the register
|
||||
fields = regDict[regName][attr.FIELDS]
|
||||
|
||||
# There must be more than one field, if fields defined
|
||||
if not len(fields) > 1 :
|
||||
print('***Error: less than two fields in fields section defined for ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# Initialise some state to be sticky or accumulated through the fieldName loop
|
||||
seenWrType = False
|
||||
seenRdType = False
|
||||
bitCount = 0
|
||||
|
||||
# Loop through the fields
|
||||
for fieldName in fields :
|
||||
|
||||
# All fields must have a description
|
||||
if attr.DESCRIPTION not in fields[fieldName] :
|
||||
print('***Error: no description attribute found for ' + fieldName +
|
||||
' of register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# All fields must have a type
|
||||
if attr.TYPE not in fields[fieldName] :
|
||||
print('***Error: no type attribute found for ' + fieldName +
|
||||
' of register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
else :
|
||||
# The type must be a valid value
|
||||
if fields[fieldName][attr.TYPE] not in MemMapperBase.validTypes :
|
||||
print('***Error: bad type attribute (' + fields[fieldName][attr.TYPE] + ') found for ' + fieldName +
|
||||
' of register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# All fields must have a bit_len
|
||||
if attr.BIT_LEN not in fields[fieldName] :
|
||||
|
||||
print('***Error: no bit_len attribute found for ' + fieldName +
|
||||
' of register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# All fields must have a bit_len
|
||||
if attr.BIT_LEN not in fields[fieldName] :
|
||||
# All fields must have a reset except rsv
|
||||
if attr.TYPE in fields[fieldName]:
|
||||
|
||||
print('***Error: no bit_len attribute found for ' + fieldName +
|
||||
' of register ' + regName +
|
||||
# Reset present for non-reserved fields
|
||||
if fields[fieldName]['type'] != regtype.RESERVED :
|
||||
if attr.RESET not in fields[fieldName] :
|
||||
print('***Error: no reset attribute found for ' + fieldName +
|
||||
' of register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# If rsv type, then no reset should be present
|
||||
else :
|
||||
if attr.RESET in fields[fieldName] :
|
||||
print('***Error: reset attribute found for field ' + fieldName +
|
||||
' of register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
if attr.BIT_LEN in fields[fieldName]:
|
||||
bitCount += int(fields[fieldName][attr.BIT_LEN], 0)
|
||||
|
||||
if attr.TYPE in fields[fieldName] :
|
||||
|
||||
fieldType = fields[fieldName][attr.TYPE]
|
||||
|
||||
if fieldType in MemMapperBase.writeTypes :
|
||||
seenWrType = True
|
||||
|
||||
if fieldType in MemMapperBase.readTypes :
|
||||
seenRdType = False
|
||||
|
||||
# No mix of read and write types in fields
|
||||
if seenWrType and seenRdType :
|
||||
print('***Error: read and write types mixed in fields for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# All fields must have a reset except rsv
|
||||
if attr.TYPE in fields[fieldName]:
|
||||
if attr.WIDTH in regDict[regName] :
|
||||
if bitCount != int(regDict[regName][attr.WIDTH], 0) :
|
||||
print('***Error: field bits do not add up to register\'s width for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# Reset present for non-reserved fields
|
||||
if fields[fieldName]['type'] != regtype.RESERVED :
|
||||
if attr.RESET not in fields[fieldName] :
|
||||
print('***Error: no reset attribute found for ' + fieldName +
|
||||
' of register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
# No field attribute for register...
|
||||
else :
|
||||
|
||||
# If rsv type, then no reset should be present
|
||||
else :
|
||||
if attr.RESET in fields[fieldName] :
|
||||
print('***Error: reset attribute found for field ' + fieldName +
|
||||
' of register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
if attr.BIT_LEN in fields[fieldName]:
|
||||
bitCount += int(fields[fieldName][attr.BIT_LEN], 0)
|
||||
|
||||
if attr.TYPE in fields[fieldName] :
|
||||
|
||||
fieldType = fields[fieldName][attr.TYPE]
|
||||
|
||||
if fieldType in MemMapperBase.writeTypes :
|
||||
seenWrType = True
|
||||
|
||||
if fieldType in MemMapperBase.readTypes :
|
||||
seenRdType = False
|
||||
|
||||
# No mix of read and write types in fields
|
||||
if seenWrType and seenRdType :
|
||||
print('***Error: read and write types mixed in fields for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
if attr.WIDTH in regDict[regName] :
|
||||
if bitCount != int(regDict[regName][attr.WIDTH], 0) :
|
||||
print('***Error: field bits do not add up to register\'s width for register ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
# If no fields attribute present, register must have a type
|
||||
if attr.TYPE not in regDict[regName]:
|
||||
print('***Error: register has no type definition when fields attribute not present ' +
|
||||
' for ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# No field attribute for register...
|
||||
else :
|
||||
|
||||
# If no fields attribute present, register must have a type
|
||||
if attr.TYPE not in regDict[regName]:
|
||||
print('***Error: register has no type definition when fields attribute not present ' +
|
||||
' for ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
# If no fields attribute present, register must have a reset attribute
|
||||
if attr.RESET not in regDict[regName]:
|
||||
print('***Error: register has no reset definition when fields attribute not present ' +
|
||||
' for ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
# If no fields attribute present, register must have a reset attribute
|
||||
if attr.RESET not in regDict[regName]:
|
||||
print('***Error: register has no reset definition when fields attribute not present ' +
|
||||
' for ' + regName +
|
||||
' when parsing ' + ip + ' on bus ' + bus)
|
||||
errorsFound = True
|
||||
|
||||
return errorsFound
|
||||
|
||||
|
|
@ -550,5 +581,7 @@ class MemMapperBase :
|
|||
qsysInsts = self.__getQsysInsts(topBlock, qsysPaths, busNames) # Find all the sub-block information in the Qsys system
|
||||
ipArray = self.__processQsysInsts(qsysInsts) # Put these IP blocks into an array
|
||||
|
||||
self.__getAllJsonPaths(self.jsonPaths, ipArray) # Find all the related JSON files
|
||||
self.__getJsonPaths(self.jsonPaths, ipArray) # Find all the related JSON files for the IP from the QSYS
|
||||
self.__processSubBlocks(ipArray) # Process any sub-block JSON files, and add IP to array
|
||||
self.__getJsonPaths(self.jsonPaths, ipArray) # Re-calculate the JSON paths so to include any sub-blocks
|
||||
self.__processJsonInsts(ipArray) # Generate VHDL files from this JSON information
|
||||
|
|
|
|||
|
|
@ -22,11 +22,13 @@
|
|||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
use ieee.std_logic_arith.all;
|
||||
|
||||
use work.%%IP_PKG%%.all;
|
||||
|
||||
entity %%REG_BLOCK%% is
|
||||
generic (
|
||||
%%GENERICS%%
|
||||
ADDR_DECODE_WIDTH : natural range 1 to 32 := 8
|
||||
);
|
||||
port (
|
||||
|
|
@ -42,7 +44,7 @@ entity %%REG_BLOCK%% is
|
|||
-- end auto-generated
|
||||
|
||||
-- Slave bus port
|
||||
avs_address : in std_logic_vector(31 downto 0);
|
||||
avs_address : in std_logic_vector(ADDR_DECODE_WIDTH-1 downto 0);
|
||||
avs_write : in std_logic;
|
||||
avs_writedata : in std_logic_vector(31 downto 0);
|
||||
avs_read : in std_logic;
|
||||
|
|
@ -97,14 +99,16 @@ begin
|
|||
-- Bus write active
|
||||
if avs_write = '1' then
|
||||
|
||||
case avs_address(ADDR_DECODE_WIDTH-1 downto 0) is
|
||||
case avs_address is
|
||||
|
||||
-- auto-generated
|
||||
|
||||
-- Write (and write pulse) register case statements
|
||||
%%WRITE_REG_CASE_STATEMENTS%%
|
||||
|
||||
when others => null;
|
||||
when others =>
|
||||
%%WRITE_REG_CASE_OTHERS%%
|
||||
null;
|
||||
|
||||
-- end auto-generated
|
||||
|
||||
|
|
@ -122,9 +126,10 @@ begin
|
|||
|
||||
-- end auto-generated
|
||||
|
||||
-- Default an active read on non-existent register to something that's not 0
|
||||
-- Default an active read on non-existent register
|
||||
when others =>
|
||||
next_avs_readdata <= x"CCCCCCCC";
|
||||
next_avs_readdata <= x"00000000";
|
||||
%%READ_REG_CASE_OTHERS%%
|
||||
|
||||
end case;
|
||||
end if;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue