Skip to content

Commit

Permalink
Merge pull request #216 from micprog/bender_proper
Browse files Browse the repository at this point in the history
Add Bender support
  • Loading branch information
meggiman authored Feb 3, 2021
2 parents 95e0a71 + 505812b commit ab1a413
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ modelsim.ini
xcelium.d/
xrun.history
xrun.log
.bender
bender
Bender.lock
3 changes: 3 additions & 0 deletions Bender.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
overrides:
tech_cells_generic: { git: "https://github.com/pulp-platform/tech_cells_generic.git", version: 0.2.3 }
axi: { git: "https://github.com/pulp-platform/axi.git", version: 0.27.0 }
83 changes: 83 additions & 0 deletions Bender.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package:
name: Pulpissimo
authors:
- "Robert Balas <[email protected]>"
- "Pasquale Davide Schiavone <[email protected]>"
- "Germain Haugou <[email protected]>"
- "Francesco Conti <[email protected]>"
- "Pirmin Vogel <[email protected]>"
- "Stefan Mach <[email protected]>"
- "Antonio Pullini <[email protected]>"
- "Gianmarco Ottavi <[email protected]>"
- "Manuel Eggimann <[email protected]>"
- "Luca Valente <[email protected]>"

dependencies:
pulp_soc: { git: "https://github.com/pulp-platform/pulp_soc.git", version: 2.1.0 }
tbtools: { git: "https://github.com/pulp-platform/tbtools.git", version: 0.2.1 }

workspace:
# package_links:
# ips/tbtools: tbtools # symlinks for backwards compatibility with IPApprox
# checkout_dir: deps

export_include_dirs:
- rtl/includes

sources:
# Source files grouped in levels. Files in level 0 have no dependencies on files in this
# package. Files in level 1 only depend on files in level 0, files in level 2 on files in
# levels 1 and 0, etc. Files within a level are ordered alphabetically.
# Level 0
- rtl/pulpissimo/jtag_tap_top.sv
- rtl/pulpissimo/pad_frame.sv
- rtl/pulpissimo/pad_control.sv
- rtl/pulpissimo/soc_domain.sv
- rtl/pulpissimo/rtc_date.sv
- rtl/pulpissimo/rtc_clock.sv
- rtl/pulpissimo/safe_domain_reg_if.sv
# Level 1
- rtl/pulpissimo/safe_domain.sv
- rtl/pulpissimo/pulpissimo.sv

# TB sources
- target: any(test,simulation)
files:
- rtl/tb/riscv_pkg.sv
- rtl/tb/jtag_pkg.sv
- rtl/tb/pulp_tap_pkg.sv
- rtl/tb/tb_clk_gen.sv
- rtl/tb/tb_fs_handler.sv
- rtl/tb/dpi_models/dpi_models.sv
- rtl/tb/tb_driver/tb_driver.sv
- rtl/tb/tb_pulp.sv
- rtl/tb/SimJTAG.sv
- rtl/tb/SimDTM.sv

# Open models
- target: any(test,simulation)
files:
- rtl/vip/spi_master_padframe.sv
- rtl/vip/uart_tb_rx.sv
- rtl/vip/camera/cam_vip.sv

# S25FS256_model (SPI Flash)
- target: any(test,simulation)
defines:
SPEEDSIM: ~
files:
- rtl/vip/spi_flash/S25fs256s/model/s25fs256s.v

# 24FC1025 model (I2C flash)
- target: all(any(test,simulation), 24fc1025_vip)
defines:
SPEEDSIM: ~
files:
- rtl/vip/i2c_eeprom/24FC1025.v

# i2s model
- target: all(any(test,simulation), i2s_vip)
defines:
SPEEDSIM: ~
files:
- rtl/vip/spi_flash/S25fs256s/model/s25fs256s.v
50 changes: 47 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,56 @@ INSTALL_FILES += $(shell cd sim && find waves -type f)

$(foreach file, $(INSTALL_FILES), $(eval $(call declareInstallFile,$(file))))

BRANCH ?= master

VLOG_ARGS += -suppress 2583 -suppress 13314
BENDER_BUILD_DIR = sim

.PHONY: checkout
ifdef BENDER
checkout: bender
./bender update
else
checkout:
git submodule update --init
./update-ips
endif
$(MAKE) scripts

# generic clean and build targets for the platform
.PHONY: clean

