From 37241af1fca7be9dec04be37f8d477e7bcd91003 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Tue, 4 Jun 2019 10:36:25 -0700 Subject: [PATCH 1/4] Add initial VLSI flow scripts --- .gitmodules | 4 ++ vlsi/.gitignore | 6 +++ vlsi/Makefile | 122 ++++++++++++++++++++++++++++++++++++++++++++++ vlsi/README.md | 5 ++ vlsi/example-vlsi | 36 ++++++++++++++ vlsi/hammer | 1 + 6 files changed, 174 insertions(+) create mode 100644 vlsi/.gitignore create mode 100644 vlsi/Makefile create mode 100644 vlsi/README.md create mode 100755 vlsi/example-vlsi create mode 160000 vlsi/hammer diff --git a/.gitmodules b/.gitmodules index ca80d661..9e30fb35 100644 --- a/.gitmodules +++ b/.gitmodules @@ -40,3 +40,7 @@ [submodule "generators/block-inclusivecache-sifive"] path = generators/sifive-cache url = https://github.com/sifive/block-inclusivecache-sifive.git +[submodule "vlsi/hammer"] + path = vlsi/hammer + url = git@github.com:ucb-bar/hammer.git + diff --git a/vlsi/.gitignore b/vlsi/.gitignore new file mode 100644 index 00000000..4cbcfe8f --- /dev/null +++ b/vlsi/.gitignore @@ -0,0 +1,6 @@ +inputs.yml +__pycache__ +hammer*.log +build +src/test/output-*.json +generated-src \ No newline at end of file diff --git a/vlsi/Makefile b/vlsi/Makefile new file mode 100644 index 00000000..5b6390b7 --- /dev/null +++ b/vlsi/Makefile @@ -0,0 +1,122 @@ +######################################################################################### +# vlsi makefile +######################################################################################### + +######################################################################################### +# general path variables +######################################################################################### +base_dir=$(abspath ..) +vlsi_dir=$(abspath .) +sim_dir=$(abspath .) + +######################################################################################### +# include shared variables +######################################################################################### +include $(base_dir)/variables.mk + +######################################################################################### +# import other necessary rules and variables +######################################################################################### +include $(base_dir)/common.mk + +######################################################################################### +# vlsi types and rules +######################################################################################### + +#sim_name is unused, but GenerateSimFiles expects it +sim_name ?= vcs +tech_name ?= +tech_dir ?= $(vlsi_dir)/hammer-$(tech_nam)-plugin/$(tech_name) +SMEMS_COMP ?= $(tech_dir)/sram-compiler.json +SMEMS_HAMMER ?= $(build_dir)/$(long_name).mems.hammer.json +MACROCOMPILER_MODE ?= -l $(SMEMS_COMP) --use-compiler -hir $(SMEMS_HAMMER) +OBJ_DIR ?= $(vlsi_dir)/build +ENV_YML ?= $(vlsi_dir)/hammer-cad-plugins/bwrc-env.yml +INPUT_CONFS ?= example.yml $(dir $(tech_dir))/bwrc.yml +HAMMER_EXEC ?= ./example-vlsi + +ROCKET_SRC_DIR=$(ROCKETCHIP_DIR)/src/main/resources/vsrc + +ROCKET_SRCS = \ + $(ROCKET_SRC_DIR)/ClockDivider2.v \ + $(ROCKET_SRC_DIR)/ClockDivider3.v \ + $(ROCKET_SRC_DIR)/AsyncResetReg.v \ + $(ROCKET_SRC_DIR)/plusarg_reader.v \ + $(ROCKET_SRC_DIR)/EICG_wrapper.v \ + +ALL_RTL = $(ROCKET_SRCS) $(VERILOG_FILE) $(SMEMS_FILE) + +CLOCK_DOMAINS = $(build_dir)/$(long_name).domains + +.PHONY: default +default: all + +all: drc lvs + + +###################################################### SYN ############################################################ + +SYNTH_CONF = $(OBJ_DIR)/inputs.yml + +$(SYNTH_CONF): + mkdir -p $(dir $@) + echo "synthesis.inputs:" > $@ + echo " top_module: $(TOP)" >> $@ + echo " input_files:" >> $@ + for x in $(ALL_RTL); do \ + echo ' - "'$$x'"' >> $@; \ + done + +GENERATED_CONFS=$(SYNTH_CONF) $(SRAM_CONF) + +.PHONY: syn synthesis +syn: $(OBJ_DIR)/syn-rundir/$(TOP).mapped.v +synthesis: syn + +$(OBJ_DIR)/syn-rundir/$(TOP).mapped.v $(OBJ_DIR)/syn-rundir/syn-output.json: $(ENV_YML) $(INPUT_CONFS) $(GENERATED_CONFS) $(ALL_RTL) + mkdir -p $(dir $@) + $(HAMMER_EXEC) -e $(ENV_YML) $(foreach x,$(INPUT_CONFS) $(GENERATED_CONFS), -p $(x)) --obj_dir $(OBJ_DIR) syn + +$(OBJ_DIR)/par-input.json: $(OBJ_DIR)/syn-rundir/syn-output.json + mkdir -p $(dir $@) + $(HAMMER_EXEC) -e $(ENV_YML) $(foreach x,$(INPUT_CONFS) $<, -p $(x)) -o $@ syn_to_par + +###################################################### PAR ############################################################ + +.PHONY: par place-and-route +par: $(OBJ_DIR)/par-rundir/$(TOP).gds +place-and-route: par + +$(OBJ_DIR)/par-rundir/$(TOP).gds $(OBJ_DIR)/par-rundir/par-output.json: $(OBJ_DIR)/par-input.json $(OBJ_DIR)/syn-rundir/$(TOP).mapped.v + mkdir -p $(dir $@) + $(HAMMER_EXEC) -e $(ENV_YML) -p $< --obj_dir $(OBJ_DIR) par + +$(OBJ_DIR)/drc-input.json: $(OBJ_DIR)/par-input.json $(OBJ_DIR)/par-rundir/par-output.json + mkdir -p $(dir $@) + $(HAMMER_EXEC) -e $(ENV_YML) $(foreach x,$^, -p $(x)) -o $@ --obj_dir $(OBJ_DIR) par_to_drc + +###################################################### DRC ############################################################ +# TODO unimplemented +.PHONY: drc +drc: $(OBJ_DIR)/drc-rundir/drc_results.db + +$(OBJ_DIR)/drc-rundir/drc_results.db: $(OBJ_DIR)/drc-input.json $(OBJ_DIR)/par-rundir/$(TOP).gds + mkdir -p $(dir $@) + $(HAMMER_EXEC) -e $(ENV_YML) -p $< --obj_dir $(OBJ_DIR) drc + +###################################################### LVS ############################################################ +# TODO unimplemented +$(OBJ_DIR)/lvs-input.json: $(OBJ_DIR)/par-input.json $(OBJ_DIR)/par-rundir/par-output.json + mkdir -p $(dir $@) + $(HAMMER_EXEC) -e $(ENV_YML) $(foreach x,$^, -p $(x)) -o $@ --obj_dir $(OBJ_DIR) par_to_lvs + +.PHONY: lvs +lvs: $(OBJ_DIR)/lvs-rundir/lvs_results.rpt + +$(OBJ_DIR)/lvs-rundir/lvs_results.rpt: $(OBJ_DIR)/lvs-input.json $(OBJ_DIR)/par-rundir/$(TOP).gds + mkdir -p $(dir $@) + $(HAMMER_EXEC) -e $(ENV_YML) -p $< --obj_dir $(OBJ_DIR) lvs + +.PHONY: clean +clean: + rm -rf $(OBJ_DIR) hammer-vlsi*.log __pycache__ output.json $(GENERATED_CONFS) generated-src diff --git a/vlsi/README.md b/vlsi/README.md new file mode 100644 index 00000000..d09fb5d8 --- /dev/null +++ b/vlsi/README.md @@ -0,0 +1,5 @@ +This is the starting point for a vlsi flow from this repository. + +This flow will not work without the necessary CAD and technology plugins for HAMMER. + +If you are a UCB-affiliate, you may be able to acquire access to the tech-plugins. \ No newline at end of file diff --git a/vlsi/example-vlsi b/vlsi/example-vlsi new file mode 100755 index 00000000..90ddec3c --- /dev/null +++ b/vlsi/example-vlsi @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import hammer_vlsi +from hammer_vlsi import CLIDriver + +from typing import Dict, Callable, Optional + +def example_place_tap_cells(x: hammer_vlsi.HammerTool) -> bool: + x.append(''' +# TODO +''') + return True + +class ExampleDriver(CLIDriver): + + def action_map(self) -> Dict[str, Callable[[hammer_vlsi.HammerDriver, Callable[[str], None]], Optional[dict]]]: + par_action = self.create_par_action(custom_hooks=[ + hammer_vlsi.HammerTool.make_replacement_hook("place_tap_cells", example_place_tap_cells) + ]) + + new_dict = dict(super().action_map()) + new_dict.update({ + "par": par_action + }) + return new_dict + + def par_action(self, driver: hammer_vlsi.HammerDriver, append_error_func: Callable[[str], None]) -> Optional[dict]: + if not driver.load_par_tool(): + return None + success, par_output = driver.run_par(hook_actions=[ + hammer_vlsi.HammerTool.make_replacement_hook("place_tap_cells", example_place_tap_cells) + ]) + return par_output + +if __name__ == '__main__': + ExampleDriver().main() diff --git a/vlsi/hammer b/vlsi/hammer new file mode 160000 index 00000000..873b2c1a --- /dev/null +++ b/vlsi/hammer @@ -0,0 +1 @@ +Subproject commit 873b2c1af0a54cb339a19a7c8cf3a1e7905feb58 From f7735dedc0c3eb9744695af61de230864b05d12d Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Tue, 4 Jun 2019 12:18:34 -0700 Subject: [PATCH 2/4] Use new API for par hooks | fix typo --- vlsi/Makefile | 2 +- vlsi/example-vlsi | 25 ++++--------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/vlsi/Makefile b/vlsi/Makefile index 5b6390b7..193ed0b4 100644 --- a/vlsi/Makefile +++ b/vlsi/Makefile @@ -26,7 +26,7 @@ include $(base_dir)/common.mk #sim_name is unused, but GenerateSimFiles expects it sim_name ?= vcs tech_name ?= -tech_dir ?= $(vlsi_dir)/hammer-$(tech_nam)-plugin/$(tech_name) +tech_dir ?= $(vlsi_dir)/hammer-$(tech_name)-plugin/$(tech_name) SMEMS_COMP ?= $(tech_dir)/sram-compiler.json SMEMS_HAMMER ?= $(build_dir)/$(long_name).mems.hammer.json MACROCOMPILER_MODE ?= -l $(SMEMS_COMP) --use-compiler -hir $(SMEMS_HAMMER) diff --git a/vlsi/example-vlsi b/vlsi/example-vlsi index 90ddec3c..3f65d9a5 100755 --- a/vlsi/example-vlsi +++ b/vlsi/example-vlsi @@ -1,9 +1,9 @@ #!/usr/bin/env python3 import hammer_vlsi -from hammer_vlsi import CLIDriver +from hammer_vlsi import CLIDriver, HammerToolHookAction -from typing import Dict, Callable, Optional +from typing import Dict, Callable, Optional, List def example_place_tap_cells(x: hammer_vlsi.HammerTool) -> bool: x.append(''' @@ -12,25 +12,8 @@ def example_place_tap_cells(x: hammer_vlsi.HammerTool) -> bool: return True class ExampleDriver(CLIDriver): - - def action_map(self) -> Dict[str, Callable[[hammer_vlsi.HammerDriver, Callable[[str], None]], Optional[dict]]]: - par_action = self.create_par_action(custom_hooks=[ - hammer_vlsi.HammerTool.make_replacement_hook("place_tap_cells", example_place_tap_cells) - ]) - - new_dict = dict(super().action_map()) - new_dict.update({ - "par": par_action - }) - return new_dict - - def par_action(self, driver: hammer_vlsi.HammerDriver, append_error_func: Callable[[str], None]) -> Optional[dict]: - if not driver.load_par_tool(): - return None - success, par_output = driver.run_par(hook_actions=[ - hammer_vlsi.HammerTool.make_replacement_hook("place_tap_cells", example_place_tap_cells) - ]) - return par_output + def get_extra_par_hooks(self) -> List[HammerToolHookAction]: + return [hammer_vlsi.HammerTool.make_replacement_hook("place_tap_cells", example_place_tap_cells)] if __name__ == '__main__': ExampleDriver().main() From 6e790abdeeb52a284f95c69f4a70343ad424eebb Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Mon, 15 Jul 2019 16:08:10 -0700 Subject: [PATCH 3/4] Add hammer-cad-plugins submodule --- .gitmodules | 3 +++ vlsi/Makefile | 2 +- vlsi/hammer-cad-plugins | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) create mode 160000 vlsi/hammer-cad-plugins diff --git a/.gitmodules b/.gitmodules index 9e30fb35..9729ae2e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -43,4 +43,7 @@ [submodule "vlsi/hammer"] path = vlsi/hammer url = git@github.com:ucb-bar/hammer.git +[submodule "vlsi/hammer-cad-plugins"] + path = vlsi/hammer-cad-plugins + url = git@github.com:ucb-bar/hammer-cad-plugins diff --git a/vlsi/Makefile b/vlsi/Makefile index 193ed0b4..7dc797c6 100644 --- a/vlsi/Makefile +++ b/vlsi/Makefile @@ -31,7 +31,7 @@ SMEMS_COMP ?= $(tech_dir)/sram-compiler.json SMEMS_HAMMER ?= $(build_dir)/$(long_name).mems.hammer.json MACROCOMPILER_MODE ?= -l $(SMEMS_COMP) --use-compiler -hir $(SMEMS_HAMMER) OBJ_DIR ?= $(vlsi_dir)/build -ENV_YML ?= $(vlsi_dir)/hammer-cad-plugins/bwrc-env.yml +ENV_YML ?= $(vlsi_dir)/bwrc-env.yml INPUT_CONFS ?= example.yml $(dir $(tech_dir))/bwrc.yml HAMMER_EXEC ?= ./example-vlsi diff --git a/vlsi/hammer-cad-plugins b/vlsi/hammer-cad-plugins new file mode 160000 index 00000000..72809f53 --- /dev/null +++ b/vlsi/hammer-cad-plugins @@ -0,0 +1 @@ +Subproject commit 72809f538c4bbe91c103de52e92baad9df6d8f9a From 906f5af809df17f97079f46870785175db25494d Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Mon, 15 Jul 2019 16:15:09 -0700 Subject: [PATCH 4/4] Don't pull hammer-cad-plugins in init script --- .circleci/check-commit.sh | 1 + scripts/init-submodules-no-riscv-tools.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.circleci/check-commit.sh b/.circleci/check-commit.sh index ea7e30f5..bcf4e2ea 100755 --- a/.circleci/check-commit.sh +++ b/.circleci/check-commit.sh @@ -9,6 +9,7 @@ set -ex cd $HOME/project # initialize submodules and get the hashes +git config submodule.vlsi/hammer-cad-plugins.update none git submodule update --init status=$(git submodule status) diff --git a/scripts/init-submodules-no-riscv-tools.sh b/scripts/init-submodules-no-riscv-tools.sh index 8bf6b300..99b1b497 100755 --- a/scripts/init-submodules-no-riscv-tools.sh +++ b/scripts/init-submodules-no-riscv-tools.sh @@ -16,6 +16,8 @@ git config --global submodule.esp-tools.update none git config --global submodule.experimental-blocks.update none # Disable updates to the FireSim submodule until explicitly requested git config submodule.sims/firesim.update none +# Disable updates to the hammer-cad-plugins repo +git config submodule.vlsi/hammer-cad-plugins.update none git submodule update --init --recursive #--jobs 8 # unignore riscv-tools,catapult-shell2 globally git config --global --unset submodule.riscv-tools.update