diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index fa6705f..58c0781 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -41,7 +41,7 @@ jobs: - macOS-11 needs: build env: - IVERILOG_REF: 7c5694e5163e905b7ba85096ae67e5f28862db48 + IVERILOG_REF: eab37efb561259df7e27aa26f080a7b0f2ca48a1 steps: - uses: actions/checkout@v1 - name: Install Dependencies (macOS) diff --git a/README.md b/README.md index 4b464d1..fa445ae 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ All of sv2v's dependencies are free and open-source. * [Icarus Verilog](https://steveicarus.github.io/iverilog/) - for Verilog simulation * [shUnit2](https://github.com/kward/shunit2) - test framework - * Python (any version) - for generating certain test cases + * Python 3.x - for evaluating certain test cases ## Installation diff --git a/test/lib/clean_vcd.py b/test/lib/clean_vcd.py new file mode 100755 index 0000000..c23b7c3 --- /dev/null +++ b/test/lib/clean_vcd.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +import sys + +from collections import deque + +if __name__ == "__main__": + pending = deque() + replaced = {} + dumping = False + + for line in sys.stdin: + # Find and drop dumped parameters. + if line.startswith("$var "): + parts = line.split() + should_drop = parts[1] == "parameter" + if not should_drop and not pending: + print(line, end="") + continue + ident_old = parts[3] + pending.append(ident_old) + if should_drop: + replaced[ident_old] = None + continue + ident_new = pending.popleft() + parts[3] = ident_new + replaced[ident_old] = ident_new + print(" ".join(parts)) + + # Pass through lines if we have no transformations to do. + elif line.startswith("$dump"): + dumping = True + print(line, end="") + elif line.startswith("$end"): + # dumping = False + print(line, end="") + elif not dumping or not replaced: + print(line, end="") + elif line[0] == "#": + print(line, end="") + + # Rename dumped variables. + elif line.startswith("b"): + value, ident = line.split() + ident = replaced.get(ident, ident) + if ident is not None: + print(value, ident) + elif line[0] in "01xz": + value = line[0] + ident = line[1:-1] + ident = replaced.get(ident, ident) + if ident is not None: + print(value + ident) + + else: + raise RuntimeError(f"Unhandled: {line.strip()}") diff --git a/test/lib/functions.sh b/test/lib/functions.sh index c37f63d..0322e5e 100644 --- a/test/lib/functions.sh +++ b/test/lib/functions.sh @@ -36,7 +36,7 @@ simulate() { $sim_prog > $sim_log assertTrue "simulating $1 failed" $? # remove the date from the VCD - sed -e "1,3d" < $sim_vcd_tmp > $sim_vcd + sed -e "1,3d" < $sim_vcd_tmp | $SCRIPT_DIR/clean_vcd.py > $sim_vcd } assertConverts() { diff --git a/test/number/run.sh b/test/number/run.sh index 0c5e0cf..7ba4a4b 100755 --- a/test/number/run.sh +++ b/test/number/run.sh @@ -1,7 +1,6 @@ #!/bin/bash -py=$(which python3 || which python) -$py gen.py 4 b 2 01xz > binary.sv -$py gen.py 2 o 8 01234567xz > octal.sv -$py gen.py 2 d 10 0123456789 > decimal.sv -$py gen.py 2 h 16 0123456789abcdefxz > hex.sv +python3 gen.py 4 b 2 01xz > binary.sv +python3 gen.py 2 o 8 01234567xz > octal.sv +python3 gen.py 2 d 10 0123456789 > decimal.sv +python3 gen.py 2 h 16 0123456789abcdefxz > hex.sv source ../lib/runner.sh