-
Notifications
You must be signed in to change notification settings - Fork 57
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(...) #202
Comments
You can use this in
I don't think adding support for don't cares to |
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 |
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 |
+1, I'm a fan of |
Right. So now the question becomes, can this translate nicely to Verilog? Can Yosys' |
Oh, I would just translate to '(x&p)==p' where 'p' is the pattern with '0' for '?'. |
Sure, that works. Can you implement it? Make sure to reproduce all the errors and warnings from |
Can do. |
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... |
Pre-work: accept '?' in Case. |
@RobertBaruch I don't understand why #203 is necessary for this feature. |
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 |
In the meantime, I can just add the |
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. |
I agree -- it would be confusing to add |
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: