diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..4a8624758ceff1ea985f3e05b2d99c42b00380b6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 vauban353 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/build-bitstream.py b/build-bitstream.py new file mode 100644 index 0000000000000000000000000000000000000000..88ad6a8ee1ecf5f9eba8681890994c2fe3067a85 --- /dev/null +++ b/build-bitstream.py @@ -0,0 +1,375 @@ +# The BeagleV Fire Bitstream Builder is released under the following software license: + +# Copyright 2021 Microchip Corporation. +# SPDX-License-Identifier: MIT + + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + + +# The BeagleV Fire Bitstream Builder is an evolution of the Microchip +# Bitstream Builder available from: +# https://github.com/polarfire-soc/icicle-kit-minimal-bring-up-design-bitstream-builder +# + + + +import argparse +import io +import os +import platform +import shutil +import zipfile + +import git +import requests +import yaml +import sys +import subprocess + +from generate_gateware_overlays import generate_gateware_overlays + + +def check_native_platform(): + if os.path.isfile('/.dockerenv'): + return "" + else: + return " --native" + + +# Parse command line arguments and set tool locations +def parse_arguments(): + global libero + global mss_configurator + global softconsole_headless + global programming + global update + + global yaml_input_file + + # Initialize parser + parser = argparse.ArgumentParser() + + parser.add_argument('Path', + metavar='path', + type=str, + help='Path to the YAML file describing the list of sources used to build the bitstream.') + + # Read arguments from command line + args = parser.parse_args() + yaml_input_file_arg = args.Path + + if not os.path.isfile(yaml_input_file_arg): + print("\r\n!!! The path specified for the YAML input file does not exist !!!\r\n") + parser.print_help() + sys.exit() + + yaml_input_file = os.path.abspath(yaml_input_file_arg) + + # Tool call variables - these are the names of the tools to run which will be called from os.system. + # Full paths could be used here instead of assuming tools are in PATH + libero = "libero" + mss_configurator = "pfsoc_mss" + softconsole_headless = "softconsole-headless" + + update = False + programming = False + + +# Checks to see if all of the required tools are installed and present in path, if a needed tool isn't available the script will exit +def check_tool_status_linux(): + if shutil.which("libero") is None: + print("Error: libero not found in path") + exit() + + if shutil.which("pfsoc_mss") is None: + print("Error: polarfire soc mss configurator not found in path") + exit() + + if os.environ.get('SC_INSTALL_DIR') is None: + print( + "Error: SC_INSTALL_DIR environment variable not set, please set this variable and point it to the " + "appropriate SoftConsole installation directory to run this script") + exit() + + if os.environ.get('FPGENPROG') is None: + print( + "Error: FPGENPROG environment variable not set, please set this variable and point it to the appropriate " + "FPGENPROG executable to run this script") + exit() + + path = os.environ["PATH"] + + if "/riscv-unknown-elf-gcc/bin" not in path: + print( + "The path to the RISC-V toolchain needs to be set in PATH to run this script") + exit() + + +# Creates required folders and removes artifacts before beginning +def init_workspace(): + print("================================================================================") + print(" Initialize workspace") + print("================================================================================\r\n", flush=True) + + # Create the sources folder to clone into if it doesn't exist (any existing source folders are handled in the + # clone_sources function) +# if not os.path.exists("./sources"): +# os.mkdir("./sources") + + # Delete the work folder and its content if it exists. + if os.path.exists("./work"): + shutil.rmtree('./work') + + # Create each output subdirectory + os.mkdir("./work") + os.mkdir("./work/MSS") + os.mkdir("./work/HSS") + + # Delete the bitstream folder if it exists to remove previously created bitstreams. + if os.path.exists("./bitstream"): + shutil.rmtree('./bitstream') + + # Create the bitstream folder structure. This is where the created bitstreams will be generated. There might be + # multiple subdirectories there to provided different programming options. + os.mkdir("./bitstream") + os.mkdir("./bitstream/FlashProExpress") + os.mkdir("./bitstream/LinuxProgramming") + print(" The FlashPro Express bitstream programming job files will be stored in") + print(" directory: ./bitstream/FlashProExpress\r\n", flush=True) + + +# clones the sources specified in the sources.yaml file +def clone_sources(source_list): + print("================================================================================") + print(" Clone sources") + print("================================================================================\r\n", flush=True) + + source_directories = {} + with open(source_list) as f: # open the yaml file passed as an arg + data = yaml.load(f, Loader=yaml.FullLoader) + + keys = data.keys() + # each entry in the file is a source + for source in keys: + + # Check if this is a git source + if "git" in data.get(source).get("type"): + + # Check if we've already cloned the repo + if os.path.exists(os.path.join("./sources", source)): + repo = git.Repo.init(os.path.join("./sources", source)) # set up repo + repo.git.checkout(data.get(source).get("branch")) # checkout the branch from the yaml file + repo.remotes.origin.pull() # pull changes + + # We don't already have the repo, clone it + else: + repo = git.Repo.clone_from(data.get(source).get("link"), os.path.join("./sources", source), + branch=data.get(source).get("branch")) + + # check if a specific commit from this branch is required + if "commit" in data.get(source): + repo.git.checkout(data.get(source).get("commit")) # check out a specific commit + + # Check if this is source is a url to a zip + elif "zip" in data.get(source).get("type"): + + # if we already have a source of the same name delete it - can't check versions + if os.path.exists(os.path.join("./sources", source)): + shutil.rmtree(os.path.join("./sources", source)) + r = requests.get(data.get(source).get("link")) # download zip + z = zipfile.ZipFile(io.BytesIO(r.content)) # extract zip + z.extractall(os.path.join("./sources", source)) # save contents + source_directories[source] = os.path.join("./sources", + source) # Generate a dictionary of all of the sources that were cloned + + f.close() + + # return the dictionary of sources + return source_directories + + +# Calls the MSS Configurator and generate an MSS configuration in a directory based on a cfg file +def make_mss_config(mss_configurator, config_file, output_dir): + print("================================================================================") + print(" Generating MSS configuration") + print("================================================================================\r\n", flush=True) + os.system(mss_configurator + ' -GENERATE -CONFIGURATION_FILE:' + config_file + ' -OUTPUT_DIR:' + output_dir) + + +# Builds the HSS using a pre-defined config file using SoftConsole in headless mode +def make_hss(hss_source, yaml_input_file): + print("================================================================================") + print(" Build Hart Software Services (HSS)") + print("================================================================================\r\n", flush=True) + + # Retrieve build target info from YAML file + with open(yaml_input_file) as f: # open the yaml file passed as an arg + data = yaml.load(f, Loader=yaml.FullLoader) + try: + target_board = data.get("HSS").get("board") + except: + target_board = "bvf" + f.close() + print("Target board: " + target_board) + + # Update XML in HSS project + XML_file = "boards/" + target_board + "/soc_fpga_design/xml/PF_SOC_MSS_mss_cfg.xml" + XML_file_abs_path = os.path.join(hss_source, XML_file) + try: + os.remove(XML_file_abs_path) + except: + print("HSS target board does not have a default MSS XML configuration - not a problem.", flush=True) + + shutil.copyfile("./work/MSS/PF_SOC_MSS_mss_cfg.xml", XML_file_abs_path) + + # Select HSS configuration to build + def_config_file = os.path.join(hss_source, "boards/" + target_board + "/def_config") + shutil.copyfile(def_config_file, os.path.join(hss_source, "./.config")) + + # Call HSS makefile + initial_directory = os.getcwd() + os.chdir(hss_source) + make_command = "make BOARD=" + target_board + os.system(make_command) + os.chdir(initial_directory) + + # Check build was successful and copy the build artifact to the output directory + generated_hex_file = "./sources/HSS/Default/bootmode1/hss-envm-wrapper-bm1-p0.hex" + if os.path.isfile(generated_hex_file): + shutil.copyfile(generated_hex_file, "./work/HSS/hss-envm-wrapper-bm1-p0.hex") + else: + print("!!! Error: Hart Soft Service build failed !!!", flush=True) + exit() + + +def get_libero_script_args(source_list): + libero_script_args = "NO_BUILD_ARGUMENT" + with open(source_list) as f: # open the yaml file passed as an arg + data = yaml.load(f, Loader=yaml.FullLoader) +# try: + libero_script_args = data.get("gateware").get("build-args") +# except: +# libero_script_args = "NO_BUILD_ARGUMENT" + f.close() + + if libero_script_args is None: + libero_script_args = "NONE" + return libero_script_args + + +def get_design_version(source_list): + with open(source_list) as f: # open the yaml file passed as an arg + data = yaml.load(f, Loader=yaml.FullLoader) + unique_design_version = data.get("gateware").get("unique-design-version") + f.close() + if unique_design_version is None: + unique_design_version = "65.53.5" + + udv_sl = unique_design_version.split(".") + design_version = (int(udv_sl[0]) * 1000) + (int(udv_sl[1]) * 10) + int(udv_sl[2]) + + print("design_version: ", design_version) + return str(design_version) + + +# The function below assumes the current working directory is the gateware's git repository. +def get_git_hash(): + try: + git_hash = subprocess.check_output(['git', 'log', "--pretty=format:'%H'", '-n', '1']) + except subprocess.CalledProcessError as e: + git_hash = 0 + return git_hash.decode('ascii').strip("'") + + +# Build the gateware's top level name from the build option directory name and the git hassh of the gateware's +# repository. +def get_top_level_name(): + git_hash = get_git_hash() + top_level_name = str(os.path.splitext(os.path.basename(yaml_input_file))[0]) + top_level_name = top_level_name.replace('-', '_') + top_level_name = top_level_name + '_' + git_hash + if len(top_level_name) > 30: + top_level_name = top_level_name[:30] + top_level_name = top_level_name.upper() + return top_level_name + + +# Calls Libero and runs a script +def call_libero(libero, script, script_args, project_location, hss_image_location, prog_export_path, top_level_name, design_version): + libero_cmd = libero + " SCRIPT:" + script + " \"SCRIPT_ARGS: " + script_args + " PROJECT_LOCATION:" + project_location + " TOP_LEVEL_NAME:" + top_level_name + " HSS_IMAGE_PATH:" + hss_image_location + " PROG_EXPORT_PATH:" + prog_export_path + " DESIGN_VERSION:" + design_version + "\"" + print("Libero command: " + libero_cmd, flush=True) + os.system(libero_cmd) + + +def generate_libero_project(libero, yaml_input_file): + print("================================================================================") + print(" Generate Libero project") + print("================================================================================\r\n", flush=True) + # Execute the Libero TCL script used to create the Libero design + initial_directory = os.getcwd() + os.chdir("./sources/FPGA-design") + project_location = os.path.join(initial_directory, "work/libero") + script = os.path.join(initial_directory , "sources/FPGA-design/BUILD_BVF_GATEWARE.tcl") + + script_args = get_libero_script_args(yaml_input_file) + design_version = get_design_version(yaml_input_file) + + hss_image_location = os.path.join(initial_directory, "work/HSS/hss-envm-wrapper-bm1-p0.hex") + prog_export_path = initial_directory + + top_level_name = get_top_level_name() + print("top level name: ", top_level_name) + + call_libero(libero, script, script_args, project_location, hss_image_location, prog_export_path, top_level_name, design_version) + os.chdir(initial_directory) + + +def main(): + global libero + global mss_configurator + global softconsole_headless + global programming + + parse_arguments() + + # This function will check if all of the required tools are present and quit if they aren't + check_tool_status_linux() + + sources = {} + + # Bitstream building starts here - see individual functions for a description of their purpose + init_workspace() + + sources = clone_sources(yaml_input_file) + + build_options_list = get_libero_script_args(yaml_input_file) + generate_gateware_overlays(os.path.join(os.getcwd(), "bitstream", "LinuxProgramming"), build_options_list) + + make_mss_config(mss_configurator, "./sources/MSS_Configuration/MSS_Configuration.cfg", os.path.join(os.getcwd(), "work/MSS")) + + make_hss(sources["HSS"], yaml_input_file) + + generate_libero_project(libero, yaml_input_file) + + print("Finished", flush=True) + + +if __name__ == '__main__': + main() diff --git a/build-options/board-tests.yaml b/build-options/board-tests.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c461d95d8a9dca027f1f318280a681e5fbecc190 --- /dev/null +++ b/build-options/board-tests.yaml @@ -0,0 +1,10 @@ +--- +HSS: + type: git + link: https://git.beagleboard.org/beaglev-fire/hart-software-services.git + branch: develop-beaglev-fire + board: bvf +gateware: + type: sources + build-args: "CAPE_OPTION:GPIOS MIPI_CSI_OPTION:NONE M2_OPTION:BOARD_TESTS SYZYGY_OPTION:BOARD_TESTS_SEEED_STUDIO" + unique-design-version: 0.0.2 diff --git a/build-options/default.yaml b/build-options/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5c4ac1eef4743f2fa68ac7b809c8ff92082c53fa --- /dev/null +++ b/build-options/default.yaml @@ -0,0 +1,10 @@ +--- +HSS: + type: git + link: https://git.beagleboard.org/beaglev-fire/hart-software-services.git + branch: develop-beaglev-fire + board: bvf +gateware: + type: sources + unique-design-version: 2.0.2 + diff --git a/build-options/minimal.yaml b/build-options/minimal.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f54ee77e2040082603beb6bb63fef15898f8b9fc --- /dev/null +++ b/build-options/minimal.yaml @@ -0,0 +1,11 @@ +--- +HSS: + type: git + link: https://git.beagleboard.org/beaglev-fire/hart-software-services.git + branch: develop-beaglev-fire + board: bvf +gateware: + type: sources + build-args: "M2_OPTION:NONE CAPE_OPTION:NONE" + unique-design-version: 1.0.2 + diff --git a/build-options/robotics.yaml b/build-options/robotics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4dd0636bdc9761c0d60c6413207b429d2f09dde5 --- /dev/null +++ b/build-options/robotics.yaml @@ -0,0 +1,11 @@ +--- +HSS: + type: git + link: https://git.beagleboard.org/beaglev-fire/hart-software-services.git + branch: develop-beaglev-fire + board: bvf +gateware: + type: sources + build-args: "CAPE_OPTION:ROBOTICS " + unique-design-version: 3.0.3 + diff --git a/gather_dtso.py b/gather_dtso.py new file mode 100644 index 0000000000000000000000000000000000000000..d3b0df0309c9484deaf3a8cb808d71c0774169e7 --- /dev/null +++ b/gather_dtso.py @@ -0,0 +1,69 @@ +# Gather device tree overlay dtso files from the gateware's +# script_support/components/<component-name>/<build-option-name>/device-tree-overlay +# directories into the bitstream builder's work/dtbo/context-0/<component-name> +# directories. +import os +import shutil +import sys + + +def gather_dtso(gateware_dir, work_dir, build_options): + context_dir = os.path.join(gateware_dir, "script_support", "components") + + build_options_dict = {} + if build_options != 'NONE': + options = build_options.split() + for option in options: + opt = option.split(':') + le = len("_OPTION") + component_dir = opt[0][:-le] + option_dir = opt[1] + build_options_dict[component_dir] = option_dir + + dtbo_dir = os.path.join(work_dir, "dtbo") + if not os.path.exists(dtbo_dir): + os.makedirs(dtbo_dir) + context_0_dir = os.path.join(dtbo_dir, "context-0") + if not os.path.exists(context_0_dir): + os.makedirs(context_0_dir) + + for root, dirs, files in os.walk(context_dir): + for file in files: + if file.endswith(".dtso"): + dir_filename = os.path.split(root) + if dir_filename[1] == 'device-tree-overlay': + option_name = os.path.split(dir_filename[0])[1] + component_name = os.path.split(os.path.split(dir_filename[0])[0])[1] + if component_name in build_options_dict: + desired_option = build_options_dict[component_name] + else: + desired_option = 'DEFAULT' + if option_name == desired_option: + print(" Device tree overlay selected:") + print(" component: ", component_name) + print(" build option: ", option_name) + print(" device tree overlay file: ", file) + component_dir = os.path.join(context_0_dir, component_name) + if not os.path.exists(component_dir): + os.makedirs(component_dir) + src_path = os.path.join(root, file) + dst_path = os.path.join(component_dir, file) + shutil.copy(src_path, dst_path) + + +if __name__ == '__main__': + if len(sys.argv) < 3: + print("Two arguments expected: gateware and work directory paths.") + exit() + + argumentList = sys.argv[1:] + gateware_dir = argumentList[0] + work_dir = argumentList[1] + + if os.path.exists(gateware_dir): + if os.path.exists(work_dir): + gather_dtso(gateware_dir, work_dir, argumentList[2:]) + else: + print("Invalid bitstream builder work directory.") + else: + print("Gateware directory does not exist.") diff --git a/generate_gateware_overlays.py b/generate_gateware_overlays.py new file mode 100644 index 0000000000000000000000000000000000000000..3f76439857135565ef977ef6a4d9630f2a57556b --- /dev/null +++ b/generate_gateware_overlays.py @@ -0,0 +1,156 @@ +import os +import struct +import ctypes +import sys +import subprocess + +from gather_dtso import gather_dtso + +global dtbo_info + + +def gen_magic(): + global dtbo_info + struct.pack_into('cccc', dtbo_info, 0, b'M', b'C', b'H', b'P') + + +def gen_descriptor_length(no_of_contexts, no_of_dtbo): + global dtbo_info + descriptor_length = 12 + (4 * no_of_contexts) + (4 * no_of_dtbo) + struct.pack_into('I', dtbo_info, 4, descriptor_length) + + +# 2 bytes longs version number +def gen_version(): + global dtbo_info + version = 0 + struct.pack_into('H', dtbo_info, 8, version) + + +def gen_number_of_contexts(no_of_contexts): + global dtbo_info + in_number_of_contexts = no_of_contexts + struct.pack_into('H', dtbo_info, 10, in_number_of_contexts) + + +def get_dtbo_files_list(): + initial_directory = os.getcwd() + context_dir = os.path.join(initial_directory, "work", "dtbo", "context-0") + dtbo_files_list = [] + for root, dirs, files in os.walk(context_dir): + for file in files: + if file.endswith(".dtbo"): + dtbo_files_list.append(os.path.join(root, file)) + return dtbo_files_list + + +def get_dtbo_total_size(dtbo_list): + size = 0 + for dtbo_file in dtbo_list: + size = size + os.path.getsize(dtbo_file) + return size + + +def gen_dtbo_info(overlay_dir_path, no_of_contexts, dtbo_list): + dtbo_desc_list_start_offset = 12 + (no_of_contexts * 4) + struct.pack_into('I', dtbo_info, 12, dtbo_desc_list_start_offset) + no_of_dtbo = len(dtbo_list) + struct.pack_into('I', dtbo_info, 16, no_of_dtbo) + dtbo_data_offset = 20 + (no_of_dtbo * 12) + dtbo_idx = 0 + for dtbo_file in dtbo_list: + size = os.path.getsize(dtbo_file) + struct.pack_into('I', dtbo_info, 20 + (dtbo_idx * 12), dtbo_data_offset) + struct.pack_into('I', dtbo_info, 24 + (dtbo_idx * 12), dtbo_data_offset + size) + struct.pack_into('I', dtbo_info, 28 + (dtbo_idx * 12), size) + dtbo_data_offset += size + dtbo_idx += 1 + + dtbo_full_path = os.path.join(overlay_dir_path, "mpfs_dtbo.spi") + with open(dtbo_full_path, "wb") as mpfs_dtbo: + mpfs_dtbo.write(dtbo_info) + + # + # Append the actual dtbo files to the dtbo_file + # + with open(dtbo_full_path, "ab") as mpfs_dtbo: + for dtbo_file in dtbo_list: + with open(dtbo_file, "rb") as in_dtbo_file: + mpfs_dtbo.write(in_dtbo_file.read()) + + +def create_dtbo_info(overlay_dir_path): + global dtbo_info + + dtbo_list = get_dtbo_files_list() + print("number of gateware device tree overlays: ", len(dtbo_list)) + for dtbo_file in dtbo_list: + print(dtbo_file) + no_of_contexts = 1 + no_of_dtbo = len(dtbo_list) + + # + # Generate the DTBO info binary. + # + dtbo_info_length = 12 + (8 * no_of_contexts) + (12 * no_of_dtbo) + + dtbo_info = ctypes.create_string_buffer(dtbo_info_length) + gen_magic() + gen_descriptor_length(no_of_contexts, no_of_dtbo) + gen_version() + gen_number_of_contexts(no_of_contexts) + gen_dtbo_info(overlay_dir_path, no_of_contexts, dtbo_list) + print(dtbo_info[:]) + + +def get_gateware_git_version(work_dir): + try: + git_hash = subprocess.check_output(['git', 'describe', '--tags']) + except subprocess.CalledProcessError as e: + git_hash = 0 + return git_hash.decode('ascii').strip("'").strip("\n") + + +def inject_git_info_into_src_dtso(dtso_file, git_version): + with open(dtso_file, "r") as f: + dtso = f.read() + dtso = dtso.replace('GATEWARE_GIT_VERSION', git_version) + with open(dtso_file, "w") as fout: + fout.write(dtso) + + +def compile_dtso(work_dir): + root_dir = os.path.join(work_dir, 'dtbo', 'context-0') + git_version = get_gateware_git_version(work_dir) + for root, dirs, files in os.walk(root_dir): + for file in files: + if file.endswith(".dtso"): + dtso_file = os.path.join(root, file) + inject_git_info_into_src_dtso(dtso_file, git_version) + dtbo_file = os.path.splitext(dtso_file)[0] + '.dtbo' + cmd = 'dtc -O dtb -I dts -o ' + dtbo_file + ' ' + dtso_file + os.system(cmd) + + +def generate_device_tree_overlays(overlay_dir_path, build_options_list): + print("================================================================================") + print(" Generate Device Tree Overlays") + print("================================================================================\r\n", flush=True) + bitstream_builder_root = os.getcwd() + gateware_dir = os.path.join(bitstream_builder_root, 'sources', 'gateware') + work_dir = os.path.join(bitstream_builder_root, 'work') + gather_dtso(gateware_dir, work_dir, build_options_list) + compile_dtso(work_dir) + create_dtbo_info(overlay_dir_path) + + +def generate_gateware_overlays(overlay_dir_path, build_options_list): + generate_device_tree_overlays(overlay_dir_path, build_options_list) + + +if __name__ == '__main__': + if len(sys.argv) > 1: + argument_list = sys.argv[1:] + else: + argument_list = 'NONE' + generate_device_tree_overlays(argument_list) diff --git a/recipes/libero-project/configure.tcl b/recipes/libero-project/configure.tcl new file mode 100644 index 0000000000000000000000000000000000000000..6bca88e873150a96daf3f42e9e7e4bf2c8605cc3 --- /dev/null +++ b/recipes/libero-project/configure.tcl @@ -0,0 +1,45 @@ +# The Microchip Bitstream Builder is released under the following software licese: + +# Copyright 2021 Microchip Corporation. +# SPDX-License-Identifier: MIT + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +source ./recipes/libero-project/functions.tcl +set local_dir [pwd] +set project_name libero_project +set output_directory "$local_dir/output" +set libero_project_directory "$output_directory/$project_name" +set artifact_directory "$output_directory/final-files" + +# Set variables from arguments +if { $::argc > 0 } { + set i 1 + foreach arg $::argv { + if {[string match "*:*" $arg]} { + set temp [split $arg ":"] + puts "Setting parameter [lindex $temp 0] to [lindex $temp 1]" + set [lindex $temp 0] "[lindex $temp 1]" + } else { + set $arg 1 + puts "set $arg to 1" + } + incr i + } +} diff --git a/recipes/libero-project/constraints.tcl b/recipes/libero-project/constraints.tcl new file mode 100644 index 0000000000000000000000000000000000000000..bd9bb8a6fb05e05c586d849d798401f0bf463caf --- /dev/null +++ b/recipes/libero-project/constraints.tcl @@ -0,0 +1,33 @@ +# The Microchip Bitstream Builder is released under the following software licese: + +# Copyright 2021 Microchip Corporation. +# SPDX-License-Identifier: MIT + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +create_links \ + -convert_EDN_to_HDL 0 \ + -io_pdc ./sources/HDL/Constraints/mmuart0.pdc + +organize_tool_files \ + -tool {PLACEROUTE} \ + -file ./sources/HDL/Constraints/mmuart0.pdc \ + -module {base::work} \ + -input_type {constraint} + diff --git a/recipes/libero-project/export-data.tcl b/recipes/libero-project/export-data.tcl new file mode 100644 index 0000000000000000000000000000000000000000..f1dd9ae2bd65f3b3f0bd80a2a02230b2d3f27643 --- /dev/null +++ b/recipes/libero-project/export-data.tcl @@ -0,0 +1,141 @@ +# The Microchip Bitstream Builder is released under the following software licese: + +# Copyright 2021 Microchip Corporation. +# SPDX-License-Identifier: MIT + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +source ./recipes/libero-project/configure.tcl + +open_project -file {./output/libero_project/libero_project.prjx} -do_backup_on_convert 1 -backup_file {./output/libero_project/libero_project.zip} + +run_tool -name {GENERATEPROGRAMMINGFILE} + +run_tool -name {GENERATEDEBUGDATA} + +export_bitstream_file \ + -file_name {bitstream_file} \ + -export_dir $artifact_directory \ + -format {DAT PPD} \ + -for_ihp 0 \ + -limit_SVF_file_size 0 \ + -limit_SVF_file_by_max_filesize_or_vectors {} \ + -svf_max_filesize {} \ + -svf_max_vectors {} \ + -master_file 0 \ + -master_file_components {} \ + -encrypted_uek1_file 0 \ + -encrypted_uek1_file_components {} \ + -encrypted_uek2_file 0 \ + -encrypted_uek2_file_components {} \ + -trusted_facility_file 1 \ + -trusted_facility_file_components {FABRIC_SNVM} \ + -zeroization_likenew_action 0 \ + -zeroization_unrecoverable_action 0 \ + -master_backlevel_bypass 0 \ + -uek1_backlevel_bypass 0 \ + -uek2_backlevel_bypass 0 \ + -master_include_plaintext_passkey 0 \ + -uek1_include_plaintext_passkey 0 \ + -uek2_include_plaintext_passkey 0 \ + -sanitize_snvm 0 \ + -sanitize_envm 0 \ + -trusted_facility_keep_fabric_operational 0 \ + -trusted_facility_skip_startup_seq 0 \ + -uek1_keep_fabric_operational 0 \ + -uek1_skip_startup_seq 0 \ + -uek2_keep_fabric_operational 0 \ + -uek2_skip_startup_seq 0 + +export_prog_job \ + -job_file_name {programming_job} \ + -export_dir $artifact_directory \ + -bitstream_file_type {TRUSTED_FACILITY} \ + -bitstream_file_components {FABRIC_SNVM} \ + -zeroization_likenew_action 0 \ + -zeroization_unrecoverable_action 0 \ + -program_design 1 \ + -program_spi_flash 0 \ + -include_plaintext_passkey 0 \ + -design_bitstream_format {PPD} \ + -prog_optional_procedures {} \ + -skip_recommended_procedures {} \ + -sanitize_snvm 0 \ + -sanitize_envm 0 + +export_spiflash_image \ + -file_name {spi-flash-image} \ + -export_dir $artifact_directory + +export_pin_reports \ + -export_dir $artifact_directory \ + -pin_report_by_name 1 \ + -pin_report_by_pkg_pin 1 \ + -bank_report 1 \ + -io_report 1 + +export_bsdl_file \ + -file $artifact_directory + +update_and_run_tool -name {EXPORTDEVMEMINIT} + +export_dev_mem_init_report \ + -export_dir $artifact_directory + +export_smart_debug_data \ + -file_name {smart-debug-data} \ + -export_dir $artifact_directory \ + -probes 1 \ + -package_pins 0 \ + -memory_blocks 1 \ + -envm_data 0 \ + -security_data 1 \ + -display_security_in_smartdebug 0 \ + -chain 1 \ + -programmer_settings 1 \ + -ios_states 1 \ + -generate_bitstream 0 \ + -bitstream_format {PPD} \ + -bitstream_security 0 \ + -bitstream_fabric 0 \ + -bitstream_envm 0 \ + -sanitize_envm 0 \ + -bitstream_snvm 0 \ + -sanitize_snvm 0 \ + -master_include_plaintext_passkey 0 \ + -snvm_data 1 + + +export_prog_job \ + -job_file_name {fp-job} \ + -export_dir $artifact_directory \ + -bitstream_file_type {TRUSTED_FACILITY} \ + -bitstream_file_components {ENVM FABRIC_SNVM} \ + -zeroization_likenew_action 0 \ + -zeroization_unrecoverable_action 0 \ + -program_design 1 \ + -program_spi_flash 0 \ + -include_plaintext_passkey 0 \ + -design_bitstream_format {PPD} \ + -prog_optional_procedures {} \ + -skip_recommended_procedures {} \ + -sanitize_snvm 0 \ + -sanitize_envm 0 + +save_project diff --git a/recipes/libero-project/functions.tcl b/recipes/libero-project/functions.tcl new file mode 100644 index 0000000000000000000000000000000000000000..29edd2b6a8fe2e409b0f250ad084bce4af2e10b3 --- /dev/null +++ b/recipes/libero-project/functions.tcl @@ -0,0 +1,61 @@ +# The Microchip Bitstream Builder is released under the following software licese: + +# Copyright 2021 Microchip Corporation. +# SPDX-License-Identifier: MIT + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +proc create_eNVM_config {config client} { + set envm_config [open $config w] + + puts $envm_config "set_plain_text_client \\" + puts $envm_config "-client_name {BOOT_MODE_1_ENVM_CLIENT} \\" + puts $envm_config "-number_of_bytes 117248 \\" + puts $envm_config "-content_type {MEMORY_FILE} \\" + puts $envm_config "-content_file_format {Intel-Hex} \\" + puts $envm_config "-content_file {$client} \\" + puts $envm_config "-mem_file_base_address {0x20220000} \\" + puts $envm_config "-start_page 0 \\" + puts $envm_config "-use_for_simulation 0 \\" + puts $envm_config "-reprogram 1 \\" + puts $envm_config "-use_as_rom 0 \\" + puts $envm_config "-fabric_access_read 1 \\" + puts $envm_config "-fabric_access_write 0 \\" + puts $envm_config "-mss_access_read 1 \\" + puts $envm_config "-mss_access_write 0" + + close $envm_config +} + +proc create_spi_config {config client} { + set spi_config [open $config w] + + puts $spi_config "set_auto_update_mode {0} " + puts $spi_config "set_spi_flash_memory_size {134217728} " + puts $spi_config "set_client \\" + puts $spi_config " -client_name {baremetal} \\" + puts $spi_config " -client_type {FILE_DATA_STORAGE_PLAIN_BIN} \\" + puts $spi_config " -content_type {MEMORY_FILE} \\" + puts $spi_config " -content_file {$client} \\" + puts $spi_config " -start_address {1024} \\" + puts $spi_config " -client_size {16496} \\" + puts $spi_config " -program {1}" + + close $spi_config +} diff --git a/recipes/libero-project/generate-project.tcl b/recipes/libero-project/generate-project.tcl new file mode 100644 index 0000000000000000000000000000000000000000..bdd3a227a440c0fab55abe44a743d20534573d8f --- /dev/null +++ b/recipes/libero-project/generate-project.tcl @@ -0,0 +1,68 @@ +# The Microchip Bitstream Builder is released under the following software licese: + +# Copyright 2021 Microchip Corporation. +# SPDX-License-Identifier: MIT + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +source ./recipes/libero-project/configure.tcl + +# Make the project +new_project \ + -location $libero_project_directory \ + -name $project_name \ + -project_description {} \ + -block_mode 0 \ + -standalone_peripheral_initialization 0 \ + -instantiate_in_smartdesign 1 \ + -ondemand_build_dh 1 \ + -use_relative_path 0 \ + -linked_files_root_dir_env {} \ + -hdl {VERILOG} \ + -family {PolarFireSoC} \ + -die {MPFS250T_ES} \ + -package {FCVG484} \ + -speed {STD} \ + -die_voltage {1.05} \ + -part_range {EXT} \ + -adv_options {IO_DEFT_STD:LVCMOS 1.8V} \ + -adv_options {RESTRICTPROBEPINS:1} \ + -adv_options {RESTRICTSPIPINS:0} \ + -adv_options {SYSTEM_CONTROLLER_SUSPEND_MODE:0} \ + -adv_options {TEMPR:EXT} \ + -adv_options {VCCI_1.2_VOLTR:EXT} \ + -adv_options {VCCI_1.5_VOLTR:EXT} \ + -adv_options {VCCI_1.8_VOLTR:EXT} \ + -adv_options {VCCI_2.5_VOLTR:EXT} \ + -adv_options {VCCI_3.3_VOLTR:EXT} \ + -adv_options {VOLTR:EXT} + +# Make and import HDL sources +import_mss_component -file "./output/MSS/test_mss.cxz" + +# Generate SmartDesign +cd ./sources/HDL/base +source ./base_recursive.tcl +set_root -module {base::work} +cd ../../../ + +# Import constraints +source ./recipes/libero-project/constraints.tcl + +save_project diff --git a/recipes/libero-project/import-clients.tcl b/recipes/libero-project/import-clients.tcl new file mode 100644 index 0000000000000000000000000000000000000000..0fbc322da78d089d6af60f31d131a4c916467ff6 --- /dev/null +++ b/recipes/libero-project/import-clients.tcl @@ -0,0 +1,36 @@ +# The Microchip Bitstream Builder is released under the following software licese: + +# Copyright 2021 Microchip Corporation. +# SPDX-License-Identifier: MIT + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +source ./recipes/libero-project/configure.tcl + +open_project -file {./output/libero_project/libero_project.prjx} -do_backup_on_convert 1 -backup_file {./output/libero_project/libero_project.zip} + +# Import clients +create_eNVM_config "output/clients/HSS_ENVM.cfg" "../../output/HSS/hss-envm-wrapper-bm1-p0.hex" +configure_envm -cfg_file "./output/clients/HSS_ENVM.cfg" + +create_spi_config "output/clients/bare_metal_spi.cfg" "../../output/payload/spi.bin" +configure_spiflash -cfg_file "./output/clients/bare_metal_spi.cfg" +generate_design_initialization_data + +save_project diff --git a/recipes/libero-project/program-device.tcl b/recipes/libero-project/program-device.tcl new file mode 100644 index 0000000000000000000000000000000000000000..9170f5b95f5a287c9cc8c6db0a32daa4d07c07d1 --- /dev/null +++ b/recipes/libero-project/program-device.tcl @@ -0,0 +1,78 @@ +# The Microchip Bitstream Builder is released under the following software licese: + +# Copyright 2021 Microchip Corporation. +# SPDX-License-Identifier: MIT + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +open_project -file {./output/libero_project/libero_project.prjx} -do_backup_on_convert 1 -backup_file {./output/libero_project/libero_project.zip} + +# configure_tool \ + -name {IO_PROGRAMMING_STATE} \ + -params {ios_file:} + +# configure_tool \ + -name {CONFIGURE_PROG_OPTIONS} \ + -params {back_level_version:0} \ + -params {design_version:0} \ + -params {silicon_signature:} + +# configure_tool \ + -name {SPM} \ + -params {back_level_protection:true} \ + -params {debug_passkey:} \ + -params {disable_authenticate_action:false} \ + -params {disable_autoprog_iap_services:false} \ + -params {disable_debug_jtag_boundary_scan:false} \ + -params {disable_debug_read_temp_volt:false} \ + -params {disable_debug_ujtag:false} \ + -params {disable_ext_zeroization:false} \ + -params {disable_external_digest_check:false} \ + -params {disable_jtag:false} \ + -params {disable_program_action:false} \ + -params {disable_puf_emulation:false} \ + -params {disable_smartdebug_debug:false} \ + -params {disable_smartdebug_live_probe:false} \ + -params {disable_smartdebug_snvm:false} \ + -params {disable_spi_slave:false} \ + -params {disable_user_encryption_key_1:false} \ + -params {disable_user_encryption_key_2:false} \ + -params {disable_verify_action:false} \ + -params {envm_update_protection:open} \ + -params {fabric_update_protection:open} \ + -params {security_factory_access:open} \ + -params {security_key_mode:default} \ + -params {user_encryption_key_1:} \ + -params {user_encryption_key_2:} \ + -params {user_passkey_1:} \ + -params {user_passkey_2:} + +run_tool -name {GENERATEPROGRAMMINGFILE} + +# Program the SPI first so the device is reset after bitstream programming to boot the payload +run_tool -name {GENERATE_SPI_FLASH_IMAGE} +run_tool -name {PROGRAM_SPI_FLASH_IMAGE} + +configure_tool -name {CONFIGURE_ACTION_PROCEDURES} \ + -params {prog_optional_procedures:""} \ + -params {skip_recommended_procedures:""} + +run_tool -name {PROGRAMDEVICE} + +save_project diff --git a/recipes/libero-project/run-flow.tcl b/recipes/libero-project/run-flow.tcl new file mode 100644 index 0000000000000000000000000000000000000000..3fa5866558eeb636d6cdeb555e825b6d831162c8 --- /dev/null +++ b/recipes/libero-project/run-flow.tcl @@ -0,0 +1,145 @@ +# The Microchip Bitstream Builder is released under the following software licese: + +# Copyright 2021 Microchip Corporation. +# SPDX-License-Identifier: MIT + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +open_project -file {./output/libero_project/libero_project.prjx} -do_backup_on_convert 1 -backup_file {./output/libero_project/libero_project.zip} + +# organize_tool_files -tool {SIM_PRESYNTH} \ + -file {} \ + -module {base::work} \ + -input_type {stimulus} + +# run_tool -name {SIM_PRESYNTH} + +# Configure synthesis options +# configure_tool \ + -name {SYNTHESIZE} \ + -params {ACTIVE_IMPLEMENTATION:synthesis} \ + -params {AUTO_COMPILE_POINT:true} \ + -params {BLOCK_MODE:false} \ + -params {BLOCK_PLACEMENT_CONFLICTS:ERROR} \ + -params {BLOCK_ROUTING_CONFLICTS:LOCK} \ + -params {CDC_MIN_NUM_SYNC_REGS:2} \ + -params {CDC_REPORT:true} \ + -params {CLOCK_ASYNC:800} \ + -params {CLOCK_DATA:5000} \ + -params {CLOCK_GATE_ENABLE:false} \ + -params {CLOCK_GATE_ENABLE_THRESHOLD_GLOBAL:1000} \ + -params {CLOCK_GATE_ENABLE_THRESHOLD_ROW:100} \ + -params {CLOCK_GLOBAL:2} \ + -params {CREATE_IMPLEMENTATION_IDENTIFY:} \ + -params {CREATE_IMPLEMENTATION_SYNTHESIS:synthesis} \ + -params {PA4_GB_COUNT:36} \ + -params {PA4_GB_MAX_RCLKINT_INSERTION:16} \ + -params {PA4_GB_MIN_GB_FANOUT_TO_USE_RCLKINT:1000} \ + -params {RAM_OPTIMIZED_FOR_POWER:0} \ + -params {RETIMING:false} \ + -params {ROM_TO_LOGIC:true} \ + -params {SEQSHIFT_TO_URAM:1} \ + -params {SYNPLIFY_OPTIONS:} \ + -params {SYNPLIFY_TCL_FILE:} + +# Run synthesis +run_tool -name {SYNTHESIZE} + +# organize_tool_files -tool {SIM_POSTSYNTH} \ + -file {} \ + -module {base::work} \ + -input_type {stimulus} + +# run_tool -name {SIM_POSTSYNTH} + +# Export the netlist +# run_tool -name {EXPORTNETLIST} + +# Timing verification +# Max timing work first - no high effort, no min delay +configure_tool -name {PLACEROUTE} \ + -params {DELAY_ANALYSIS:MAX} \ + -params {EFFORT_LEVEL:false} \ + -params {GB_DEMOTION:true} \ + -params {INCRPLACEANDROUTE:false} \ + -params {IOREG_COMBINING:false} \ + -params {MULTI_PASS_CRITERIA:VIOLATIONS} \ + -params {MULTI_PASS_LAYOUT:false} \ + -params {NUM_MULTI_PASSES:5} \ + -params {PDPR:false} \ + -params {RANDOM_SEED:0} \ + -params {REPAIR_MIN_DELAY:true} \ + -params {REPLICATION:false} \ + -params {SLACK_CRITERIA:WORST_SLACK} \ + -params {SPECIFIC_CLOCK:} \ + -params {START_SEED_INDEX:1} \ + -params {STOP_ON_FIRST_PASS:false} \ + -params {TDPR:true} + +run_tool -name {PLACEROUTE} + +# Check for max delay and min delay violations using timing verification + +run_tool -name {VERIFYTIMING} + +# if no max violations continue... + +# Min delay next in incremental +configure_tool -name {PLACEROUTE} \ + -params {DELAY_ANALYSIS:MAX} \ + -params {EFFORT_LEVEL:false} \ + -params {GB_DEMOTION:true} \ + -params {INCRPLACEANDROUTE:true} \ + -params {IOREG_COMBINING:false} \ + -params {MULTI_PASS_CRITERIA:VIOLATIONS} \ + -params {MULTI_PASS_LAYOUT:false} \ + -params {NUM_MULTI_PASSES:25} \ + -params {PDPR:false} \ + -params {RANDOM_SEED:7} \ + -params {REPAIR_MIN_DELAY:true} \ + -params {REPLICATION:false} \ + -params {SLACK_CRITERIA:WORST_SLACK} \ + -params {SPECIFIC_CLOCK:} \ + -params {START_SEED_INDEX:9} \ + -params {STOP_ON_FIRST_PASS:true} \ + -params {TDPR:true} + +run_tool -name {PLACEROUTE} + +# Finial timing check - should stop here on violations +run_tool -name {VERIFYTIMING} + +run_tool -name {VERIFYPOWER} + +# run_tool -name {EXPORTSDF} + +# organize_tool_files -tool {SIM_POSTLAYOUT} \ + -file {} \ + -module {base::work} \ + -input_type {stimulus} + +# run_tool -name {SIM_POSTLAYOUT} + +# run_tool -name {CONFIGURE_CHAIN} + +# select_programmer -programmer_id {S2011K1YJJ} + +run_tool -name {GENERATEPROGRAMMINGDATA} + +save_project