2012-10-16 23:26:33 +02:00
|
|
|
package uncore
|
|
|
|
import Chisel._
|
|
|
|
|
2014-04-02 02:14:45 +02:00
|
|
|
case class TileLinkConfiguration(co: CoherencePolicyWithUncached, ln: LogicalNetworkConfiguration, addrBits: Int, masterXactIdBits: Int, clientXactIdBits: Int, dataBits: Int, writeMaskBits: Int, wordAddrBits: Int, atomicOpBits: Int)
|
2013-03-20 22:10:16 +01:00
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
abstract trait TileLinkSubBundle extends Bundle {
|
2014-04-26 23:58:38 +02:00
|
|
|
implicit val tlconf: TileLinkConfiguration
|
|
|
|
override def clone = this.getClass.getConstructors.head.newInstance(tlconf).asInstanceOf[this.type]
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
trait HasPhysicalAddress extends TileLinkSubBundle {
|
2014-04-26 23:58:38 +02:00
|
|
|
val addr = UInt(width = tlconf.addrBits)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
trait HasClientTransactionId extends TileLinkSubBundle {
|
2014-04-26 23:58:38 +02:00
|
|
|
val client_xact_id = Bits(width = tlconf.clientXactIdBits)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
trait HasMasterTransactionId extends TileLinkSubBundle {
|
2014-04-26 23:58:38 +02:00
|
|
|
val master_xact_id = Bits(width = tlconf.masterXactIdBits)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
trait HasTileLinkData extends TileLinkSubBundle {
|
2014-04-26 23:58:38 +02:00
|
|
|
val data = Bits(width = tlconf.dataBits)
|
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
|
|
|
{
|
2013-08-13 08:15:54 +02:00
|
|
|
def apply(a_type: Bits, addr: UInt, client_xact_id: UInt)(implicit conf: TileLinkConfiguration): 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-03-29 18:53:49 +01:00
|
|
|
def apply(a_type: Bits, addr: UInt, client_xact_id: UInt, data: UInt)(implicit conf: TileLinkConfiguration): 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
|
|
|
|
}
|
|
|
|
def apply(a_type: UInt, addr: UInt, client_xact_id: UInt, write_mask: Bits, data: UInt)(implicit conf: TileLinkConfiguration): Acquire = {
|
|
|
|
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-03-29 18:53:49 +01:00
|
|
|
def apply(a_type: UInt, addr: UInt, client_xact_id: UInt, subword_addr: UInt, atomic_opcode: UInt, data: UInt)(implicit conf: TileLinkConfiguration): Acquire = {
|
|
|
|
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-01-21 21:20:55 +01:00
|
|
|
def apply(a: Acquire)(implicit conf: TileLinkConfiguration): Acquire = {
|
|
|
|
val acq = new Acquire
|
|
|
|
acq := a
|
|
|
|
acq
|
|
|
|
}
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
2014-03-29 18:53:49 +01:00
|
|
|
|
2014-04-26 23:58:38 +02:00
|
|
|
class Acquire(implicit val tlconf: TileLinkConfiguration) extends ClientSourcedMessage
|
2014-03-29 18:53:49 +01:00
|
|
|
with HasPhysicalAddress
|
|
|
|
with HasClientTransactionId
|
|
|
|
with HasTileLinkData {
|
2014-04-26 23:58:38 +02:00
|
|
|
val a_type = UInt(width = tlconf.co.acquireTypeWidth)
|
|
|
|
val write_mask = Bits(width = tlconf.writeMaskBits)
|
|
|
|
val subword_addr = Bits(width = tlconf.wordAddrBits)
|
|
|
|
val atomic_opcode = Bits(width = tlconf.atomicOpBits)
|
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
|
|
|
|
{
|
|
|
|
def apply(p_type: UInt, addr: UInt, master_xact_id: UInt)(implicit conf: TileLinkConfiguration) = {
|
|
|
|
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-04-26 23:58:38 +02:00
|
|
|
class Probe(implicit val tlconf: TileLinkConfiguration) extends MasterSourcedMessage
|
2014-03-29 18:53:49 +01:00
|
|
|
with HasPhysicalAddress
|
|
|
|
with HasMasterTransactionId {
|
2014-04-26 23:58:38 +02:00
|
|
|
val p_type = UInt(width = tlconf.co.probeTypeWidth)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-01-29 01:39:45 +01:00
|
|
|
object Release
|
|
|
|
{
|
2014-03-29 18:53:49 +01:00
|
|
|
def apply(r_type: UInt, addr: UInt, data: UInt)(implicit conf: TileLinkConfiguration) = {
|
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
|
|
|
|
}
|
|
|
|
def apply(r_type: UInt, addr: UInt, client_xact_id: UInt, master_xact_id: UInt)(implicit conf: TileLinkConfiguration) = {
|
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
|
|
|
|
}
|
|
|
|
def apply(r_type: UInt, addr: UInt, client_xact_id: UInt, master_xact_id: UInt, data: UInt)(implicit conf: TileLinkConfiguration): Release = {
|
|
|
|
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-04-26 23:58:38 +02:00
|
|
|
class Release(implicit val tlconf: TileLinkConfiguration) extends ClientSourcedMessage
|
2014-03-29 18:53:49 +01:00
|
|
|
with HasPhysicalAddress
|
|
|
|
with HasClientTransactionId
|
|
|
|
with HasMasterTransactionId
|
|
|
|
with HasTileLinkData {
|
2014-04-26 23:58:38 +02:00
|
|
|
val r_type = UInt(width = tlconf.co.releaseTypeWidth)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2014-03-29 18:53:49 +01:00
|
|
|
object Grant
|
|
|
|
{
|
|
|
|
def apply(g_type: UInt, client_xact_id: UInt, master_xact_id: UInt)(implicit conf: TileLinkConfiguration) = {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
def apply(g_type: UInt, client_xact_id: UInt, master_xact_id: UInt, data: UInt)(implicit conf: TileLinkConfiguration): Grant = {
|
|
|
|
val gnt = apply(g_type, client_xact_id, master_xact_id)
|
|
|
|
gnt.data := data
|
|
|
|
gnt
|
|
|
|
}
|
|
|
|
}
|
2013-08-02 23:55:06 +02:00
|
|
|
|
2014-04-26 23:58:38 +02:00
|
|
|
class Grant(implicit val tlconf: TileLinkConfiguration) extends MasterSourcedMessage
|
2014-03-29 18:53:49 +01:00
|
|
|
with HasTileLinkData
|
|
|
|
with HasClientTransactionId
|
|
|
|
with HasMasterTransactionId {
|
2014-04-26 23:58:38 +02:00
|
|
|
val g_type = UInt(width = tlconf.co.grantTypeWidth)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2014-04-26 23:58:38 +02:00
|
|
|
class GrantAck(implicit val tlconf: TileLinkConfiguration) extends ClientSourcedMessage with HasMasterTransactionId
|
2012-10-16 23:26:33 +02:00
|
|
|
|
2013-01-22 02:17:26 +01:00
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
class UncachedTileLinkIO(implicit conf: TileLinkConfiguration) extends Bundle {
|
|
|
|
implicit val ln = conf.ln
|
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
|
|
|
|
val grant_ack = new DecoupledIO(new LogicalNetworkIO(new GrantAck))
|
2013-03-20 22:10:16 +01:00
|
|
|
override def clone = { new UncachedTileLinkIO().asInstanceOf[this.type] }
|
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
class TileLinkIO(implicit conf: TileLinkConfiguration) extends UncachedTileLinkIO()(conf) {
|
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))
|
2013-01-22 02:17:26 +01:00
|
|
|
override def clone = { new TileLinkIO().asInstanceOf[this.type] }
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
2013-03-20 22:10:16 +01:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
abstract class TileLinkArbiterLike(val arbN: Int)(implicit conf: TileLinkConfiguration) extends Module {
|
2013-08-02 23:55:06 +02:00
|
|
|
implicit val (ln, co) = (conf.ln, conf.co)
|
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-01-21 21:20:55 +01:00
|
|
|
def hasData(m: LogicalNetworkIO[M]) = co.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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class UncachedTileLinkIOArbiter(n: Int)(implicit conf: TileLinkConfiguration) extends TileLinkArbiterLike(n)(conf) {
|
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
|
|
|
|
2013-09-11 01:15:41 +02:00
|
|
|
val grant_ack_arb = Module(new RRArbiter(new LogicalNetworkIO(new GrantAck), n))
|
2013-07-10 00:37:42 +02:00
|
|
|
io.out.grant_ack <> grant_ack_arb.io.out
|
|
|
|
grant_ack_arb.io.in zip io.in map { case (arb, req) => arb <> req.grant_ack }
|
2014-01-21 21:20:55 +01:00
|
|
|
}
|
2013-03-20 22:10:16 +01:00
|
|
|
|
2014-01-21 21:20:55 +01:00
|
|
|
abstract class TileLinkIOArbiter(n: Int)(implicit conf: TileLinkConfiguration) extends TileLinkArbiterLike(n)(conf) {
|
|
|
|
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-01-21 21:20:55 +01:00
|
|
|
val grant_ack_arb = Module(new RRArbiter(new LogicalNetworkIO(new GrantAck), n))
|
|
|
|
io.out.grant_ack <> grant_ack_arb.io.out
|
|
|
|
grant_ack_arb.io.in zip io.in map { case (arb, req) => arb <> req.grant_ack }
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
class UncachedTileLinkIOArbiterThatAppendsArbiterId(val n: Int)(implicit conf: TileLinkConfiguration) extends UncachedTileLinkIOArbiter(n)(conf) with AppendsArbiterId
|
|
|
|
class UncachedTileLinkIOArbiterThatPassesId(val n: Int)(implicit conf: TileLinkConfiguration) extends UncachedTileLinkIOArbiter(n)(conf) with PassesId
|
|
|
|
class UncachedTileLinkIOArbiterThatUsesNewId(val n: Int)(implicit conf: TileLinkConfiguration) extends UncachedTileLinkIOArbiter(n)(conf) with UsesNewId
|
|
|
|
class TileLinkIOArbiterThatAppendsArbiterId(val n: Int)(implicit conf: TileLinkConfiguration) extends TileLinkIOArbiter(n)(conf) with AppendsArbiterId
|
|
|
|
class TileLinkIOArbiterThatPassesId(val n: Int)(implicit conf: TileLinkConfiguration) extends TileLinkIOArbiter(n)(conf) with PassesId
|
|
|
|
class TileLinkIOArbiterThatUsesNewId(val n: Int)(implicit conf: TileLinkConfiguration) extends TileLinkIOArbiter(n)(conf) with UsesNewId
|