From f401a54a13f7ea51c76f503d82a75dd7412530e0 Mon Sep 17 00:00:00 2001 From: rgantonio Date: Tue, 27 Aug 2024 16:35:40 +0200 Subject: [PATCH 1/8] make: add gen-syn-flist target --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 5f8cb6484..42a929ab6 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,15 @@ sw: # In Occamy Docker rtl: # In SNAX Docker make -C ./target/rtl/ rtl CFG_OVERRIDE=$(CFG) +################### +# Tapeout targets # +################### + +# Generating filelist per cluster +# Needed for a per-cluster synthesis +gen-syn-flist: + make -C ./target/tapeout/ syn-gen-list CFG_OVERRIDE=$(CFG) + # FPGA Workflow occamy_system_vivado_preparation: # In SNAX Docker make -C ./target/fpga/ define_defines_includes_no_simset.tcl From 8b891ed0322b271d2e102d244d905a15fa60b296 Mon Sep 17 00:00:00 2001 From: rgantonio Date: Tue, 27 Aug 2024 16:37:04 +0200 Subject: [PATCH 2/8] util: add occamy related generation --- util/occamygen/occamy.py | 14 +++++++++++++- util/occamygen/occamygen.py | 10 +++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/util/occamygen/occamy.py b/util/occamygen/occamy.py index 0e56b345c..380997ef9 100644 --- a/util/occamygen/occamy.py +++ b/util/occamygen/occamy.py @@ -9,6 +9,7 @@ sys.path.append(str(Path(__file__).parent / '../../deps/snitch_cluster/util/clustergen')) from cluster import Generator, PMA, PMACfg, SnitchCluster, clog2 # noqa: E402 import subprocess +import os def read_json_file(file): try: @@ -82,6 +83,17 @@ def generate_snitch(cluster_cfg_dir, snitch_path): for cfg in cluster_cfg_dir: subprocess.call(f"make -C {snitch_path}/target/snitch_cluster CFG_OVERRIDE={cfg} rtl-gen", shell=True) +# For generating cluster synthesis filelists +def generate_cluster_syn_flist(cluster_cfg_dir, snitch_path, outdir): + for cfg in cluster_cfg_dir: + config_name = os.path.splitext(os.path.basename(os.path.normpath(cfg)))[0] + subprocess.call(f"make -C {snitch_path}/target/snitch_cluster \ + CFG_OVERRIDE={cfg} \ + MEM_TYPE=exclude_tcsram \ + SYN_FLIST={config_name}.tcl \ + SYN_BUILDDIR={outdir} \ + gen-syn", shell=True) + def generate_wrappers(cluster_generators,out_dir): for cluster_generator in cluster_generators: cluster_name = cluster_generator.cfg["name"] @@ -568,4 +580,4 @@ def cluster_add_mem(cluster_obj, occamy_cfg): # def render_wrapper(self): # return self.cluster.render_wrapper() # def render_wrappers(self,idx): -# return self.clusters[idx].render_wrapper() \ No newline at end of file +# return self.clusters[idx].render_wrapper() diff --git a/util/occamygen/occamygen.py b/util/occamygen/occamygen.py index 3508264ab..37096f8c4 100755 --- a/util/occamygen/occamygen.py +++ b/util/occamygen/occamygen.py @@ -17,7 +17,7 @@ from mako.template import Template -from occamy import check_occamy_cfg, get_cluster_generators, generate_wrappers, generate_memories, get_cluster_cfg_list, generate_snitch +from occamy import check_occamy_cfg, get_cluster_generators, generate_wrappers, generate_memories, get_cluster_cfg_list, generate_snitch, generate_cluster_syn_flist sys.path.append(str(pathlib.Path(__file__).parent / '../')) from solder import solder, device_tree, util # noqa: E402 @@ -552,6 +552,9 @@ def main(): parser.add_argument("--chip", metavar="CHIP_TOP", help="(Optional) Chip Top-level") + parser.add_argument("--cluster-only-flist", + metavar="TAEPOUT", + help="Flag for generating for generating cluster specific flists only.") parser.add_argument("--graph", "-g", metavar="DOT") parser.add_argument("--memories", "-m", action="store_true") parser.add_argument("--wrapper", "-w", action="store_true") @@ -614,6 +617,11 @@ def main(): print(cluster_cfg_list) generate_snitch(cluster_cfg_list, args.snitch) + # For generating filelists for each cluster + if args.cluster_only_flist: + print("Generate filelist for each cluster only.") + generate_cluster_syn_flist(cluster_cfg_list, args.cluster_only_flist, outdir) + if args.wrapper: generate_wrappers(cluster_generators,outdir) From 929eb89429a41ac142c00a59fc1e5af26014d757 Mon Sep 17 00:00:00 2001 From: rgantonio Date: Tue, 27 Aug 2024 16:38:20 +0200 Subject: [PATCH 3/8] make: add tapeout makefile --- target/tapeout/Makefile | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 target/tapeout/Makefile diff --git a/target/tapeout/Makefile b/target/tapeout/Makefile new file mode 100644 index 000000000..48d832d42 --- /dev/null +++ b/target/tapeout/Makefile @@ -0,0 +1,55 @@ + + +########################## +# Default configurations # +########################## + +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +MKFILE_DIR := $(dir $(MKFILE_PATH)) +ROOT := $(MKFILE_DIR)../.. +BENDER := bender +SNITCH_ROOT := $(shell $(BENDER) path snitch_cluster) + +OCCAMYGEN ?= $(ROOT)/util/occamygen/occamygen.py + +TARGET_RTL ?= $(ROOT)/target/rtl + +####################### +# Config prerequisite # +####################### + +# If the configuration file is overriden on the command-line (through +# CFG_OVERRIDE) and this file differs from the least recently used +# (LRU) config, all targets depending on the configuration file have +# to be rebuilt. This file is used to express this condition as a +# prerequisite for other rules. +CFG = $(TARGET_RTL)/cfg/occamy_cfg/lru.hjson + +$(CFG): FORCE + @# If the LRU config file doesn't exist, we use the default config. + @if [ ! -e $@ ] ; then \ + DEFAULT_CFG="$(TARGET_RTL)/cfg/occamy_cfg/snax_two_clusters.hjson"; \ + echo "Using default config file: $$DEFAULT_CFG"; \ + cp $$DEFAULT_CFG $@; \ + fi + @# If a config file is provided on the command-line + @# then we override the LRU file with it + @if [ $(CFG_OVERRIDE) ] ; then \ + echo "Overriding config file with: $(CFG_OVERRIDE)"; \ + cp $(CFG_OVERRIDE) $@; \ + fi +FORCE: + +######################## +# Generating Filelists # +######################## + +syn-gen-list: + @$(OCCAMYGEN) --cfg $(CFG) --outdir ${MKFILE_DIR} --cluster-only-flist ${SNITCH_ROOT} + +debug-info: + @echo "SNITCH ROOT: ${SNITCH_ROOT}" + @echo "CFG override: ${CFG_OVERRIDE}" + @echo "Makefile path: ${MKFILE_PATH}" + @echo "Makefile dir: ${MKFILE_DIR}" + From 3fdfaf05319e14eb2568d540c7101504e2f4cf52 Mon Sep 17 00:00:00 2001 From: rgantonio Date: Wed, 28 Aug 2024 16:29:07 +0200 Subject: [PATCH 4/8] util: add functionality for flist gen --- util/hemaia/util.py | 55 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/util/hemaia/util.py b/util/hemaia/util.py index f4b0f857b..5f7e4de15 100755 --- a/util/hemaia/util.py +++ b/util/hemaia/util.py @@ -4,13 +4,17 @@ # SPDX-License-Identifier: Apache-2.0 # # Yunhao Deng +# Ryan Antonio -from mako.lookup import TemplateLookup -from mako.template import Template +# TODO: commenting some so that they will be added later +# from mako.lookup import TemplateLookup +# from mako.template import Template from jsonref import JsonRef import hjson import argparse import os +import subprocess +import pathlib # Extract json file @@ -23,10 +27,23 @@ def get_config(cfg_path: str): cfg = JsonRef.replace_refs(cfg) return cfg + +# For generating cluster synthesis filelists +def generate_cluster_syn_flist(cfg, snax_path, outdir): + config_name = os.path.splitext(os.path.basename(os.path.normpath(cfg)))[0] + subprocess.call(f"make -C {snax_path}/target/snitch_cluster \ + CFG_OVERRIDE={cfg} \ + MEM_TYPE=exclude_tcsram \ + SYN_FLIST={config_name}.tcl \ + SYN_BUILDDIR={outdir} \ + gen-syn", shell=True) + + def hemaia_util(): # Parse all arguments parser = argparse.ArgumentParser( - description="The util collection to retrieve information from the hemaia json file" + description="The util collection to \ + retrieve information from the hemaia json file" ) parser.add_argument( "--cfg_path", @@ -41,6 +58,20 @@ def hemaia_util(): help="Print out the containing cluster names", ) + parser.add_argument("--outdir", + "-o", + type=pathlib.Path, + help="Target directory.") + + parser.add_argument("--snax-path", + type=pathlib.Path, + help="Path to the SNAX cluster repo.") + + parser.add_argument("--cluster-flist", + action="store_true", + help="Flag for generating for generating \ + cluster specific flists only.") + parsed_args = parser.parse_args() # Parse the occamy_cfg file @@ -49,14 +80,25 @@ def hemaia_util(): clusters = occamy_cfg['clusters'] cluster_cfgs = [] for cluster in clusters: - cluster_cfg_path = os.path.dirname(parsed_args.cfg_path) + "/../cluster_cfg/" + cluster + ".hjson" + cluster_cfg_path = os.path.dirname(parsed_args.cfg_path) + \ + "/../cluster_cfg/" + cluster + ".hjson" cluster_cfgs.append(get_config(cluster_cfg_path)) else: raise Exception("No clusters found in the hemaia json file") - + + # For generating filelists for each cluster + # These filelists are specific for synthesis only + if parsed_args.cluster_flist: + print("Generate filelist for each cluster only.") + for cluster in occamy_cfg['clusters']: + cfg_str = f"cfg/{cluster}.hjson" + generate_cluster_syn_flist(cfg_str, + parsed_args.snax_path, + parsed_args.outdir) + if cluster_cfgs.__len__() == 0: raise Exception("The number of cluster is 0") - + # The remaining part is related to different functions # Available variables: # - occamy_cfg: The main configuration file @@ -68,5 +110,6 @@ def hemaia_util(): print() return + if __name__ == "__main__": hemaia_util() From 7a904061b95cee3b6171eaae7f93e3e2ce7110f1 Mon Sep 17 00:00:00 2001 From: rgantonio Date: Wed, 28 Aug 2024 16:29:20 +0200 Subject: [PATCH 5/8] util: refactor flist gen --- util/occamygen/occamy.py | 11 ----------- util/occamygen/occamygen.py | 10 +--------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/util/occamygen/occamy.py b/util/occamygen/occamy.py index 380997ef9..2068834b7 100644 --- a/util/occamygen/occamy.py +++ b/util/occamygen/occamy.py @@ -83,17 +83,6 @@ def generate_snitch(cluster_cfg_dir, snitch_path): for cfg in cluster_cfg_dir: subprocess.call(f"make -C {snitch_path}/target/snitch_cluster CFG_OVERRIDE={cfg} rtl-gen", shell=True) -# For generating cluster synthesis filelists -def generate_cluster_syn_flist(cluster_cfg_dir, snitch_path, outdir): - for cfg in cluster_cfg_dir: - config_name = os.path.splitext(os.path.basename(os.path.normpath(cfg)))[0] - subprocess.call(f"make -C {snitch_path}/target/snitch_cluster \ - CFG_OVERRIDE={cfg} \ - MEM_TYPE=exclude_tcsram \ - SYN_FLIST={config_name}.tcl \ - SYN_BUILDDIR={outdir} \ - gen-syn", shell=True) - def generate_wrappers(cluster_generators,out_dir): for cluster_generator in cluster_generators: cluster_name = cluster_generator.cfg["name"] diff --git a/util/occamygen/occamygen.py b/util/occamygen/occamygen.py index 37096f8c4..3508264ab 100755 --- a/util/occamygen/occamygen.py +++ b/util/occamygen/occamygen.py @@ -17,7 +17,7 @@ from mako.template import Template -from occamy import check_occamy_cfg, get_cluster_generators, generate_wrappers, generate_memories, get_cluster_cfg_list, generate_snitch, generate_cluster_syn_flist +from occamy import check_occamy_cfg, get_cluster_generators, generate_wrappers, generate_memories, get_cluster_cfg_list, generate_snitch sys.path.append(str(pathlib.Path(__file__).parent / '../')) from solder import solder, device_tree, util # noqa: E402 @@ -552,9 +552,6 @@ def main(): parser.add_argument("--chip", metavar="CHIP_TOP", help="(Optional) Chip Top-level") - parser.add_argument("--cluster-only-flist", - metavar="TAEPOUT", - help="Flag for generating for generating cluster specific flists only.") parser.add_argument("--graph", "-g", metavar="DOT") parser.add_argument("--memories", "-m", action="store_true") parser.add_argument("--wrapper", "-w", action="store_true") @@ -617,11 +614,6 @@ def main(): print(cluster_cfg_list) generate_snitch(cluster_cfg_list, args.snitch) - # For generating filelists for each cluster - if args.cluster_only_flist: - print("Generate filelist for each cluster only.") - generate_cluster_syn_flist(cluster_cfg_list, args.cluster_only_flist, outdir) - if args.wrapper: generate_wrappers(cluster_generators,outdir) From bf2ea7d7e6dfb125937d64435bbcf4199cb4636f Mon Sep 17 00:00:00 2001 From: rgantonio Date: Wed, 28 Aug 2024 16:29:35 +0200 Subject: [PATCH 6/8] make: modify target recipe --- target/tapeout/Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/tapeout/Makefile b/target/tapeout/Makefile index 48d832d42..c7b1dd50e 100644 --- a/target/tapeout/Makefile +++ b/target/tapeout/Makefile @@ -8,11 +8,11 @@ MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) MKFILE_DIR := $(dir $(MKFILE_PATH)) ROOT := $(MKFILE_DIR)../.. BENDER := bender -SNITCH_ROOT := $(shell $(BENDER) path snitch_cluster) +SNAX_ROOT := $(shell $(BENDER) path snitch_cluster) -OCCAMYGEN ?= $(ROOT)/util/occamygen/occamygen.py +HEMAIA_UTIL ?= $(ROOT)/util/hemaia/util.py -TARGET_RTL ?= $(ROOT)/target/rtl +TARGET_RTL ?= $(ROOT)/target/rtl ####################### # Config prerequisite # @@ -45,10 +45,11 @@ FORCE: ######################## syn-gen-list: - @$(OCCAMYGEN) --cfg $(CFG) --outdir ${MKFILE_DIR} --cluster-only-flist ${SNITCH_ROOT} + @$(HEMAIA_UTIL) --cfg_path $(CFG) --snax-path $(SNAX_ROOT) \ + --outdir ${MKFILE_DIR} --cluster-flist debug-info: - @echo "SNITCH ROOT: ${SNITCH_ROOT}" + @echo "SNAX ROOT: ${SNAX_ROOT}" @echo "CFG override: ${CFG_OVERRIDE}" @echo "Makefile path: ${MKFILE_PATH}" @echo "Makefile dir: ${MKFILE_DIR}" From 4cb2d2d61dd2ed988cf62ff650b308c1ecaa6ca9 Mon Sep 17 00:00:00 2001 From: rgantonio Date: Wed, 28 Aug 2024 16:31:46 +0200 Subject: [PATCH 7/8] util: fmt --- util/occamygen/occamy.py | 1 - 1 file changed, 1 deletion(-) diff --git a/util/occamygen/occamy.py b/util/occamygen/occamy.py index 2068834b7..0be082dde 100644 --- a/util/occamygen/occamy.py +++ b/util/occamygen/occamy.py @@ -9,7 +9,6 @@ sys.path.append(str(Path(__file__).parent / '../../deps/snitch_cluster/util/clustergen')) from cluster import Generator, PMA, PMACfg, SnitchCluster, clog2 # noqa: E402 import subprocess -import os def read_json_file(file): try: From 8e18cbebd64afd750020b6972c3c2dac4b2c21dd Mon Sep 17 00:00:00 2001 From: Yunhao Deng Date: Thu, 29 Aug 2024 10:20:13 +0200 Subject: [PATCH 8/8] Improve hemaia util --- util/hemaia/util.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/util/hemaia/util.py b/util/hemaia/util.py index 5f7e4de15..e3b11cea6 100755 --- a/util/hemaia/util.py +++ b/util/hemaia/util.py @@ -79,37 +79,38 @@ def hemaia_util(): if 'clusters' in occamy_cfg: clusters = occamy_cfg['clusters'] cluster_cfgs = [] + cluster_cfg_paths = [] for cluster in clusters: cluster_cfg_path = os.path.dirname(parsed_args.cfg_path) + \ "/../cluster_cfg/" + cluster + ".hjson" + cluster_cfg_paths.append(cluster_cfg_path) cluster_cfgs.append(get_config(cluster_cfg_path)) else: raise Exception("No clusters found in the hemaia json file") - - # For generating filelists for each cluster - # These filelists are specific for synthesis only - if parsed_args.cluster_flist: - print("Generate filelist for each cluster only.") - for cluster in occamy_cfg['clusters']: - cfg_str = f"cfg/{cluster}.hjson" - generate_cluster_syn_flist(cfg_str, - parsed_args.snax_path, - parsed_args.outdir) - if cluster_cfgs.__len__() == 0: raise Exception("The number of cluster is 0") - # The remaining part is related to different functions + # The remaining part is the region for the util functions # Available variables: # - occamy_cfg: The main configuration file + # - cluster_cfg_paths: The paths to the cluster configurations in a list # - cluster_cfgs: The parsed cluster configurations in a list + # For printing out the cluster names and generate targets if parsed_args.print_clusters: for cluster_cfg in cluster_cfgs: print(cluster_cfg['cluster']['name'] + " ", end="") print() return - + + # For generating filelists for each cluster + # These filelists are specific for synthesis only + if parsed_args.cluster_flist: + print("Generate filelist for each cluster only.") + for cluster_cfg_path in cluster_cfg_paths: + generate_cluster_syn_flist(cluster_cfg_path, + parsed_args.snax_path, + parsed_args.outdir) if __name__ == "__main__": hemaia_util()