igneum/tools/chip-model/rtl/Makefile

83 lines
3.9 KiB
Makefile

# Shadow-k floor lane: RTL -> ASAP7 (Yosys + OpenROAD, the ORFS docker image) -> pJ per op from a
# random-input gate-level simulation. Reproduces every row of docs/analysis/class-v6/floor/shadow-k.md.
#
# make row-arx synthesise, place, route, simulate and report one family
# make rows every family (serially; use -j for parallel on the box)
# make table collect every power log into table.md and table.csv
#
# Runs on build-4 or build-3 (docker, the build user in the docker group). Never on the Mac.
# Images: openroad/orfs:latest (yosys 0.68, OpenROAD) and orfs-sim:latest (the same plus iverilog,
# built once with: docker run --name b -u root openroad/orfs:latest bash -c 'apt-get update && apt-get install -y iverilog' && docker commit b orfs-sim:latest).
WORK ?= $(abspath .)
ORFS_IMG ?= openroad/orfs:latest
SIM_IMG ?= orfs-sim:latest
UID_GID := $(shell id -u):$(shell id -g)
# Every run on a box goes through the lease tool (the coordinator's rule, 8 October 2026): THREADS cores from the
# bounded pool at nice 19; the docker container is pinned to the leased set and ORFS gets NUM_CORES=THREADS.
THREADS ?= 24
LEASE ?= /srv/builds/_bin/lease
LEASE_ON ?= $(shell test -x $(LEASE) && echo 1)
LEASEPFX = $(if $(LEASE_ON),$(LEASE) pool $(THREADS) --label "floor-k shadow-k" --owner floor-k --nice 19 --,)
CPUSET = $(if $(LEASE_ON),--cpuset-cpus {cpuset},)
DOCKER := $(LEASEPFX) docker run --rm -u $(UID_GID) -e HOME=/tmp -e NUM_CORES=$(THREADS) $(CPUSET) -v $(WORK):/work
ORFS := $(DOCKER) -w /OpenROAD-flow-scripts/flow $(ORFS_IMG)
SIM := $(DOCKER) -w /work $(SIM_IMG)
DESIGNS := arx mul prmt lop3 fold shfl xbar scratch tile core8 core32 core32r16 core8r64 core8i1k core8sel core32all
top = $(shell sed -n 's/^$(1) \([^ ]*\) .*/\1/p' flow/designs.txt)
# per-family simulation tags (the op field fixed per row where the family has several ops)
SIMS_arx := mix add:+op=0 sub:+op=1 xor:+op=2 or:+op=3 rotl:+op=4 rotr:+op=5
SIMS_mul := mix mul:+op=0 mulhi:+op=1 mad:+op=2
SIMS_prmt := mix
SIMS_lop3 := mix
SIMS_fold := mix
SIMS_shfl := mix
SIMS_xbar := mix
SIMS_scratch := mix
SIMS_tile := mix
SIMS_core8 := mix mixld:+loads=1
SIMS_core32 := mix mixld:+loads=1
SIMS_core32r16 := mix mixld:+loads=1
SIMS_core8r64 := mix
SIMS_core8i1k := mix
SIMS_core8sel := mix
SIMS_core32all := mix
.PHONY: rows table clean
rows: $(addprefix row-,$(DESIGNS))
row-%: power-%
@echo "row $* done: $(WORK)/out/$*/logs/asap7/$*/base/power.log"
flow-%:
mkdir -p out/$* logs
$(ORFS) make DESIGN_CONFIG=/work/flow/$*.mk 2>&1 | tee logs/flow-$*.log
test -f out/$*/results/asap7/$*/base/6_final.v
sim-%: flow-%
mkdir -p sim/$*
$(SIM) bash /work/flow/gl2sim.sh $* $(call top,$*) 2>&1 | tee logs/gl2sim-$*.log
for t in $(SIMS_$*); do tag=$${t%%:*}; args=$${t#*:}; [ "$$args" = "$$t" ] && args=""; \
$(SIM) bash /work/flow/sim.sh $* $$tag $$args 2>&1 | tee logs/sim-$*-$$tag.log; done
power-%: sim-%
$(ORFS) make DESIGN_CONFIG=/work/flow/$*.mk RUN_SCRIPT=/work/flow/power.tcl RUN_LOG_NAME_STEM=power run 2>&1 | tee logs/power-$*.log
# synthesis-only row (no placement, no parasitics): the 14:45 fallback
synth-%:
mkdir -p out/$* logs sim/$*-synth
$(ORFS) make DESIGN_CONFIG=/work/flow/$*.mk synth 2>&1 | tee logs/synth-$*.log
NET=1_2_yosys.v $(SIM) bash -c 'NET=1_2_yosys.v bash /work/flow/gl2sim.sh $* $(call top,$*)' 2>&1 | tee logs/gl2sim-$*-synth.log
$(SIM) bash /work/flow/sim.sh $* s150 +cycles=150 2>&1 | tee logs/sim-$*-s150.log
$(SIM) bash /work/flow/sim.sh $* s600 +cycles=600 2>&1 | tee logs/sim-$*-s600.log
$(ORFS) make DESIGN_CONFIG=/work/flow/$*.mk RUN_SCRIPT=/work/flow/power.tcl RUN_LOG_NAME_STEM=power_synth FLOORK_ODB=1_synth.odb FLOORK_SDC=1_synth.sdc run 2>&1 | tee logs/power-$*-synth.log
table:
python3 flow/collect.py $(WORK) > table.md
@echo wrote table.md and table.csv
clean:
rm -rf out sim logs table.md table.csv