feat: add lab-rv32i-c-uart card
This commit is contained in:
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
prefix="${RISCV_PREFIX:-riscv64-unknown-elf-}"
|
||||
|
||||
make -C "$root" -s tasks
|
||||
for elf in "$root"/build/task*/prog.elf; do
|
||||
"$prefix"readelf -h "$elf" | grep -F 'RISC-V' >/dev/null
|
||||
"$prefix"nm -a "$elf" | grep -E ' task0[1-3]_debug_checkpoint$' >/dev/null
|
||||
done
|
||||
"$prefix"nm -a "$root/build/task02_uart_rx_interrupt/prog.elf" | \
|
||||
grep -E ' task02_uart_handler$' >/dev/null
|
||||
"$prefix"nm -a "$root/build/task03_uart_mailbox/prog.elf" | \
|
||||
grep -E ' task03_uart_handler$' >/dev/null
|
||||
printf 'PASS: RV32I ELF symbols and handlers\n'
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
source_json="$root/json/card_source.json"
|
||||
pdf="$root/doc/pdf/mpabi-inf-c-12-uart-polling-interrupts-v00.01-e766c4bb-2a43-5f4e-b10a-b3393a42932c.pdf"
|
||||
|
||||
jq -e '(.tasks | length) == 3 and
|
||||
([.tasks[].viewpoints | map(.id)] |
|
||||
all(. == ["A1","A2","A3","A4","A5","A6","A7","A8"]))' \
|
||||
"$source_json" >/dev/null
|
||||
node --check "$root/web/app.js"
|
||||
node -e 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' \
|
||||
"$root/web/card-data.json"
|
||||
qpdf --check "$pdf" >/dev/null
|
||||
[[ "$(pdftotext -layout "$pdf" - | grep -Eo 'BLOCK A[1-8]' | wc -l)" -eq 24 ]]
|
||||
[[ "$(pdftotext -layout "$pdf" - | awk 'BEGIN {RS="\f"} /BLOCK A[1-8]/ && !/TASK0[1-3]/ {n++} END {print n+0}')" -eq 0 ]]
|
||||
printf 'PASS: JSON, web and PDF contain 3 x A1-A8\n'
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
env_root="${RV_ENV_ROOT:-/home/user/dev/edu/rv32i-hazard3-student-env}"
|
||||
tb="${HAZARD3_TB:-$env_root/vendor/Hazard3/test/sim/tb_verilator/tb}"
|
||||
|
||||
test -x "$tb"
|
||||
make -C "$root" -s tasks "RV_ENV_ROOT=$env_root"
|
||||
|
||||
assert_words() {
|
||||
local output="$1"
|
||||
shift
|
||||
local actual expected
|
||||
mapfile -t actual < <(printf '%s\n' "$output" | grep -E '^[0-9a-f]{8}$')
|
||||
expected=("$@")
|
||||
[[ "${actual[*]}" == "${expected[*]}" ]] || {
|
||||
printf 'FAIL words\nexpected: %s\nactual: %s\n' \
|
||||
"${expected[*]}" "${actual[*]}" >&2
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
task1="$($tb --bin "$root/build/task01_uart_polling/prog.bin" --cycles 500000 --cpuret)"
|
||||
printf '%s\n' "$task1" | grep -F 'Exit code 0' >/dev/null
|
||||
printf '%s\n' "$task1" | grep -Fqx 'T'
|
||||
assert_words "$task1" c1201001 00000003 00000050 00000002 00000054 00000001
|
||||
printf 'PASS Task01 polling oracle\n'
|
||||
|
||||
task2="$($tb --bin "$root/build/task02_uart_rx_interrupt/prog.bin" --cycles 500000 --cpuret)"
|
||||
printf '%s\n' "$task2" | grep -F 'Exit code 0' >/dev/null
|
||||
assert_words "$task2" c1202002 00000001 00000001 00000010 00000013 00000052 00000000 00000001
|
||||
printf 'PASS Task02 IRQ oracle\n'
|
||||
|
||||
task3="$($tb --bin "$root/build/task03_uart_mailbox/prog.bin" --cycles 500000 --cpuret)"
|
||||
printf '%s\n' "$task3" | grep -F 'Exit code 0' >/dev/null
|
||||
assert_words "$task3" c1203003 00000003 00000002 00000001 00000041 00000043 00000000 00000001
|
||||
printf 'PASS Task03 mailbox oracle\n'
|
||||
Reference in New Issue
Block a user