2014-09-13 00:31:38 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
2012-10-16 23:26:33 +02:00
|
|
|
package uncore
|
|
|
|
import Chisel._
|
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
case object TLCoherence extends Field[CoherencePolicyWithUncached]
|
|
|
|
case object TLAddrBits extends Field[Int]
|
|
|
|
case object TLMasterXactIdBits extends Field[Int]
|
|
|
|
case object TLClientXactIdBits extends Field[Int]
|
|
|
|
case object TLDataBits extends Field[Int]
|
|
|
|
case object TLWriteMaskBits extends Field[Int]
|
|
|
|
case object TLWordAddrBits extends Field[Int]
|
|
|
|
case object TLAtomicOpBits extends Field[Int]
|
|
|
|
|
|
|
|
trait HasPhysicalAddress extends Bundle {
|
|
|
|
val addr = UInt(width = params(TLAddrBits))
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
trait HasClientTransactionId extends Bundle {
|
|
|
|
val client_xact_id = Bits(width = params(TLClientXactIdBits))
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
trait HasMasterTransactionId extends Bundle {
|
|
|
|
val master_xact_id = Bits(width = params(TLMasterXactIdBits))
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
trait HasTileLinkData extends Bundle {
|
|
|
|
val data = Bits(width = params(TLDataBits))
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-03-20 22:10:16 +01:00
|
|
|
trait SourcedMessage extends Bundle
|
|
|
|
trait ClientSourcedMessage extends SourcedMessage
|
|
|
|
trait MasterSourcedMessage extends SourcedMessage
|
|
|
|
|
2013-01-22 02:17:26 +01:00
|
|
|
object Acquire
|
2012-10-16 23:26:33 +02:00
|
|
|
{
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(a_type: Bits, addr: UInt, client_xact_id: UInt): Acquire = {
|
2013-01-22 02:17:26 +01:00
|
|
|
val acq = new Acquire
|
|
|
|
acq.a_type := a_type
|
|
|
|
acq.addr := addr
|
|
|
|
acq.client_xact_id := client_xact_id
|
2014-03-29 18:53:49 +01:00
|
|
|
acq.data := Bits(0)
|
2013-08-02 23:55:06 +02:00
|
|
|
acq.write_mask := Bits(0)
|
|
|
|
acq.subword_addr := Bits(0)
|
|
|
|
acq.atomic_opcode := Bits(0)
|
2013-01-22 02:17:26 +01:00
|
|
|
acq
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(a_type: Bits, addr: UInt, client_xact_id: UInt, data: UInt): Acquire = {
|
2013-08-13 08:15:54 +02:00
|
|
|
val acq = apply(a_type, addr, client_xact_id)
|
2014-03-29 18:53:49 +01:00
|
|
|
acq.data := data
|
|
|
|
acq
|
|
|
|
}
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(a_type: UInt, addr: UInt, client_xact_id: UInt, write_mask: Bits, data: UInt): Acquire = {
|
2014-03-29 18:53:49 +01:00
|
|
|
val acq = apply(a_type, addr, client_xact_id, data)
|
2013-01-22 02:17:26 +01:00
|
|
|
acq.write_mask := write_mask
|
|
|
|
acq
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(a_type: UInt, addr: UInt, client_xact_id: UInt, subword_addr: UInt, atomic_opcode: UInt, data: UInt): Acquire = {
|
2014-03-29 18:53:49 +01:00
|
|
|
val acq = apply(a_type, addr, client_xact_id, data)
|
2013-01-22 02:17:26 +01:00
|
|
|
acq.subword_addr := subword_addr
|
|
|
|
acq.atomic_opcode := atomic_opcode
|
|
|
|
acq
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(a: Acquire): Acquire = {
|
2014-01-21 21:20:55 +01:00
|
|
|
val acq = new Acquire
|
|
|
|
acq := a
|
|
|
|
acq
|
|
|
|
}
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
2014-03-29 18:53:49 +01:00
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
class Acquire extends ClientSourcedMessage
|
2014-03-29 18:53:49 +01:00
|
|
|
with HasPhysicalAddress
|
|
|
|
with HasClientTransactionId
|
|
|
|
with HasTileLinkData {
|
2014-08-08 21:21:57 +02:00
|
|
|
val a_type = UInt(width = params(TLCoherence).acquireTypeWidth)
|
|
|
|
val write_mask = Bits(width = params(TLWriteMaskBits))
|
|
|
|
val subword_addr = Bits(width = params(TLWordAddrBits))
|
|
|
|
val atomic_opcode = Bits(width = params(TLAtomicOpBits))
|
2013-08-02 23:55:06 +02:00
|
|
|
}
|
2012-10-16 23:26:33 +02:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
object Probe
|
|
|
|
{
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(p_type: UInt, addr: UInt, master_xact_id: UInt) = {
|
2014-01-21 21:20:55 +01:00
|
|
|
val prb = new Probe
|
|
|
|
prb.p_type := p_type
|
|
|
|
prb.addr := addr
|
|
|
|
prb.master_xact_id := master_xact_id
|
|
|
|
prb
|
|
|
|
}
|
|
|
|
}
|
2014-03-29 18:53:49 +01:00
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
class Probe extends MasterSourcedMessage
|
2014-03-29 18:53:49 +01:00
|
|
|
with HasPhysicalAddress
|
|
|
|
with HasMasterTransactionId {
|
2014-08-08 21:21:57 +02:00
|
|
|
val p_type = UInt(width = params(TLCoherence).probeTypeWidth)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-01-29 01:39:45 +01:00
|
|
|
object Release
|
|
|
|
{
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(r_type: UInt, addr: UInt, data: UInt): Release = {
|
2014-01-21 21:20:55 +01:00
|
|
|
val rel = new Release
|
|
|
|
rel.r_type := r_type
|
|
|
|
rel.addr := addr
|
2014-03-29 18:53:49 +01:00
|
|
|
rel.data := data
|
2014-01-21 21:20:55 +01:00
|
|
|
rel
|
|
|
|
}
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(r_type: UInt, addr: UInt, client_xact_id: UInt, master_xact_id: UInt): Release = {
|
2013-01-29 01:39:45 +01:00
|
|
|
val rel = new Release
|
|
|
|
rel.r_type := r_type
|
|
|
|
rel.addr := addr
|
|
|
|
rel.client_xact_id := client_xact_id
|
|
|
|
rel.master_xact_id := master_xact_id
|
2014-03-29 18:53:49 +01:00
|
|
|
rel.data := UInt(0)
|
|
|
|
rel
|
|
|
|
}
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(r_type: UInt, addr: UInt, client_xact_id: UInt, master_xact_id: UInt, data: UInt): Release = {
|
2014-03-29 18:53:49 +01:00
|
|
|
val rel = apply(r_type, addr, client_xact_id, master_xact_id)
|
|
|
|
rel.data := data
|
2013-01-29 01:39:45 +01:00
|
|
|
rel
|
|
|
|
}
|
|
|
|
}
|
2014-03-29 18:53:49 +01:00
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
class Release extends ClientSourcedMessage
|
2014-03-29 18:53:49 +01:00
|
|
|
with HasPhysicalAddress
|
|
|
|
with HasClientTransactionId
|
|
|
|
with HasMasterTransactionId
|
|
|
|
with HasTileLinkData {
|
2014-08-08 21:21:57 +02:00
|
|
|
val r_type = UInt(width = params(TLCoherence).releaseTypeWidth)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2014-03-29 18:53:49 +01:00
|
|
|
object Grant
|
|
|
|
{
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(g_type: UInt, client_xact_id: UInt, master_xact_id: UInt): Grant = {
|
2014-03-29 18:53:49 +01:00
|
|
|
val gnt = new Grant
|
|
|
|
gnt.g_type := g_type
|
|
|
|
gnt.client_xact_id := client_xact_id
|
|
|
|
gnt.master_xact_id := master_xact_id
|
|
|
|
gnt.data := UInt(0)
|
|
|
|
gnt
|
|
|
|
}
|
2014-08-08 21:21:57 +02:00
|
|
|
def apply(g_type: UInt, client_xact_id: UInt, master_xact_id: UInt, data: UInt): Grant = {
|
2014-03-29 18:53:49 +01:00
|
|
|
val gnt = apply(g_type, client_xact_id, master_xact_id)
|
|
|
|
gnt.data := data
|
|
|
|
gnt
|
|
|
|
}
|
|
|
|
}
|
2013-08-02 23:55:06 +02:00
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
class Grant extends MasterSourcedMessage
|
2014-03-29 18:53:49 +01:00
|
|
|
with HasTileLinkData
|
|
|
|
with HasClientTransactionId
|
|
|
|
with HasMasterTransactionId {
|
2014-08-08 21:21:57 +02:00
|
|
|
val g_type = UInt(width = params(TLCoherence).grantTypeWidth)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
class Finish extends ClientSourcedMessage with HasMasterTransactionId
|
2012-10-16 23:26:33 +02:00
|
|
|
|
2013-01-22 02:17:26 +01:00
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
class UncachedTileLinkIO extends Bundle {
|
2014-03-29 18:53:49 +01:00
|
|
|
val acquire = new DecoupledIO(new LogicalNetworkIO(new Acquire))
|
2014-01-21 21:20:55 +01:00
|
|
|
val grant = new DecoupledIO(new LogicalNetworkIO(new Grant)).flip
|
2014-04-27 00:17:05 +02:00
|
|
|
val finish = new DecoupledIO(new LogicalNetworkIO(new Finish))
|
2013-03-20 22:10:16 +01:00
|
|
|
}
|
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
class TileLinkIO extends UncachedTileLinkIO {
|
2014-01-21 21:20:55 +01:00
|
|
|
val probe = new DecoupledIO(new LogicalNetworkIO(new Probe)).flip
|
2014-03-29 18:53:49 +01:00
|
|
|
val release = new DecoupledIO(new LogicalNetworkIO(new Release))
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
2013-03-20 22:10:16 +01:00
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
abstract class TileLinkArbiterLike(val arbN: Int) extends Module {
|
2014-01-21 21:20:55 +01:00
|
|
|
type MasterSourcedWithId = MasterSourcedMessage with HasClientTransactionId
|
|
|
|
type ClientSourcedWithId = ClientSourcedMessage with HasClientTransactionId
|
|
|
|
|
|
|
|
def clientSourcedClientXactId(in: ClientSourcedWithId, id: Int): Bits
|
|
|
|
def masterSourcedClientXactId(in: MasterSourcedWithId): Bits
|
|
|
|
def arbIdx(in: MasterSourcedWithId): UInt
|
|
|
|
|
2014-03-29 18:53:49 +01:00
|
|
|
def hookupClientSource[M <: ClientSourcedWithId]
|
|
|
|
(ins: Seq[DecoupledIO[LogicalNetworkIO[M]]],
|
|
|
|
out: DecoupledIO[LogicalNetworkIO[M]]) {
|
2014-08-08 21:21:57 +02:00
|
|
|
def hasData(m: LogicalNetworkIO[M]) = params(TLCoherence).messageHasData(m.payload)
|
2014-03-29 18:53:49 +01:00
|
|
|
val arb = Module(new RRArbiter(out.bits.clone, arbN))
|
2014-01-21 21:20:55 +01:00
|
|
|
out <> arb.io.out
|
|
|
|
ins.zipWithIndex.zip(arb.io.in).map{ case ((req,id), arb) => {
|
2014-03-29 18:53:49 +01:00
|
|
|
arb.valid := req.valid
|
|
|
|
arb.bits := req.bits
|
|
|
|
arb.bits.payload.client_xact_id := clientSourcedClientXactId(req.bits.payload, id)
|
|
|
|
req.ready := arb.ready
|
2014-01-21 21:20:55 +01:00
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
def hookupMasterSource[M <: MasterSourcedWithId]
|
|
|
|
(ins: Seq[DecoupledIO[LogicalNetworkIO[M]]],
|
2014-03-29 18:53:49 +01:00
|
|
|
out: DecoupledIO[LogicalNetworkIO[M]]) {
|
2014-01-21 21:20:55 +01:00
|
|
|
out.ready := Bool(false)
|
|
|
|
for (i <- 0 until arbN) {
|
|
|
|
ins(i).valid := Bool(false)
|
|
|
|
when (arbIdx(out.bits.payload) === UInt(i)) {
|
|
|
|
ins(i).valid := out.valid
|
|
|
|
out.ready := ins(i).ready
|
|
|
|
}
|
|
|
|
ins(i).bits := out.bits
|
|
|
|
ins(i).bits.payload.client_xact_id := masterSourcedClientXactId(out.bits.payload)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
abstract class UncachedTileLinkIOArbiter(n: Int)
|
|
|
|
extends TileLinkArbiterLike(n) {
|
2013-03-20 22:10:16 +01:00
|
|
|
val io = new Bundle {
|
2013-08-12 19:36:44 +02:00
|
|
|
val in = Vec.fill(n){new UncachedTileLinkIO}.flip
|
2013-03-20 22:10:16 +01:00
|
|
|
val out = new UncachedTileLinkIO
|
|
|
|
}
|
2014-01-21 21:20:55 +01:00
|
|
|
|
|
|
|
hookupClientSource(io.in.map(_.acquire), io.out.acquire)
|
|
|
|
hookupMasterSource(io.in.map(_.grant), io.out.grant)
|
2013-07-10 00:37:42 +02:00
|
|
|
|
2014-04-27 00:17:05 +02:00
|
|
|
val finish_arb = Module(new RRArbiter(new LogicalNetworkIO(new Finish), n))
|
|
|
|
io.out.finish <> finish_arb.io.out
|
|
|
|
finish_arb.io.in zip io.in map { case (arb, req) => arb <> req.finish }
|
2014-01-21 21:20:55 +01:00
|
|
|
}
|
2013-03-20 22:10:16 +01:00
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
abstract class TileLinkIOArbiter(n: Int) extends TileLinkArbiterLike(n) {
|
2014-01-21 21:20:55 +01:00
|
|
|
val io = new Bundle {
|
|
|
|
val in = Vec.fill(n){new TileLinkIO}.flip
|
|
|
|
val out = new TileLinkIO
|
2013-07-10 00:37:42 +02:00
|
|
|
}
|
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
hookupClientSource(io.in.map(_.acquire), io.out.acquire)
|
|
|
|
hookupClientSource(io.in.map(_.release), io.out.release)
|
|
|
|
hookupMasterSource(io.in.map(_.grant), io.out.grant)
|
2013-08-13 09:01:11 +02:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
io.in.map{ _.probe.valid := io.out.probe.valid }
|
|
|
|
io.in.map{ _.probe.bits := io.out.probe.bits }
|
|
|
|
io.out.probe.ready := io.in.map(_.probe.ready).reduce(_||_)
|
2013-07-10 00:37:42 +02:00
|
|
|
|
2014-04-27 00:17:05 +02:00
|
|
|
val finish_arb = Module(new RRArbiter(new LogicalNetworkIO(new Finish), n))
|
|
|
|
io.out.finish <> finish_arb.io.out
|
|
|
|
finish_arb.io.in zip io.in map { case (arb, req) => arb <> req.finish }
|
2013-07-10 00:37:42 +02:00
|
|
|
}
|
2014-01-21 21:20:55 +01:00
|
|
|
|
|
|
|
abstract trait AppendsArbiterId {
|
|
|
|
val arbN: Int
|
|
|
|
def clientSourcedClientXactId(in: ClientSourcedMessage with HasClientTransactionId, id: Int) =
|
|
|
|
Cat(in.client_xact_id, UInt(id, log2Up(arbN)))
|
|
|
|
def masterSourcedClientXactId(in: MasterSourcedMessage with HasClientTransactionId) =
|
|
|
|
in.client_xact_id >> UInt(log2Up(arbN))
|
|
|
|
def arbIdx(in: MasterSourcedMessage with HasClientTransactionId) =
|
|
|
|
in.client_xact_id(log2Up(arbN)-1,0).toUInt
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract trait PassesId {
|
|
|
|
def clientSourcedClientXactId(in: ClientSourcedMessage with HasClientTransactionId, id: Int) =
|
|
|
|
in.client_xact_id
|
|
|
|
def masterSourcedClientXactId(in: MasterSourcedMessage with HasClientTransactionId) =
|
|
|
|
in.client_xact_id
|
|
|
|
def arbIdx(in: MasterSourcedMessage with HasClientTransactionId) =
|
|
|
|
in.client_xact_id
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract trait UsesNewId {
|
|
|
|
val arbN: Int
|
|
|
|
def clientSourcedClientXactId(in: ClientSourcedMessage with HasClientTransactionId, id: Int) =
|
|
|
|
UInt(id, log2Up(arbN))
|
|
|
|
def masterSourcedClientXactId(in: MasterSourcedMessage with HasClientTransactionId) =
|
|
|
|
UInt(0)
|
|
|
|
def arbIdx(in: MasterSourcedMessage with HasClientTransactionId) =
|
|
|
|
in.client_xact_id
|
|
|
|
}
|
|
|
|
|
2014-08-08 21:21:57 +02:00
|
|
|
class UncachedTileLinkIOArbiterThatAppendsArbiterId(val n: Int) extends UncachedTileLinkIOArbiter(n) with AppendsArbiterId
|
|
|
|
class UncachedTileLinkIOArbiterThatPassesId(val n: Int) extends UncachedTileLinkIOArbiter(n) with PassesId
|
|
|
|
class UncachedTileLinkIOArbiterThatUsesNewId(val n: Int) extends UncachedTileLinkIOArbiter(n) with UsesNewId
|
|
|
|
class TileLinkIOArbiterThatAppendsArbiterId(val n: Int) extends TileLinkIOArbiter(n) with AppendsArbiterId
|
|
|
|
class TileLinkIOArbiterThatPassesId(val n: Int) extends TileLinkIOArbiter(n) with PassesId
|
|
|
|
class TileLinkIOArbiterThatUsesNewId(val n: Int) extends TileLinkIOArbiter(n) with UsesNewId
|