Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding V2 Constructors in Paramaters and Emits Parameters #2532

Merged
merged 15 commits into from
Jul 17, 2020
16 changes: 10 additions & 6 deletions src/main/scala/amba/ahb/ToTL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ import freechips.rocketchip.util._

case class AHBToTLNode()(implicit valName: ValName) extends MixedAdapterNode(AHBImpSlave, TLImp)(
dFn = { case mp =>
TLMasterPortParameters.v1(
clients = mp.masters.map { m =>
TLMasterPortParameters.v2(
masters = mp.masters.map { m =>
// AHB fixed length transfer size maximum is 16384 = 1024 * 16 bits, hsize is capped at 111 = 1024 bit transfer size and hburst is capped at 111 = 16 beat burst
// This master can only produce:
// emitsGet = TransferSizes(1, 2048),
// emitsPutFull = TransferSizes(1, 2048)
TLMasterParameters.v1(name = m.name, nodePath = m.nodePath)
TLMasterParameters.v2(
name = m.name,
nodePath = m.nodePath,
emits = TLMasterToSlaveTransferSizes(
Copy link
Contributor Author

@brrmorre brrmorre Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment that specifies that "This value should be constrained by a data width parameter that flows from masters to slaves"

get = TransferSizes(1, 2048),
putFull = TransferSizes(1, 2048)
)
)
},
requestFields = AMBAProtField() +: mp.requestFields,
responseKeys = mp.responseKeys)
Expand Down
12 changes: 6 additions & 6 deletions src/main/scala/devices/debug/DMI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ class ClockedDMIIO(implicit val p: Parameters) extends ParameterizedBundle()(p){
*/

class DMIToTL(implicit p: Parameters) extends LazyModule {

// This master can only produce:
// emitsGet = TransferSizes(4, 4),
// emitsPutFull = TransferSizes(4, 4),
// emitsPutPartial = TransferSizes(4, 4)
val node = TLClientNode(Seq(TLMasterPortParameters.v1(Seq(TLMasterParameters.v1("debug")))))
val node = TLClientNode(Seq(TLMasterPortParameters.v2(Seq(TLMasterParameters.v2(
name = "debug",
emits = TLMasterToSlaveTransferSizes(
get = TransferSizes(4,4),
putFull = TransferSizes(4,4),
putPartial = TransferSizes(4,4)))))))

lazy val module = new LazyModuleImp(this) {
val io = IO(new Bundle {
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/diplomacy/Parameters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ case class TransferSizes(min: Int, max: Int)
def intersect(x: TransferSizes) =
if (x.max < min || max < x.min) TransferSizes.none
else TransferSizes(scala.math.max(min, x.min), scala.math.min(max, x.max))

// Not a union, because the result may contain sizes contained by neither term
// NOT TO BE CONFUSED WITH COVERPOINTS
def cover(x: TransferSizes) = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace this with mincover

if (none) {
x
Expand Down
30 changes: 16 additions & 14 deletions src/main/scala/tilelink/Fragmenter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,24 @@ class TLFragmenter(val minSize: Int, val maxSize: Int, val alwaysMin: Boolean =
val node = TLAdapterNode(
// We require that all the responses are mutually FIFO
// Thus we need to compact all of the masters into one big master
clientFn = { c => c.v1copy(
clients = Seq(TLMasterParameters.v1(
clientFn = { c => c.v2copy(
masters = Seq(TLMasterParameters.v2(
name = "TLFragmenter",
sourceId = IdRange(0, if (minSize == maxSize) c.endSourceId else (c.endSourceId << addedBits)),
requestFifo = true))),
// This master can only produce:
// emitsAcquireT = c.clients.map(_.knownToEmit.get.emitsAcquireT).reduce(_ smallestintervalcover _),
// emitsAcquireB = c.clients.map(_.knownToEmit.get.emitsAcquireB).reduce(_ smallestintervalcover _),
// emitsArithmetic = c.clients.map(_.knownToEmit.get.emitsArithmetic).reduce(_ smallestintervalcover _),
// emitsLogical = c.clients.map(_.knownToEmit.get.emitsLogical).reduce(_ smallestintervalcover _),
// emitsGet = c.clients.map(_.knownToEmit.get.emitsGet).reduce(_ smallestintervalcover _),
// emitsPutFull = c.clients.map(_.knownToEmit.get.emitsPutFull).reduce(_ smallestintervalcover _),
// emitsPutPartial = c.clients.map(_.knownToEmit.get.emitsPutPartial).reduce(_ smallestintervalcover _),
// emitsHint = c.clients.map(_.knownToEmit.get.emitsHint).reduce(_ smallestintervalcover _)
},
managerFn = { m => m.v1copy(managers = m.managers.map(mapManager)) })
requestFifo = true,
emits = TLMasterToSlaveTransferSizes(
acquireT = c.masters.map(_.emits.acquireT) .reduce(_ cover _),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try and use shrinktransfer to make the bound tighter

Copy link
Contributor

@terpstra terpstra Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe: = shrinkTransfer(c.masters.map(_.emits.acquireT) .reduce(_ cover _))

acquireB = c.masters.map(_.emits.acquireB) .reduce(_ cover _),
arithmetic = c.masters.map(_.emits.arithmetic).reduce(_ cover _),
logical = c.masters.map(_.emits.logical) .reduce(_ cover _),
get = c.masters.map(_.emits.get) .reduce(_ cover _),
putFull = c.masters.map(_.emits.putFull) .reduce(_ cover _),
putPartial = c.masters.map(_.emits.putPartial).reduce(_ cover _),
hint = c.masters.map(_.emits.hint) .reduce(_ cover _)
)
))
)},
managerFn = { m => m.v2copy(slaves = m.slaves.map(mapManager)) })

lazy val module = new LazyModuleImp(this) {
(node.in zip node.out) foreach { case ((in, edgeIn), (out, edgeOut)) =>
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/tilelink/Monitor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class TLMonitor(args: TLMonitorArgs, monitorDir: MonitorDirection = MonitorDirec
}

when (bundle.opcode === TLMessages.Get) {
monAssert (edge.expectsVipCheckerMasterToSlaveGet(bundle.source, edge.address(bundle), bundle.size), "'A' channel carries Get type which is unexpected using diplomatic parameters" + diplomacyInfo + extra)
monAssert (edge.master.expectsVipCheckerEmitsGet(bundle.source, bundle.size), "'A' channel carries Get type which master claims it can't emit" + diplomacyInfo + extra)
monAssert (edge.slave.expectsVipCheckerSupportsGet(edge.address(bundle), bundle.size, None), "'A' channel carries Get type which slave claims it can't support" + diplomacyInfo + extra)
monAssert (source_ok, "'A' channel Get carries invalid source ID" + diplomacyInfo + extra)
monAssert (is_aligned, "'A' channel Get address not aligned to size" + extra)
monAssert (bundle.param === 0.U, "'A' channel Get carries invalid param" + extra)
Expand Down
168 changes: 165 additions & 3 deletions src/main/scala/tilelink/Parameters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,42 @@ class TLSlaveParameters private(
putFull = supportsPutFull,
putPartial = supportsPutPartial,
hint = supportsHint),
emits = emits,
emits = emits,
mayDenyGet = mayDenyGet,
mayDenyPut = mayDenyPut,
alwaysGrantsT = alwaysGrantsT,
fifoId = fifoId)
}

def v2copy(
nodePath: Seq[BaseNode] = nodePath,
resources: Seq[Resource] = resources,
setName: Option[String] = setName,
address: Seq[AddressSet] = address,
regionType: RegionType.T = regionType,
executable: Boolean = executable,
fifoId: Option[Int] = fifoId,
supports: TLMasterToSlaveTransferSizes = supports,
emits: TLSlaveToMasterTransferSizes = emits,
alwaysGrantsT: Boolean = alwaysGrantsT,
mayDenyGet: Boolean = mayDenyGet,
mayDenyPut: Boolean = mayDenyPut) =
{
new TLSlaveParameters(
nodePath = nodePath,
resources = resources,
setName = setName,
address = address,
regionType = regionType,
executable = executable,
fifoId = fifoId,
supports = supports,
emits = emits,
alwaysGrantsT = alwaysGrantsT,
mayDenyGet = mayDenyGet,
mayDenyPut = mayDenyPut)
}

@deprecated("Use v1copy instead of copy","")
def copy(
address: Seq[AddressSet] = address,
Expand Down Expand Up @@ -386,6 +415,35 @@ object TLSlaveParameters {
alwaysGrantsT = alwaysGrantsT,
fifoId = fifoId)
}

def v2(
address: Seq[AddressSet],
nodePath: Seq[BaseNode] = Seq(),
resources: Seq[Resource] = Seq(),
setName: Option[String] = None,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try and change setname to name

regionType: RegionType.T = RegionType.GET_EFFECTS,
executable: Boolean = false,
fifoId: Option[Int] = None,
supports: TLMasterToSlaveTransferSizes = TLMasterToSlaveTransferSizes.unknownSupports,
emits: TLSlaveToMasterTransferSizes = TLSlaveToMasterTransferSizes.unknownEmits,
alwaysGrantsT: Boolean = false,
mayDenyGet: Boolean = false,
mayDenyPut: Boolean = false) =
{
new TLSlaveParameters(
nodePath = nodePath,
resources = resources,
setName = setName,
address = address,
regionType = regionType,
executable = executable,
fifoId = fifoId,
supports = supports,
emits = emits,
alwaysGrantsT = alwaysGrantsT,
mayDenyGet = mayDenyGet,
mayDenyPut = mayDenyPut)
}
}

object TLManagerParameters {
Expand Down Expand Up @@ -677,6 +735,23 @@ class TLSlavePortParameters private(
requestKeys = requestKeys)
}

def v2copy(
slaves: Seq[TLSlaveParameters] = slaves,
channelBytes: TLChannelBeatBytes = channelBytes,
endSinkId: Int = endSinkId,
minLatency: Int = minLatency,
responseFields: Seq[BundleFieldBase] = responseFields,
requestKeys: Seq[BundleKeyBase] = requestKeys) =
{
new TLSlavePortParameters(
slaves = slaves,
channelBytes = channelBytes,
endSinkId = endSinkId,
minLatency = minLatency,
responseFields = responseFields,
requestKeys = requestKeys)
}

@deprecated("Use v1copy instead of copy","")
def copy(
managers: Seq[TLSlaveParameters] = slaves,
Expand Down Expand Up @@ -847,6 +922,33 @@ class TLMasterParameters private(
sourceId = sourceId)
}

def v2copy(
nodePath: Seq[BaseNode] = nodePath,
resources: Seq[Resource] = resources,
name: String = name,
visibility: Seq[AddressSet] = visibility,
unusedRegionTypes: Set[RegionType.T] = unusedRegionTypes,
executesOnly: Boolean = executesOnly,
requestFifo: Boolean = requestFifo,
supports: TLSlaveToMasterTransferSizes = supports,
emits: TLMasterToSlaveTransferSizes = emits,
neverReleasesData: Boolean = neverReleasesData,
sourceId: IdRange = sourceId) =
{
new TLMasterParameters(
nodePath = nodePath,
resources = resources,
name = name,
visibility = visibility,
unusedRegionTypes = unusedRegionTypes,
executesOnly = executesOnly,
requestFifo = requestFifo,
supports = supports,
emits = emits,
neverReleasesData = neverReleasesData,
sourceId = sourceId)
}

@deprecated("Use v1copy instead of copy","")
def copy(
name: String = name,
Expand Down Expand Up @@ -913,6 +1015,33 @@ object TLMasterParameters {
neverReleasesData = false,
sourceId = sourceId)
}

def v2(
nodePath: Seq[BaseNode] = Seq(),
resources: Seq[Resource] = Nil,
name: String,
visibility: Seq[AddressSet] = Seq(AddressSet(0, ~0)),
unusedRegionTypes: Set[RegionType.T] = Set(),
executesOnly: Boolean = false,
requestFifo: Boolean = false,
supports: TLSlaveToMasterTransferSizes = TLSlaveToMasterTransferSizes.unknownSupports,
emits: TLMasterToSlaveTransferSizes = TLMasterToSlaveTransferSizes.unknownEmits,
neverReleasesData: Boolean = false,
sourceId: IdRange = IdRange(0,1)) =
{
new TLMasterParameters(
nodePath = nodePath,
resources = resources,
name = name,
visibility = visibility,
unusedRegionTypes = unusedRegionTypes,
executesOnly = executesOnly,
requestFifo = requestFifo,
supports = supports,
emits = emits,
neverReleasesData = neverReleasesData,
sourceId = sourceId)
}
}

object TLClientParameters {
Expand Down Expand Up @@ -1096,6 +1225,23 @@ class TLMasterPortParameters private(
responseKeys = responseKeys)
}

def v2copy(
masters: Seq[TLMasterParameters] = masters,
channelBytes: TLChannelBeatBytes = channelBytes,
minLatency: Int = minLatency,
echoFields: Seq[BundleFieldBase] = echoFields,
requestFields: Seq[BundleFieldBase] = requestFields,
responseKeys: Seq[BundleKeyBase] = responseKeys) =
{
new TLMasterPortParameters(
masters = masters,
channelBytes = channelBytes,
minLatency = minLatency,
echoFields = echoFields,
requestFields = requestFields,
responseKeys = responseKeys)
}

@deprecated("Use v1copy instead of copy","")
def copy(
clients: Seq[TLMasterParameters] = masters,
Expand Down Expand Up @@ -1133,8 +1279,8 @@ object TLClientPortParameters {

object TLMasterPortParameters {
def v1(
clients: Seq[TLMasterParameters],
minLatency: Int = 0,
clients: Seq[TLMasterParameters],
minLatency: Int = 0,
echoFields: Seq[BundleFieldBase] = Nil,
requestFields: Seq[BundleFieldBase] = Nil,
responseKeys: Seq[BundleKeyBase] = Nil) =
Expand All @@ -1147,6 +1293,22 @@ object TLMasterPortParameters {
requestFields = requestFields,
responseKeys = responseKeys)
}
def v2(
masters: Seq[TLMasterParameters],
channelBytes: TLChannelBeatBytes = TLChannelBeatBytes(),
minLatency: Int = 0,
echoFields: Seq[BundleFieldBase] = Nil,
requestFields: Seq[BundleFieldBase] = Nil,
responseKeys: Seq[BundleKeyBase] = Nil) =
{
new TLMasterPortParameters(
masters = masters,
channelBytes = channelBytes,
minLatency = minLatency,
echoFields = echoFields,
requestFields = requestFields,
responseKeys = responseKeys)
}
}

case class TLBundleParameters(
Expand Down