Skip to content

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

@leonardt

Description

@leonardt

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.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions