core-695. Add file that converts files list from Altera Quartus to Xilinx format

This commit is contained in:
David Steele 2022-06-08 14:13:25 +01:00
commit dcd02bd562

View file

@ -0,0 +1,80 @@
# -----------------------------------------------------------------------------
# Title : Convert Altera TCL to Xilinx TCL
# Project : Generic FW tools
# -----------------------------------------------------------------------------
# File : alt_to_xilinx.py
# Author : Dave Steele
# Company : Global Inkjet Systems
# Created : 2022-06-08
# Last update: 2022-06-08
# Platform :
# Standard : Python 3.x
# -----------------------------------------------------------------------------
# Description:
# Reads the Altera core_hw_tcl and extracts a files list and generic settings
# -----------------------------------------------------------------------------
# Copyright (c) 2022 Global Inkjet Systems
# -----------------------------------------------------------------------------
import os
import sys
# ###############################################################
# Only run if not imported (to test)
#
if __name__ == '__main__':
if (len(sys.argv) != 3):
print("wrong number of arguments; infile , outfile")
exit()
print("0- ", sys.argv[0],", 1- ", sys.argv[1])
fileIn = open(sys.argv[1], 'r')
linesIn = fileIn.readlines()
fileOut = open(sys.argv[2], 'w')
for line in linesIn:
if (line.find("add_fileset_file") != -1):
# Parsing to extract filepath (add_fileset_file sync_uart_tx.vhd VHDL PATH ../../sync_uart/sync_uart_tx.vhd)
pathPos = line.find("PATH")
subline = line[pathPos+5:]
vPos = subline.find(".v")
endPos = vPos+2
# make sure .v or .vhd is added to the string
if (subline[endPos] == "h"):
endPos += 2
#extract just the path
path = subline[0:endPos]
#if file is local to this directory, add a prefix to enable it to be found from build dir
if (path[0] != "."):
path = "../src/"+path
# don't include any altera primitives
if (path.find("/altera/") == -1):
# convert to xilinx tcl format
outStr = "\"[file normalize \"$origin_dir/"+path+"\"]\""+"\\"
# output
#print(outStr)
fileOut.write(outStr+"\n")
fileIn.close()
fileOut.close()