From dcd02bd562c1deac0943f90a09b623cfe4075ee3 Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 8 Jun 2022 14:13:25 +0100 Subject: [PATCH] core-695. Add file that converts files list from Altera Quartus to Xilinx format --- utilities/altera_to_xilinx.py | 80 +++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 utilities/altera_to_xilinx.py diff --git a/utilities/altera_to_xilinx.py b/utilities/altera_to_xilinx.py new file mode 100644 index 0000000..0d5f9fa --- /dev/null +++ b/utilities/altera_to_xilinx.py @@ -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() + + + + + + + + + + + + + + + + +