Skip to content

Commit

Permalink
Cleanup NPU scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
minseongg committed Nov 8, 2024
1 parent 21aba5e commit 1e6bf91
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 178 deletions.
12 changes: 6 additions & 6 deletions scripts/gemmini/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import os

# Paths
CHIPYARD_PATH = os.path.dirname(os.environ["CONDA_PREFIX"])
GEMMINI_PATH = CHIPYARD_PATH + "/generators/gemmini"
VERILATOR_MAKEFILE_PATH = CHIPYARD_PATH + "/sims/verilator"
GEMMINI_SRC_PATH = GEMMINI_PATH + "/src/main"
GEMMINI_VSRC_PATH = GEMMINI_SRC_PATH + "/resources/vsrc"
GEMMINI_CHISEL_PATH = GEMMINI_SRC_PATH + "/scala/gemmini"
CHIPYARD_PATH = pathlib.Path(os.environ["CONDA_PREFIX"]).absolute().parent
GEMMINI_PATH = CHIPYARD_PATH / "generators" / "gemmini"
VERILATOR_MAKEFILE_PATH = CHIPYARD_PATH / "sims" / "verilator"
GEMMINI_SRC_PATH = GEMMINI_PATH / "src" / "main"
GEMMINI_VSRC_PATH = GEMMINI_SRC_PATH / "resources" / "vsrc"
GEMMINI_CHISEL_PATH = GEMMINI_SRC_PATH / "scala" / "gemmini"

HAZARDFLOW_PATH = pathlib.Path(__file__).absolute().parent.parent.parent
GEMMINI_SCRIPT_PATH = HAZARDFLOW_PATH / "scripts" / "gemmini"
Expand Down
159 changes: 0 additions & 159 deletions scripts/gemmini/convert.py

This file was deleted.

24 changes: 12 additions & 12 deletions scripts/gemmini/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ def copy_verilator_configuration_files():
# Copy `build-verilator.sh`
shutil.copy(
VERILATOR_CONFIG_FILES_PATH / "build-verilator.sh",
GEMMINI_PATH + "/scripts/build-verilator.sh",
GEMMINI_PATH / "scripts" / "build-verilator.sh",
)
# Copy Makefile
shutil.copy(
VERILATOR_CONFIG_FILES_PATH / "Makefile", VERILATOR_MAKEFILE_PATH + "/Makefile"
VERILATOR_CONFIG_FILES_PATH / "Makefile", VERILATOR_MAKEFILE_PATH / "Makefile"
)


def compile_testbenches_with_fast_option():
subprocess.run(
"CFLAGS=-DFAST ./build.sh",
shell=True,
cwd=CHIPYARD_PATH + "/generators/gemmini/software/gemmini-rocc-tests",
cwd=CHIPYARD_PATH / "generators" / "gemmini" / "software" / "gemmini-rocc-tests",
)


Expand Down Expand Up @@ -123,15 +123,15 @@ def setup_gemmini(config: str):


def build_verilator_simulation_binary(debug: bool):
subprocess.run(["bash", GEMMINI_PATH + "/scripts/setup-paths.sh"], cwd=GEMMINI_PATH)
subprocess.run(["bash", GEMMINI_PATH / "scripts" / "setup-paths.sh"], cwd=GEMMINI_PATH)
if debug:
subprocess.run(
["bash", GEMMINI_PATH + "/scripts/build-verilator.sh", "--debug"],
["bash", GEMMINI_PATH / "scripts" / "build-verilator.sh", "--debug"],
cwd=GEMMINI_PATH,
)
else:
subprocess.run(
["bash", GEMMINI_PATH + "/scripts/build-verilator.sh"],
["bash", GEMMINI_PATH / "scripts" / "build-verilator.sh"],
cwd=GEMMINI_PATH,
)

Expand Down Expand Up @@ -170,14 +170,14 @@ def run_simulation(tb: str, debug: bool):
compile_testbenches_with_fast_option()
if debug:
subprocess.run(
["bash", GEMMINI_PATH + "/scripts/run-verilator.sh", tb, "--debug"],
["bash", GEMMINI_PATH / "scripts" / "run-verilator.sh", tb, "--debug"],
cwd=GEMMINI_PATH,
)
with open(GEMMINI_PATH + "/waveforms/waveform_pruned.vcd", "w") as outfile:
with open(GEMMINI_PATH / "waveforms" / "waveform_pruned.vcd", "w") as outfile:
subprocess.run(
[
"vcd-prune",
GEMMINI_PATH + "/waveforms/waveform.vcd",
GEMMINI_PATH / "waveforms" / "waveform.vcd",
"-m",
"gemmini",
],
Expand All @@ -186,13 +186,13 @@ def run_simulation(tb: str, debug: bool):
subprocess.run(
[
"cp",
GEMMINI_PATH + "/waveforms/waveform_pruned.vcd",
GEMMINI_SCRIPT_PATH + "/" + tb + ".vcd",
GEMMINI_PATH / "waveforms" / "waveform_pruned.vcd",
GEMMINI_SCRIPT_PATH / f"{tb}.vcd",
]
)
else:
subprocess.run(
["bash", GEMMINI_PATH + "/scripts/run-verilator.sh", tb], cwd=GEMMINI_PATH
["bash", GEMMINI_PATH / "scripts" / "run-verilator.sh", tb], cwd=GEMMINI_PATH
)


Expand Down
2 changes: 1 addition & 1 deletion scripts/gemmini/unit_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
# Silently run the command to check if the conda env is base
if [[ $CONDA_DEFAULT_ENV == "base" ]]; then
echo "Please activate a conda environment before running this script."
echo "Run \`source ~/chipyard/env.sh\` to activate the chipyard conda environment."
echo "Run \`source /tmp/chipyard/env.sh\` to activate the chipyard conda environment."
exit 1
fi

Expand Down

0 comments on commit 1e6bf91

Please sign in to comment.