File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
core/src/main/scala/dfhdl Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1239,8 +1239,9 @@ extension [T <: DFTypeAny](dfVar: DFValOf[T])
12391239extension [T <: DFTypeAny ](lhs : DFValOf [T ])
12401240 def connect (resource : Resource )(using dfc : DFC ): Unit =
12411241 import dfc .getSet
1242+ import dfhdl .compiler .analysis .DclPort
12421243 lhs.asIR.departialDcl match
1243- case Some (dcl, range) =>
1244+ case Some (dcl @ DclPort () , range) if dcl.getOwnerDesign.isTop =>
12441245 val newSigConstraints =
12451246 if (range.length != dcl.width) resource.allSigConstraints.flatMap { cs =>
12461247 for (i <- range) yield cs.updateBitIdx(i)
@@ -1254,7 +1255,10 @@ extension [T <: DFTypeAny](lhs: DFValOf[T])
12541255 (existingSigConstraints ++ newSigConstraints).merge.consolidate(dcl.width)
12551256 val updatedAnnotations = updatedSigConstraints ++ otherAnnotations
12561257 dcl.setMeta(m => m.copy(annotations = updatedAnnotations))
1257- case None =>
1258+ case _ =>
1259+ throw new IllegalArgumentException (
1260+ " Cannot apply resource constraints to a non-top-level port value."
1261+ )
12581262 end match
12591263 end connect
12601264 def connect [R <: DFTypeAny ](rhs : DFValOf [R ])(using DFC ): Unit =
@@ -1461,6 +1465,7 @@ object DFPortOps:
14611465 )(using
14621466 connectableOnly : ConnectableOnly [C , rhs.ExactFrom ]
14631467 ): ConnectPlaceholder =
1468+ given CTName = CTName (" <>" )
14641469 trydf {
14651470 rhs.exactFrom match
14661471 case resource : Resource => dfPort.connect(resource)
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import scala.annotation.implicitNotFound
33import scala .collection .mutable
44import dfhdl .compiler .ir .constraints .SigConstraint
55import dfhdl .core .*
6+ import dfhdl .internals .CTName
67
78trait Resource extends ResourceContext :
89 private val connections = mutable.ListBuffer [Resource ]()
@@ -43,7 +44,9 @@ object Resource extends ResourceLP:
4344 resource1.connect(resource2)
4445 resource2.connect(resource1)
4546 given [T <: Resource , R <: DFValAny ](using DFC ): CanConnect [T , R ] =
46- (resource : T , dfVal : R ) => dfVal.connect(resource)
47+ (resource : T , dfVal : R ) =>
48+ given CTName = CTName (" <>" )
49+ trydf { dfVal.connect(resource) }
4750
4851 object Ops :
4952 extension [T <: Resource ](self : T )
You can’t perform that action at this time.
0 commit comments