You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.
I added nodes and chisel backends for saturating ops by enclosing them in <> (like <+>) and unbiased rounding by appending & (like *&) but I think there can be times when we just want to reduce the precision of a number and have control over whether the cast will saturate or truncate the bits.
For saturation casting, is this the intention of to[T] vs as[T] or are these just supposed to handle sign extension? The backend already exists for whatever kind of conversion, but I think right now I sign extend when upcasting and I think I default to truncation for downcasting.
What should the syntax be for unbiased rounding upon downcasting? I already have chisel for this too but I think we need a node to plug it into.
The text was updated successfully, but these errors were encountered:
val x: A
// Insert an explicit cast from A to B <truncate, roll over> on <reduced precision, under/overflow>
x.to[B]
// Reinterpret the bits of A as being of type B. Same as casting from (A*) to (B*) in C/C++
x.as[B]
e.g.
val x: Float = 128.5f
val y = x.to[Byte] // Rolls over, truncates to -128
val z = x.as[Int] // 0x43008000 => 1124106240
At the moment we don't have a syntax for anything besides truncating/rolling over in type conversion.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I added nodes and chisel backends for saturating ops by enclosing them in <> (like
<+>
) and unbiased rounding by appending & (like*&
) but I think there can be times when we just want to reduce the precision of a number and have control over whether the cast will saturate or truncate the bits.For saturation casting, is this the intention of
to[T]
vsas[T]
or are these just supposed to handle sign extension? The backend already exists for whatever kind of conversion, but I think right now I sign extend when upcasting and I think I default to truncation for downcasting.What should the syntax be for unbiased rounding upon downcasting? I already have chisel for this too but I think we need a node to plug it into.
The text was updated successfully, but these errors were encountered: