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

Install Bender through Cargo for more solid toolchain buildflow #35

Merged
merged 2 commits into from
Feb 21, 2025
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
27 changes: 18 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ SW ?= $(RootDir)sw
BUILD_DIR ?= $(SW)/build
SIM_DIR ?= $(RootDir)vsim
QUESTA ?= questa-2023.4
BENDER_DIR ?= .
BENDER ?= bender
Bender ?= $(CargoInstallDir)/bin/bender
Gcc ?= $(GccInstallDir)/bin/
ISA ?= riscv
ARCH ?= rv
Expand Down Expand Up @@ -104,17 +103,12 @@ SHELL := /bin/bash
# Generate instructions and data stimuli
sw-build: $(STIM_INSTR) $(STIM_DATA) dis

# Download bender
bender:
curl --proto '=https' \
--tlsv1.2 https://pulp-platform.github.io/bender/init -sSf | sh -s -- 0.24.0

$(SIM_DIR):
mkdir -p $(SIM_DIR)

synth-ips:
$(BENDER) update
$(BENDER) script synopsys \
$(Bender) update
$(Bender) script synopsys \
$(common_targs) $(common_defs) \
$(synth_targs) $(synth_defs) \
> ${compile_script_synth}
Expand Down Expand Up @@ -156,6 +150,11 @@ VerilatorInstallDir := $(InstallDir)/verilator
GccInstallDir := $(InstallDir)/riscv
RiscvTarDir := riscv.tar.gz
GccUrl := https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2024.08.28/riscv32-elf-ubuntu-20.04-gcc-nightly-2024.08.28-nightly.tar.gz
# Bender
RustupInit := $(ScriptsDir)/rustup-init.sh
CargoInstallDir := $(InstallDir)/cargo
RustupInstallDir := $(InstallDir)/rustup
Cargo := $(CargoInstallDir)/bin/cargo

verilator: $(InstallDir)/bin/verilator

Expand All @@ -177,3 +176,13 @@ $(GccInstallDir):
cd $(VendorDir) && \
wget $(GccUrl) -O $(RiscvTarDir) && \
tar -xzvf $(RiscvTarDir) -C $(InstallDir) riscv

bender: $(CargoInstallDir)/bin/bender

$(CargoInstallDir)/bin/bender:
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf > $(RustupInit)
mkdir -p $(InstallDir)
export CARGO_HOME=$(CargoInstallDir) && export RUSTUP_HOME=$(RustupInstallDir) && \
chmod +x $(RustupInit); source $(RustupInit) -y && \
$(Cargo) install bender
rm -rf $(RustupInit)
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ The RedMulE Golden Model is intended to generate Floating-Point (FP) input and r
The golden model makes use of Python3.6 virtual environment, Numpy and Pytorch. These modules have
to be installed if they are not already present. To simplify this procedure, the `golden-model` folder
contains a `setup-py.sh` that can be sourced to install all these modules, and to export the
required environment variables. Thus, the first step is to move into the `golden-model` folder and run:
required environment variables. Thus, the first step is to install such python packages by running:
```bash
source golden-model/setup-py.sh
cd golden-model
source setup-py.sh
cd ..
```

This will install a Python3.6 virtual environment under the `venv` folder.
Expand Down
4 changes: 2 additions & 2 deletions target/sim/verilator/verilator.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ hw-clean:
rm -rf $(VerilatorAbsObjDir) $(VerilatorCompileScript) $(VerilatorWaves) $(VerilatorDir)/transcript

hw-script:
$(BENDER) update
$(BENDER) script $(target) \
$(Bender) update
$(Bender) script $(target) \
$(common_targs) $(common_defs) \
$(sim_targs) \
> $(VerilatorCompileScript)
Expand Down
4 changes: 2 additions & 2 deletions target/sim/vsim/vsim.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ hw-clean:
rm -rf $(VsimCompileScript) $(VsimDir)/transcript $(VsimDir)/modelsim.ini $(VsimDir)/*.wlf $(VsimDir)/work

hw-script:
$(BENDER) update
$(BENDER) script $(target) \
$(Bender) update
$(Bender) script $(target) \
--vlog-arg="$(CompileFlags)" \
--vcom-arg="-pedanticerrors" \
$(common_targs) $(common_defs) \
Expand Down