## Remove the RTL model files
clean:
rm -rf $(VSIM_PATH)
cd sim && $(MAKE) clean
$(MAKE) -C sim BENDER=$(BENDER) clean

.PHONY: scripts
## Generate the scripts
ifdef BENDER
scripts: bender
echo 'set ROOT [file normalize [file dirname [info script]]/..]' > $(BENDER_BUILD_DIR)/compile.tcl
./bender script vsim \
--vlog-arg="$(VLOG_ARGS)" --vcom-arg="" \
-t rtl -t test \
| grep -v "set ROOT" >> $(BENDER_BUILD_DIR)/compile.tcl

else
scripts:
./generate-scripts
endif

.PHONY: build
## Build the RTL model for vsim
ifdef BENDER
build: bender
@test -f Bender.lock || { echo "ERROR: Bender.lock file does not exist. Did you run make checkout in bender mode?"; exit 1; }
cd sim && $(MAKE) BENDER=bender all
else
build:
@[ "$$(ls -A ips/)" ] || { echo "ERROR: ips/ is an empty directory. Did you run ./update-ips?"; exit 1; }
cd sim && $(MAKE) lib build opt
cd sim && $(MAKE) all
cp -r rtl/tb/* $(VSIM_PATH)
endif

.PHONY: build-incisive
## Build the RTL model for xsim
Expand Down Expand Up @@ -186,6 +218,18 @@ test-gitlab2:
source configs/rtl.sh; \
cd ../tests && plptest --threads 16 --stdout

# Bender integration
bender:
ifeq (,$(wildcard ./bender))
curl --proto '=https' --tlsv1.2 -sSf https://fabianschuiki.github.io/bender/init \
| bash -s -- 0.22.0
touch bender
endif

.PHONY: bender-rm
bender-rm:
rm -f bender

.PHONY: help
help: Makefile
@printf "PULP Platform\n"
Expand Down
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ source env/pulpissimo.sh
To build the RTL simulation platform, start by getting the latest version of the
IPs composing the PULP system:
```bash
./update-ips
make checkout
```
This will download all the required IPs, solve dependencies and generate the
scripts by calling `./generate-scripts`.
scripts. The default dependency management tool is IPApproX, where `./update-ips` and `./generate-scripts` are called. If the environment variable `BENDER` is set, bender is used as the dependency management tool.

After having access to the SDK, you can build the simulation platform by doing
the following:
Expand All @@ -165,7 +165,7 @@ external models for peripherals. See below (Proprietary verification IPs) for
details on how to plug in some models of real SPI, I2C, I2S peripherals.

For more advanced usage have a look at `./generate-scripts --help` and
`update-ips --help`.
`update-ips --help` for IPApproX, or `./bender --help` for bender.

Also check out the output of `make help` for more useful Makefile targets.

Expand Down Expand Up @@ -238,7 +238,8 @@ follow the section below to generate the bitstreams yourself.
### Bitstream Generation
In order to generate the PULPissimo bitstream for a supported target FPGA board
first generate the necessary synthesis include scripts by starting the
`update-ips` script in the pulpissimo root directory:
`update-ips` script in the pulpissimo root directory when using IPApproX (Bender
compatibility may not be available yet):

```Shell
./update-ips
Expand Down Expand Up @@ -516,8 +517,8 @@ repository is structured as follows:
e.g. SPI flash and camera.
- `rtl` could also contain other material (e.g. global includes, top-level
files)
- `ips` contains all IPs downloaded by `update-ips` script. Most of the actual
logic of the platform is located in these IPs.
- `ips` contains all IPs downloaded by `update-ips` script when using IPApproX.
Most of the actual logic of the platform is located in these IPs.
- `sim` contains the ModelSim/QuestaSim simulation platform.
- `pulp-sdk` contains the PULP software development kit; `pulp-sdk/tests`
contains all tests released with the SDK.
Expand All @@ -529,6 +530,13 @@ repository is structured as follows:
this file.
- `rtl_list.yml` contains the list of places where local RTL sources are found
(e.g. `rtl/tb`, `rtl/vip`).
- `Bender.yml` contains the package information used with bender. This includes
a list of IPs required and source files contained within this repository.
- When using bender, other files may be relevant: `Bender.local` contains
configs for bender, including overrides for dependencies, `Bender.lock` is a
generated file used by bender, `bender` is the bender executable fetched by
the makefile, `.bender` directory contains the database and checkouts used by
bender.

## Requirements
The RTL platform has the following requirements:
Expand All @@ -546,8 +554,8 @@ The PULP and PULPissimo platforms are highly hierarchical and the Git
repositories for the various IPs follow the hierarchy structure to keep maximum
flexibility.
Most of the complexity of the IP updating system are hidden behind the
`update-ips` and `generate-scripts` Python scripts; however, a few details are
important to know:
`update-ips` and `generate-scripts` Python scripts, or the bender software;
however, a few details are important to know:
- Do not assume that the `master` branch of an arbitrary IP is stable; many
internal IPs could include unstable changes at a certain point of their
history. Conversely, in top-level platforms (`pulpissimo`, `pulp`) we always
Expand All @@ -558,7 +566,8 @@ important to know:
GitHub. However, for development it is often easier to use SSH instead,
particularly if you want to push changes back.
To enable this, just replace `https://github.com` with `[email protected]` in the
`ipstools_cfg.py` configuration file in the root of this repository.
`ipstools_cfg.py` configuration file in the root of this repository for IPApproX.
Bender compatibility may not be perfect yet.

The tools used to collect IPs and create scripts for simulation have many
features that are not necessarily intended for the end user, but can be useful
Expand All @@ -574,7 +583,7 @@ The pull request will be evaluated and checked with our regression test suite
for possible integration.
If you want to replace our version of an IP with your GitHub fork, just add
`group: YOUR_GITHUB_NAMESPACE` to its entry in `ips_list.yml` or
`ips/pulp_soc/ips_list.yml`.
`ips/pulp_soc/ips_list.yml` when using IPApproX, or update the Bender.yml file.
While we are quite relaxed in terms of coding style, please try to follow these
recommendations:
https://github.com/pulp-platform/ariane/blob/master/CONTRIBUTING.md
Expand Down
29 changes: 26 additions & 3 deletions sim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

mkfile_path := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))

VSIM ?= vsim
VSIM_FLAGS = -gUSE_SDVT_SPI=0 -gUSE_SDVT_CPI=0 -gBAUDRATE=115200 \
VOPT ?= vopt
VSIM ?= vsim
VLIB ?= vlib
VMAP ?= vmap
VSIM_FLAGS = -gUSE_SDVT_SPI=0 -gUSE_SDVT_CPI=0 -gBAUDRATE=115200 \
-gENABLE_DEV_DPI=0 -gLOAD_L2=JTAG -gUSE_SDVT_I2S=0

SVLIB = ../rtl/tb/remote_bitbang/librbs

all: clean lib build opt
all: lib build opt

# build the bitbang library, needed for simulating a jtag bridge to OpenOCD
build-deps:
Expand All @@ -34,16 +37,36 @@ simc:
-do "quit -code [examine -radix decimal sim:/tb_pulp/exit_status]"

opt:
ifdef BENDER
$(VOPT) +acc=npr -o vopt_tb tb_pulp -floatparameters+tb_pulp -work work
else
$(mkfile_path)/tcl_files/rtl_vopt.tcl
endif

build: build-deps
ifdef BENDER
$(VSIM) -c -do 'source compile.tcl; quit'
else
@make --no-print-directory -f $(mkfile_path)/vcompile/ips.mk build
@make --no-print-directory -f $(mkfile_path)/vcompile/rtl.mk build
endif

lib:
ifdef BENDER
@$(VLIB) work
$(VMAP) work $(mkfile_path)/work
else
@make --no-print-directory -f $(mkfile_path)/vcompile/ips.mk lib
@make --no-print-directory -f $(mkfile_path)/vcompile/rtl.mk lib
endif

clean: clean-deps
ifdef BENDER
@mkdir -p work
rm -r work
else
@make --no-print-directory -f $(mkfile_path)/vcompile/ips.mk clean
@make --no-print-directory -f $(mkfile_path)/vcompile/rtl.mk clean
endif
@touch modelsim.ini
rm modelsim.ini
4 changes: 2 additions & 2 deletions update-ips
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ ipdb.update_ips()
# launch generate-ips.py
ipdb.save_database()

# pass arguments and call generate script
execute("./generate-scripts " + (' '.join(sys.argv[1:])))
# # pass arguments and call generate script
# execute("./generate-scripts " + (' '.join(sys.argv[1:])))

0 comments on commit ab1a413

Please sign in to comment.