llvm / llvm/circt

[circt-verilog] 'moore.case_eq' operand must be simple bit vector type, but got array

Open
#8,844 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I ran `circt-verilog` on this file from OpenTitan:
https://github.com/lowRISC/opentitan/blob/d8b5efd1427152b8387d6e03d9db413167e58475/hw/ip/lc_ctrl/rtl/lc_ctrl_fsm.sv

I got this error:

```bash
ak2518@autobot:/local/scratch/ak2518/opentitan$ /local/scratch/ak2518/circt/build/bin/circt-verilog --debug --parse-only /local/scratch/ak2518/opentitan/hw/ip/lc_ctrl/rtl/lc_ctrl_fsm.sv -yhw/ip/prim_generic/rtl -yhw/ip/prim/rtl -yhw/ip/lc_ctrl/rtl -yhw/ip/rom_ctrl/rtl -Ihw/ip/prim/rtl -yhw/ip/prim_generic/rtl -DYOSYS -DSYNTHESIS --mlir-print-ir-after-failure --verbose-pass-executions --mlir-pass-statistics
Args: /local/scratch/ak2518/circt/build/bin/circt-verilog --debug --parse-only /local/scratch/ak2518/opentitan/hw/ip/lc_ctrl/rtl/lc_ctrl_fsm.sv -yhw/ip/prim_generic/rtl -yhw/ip/prim/rtl -yhw/ip/lc_ctrl/rtl -yhw/ip/rom_ctrl/rtl -Ihw/ip/prim/rtl -yhw/ip/prim_generic/rtl -DYOSYS -DSYNTHESIS --mlir-print-ir-after-failure --verbose-pass-executions --mlir-pass-statistics
Load new dialect in Context builtin
Load new dialect in Context moore
Load new dialect in Context hw
Load new dialect in Context cf
Load new dialect in Context arith
Load new dialect in Context func
Load new dialect in Context verif
Load new dialect in Context seq
Load new dialect in Context ltl
Load new dialect in Context comb
Load new dialect in Context dbg
-:148:13: error: 'moore.case_eq' op operand #0 must be simple bit vector type, but got '!moore.array<6 x l5>'
-:148:13: note: see current operation: %243 = "moore.case_eq"(%239, %242) : (!moore.array<6 x l5>, !moore.l30) -> !moore.i1
ak2518@autobot:/local/scratch/ak2518/opentitan$
```

I'm not sure what this error means. I don't know how to debug/inspect the intermediate representation before the error happens. It would be useful if I could see what construct in the original SystemVerilog caused this line in the MLIR.

version:

```bash
ak2518@autobot:/local/scratch/ak2518/opentitan$ /local/scratch/ak2518/circt/build/bin/circt-verilog --version
LLVM (http://llvm.org/):
LLVM version 22.0.0git
DEBUG build with assertions.
CIRCT 55f12edd1
slang version 9.0.0+54385bb
```

Through trial-and-error, I've realised that this is caused by lines 148-203 in `lc_ctrl_state_transition.sv`
https://github.com/lowRISC/opentitan/blob/d8b5efd1427152b8387d6e03d9db413167e58475/hw/ip/lc_ctrl/rtl/lc_ctrl_state_transition.sv#L148-L203

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 provided circt-verilog command and the OpenTitan lc_ctrl_state_transition.sv lines 148-203. Start by tracing how that SystemVerilog construct becomes the moore.case_eq operation and inspect available diagnostic or source-location handling. Done means the failure identifies the originating construct or provides a useful way to inspect the preceding IR.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.