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 diff --git a/target/tapeout/Makefile b/target/tapeout/Makefile new file mode 100644 index 000000000..c7b1dd50e --- /dev/null +++ b/target/tapeout/Makefile @@ -0,0 +1,56 @@ + + +########################## +# Default configurations # +########################## + +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +MKFILE_DIR := $(dir $(MKFILE_PATH)) +ROOT := $(MKFILE_DIR)../.. +BENDER := bender +SNAX_ROOT := $(shell $(BENDER) path snitch_cluster) + +HEMAIA_UTIL ?= $(ROOT)/util/hemaia/util.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: + @$(HEMAIA_UTIL) --cfg_path $(CFG) --snax-path $(SNAX_ROOT) \ + --outdir ${MKFILE_DIR} --cluster-flist + +debug-info: + @echo "SNAX ROOT: ${SNAX_ROOT}" + @echo "CFG override: ${CFG_OVERRIDE}" + @echo "Makefile path: ${MKFILE_PATH}" + @echo "Makefile dir: ${MKFILE_DIR}" + diff --git a/util/hemaia/util.py b/util/hemaia/util.py index f4b0f857b..e3b11cea6 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 @@ -48,25 +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_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") - 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() diff --git a/util/occamygen/occamy.py b/util/occamygen/occamy.py index 0e56b345c..0be082dde 100644 --- a/util/occamygen/occamy.py +++ b/util/occamygen/occamy.py @@ -568,4 +568,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()