llvm / llvm/circt

[ImportVerilog] Streaming operators fail on unpacked arrays

Open
#11,028 6 comments 0 reactions 0 assignees View on GitHub
good first issue ImportVerilog
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

Streaming concatenation operators (`{>>{...}}`, `{<<{...}}`) need to convert non-packed, fixed-size aggregates (unpacked arrays, unpacked structs) to and from a flat packed bit vector, and ImportVerilog has no such conversion, so any streaming operand that isn't already a plain packed type fails to import. This bug used to be hidden by the `moore.conversion` op that pretended to convert an unpacked array to a dense bit vector. That op no longer exists after #11024.

```systemverilog
module Streaming;
logic [15:0] vec_3;
logic [31:0] vec_1;
logic arr_1 [63:0];

initial begin
vec_1 = {<' to '!moore.l16'
```

Per IEEE 1800-2017 §11.4.14, streaming braces accept packed types, strings, unpacked arrays (fixed-size, dynamic, and queues), unpacked structs/unions, and class handles (source-only); `with [..]` part-select is further restricted to fixed-size unpacked arrays, dynamic arrays, and queues.

`Context::materializeConversion` in ImportVerilog needs a conversion path for fixed-size aggregates, gated on both sides having equal, statically-known `UnpackedType::getBitSize()`. `moore.conversion`'s existing MooreToCore lowering already does a width-checked bitcast for such pairs, so this is mostly a frontend-side gap. Queues, dynamic arrays, and associative arrays should stay unsupported since they have no static width to bitcast against.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Context::materializeConversion in ImportVerilog and inspect the existing moore.conversion MooreToCore lowering for its width-checked bitcast behavior. Reproduce the provided streaming-array example, then verify that fixed-size aggregates with equal statically known bit sizes convert while queues, dynamic arrays, and associative arrays remain unsupported.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.