diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/Utils.scala | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main/scala/firrtl/Utils.scala b/src/main/scala/firrtl/Utils.scala index e3f0fee1..b4ad2e74 100644 --- a/src/main/scala/firrtl/Utils.scala +++ b/src/main/scala/firrtl/Utils.scala @@ -61,11 +61,18 @@ object bitWidth { object castRhs { def apply(lhst: Type, rhs: Expression) = { - lhst match { - case _: SIntType => DoPrim(AsSInt, Seq(rhs), Seq.empty, lhst) - case FixedType(_, IntWidth(p)) => DoPrim(AsFixedPoint, Seq(rhs), Seq(p), lhst) - case ClockType => DoPrim(AsClock, Seq(rhs), Seq.empty, lhst) - case _: UIntType => rhs + (lhst, rhs.tpe) match { + case (x: GroundType, y: GroundType) if WrappedType(x) == WrappedType(y) => + rhs + case (_: SIntType, _) => + DoPrim(AsSInt, Seq(rhs), Seq.empty, lhst) + case (FixedType(_, IntWidth(p)), _) => + DoPrim(AsFixedPoint, Seq(rhs), Seq(p), lhst) + case (ClockType, _) => + DoPrim(AsClock, Seq(rhs), Seq.empty, lhst) + case (_: UIntType, _) => + DoPrim(AsUInt, Seq(rhs), Seq.empty, lhst) + case (_, _) => error("castRhs lhst, rhs type combination is invalid") } } } |
