AI Computing Systems (EE219)

School of Science and Technology (SIST), ShanghaiTech University

Shanghai Institute of Semiconductor Innovation (SISI)

Lab 4

Lab 4 · README · SISI environment · SIST environment

Lab4 Environment Setup

Student entry · Required tasks · Bonus

This guide sets up the Chipyard/Gemmini environment for required Parts A/B/C. Part A does not need a completed B mesh or a RISC-V bare-metal program. The standalone Bonus checks need only completed Lab3 RTL and Verilator; see the Bonus guide for the supplied testbenches.

Use the assigned course environment and follow the shared environment guide (docs/environment.md) when selecting a compute node. Disk usage of a fully initialized Chipyard checkout is large; plan for several tens of GB.

1. Get Chipyard and switch to the pinned revision

The default checkout location is Lab4/chipyard, beside the Lab4 Makefile. Gemmini is the generators/gemmini submodule inside that worktree.

cd Lab4

# fresh clone (skip if the course already provides a checkout)
git clone https://github.com/ucb-bar/chipyard.git
cd chipyard

# switch to the revision the course pinned
git checkout e602d9

Lab4 pins Gemmini revision 8c3f992 inside that Chipyard worktree. The overlay checks enforce the pin:

cd ../            # back to Lab4/
make integration-check

make integration-check fails if generators/gemmini is not at 8c3f992. If you use a different Chipyard revision, fix the submodule pointer:

cd chipyard/generators/gemmini
git checkout 8c3f992

2. Initialize submodules recursively

Chipyard and Gemmini both nest submodules. Initialize them all from the Chipyard root:

cd Lab4/chipyard
git submodule update --init --recursive

This step downloads the RISC-V toolchain sources, Verilator, and the Gemmini software tests (software/gemmini-rocc-tests, which provides gemmini.h). The benchmark targets check for those headers and fail with a clear message if the submodule is missing.

A full ./build-setup.sh also works, but it is heavier than Lab4 needs; the steps below cover the pieces Lab4 actually uses.

3. Toolchain environment: Java, SBT, Verilator, RISC-V GCC

Source Chipyard's environment script from the Chipyard root. It exports the conda-based toolchain (Java, SBT, Verilator, RISC-V GCC, and friends) that the Lab4 Makefile expects:

cd Lab4/chipyard
source env.sh

Verify the tools are on PATH:

java -version          # JDK 11+ from the Chipyard conda env
sbt --version          # Scala Build Tool, used to compile Gemmini
verilator --version    # cycle-accurate simulator backend
riscv64-unknown-elf-gcc --version   # bare-metal RISC-V cross compiler

Notes:

  • The Lab4 Makefile derives JAVA_HOME from the java found on PATH and prepends its bin/ to PATH before invoking SBT, so activate the Chipyard environment before running make gemmini-compile or make benchmark.
  • If your site provides its own Verilator (Lab3 also needs one), a recent version on PATH is sufficient for the standalone checks; the Gemmini integration uses the Chipyard-provided one.
  • SBT downloads dependencies on first use. The Lab4 Makefile redirects all SBT/Coursier caches into Lab4/build/sbt/ so the course checkout stays clean; the first compile can take a long time.

4. Set CHIPYARD_HOME and GEMMINI_HOME

The Lab4 Makefile defaults match the layout above:

CHIPYARD_HOME = Lab4/chipyard                        (default)
GEMMINI_HOME  = $(CHIPYARD_HOME)/generators/gemmini (default)
CHIPYARD_ENV  = $(CHIPYARD_HOME)/env.sh             (default)
GEMMINI_TESTS = $(GEMMINI_HOME)/software/gemmini-rocc-tests (default)

If your Chipyard checkout lives elsewhere (for example a shared course checkout), override the variables on the command line:

make gemmini-test \
  CHIPYARD_HOME=/path/to/chipyard \
  GEMMINI_HOME=/path/to/chipyard/generators/gemmini \
  CHIPYARD_ENV=/path/to/chipyard/env.sh

make benchmark \
  CHIPYARD_HOME=/path/to/chipyard \
  GEMMINI_HOME=/path/to/chipyard/generators/gemmini \
  GEMMINI_TESTS=/path/to/chipyard/generators/gemmini/software/gemmini-rocc-tests \
  CHIPYARD_ENV=/path/to/chipyard/env.sh

CHIPYARD_ENV must point to an initialized Chipyard env.sh; a standalone Gemmini checkout is not enough for gemmini-test or the benchmark.

Benchmark logs and cleanup

With the default paths, benchmark logs are saved under Lab4/build/benchmark/. From Lab4/, parse a saved baseline log with:

make benchmark-parse LOG=build/benchmark/baseline.log

make clean removes Lab4/build/, including its SBT caches. The generated system simulator under chipyard/sims/verilator/ is retained.

Validate the setup

Continue with the Quick Start for the setup checks, A/B validation, and Part C run commands. Plain make runs scheduler-test. All hardware commands share gemmini-install, which verifies the pin and installs the overlay only if pristine; installed student changes are preserved. After changing files in student/, synchronize the installed copies as described in the Overlay guide. Test coverage and benchmark acceptance criteria are defined in TASKS.md.