Skip to content

Commit a3e4cd5

Browse files
author
Oron Port
committed
fix DFXInt width checking to useisSimilarTo instead of =~
1 parent a352599 commit a3e4cd5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/stages/src/test/scala/StagesSpec/PrintVerilogCodeSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ class PrintVerilogCodeSpec extends StageSpec:
500500
)
501501
test("UInt counter example"):
502502
class Counter(val width: Int <> CONST) extends RTDesign:
503-
val cnt = UInt(width) <> OUT init d"8'0"
503+
val cnt = UInt(width) <> OUT init 0
504504
cnt := cnt.reg + 1
505505
val top = (new Counter(8)).getCompiledCodeString
506506
assertNoDiff(

core/src/main/scala/dfhdl/core/DFDecimal.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,6 @@ object DFXInt:
719719
): TC[DFXInt[LS, LW, LN], R] with
720720
type OutP = ic.OutP
721721
def conv(dfType: DFXInt[LS, LW, LN], value: R)(using dfc: DFC): Out =
722-
import Ops.resize
723722
import DFUInt.Val.Ops.signed
724723
val rhs = ic(value)
725724
val (rhsSigned, rhsWidth) = rhs.getActualSignedWidth
@@ -811,9 +810,10 @@ object DFXInt:
811810
lhsSignFix.toInt.asIR
812811
case BitAccurate =>
813812
DFVal.Alias.AsIs(dfType, lhsSignFix).asIR
814-
else if (!(dfType.asIR.widthParamRef =~ lhsSignFix.dfType.asIR.widthParamRef))
813+
else if (!dfType.asIR.widthParamRef.isSimilarTo(lhsSignFix.dfType.asIR.widthParamRef))
815814
lhsSignFix.resize(dfType.widthIntParam).asIR
816815
else lhsSignFix.asIR
816+
end if
817817
end if
818818
end dfValIR
819819
dfValIR.asValTP[DFXInt[RS, RW, RN], P]

0 commit comments

Comments
 (0)