2016-08-19 20:08:35 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
|
|
|
package uncore.tilelink2
|
|
|
|
|
|
|
|
import Chisel._
|
|
|
|
|
2016-08-30 02:02:04 +02:00
|
|
|
abstract class GenericParameterizedBundle[T <: Object](val params: T) extends Bundle
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
|
|
|
override def cloneType = {
|
|
|
|
try {
|
|
|
|
this.getClass.getConstructors.head.newInstance(params).asInstanceOf[this.type]
|
|
|
|
} catch {
|
|
|
|
case e: java.lang.IllegalArgumentException =>
|
2016-08-30 02:02:04 +02:00
|
|
|
throwException("Unable to use GenericParameterizedBundle.cloneType on " +
|
2016-08-19 20:08:35 +02:00
|
|
|
this.getClass + ", probably because " + this.getClass +
|
|
|
|
"() takes more than one argument. Consider overriding " +
|
|
|
|
"cloneType() on " + this.getClass, e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-30 02:02:04 +02:00
|
|
|
abstract class TLBundleBase(params: TLBundleParameters) extends GenericParameterizedBundle(params)
|
|
|
|
|
2016-08-24 01:23:35 +02:00
|
|
|
// common combos in lazy policy:
|
|
|
|
// Put + Acquire
|
|
|
|
// Release + AccessAck
|
|
|
|
|
2016-08-20 00:25:51 +02:00
|
|
|
object TLMessages
|
|
|
|
{
|
|
|
|
// A B C D E
|
2016-08-30 23:43:07 +02:00
|
|
|
val PutFullData = UInt(0) // . . => AccessAck
|
|
|
|
val PutPartialData = UInt(1) // . . => AccessAck
|
|
|
|
val ArithmeticData = UInt(2) // . . => AccessAckData
|
|
|
|
val LogicalData = UInt(3) // . . => AccessAckData
|
|
|
|
val Get = UInt(4) // . . => AccessAckData
|
|
|
|
val Hint = UInt(5) // . . => HintAck
|
|
|
|
val Acquire = UInt(6) // . => Grant[Data]
|
|
|
|
val Probe = UInt(6) // . => ProbeAck[Data]
|
2016-08-30 23:38:26 +02:00
|
|
|
val AccessAck = UInt(0) // . .
|
|
|
|
val AccessAckData = UInt(1) // . .
|
|
|
|
val HintAck = UInt(2) // . .
|
|
|
|
//val PutThroughData = UInt(3) // . // future extension ?
|
|
|
|
val ProbeAck = UInt(4) // .
|
|
|
|
val ProbeAckData = UInt(5) // .
|
2016-08-30 23:43:07 +02:00
|
|
|
val Release = UInt(6) // . => ReleaseAck
|
|
|
|
val ReleaseData = UInt(7) // . => ReleaseAck
|
|
|
|
val Grant = UInt(4) // . => GrantAck
|
|
|
|
val GrantData = UInt(5) // . => GrantAck
|
2016-08-30 23:38:26 +02:00
|
|
|
val ReleaseAck = UInt(6) // .
|
2016-08-20 00:25:51 +02:00
|
|
|
val GrantAck = UInt(0) // .
|
2016-08-23 00:36:39 +02:00
|
|
|
|
|
|
|
def isA(x: UInt) = x <= Acquire
|
|
|
|
def isB(x: UInt) = x <= Probe
|
|
|
|
def isC(x: UInt) = x <= ReleaseData
|
2016-08-30 23:38:26 +02:00
|
|
|
def isD(x: UInt) = x <= ReleaseAck
|
2016-08-20 00:25:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
object TLPermissions
|
|
|
|
{
|
|
|
|
// Cap types (Grant = new permissions, Probe = permisions <= target)
|
|
|
|
val toT = UInt(0)
|
|
|
|
val toB = UInt(1)
|
|
|
|
val toN = UInt(2)
|
2016-08-23 00:36:39 +02:00
|
|
|
def isCap(x: UInt) = x <= toN
|
2016-08-20 00:25:51 +02:00
|
|
|
|
|
|
|
// Grow types (Acquire = permissions >= target)
|
|
|
|
val NtoB = UInt(0)
|
|
|
|
val NtoT = UInt(1)
|
|
|
|
val BtoT = UInt(2)
|
2016-08-23 00:36:39 +02:00
|
|
|
def isGrow(x: UInt) = x <= BtoT
|
2016-08-20 00:25:51 +02:00
|
|
|
|
|
|
|
// Shrink types (ProbeAck, Release)
|
|
|
|
val TtoB = UInt(0)
|
|
|
|
val TtoN = UInt(1)
|
|
|
|
val BtoN = UInt(2)
|
2016-08-23 00:36:39 +02:00
|
|
|
def isShrink(x: UInt) = x <= BtoN
|
2016-08-20 00:25:51 +02:00
|
|
|
|
|
|
|
// Report types (ProbeAck)
|
|
|
|
val TtoT = UInt(3)
|
|
|
|
val BtoB = UInt(4)
|
|
|
|
val NtoN = UInt(5)
|
2016-08-23 00:36:39 +02:00
|
|
|
def isReport(x: UInt) = x <= NtoN
|
2016-08-20 00:25:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
object TLAtomics
|
|
|
|
{
|
2016-08-23 00:36:39 +02:00
|
|
|
// Arithmetic types
|
2016-08-30 19:40:14 +02:00
|
|
|
val MIN = UInt(0)
|
|
|
|
val MAX = UInt(1)
|
|
|
|
val MINU = UInt(2)
|
|
|
|
val MAXU = UInt(3)
|
|
|
|
val ADD = UInt(4)
|
|
|
|
def isArithmetic(x: UInt) = x <= ADD
|
2016-08-23 00:36:39 +02:00
|
|
|
|
|
|
|
// Logical types
|
2016-08-30 19:40:14 +02:00
|
|
|
val XOR = UInt(0)
|
|
|
|
val OR = UInt(1)
|
|
|
|
val AND = UInt(2)
|
|
|
|
val SWAP = UInt(3)
|
|
|
|
def isLogical(x: UInt) = x <= SWAP
|
2016-08-20 00:25:51 +02:00
|
|
|
}
|
|
|
|
|
2016-08-27 00:03:39 +02:00
|
|
|
class Bogus
|
|
|
|
object Bogus
|
|
|
|
{
|
|
|
|
def apply() = new Bogus
|
|
|
|
}
|
|
|
|
|
2016-08-24 01:23:35 +02:00
|
|
|
trait HasTLOpcode
|
|
|
|
{
|
|
|
|
// The data field in this message has value
|
2016-08-27 00:03:39 +02:00
|
|
|
def hasData(x: Bogus = Bogus()): Bool
|
2016-08-24 01:23:35 +02:00
|
|
|
// This message requires a response
|
2016-08-27 00:03:39 +02:00
|
|
|
def hasFollowUp(x: Bogus = Bogus()): Bool
|
2016-08-24 01:23:35 +02:00
|
|
|
// The size field of the opcode
|
2016-08-27 00:03:39 +02:00
|
|
|
def size(x: Bogus = Bogus()): UInt
|
2016-08-24 01:23:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
trait HasTLData extends HasTLOpcode
|
|
|
|
{
|
2016-08-27 00:03:39 +02:00
|
|
|
def data(x: Bogus = Bogus()): UInt
|
2016-08-31 00:06:37 +02:00
|
|
|
def mask(x: Bogus = Bogus()): UInt
|
2016-08-24 01:23:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class TLBundleA(params: TLBundleParameters)
|
|
|
|
extends TLBundleBase(params)
|
|
|
|
with HasTLData
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
|
|
|
val opcode = UInt(width = 3)
|
2016-08-20 03:39:21 +02:00
|
|
|
val param = UInt(width = 3) // amo_opcode || perms || hint
|
2016-08-19 20:08:35 +02:00
|
|
|
val size = UInt(width = params.sizeBits)
|
|
|
|
val source = UInt(width = params.sourceBits) // from
|
|
|
|
val address = UInt(width = params.addressBits) // to
|
2016-08-31 00:06:37 +02:00
|
|
|
val mask = UInt(width = params.dataBits/8)
|
2016-08-19 20:08:35 +02:00
|
|
|
val data = UInt(width = params.dataBits)
|
2016-08-24 01:23:35 +02:00
|
|
|
|
2016-08-27 00:03:39 +02:00
|
|
|
def hasData(x: Bogus = Bogus()) = !opcode(2)
|
2016-08-24 01:23:35 +02:00
|
|
|
// opcode === TLMessages.PutFullData ||
|
|
|
|
// opcode === TLMessages.PutPartialData ||
|
|
|
|
// opcode === TLMessages.ArithmeticData ||
|
|
|
|
// opcode === TLMessages.LogicalData
|
2016-08-27 00:03:39 +02:00
|
|
|
def hasFollowUp(x: Bogus = Bogus()) = Bool(true)
|
|
|
|
def size(x: Bogus = Bogus()) = size
|
|
|
|
def data(x: Bogus = Bogus()) = data
|
2016-08-31 00:06:37 +02:00
|
|
|
def mask(x: Bogus = Bogus()) = mask
|
2016-08-19 20:08:35 +02:00
|
|
|
}
|
|
|
|
|
2016-08-24 01:23:35 +02:00
|
|
|
class TLBundleB(params: TLBundleParameters)
|
|
|
|
extends TLBundleBase(params)
|
|
|
|
with HasTLData
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
|
|
|
val opcode = UInt(width = 3)
|
2016-08-20 03:39:21 +02:00
|
|
|
val param = UInt(width = 3)
|
2016-08-19 20:08:35 +02:00
|
|
|
val size = UInt(width = params.sizeBits)
|
|
|
|
val source = UInt(width = params.sourceBits) // to
|
|
|
|
val address = UInt(width = params.addressBits) // from
|
2016-08-31 00:06:37 +02:00
|
|
|
val mask = UInt(width = params.dataBits/8)
|
2016-08-19 20:08:35 +02:00
|
|
|
val data = UInt(width = params.dataBits)
|
2016-08-24 01:23:35 +02:00
|
|
|
|
2016-08-27 00:03:39 +02:00
|
|
|
def hasData(x: Bogus = Bogus()) = !opcode(2)
|
|
|
|
def hasFollowUp(x: Bogus = Bogus()) = Bool(true)
|
|
|
|
def size(x: Bogus = Bogus()) = size
|
|
|
|
def data(x: Bogus = Bogus()) = data
|
2016-08-31 00:06:37 +02:00
|
|
|
def mask(x: Bogus = Bogus()) = mask
|
2016-08-19 20:08:35 +02:00
|
|
|
}
|
|
|
|
|
2016-08-24 01:23:35 +02:00
|
|
|
class TLBundleC(params: TLBundleParameters)
|
|
|
|
extends TLBundleBase(params)
|
|
|
|
with HasTLData
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
|
|
|
val opcode = UInt(width = 3)
|
2016-08-20 00:25:51 +02:00
|
|
|
val param = UInt(width = 3)
|
2016-08-19 20:08:35 +02:00
|
|
|
val size = UInt(width = params.sizeBits)
|
2016-08-20 00:25:51 +02:00
|
|
|
val source = UInt(width = params.sourceBits) // from
|
2016-08-19 20:08:35 +02:00
|
|
|
val address = UInt(width = params.addressBits) // to
|
|
|
|
val data = UInt(width = params.dataBits)
|
2016-08-30 23:38:26 +02:00
|
|
|
val error = Bool() // AccessAck[Data]
|
2016-08-24 01:23:35 +02:00
|
|
|
|
2016-08-27 00:03:39 +02:00
|
|
|
def hasData(x: Bogus = Bogus()) = opcode(0)
|
2016-08-24 01:23:35 +02:00
|
|
|
// opcode === TLMessages.AccessAckData ||
|
|
|
|
// opcode === TLMessages.ProbeAckData ||
|
|
|
|
// opcode === TLMessages.ReleaseData
|
2016-08-30 23:38:26 +02:00
|
|
|
def hasFollowUp(x: Bogus = Bogus()) = opcode(2) && opcode(1)
|
2016-08-24 01:23:35 +02:00
|
|
|
// opcode === TLMessages.Release ||
|
|
|
|
// opcode === TLMessages.ReleaseData
|
2016-08-27 00:03:39 +02:00
|
|
|
def size(x: Bogus = Bogus()) = size
|
|
|
|
def data(x: Bogus = Bogus()) = data
|
2016-08-31 00:06:37 +02:00
|
|
|
def mask(x: Bogus = Bogus()) = SInt(-1, width = params.dataBits/8).asUInt
|
2016-08-19 20:08:35 +02:00
|
|
|
}
|
|
|
|
|
2016-08-24 01:23:35 +02:00
|
|
|
class TLBundleD(params: TLBundleParameters)
|
|
|
|
extends TLBundleBase(params)
|
|
|
|
with HasTLData
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
|
|
|
val opcode = UInt(width = 3)
|
2016-08-20 00:25:51 +02:00
|
|
|
val param = UInt(width = 2)
|
2016-08-19 20:08:35 +02:00
|
|
|
val size = UInt(width = params.sizeBits)
|
|
|
|
val source = UInt(width = params.sourceBits) // to
|
|
|
|
val sink = UInt(width = params.sinkBits) // from
|
|
|
|
val data = UInt(width = params.dataBits)
|
2016-08-30 23:38:26 +02:00
|
|
|
val error = Bool() // AccessAck[Data], Grant[Data]
|
2016-08-24 01:23:35 +02:00
|
|
|
|
2016-08-27 00:03:39 +02:00
|
|
|
def hasData(x: Bogus = Bogus()) = opcode(0)
|
2016-08-24 01:23:35 +02:00
|
|
|
// opcode === TLMessages.AccessAckData ||
|
|
|
|
// opcode === TLMessages.GrantData
|
2016-08-30 23:38:26 +02:00
|
|
|
def hasFollowUp(x: Bogus = Bogus()) = opcode(2) && !opcode(1)
|
2016-08-24 01:23:35 +02:00
|
|
|
// opcode === TLMessages.Grant ||
|
|
|
|
// opcode === TLMessages.GrantData
|
2016-08-27 00:03:39 +02:00
|
|
|
def size(x: Bogus = Bogus()) = size
|
|
|
|
def data(x: Bogus = Bogus()) = data
|
2016-08-31 00:06:37 +02:00
|
|
|
def mask(x: Bogus = Bogus()) = SInt(-1, width = params.dataBits/8).asUInt
|
2016-08-19 20:08:35 +02:00
|
|
|
}
|
|
|
|
|
2016-08-24 01:23:35 +02:00
|
|
|
class TLBundleE(params: TLBundleParameters)
|
|
|
|
extends TLBundleBase(params)
|
|
|
|
with HasTLOpcode
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
|
|
|
val sink = UInt(width = params.sourceBits) // to
|
2016-08-24 01:23:35 +02:00
|
|
|
|
2016-08-27 00:03:39 +02:00
|
|
|
def hasData(x: Bogus = Bogus()) = Bool(false)
|
|
|
|
def hasFollowUp(x: Bogus = Bogus()) = Bool(false)
|
|
|
|
def size(x: Bogus = Bogus()) = UInt(log2Up(params.dataBits/8))
|
2016-08-19 20:08:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class TLBundle(params: TLBundleParameters) extends TLBundleBase(params)
|
|
|
|
{
|
|
|
|
val a = Decoupled(new TLBundleA(params))
|
|
|
|
val b = Decoupled(new TLBundleB(params)).flip
|
|
|
|
val c = Decoupled(new TLBundleC(params))
|
|
|
|
val d = Decoupled(new TLBundleD(params)).flip
|
|
|
|
val e = Decoupled(new TLBundleE(params))
|
|
|
|
}
|
2016-08-24 22:50:11 +02:00
|
|
|
|
|
|
|
object TLBundle
|
|
|
|
{
|
|
|
|
def apply(params: TLBundleParameters) = new TLBundle(params)
|
|
|
|
}
|