Single port SRAM read -> write path causes a getSplitArray assertion failure

Open
#145 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@ngc7331 is already working on this.

Since Oct 28, 2026.

  • #146 by @ngc7331 — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
20/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp, scala
Domain
compilers

Research direction

The assertion fires in getSplitArray in src/splitArray.cpp at line 115, so start there and see how read-port data is split when a read and write share one port. Run gsim on the minimal.fir reproducer from the issue to confirm the failure. Done means it compiles without the assertion and matches Verilator's output. A fix is already open as PR #146, so check that before starting.

Written by the indexing model from the issue text.

Description

Before start
  • I confirm that this is a bug of GSIM, rather than a usage problem or other types of problems. 我确认这是一个 GSIM 的 bug,而不是使用上的问题或者其他类型的问题。
  • I have searched the previous issues and did not find anything relevant. 我已经搜索过之前的 issue,并没有找到相关的。
  • I have reviewed the commit messages from the relevant commit history. 我已经浏览过相关的提交历史和提交信息。
  • I have reproduced the incorrect behaviors using the latest commit on the corresponding branch. 我已经使用相应分支最新的 commit 复现了不正确的行为。
Branch

master

Describe the bug

A pure-combinational path between the r/w port of one SRAM like this:

// read sram in s0
sram.io.r.req.valid := s0_valid

// get sram result, do some computation in s1
val s1_rdata = sram.io.r.resp.bits.data
val s1_wdata = s1_rdata + 1.U

// then write back, still in s1
sram.io.w.req.valid := s1_valid && !s0_valid // drop if there is a new request, to prevent r-w conflict
sram.io.w.req.bits.data := s1_wdata

will result in:

Should Not Reach Here!
current sram$array$RW0$$wdata 1/2
  missing sram$wdata
...
current sram$rdataReg$NEXT 1/2
  missing sram$array$RW0$$rdata
gsim: src/splitArray.cpp:115: Node *getSplitArray(graph *): Assertion `0' failed.

A minimal .fir reproducer will be like:

    smem mem : UInt<8>[4]
    node wdata = xor(rdata, UInt<8>(0h1))
    when en :
      rdwr mport p = mem[addr], clock
      when write :
        connect p, wdata
    connect rdata, p

which gives a similar failure:

Should Not Reach Here!
current p 4/5
  missing wdata
gsim: src/splitArray.cpp:115: Node *getSplitArray(graph *): Assertion `0' failed.
Expected behavior

Should compile normally, as verilator does.

Environment
$ gsim --version
GSIM master-2026-10-26-cd08a32
Build Date: 2026-10-27T07:47:12Z
Build CXX: Ubuntu clang version 19.1.1 (1ubuntu1~24.04.2)
To Reproduce

Pipeline:

Minimal .fir: minimal.fir

Additional context

AI disclosure: the minimal .fir reproducer is generated by GPT 6.1 Sol

Dominant language
C++
Stars
93
Forks
16
Avg merge
2d 7h
Merged PRs (30d)
11

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from OpenXiangShan/gsim

All issues in OpenXiangShan/gsim

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.