@@ -1041,25 +1041,32 @@ object DFVal extends DFValLP:
1041
1041
export DFTuple .Val .TCConv .given
1042
1042
export DFVector .Val .TCConv .given
1043
1043
1044
- trait TC_Or_OPEN_Or_Resource [T <: DFTypeAny , R ] extends TC [T , R ]
1044
+ trait TC_Or_OPEN_Or_Resource [T <: DFTypeAny , R ] extends TC [T , R ]:
1045
+ def connect (dfVal : DFValOf [T ], that : R )(using DFC ): Unit
1045
1046
object TC_Or_OPEN_Or_Resource :
1046
1047
type Exact [T <: DFTypeAny ] =
1047
1048
Exact1 [DFTypeAny , T , [t <: DFTypeAny ] =>> t, DFC , TC_Or_OPEN_Or_Resource ]
1048
1049
given fromOPEN [T <: DFTypeAny ]: TC_Or_OPEN_Or_Resource [T , OPEN ] with
1049
1050
type OutP = NOTCONST
1050
1051
def conv (dfType : T , from : OPEN )(using DFC ): Out = DFVal .OPEN (dfType)
1052
+ def connect (dfVal : DFValOf [T ], that : OPEN )(using DFC ): Unit =
1053
+ dfVal.connect(conv(dfVal.dfType, that))
1051
1054
given fromTC [
1052
1055
T <: DFTypeAny ,
1053
1056
R ,
1054
1057
TC <: DFVal .TC [T , R ]
1055
1058
](using tc : TC ): TC_Or_OPEN_Or_Resource [T , R ] with
1056
1059
type OutP = tc.OutP
1057
1060
def conv (dfType : T , from : R )(using DFC ): Out = tc(dfType, from)
1061
+ def connect (dfVal : DFValOf [T ], that : R )(using DFC ): Unit =
1062
+ dfVal.connect(conv(dfVal.dfType, that))
1058
1063
given fromResource [T <: DFTypeAny , R <: Resource ](using
1059
- Resource .CanConnect [R , DFValOf [T ]] // just type checking
1064
+ cc : Resource .CanConnect [R , DFValOf [T ]]
1060
1065
): TC_Or_OPEN_Or_Resource [T , R ] with
1061
1066
type OutP = NOTCONST
1062
1067
def conv (dfType : T , from : R )(using DFC ): Out = ???
1068
+ def connect (dfVal : DFValOf [T ], that : R )(using DFC ): Unit =
1069
+ cc.connect(that, dfVal)
1063
1070
end TC_Or_OPEN_Or_Resource
1064
1071
1065
1072
trait Compare [T <: DFTypeAny , V , Op <: FuncOp , C <: Boolean ] extends TCCommon [T , V , DFValAny ]:
@@ -1443,9 +1450,7 @@ object DFPortOps:
1443
1450
): ConnectPlaceholder =
1444
1451
given CTName = CTName (" <>" )
1445
1452
trydf {
1446
- rhs.exactFrom match
1447
- case resource : Resource => resource.connect(dfPort)
1448
- case _ => dfPort.connect(rhs(dfPort.dfType))
1453
+ rhs.tc.connect(dfPort, rhs.exactFrom)
1449
1454
}
1450
1455
ConnectPlaceholder
1451
1456
end extension
0 commit comments