-
Notifications
You must be signed in to change notification settings - Fork 76
peek.litValue is confusing #298
Comments
Unfortunately this is a However, we could probably add a better name in addition to the old method. I do like |
So I'm not sure I completely understand what you mean: but what However, every time you call If you're asking for some way to check if a wire in a circuit is truly const, and return its value in that case (and perhaps crash otherwise?), that functionality doesn't exist. I'm not sure how useful it will be either. Possibly related: see chisel3 #830 for prior discussion on |
I understand that the API comes from Chisel and not from the tester. And I think mixing this is the issue. Having a HW constant as a Chisel type is fine. Let's rephrase the issue:
This function will return a different value for each different Maybe I am picky, but a return from a function (peek) is usually not a constant/a literal value. |
I'm still lost.
I guess my question is ... what do you want to see? |
Maybe this is getting a bit philosophical. What is a literal? for me this is a constant, something that does not change. Maybe not a big thing, but it is a least a stable contract. When a function (foo() or peek()) returns something, than this is not a constant/literal but a value. It is computed by the input values and maybe be some internal state. So Am I picky here? ;-) |
Ah, I think I see. Currently the object returned by |
I feel like a good summary here would be that (1) I wonder if it would be possible to allow UInt/SInt types to implicitly be cast to BigInt. What do you think @ducky64 ? |
My immediate feeling is that the implicit conversion could end up being confusing - I think we've generally had problems with getting non-PML implicits to be robust. It might be worth prototyping and seeing how it works in a few realistic use cases, but I don't have high hopes for it? But yes, I agree that |
the return value is a String value, not a literal or constant. Although strings in the JVM are internally constants and immutable. So |
Maybe we should start within Chisel to change from |
So in Chisel we call things like In terms of renaming: feel free to propose as a chisel3 issue. But a main concern there is to minimize maintenance burden on legacy code, so I wouldn't be optimistic that a stylistic renaming without a large usability benefit will go through. We also do things like In any case, unless you have a concrete proposal for a chiseltest change, this seems more like a chisel3 issue that should be discussed either as a chisel3 issue or during a dev meeting? |
I feel like just adding an alias might be acceptable. |
I'm generally not a fan of having multiple ways to do the same thing without some kind of deprecation automation (even if the old API never gets removed, and individual deprecations can be suppressed), otherwise we just end up with a confusing mix of old APIs that people never migrate off of because they don't know, and new people not being clear on which option to use. In any case, this seems like a chisel3 / dev meeting discussion. |
OK, I agree that changing the name of a function that is widely used is not really an option (anymore). And I agree with @ducky64 that it is not a good idea to have two names for the same function. I agree that Yes, let us pick this up on a Monday discusssion. |
Maybe even having a simpler alias to peek().litValue like .getLit () to reduce verbosity and use native Scala types? |
I think something like that might be interesting. It would only work on |
I think working on SInt, UInt and Bool is sufficient for most cases (if not all) :) |
I'm amenable to making Chisel literals act more like Scala literals (including in operations like Obviously this would need some thought though. |
I have no issue with working with Chisel's own types for hardware generation, also I think it helps on keeping your thinking on "this is generation and that is hardware" but I believe for testing, the conversion to native Scala types would benefit some automation and comparison using validation functions and etc... I think having a function returning the native value would reduce verbosity too. |
The main problem with returning native Scala values is handling of Aggregates. We could return |
fixed by #480 |
I think we have a confusing naming here with ChielsTest and the notion of a literal. I understand that ChiselTest is using Chisel types for peek and poke. However, in a testing environment, we may use Scala land types and we need to convert. A function called
litValue
is hinting in its name that this is a literal/constant. However, during tests this is not the case. It may return a different value on a peek each clock cycle! So the namelit
is misleading. Maybe something likevalue`` or
asBigInt``` is more appropriate.Luckily ChiselTest is still in alpha mode and we can change the API for a more consistent naming ;-)
Cheers,
Martin
The text was updated successfully, but these errors were encountered: