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

Legalizer for Part misses one branch #52

Closed
rroohhh opened this issue Mar 26, 2019 · 1 comment
Closed

Legalizer for Part misses one branch #52

rroohhh opened this issue Mar 26, 2019 · 1 comment
Labels
Milestone

Comments

@rroohhh
Copy link
Contributor

rroohhh commented Mar 26, 2019

Shouldn't this line read:

raise LegalizeValue(value.offset, range(1 << len(value.offset)))

Currently this:

from nmigen import *
from nmigen.cli import main

m = Module()

p = Signal(4, reset=0b11)
a = Signal(1, reset = 1)

m.d.sync += p.part(a, 1).eq(0)

if __name__ == "__main__":
    main(m)

just generates one assignment:

/* Generated by Yosys 0.8+152 (git sha1 2a8e5bf9, gcc 8.2.0-r6 -fPIC -O3) */

(* top =  1  *)
(* generator = "nMigen" *)
module top(rst, clk, a);
  (* src = "cdc.py:6" *)
  reg [3:0] \$next\p ;
  (* src = "cdc.py:7" *)
  input a;
  (* src = "/home/robin/.local/lib/python3.7/site-packages/nmigen/hdl/ir.py:304" *)
  input clk;
  (* init = 4'h3 *)
  (* src = "cdc.py:6" *)
  reg [3:0] p = 4'h3;
  (* src = "/home/robin/.local/lib/python3.7/site-packages/nmigen/hdl/ir.py:304" *)
  input rst;
  always @(posedge clk)
      p <= \$next\p ;
  always @* begin
    \$next\p  = p;
    casez (a)
      1'hz:
          \$next\p [0] = 1'h0;
    endcase
    casez (rst)
      1'h1:
          \$next\p  = 4'h3;
    endcase
  end
endmodule

which does not seem equivalent to the described logic.

@whitequark
Copy link
Contributor

You're right! Good catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants