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

Magma should raise an error when an operator with an integer requires truncation #969

Closed
leonardt opened this issue Jun 10, 2021 · 0 comments · Fixed by #971
Closed

Magma should raise an error when an operator with an integer requires truncation #969

leonardt opened this issue Jun 10, 2021 · 0 comments · Fixed by #971
Assignees
Labels
Milestone

Comments

@leonardt
Copy link
Collaborator

Here's an example:

import magma as m


class Foo(m.Circuit):
    io = m.IO(x=m.In(m.Bits[2]), y=m.Out(m.Bits[2]))
    io.y @= io.x & 4


m.compile("build/Foo", Foo, inline=True)

This produces

module Foo (
    input [1:0] x,
    output [1:0] y
);
assign y = x & 2'h0;
endmodule

Rather than implicitly truncating the integer value, we should raise and error and force the user to acknowledge that the value will be truncated by doing the truncation themselves.

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

Successfully merging a pull request may close this issue.

1 participant