Skip to content

arp_resolver: match case literal width to counter signal width#3

Open
UnsignedChad wants to merge 1 commit into
hamsternz:masterfrom
UnsignedChad:fix-arp-resolver-case-literal-width
Open

arp_resolver: match case literal width to counter signal width#3
UnsignedChad wants to merge 1 commit into
hamsternz:masterfrom
UnsignedChad:fix-arp-resolver-case-literal-width

Conversation

@UnsignedChad

@UnsignedChad UnsignedChad commented May 24, 2026

Copy link
Copy Markdown

Summary

In hdl/arp/arp_resolver.vhd, the case statement in the main process branches against unsigned(1 downto 0) (a 2-bit signal, declared at line 84) but the branch literals are 3 bits wide ("000", "001", "010"). Strict simulators (GHDL, NVC) reject this:

hdl/arp/arp_resolver.vhd:103:23:error: string length does not match
that of anonymous integer subtype defined at hdl/arp/arp_resolver.vhd:84:31
hdl/arp/arp_resolver.vhd:103:23:error: incorrect length for the choice value

Vivado / XST appear to accept it historically (likely silently truncating the leading zero), which is presumably why the bug hasn't surfaced in synthesis runs.

This PR shrinks the literals to 2 bits to match the signal type. Run-time behaviour is unchanged.

Test

Before:

$ ghdl -a --std=08 hdl/arp/arp_resolver.vhd
... 6 errors related to case literal width

After:

$ ghdl -a --std=08 hdl/arp/arp_resolver.vhd
(case-literal errors gone; the remaining errors in this file are
 unrelated missing-declaration issues for arp_lookup_mac,
 arp_lookup_valid, arp_request, etc. — pre-existing and outside
 the scope of this PR.)

Note

This patch was identified while exercising the project through a third-party VHDL → WebAssembly pipeline. The diagnosis and minimal fix were AI-assisted (large-language-model code review) and verified manually before submission.

The case statement in the main process compares against an unsigned(1
downto 0) signal — i.e. a 2-bit value — but the branches use 3-bit
string literals ('000', '001', '010'). GHDL rejects this with:

    error: string length does not match that of anonymous integer
           subtype defined at arp_resolver.vhd:84:31
    error: incorrect length for the choice value

Vivado/XST accepted it historically (likely silently truncating the
extra leading zero), which is presumably why the bug hasn't surfaced
in synthesis runs.  Strict simulators (GHDL, NVC) refuse.

The fix shrinks the literals to 2 bits to match the signal type.
Behaviour is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant