2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
2016-08-19 20:08:35 +02:00
|
|
|
|
|
|
|
package uncore.tilelink2
|
|
|
|
|
2016-09-27 23:44:26 +02:00
|
|
|
import Chisel._
|
2016-10-13 03:09:01 +02:00
|
|
|
import chisel3.util.{ReadyValidIO}
|
2016-10-04 00:17:36 +02:00
|
|
|
import diplomacy._
|
2016-11-16 03:27:52 +01:00
|
|
|
import util._
|
2016-08-19 20:08:35 +02:00
|
|
|
|
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
|
2017-01-31 22:54:02 +01:00
|
|
|
def PutFullData = UInt(0) // . . => AccessAck
|
|
|
|
def PutPartialData = UInt(1) // . . => AccessAck
|
|
|
|
def ArithmeticData = UInt(2) // . . => AccessAckData
|
|
|
|
def LogicalData = UInt(3) // . . => AccessAckData
|
|
|
|
def Get = UInt(4) // . . => AccessAckData
|
|
|
|
def Hint = UInt(5) // . . => HintAck
|
|
|
|
def Acquire = UInt(6) // . => Grant[Data]
|
|
|
|
def Probe = UInt(6) // . => ProbeAck[Data]
|
|
|
|
def AccessAck = UInt(0) // . .
|
|
|
|
def AccessAckData = UInt(1) // . .
|
|
|
|
def HintAck = UInt(2) // . .
|
|
|
|
def ProbeAck = UInt(4) // .
|
|
|
|
def ProbeAckData = UInt(5) // .
|
|
|
|
def Release = UInt(6) // . => ReleaseAck
|
|
|
|
def ReleaseData = UInt(7) // . => ReleaseAck
|
|
|
|
def Grant = UInt(4) // . => GrantAck
|
|
|
|
def GrantData = UInt(5) // . => GrantAck
|
|
|
|
def ReleaseAck = UInt(6) // .
|
|
|
|
def 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
|
|
|
}
|
|
|
|
|
2016-11-11 00:56:42 +01:00
|
|
|
/**
|
|
|
|
* The three primary TileLink permissions are:
|
2016-11-18 19:08:39 +01:00
|
|
|
* (T)runk: the agent is (or is on inwards path to) the global point of serialization.
|
|
|
|
* (B)ranch: the agent is on an outwards path to
|
2016-11-11 00:56:42 +01:00
|
|
|
* (N)one:
|
|
|
|
* These permissions are permuted by transfer operations in various ways.
|
2016-11-18 19:08:39 +01:00
|
|
|
* Operations can cap permissions, request for them to be grown or shrunk,
|
|
|
|
* or for a report on their current status.
|
2016-11-11 00:56:42 +01:00
|
|
|
*/
|
2016-08-20 00:25:51 +02:00
|
|
|
object TLPermissions
|
|
|
|
{
|
2016-11-12 03:34:48 +01:00
|
|
|
val aWidth = 2
|
|
|
|
val bdWidth = 2
|
|
|
|
val cWidth = 3
|
|
|
|
|
2016-08-20 00:25:51 +02:00
|
|
|
// Cap types (Grant = new permissions, Probe = permisions <= target)
|
2017-01-31 22:54:02 +01:00
|
|
|
def toT = UInt(0, bdWidth)
|
|
|
|
def toB = UInt(1, bdWidth)
|
|
|
|
def toN = UInt(2, bdWidth)
|
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)
|
2017-01-31 22:54:02 +01:00
|
|
|
def NtoB = UInt(0, aWidth)
|
|
|
|
def NtoT = UInt(1, aWidth)
|
|
|
|
def BtoT = UInt(2, aWidth)
|
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)
|
2017-01-31 22:54:02 +01:00
|
|
|
def TtoB = UInt(0, cWidth)
|
|
|
|
def TtoN = UInt(1, cWidth)
|
|
|
|
def BtoN = UInt(2, cWidth)
|
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)
|
2017-01-31 22:54:02 +01:00
|
|
|
def TtoT = UInt(3, cWidth)
|
|
|
|
def BtoB = UInt(4, cWidth)
|
|
|
|
def NtoN = UInt(5, cWidth)
|
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-11-12 03:34:48 +01:00
|
|
|
val width = 3
|
|
|
|
|
2016-08-23 00:36:39 +02:00
|
|
|
// Arithmetic types
|
2017-01-31 22:54:02 +01:00
|
|
|
def MIN = UInt(0, width)
|
|
|
|
def MAX = UInt(1, width)
|
|
|
|
def MINU = UInt(2, width)
|
|
|
|
def MAXU = UInt(3, width)
|
|
|
|
def ADD = UInt(4, width)
|
2016-08-30 19:40:14 +02:00
|
|
|
def isArithmetic(x: UInt) = x <= ADD
|
2016-08-23 00:36:39 +02:00
|
|
|
|
|
|
|
// Logical types
|
2017-01-31 22:54:02 +01:00
|
|
|
def XOR = UInt(0, width)
|
|
|
|
def OR = UInt(1, width)
|
|
|
|
def AND = UInt(2, width)
|
|
|
|
def SWAP = UInt(3, width)
|
2016-08-30 19:40:14 +02:00
|
|
|
def isLogical(x: UInt) = x <= SWAP
|
2016-08-20 00:25:51 +02:00
|
|
|
}
|
|
|
|
|
2016-11-03 05:37:30 +01:00
|
|
|
object TLHints
|
|
|
|
{
|
2016-11-12 03:34:48 +01:00
|
|
|
val width = 1
|
|
|
|
|
2017-01-31 22:54:02 +01:00
|
|
|
def PREFETCH_READ = UInt(0, width)
|
|
|
|
def PREFETCH_WRITE = UInt(1, width)
|
2016-11-03 05:37:30 +01:00
|
|
|
}
|
|
|
|
|
2016-09-15 02:43:07 +02:00
|
|
|
sealed trait TLChannel extends TLBundleBase {
|
|
|
|
val channelName: String
|
|
|
|
}
|
2016-09-07 08:46:44 +02:00
|
|
|
sealed trait TLDataChannel extends TLChannel
|
|
|
|
sealed trait TLAddrChannel extends TLDataChannel
|
2016-08-24 01:23:35 +02:00
|
|
|
|
2016-09-07 08:46:44 +02:00
|
|
|
final class TLBundleA(params: TLBundleParameters)
|
|
|
|
extends TLBundleBase(params) with TLAddrChannel
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
2016-09-15 02:43:07 +02:00
|
|
|
val channelName = "'A' channel"
|
2016-09-01 20:34:56 +02:00
|
|
|
// fixed fields during multibeat:
|
2016-08-19 20:08:35 +02:00
|
|
|
val opcode = UInt(width = 3)
|
2016-11-12 03:34:48 +01:00
|
|
|
val param = UInt(width = List(TLAtomics.width, TLPermissions.aWidth, TLHints.width).max) // amo_opcode || grow perms || hint
|
2016-08-19 20:08:35 +02:00
|
|
|
val size = UInt(width = params.sizeBits)
|
2016-09-07 08:46:44 +02:00
|
|
|
val source = UInt(width = params.sourceBits) // from
|
2016-10-14 23:09:39 +02:00
|
|
|
val address = UInt(width = params.addressBits) // to
|
2016-09-01 20:34:56 +02:00
|
|
|
// variable fields during multibeat:
|
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-09-07 08:46:44 +02:00
|
|
|
final class TLBundleB(params: TLBundleParameters)
|
|
|
|
extends TLBundleBase(params) with TLAddrChannel
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
2016-09-15 02:43:07 +02:00
|
|
|
val channelName = "'B' channel"
|
2016-09-01 20:34:56 +02:00
|
|
|
// fixed fields during multibeat:
|
2016-08-19 20:08:35 +02:00
|
|
|
val opcode = UInt(width = 3)
|
2016-11-12 03:34:48 +01:00
|
|
|
val param = UInt(width = TLPermissions.bdWidth) // cap perms
|
2016-08-19 20:08:35 +02:00
|
|
|
val size = UInt(width = params.sizeBits)
|
2016-09-07 08:46:44 +02:00
|
|
|
val source = UInt(width = params.sourceBits) // to
|
2016-10-14 23:09:39 +02:00
|
|
|
val address = UInt(width = params.addressBits) // from
|
2016-09-01 20:34:56 +02:00
|
|
|
// variable fields during multibeat:
|
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-09-07 08:46:44 +02:00
|
|
|
final class TLBundleC(params: TLBundleParameters)
|
|
|
|
extends TLBundleBase(params) with TLAddrChannel
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
2016-09-15 02:43:07 +02:00
|
|
|
val channelName = "'C' channel"
|
2016-09-01 20:34:56 +02:00
|
|
|
// fixed fields during multibeat:
|
2016-08-19 20:08:35 +02:00
|
|
|
val opcode = UInt(width = 3)
|
2016-11-12 03:34:48 +01:00
|
|
|
val param = UInt(width = TLPermissions.cWidth) // shrink or report perms
|
2016-08-19 20:08:35 +02:00
|
|
|
val size = UInt(width = params.sizeBits)
|
2016-09-07 08:46:44 +02:00
|
|
|
val source = UInt(width = params.sourceBits) // from
|
2016-10-14 23:09:39 +02:00
|
|
|
val address = UInt(width = params.addressBits) // to
|
2016-09-01 20:34:56 +02:00
|
|
|
// variable fields during multibeat:
|
2016-08-19 20:08:35 +02:00
|
|
|
val data = UInt(width = params.dataBits)
|
2016-08-30 23:38:26 +02:00
|
|
|
val error = Bool() // AccessAck[Data]
|
2016-08-19 20:08:35 +02:00
|
|
|
}
|
|
|
|
|
2016-09-07 08:46:44 +02:00
|
|
|
final class TLBundleD(params: TLBundleParameters)
|
|
|
|
extends TLBundleBase(params) with TLDataChannel
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
2016-09-15 02:43:07 +02:00
|
|
|
val channelName = "'D' channel"
|
2016-09-01 20:34:56 +02:00
|
|
|
// fixed fields during multibeat:
|
2016-09-07 08:46:44 +02:00
|
|
|
val opcode = UInt(width = 3)
|
2016-11-12 03:34:48 +01:00
|
|
|
val param = UInt(width = TLPermissions.bdWidth) // cap perms
|
2016-09-07 08:46:44 +02:00
|
|
|
val size = UInt(width = params.sizeBits)
|
|
|
|
val source = UInt(width = params.sourceBits) // to
|
|
|
|
val sink = UInt(width = params.sinkBits) // from
|
|
|
|
val addr_lo = UInt(width = params.addrLoBits) // instead of mask
|
2016-09-01 20:34:56 +02:00
|
|
|
// variable fields during multibeat:
|
2016-09-07 08:46:44 +02:00
|
|
|
val data = UInt(width = params.dataBits)
|
|
|
|
val error = Bool() // AccessAck[Data], Grant[Data]
|
2016-08-19 20:08:35 +02:00
|
|
|
}
|
|
|
|
|
2016-09-07 08:46:44 +02:00
|
|
|
final class TLBundleE(params: TLBundleParameters)
|
|
|
|
extends TLBundleBase(params) with TLChannel
|
2016-08-19 20:08:35 +02:00
|
|
|
{
|
2016-09-15 02:43:07 +02:00
|
|
|
val channelName = "'E' channel"
|
2016-09-08 21:14:55 +02:00
|
|
|
val sink = UInt(width = params.sinkBits) // to
|
2016-08-19 20:08:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class TLBundle(params: TLBundleParameters) extends TLBundleBase(params)
|
|
|
|
{
|
2016-10-13 03:09:01 +02:00
|
|
|
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-19 20:08:35 +02:00
|
|
|
}
|
2016-08-24 22:50:11 +02:00
|
|
|
|
|
|
|
object TLBundle
|
|
|
|
{
|
|
|
|
def apply(params: TLBundleParameters) = new TLBundle(params)
|
|
|
|
}
|
2016-09-21 21:04:52 +02:00
|
|
|
|
2016-10-13 03:09:01 +02:00
|
|
|
final class DecoupledSnoop[+T <: Data](gen: T) extends Bundle
|
2016-09-21 21:04:52 +02:00
|
|
|
{
|
|
|
|
val ready = Bool()
|
|
|
|
val valid = Bool()
|
|
|
|
val bits = gen.asOutput
|
|
|
|
|
|
|
|
def fire(dummy: Int = 0) = ready && valid
|
2016-10-13 03:09:01 +02:00
|
|
|
override def cloneType: this.type = new DecoupledSnoop(gen).asInstanceOf[this.type]
|
2016-09-21 21:04:52 +02:00
|
|
|
}
|
|
|
|
|
2016-10-13 03:09:01 +02:00
|
|
|
object DecoupledSnoop
|
2016-09-21 21:04:52 +02:00
|
|
|
{
|
2017-01-30 02:25:14 +01:00
|
|
|
def apply[T <: Data](source: DecoupledIO[T], sink: DecoupledIO[T]) = {
|
|
|
|
val out = Wire(new DecoupledSnoop(sink.bits))
|
|
|
|
out.ready := sink.ready
|
|
|
|
out.valid := source.valid
|
|
|
|
out.bits := source.bits
|
2016-09-21 21:04:52 +02:00
|
|
|
out
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TLBundleSnoop(params: TLBundleParameters) extends TLBundleBase(params)
|
|
|
|
{
|
2016-10-13 03:09:01 +02:00
|
|
|
val a = new DecoupledSnoop(new TLBundleA(params))
|
|
|
|
val b = new DecoupledSnoop(new TLBundleB(params))
|
|
|
|
val c = new DecoupledSnoop(new TLBundleC(params))
|
|
|
|
val d = new DecoupledSnoop(new TLBundleD(params))
|
|
|
|
val e = new DecoupledSnoop(new TLBundleE(params))
|
2016-09-21 21:04:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
object TLBundleSnoop
|
|
|
|
{
|
2017-01-30 02:25:14 +01:00
|
|
|
def apply(source: TLBundle, sink: TLBundle) = {
|
|
|
|
val out = Wire(new TLBundleSnoop(sink.params))
|
|
|
|
out.a := DecoupledSnoop(source.a, sink.a)
|
|
|
|
out.b := DecoupledSnoop(sink.b, source.b)
|
|
|
|
out.c := DecoupledSnoop(source.c, sink.c)
|
|
|
|
out.d := DecoupledSnoop(sink.d, source.d)
|
|
|
|
out.e := DecoupledSnoop(source.e, sink.e)
|
2016-09-21 21:04:52 +02:00
|
|
|
out
|
|
|
|
}
|
|
|
|
}
|
2016-09-30 00:34:21 +02:00
|
|
|
|
|
|
|
class TLAsyncBundleBase(params: TLAsyncBundleParameters) extends GenericParameterizedBundle(params)
|
|
|
|
|
|
|
|
class TLAsyncBundle(params: TLAsyncBundleParameters) extends TLAsyncBundleBase(params)
|
|
|
|
{
|
|
|
|
val a = new AsyncBundle(params.depth, new TLBundleA(params.base))
|
|
|
|
val b = new AsyncBundle(params.depth, new TLBundleB(params.base)).flip
|
|
|
|
val c = new AsyncBundle(params.depth, new TLBundleC(params.base))
|
|
|
|
val d = new AsyncBundle(params.depth, new TLBundleD(params.base)).flip
|
|
|
|
val e = new AsyncBundle(params.depth, new TLBundleE(params.base))
|
|
|
|
}
|
2017-01-27 00:15:48 +01:00
|
|
|
|
|
|
|
class TLRationalBundle(params: TLBundleParameters) extends TLBundleBase(params)
|
|
|
|
{
|
|
|
|
val a = RationalIO(new TLBundleA(params))
|
|
|
|
val b = RationalIO(new TLBundleB(params)).flip
|
|
|
|
val c = RationalIO(new TLBundleC(params))
|
|
|
|
val d = RationalIO(new TLBundleD(params)).flip
|
|
|
|
val e = RationalIO(new TLBundleE(params))
|
|
|
|
}
|