llvm / llvm/circt

[FIRRTL] some zero-width types fail ExportToVerilog pass w/ out optimizations

Open
#11,091 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

When certain zero-width types exist but optimizations are disabled, the passes that are meant to remove them do not seem to run, causing a failure when exporting to verilog. Based on my testing, this seems to only happen with nested arrays of length zero? But I'll look more into it tomorrow and see if I can figure out a fix.

```firrtl
FIRRTL version 4.0.0
circuit Top:
public module Top:
output size: UInt<32>
wire empty: {nested: UInt<1>[0]} ; (FAILS)
; wire empty: UInt<0>[2] ; (WORKS)
; wire empty: UInt<1>[0] ; (WORKS)
; wire empty: {nested: UInt<0>} ; (WORKS)
invalidate empty
node sizeNode = intrinsic(circt_sizeof : UInt<32>, empty)
connect size, sizeNode
```

```
Assertion failed: (!isZeroBitType(op.getType()) && "zero-bit types not allowed at this point"), function visitTypeOp, file ExportVerilog.cpp, line 3133.
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the FIRRTL 4.0.0 snippet and optimizations disabled. Start at ExportVerilog.cpp line 3133 and trace the zero-width-type removal passes for nested zero-length arrays. Done means the example exports to Verilog without the assertion while the existing working cases remain valid.

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
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.