@@ -21,6 +21,9 @@ object Ident:
21
21
if (alias.hasTagOf[DFVal .Alias .IdentTag .type ]) Some (alias.relValRef.get)
22
22
else None
23
23
24
+ object StrippedPortByNameSelect :
25
+ def unapply (dfVal : DFVal )(using MemberGetSet ): Option [DFVal ] = Some (dfVal.stripPortSel)
26
+
24
27
// A design parameter is an as-is alias that:
25
28
// 1. has `DesignParamTag` tag
26
29
// TODO: This is not yet working. more complicated than initially thought.
@@ -101,9 +104,11 @@ object RstActive:
101
104
case FuncOp .=== | FuncOp .=!= =>
102
105
val List (lhsRef, rhsRef) = func.args
103
106
val (dcl, const) = (lhsRef.get, rhsRef.get) match
104
- case (dcl : DFVal .Dcl , const : DFVal .Const ) if const.dfType equals DFBit =>
107
+ case (dcl : (DFVal .Dcl | DFVal .PortByNameSelect ), const : DFVal .Const )
108
+ if const.dfType equals DFBit =>
105
109
(dcl, const)
106
- case (const : DFVal .Const , dcl : DFVal .Dcl ) if const.dfType equals DFBit =>
110
+ case (const : DFVal .Const , dcl : (DFVal .Dcl | DFVal .PortByNameSelect ))
111
+ if const.dfType equals DFBit =>
107
112
(dcl, const)
108
113
case _ => break(None )
109
114
val value = const.data.asInstanceOf [Option [Boolean ]].get
@@ -116,8 +121,8 @@ object RstActive:
116
121
val relVal = func.args.head.get
117
122
Some (relVal, RstCfg .Active .Low )
118
123
case _ => None
119
- case dcl : DFVal .Dcl => Some (dcl, RstCfg .Active .High )
120
- case _ => None
124
+ case dcl : ( DFVal .Dcl | DFVal . PortByNameSelect ) => Some (dcl, RstCfg .Active .High )
125
+ case _ => None
121
126
end RstActive
122
127
123
128
// not only `DFVal.Const` but all non-anonymous values that
@@ -210,19 +215,22 @@ extension (dfVal: DFVal)
210
215
dfVal.originMembers.view
211
216
.collect { case dfVal : DFVal => dfVal }
212
217
.exists(dfVal => cond(dfVal) || dfVal.existsInComposedReadDeps(cond))
213
- def getReadDeps (using MemberGetSet ): Set [DFNet | DFVal | DFConditional .Block ] =
214
- val fromRefs : Set [DFNet | DFVal | DFConditional .Block ] = dfVal.originMembersNoTypeRef.flatMap {
215
- case net : DFNet =>
216
- net match
217
- // ignoring receiver or if connecting to an OPEN
218
- case DFNet .Connection (toVal : DFVal , _, _) if toVal.isOpen || toVal == dfVal => None
219
- // ignoring receiver
220
- case DFNet .Assignment (toVal, _) if toVal == dfVal => None
221
- case _ => Some (net)
222
- case dfVal : DFVal => Some (dfVal)
223
- case guardBlock : DFConditional .Block if guardBlock.guardRef.get == dfVal => Some (guardBlock)
224
- case _ => None
225
- }
218
+ def getReadDeps (using MemberGetSet ): Set [TextOut | DFNet | DFVal | DFConditional .Block ] =
219
+ val fromRefs : Set [TextOut | DFNet | DFVal | DFConditional .Block ] =
220
+ dfVal.originMembersNoTypeRef.flatMap {
221
+ case net : DFNet =>
222
+ net match
223
+ // ignoring receiver or if connecting to an OPEN
224
+ case DFNet .Connection (toVal = toVal : DFVal ) if toVal.isOpen || toVal == dfVal =>
225
+ None
226
+ // ignoring receiver
227
+ case DFNet .Assignment (toVal = toVal) if toVal == dfVal => None
228
+ case _ => Some (net)
229
+ case dfVal : DFVal => Some (dfVal)
230
+ case guardBlock : DFConditional .Block if guardBlock.guardRef.get == dfVal => Some (guardBlock)
231
+ case textOut : TextOut => Some (textOut)
232
+ case _ => None
233
+ }
226
234
dfVal match
227
235
// for ports we need to also account for by-name referencing
228
236
case port @ DclPort () =>
@@ -280,10 +288,10 @@ extension (dfVal: DFVal)
280
288
case r : TypeRef =>
281
289
// looking for what kind of type reference it is
282
290
r.originMember.asInstanceOf [DFVal ].dfType match
283
- case DFVector (_, (cellDimRef : TypeRef ) :: _) if cellDimRef == r => Some (" length" )
284
- case DFBits (widthRef : TypeRef ) if widthRef == r => Some (" width" )
285
- case DFDecimal (_, widthRef : TypeRef , _, _ ) if widthRef == r => Some (" width" )
286
- case _ => None
291
+ case DFVector (_, (cellDimRef : TypeRef ) :: _) if cellDimRef == r => Some (" length" )
292
+ case DFBits (widthRef : TypeRef ) if widthRef == r => Some (" width" )
293
+ case DFDecimal (widthParamRef = widthRef : TypeRef ) if widthRef == r => Some (" width" )
294
+ case _ => None
287
295
case _ => None
288
296
}.headOption
289
297
else None
@@ -324,9 +332,9 @@ extension (dfVal: DFVal)
324
332
end refOwner
325
333
refOwner match
326
334
// name from assignment destination
327
- case Some (DFNet .Assignment (toVal, _ )) => Some (partName(member, toVal))
335
+ case Some (DFNet .Assignment (toVal = toVal )) => Some (partName(member, toVal))
328
336
// name from connection destination
329
- case Some (DFNet .Connection (toVal : DFVal , _, _ )) => Some (partName(member, toVal))
337
+ case Some (DFNet .Connection (toVal = toVal : DFVal )) => Some (partName(member, toVal))
330
338
// name from a named value which was referenced by an alias
331
339
case Some (value : DFVal ) if ! value.isAnonymous => Some (partName(member, value))
332
340
// found an (anonymous) value -> checking suggestion for it
@@ -342,22 +350,6 @@ extension (dfVal: DFVal)
342
350
.replace('.' , '_' )
343
351
)
344
352
case _ => suggestName(dfVal)
345
- def isBubble (using MemberGetSet ): Boolean =
346
- dfVal match
347
- case c : DFVal .Const => c.dfType.isDataBubble(c.data.asInstanceOf [c.dfType.Data ])
348
- case f : DFVal .Func => f.args.exists(_.get.isBubble)
349
- case a : DFVal .Alias .ApplyIdx => a.relValRef.get.isBubble || a.relIdx.get.isBubble
350
- case a : DFVal .Alias .Partial => a.relValRef.get.isBubble
351
- case _ => false
352
- def isDFDomain (using MemberGetSet ): Boolean = dfVal.getDomainType match
353
- case DomainType .DF => true
354
- case _ => false
355
- def isRTDomain (using MemberGetSet ): Boolean = dfVal.getDomainType match
356
- case DomainType .RT (_) => true
357
- case _ => false
358
- def isEDDomain (using MemberGetSet ): Boolean = dfVal.getDomainType match
359
- case DomainType .ED => true
360
- case _ => false
361
353
// true if this is a variable that is never assigned/connected to
362
354
def isConstVAR (using MemberGetSet ): Boolean =
363
355
dfVal match
@@ -376,16 +368,6 @@ extension (dfVal: DFVal)
376
368
377
369
end extension
378
370
379
- extension (dcl : DFVal .Dcl )
380
- def hasNonBubbleInit (using MemberGetSet ): Boolean = dcl.initRefList match
381
- case DFRef (dfVal) :: _ => ! dfVal.isBubble
382
- case _ => false
383
-
384
- extension (dcl : DFVal .Alias .History )
385
- def hasNonBubbleInit (using MemberGetSet ): Boolean = dcl.initRefOption match
386
- case Some (DFRef (dfVal)) => ! dfVal.isBubble
387
- case _ => false
388
-
389
371
extension (refTW : DFNet .Ref )
390
372
def isViaRef (using MemberGetSet ): Boolean =
391
373
refTW.originMember match
@@ -413,14 +395,35 @@ extension (net: DFNet)
413
395
@ targetName(" collectRelMembersDFNet" )
414
396
def collectRelMembers (using MemberGetSet ): List [DFVal ] =
415
397
net match
416
- case DFNet (DFRef (lhs : DFVal ), _, DFRef (rhs : DFVal ), _, _, _ ) =>
398
+ case DFNet (lhsRef = DFRef (lhs : DFVal ), rhsRef = DFRef (rhs : DFVal )) =>
417
399
lhs.collectRelMembers(false ) ++ rhs.collectRelMembers(false )
418
400
case _ => Nil
419
401
402
+ extension (textOut : TextOut )
403
+ @ targetName(" collectRelMembersTextOut" )
404
+ def collectRelMembers (using MemberGetSet ): List [DFVal ] =
405
+ textOut.getRefs.view
406
+ .collect { case DFRef (dfVal : DFVal ) => dfVal }
407
+ .flatMap(_.collectRelMembers(false )).toList
408
+
420
409
extension (member : DFMember )
421
410
def isPublicMember (using MemberGetSet ): Boolean =
422
411
member match
423
412
case DclPort () => true
424
413
case _ : DFVal .DesignParam => true
425
414
case _ : DomainBlock => true
426
415
case _ => false
416
+ end extension
417
+
418
+ extension (member : DFMember )
419
+ def consumesCycles (using MemberGetSet ): Boolean =
420
+ member match
421
+ case loop : DFLoop .Block =>
422
+ loop.isInRTDomain && ! loop.isCombinational
423
+ case wait : Wait => wait.isInRTDomain
424
+ case _ : StepBlock => true
425
+ case _ : Goto => true
426
+ case cb : DFConditional .Block =>
427
+ cb.members(MemberView .Folded ).exists(_.consumesCycles)
428
+ case _ => false
429
+ end extension
0 commit comments