678 lines
29 KiB
Python
678 lines
29 KiB
Python
import sys
|
|
import os
|
|
import fileinput
|
|
import subprocess
|
|
import shutil
|
|
from distutils.dir_util import copy_tree
|
|
|
|
from os import listdir
|
|
from os.path import isfile, join, isdir
|
|
|
|
subst_array = dict([
|
|
('MM_interface', 'Mi' )
|
|
,('mm_interconnect', 'mi' )
|
|
,('agent_rsp_fifo', 'arf' )
|
|
,('avalon_slave', 'avas')
|
|
,('translator_avalon_universal_slave', 'taus')
|
|
,('translator_avalon_universal_master', 'taum')
|
|
])
|
|
|
|
batch = 0
|
|
|
|
def get_tool_root():
|
|
tmpPath = os.environ['QUARTUS_ROOTDIR']
|
|
newPath = tmpPath.replace('\\', '/')
|
|
return newPath
|
|
|
|
def get_dev_root():
|
|
tmpPath = os.getcwd()
|
|
tmpList = tmpPath.split("\\build")
|
|
intPath = tmpList[0]
|
|
tmpList = intPath.split("\\sim")
|
|
newPath = tmpList[0]
|
|
newPath = newPath.replace('\\', '/')
|
|
return newPath
|
|
|
|
def my_module():
|
|
firstArg = sys.argv[0]
|
|
splitList = firstArg.split(".")
|
|
return splitList[0]
|
|
|
|
def create_new_qsys():
|
|
readFileName = get_dev_root() + "/build/" + my_module() + "_system.qsys.tmp"
|
|
writeFileName = get_dev_root() + "/build/" + my_module() + "_system.qsys"
|
|
if os.path.isfile(readFileName):
|
|
os.remove(readFileName)
|
|
os.rename(writeFileName, readFileName)
|
|
readFile = open(readFileName , "r")
|
|
writeFile = open(writeFileName, "w")
|
|
for line in readFile:
|
|
newLine = line
|
|
if ("defaultValue" in line):
|
|
#newLine = newLine.replace(" elab", " elab_tb")
|
|
newLine = ''' defaultValue="101"''' + "\n"
|
|
writeFile.write(newLine)
|
|
|
|
readFile.close()
|
|
writeFile.close()
|
|
|
|
def conv2008(fileToSearch):
|
|
textToSearch = "vcom"
|
|
textToReplace = "vcom -2008"
|
|
tempFile = open( fileToSearch, 'r+' )
|
|
for line in fileinput.input( fileToSearch ):
|
|
tempFile.write( line.replace( textToSearch, textToReplace ) )
|
|
tempFile.close()
|
|
|
|
def generate_sim_files(searchPathList):
|
|
totalPath = "$"
|
|
for ip in searchPathList:
|
|
searchPath = ''.join(['../../', ip, '/src/'])
|
|
totalPath = ','.join([totalPath, searchPath])
|
|
searchPath = ''.join(['../../', ip, '/build/'])
|
|
totalPath = ','.join([totalPath, searchPath])
|
|
|
|
# Run Qsys 'generate IP'
|
|
myCmd = '''_TOOL_ROOT_/sopc_builder/bin/ip-generate --remove-qsys-generate-warning --project-directory=_DEV_ROOT_/build --output-directory=_DEV_ROOT_/build/_MODULE_/simulation --file-set=SIM_VHDL --report-file=html:_DEV_ROOT_/build/_MODULE_/_MODULE_.html --report-file=sopcinfo:_DEV_ROOT_/build/_MODULE_.sopcinfo --report-file=csv:_DEV_ROOT_/build/_MODULE_/_MODULE_.csv --report-file=spd:_DEV_ROOT_/build/_MODULE_/_MODULE_.spd --report-file=cmp:_DEV_ROOT_/build/_MODULE_/_MODULE_.cmp --report-file=sip:_DEV_ROOT_/build/_MODULE_/simulation/_MODULE_.sip --system-info=DEVICE_FAMILY=\"Cyclone V\" --system-info=DEVICE=5CSXFC6D6F31C8ES --system-info=DEVICE_SPEEDGRADE=8_H6 --component-file=_DEV_ROOT_/build/_MODULE_.qsys --search-path=_SEARCH_PATH_'''
|
|
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
|
|
myCmd = myCmd.replace('_DEV_ROOT_', get_dev_root())
|
|
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
|
|
myCmd = myCmd.replace('_SEARCH_PATH_', totalPath)
|
|
|
|
print myCmd
|
|
myCmdArray = myCmd.split(" ")
|
|
subprocess.call(myCmdArray)
|
|
|
|
# Run Qsys 'generate scripts'
|
|
myCmd = '''_TOOL_ROOT_/sopc_builder/bin/sim-script-gen --spd=_DEV_ROOT_/build/_MODULE_/_MODULE_.spd --output-directory=_DEV_ROOT_/build/_MODULE_/simulation/ --use-relative-paths=true'''
|
|
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
|
|
myCmd = myCmd.replace('_DEV_ROOT_', get_dev_root())
|
|
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
|
|
myCmd = myCmd.replace('_SEARCH_PATH_', totalPath)
|
|
|
|
print myCmd
|
|
myCmdArray = myCmd.split(" ")
|
|
subprocess.call(myCmdArray)
|
|
|
|
# Run Qsys 'generate bsf'
|
|
myCmd = '''_TOOL_ROOT_/sopc_builder/bin/ip-generate --project-directory=_DEV_ROOT_/build --output-directory=_DEV_ROOT_/build/_MODULE_ --report-file=bsf:_DEV_ROOT_/build/_MODULE_/stripe_transform_system.bsf --system-info=DEVICE_FAMILY="Cyclone V" --system-info=DEVICE=5CSXFC6D6F31C6 --system-info=DEVICE_SPEEDGRADE=6_H6 --component-file=_DEV_ROOT_/build/_MODULE_.qsys --remove-qsys-generate-warning'''
|
|
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
|
|
myCmd = myCmd.replace('_DEV_ROOT_', get_dev_root())
|
|
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
|
|
myCmd = myCmd.replace('_SEARCH_PATH_', totalPath)
|
|
|
|
print myCmd
|
|
myCmdArray = myCmd.split(" ")
|
|
subprocess.call(myCmdArray)
|
|
|
|
myCmd2 = '''_DEV_ROOT_/build/_MODULE_/simulation/mentor/msim_setup.tcl'''
|
|
myCmd2 = myCmd2.replace('_DEV_ROOT_', get_dev_root())
|
|
myCmd2 = myCmd2.replace('_MODULE_', "".join([my_module() + "_system"]))
|
|
print myCmd2
|
|
conv2008(myCmd2)
|
|
|
|
|
|
def generate_synth_files(searchPathList):
|
|
totalPath = "$"
|
|
for ip in searchPathList:
|
|
searchPath = ''.join(['../../', ip, '/src/'])
|
|
totalPath = ','.join([totalPath, searchPath])
|
|
searchPath = ''.join(['../../', ip, '/build/'])
|
|
totalPath = ','.join([totalPath, searchPath])
|
|
searchPath = '../../**/*'
|
|
totalPath = ','.join([totalPath, searchPath])
|
|
|
|
|
|
# Run Qsys 'generate'
|
|
myCmd = '''_TOOL_ROOT_/sopc_builder/bin/ip-generate --project-directory=_DEV_ROOT_/build --output-directory=_DEV_ROOT_/build/_MODULE_ --report-file=bsf:_DEV_ROOT_/build/_MODULE_/_MODULE_.bsf --system-info=DEVICE_FAMILY="Cyclone V" --system-info=DEVICE=5CSXFC6D6F31C6 --system-info=DEVICE_SPEEDGRADE=6_H6 --component-file=_DEV_ROOT_/build/_MODULE_.qsys --remove-qsys-generate-warning --search-path=$,../../../../../**/*'''
|
|
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
|
|
myCmd = myCmd.replace('_DEV_ROOT_', get_dev_root())
|
|
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
|
|
myCmd = myCmd.replace('_SEARCH_PATH_', totalPath)
|
|
|
|
print myCmd
|
|
myCmdArray = myCmd.split(" ")
|
|
subprocess.call(myCmdArray)
|
|
|
|
|
|
|
|
# Run Qsys 'generate'
|
|
myCmd = '''_TOOL_ROOT_/sopc_builder/bin/ip-generate --project-directory=_DEV_ROOT_/build --output-directory=_DEV_ROOT_/build/_MODULE_/synthesis --file-set=QUARTUS_SYNTH --report-file=html:_DEV_ROOT_/build/_MODULE_/_MODULE_.html --report-file=sopcinfo:_DEV_ROOT_/build/_MODULE_.sopcinfo --report-file=cmp:_DEV_ROOT_/build/_MODULE_/_MODULE_.cmp --report-file=qip:_DEV_ROOT_/build/_MODULE_/synthesis/_MODULE_.qip --report-file=svd:_DEV_ROOT_/build/_MODULE_/synthesis/_MODULE_.svd --report-file=regmap:_DEV_ROOT_/build/_MODULE_/synthesis/_MODULE_.regmap --report-file=xml:_DEV_ROOT_/build/_MODULE_/_MODULE_.xml --report-file=debuginfo:_DEV_ROOT_/build/_MODULE_/synthesis/_MODULE_.debuginfo --system-info=DEVICE_FAMILY="Cyclone V" --system-info=DEVICE=5CSXFC6D6F31C6 --system-info=DEVICE_SPEEDGRADE=6_H6 --component-file=_DEV_ROOT_/build/_MODULE_.qsys --remove-qsys-generate-warning --language=VHDL --search-path=$,../../../../../**/* --component-parameter=sysid_ver_num=_VER_NUM_'''
|
|
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
|
|
myCmd = myCmd.replace('_DEV_ROOT_', get_dev_root())
|
|
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
|
|
myCmd = myCmd.replace('_SEARCH_PATH_', totalPath)
|
|
myCmd = myCmd.replace('_VER_NUM_', "8")
|
|
|
|
print myCmd
|
|
myCmdArray = myCmd.split(" ")
|
|
subprocess.call(myCmdArray)
|
|
|
|
# Perform Quartus synthesis
|
|
myCmd = '''_TOOL_ROOT_/bin64/quartus_sh --flow compile _MODULE_'''
|
|
myCmd = myCmd.replace('_TOOL_ROOT_', get_tool_root())
|
|
myCmd = myCmd.replace('_MODULE_', "".join([my_module() + "_system"]))
|
|
|
|
print myCmd
|
|
myCmdArray = myCmd.split(" ")
|
|
subprocess.call(myCmdArray)
|
|
|
|
def get_batch_mode():
|
|
for i in sys.argv:
|
|
if i == 'yesBatch':
|
|
print "yesBatch detected"
|
|
return 1
|
|
return 0
|
|
|
|
def get_qsys_build():
|
|
for i in sys.argv:
|
|
if i == 'yesQsys':
|
|
print "yesQsys detected"
|
|
return 1
|
|
return 0
|
|
|
|
def copy_files(system_name):
|
|
# Move, shorten, and then move back the generated files
|
|
curPath = os.getcwd()
|
|
srcPath = "".join(["..\\build\\" + system_name + "_system\simulation"])
|
|
print srcPath
|
|
dstPath = "c:\simulation"
|
|
# Create directories if they don't exist
|
|
if not os.path.exists(dstPath): os.makedirs(dstPath)
|
|
if not os.path.exists("".join([dstPath, "\submodules"])): os.makedirs("".join([dstPath, "\submodules"]))
|
|
if not os.path.exists("".join([dstPath, "\mentor"])): os.makedirs("".join([dstPath, "\mentor"]))
|
|
# Clear out what is currently in the temporary directory
|
|
os.chdir(dstPath)
|
|
filelist = [ f for f in os.listdir(".") if f.endswith(".vhd") ]
|
|
filelist = filelist + [ f for f in os.listdir(".") if f.endswith(".vho") ]
|
|
filelist = filelist + [ f for f in os.listdir(".") if f.endswith(".safe")]
|
|
filelist = filelist + [ f for f in os.listdir(".") if f.endswith(".sip") ]
|
|
filelist = filelist + [ f for f in os.listdir(".") if f.endswith("~") ]
|
|
for f in filelist: os.remove(f)
|
|
os.chdir("submodules")
|
|
filelist = [ f for f in os.listdir(".") if f.endswith(".vhd") ]
|
|
filelist = filelist + [ f for f in os.listdir(".") if f.endswith(".vho") ]
|
|
filelist = filelist + [ f for f in os.listdir(".") if f.endswith(".safe")]
|
|
filelist = filelist + [ f for f in os.listdir(".") if f.endswith("~") ]
|
|
for f in filelist: os.remove(f)
|
|
os.chdir(curPath)
|
|
# Perform the copy
|
|
#shutil.copyfile("\\".join([srcPath, "submodules\\print_control_system_head_1_Print_data.vhd"]),
|
|
# "\\".join([dstPath, "submodules\\print_control_system_head_1_Print_data.vhd"]))
|
|
subprocess.call(" ".join(["robocopy ", srcPath , dstPath]) , shell=True)
|
|
subprocess.call(" ".join(["robocopy ", "".join([srcPath, "\submodules"]), "".join([dstPath, "\submodules"])]), shell=True)
|
|
subprocess.call(" ".join(["robocopy ", "".join([srcPath, "\mentor"]) , "".join([dstPath, "\mentor"])]) , shell=True)
|
|
|
|
def return_files(system_name):
|
|
# Move, shorten, and then move back the generated files
|
|
srcPath = "c:/simulation"
|
|
dstPath = "".join(["..\\build\\" + system_name + "_system\simulation"])
|
|
myCmd = " ".join(["robocopy /E", srcPath, dstPath])
|
|
#print myCmd
|
|
subprocess.call(myCmd, shell=True)
|
|
|
|
def get_top_level():
|
|
searchfile = open('msim_setup.tcl', "r")
|
|
for line in searchfile:
|
|
if "set TOP_LEVEL_NAME" in line:
|
|
myList = line.split('''"''')
|
|
topLevel = myList[1]
|
|
#topLevel = "".join([myList[1], "_mm_interconnect"])
|
|
#print topLevel
|
|
searchfile.close()
|
|
return topLevel
|
|
|
|
def edit_msim_setup(longName, sub_array):
|
|
tbName = "".join([longName, "_tb -f args.txt"])
|
|
#sub_array[longerName] = "shrt"
|
|
sub_keys = sub_array.keys()
|
|
readFileName = 'msim_setup_old.tcl'
|
|
writeFileName = 'msim_setup.tcl'
|
|
if os.path.isfile(readFileName):
|
|
os.remove(readFileName)
|
|
os.rename(writeFileName, readFileName)
|
|
readFile = open('msim_setup_old.tcl', "r")
|
|
writeFile = open('msim_setup.tcl', "w")
|
|
copyNum = 0
|
|
elab_tb = 0
|
|
myAlias = ""
|
|
for line in readFile:
|
|
newLine = line
|
|
pcName = os.environ['USERDOMAIN']
|
|
# Swap in 'dev_com' edit
|
|
if ((" if " in line) and ("ModelSim" in line)):
|
|
if 'MULL' in pcName:
|
|
newLine = " if ![file isdirectory libraries/cyclonev/cyclonev_and1] {\n"
|
|
else:
|
|
newLine = " if [file isdirectory libraries/cyclonev/cyclonev_and1] {\n"
|
|
|
|
# Swap in shortened file names
|
|
for key in sub_keys:
|
|
if (elab_tb == 0): newLine = newLine.replace(key, sub_array[key])
|
|
|
|
# Check to see if we have already added the new 'elab_tb'
|
|
if ("alias elab_tb " in line):
|
|
elab_tb = 1
|
|
|
|
# Detect the 'elab' target and take a copy while creating the 'elab_tb'
|
|
if (("alias elab " in line) and (elab_tb == 0)):
|
|
copyNum = 5
|
|
elif copyNum > 0:
|
|
copyNum = copyNum - 1
|
|
|
|
if copyNum > 1:
|
|
myAlias = "".join([myAlias, newLine])
|
|
newLine = newLine.replace(" elab", " elab_tb")
|
|
newLine = newLine.replace('''$TOP_LEVEL_NAME''', tbName)
|
|
elif copyNum == 1:
|
|
writeFile.write(myAlias)
|
|
|
|
# Write back the original 'elab' target
|
|
writeFile.write(newLine)
|
|
|
|
readFile.close()
|
|
writeFile.close()
|
|
|
|
def rename_top_level(topLevel, longName, sub_array):
|
|
readFileName = "".join(["../", topLevel, "_old.vhd"])
|
|
writeFileName = "".join(["../", topLevel, ".vhd"])
|
|
sub_keys = sub_array.keys()
|
|
if os.path.isfile(readFileName):
|
|
os.remove(readFileName)
|
|
os.rename(writeFileName, readFileName)
|
|
readFile = open(readFileName, "r")
|
|
writeFile = open(writeFileName, "w")
|
|
myHeadAux = 0
|
|
entity = 1
|
|
|
|
for line in readFile:
|
|
|
|
newLine = line
|
|
|
|
# Replace all the long strings with shortened versions
|
|
for key in sub_keys:
|
|
newLine = newLine.replace(key, sub_array[key])
|
|
|
|
# Remove the std_logic_vector initialisation values as this upsets SystemC flow
|
|
if (": in " in newLine) and ("address " in newLine) and (entity == 1):
|
|
newLine = newLine.replace(":= '0'", "")
|
|
if (": in " in newLine) and (entity == 1):
|
|
newLine = newLine.replace(":= (others => '0')", "")
|
|
if ("end entity" in newLine):
|
|
entity = 0
|
|
|
|
# Correct the 1 bit address vector width issue
|
|
if ("address " in newLine) and (": in " in newLine) and (" std_logic " in newLine):
|
|
newLine = newLine.replace("std_logic", "std_logic_vector(0 downto 0)")
|
|
newLine = newLine.replace("'X'", "(others => 'X')")
|
|
newLine = newLine.replace("(0)", "")
|
|
writeFile.write(newLine)
|
|
|
|
readFile.close()
|
|
writeFile.close()
|
|
|
|
# Now fix the _rst_controller.vhd file
|
|
|
|
sub_keys = sub_array.keys()
|
|
os.chdir("..")
|
|
oldList = [ f for f in listdir("./") if isfile(join("./",f)) ]
|
|
newList = []
|
|
|
|
for f in oldList:
|
|
if isdir(f):
|
|
dummy = "me"
|
|
print "Removing: " + f
|
|
elif f.endswith("rst_controller.vhd"):
|
|
newList.append(f)
|
|
elif f.endswith("rst_controller_001.vhd"):
|
|
newList.append(f)
|
|
|
|
for f in newList:
|
|
readFileName = f + ".safe"
|
|
|
|
writeFileName = f
|
|
for key in sub_keys:
|
|
writeFileName = writeFileName.replace(key, sub_array[key])
|
|
|
|
print writeFileName
|
|
if os.path.isfile(readFileName):
|
|
os.remove(readFileName)
|
|
|
|
print '''Renaming "''' + f + '''" as "''' + readFileName
|
|
os.rename(f, readFileName)
|
|
|
|
#print "readFileName is:"+readFileName
|
|
#print "writeFileName is:"+writeFileName
|
|
|
|
readFile = open(readFileName, "r")
|
|
writeFile = open(writeFileName, "w")
|
|
|
|
for line in readFile:
|
|
|
|
newLine = line
|
|
for key in sub_keys:
|
|
newLine = newLine.replace(key, sub_array[key])
|
|
|
|
if ("address " in newLine) and (": in " in newLine) and (" std_logic " in newLine):
|
|
newLine = newLine.replace("std_logic", "std_logic_vector(0 downto 0)")
|
|
newLine = newLine.replace("'X'", "(others => 'X')")
|
|
if ("address " in newLine) and (": IN " in newLine) and (" STD_LOGIC;" in newLine):
|
|
newLine = newLine.replace("STD_LOGIC", "STD_LOGIC_VECTOR(0 DOWNTO 0)")
|
|
newLine = newLine.replace("'X'", "(others => 'X')")
|
|
if ("address\t" in newLine) and (":\tIN " in newLine) and (" STD_LOGIC;" in newLine):
|
|
newLine = newLine.replace("STD_LOGIC", "STD_LOGIC_VECTOR(0 DOWNTO 0)")
|
|
newLine = newLine.replace("'X'", "(others => 'X')")
|
|
if ("=>" in newLine):
|
|
newLine = newLine.replace("_address(0)", "_address")
|
|
if ("std_logic'" in newLine) and ("av_address" in newLine):
|
|
newLine = newLine.replace("(av_address)", "(av_address(0))")
|
|
newLine = newLine.replace("NOT av_address)", "NOT av_address(0))")
|
|
if ("av_address;" in newLine):
|
|
newLine = newLine.replace("av_address;", "av_address(0);")
|
|
if (" address " in newLine) and ("<=" in newLine) and not ("DOWNTO" in newLine):
|
|
newLine = newLine.replace(" address ", " address(0) ")
|
|
if (" address;" in newLine):
|
|
newLine = newLine.replace(" address;", " address(0);")
|
|
|
|
writeFile.write(newLine)
|
|
|
|
readFile.close()
|
|
writeFile.close()
|
|
|
|
os.chdir("mentor")
|
|
|
|
def rename_bridges(longName):
|
|
print longName
|
|
os.chdir("..")
|
|
oldList = [ f for f in listdir("./") if isfile(join("./",f)) ]
|
|
newList = []
|
|
for f in oldList:
|
|
if f.endswith("safe.safe"):
|
|
os.remove(f)
|
|
elif ("_bridge_" in f):
|
|
newList.append(f)
|
|
elif ("_translator" in f):
|
|
newList.append(f)
|
|
|
|
print newList
|
|
|
|
for f in newList:
|
|
readFileName = f + ".safe"
|
|
|
|
writeFileName = f
|
|
writeFileName = writeFileName.replace(longName, "shrt")
|
|
|
|
print writeFileName
|
|
if os.path.isfile(readFileName):
|
|
os.remove(readFileName)
|
|
|
|
print '''Renaming "''' + f + '''" as "''' + readFileName
|
|
os.rename(f, readFileName)
|
|
|
|
readFile = open(readFileName, "r")
|
|
writeFile = open(writeFileName, "w")
|
|
|
|
for line in readFile:
|
|
|
|
newLine = line
|
|
newLine = newLine.replace(longName, "shrt")
|
|
writeFile.write(newLine)
|
|
|
|
readFile.close()
|
|
writeFile.close()
|
|
os.chdir("mentor")
|
|
|
|
|
|
def rename_other_entities(longName, sub_array):
|
|
sub_keys = sub_array.keys()
|
|
os.chdir("../submodules")
|
|
oldList = [ f for f in listdir("./") if isfile(join("./",f)) ]
|
|
#oldList = ["lvds_slave_system_mm_interconnect_1_spi_0_spi_control_port_translator_avalon_universal_slave_0_agent_rsp_fifo.vho"]
|
|
#oldList = listdir(".")
|
|
#print oldList
|
|
newList = []
|
|
for f in oldList:
|
|
if isdir(f):
|
|
dummy = "me"
|
|
print "Removing: " + f
|
|
elif f.endswith("safe"):
|
|
if f.endswith("safe.safe"):
|
|
#print "Deleting: " + f
|
|
os.remove(f)
|
|
else:
|
|
dummy = "me"
|
|
#print "Not deleting: " + f
|
|
print "Removing: " + f
|
|
else:
|
|
#print "Not removing: " + f
|
|
newList.append(f)
|
|
|
|
print newList
|
|
|
|
for f in newList:
|
|
readFileName = f + ".safe"
|
|
|
|
writeFileName = f
|
|
for key in sub_keys:
|
|
writeFileName = writeFileName.replace(key, sub_array[key])
|
|
|
|
print writeFileName
|
|
if os.path.isfile(readFileName):
|
|
os.remove(readFileName)
|
|
|
|
print '''Renaming "''' + f + '''" as "''' + readFileName
|
|
os.rename(f, readFileName)
|
|
|
|
readFile = open(readFileName, "r")
|
|
writeFile = open(writeFileName, "w")
|
|
|
|
for line in readFile:
|
|
|
|
newLine = line
|
|
for key in sub_keys:
|
|
newLine = newLine.replace(key, sub_array[key])
|
|
|
|
if ("address " in newLine) and (": in " in newLine) and (" std_logic " in newLine):
|
|
newLine = newLine.replace("std_logic", "std_logic_vector(0 downto 0)")
|
|
newLine = newLine.replace("'X'", "(others => 'X')")
|
|
if ("address " in newLine) and (": IN " in newLine) and (" STD_LOGIC;" in newLine):
|
|
newLine = newLine.replace("STD_LOGIC", "STD_LOGIC_VECTOR(0 DOWNTO 0)")
|
|
newLine = newLine.replace("'X'", "(others => 'X')")
|
|
if ("address\t" in newLine) and (":\tIN " in newLine) and (" STD_LOGIC;" in newLine):
|
|
newLine = newLine.replace("STD_LOGIC", "STD_LOGIC_VECTOR(0 DOWNTO 0)")
|
|
newLine = newLine.replace("'X'", "(others => 'X')")
|
|
if ("=>" in newLine) and ("vhd" in readFileName):
|
|
newLine = newLine.replace("_address(0)", "_address")
|
|
if ("std_logic'" in newLine) and ("av_address" in newLine) and ("vhd" in readFileName):
|
|
newLine = newLine.replace("(av_address)", "(av_address(0))")
|
|
newLine = newLine.replace("NOT av_address)", "NOT av_address(0))")
|
|
if ("av_address;" in newLine) and ("vhd" in readFileName):
|
|
newLine = newLine.replace("av_address;", "av_address(0);")
|
|
if (" address " in newLine) and ("<=" in newLine) and not ("DOWNTO" in newLine) and ("vhd" in readFileName):
|
|
newLine = newLine.replace(" address ", " address(0) ")
|
|
if (" address;" in newLine) and ("vhd" in readFileName):
|
|
newLine = newLine.replace(" address;", " address(0);")
|
|
|
|
writeFile.write(newLine)
|
|
|
|
readFile.close()
|
|
writeFile.close()
|
|
|
|
def compile_test(longName):
|
|
origDir = os.getcwd()
|
|
compDir = longName.join(['../build/', '/simulation/mentor'])
|
|
os.chdir(compDir)
|
|
pcName = os.environ['USERDOMAIN']
|
|
if 'MULL' in pcName:
|
|
if ("supervisor" in longName):
|
|
subprocess.call(["C:\\modeltech_pe_10.1a\\win32pe\\vsim",
|
|
"-do", "../../../../../generic_ip/common/sim/supervisor_comp.do",
|
|
"-c", "-l", "compile.log"])
|
|
elif ("top" in longName):
|
|
subprocess.call(["C:\\modeltech_pe_10.1a\\win32pe\\vsim",
|
|
"-do", "../../../../../generic_ip/common/sim/top_comp.do",
|
|
"-c", "-l", "compile.log"])
|
|
else:
|
|
subprocess.call(["C:\\modeltech_pe_10.1a\\win32pe\\vsim",
|
|
"-do", "../../../../../generic_ip/common/sim/comp.do",
|
|
"-c", "-l", "compile.log"])
|
|
else:
|
|
vsimloc = os.environ['QUARTUS_ROOTDIR']+"\\..\\modelsim_ase\\win32aloem\\vsim"
|
|
print "about to call complie using vsim location of: {}".format(vsimloc)
|
|
subprocess.call([vsimloc,
|
|
"-do", "../../../../../generic_ip/common/sim/comp.do",
|
|
"-c", "-l", "compile.log"])
|
|
os.chdir(origDir)
|
|
|
|
|
|
def copy_artifacts(moduleName, testName):
|
|
# create directory in WORKSPACE called sim_results
|
|
tmpList = os.getcwd().split("\\firmware")
|
|
tgtDir = os.path.join(tmpList[0], "sim_results")
|
|
if not os.path.exists(tgtDir):
|
|
print "making directory at {}".format(tgtDir)
|
|
os.makedirs(tgtDir)
|
|
|
|
# create directory in there called moduleName_testName
|
|
newDirName = "_".join([moduleName,testName])
|
|
tgtDir = os.path.join(tgtDir,newDirName)
|
|
if not os.path.exists(tgtDir):
|
|
os.makedirs(tgtDir)
|
|
print "making directory at {}".format(tgtDir)
|
|
else:
|
|
for f in os.listdir(tgtDir):
|
|
fullPathF = os.path.join(tgtDir,f)
|
|
print "removing {}".format(fullPathF)
|
|
os.remove(fullPathF)
|
|
|
|
# from current location copy *.txt, *.log, *.tcl, *.vstf into the directory
|
|
localDir = os.getcwd()
|
|
print "copying relevant files from {} to {}".format(localDir,tgtDir)
|
|
extList = [".txt",".log",".tcl",".vstf"]
|
|
for f in os.listdir(localDir):
|
|
for ext in extList:
|
|
if f.endswith(ext):
|
|
fullPathF = os.path.join(localDir,f)
|
|
print "copying {}".format(fullPathF)
|
|
shutil.copy(fullPathF,tgtDir)
|
|
|
|
def run_program(moduleName, testArray):
|
|
paramNameArray = testArray.keys()
|
|
paramNameArray.remove('testName') # this is now an array of the names of the generics to be set
|
|
numParams = len(paramNameArray)
|
|
testNameArray = testArray['testName']
|
|
numTests = len(testNameArray)
|
|
print "run_program starting"
|
|
print "numParams: {} ".format(numParams)
|
|
print "testNameArray[0] {}".format(testNameArray[0])
|
|
print "numTests {}".format(numTests)
|
|
tmpStr = ""
|
|
for i in sys.argv:
|
|
tmpStr = "{},{}".format(tmpStr,i)
|
|
print "Argv items are {}".format(tmpStr)
|
|
|
|
namedTestPerformed = False
|
|
print "I running program-------------------------------------------------------"
|
|
origDir = os.getcwd()
|
|
simDir = moduleName.join(['../build/', '_system/simulation/mentor'])
|
|
os.chdir(simDir)
|
|
|
|
pcName = os.environ['USERDOMAIN']
|
|
for testName in testNameArray:
|
|
tmpStr = ""
|
|
for paramName in paramNameArray:
|
|
paramArray = testArray[paramName]
|
|
#print paramArray
|
|
#print paramArray[1]
|
|
paramValue = paramArray[testNameArray.index(testName)]
|
|
paramStr = "".join(["-G", paramName, "=", paramValue])
|
|
scParamStr = "".join(["-sc_arg \"", paramName, "=", paramValue, "\""])
|
|
if ("top" in moduleName) or ("supervisor" in moduleName):
|
|
tmpStr = " ".join([tmpStr, scParamStr])
|
|
else:
|
|
tmpStr = " ".join([tmpStr, paramStr])
|
|
print "set of parameters going to args.txt for test:{} is:{}".format(testName,tmpStr)
|
|
create_args_file(tmpStr)
|
|
logStr = "".join([testName, "_run.log"])
|
|
tbName = "".join([moduleName, "_system_tb"])
|
|
batchMode = get_batch_mode()
|
|
if 'MULL' in pcName:
|
|
if ("top" in moduleName) or ("supervisor" in moduleName):
|
|
print "Samba"
|
|
if batchMode==1:
|
|
callStr = " ".join(["C:/modeltech_pe_10.1a/win32pe/vsim", "-c",
|
|
"-do", "../../../../../generic_ip/common/sim/sc_run_batch.do", "-l", logStr])
|
|
else:
|
|
callStr = " ".join(["C:/modeltech_pe_10.1a/win32pe/vsim",
|
|
"-do", "../../../../../generic_ip/common/sim/sc_run.do", "-l", logStr])
|
|
else:
|
|
print "Not Samba"
|
|
if batchMode==1:
|
|
callStr = " ".join(["C:/modeltech_pe_10.1a/win32pe/vsim", "-c",
|
|
"-do", "../../../../../generic_ip/common/sim/run_batch.do", "-l", logStr])
|
|
else:
|
|
callStr = " ".join(["C:/modeltech_pe_10.1a/win32pe/vsim",
|
|
"-do", "../../../../../generic_ip/common/sim/run.do", "-l", logStr])
|
|
else:
|
|
if batchMode==1:
|
|
callStr = " ".join([os.environ['QUARTUS_ROOTDIR']+"\\..\\modelsim_ase\\win32aloem\\vsim", "-c",
|
|
"-do", "../../../../../generic_ip/common/sim/run_batch.do", "-l", logStr])
|
|
else:
|
|
callStr = " ".join([os.environ['QUARTUS_ROOTDIR']+"\\..\\modelsim_ase\\win32aloem\\vsim",
|
|
"-do", "../../../../../generic_ip/common/sim/run.do", "-l", logStr])
|
|
|
|
if ((sys.argv[-1]==testName) or (sys.argv[-1]=='all')):
|
|
print "current directory is {}".format(os.getcwd())
|
|
print "call String will be: {}".format(callStr)
|
|
subprocess.call(callStr, shell=True) # does the simulation
|
|
check_result(logStr)
|
|
namedTestPerformed = True
|
|
copy_artifacts(moduleName, testName)
|
|
|
|
if namedTestPerformed:
|
|
print "All requested tests performed per '{}'".format(sys.argv[-1])
|
|
else:
|
|
print "Oops!\n"
|
|
print "Test name '{}' was not found in array".format(sys.argv[-1])
|
|
|
|
os.chdir(origDir)
|
|
|
|
def create_args_file(argsString):
|
|
argsFileName = "args.txt"
|
|
argsFile = open(argsFileName, "w")
|
|
argsFile.write(argsString)
|
|
argsFile.close()
|
|
|
|
def check_result(logfile):
|
|
searchfile = open(logfile, "r")
|
|
for line in searchfile:
|
|
if "SUCCESS" in line:
|
|
print 'Test appears to have been successful, which is nice...'
|
|
return None
|
|
|
|
searchfile.close()
|
|
print 'Test appears to have NOT been successful, oops...'
|
|
sys.exit(1)
|
|
|
|
def main(myModule, testArray, ipArray):
|
|
origDir = os.getcwd()
|
|
create_new_qsys()
|
|
if (get_qsys_build()==1): generate_sim_files(ipArray)
|
|
copy_files(my_module())
|
|
os.chdir("c:/simulation/mentor")
|
|
topLevel = get_top_level()
|
|
#longName = "".join([topLevel, "_mm_interconnect"])
|
|
longName = topLevel
|
|
print "The top level is " + topLevel + " and the long name to be replaced is " + longName
|
|
edit_msim_setup(longName, subst_array)
|
|
rename_top_level(topLevel, longName, subst_array)
|
|
rename_bridges(longName)
|
|
rename_other_entities(longName, subst_array)
|
|
os.chdir(origDir)
|
|
return_files(my_module())
|
|
compile_test(longName)
|
|
run_program(myModule, testArray)
|
|
|
|
|
|
|
|
|