From bf4a46ccb3b37517f62ac451cf4535630fee365d Mon Sep 17 00:00:00 2001 From: Amelia Cuss Date: Sun, 18 Feb 2024 01:30:28 +1100 Subject: [PATCH] proc_rom: don't assert on big actionless switch. See the test case. PROC_ROM will consider this for evaluation, even though -- without any actions -- lhs is empty (but still "uniform"). A zero-width memory is constructed, which later fails check with: ERROR: Assert `width != 0' failed in kernel/mem.cc:518. Ensure we don't proceed if there's nothing to encode. --- passes/proc/proc_rom.cc | 5 +++++ tests/proc/proc_rom.ys | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/passes/proc/proc_rom.cc b/passes/proc/proc_rom.cc index b83466ce7..ebc2377aa 100644 --- a/passes/proc/proc_rom.cc +++ b/passes/proc/proc_rom.cc @@ -66,6 +66,11 @@ struct RomWorker } } + if (lhs.empty()) { + log_debug("rejecting switch: lhs empty\n"); + return; + } + int swsigbits = 0; for (int i = 0; i < GetSize(sw->signal); i++) if (sw->signal[i] != State::S0) diff --git a/tests/proc/proc_rom.ys b/tests/proc/proc_rom.ys index 0ef2e2c61..93fd5002b 100644 --- a/tests/proc/proc_rom.ys +++ b/tests/proc/proc_rom.ys @@ -186,4 +186,27 @@ design -stash preopt equiv_opt -assert -run prepare: dummy +design -reset +read_ilang <