Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proc_prune: do not promote partially redundant assignments. #2458

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jfng
Copy link
Contributor

@jfng jfng commented Nov 28, 2020

According to #2035 (comment), the bug in #2035 requires intrusive changes to write_verilog to be properly fixed.

In the meantime, this PR proposes a workaround to proc_prune to avoid emitting the incriminated corner-case.

The source of the bug would still need to be fixed, but e.g. nMigen users will be able to use proc -nomux without hitting it.

Before this commit, in a process like:
  process $group_0
    assign $o 2'00
    attribute \full_case 1
    switch \x
      case 1'1
        assign $o [0] 1'1
      case
        assign $o [0] 1'0
    end
  end
"assign $o 2'00" would be promoted to "connect $o [1] 1'0".

Mixing assign and connect statements to different bits of the same
signal results in incorrect codegen from the write_verilog backend.

After this commit, "assign $o 2'00" is pruned to "assign $o [1] 1'0"
as a workaround.
@whitequark
Copy link
Member

Thanks for spearheading this! I don't like the idea of this change very much (and I assume neither do you); the coupling of proc passes with write_verilog really shouldn't be a thing. Furthermore, historically proc_prune has been a source of pretty obscure bugs, so I will be cautious when merging this.

My plan is to review this PR carefully and at the same time decide on the feasibility of a more tractable workaround in write_verilog (I have some ideas). Either way this issue will be solved.

@whitequark
Copy link
Member

@jfng By any chance, did #2964 improve this?

@mwkmwkmwk
Copy link
Member

@jfng By any chance, did #2964 improve this?

Nope, no change in behavior here. This can only be fixed properly on the Verilog backend side, I'm afraid. I have some vague hack ideas for proc_prune, but they all seem harder than just fixing the backend by adding an intermediate wire when different bits of an RTLIL wire have differing wire/reg requirements.

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.

3 participants