Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.9.9
d22cdfc940528b50216a1996cf06f62626c24220
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.9.8
version = 3.9.9
runner.dialect = scala3

maxColumn = 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extension [CB <: DFConditional.Block](cb: CB)(using MemberGetSet)
.toSet
selectorVal.dfType match
case _ if complexPattern => None
case DFBits(Int(width)) =>
case DFBits(Int(width)) =>
if (constSet.exists(_.isBubble)) None // currently not checking don't-care patterns
else Some((1 << width) == constSet.size)
case dec: DFDecimal =>
Expand Down
12 changes: 6 additions & 6 deletions compiler/ir/src/main/scala/dfhdl/compiler/ir/DB.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ final case class DB(
origMember.getRefs.foreach {
case _: DFRef.Empty =>
case _: DFRef.TypeRef if excludeTypeRef =>
case r =>
case r =>
tbl.updateWith(
refTable.getOrElse(
r,
Expand Down Expand Up @@ -275,7 +275,7 @@ final case class DB(
): (DFConditional.Header, List[DFConditional.Block]) =
handled += block
block.prevBlockOrHeaderRef.get match
case header: DFConditional.Header => (header, block :: chain)
case header: DFConditional.Header => (header, block :: chain)
case prevBlock: DFConditional.Block =>
getChain(prevBlock, block :: chain)
chainMap + getChain(m, Nil)
Expand Down Expand Up @@ -391,14 +391,14 @@ final case class DB(
val toValOption = (lhsAccess, rhsAccess) match
case (Write, Read | ReadWrite | Unknown) => Some(lhsVal)
case (Read | ReadWrite | Unknown, Write) => Some(rhsVal)
case (Read, Read) =>
case (Read, Read) =>
newError("Unsupported read-to-read connection.")
None
case (Write, Write) =>
newError("Unsupported write-to-write connection.")
None
case (_, Read) => Some(lhsVal)
case (Read, _) => Some(rhsVal)
case (_, Read) => Some(lhsVal)
case (Read, _) => Some(rhsVal)
case (Error, _) =>
newError(s"Unknown access pattern with ${lhsVal.relValString}.")
None
Expand Down Expand Up @@ -941,7 +941,7 @@ final case class DB(
val problemReferences: List[(DFMember, DFMember)] =
membersNoGlobals.view.drop(1).flatMap {
case _: PortByNameSelect => None
case m =>
case m =>
val isDesignParam = m match
case _: DFVal.DesignParam => true
case _ => false
Expand Down
6 changes: 3 additions & 3 deletions compiler/ir/src/main/scala/dfhdl/compiler/ir/Data.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object Data:
given ReadWriter[Data] = readwriter[ujson.Value].bimap(
data =>
data match
case None => ujson.Null
case None => ujson.Null
case (valueBits: BitVector, bubbleBits: BitVector) =>
writeJs(("bits", (valueBits, bubbleBits)))
case Some(decimalOrEnumValue: BigInt) => writeJs(("decimal", decimalOrEnumValue))
Expand All @@ -24,7 +24,7 @@ object Data:
case Some(stringValue: String) => writeJs(("string", stringValue))
case (bigDecimal: BigDecimal, unit: DFTime.Unit) => writeJs(("time", (bigDecimal, unit)))
case (bigDecimal: BigDecimal, unit: DFFreq.Unit) => writeJs(("freq", (bigDecimal, unit)))
case vectorData: Vector[Data] =>
case vectorData: Vector[Data] =>
given ReadWriter[Vector[Data]] = vectorDataWriter
writeJs(("vector", vectorData))
case listData: List[Data] =>
Expand All @@ -33,7 +33,7 @@ object Data:
,
json =>
json match
case ujson.Null => None
case ujson.Null => None
case ujson.Arr(ArrayBuffer(ujson.Str("bits"), bitsValue)) =>
read[(BitVector, BitVector)](bitsValue)
case ujson.Arr(ArrayBuffer(ujson.Str("decimal"), decimalValue)) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ trait HasRefCompare[T <: HasRefCompare[T]]:
final def =~(that: T)(using MemberGetSet): Boolean =
cachedCompare match
case Some(prevCompare, result) if prevCompare eq that => result
case _ =>
case _ =>
val res = this `prot_=~` that
cachedCompare = Some(that, res)
res
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait AbstractDataPrinter extends AbstractPrinter:
case (_, 'F' | 'f') => s"$csDFBitBubbleChar"
case (h, '0') => s"$h"
case (h, b) if allowBitsBinModeInHex => s"{${binZip(BitVector(h), BitVector(b))}}"
case _ =>
case _ =>
err = true
""
}
Expand Down Expand Up @@ -68,7 +68,7 @@ trait AbstractDataPrinter extends AbstractPrinter:
case _ =>
val binRep = csDFBitsBinFormat(toBinString)
val hexRepOption = toHexString match
case Some(v) if width % 4 == 0 => Some(csDFBitsHexFormat(v))
case Some(v) if width % 4 == 0 => Some(csDFBitsHexFormat(v))
case Some(v) if allowBitsExplicitWidth =>
Some(csDFBitsHexFormat(v, binRep.length, widthParamRef))
case _ => None
Expand Down Expand Up @@ -140,13 +140,13 @@ trait AbstractDataPrinter extends AbstractPrinter:
def csDFNumberData(data: (BigDecimal, DFNumber.Unit)): String
def csDFStringData(dfType: DFString, data: Option[String]): String
final def csConstData(dfType: DFType, data: Any): String = (dfType, data) match
case DFBits.Data(dt, data) => csDFBitsData(dt, data)
case DFBoolOrBit.Data(dt, data) => csDFBoolOrBitData(dt, data)
case DFDecimal.Data(dt, data) => csDFDecimalData(dt, data)
case DFDouble.Data(dt, data) => csDFDoubleData(dt, data)
case DFEnum.Data(dt, data) => csDFEnumData(dt, data)
case DFVector.Data(dt, data) => csDFVectorData(dt, data)
case DFOpaque.Data(dt, data) => csDFOpaqueData(dt, data)
case DFBits.Data(dt, data) => csDFBitsData(dt, data)
case DFBoolOrBit.Data(dt, data) => csDFBoolOrBitData(dt, data)
case DFDecimal.Data(dt, data) => csDFDecimalData(dt, data)
case DFDouble.Data(dt, data) => csDFDoubleData(dt, data)
case DFEnum.Data(dt, data) => csDFEnumData(dt, data)
case DFVector.Data(dt, data) => csDFVectorData(dt, data)
case DFOpaque.Data(dt, data) => csDFOpaqueData(dt, data)
case DFStruct.Data(dt, data) if dt.isTuple && tupleSupportEnable =>
csDFTupleData(dt.fieldMap.values.toList, data)
case DFStruct.Data(dt, data) => csDFStructData(dt, data)
Expand All @@ -155,7 +155,7 @@ trait AbstractDataPrinter extends AbstractPrinter:
case DFFreq.Data(dt, data) => csDFFreqData(data)
case DFNumber.Data(dt, data) => csDFNumberData(data)
case DFString.Data(dt, data) => csDFStringData(dt, data)
case x =>
case x =>
throw new IllegalArgumentException(
s"Unexpected data found: $x"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ trait AbstractOwnerPrinter extends AbstractPrinter:
final def csDFIfElseStatement(ifBlock: DFConditional.DFIfElseBlock): String =
ifBlock.prevBlockOrHeaderRef.get match
case _: DFConditional.Header => csDFIfStatement(csDFIfGuard(ifBlock))
case _ =>
case _ =>
ifBlock.guardRef.get match
case DFMember.Empty => csDFElseStatement
case _ => csDFElseIfStatement(csDFIfGuard(ifBlock))
Expand All @@ -102,7 +102,7 @@ trait AbstractOwnerPrinter extends AbstractPrinter:
def csDFCasePattern(pattern: Pattern): String = pattern match
case Pattern.CatchAll => csDFCasePatternCatchAll
case Pattern.Singleton(valueRef) => valueRef.refCodeString
case Pattern.Alternative(list) =>
case Pattern.Alternative(list) =>
list.map(csDFCasePattern).mkString(csDFCasePatternAlternativeData)
case pattern: Pattern.Struct => csDFCasePatternStruct(pattern)
case pattern: Pattern.Bind => csDFCasePatternBind(pattern)
Expand Down Expand Up @@ -222,7 +222,7 @@ protected trait DFOwnerPrinter extends AbstractOwnerPrinter:
val body = csDFOwnerBody(design)
val bodyWithDcls = if (localDcls.isEmpty) body else s"$localDcls\n\n$body"
val dsnCls = design.domainType match
case DomainType.DF => "DFDesign"
case DomainType.DF => "DFDesign"
case rt: DomainType.RT =>
val cfgStr = rt.cfg match
case RTDomainCfg.Derived => ""
Expand Down Expand Up @@ -271,7 +271,7 @@ protected trait DFOwnerPrinter extends AbstractOwnerPrinter:
var hasNet = false
cb.members(MemberView.Folded).foreach {
case block: DFBlock => break(true)
case net: DFNet =>
case net: DFNet =>
if (hasNet) break(true)
hasNet = true
case _ =>
Expand Down Expand Up @@ -339,7 +339,7 @@ protected trait DFOwnerPrinter extends AbstractOwnerPrinter:
val body = csDFOwnerBody(domain)
val named = domain.meta.nameOpt.map(n => s"val $n = ").getOrElse("")
val domainStr = domain.domainType match
case DomainType.DF => "DFDomain"
case DomainType.DF => "DFDomain"
case rt: DomainType.RT =>
rt.cfg match
case RTDomainCfg.Related(relatedDomainRef) =>
Expand All @@ -349,7 +349,7 @@ protected trait DFOwnerPrinter extends AbstractOwnerPrinter:
else
s"${relatedDomain.getRelativeName(domain.getOwnerNamed)}.RelatedDomain"
case RTDomainCfg.Derived => "RTDomain"
case _ =>
case _ =>
s"RTDomain(${printer.csRTDomainCfg(rt.cfg)})"
case DomainType.ED => "EDDomain"
s"${named}new $domainStr:\n${body.hindent}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ trait AbstractTypePrinter extends AbstractPrinter:
def csDFString(dfType: DFString, typeCS: Boolean): String

final def csDFType(dfType: DFType, typeCS: Boolean = false): String = dfType match
case dt: DFBoolOrBit => csDFBoolOrBit(dt, typeCS)
case dt: DFBits => csDFBits(dt, typeCS)
case dt: DFDecimal => csDFDecimal(dt, typeCS)
case dt: DFEnum => csDFEnum(dt, typeCS)
case dt: DFVector => csDFVector(dt, typeCS)
case dt: DFOpaque => csDFOpaque(dt, typeCS)
case dt: DFBoolOrBit => csDFBoolOrBit(dt, typeCS)
case dt: DFBits => csDFBits(dt, typeCS)
case dt: DFDecimal => csDFDecimal(dt, typeCS)
case dt: DFEnum => csDFEnum(dt, typeCS)
case dt: DFVector => csDFVector(dt, typeCS)
case dt: DFOpaque => csDFOpaque(dt, typeCS)
case dt: DFStruct if dt.isTuple && tupleSupportEnable =>
csDFTuple(dt.fieldMap.values.toList, typeCS)
case dt: DFStruct => csDFStruct(dt, typeCS)
Expand All @@ -97,7 +97,7 @@ protected trait DFTypePrinter extends AbstractTypePrinter:
val (ob, cb) = if (typeCS) ("[", "]") else ("(", ")")
(signed, fractionWidth) match
case (false, 0) => s"UInt$ob$csWidth$cb"
case (true, 0) =>
case (true, 0) =>
if (dfType.isDFInt32) "Int"
else s"SInt$ob$csWidth$cb"
case (false, _) => s"UFix$ob$magnitudeWidth, $fractionWidth$cb"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@ extension (text: String)
val upperIndex = math.ceil(index).toInt
if (lowerIndex == upperIndex)
sortedData(lowerIndex)
else {
else
val lowerValue = sortedData(lowerIndex)
val upperValue = sortedData(upperIndex)
lowerValue + (upperValue - lowerValue) * (index - lowerIndex)
}

if (alignLengths.length > 0)
// we remove long align outliers that pass the threshold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ case object DropUnreferencedAnons extends Stage, NoCheckStage:
// skipping over conditional headers that can be considered values as well.
case _: DFConditional.Header => None
// idents are always kept
case Ident(_) => None
case Ident(_) => None
case m: DFVal if m.isAnonymous && m.originMembers.isEmpty =>
Some(m -> Patch.Remove())
case _ => None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ case object MatchToIf extends Stage:
list match
case cond :: Nil => Some(cond)
case Nil => None
case _ =>
case _ =>
Some(dfhdl.core.DFVal.Func(dfhdl.core.DFBool, reductionOp, list))
pattern match
case Pattern.Singleton(DFRef(const: DFVal.Const)) =>
Expand Down Expand Up @@ -118,8 +118,8 @@ case object MatchToIf extends Stage:
val patternCondOpt = getPatternCondOpt(selector, c.pattern)
val guardRef: DFConditional.Block.GuardRef =
(c.getGuardOption, patternCondOpt) match
case (_, None) => c.guardRef
case (None, Some(cond)) => cond.asIR.refTW[DFIfElseBlock]
case (_, None) => c.guardRef
case (None, Some(cond)) => cond.asIR.refTW[DFIfElseBlock]
case (Some(guardVal), Some(cond)) =>
val combinedGuard = guardVal.asValOf[dfhdl.core.DFBool] && cond
combinedGuard.asIR.refTW[DFIfElseBlock]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ case class SanityCheck(skipAnonRefCheck: Boolean) extends Stage:
else memberSet += m
// check for missing references
m.getRefs.foreach {
case _: DFRef.Empty => // do nothing
case _: DFRef.Empty => // do nothing
case r if !refTable.contains(r) =>
reportViolation(s"Missing ref $r for the member: $m")
case _ => // do nothing
Expand Down Expand Up @@ -72,7 +72,7 @@ case class SanityCheck(skipAnonRefCheck: Boolean) extends Stage:
// check that anonymous values are referenced exactly once
m match
case dfVal: DFVal if dfVal.isAllowedMultipleReferences => // skip named
case dfVal: DFVal =>
case dfVal: DFVal =>
val deps = dfVal.getReadDeps
if (deps.size > 1)
reportViolation(
Expand All @@ -85,7 +85,7 @@ case class SanityCheck(skipAnonRefCheck: Boolean) extends Stage:
dfVal match
case ch: DFConditional.Header if ch.dfType == DFUnit =>
case Ident(_) =>
case _ =>
case _ =>
reportViolation(
s"""|An anonymous value has no references.
|Referenced value: $dfVal""".stripMargin
Expand All @@ -108,7 +108,7 @@ case class SanityCheck(skipAnonRefCheck: Boolean) extends Stage:
memberSet.foreach { m =>
m.getRefs.foreach {
case _: DFRef.Empty => // skip empty referenced
case r =>
case r =>
originRefTableMutable.get(r).foreach { prevMember =>
def originViolation(addedText: String) = reportViolation(
s"""|Ref $r has more than one origin member$addedText.
Expand All @@ -121,7 +121,7 @@ case class SanityCheck(skipAnonRefCheck: Boolean) extends Stage:
r.get match
// global references can be shared across types
case dfVal: DFVal.CanBeGlobal if dfVal.isGlobal => // no violation
case _ =>
case _ =>
if (!(prevMember isSameOwnerDesignAs m))
originViolation(" from a different design")
case _ => originViolation("")
Expand All @@ -133,13 +133,13 @@ case class SanityCheck(skipAnonRefCheck: Boolean) extends Stage:
// or the referencing member is a design parameter
originRefTableMutable.foreach {
case (_: DFRef.TypeRef, _) => // do nothing
case (r, originMember) =>
case (r, originMember) =>
r.get match
case targetVal: DFVal if targetVal.isAnonymous && targetVal.isGlobal =>
originMember match
case originVal: DFVal if originVal.isGlobal =>
case _: DFVal.DesignParam =>
case _ =>
case _ =>
reportViolation(
s"""|A global anonymous member is referenced by a non-global member.
|Target member: ${targetVal}
Expand Down Expand Up @@ -189,7 +189,7 @@ case class SanityCheck(skipAnonRefCheck: Boolean) extends Stage:
m match // still in current owner
case o: DFOwner => ownershipCheck(o, nextMembers) // entering new owner
case _ => ownershipCheck(currentOwner, nextMembers) // new non-member found
case Nil => // Done! All is OK
case Nil => // Done! All is OK
case m :: _ => // not in current owner
if (currentOwner.isTop)
println(
Expand All @@ -212,7 +212,7 @@ case class SanityCheck(skipAnonRefCheck: Boolean) extends Stage:
getSet.designDB.members.foreach {
// goto statement can reference later steps
case _: Goto =>
case m =>
case m =>
m.getRefs.foreach {
case r @ DFRef(rm) if !discoveredMembers.contains(rm) =>
m match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected trait VerilogTypePrinter extends AbstractTypePrinter:
val signedKeyword = if (allowSignedKeywordAndOps) "signed " else ""
(signed, fractionWidth) match
case (false, 0) => s"logic [${dfType.widthParamRef.uboundCS}:0]"
case (true, 0) =>
case (true, 0) =>
if (dfType.isDFInt32)
if (intTypeIsSupported) "int"
else "integer"
Expand Down
Loading