Files
lab-rv32i-asm-alu/tools/card-action.sh
T

17 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
action="${1:?action is required}"; root="${STEM_REPO:-$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)}"
profile="${STEM_PROFILE:-native-amd64}"; target="${STEM_TARGET:-native}"; selector="${STEM_TASK:-task1}"
state="${STEM_STATE_DIR:-$root/.stem/instances/local}"
tasks=(task01_alu_core task02_verilog_assembler task03_execute_stage)
resolve_task() { local value="${1,,}" stem; for stem in "${tasks[@]}"; do [[ "$value" == "$stem" ]] && { printf '%s\n' "$stem"; return; }; done; [[ "$value" =~ ^(task|t)?[-_]?0*([1-3])($|[-_].*) ]] && { printf '%s\n' "${tasks[${BASH_REMATCH[2]} - 1]}"; return; }; printf 'Unknown task selector: %s\n' "$1" >&2; exit 2; }
task="$(resolve_task "$selector")"; artifact_dir="$root/.stem/artifacts/$profile/$target/$task"; mkdir -p "$state" "$artifact_dir"
case "$profile:$target:$action" in
native-amd64:native:build) python3 -m py_compile "$root/tests/reference_model.py"; cp -f "$root/src/tasks/$task.sv" "$artifact_dir/" ;;
native-amd64:native:test|native-amd64:native:run) exec python3 "$root/tests/reference_model.py" "$task" ;;
hazard3-sim:hazard3-baremetal:build) exec "$root/tests/test_rtl.sh" --build-only "$task" ;;
hazard3-sim:hazard3-baremetal:test|hazard3-sim:hazard3-baremetal:run) exec "$root/tests/test_rtl.sh" "$task" ;;
hazard3-sim:hazard3-baremetal:debug) exec "$root/tests/test_rtl.sh" --trace "$task" ;;
*) printf 'Unsupported profile/target/action: %s/%s/%s\n' "$profile" "$target" "$action" >&2; exit 2 ;;
esac