GIS-6905 Added command line option (-s, -file_suffix) to allow specification of a suffix (e.g. _auto) to be added to the output filename(s). This is targetted at the HDL generation, but has been added to the base class and supported in all the scripts.
This commit is contained in:
parent
504dadbf5f
commit
c4e33eaed2
5 changed files with 26 additions and 25 deletions
|
|
@ -48,7 +48,7 @@ class MemMapperCpp(MemMapperBase):
|
|||
# and generate a C/C++ header file with some useful
|
||||
# constants in it.
|
||||
# ---------------------------------------------------------
|
||||
def genOutput(self, ip, opDir):
|
||||
def genOutput(self, ip, opDir='', opSuffix=''):
|
||||
|
||||
colWidth = 45
|
||||
|
||||
|
|
@ -77,12 +77,12 @@ class MemMapperCpp(MemMapperBase):
|
|||
offsetTypeStr = 'word'
|
||||
|
||||
# Open up the file for the header information
|
||||
writeFileName = srcDir + sep + ip + '.h'
|
||||
writeFileName = srcDir + sep + ip + opSuffix + '.h'
|
||||
wfp = open(writeFileName, 'w')
|
||||
wfp.write('// Block name: ' + jsonDict[0][attr.IP_NAME] + ', using ' + offsetTypeStr + ' offsets\n')
|
||||
|
||||
# Open up the file for the field access functions
|
||||
funcsFilename = srcDir + sep + ip + '.cpp'
|
||||
funcsFilename = srcDir + sep + ip + opSuffix + '.cpp'
|
||||
ffp = open(funcsFilename, 'w')
|
||||
ffp.write('#include <stdint.h>\n')
|
||||
ffp.write('#include <' + ip + '.h>\n\n')
|
||||
|
|
@ -273,5 +273,5 @@ if __name__ == '__main__':
|
|||
memMap.setByteAddrMode(cmdArgs.byteAddrs)
|
||||
|
||||
# Run the program for C++ definitions generation
|
||||
memMap.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir, cmdArgs.opDir)
|
||||
memMap.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir, cmdArgs.opDir, cmdArgs.opFileSuffix)
|
||||
del memMap
|
||||
|
|
|
|||
|
|
@ -554,12 +554,12 @@ class MemMapperHdl(MemMapperBase) :
|
|||
# ---------------------------------------------------------
|
||||
# ---------------------------------------------------------
|
||||
|
||||
def __processSubBlocks(self, jsonBusDict, srcDir, bus, ip, sep) :
|
||||
def __processSubBlocks(self, jsonBusDict, srcDir, bus, ip, sep, opSuffix='') :
|
||||
|
||||
colWidth = MemMapperHdl.outputNameWidth
|
||||
|
||||
# Open up a file for writing the decoder VHDL
|
||||
writeFileName = srcDir + sep + ip + '_' + bus + '_decode.vhd'
|
||||
writeFileName = srcDir + sep + ip + '_' + bus + '_decode' + opSuffix + '.vhd'
|
||||
wfp = open(writeFileName, 'w')
|
||||
|
||||
# Open template file for reading
|
||||
|
|
@ -743,7 +743,7 @@ class MemMapperHdl(MemMapperBase) :
|
|||
# Overload base classes virtual function with specific
|
||||
# output generation (VHDL package)
|
||||
# ---------------------------------------------------------
|
||||
def genOutput(self, ip, opDir) :
|
||||
def genOutput(self, ip, opDir='', opSuffix='') :
|
||||
|
||||
# Fetch the JSON path and the dictionary with the parsed data
|
||||
jsonPath, jsonDict = self._getModel(ip)
|
||||
|
|
@ -771,12 +771,12 @@ class MemMapperHdl(MemMapperBase) :
|
|||
|
||||
# If a hierarchy block, skip
|
||||
if attr.SUB_BLOCKS in jsonBusDict:
|
||||
self.__processSubBlocks(jsonBusDict, srcDir, bus, ip, sep)
|
||||
self.__processSubBlocks(jsonBusDict, srcDir, bus, ip, sep, opSuffix)
|
||||
|
||||
if attr.REGISTERS not in jsonBusDict :
|
||||
continue
|
||||
|
||||
writeFileName = srcDir + sep + ip + '_' + bus + '_regs.vhd'
|
||||
writeFileName = srcDir + sep + ip + '_' + bus + '_regs' + opSuffix + '.vhd'
|
||||
wfp = open(writeFileName, 'w')
|
||||
|
||||
# Open template file for reading
|
||||
|
|
@ -926,11 +926,11 @@ if __name__ == '__main__' :
|
|||
memMapHdl = MemMapperHdl(cmdArgs.projName)
|
||||
|
||||
# Run the program for VHDL RTL generation
|
||||
memMapHdl.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir)
|
||||
memMapHdl.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir, cmdArgs.opDir, cmdArgs.opFileSuffix)
|
||||
del memMapHdl
|
||||
|
||||
memMapPkg = MemMapperPkg()
|
||||
|
||||
# Run the program for the package generation
|
||||
memMapPkg.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir, cmdArgs.opDir)
|
||||
memMapPkg.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir, cmdArgs.opDir, cmdArgs.opFileSuffix)
|
||||
del memMapPkg
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class MemMapperPkg(MemMapperBase) :
|
|||
# Overload base classes virtual function with specific
|
||||
# output generation (VHDL package)
|
||||
# ---------------------------------------------------------
|
||||
def genOutput(self, ip, opDir='') :
|
||||
def genOutput(self, ip, opDir='', opSuffix='') :
|
||||
|
||||
# Fetch the JSON path and the dictionary with the parsed data
|
||||
jsonPath, jsonDict = self._getModel(ip)
|
||||
|
|
@ -83,7 +83,7 @@ class MemMapperPkg(MemMapperBase) :
|
|||
if not os.path.exists(srcDir) :
|
||||
os.makedirs(srcDir)
|
||||
|
||||
writeFileName = srcDir + sep + ip + '_pkg.vhd'
|
||||
writeFileName = srcDir + sep + ip + '_pkg' + opSuffix + '.vhd'
|
||||
wfp = open(writeFileName, 'w')
|
||||
|
||||
wfp.write('-- Block name: ' + jsonDict[0][attr.IP_NAME] + '\n')
|
||||
|
|
@ -244,5 +244,5 @@ if __name__ == '__main__' :
|
|||
cmdArgs = processCmdLine()
|
||||
|
||||
# Run the program for VHDL package generation
|
||||
memMap.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir, cmdArgs.opDir)
|
||||
memMap.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir, cmdArgs.opDir, cmdArgs.opFileSuffix)
|
||||
del memMap
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ class MemMapperTxt(MemMapperBase):
|
|||
# and generate a text document file with some useful
|
||||
# register definitions in it.
|
||||
# ---------------------------------------------------------
|
||||
def genOutput(self, ip, opDir='') :
|
||||
def genOutput(self, ip, opDir='', opSuffix='') :
|
||||
|
||||
# Fetch the JSON path and the dictionary with the parsed data
|
||||
jsonPath, jsonDict = self._getModel(ip)
|
||||
|
|
@ -204,7 +204,7 @@ class MemMapperTxt(MemMapperBase):
|
|||
# ipNameCamel = self._underScore2CamelCase(ip)
|
||||
|
||||
# Construct the write file name (with a .txt suffix) and open it
|
||||
writeFileName = srcDir + sep + ip + '.txt'
|
||||
writeFileName = srcDir + sep + ip + opSuffix + '.txt'
|
||||
wfp = open(writeFileName, 'w')
|
||||
|
||||
# Address column header text dependant on byte/word address mode
|
||||
|
|
@ -377,5 +377,5 @@ if __name__ == '__main__':
|
|||
memMap.setByteAddrMode(cmdArgs.byteAddrs)
|
||||
|
||||
# Run the processing and generate output
|
||||
memMap.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir, cmdArgs.opDir)
|
||||
memMap.run(cmdArgs.topBlock, cmdArgs.busList, cmdArgs.repoDir, cmdArgs.opDir, cmdArgs.opFileSuffix)
|
||||
del memMap
|
||||
|
|
|
|||
|
|
@ -295,10 +295,10 @@ class MemMapperBase :
|
|||
# ---------------------------------------------------------
|
||||
# Process all the instances (private method)
|
||||
# ---------------------------------------------------------
|
||||
def __processJsonInsts(self, ipArray, opDir='') :
|
||||
def __processJsonInsts(self, ipArray, opDir='', opSuffix='') :
|
||||
|
||||
for ip in ipArray:
|
||||
self.genOutput(ip, opDir) # Virtual function, not defined in this base class
|
||||
self.genOutput(ip, opDir, opSuffix) # Virtual function, not defined in this base class
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Process all the sub-blocks and add to ipArray the entries
|
||||
|
|
@ -546,15 +546,16 @@ class MemMapperBase :
|
|||
@staticmethod
|
||||
def processCmdLine(parser) :
|
||||
|
||||
parser.add_argument('-t', '--top_block', dest='topBlock', default='top', action='store', help='Top block name')
|
||||
parser.add_argument('-r', '--repo_dir', dest='repoDir', default='', action='store', help='Specify repository dir for processing')
|
||||
parser.add_argument('-b', '--bus_list', dest='busList', default=['csr', 'trim'], nargs='+', help='Bus list')
|
||||
parser.add_argument('-o', '--output_dir', dest='opDir', default='', action='store', help='Specify output directory')
|
||||
parser.add_argument('-t', '--top_block', dest='topBlock', default='top', action='store', help='Top block name')
|
||||
parser.add_argument('-r', '--repo_dir', dest='repoDir', default='', action='store', help='Specify repository dir for processing')
|
||||
parser.add_argument('-b', '--bus_list', dest='busList', default=['csr', 'trim'], nargs='+', help='Bus list')
|
||||
parser.add_argument('-o', '--output_dir', dest='opDir', default='', action='store', help='Specify output directory')
|
||||
parser.add_argument('-s', '--file_suffix', dest='opFileSuffix', default='', action='store', help='Output file name suffix (default none)')
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# run
|
||||
# ---------------------------------------------------------
|
||||
def run(self, topBlock, busNames, repoDir='', opDir='') :
|
||||
def run(self, topBlock, busNames, repoDir='', opDir='', opSuffix='') :
|
||||
|
||||
print('MemMapperBase')
|
||||
|
||||
|
|
@ -583,4 +584,4 @@ class MemMapperBase :
|
|||
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, opDir) # Generate VHDL files from this JSON information
|
||||
self.__processJsonInsts(ipArray, opDir, opSuffix) # Generate VHDL files from this JSON information
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue