ucb-bar / chisel2-deprecated

chisel.eecs.berkeley.edu
387 stars 90 forks source link

Added an equal bits method #584

Closed da-steve101 closed 8 years ago

da-steve101 commented 8 years ago

I can understand why the assignment such as from UInt to Flo may be ambiguous in that either setting the bits directly or converting the integer to a floating point number.

For the case of setting the bits directly, this is a bit painful. All that is needed is access to the Bits colonEquals however, so I added equalsBits() which is this method but not overridden.

da-steve101 commented 8 years ago

Thinking about this a bit more, perhaps Flo and Dbl shouldn't override the colonEquals method? ie) I think this should be allowed:

myFlo := myUInt

Hence, colonEquals is always at the bit level, any conversions should be explicit. Thoughts?

sdtwigg commented 8 years ago

You can currently do either myFlo := myFlo.fromBits(myUInt) myFlo := Flo().fromBits(myUInt)

Note, this requires, in general, that for x.myBits, x has no uninferred widths (as myUInt will be zero-extended as needed). In this specific case, Flo/myFlo has fully known widths so this is fine.

I think this satisfies your needs already?

ghost commented 8 years ago

Can one of the admins verify this patch?