From 15d072bbb714720c9285e0160c804f3151110498 Mon Sep 17 00:00:00 2001 From: Joppe Blondel Date: Mon, 5 Sep 2022 14:44:09 +0200 Subject: [PATCH] Added vivado IP generatioon Signed-off-by: Joppe Blondel --- examples/zynq7000/.gitignore | 2 ++ examples/zynq7000/IP/zynqps.tcl | 16 +++++++++ examples/zynq7000/project.cfg | 28 +++++++++++++++ remotesyn/toolchains/ISE_IP.py | 7 ---- remotesyn/toolchains/VIVADO_IP.py | 58 +++++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 examples/zynq7000/.gitignore create mode 100644 examples/zynq7000/IP/zynqps.tcl create mode 100644 examples/zynq7000/project.cfg create mode 100644 remotesyn/toolchains/VIVADO_IP.py diff --git a/examples/zynq7000/.gitignore b/examples/zynq7000/.gitignore new file mode 100644 index 0000000..d28717d --- /dev/null +++ b/examples/zynq7000/.gitignore @@ -0,0 +1,2 @@ +OUT +BUILD \ No newline at end of file diff --git a/examples/zynq7000/IP/zynqps.tcl b/examples/zynq7000/IP/zynqps.tcl new file mode 100644 index 0000000..ba29f79 --- /dev/null +++ b/examples/zynq7000/IP/zynqps.tcl @@ -0,0 +1,16 @@ +create_ip -vlnv xilinx.com:ip:processing_system7 -module_name zynqps +set_property -dict [ list \ + CONFIG.PCW_UIPARAM_DDR_BUS_WIDTH {16 Bit} \ + CONFIG.PCW_UIPARAM_DDR_PARTNO {MT41K256M16 RE-125} \ + CONFIG.PCW_UART1_PERIPHERAL_ENABLE {1} \ + CONFIG.PCW_UART1_UART1_IO {MIO 44 .. 45} \ + CONFIG.PCW_FPGA0_PERIPHERAL_FREQMHZ {100} \ + CONFIG.PCW_USE_S_AXI_GP0 {0} \ + CONFIG.PCW_USE_M_AXI_GP0 {0} \ + CONFIG.PCW_USE_S_AXI_GP1 {0} \ + CONFIG.PCW_USE_M_AXI_GP1 {0} \ + CONFIG.PCW_USE_S_AXI_HP0 {0} \ + CONFIG.PCW_USE_S_AXI_HP1 {0} \ + CONFIG.PCW_USE_S_AXI_HP2 {0} \ + CONFIG.PCW_USE_S_AXI_HP3 {0} \ +] [ get_ips zynqps ] \ No newline at end of file diff --git a/examples/zynq7000/project.cfg b/examples/zynq7000/project.cfg new file mode 100644 index 0000000..0c34474 --- /dev/null +++ b/examples/zynq7000/project.cfg @@ -0,0 +1,28 @@ +[project] +name = zynq7000_project +version = 0.1 +out_dir = OUT +build_dir = BUILD + +[server] +hostname = localhost +port = 2020 +privkey = /home/joppe/.ssh/id_rsa +pubkey = /home/joppe/.ssh/id_rsa.pub + +# ###################################### +# ISE IP block generation +[target.ip] +toolchain = VIVADO_IP + +# Toolchain settings +family = zynq +device = xc7z010 +package = clg400 +speedgrade = -2 + +# Fileset +files_tcl = IP/zynqps.tcl +# Note: IP file names must be the same as the component name in the tcl file! + +# ###################################### \ No newline at end of file diff --git a/remotesyn/toolchains/ISE_IP.py b/remotesyn/toolchains/ISE_IP.py index c54d827..cce1736 100644 --- a/remotesyn/toolchains/ISE_IP.py +++ b/remotesyn/toolchains/ISE_IP.py @@ -1,10 +1,3 @@ -from .util_ISE.xst import xst -from .util_ISE.ngdbuild import ngdbuild -from .util_ISE.map import map -from .util_ISE.par import par -from .util_ISE.netgen import netgen -from .util_ISE.bitgen import bitgen -from .util_ISE.trce import trce from .util_ISE.coregen import coregen import shutil diff --git a/remotesyn/toolchains/VIVADO_IP.py b/remotesyn/toolchains/VIVADO_IP.py new file mode 100644 index 0000000..b09f7fe --- /dev/null +++ b/remotesyn/toolchains/VIVADO_IP.py @@ -0,0 +1,58 @@ +import shutil +import os +import time +import subprocess + +def do(config, target, log, subprocesses, prefix='.'): + shutil.rmtree(config.get('project', 'build_dir', fallback='build'), True) + + log("Generate IP's:") + + log(" - parsing options") + device = config.get(f'target.{target}', 'device', fallback='') + family = config.get(f'target.{target}', 'family', fallback='') + package = config.get(f'target.{target}', 'package', fallback='') + speedgrade = config.get(f'target.{target}', 'speedgrade', fallback='') + files_tcl = config.get(f'target.{target}', 'files_tcl', fallback='').split() + build_dir = config.get(f'project', 'build_dir', fallback='build') + out_dir = config.get(f'project', 'out_dir', fallback='out') + + prefix = f'{os.getcwd()}/{prefix}' + build_dir = f'{prefix}/{build_dir}' + out_dir = f'{prefix}/{out_dir}/{target}' + + log(" - creating output directories") + os.makedirs(build_dir, exist_ok=True) + os.makedirs(out_dir, exist_ok=True) + + for tcl in files_tcl: + cname = tcl.split('/')[-1].split('.')[0] + + log(" - Generating", cname, "...") + + log(" - writing project tcl file") + with open(f'{build_dir}/do.tcl', 'w') as f: + f.write(f"file mkdir {cname}\ncreate_project -in_memory\nset_property part {device}{package}{speedgrade} [current_project]\n") + f.write(f"source {prefix}/{tcl}\n") + f.write(f"export_ip_user_files -of_objects [get_files {cname}/{cname}/{cname}.xci ] -no_script -sync -force -quiet\n") + f.write(f"upgrade_ip [get_ips {cname}]\ngenerate_target all [get_ips {cname}]\n") + + log(" - run vivado") + p = subprocess.Popen(f"vivado -mode batch -source do.tcl", + shell=True, cwd=build_dir, + stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocesses.append(p) + while p.poll() is None: + time.sleep(1) + res = p.returncode + + log(" - copy logs") + shutil.copy(f'{build_dir}/vivado.log', f'{out_dir}/vivado_{cname}.log') + + if res==0: + log(" - copy output files") + shutil.copytree(f'{build_dir}/.gen/sources_1/ip/{cname}', f'{out_dir}/{cname}') + else: + log("ERROR: vivado returned with:", res) + return res +