|
|
@ -122,50 +122,53 @@ object BaseNode
|
|
|
|
trait NoHandle
|
|
|
|
trait NoHandle
|
|
|
|
case object NoHandleObject extends NoHandle
|
|
|
|
case object NoHandleObject extends NoHandle
|
|
|
|
|
|
|
|
|
|
|
|
trait NodeHandle[DI, UI, BI <: Data, DO, UO, BO <: Data]
|
|
|
|
trait NodeHandle[DI, UI, EI, BI <: Data, DO, UO, EO, BO <: Data]
|
|
|
|
extends InwardNodeHandle[DI, UI, BI] with OutwardNodeHandle[DO, UO, BO]
|
|
|
|
extends InwardNodeHandle[DI, UI, EI, BI] with OutwardNodeHandle[DO, UO, EO, BO]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// connecting two full nodes => full node
|
|
|
|
// connecting two full nodes => full node
|
|
|
|
override def := [DX, UX, BX <: Data](h: NodeHandle[DX, UX, BX, DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NodeHandle[DX, UX, BX, DO, UO, BO] = { bind(h, BIND_ONCE); NodeHandle(h, this) }
|
|
|
|
override def := [DX, UX, EX, BX <: Data, EY](h: NodeHandle[DX, UX, EX, BX, DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NodeHandle[DX, UX, EX, BX, DO, UO, EO, BO] = { bind(h, BIND_ONCE); NodeHandle(h, this) }
|
|
|
|
override def :*= [DX, UX, BX <: Data](h: NodeHandle[DX, UX, BX, DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NodeHandle[DX, UX, BX, DO, UO, BO] = { bind(h, BIND_STAR); NodeHandle(h, this) }
|
|
|
|
override def :*= [DX, UX, EX, BX <: Data, EY](h: NodeHandle[DX, UX, EX, BX, DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NodeHandle[DX, UX, EX, BX, DO, UO, EO, BO] = { bind(h, BIND_STAR); NodeHandle(h, this) }
|
|
|
|
override def :=* [DX, UX, BX <: Data](h: NodeHandle[DX, UX, BX, DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NodeHandle[DX, UX, BX, DO, UO, BO] = { bind(h, BIND_QUERY); NodeHandle(h, this) }
|
|
|
|
override def :=* [DX, UX, EX, BX <: Data, EY](h: NodeHandle[DX, UX, EX, BX, DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NodeHandle[DX, UX, EX, BX, DO, UO, EO, BO] = { bind(h, BIND_QUERY); NodeHandle(h, this) }
|
|
|
|
override def :=? [DX, UX, BX <: Data](h: NodeHandle[DX, UX, BX, DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NodeHandle[DX, UX, BX, DO, UO, BO] = { bind(h, p(CardinalityInferenceDirectionKey)); NodeHandle(h, this) }
|
|
|
|
override def :=? [DX, UX, EX, BX <: Data, EY](h: NodeHandle[DX, UX, EX, BX, DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NodeHandle[DX, UX, EX, BX, DO, UO, EO, BO] = { bind(h, p(CardinalityInferenceDirectionKey)); NodeHandle(h, this) }
|
|
|
|
// connecting a full node with an output => an output
|
|
|
|
// connecting a full node with an output => an output
|
|
|
|
override def := (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): OutwardNodeHandle[DO, UO, BO] = { bind(h, BIND_ONCE); this }
|
|
|
|
override def := [EY](h: OutwardNodeHandle[DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): OutwardNodeHandle[DO, UO, EO, BO] = { bind(h, BIND_ONCE); this }
|
|
|
|
override def :*= (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): OutwardNodeHandle[DO, UO, BO] = { bind(h, BIND_STAR); this }
|
|
|
|
override def :*= [EY](h: OutwardNodeHandle[DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): OutwardNodeHandle[DO, UO, EO, BO] = { bind(h, BIND_STAR); this }
|
|
|
|
override def :=* (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): OutwardNodeHandle[DO, UO, BO] = { bind(h, BIND_QUERY); this }
|
|
|
|
override def :=* [EY](h: OutwardNodeHandle[DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): OutwardNodeHandle[DO, UO, EO, BO] = { bind(h, BIND_QUERY); this }
|
|
|
|
override def :=? (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): OutwardNodeHandle[DO, UO, BO] = { bind(h, p(CardinalityInferenceDirectionKey)); this }
|
|
|
|
override def :=? [EY](h: OutwardNodeHandle[DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): OutwardNodeHandle[DO, UO, EO, BO] = { bind(h, p(CardinalityInferenceDirectionKey)); this }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
object NodeHandle
|
|
|
|
object NodeHandle
|
|
|
|
{
|
|
|
|
{
|
|
|
|
def apply[DI, UI, BI <: Data, DO, UO, BO <: Data](i: InwardNodeHandle[DI, UI, BI], o: OutwardNodeHandle[DO, UO, BO]) = NodeHandlePair(i, o)
|
|
|
|
def apply[DI, UI, EI, BI <: Data, DO, UO, EO, BO <: Data](i: InwardNodeHandle[DI, UI, EI, BI], o: OutwardNodeHandle[DO, UO, EO, BO]) = new NodeHandlePair(i, o)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case class NodeHandlePair[DI, UI, BI <: Data, DO, UO, BO <: Data]
|
|
|
|
class NodeHandlePair[DI, UI, EI, BI <: Data, DO, UO, EO, BO <: Data]
|
|
|
|
(inwardHandle: InwardNodeHandle[DI, UI, BI], outwardHandle: OutwardNodeHandle[DO, UO, BO])
|
|
|
|
(inwardHandle: InwardNodeHandle[DI, UI, EI, BI], outwardHandle: OutwardNodeHandle[DO, UO, EO, BO])
|
|
|
|
extends NodeHandle[DI, UI, BI, DO, UO, BO]
|
|
|
|
extends NodeHandle[DI, UI, EI, BI, DO, UO, EO, BO]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
val inward = inwardHandle.inward
|
|
|
|
val inward = inwardHandle.inward
|
|
|
|
val outward = outwardHandle.outward
|
|
|
|
val outward = outwardHandle.outward
|
|
|
|
|
|
|
|
def inner = inwardHandle.inner
|
|
|
|
|
|
|
|
def outer = outwardHandle.outer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trait InwardNodeHandle[DI, UI, BI <: Data] extends NoHandle
|
|
|
|
trait InwardNodeHandle[DI, UI, EI, BI <: Data] extends NoHandle
|
|
|
|
{
|
|
|
|
{
|
|
|
|
def inward: InwardNode[DI, UI, BI]
|
|
|
|
def inward: InwardNode[DI, UI, BI]
|
|
|
|
def parentsIn: Seq[LazyModule] = inward.parents
|
|
|
|
def inner: InwardNodeImp[DI, UI, EI, BI]
|
|
|
|
def bind(h: OutwardNodeHandle[DI, UI, BI], binding: NodeBinding)(implicit p: Parameters, sourceInfo: SourceInfo): Unit = inward.bind(h.outward, binding)
|
|
|
|
|
|
|
|
|
|
|
|
protected def bind[EY](h: OutwardNodeHandle[DI, UI, EY, BI], binding: NodeBinding)(implicit p: Parameters, sourceInfo: SourceInfo): Unit = inward.bind(h.outward, binding)
|
|
|
|
|
|
|
|
|
|
|
|
// connecting an input node with a full nodes => an input node
|
|
|
|
// connecting an input node with a full nodes => an input node
|
|
|
|
def := [DX, UX, BX <: Data](h: NodeHandle[DX, UX, BX, DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): InwardNodeHandle[DX, UX, BX] = { bind(h, BIND_ONCE); h }
|
|
|
|
def := [DX, UX, EX, BX <: Data, EY](h: NodeHandle[DX, UX, EX, BX, DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): InwardNodeHandle[DX, UX, EX, BX] = { bind(h, BIND_ONCE); h }
|
|
|
|
def :*= [DX, UX, BX <: Data](h: NodeHandle[DX, UX, BX, DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): InwardNodeHandle[DX, UX, BX] = { bind(h, BIND_STAR); h }
|
|
|
|
def :*= [DX, UX, EX, BX <: Data, EY](h: NodeHandle[DX, UX, EX, BX, DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): InwardNodeHandle[DX, UX, EX, BX] = { bind(h, BIND_STAR); h }
|
|
|
|
def :=* [DX, UX, BX <: Data](h: NodeHandle[DX, UX, BX, DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): InwardNodeHandle[DX, UX, BX] = { bind(h, BIND_QUERY); h }
|
|
|
|
def :=* [DX, UX, EX, BX <: Data, EY](h: NodeHandle[DX, UX, EX, BX, DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): InwardNodeHandle[DX, UX, EX, BX] = { bind(h, BIND_QUERY); h }
|
|
|
|
def :=? [DX, UX, BX <: Data](h: NodeHandle[DX, UX, BX, DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): InwardNodeHandle[DX, UX, BX] = { bind(h, p(CardinalityInferenceDirectionKey)); h }
|
|
|
|
def :=? [DX, UX, EX, BX <: Data, EY](h: NodeHandle[DX, UX, EX, BX, DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): InwardNodeHandle[DX, UX, EX, BX] = { bind(h, p(CardinalityInferenceDirectionKey)); h }
|
|
|
|
// connecting input node with output node => no node
|
|
|
|
// connecting input node with output node => no node
|
|
|
|
def := (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NoHandle = { bind(h, BIND_ONCE); NoHandleObject }
|
|
|
|
def := [EY](h: OutwardNodeHandle[DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NoHandle = { bind(h, BIND_ONCE); NoHandleObject }
|
|
|
|
def :*= (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NoHandle = { bind(h, BIND_STAR); NoHandleObject }
|
|
|
|
def :*= [EY](h: OutwardNodeHandle[DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NoHandle = { bind(h, BIND_STAR); NoHandleObject }
|
|
|
|
def :=* (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NoHandle = { bind(h, BIND_QUERY); NoHandleObject }
|
|
|
|
def :=* [EY](h: OutwardNodeHandle[DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NoHandle = { bind(h, BIND_QUERY); NoHandleObject }
|
|
|
|
def :=? (h: OutwardNodeHandle[DI, UI, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NoHandle = { bind(h, p(CardinalityInferenceDirectionKey)); NoHandleObject }
|
|
|
|
def :=? [EY](h: OutwardNodeHandle[DI, UI, EY, BI])(implicit p: Parameters, sourceInfo: SourceInfo): NoHandle = { bind(h, p(CardinalityInferenceDirectionKey)); NoHandleObject }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sealed trait NodeBinding
|
|
|
|
sealed trait NodeBinding
|
|
|
@ -182,10 +185,8 @@ object NodeBinding
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trait InwardNode[DI, UI, BI <: Data] extends BaseNode with InwardNodeHandle[DI, UI, BI]
|
|
|
|
trait InwardNode[DI, UI, BI <: Data] extends BaseNode
|
|
|
|
{
|
|
|
|
{
|
|
|
|
val inward = this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected[diplomacy] val numPI: Range.Inclusive
|
|
|
|
protected[diplomacy] val numPI: Range.Inclusive
|
|
|
|
require (!numPI.isEmpty, s"No number of inputs would be acceptable to ${name}${lazyModule.line}")
|
|
|
|
require (!numPI.isEmpty, s"No number of inputs would be acceptable to ${name}${lazyModule.line}")
|
|
|
|
require (numPI.start >= 0, s"${name} accepts a negative number of inputs${lazyModule.line}")
|
|
|
|
require (numPI.start >= 0, s"${name} accepts a negative number of inputs${lazyModule.line}")
|
|
|
@ -211,16 +212,14 @@ trait InwardNode[DI, UI, BI <: Data] extends BaseNode with InwardNodeHandle[DI,
|
|
|
|
protected[diplomacy] def bind(h: OutwardNode[DI, UI, BI], binding: NodeBinding)(implicit p: Parameters, sourceInfo: SourceInfo): Unit
|
|
|
|
protected[diplomacy] def bind(h: OutwardNode[DI, UI, BI], binding: NodeBinding)(implicit p: Parameters, sourceInfo: SourceInfo): Unit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trait OutwardNodeHandle[DO, UO, BO <: Data] extends NoHandle
|
|
|
|
trait OutwardNodeHandle[DO, UO, EO, BO <: Data] extends NoHandle
|
|
|
|
{
|
|
|
|
{
|
|
|
|
def outward: OutwardNode[DO, UO, BO]
|
|
|
|
def outward: OutwardNode[DO, UO, BO]
|
|
|
|
def parentsOut: Seq[LazyModule] = outward.parents
|
|
|
|
def outer: OutwardNodeImp[DO, UO, EO, BO]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trait OutwardNode[DO, UO, BO <: Data] extends BaseNode with OutwardNodeHandle[DO, UO, BO]
|
|
|
|
trait OutwardNode[DO, UO, BO <: Data] extends BaseNode
|
|
|
|
{
|
|
|
|
{
|
|
|
|
val outward = this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected[diplomacy] val numPO: Range.Inclusive
|
|
|
|
protected[diplomacy] val numPO: Range.Inclusive
|
|
|
|
require (!numPO.isEmpty, s"No number of outputs would be acceptable to ${name}${lazyModule.line}")
|
|
|
|
require (!numPO.isEmpty, s"No number of outputs would be acceptable to ${name}${lazyModule.line}")
|
|
|
|
require (numPO.start >= 0, s"${name} accepts a negative number of outputs${lazyModule.line}")
|
|
|
|
require (numPO.start >= 0, s"${name} accepts a negative number of outputs${lazyModule.line}")
|
|
|
@ -251,13 +250,16 @@ case class UpwardCycleException(loop: Seq[String] = Nil) extends CycleException(
|
|
|
|
|
|
|
|
|
|
|
|
case class Edges[EI, EO](in: EI, out: EO)
|
|
|
|
case class Edges[EI, EO](in: EI, out: EO)
|
|
|
|
sealed abstract class MixedNode[DI, UI, EI, BI <: Data, DO, UO, EO, BO <: Data](
|
|
|
|
sealed abstract class MixedNode[DI, UI, EI, BI <: Data, DO, UO, EO, BO <: Data](
|
|
|
|
inner: InwardNodeImp [DI, UI, EI, BI],
|
|
|
|
val inner: InwardNodeImp [DI, UI, EI, BI],
|
|
|
|
outer: OutwardNodeImp[DO, UO, EO, BO])(
|
|
|
|
val outer: OutwardNodeImp[DO, UO, EO, BO])(
|
|
|
|
protected[diplomacy] val numPO: Range.Inclusive,
|
|
|
|
protected[diplomacy] val numPO: Range.Inclusive,
|
|
|
|
protected[diplomacy] val numPI: Range.Inclusive)(
|
|
|
|
protected[diplomacy] val numPI: Range.Inclusive)(
|
|
|
|
implicit valName: ValName)
|
|
|
|
implicit valName: ValName)
|
|
|
|
extends BaseNode with NodeHandle[DI, UI, BI, DO, UO, BO] with InwardNode[DI, UI, BI] with OutwardNode[DO, UO, BO]
|
|
|
|
extends BaseNode with NodeHandle[DI, UI, EI, BI, DO, UO, EO, BO] with InwardNode[DI, UI, BI] with OutwardNode[DO, UO, BO]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
val inward = this
|
|
|
|
|
|
|
|
val outward = this
|
|
|
|
|
|
|
|
|
|
|
|
protected[diplomacy] def resolveStar(iKnown: Int, oKnown: Int, iStar: Int, oStar: Int): (Int, Int)
|
|
|
|
protected[diplomacy] def resolveStar(iKnown: Int, oKnown: Int, iStar: Int, oStar: Int): (Int, Int)
|
|
|
|
protected[diplomacy] def mapParamsD(n: Int, p: Seq[DI]): Seq[DO]
|
|
|
|
protected[diplomacy] def mapParamsD(n: Int, p: Seq[DI]): Seq[DO]
|
|
|
|
protected[diplomacy] def mapParamsU(n: Int, p: Seq[UO]): Seq[UI]
|
|
|
|
protected[diplomacy] def mapParamsU(n: Int, p: Seq[UO]): Seq[UI]
|
|
|
|