| #!/bin/bash |
| # |
| # Copyright 2023 Google LLC |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| # Run verilator testbench simulation. |
| |
| if [[ $# -lt 5 || $1 == "--help" ]]; then |
| echo "Usage: run-chip-verilator-sim.sh <verilator testbench> <rom binary> <flash binary> <otp binary> <smc binary> [ml binary] [OPTIONS]" |
| exit 0 |
| fi |
| |
| VCHIP_TB=$1 |
| ROM_BIN=$2 |
| FLASH_BIN=$3 |
| OTP_BIN=$4 |
| RAM_SMC_BIN=$5 |
| |
| if [[ $# == 5 ]]; then |
| shift 5 |
| elif [[ $6 == "--"* ]]; then |
| shift 5 |
| else |
| ML_DMEM_BIN=$6 |
| shift 6 |
| fi |
| |
| if [[ ! -f $(realpath ${VCHIP_TB}) ]]; then |
| echo "Verilator testbench not found. Please make sure //hw:verilator is in data." |
| exit 1 |
| fi |
| |
| if [[ ! -f $(realpath ${ROM_BIN}) ]] || [[ ! -f $(realpath ${FLASH_BIN}) ]] || |
| [[ ! -f $(realpath ${OTP_BIN}) ]] || [[ ! -f $(realpath ${RAM_SMC_BIN}) ]]; then |
| echo "Software binaries not found. Please make sure the targets are in data and args." |
| exit 1 |
| fi |
| if [[ ! -z "${ML_DMEM_BIN}" ]] && [[ ! -f $(realpath ${ML_DMEM_BIN}) ]]; then |
| echo "Kelvin binary not found. Please make sure the targets are in data and args." |
| exit 1 |
| fi |
| |
| OPTIONAL_BINS="" |
| if [[ ! -z "${ML_DMEM_BIN}" ]]; then |
| OPTIONAL_BINS+="--meminit=ml_dmem,${ML_DMEM_BIN} " |
| fi |
| |
| ${VCHIP_TB} \ |
| "--meminit=rom,${ROM_BIN}" \ |
| "--meminit=flash,${FLASH_BIN}" \ |
| "--meminit=otp,${OTP_BIN}" \ |
| "--meminit=ram_smc,${RAM_SMC_BIN}" \ |
| ${OPTIONAL_BINS} $@ |