-
Notifications
You must be signed in to change notification settings - Fork 174
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
Add Value.match(...), an operator with the same semantics as Case(...) #203
Comments
Comment by whitequark You can use this in
I don't think adding support for don't cares to |
Comment by RobertBaruch I used don't-cares in equality extensively in my formal verification for instructions. For example:
This is a fragment in a module which yields expected results for the instruction matching this pattern. It's possible that this is only supported by yosys. I know that it is not supported by Icarus Verilog (not even in |
Comment by whitequark Yes, but that's a single use case and it's in (nonstandard) Verilog. In my CPU, I took advantage of Python's abstraction features to avoid tying together the semantics of an instruction pattern (which bits are set) and the implementation of it (which nMigen code matches it). This is why I'm asking "why should don't cares in Let me explain why I am so hesitant to add it. Right now, nMigen uses pure 2-value logic: every bit is either With your suggestion, I would have to add, at the minimum, two language aspects. First, it would be necessary to make Python Second, everything in the language would now have to understand 3-valued logic, Here's my proposal: instead of this, add a separate method |
Comment by RobertBaruch +1, I'm a fan of |
Comment by whitequark Right. So now the question becomes, can this translate nicely to Verilog? Can Yosys' |
Comment by RobertBaruch Oh, I would just translate to '(x&p)==p' where 'p' is the pattern with '0' for '?'. |
Comment by whitequark Sure, that works. Can you implement it? Make sure to reproduce all the errors and warnings from |
Comment by RobertBaruch Can do. |
Comment by RobertBaruch Interesting, it seems that
Is translated by
And to ilang as:
So it seems there is support (at least in Yosys) for don't care values in equality comparison... |
Comment by RobertBaruch Pre-work: accept '?' in Case. |
Comment by whitequark @RobertBaruch I don't understand why #203 is necessary for this feature. |
Comment by whitequark
In Verilog, As far as I can tell, the standard provides no way to use In particular, if my reading of the standard is correct, using something like |
Comment by RobertBaruch
That's the Verilog way of representing don't-cares in case. Or, as you point out, it translates to However, I agree that it's wrong to use |
Comment by RobertBaruch In the meantime, I can just add the |
Comment by whitequark
I think adding a syntactic feature requires more motivation than "that's how it's done in Verilog". One specific reason I don't like adding
Sounds good. |
Comment by RobertBaruch I agree -- it would be confusing to add |
Issue by RobertBaruch
Tuesday Sep 10, 2019 at 04:03 GMT
Originally opened as m-labs/nmigen#202
I'd very much like to use the standard
?
for don't-care bits:Apparently Verilog supports this directly in
casez
, but not in equality comparisons -- at least not in a compatible way. There'sinside
, but I doubt yosys supports that. Such an equality statement could just be translated to something like:The text was updated successfully, but these errors were encountered: