Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cluster-level synthesis file lists for tapeout #19

Merged
merged 8 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 56 additions & 0 deletions target/tapeout/Makefile
Original file line number Diff line number Diff line change
@@ -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}"

58 changes: 51 additions & 7 deletions util/hemaia/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
# SPDX-License-Identifier: Apache-2.0
#
# Yunhao Deng <[email protected]>
# Ryan Antonio <[email protected]>

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
Expand All @@ -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",
Expand All @@ -41,32 +58,59 @@ 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
occamy_cfg = get_config(parsed_args.cfg_path)
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()
2 changes: 1 addition & 1 deletion util/occamygen/occamy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
# return self.clusters[idx].render_wrapper()
Loading