#!/bin/sh # SPDX-License-Identifier: Apache-2.0 # Replays the model's session against the logic in an open-source simulator (Icarus Verilog), the # EMIO testbench and the AXI testbench, and fails on any mismatch. Needs iverilog and a Rust # toolchain. The vendor's simulator takes the same files: the testbenches open landscape_tb.script # and landscape_axi_tb.script in the directory they run in, so write those there with gen-tb and run # xvlog rtl/landscape_core.v rtl/landscape_axi.v tb/tb_landscape_axi.v && xelab tb -s tbs && xsim tbs -R # sh scripts/run_tb.sh [emio|axi|both] set -e WHICH=${1:-both} HERE=$(cd "$(dirname "$0")/.." && pwd) OUT=$(mktemp -d) trap 'rm -rf "$OUT"' EXIT cd "$HERE" cargo build --locked --release BIN=${CARGO_TARGET_DIR:-target}/release/wai-quantum-landscape-fpga replay() { # name script gen-flag sources... name=$1; script=$2; flag=$3; shift 3 "$BIN" gen-tb "$OUT/$script" $flag iverilog -g2012 -o "$OUT/$name.vvp" "$@" (cd "$OUT" && vvp "$name.vvp") | tee "$OUT/$name.log" | tail -3 grep -qE '^TB DONE: [0-9]+ lines, [0-9]+ checked reads, 0 mismatches' "$OUT/$name.log" || { echo "$name: the replay did not finish clean" >&2; exit 1; } } case "$WHICH" in emio|both) replay emio landscape_tb.script "" rtl/landscape_core.v rtl/landscape_port.v tb/tb_landscape.v ;; esac case "$WHICH" in axi|both) replay axi landscape_axi_tb.script --axi rtl/landscape_core.v rtl/landscape_axi.v tb/tb_landscape_axi.v ;; esac