forked from pulp-platform/occamy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cluster-level synthesis file lists for tapeout (#19)
* make: add gen-syn-flist target * util: add occamy related generation * make: add tapeout makefile * util: add functionality for flist gen * util: refactor flist gen * make: modify target recipe * util: fmt * Improve hemaia util --------- Co-authored-by: Yunhao Deng <[email protected]>
- Loading branch information
Showing
4 changed files
with
117 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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,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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters