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
|
|
|
}
|
2013-08-13 08:15:54 +02:00
|
|
|
def apply(a_type: Bits, addr: UInt, client_xact_id: UInt, write_mask: Bits)(implicit conf: TileLinkConfiguration): Acquire = {
|
|
|
|
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
|
|
|
}
|
2013-08-13 08:15:54 +02:00
|
|
|
def apply(a_type: Bits, addr: UInt, client_xact_id: UInt, subword_addr: UInt, atomic_opcode: UInt)(implicit conf: TileLinkConfiguration): Acquire = {
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2013-08-02 23:55:06 +02:00
|
|
|
class Acquire(implicit val conf: TileLinkConfiguration) extends ClientSourcedMessage with HasPhysicalAddress with HasClientTransactionId {
|
2013-08-12 19:36:44 +02:00
|
|
|
val a_type = Bits(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
|
|
|
|
|
|
|
class Probe(implicit val conf: TileLinkConfiguration) extends MasterSourcedMessage with HasPhysicalAddress with HasMasterTransactionId {
|
2013-08-12 19:36:44 +02:00
|
|
|
val p_type = Bits(width = conf.co.probeTypeWidth)
|
2012-10-16 23:26:33 +02:00
|
|
|
}
|
|
|
|
|
2013-01-29 01:39:45 +01:00
|
|
|
object Release
|
|
|
|
{
|
2013-08-12 19:36:44 +02:00
|
|
|
def apply(r_type: Bits, 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 {
|
2013-08-12 19:36:44 +02:00
|
|
|
val r_type = Bits(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 {
|
2013-08-12 19:36:44 +02:00
|
|
|
val g_type = Bits(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-05-22 02:19:07 +02:00
|
|
|
trait DirectionalIO
|
|
|
|
trait ClientSourcedIO extends DirectionalIO
|
|
|
|
trait MasterSourcedIO extends DirectionalIO
|
2013-08-12 19:36:44 +02:00
|
|
|
class ClientSourcedFIFOIO[T <: Data]()(data: => T) extends DecoupledIO(data) with ClientSourcedIO {
|
2013-05-22 02:19:07 +02:00
|
|
|
override def clone = { new ClientSourcedFIFOIO()(data).asInstanceOf[this.type] }
|
|
|
|
}
|
|
|
|
class ClientSourcedDataIO[M <: Data, D <: Data]()(meta: => M, data: => D) extends PairedDataIO()(meta,data) with ClientSourcedIO {
|
|
|
|
override def clone = { new ClientSourcedDataIO()(meta,data).asInstanceOf[this.type] }
|
|
|
|
}
|
2013-08-12 19:36:44 +02:00
|
|
|
class MasterSourcedFIFOIO[T <: Data]()(data: => T) extends DecoupledIO(data) with MasterSourcedIO {
|
2013-05-22 02:19:07 +02:00
|
|
|
flip()
|
|
|
|
override def clone = { new MasterSourcedFIFOIO()(data).asInstanceOf[this.type] }
|
|
|
|
}
|
|
|
|
class MasterSourcedDataIO[M <: Data, D <: Data]()(meta: => M, data: => D) extends PairedDataIO()(meta,data) with MasterSourcedIO {
|
|
|
|
flip()
|
|
|
|
override def clone = { new MasterSourcedDataIO()(meta,data).asInstanceOf[this.type] }
|
|
|
|
}
|
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
|
2013-05-22 02:19:07 +02:00
|
|
|
val acquire = new ClientSourcedDataIO()(new LogicalNetworkIO()(new Acquire), new LogicalNetworkIO()(new AcquireData))
|
|
|
|
val grant = new MasterSourcedFIFOIO()(new LogicalNetworkIO()(new Grant))
|
|
|
|
val grant_ack = new ClientSourcedFIFOIO()(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) {
|
2013-05-22 02:19:07 +02:00
|
|
|
val probe = new MasterSourcedFIFOIO()(new LogicalNetworkIO()(new Probe))
|
|
|
|
val release = new ClientSourcedDataIO()(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
|
|
|
|
2013-08-13 09:01:11 +02:00
|
|
|
abstract class UncachedTileLinkIOArbiter(n: Int)(implicit conf: TileLinkConfiguration) extends Module {
|
2013-07-10 00:37:42 +02:00
|
|
|
def acquireClientXactId(in: Acquire, id: Int): Bits
|
|
|
|
def grantClientXactId(in: Grant): Bits
|
2013-08-12 19:36:44 +02:00
|
|
|
def arbIdx(in: Grant): UInt
|
2013-07-10 00:37:42 +02:00
|
|
|
|
2013-08-02 23:55:06 +02:00
|
|
|
implicit val (ln, co) = (conf.ln, conf.co)
|
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
|
|
|
|
}
|
2013-07-10 00:37:42 +02:00
|
|
|
def acqHasData(acq: LogicalNetworkIO[Acquire]) = co.messageHasData(acq.payload)
|
2013-08-12 19:36:44 +02:00
|
|
|
val acq_arb = Module(new PairedLockingRRArbiter(n, REFILL_CYCLES, acqHasData _)((new LogicalNetworkIO){new Acquire},(new LogicalNetworkIO){new AcquireData}))
|
2013-07-10 00:37:42 +02:00
|
|
|
io.out.acquire <> acq_arb.io.out
|
|
|
|
io.in.map(_.acquire).zipWithIndex.zip(acq_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.client_xact_id := acquireClientXactId(req.meta.bits.payload, id)
|
|
|
|
req.meta.ready := arb.meta.ready
|
|
|
|
}}
|
|
|
|
|
2013-08-12 19:36:44 +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 }
|
2013-03-20 22:10:16 +01:00
|
|
|
|
2013-07-10 00:37:42 +02:00
|
|
|
io.out.grant.ready := Bool(false)
|
|
|
|
for (i <- 0 until n) {
|
|
|
|
io.in(i).grant.valid := Bool(false)
|
2013-08-12 19:36:44 +02:00
|
|
|
when (arbIdx(io.out.grant.bits.payload) === UInt(i)) {
|
2013-07-10 00:37:42 +02:00
|
|
|
io.in(i).grant.valid := io.out.grant.valid
|
|
|
|
io.out.grant.ready := io.in(i).grant.ready
|
|
|
|
}
|
|
|
|
io.in(i).grant.bits := io.out.grant.bits
|
|
|
|
io.in(i).grant.bits.payload.client_xact_id := grantClientXactId(io.out.grant.bits.payload)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-13 09:01:11 +02:00
|
|
|
class UncachedTileLinkIOArbiterThatAppendsArbiterId(n: Int)(implicit conf: TileLinkConfiguration) extends UncachedTileLinkIOArbiter(n)(conf) {
|
|
|
|
def acquireClientXactId(in: Acquire, id: Int) = Cat(in.client_xact_id, UInt(id, log2Up(n)))
|
|
|
|
def grantClientXactId(in: Grant) = in.client_xact_id >> UInt(log2Up(n))
|
|
|
|
def arbIdx(in: Grant) = in.client_xact_id(log2Up(n)-1,0).toUInt
|
|
|
|
}
|
|
|
|
|
|
|
|
class UncachedTileLinkIOArbiterThatPassesId(n: Int)(implicit conf: TileLinkConfiguration) extends UncachedTileLinkIOArbiter(n)(conf) {
|
2013-07-10 00:37:42 +02:00
|
|
|
def acquireClientXactId(in: Acquire, id: Int) = in.client_xact_id
|
|
|
|
def grantClientXactId(in: Grant) = in.client_xact_id
|
2013-08-12 19:36:44 +02:00
|
|
|
def arbIdx(in: Grant): UInt = in.client_xact_id
|
2013-03-20 22:10:16 +01:00
|
|
|
}
|
2013-07-10 00:37:42 +02:00
|
|
|
|
2013-08-13 09:01:11 +02:00
|
|
|
class UncachedTileLinkIOArbiterThatUsesNewId(n: Int)(implicit conf: TileLinkConfiguration) extends UncachedTileLinkIOArbiter(n)(conf) {
|
2013-08-12 19:36:44 +02:00
|
|
|
def acquireClientXactId(in: Acquire, id: Int) = UInt(id, log2Up(n))
|
|
|
|
def grantClientXactId(in: Grant) = UInt(0) // DNC
|
2013-07-10 00:37:42 +02:00
|
|
|
def arbIdx(in: Grant) = in.client_xact_id
|
|
|
|
}
|