1
0

diplomacy: leverage new Parameters defaults

This commit is contained in:
Wesley W. Terpstra 2017-09-07 13:33:07 -07:00
parent 655a08f12e
commit 7a8364ef08
2 changed files with 7 additions and 10 deletions

View File

@ -23,7 +23,8 @@ object CardinalityInferenceDirection {
case object NO_INFERENCE extends T
}
case object CardinalityInferenceDirectionKey extends Field[CardinalityInferenceDirection.T]
case object CardinalityInferenceDirectionKey extends
Field[CardinalityInferenceDirection.T](CardinalityInferenceDirection.NO_INFERENCE)
// DI = Downwards flowing Parameters received on the inner side of the node
// UI = Upwards flowing Parameters generated by the inner side of the node
@ -284,11 +285,10 @@ abstract class MixedNode[DI, UI, EI, BI <: Data, DO, UO, EO, BO <: Data](
override def :*= (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): Option[MonitorBase] = bind(h, BIND_STAR, true)
override def :=* (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): Option[MonitorBase] = bind(h, BIND_QUERY, true)
override def :=? (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): Option[MonitorBase] = {
p.lift(CardinalityInferenceDirectionKey) match {
case Some(CardinalityInferenceDirection.SOURCE_TO_SINK) => this :=* h
case Some(CardinalityInferenceDirection.SINK_TO_SOURCE) => this :*= h
case Some(CardinalityInferenceDirection.NO_INFERENCE) => this := h
case None => this := h
p(CardinalityInferenceDirectionKey) match {
case CardinalityInferenceDirection.SOURCE_TO_SINK => this :=* h
case CardinalityInferenceDirection.SINK_TO_SOURCE => this :*= h
case CardinalityInferenceDirection.NO_INFERENCE => this := h
}
}

View File

@ -32,9 +32,6 @@ package object diplomacy
case CardinalityInferenceDirectionKey => CardinalityInferenceDirection.NO_INFERENCE
})
def FlipStar[T](body: Parameters => T)(implicit p: Parameters) = body(p.alterPartial {
case CardinalityInferenceDirectionKey => p
.lift(CardinalityInferenceDirectionKey)
.map(_.flip)
.getOrElse(CardinalityInferenceDirection.NO_INFERENCE)
case CardinalityInferenceDirectionKey => p(CardinalityInferenceDirectionKey).flip
})
}