2012-10-16 23:26:33 +02:00
|
|
|
package uncore
|
|
|
|
import Chisel._
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
case class TileLinkConfiguration(co: CoherencePolicyWithUncached, ln: LogicalNetworkConfiguration, masterXactIdBits: Int, clientXactIdBits: Int, dataBits: Int)
|
2013-03-20 22:10:16 +01:00
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
abstract trait TileLinkSubBundle extends Bundle {
|
|
|
|
implicit val conf: TileLinkConfiguration
|
2013-08-13 08:15:54 +02:00
|
|
|
override def clone = this.getClass.getConstructors.head.newInstance(conf).asInstanceOf[this.type]
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
trait HasPhysicalAddress extends TileLinkSubBundle {
|
2013-08-12 19:36:44 +02:00
|
|
|
val addr = UInt(width = PADDR_BITS - OFFSET_BITS)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
trait HasClientTransactionId extends TileLinkSubBundle {
|
|
|
|
val client_xact_id = Bits(width = conf.clientXactIdBits)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
trait HasMasterTransactionId extends TileLinkSubBundle {
|
|
|
|
val master_xact_id = Bits(width = conf.masterXactIdBits)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
trait HasTileLinkData extends TileLinkSubBundle {
|
|
|
|
val data = Bits(width = conf.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
|
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-01-21 21:20:55 +01:00
|
|
|
def apply(a_type: UInt, addr: UInt, client_xact_id: UInt, write_mask: Bits)(implicit conf: TileLinkConfiguration): Acquire = {
|
2013-08-13 08:15:54 +02:00
|
|
|
val acq = apply(a_type, addr, client_xact_id)
|
2013-01-22 02:17:26 +01:00
|
|
|
acq.write_mask := write_mask
|
|
|
|
acq
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
2014-01-21 21:20:55 +01:00
|
|
|
def apply(a_type: UInt, addr: UInt, client_xact_id: UInt, subword_addr: UInt, atomic_opcode: UInt)(implicit conf: TileLinkConfiguration): Acquire = {
|
2013-08-13 08:15:54 +02:00
|
|
|
val acq = apply(a_type, addr, client_xact_id)
|
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
|
|
|
}
|
2013-08-02 23:55:06 +02:00
|
|
|
class Acquire(implicit val conf: TileLinkConfiguration) extends ClientSourcedMessage with HasPhysicalAddress with HasClientTransactionId {
|
2014-01-21 21:20:55 +01:00
|
|
|
val a_type = UInt(width = conf.co.acquireTypeWidth)
|
2013-08-02 23:55:06 +02:00
|
|
|
val write_mask = Bits(width = ACQUIRE_WRITE_MASK_BITS)
|
|
|
|
val subword_addr = Bits(width = ACQUIRE_SUBWORD_ADDR_BITS)
|
|
|
|
val atomic_opcode = Bits(width = ACQUIRE_ATOMIC_OP_BITS)
|
|
|
|
}
|
2012-10-16 23:26:33 +02:00
|
|
|
|
2013-08-13 08:15:54 +02:00
|
|
|
class AcquireData(implicit val conf: TileLinkConfiguration) extends ClientSourcedMessage with HasTileLinkData
|
2013-08-02 23:55:06 +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
|
|
|
|
}
|
|
|
|
}
|
2013-08-02 23:55:06 +02:00
|
|
|
class Probe(implicit val conf: TileLinkConfiguration) extends MasterSourcedMessage with HasPhysicalAddress with HasMasterTransactionId {
|
2014-01-21 21:20:55 +01:00
|
|
|
val p_type = UInt(width = conf.co.probeTypeWidth)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-01-29 01:39:45 +01:00
|
|
|
object Release
|
|
|
|
{
|
2014-01-21 21:20:55 +01:00
|
|
|
def apply(r_type: UInt, addr: UInt)(implicit conf: TileLinkConfiguration) = {
|
|
|
|
val rel = new Release
|
|
|
|
rel.r_type := r_type
|
|
|
|
rel.addr := addr
|
|
|
|
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
|
|
|
|
rel
|
|
|
|
}
|
|
|
|
}
|
2013-08-02 23:55:06 +02:00
|
|
|
class Release(implicit val conf: TileLinkConfiguration) extends ClientSourcedMessage with HasPhysicalAddress with HasClientTransactionId with HasMasterTransactionId {
|
2014-01-21 21:20:55 +01:00
|
|
|
val r_type = UInt(width = conf.co.releaseTypeWidth)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-13 08:15:54 +02:00
|
|
|
class ReleaseData(implicit val conf: TileLinkConfiguration) extends ClientSourcedMessage with HasTileLinkData
|
2013-08-02 23:55:06 +02:00
|
|
|
|
|
|
|
class Grant(implicit val conf: TileLinkConfiguration) extends MasterSourcedMessage with HasTileLinkData with HasClientTransactionId with HasMasterTransactionId {
|
2014-01-21 21:20:55 +01:00
|
|
|
val g_type = UInt(width = conf.co.grantTypeWidth)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-13 08:15:54 +02:00
|
|
|
class GrantAck(implicit val conf: 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-01-21 21:20:55 +01:00
|
|
|
val acquire = new PairedDataIO(new LogicalNetworkIO(new Acquire), new LogicalNetworkIO(new AcquireData))
|
|
|
|
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
|
|
|
|
val release = new PairedDataIO(new LogicalNetworkIO(new Release), new LogicalNetworkIO(new ReleaseData))
|
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
|
|
|
|
type ClientSourcedWithData = ClientSourcedMessage with HasTileLinkData
|
|
|
|
|
|
|
|
def clientSourcedClientXactId(in: ClientSourcedWithId, id: Int): Bits
|
|
|
|
def masterSourcedClientXactId(in: MasterSourcedWithId): Bits
|
|
|
|
def arbIdx(in: MasterSourcedWithId): UInt
|
|
|
|
|
|
|
|
def hookupClientSource[M <: ClientSourcedWithId, D <: ClientSourcedWithData]
|
|
|
|
(ins: Seq[PairedDataIO[LogicalNetworkIO[M],LogicalNetworkIO[D]]],
|
|
|
|
out: PairedDataIO[LogicalNetworkIO[M],LogicalNetworkIO[D]]) {
|
|
|
|
def hasData(m: LogicalNetworkIO[M]) = co.messageHasData(m.payload)
|
|
|
|
val arb = Module(new PairedLockingRRArbiter(out.meta.bits.clone, out.data.bits.clone,
|
|
|
|
arbN, REFILL_CYCLES, hasData _))
|
|
|
|
out <> arb.io.out
|
|
|
|
ins.zipWithIndex.zip(arb.io.in).map{ case ((req,id), arb) => {
|
|
|
|
arb.data <> req.data
|
|
|
|
arb.meta.valid := req.meta.valid
|
|
|
|
arb.meta.bits := req.meta.bits
|
|
|
|
arb.meta.bits.payload := req.meta.bits.payload
|
|
|
|
arb.meta.bits.payload.client_xact_id := clientSourcedClientXactId(req.meta.bits.payload, id)
|
|
|
|
req.meta.ready := arb.meta.ready
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
|
|
|
|
def hookupMasterSource[M <: MasterSourcedWithId]
|
|
|
|
(ins: Seq[DecoupledIO[LogicalNetworkIO[M]]],
|
|
|
|
out: DecoupledIO[LogicalNetworkIO[M]]) {
|
|
|
|
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
|