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

chained comparisons are not implemented correctly #108

Open
whitequark opened this issue May 13, 2018 · 1 comment
Open

chained comparisons are not implemented correctly #108

whitequark opened this issue May 13, 2018 · 1 comment

Comments

@whitequark
Copy link
Contributor

These should be identical, and indeed they are in Python:

class OK(Module):
    def __init__(self):
        self.a = Signal(8)
        self.b = Signal(8)
        self.c = Signal()
        self.comb += \
            self.c.eq((self.a == 0) & (self.b == 0))

class NG(Module):
    def __init__(self):
        self.a = Signal(8)
        self.b = Signal(8)
        self.c = Signal()
        self.comb += \
            self.c.eq(self.a == self.b == 0)

print(verilog.convert(OK())) # assign c = ((a == 1'd0) & (b == 1'd0));
print(verilog.convert(NG())) # assign c = (a == b);

a = b = 0
print(a == b == 0) # True
a = b = 1
print(a == b == 0) # False
@whitequark
Copy link
Contributor Author

Triage: fixed in nMigen, where a chained comparison is an error (throws TypeError: Attempted to convert nMigen value to boolean).

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

No branches or pull requests

1 participant