-
Notifications
You must be signed in to change notification settings - Fork 39
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
Knowing when something is in a ring #75
Comments
Actually -- that's confusing. If you have an import implicits, would it still not implicitly say that UInt is Ring? If you didn't import implicits, then I think that's correct... (not sure if I really understand implicits though...) |
I did use
Maybe @grebe can comment on that |
ok... I'm not sure if I like that behavior then :\ Definitely would've been a gotcha for me when writing control logic (i.e. control always UInt, but I still want some of the custom behaviors enabled with the typeclasses). But if that's the case, some big warning somewhere would be nice. |
I don't like it either, I couldn't figure out at first why I wasn't getting exception I expected :P but I'm not sure what to do about it. |
Could you, with the implicit stuff do some type conversion from UInt to UIntTypeClass? |
@grebe @shunshou class SignBitTester(c: SignBit[UInt]) extends DspTester(c) {
poke(c.io.uIn, 0)
expect(c.io.uOut, 0.0)
}
class SignBit[TU <: Data : Ring](uGen: TU) extends Module {
val io = IO(new Bundle {
val uIn = Input(uGen)
val uOut = Output(UInt(1.W))
})
io.uOut := io.uIn.signBit()
} But the io.uIn.signBit() is a compile error. What should I do to type signature to pick this up. I've started to go through the permutations of UIntInteger, UIntImpl etc. Do we need to consider adding chisel3 level support for things like signBit I can do
But this does not allow for generic number passing. |
@shunshou also Numbers.md says the following, is that right
|
signBit is only on Data:RealBits, Data:IntegerBits. Ring doesn't have any notion of "bits". RealBits and IntegerBits should be all encompassing (of Ring, Order, etc.). Sorry! Numbers.md is a typo -- it should be 0 if a is zero or positive; 1 is a is negative. Good catch! |
I'll change the spec with my next commit of more tests |
So what is the right way to specify type parameters so one can apply signBit |
@shunshou Numbers section on div2 what does |
Basically, Paul was using Data:Real to allow you access to anything more than +, -, * [Kind of confusing with DspReal] so I added some bit-related things by having RealBits extend Real. As an example, Ring doesn't give you comparison -- so to be safe, if you wanted the whole range of Typeclass ops, you really should be using RealBits and not Ring. Only when you want to limit the supported operations to +, -, * should you use Ring. (Again, really confusing unless you understand type classes, which I don't...). >_> |
I'm just saying that 1 >> 1 would return 0. Math-y 1 >> 1 should be 1 / 2^(1) == 1/2 (if you added more bit precision), but we don't do that. Maybe my explanation was poorly written and just confusing to people instead of being helpful. Feel free to change it to something that makes sense to you. |
@chick have you figured out how to give typeclass functionality to UInts? :\ like val test = UInt(3.W) and then do some typeclass only thing on test? Should it just be done with some implicit conversion to UIntTypeClass? It's very confusing... |
Actually, this is a huge problem that renders all of the typeclass stuff useless for all of my control logic. |
I've fiddled with it a bit this weekend, I have not solved. I'll work on it more tonight and tomorrow and hopefully by the end of hacking tomorrow, we can some up with something |
I agree this is a big problem. |
I think this is resolved by our decision that operations should have their normal behavior (eg typeclass's + === UInt +) and the addition of context_+. I think this issue can be closed, although we should revisit how happy we are with the context_ approach. |
definitely dislike having context_, but cleanly separating out somehow is important. |
The following circuit ignores the DspContext directive.
The reason is that since the IO's are not declared with generators that have been given a Ring constraint the - that is used is the basic chisel one and not the one in UInt Ring.
As a result this circuit compiles, despite that subtract with overflow type Grow is not supported
The text was updated successfully, but these errors were encountered: