1
0

tilelink2: pass sourceInfo using implicits in Monitor

This commit is contained in:
Wesley W. Terpstra 2016-09-02 11:12:25 -07:00
parent 935b53f3bf
commit 2069ca5d8d
2 changed files with 197 additions and 196 deletions

View File

@ -7,8 +7,8 @@ import chisel3.internal.sourceinfo.SourceInfo
object TLMonitor object TLMonitor
{ {
def legalizeFormatA(bundle: TLBundleA, edge: TLEdgeOut, sourceInfo: SourceInfo) = { def legalizeFormatA(bundle: TLBundleA, edge: TLEdgeOut)(implicit sourceInfo: SourceInfo) = {
assert (TLMessages.isA(bundle.opcode), "'A' channel has invalid opcode")(sourceInfo) assert (TLMessages.isA(bundle.opcode), "'A' channel has invalid opcode")
// Reuse these subexpressions to save some firrtl lines // Reuse these subexpressions to save some firrtl lines
val source_ok = edge.client.contains(bundle.source) val source_ok = edge.client.contains(bundle.source)
@ -16,64 +16,64 @@ object TLMonitor
val mask = edge.fullMask(bundle.address, bundle.size) val mask = edge.fullMask(bundle.address, bundle.size)
when (bundle.opcode === TLMessages.Acquire) { when (bundle.opcode === TLMessages.Acquire) {
assert (edge.manager.supportsAcquire(bundle.address, bundle.size), "'A' channel carries Acquire type unsupported by manager")(sourceInfo) assert (edge.manager.supportsAcquire(bundle.address, bundle.size), "'A' channel carries Acquire type unsupported by manager")
assert (source_ok, "'A' channel Acquire carries invalid source ID")(sourceInfo) assert (source_ok, "'A' channel Acquire carries invalid source ID")
assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'A' channel Acquire smaller than a beat")(sourceInfo) assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'A' channel Acquire smaller than a beat")
assert (is_aligned, "'A' channel Acquire address not aligned to size")(sourceInfo) assert (is_aligned, "'A' channel Acquire address not aligned to size")
assert (TLPermissions.isGrow(bundle.param), "'A' channel Acquire carries invalid grow param")(sourceInfo) assert (TLPermissions.isGrow(bundle.param), "'A' channel Acquire carries invalid grow param")
assert (bundle.mask === SInt(-1).asUInt, "'A' channel Acquire contains invalid mask")(sourceInfo) assert (bundle.mask === SInt(-1).asUInt, "'A' channel Acquire contains invalid mask")
} }
when (bundle.opcode === TLMessages.Get) { when (bundle.opcode === TLMessages.Get) {
assert (edge.manager.supportsGet(bundle.address, bundle.size), "'A' channel carries Get type unsupported by manager")(sourceInfo) assert (edge.manager.supportsGet(bundle.address, bundle.size), "'A' channel carries Get type unsupported by manager")
assert (source_ok, "'A' channel Get carries invalid source ID")(sourceInfo) assert (source_ok, "'A' channel Get carries invalid source ID")
assert (is_aligned, "'A' channel Get address not aligned to size")(sourceInfo) assert (is_aligned, "'A' channel Get address not aligned to size")
assert (bundle.param === UInt(0), "'A' channel Get carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'A' channel Get carries invalid param")
assert (bundle.mask === mask, "'A' channel Get contains invalid mask")(sourceInfo) assert (bundle.mask === mask, "'A' channel Get contains invalid mask")
} }
when (bundle.opcode === TLMessages.PutFullData) { when (bundle.opcode === TLMessages.PutFullData) {
assert (edge.manager.supportsPutFull(bundle.address, bundle.size), "'A' channel carries PutFull type unsupported by manager")(sourceInfo) assert (edge.manager.supportsPutFull(bundle.address, bundle.size), "'A' channel carries PutFull type unsupported by manager")
assert (source_ok, "'A' channel PutFull carries invalid source ID")(sourceInfo) assert (source_ok, "'A' channel PutFull carries invalid source ID")
assert (is_aligned, "'A' channel PutFull address not aligned to size")(sourceInfo) assert (is_aligned, "'A' channel PutFull address not aligned to size")
assert (bundle.param === UInt(0), "'A' channel PutFull carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'A' channel PutFull carries invalid param")
assert (bundle.mask === mask, "'A' channel PutFull contains invalid mask")(sourceInfo) assert (bundle.mask === mask, "'A' channel PutFull contains invalid mask")
} }
when (bundle.opcode === TLMessages.PutPartialData) { when (bundle.opcode === TLMessages.PutPartialData) {
assert (edge.manager.supportsPutPartial(bundle.address, bundle.size), "'A' channel carries PutPartial type unsupported by manager")(sourceInfo) assert (edge.manager.supportsPutPartial(bundle.address, bundle.size), "'A' channel carries PutPartial type unsupported by manager")
assert (source_ok, "'A' channel PutPartial carries invalid source ID")(sourceInfo) assert (source_ok, "'A' channel PutPartial carries invalid source ID")
assert (is_aligned, "'A' channel PutPartial address not aligned to size")(sourceInfo) assert (is_aligned, "'A' channel PutPartial address not aligned to size")
assert (bundle.param === UInt(0), "'A' channel PutPartial carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'A' channel PutPartial carries invalid param")
assert ((bundle.mask & ~mask) === UInt(0), "'A' channel PutPartial contains invalid mask")(sourceInfo) assert ((bundle.mask & ~mask) === UInt(0), "'A' channel PutPartial contains invalid mask")
} }
when (bundle.opcode === TLMessages.ArithmeticData) { when (bundle.opcode === TLMessages.ArithmeticData) {
assert (edge.manager.supportsArithmetic(bundle.address, bundle.size), "'A' channel carries Arithmetic type unsupported by manager")(sourceInfo) assert (edge.manager.supportsArithmetic(bundle.address, bundle.size), "'A' channel carries Arithmetic type unsupported by manager")
assert (source_ok, "'A' channel Arithmetic carries invalid source ID")(sourceInfo) assert (source_ok, "'A' channel Arithmetic carries invalid source ID")
assert (is_aligned, "'A' channel Arithmetic address not aligned to size")(sourceInfo) assert (is_aligned, "'A' channel Arithmetic address not aligned to size")
assert (TLAtomics.isArithmetic(bundle.param), "'A' channel Arithmetic carries invalid opcode param")(sourceInfo) assert (TLAtomics.isArithmetic(bundle.param), "'A' channel Arithmetic carries invalid opcode param")
assert (bundle.mask === mask, "'A' channel Arithmetic contains invalid mask")(sourceInfo) assert (bundle.mask === mask, "'A' channel Arithmetic contains invalid mask")
} }
when (bundle.opcode === TLMessages.LogicalData) { when (bundle.opcode === TLMessages.LogicalData) {
assert (edge.manager.supportsLogical(bundle.address, bundle.size), "'A' channel carries Logical type unsupported by manager")(sourceInfo) assert (edge.manager.supportsLogical(bundle.address, bundle.size), "'A' channel carries Logical type unsupported by manager")
assert (source_ok, "'A' channel Logical carries invalid source ID")(sourceInfo) assert (source_ok, "'A' channel Logical carries invalid source ID")
assert (is_aligned, "'A' channel Logical address not aligned to size")(sourceInfo) assert (is_aligned, "'A' channel Logical address not aligned to size")
assert (TLAtomics.isLogical(bundle.param), "'A' channel Logical carries invalid opcode param")(sourceInfo) assert (TLAtomics.isLogical(bundle.param), "'A' channel Logical carries invalid opcode param")
assert (bundle.mask === mask, "'A' channel Logical contains invalid mask")(sourceInfo) assert (bundle.mask === mask, "'A' channel Logical contains invalid mask")
} }
when (bundle.opcode === TLMessages.Hint) { when (bundle.opcode === TLMessages.Hint) {
assert (edge.manager.supportsHint(bundle.address), "'A' channel carries Hint type unsupported by manager")(sourceInfo) assert (edge.manager.supportsHint(bundle.address), "'A' channel carries Hint type unsupported by manager")
assert (source_ok, "'A' channel Hint carries invalid source ID")(sourceInfo) assert (source_ok, "'A' channel Hint carries invalid source ID")
assert (is_aligned, "'A' channel Hint address not aligned to size")(sourceInfo) assert (is_aligned, "'A' channel Hint address not aligned to size")
assert (bundle.mask === mask, "'A' channel Hint contains invalid mask")(sourceInfo) assert (bundle.mask === mask, "'A' channel Hint contains invalid mask")
} }
} }
def legalizeFormatB(bundle: TLBundleB, edge: TLEdgeIn, sourceInfo: SourceInfo) = { def legalizeFormatB(bundle: TLBundleB, edge: TLEdgeIn)(implicit sourceInfo: SourceInfo) = {
assert (TLMessages.isB(bundle.opcode), "'B' channel has invalid opcode")(sourceInfo) assert (TLMessages.isB(bundle.opcode), "'B' channel has invalid opcode")
// Reuse these subexpressions to save some firrtl lines // Reuse these subexpressions to save some firrtl lines
val address_ok = edge.manager.contains(bundle.source) val address_ok = edge.manager.contains(bundle.source)
@ -81,192 +81,192 @@ object TLMonitor
val mask = edge.fullMask(bundle.address, bundle.size) val mask = edge.fullMask(bundle.address, bundle.size)
when (bundle.opcode === TLMessages.Probe) { when (bundle.opcode === TLMessages.Probe) {
assert (edge.client.supportsProbe(bundle.source, bundle.size), "'B' channel carries Probe type unsupported by client")(sourceInfo) assert (edge.client.supportsProbe(bundle.source, bundle.size), "'B' channel carries Probe type unsupported by client")
assert (address_ok, "'B' channel Probe carries unmanaged address")(sourceInfo) assert (address_ok, "'B' channel Probe carries unmanaged address")
assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'B' channel Probe smaller than a beat")(sourceInfo) assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'B' channel Probe smaller than a beat")
assert (is_aligned, "'B' channel Probe address not aligned to size")(sourceInfo) assert (is_aligned, "'B' channel Probe address not aligned to size")
assert (TLPermissions.isCap(bundle.param), "'B' channel Probe carries invalid cap param")(sourceInfo) assert (TLPermissions.isCap(bundle.param), "'B' channel Probe carries invalid cap param")
assert (bundle.mask === SInt(-1).asUInt, "'B' channel Probe contains invalid mask")(sourceInfo) assert (bundle.mask === SInt(-1).asUInt, "'B' channel Probe contains invalid mask")
} }
when (bundle.opcode === TLMessages.Get) { when (bundle.opcode === TLMessages.Get) {
assert (edge.client.supportsGet(bundle.source, bundle.size), "'B' channel carries Get type unsupported by client")(sourceInfo) assert (edge.client.supportsGet(bundle.source, bundle.size), "'B' channel carries Get type unsupported by client")
assert (address_ok, "'B' channel Get carries unmanaged address")(sourceInfo) assert (address_ok, "'B' channel Get carries unmanaged address")
assert (is_aligned, "'B' channel Get address not aligned to size")(sourceInfo) assert (is_aligned, "'B' channel Get address not aligned to size")
assert (bundle.param === UInt(0), "'B' channel Get carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'B' channel Get carries invalid param")
assert (bundle.mask === mask, "'A' channel Get contains invalid mask")(sourceInfo) assert (bundle.mask === mask, "'A' channel Get contains invalid mask")
} }
when (bundle.opcode === TLMessages.PutFullData) { when (bundle.opcode === TLMessages.PutFullData) {
assert (edge.client.supportsPutFull(bundle.source, bundle.size), "'B' channel carries PutFull type unsupported by client")(sourceInfo) assert (edge.client.supportsPutFull(bundle.source, bundle.size), "'B' channel carries PutFull type unsupported by client")
assert (address_ok, "'B' channel PutFull carries unmanaged address")(sourceInfo) assert (address_ok, "'B' channel PutFull carries unmanaged address")
assert (is_aligned, "'B' channel PutFull address not aligned to size")(sourceInfo) assert (is_aligned, "'B' channel PutFull address not aligned to size")
assert (bundle.param === UInt(0), "'B' channel PutFull carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'B' channel PutFull carries invalid param")
assert (bundle.mask === mask, "'B' channel PutFull contains invalid mask")(sourceInfo) assert (bundle.mask === mask, "'B' channel PutFull contains invalid mask")
} }
when (bundle.opcode === TLMessages.PutPartialData) { when (bundle.opcode === TLMessages.PutPartialData) {
assert (edge.client.supportsPutPartial(bundle.source, bundle.size), "'B' channel carries PutPartial type unsupported by client")(sourceInfo) assert (edge.client.supportsPutPartial(bundle.source, bundle.size), "'B' channel carries PutPartial type unsupported by client")
assert (address_ok, "'B' channel PutPartial carries unmanaged address")(sourceInfo) assert (address_ok, "'B' channel PutPartial carries unmanaged address")
assert (is_aligned, "'B' channel PutPartial address not aligned to size")(sourceInfo) assert (is_aligned, "'B' channel PutPartial address not aligned to size")
assert (bundle.param === UInt(0), "'B' channel PutPartial carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'B' channel PutPartial carries invalid param")
assert ((bundle.mask & ~mask) === UInt(0), "'B' channel PutPartial contains invalid mask")(sourceInfo) assert ((bundle.mask & ~mask) === UInt(0), "'B' channel PutPartial contains invalid mask")
} }
when (bundle.opcode === TLMessages.ArithmeticData) { when (bundle.opcode === TLMessages.ArithmeticData) {
assert (edge.client.supportsArithmetic(bundle.source, bundle.size), "'B' channel carries Arithmetic type unsupported by client")(sourceInfo) assert (edge.client.supportsArithmetic(bundle.source, bundle.size), "'B' channel carries Arithmetic type unsupported by client")
assert (address_ok, "'B' channel Arithmetic carries unmanaged address")(sourceInfo) assert (address_ok, "'B' channel Arithmetic carries unmanaged address")
assert (is_aligned, "'B' channel Arithmetic address not aligned to size")(sourceInfo) assert (is_aligned, "'B' channel Arithmetic address not aligned to size")
assert (TLAtomics.isArithmetic(bundle.param), "'B' channel Arithmetic carries invalid opcode param")(sourceInfo) assert (TLAtomics.isArithmetic(bundle.param), "'B' channel Arithmetic carries invalid opcode param")
assert (bundle.mask === mask, "'B' channel Arithmetic contains invalid mask")(sourceInfo) assert (bundle.mask === mask, "'B' channel Arithmetic contains invalid mask")
} }
when (bundle.opcode === TLMessages.LogicalData) { when (bundle.opcode === TLMessages.LogicalData) {
assert (edge.client.supportsLogical(bundle.source, bundle.size), "'B' channel carries Logical type unsupported by client")(sourceInfo) assert (edge.client.supportsLogical(bundle.source, bundle.size), "'B' channel carries Logical type unsupported by client")
assert (address_ok, "'B' channel Logical carries unmanaged address")(sourceInfo) assert (address_ok, "'B' channel Logical carries unmanaged address")
assert (is_aligned, "'B' channel Logical address not aligned to size")(sourceInfo) assert (is_aligned, "'B' channel Logical address not aligned to size")
assert (TLAtomics.isLogical(bundle.param), "'B' channel Logical carries invalid opcode param")(sourceInfo) assert (TLAtomics.isLogical(bundle.param), "'B' channel Logical carries invalid opcode param")
assert (bundle.mask === mask, "'B' channel Logical contains invalid mask")(sourceInfo) assert (bundle.mask === mask, "'B' channel Logical contains invalid mask")
} }
when (bundle.opcode === TLMessages.Hint) { when (bundle.opcode === TLMessages.Hint) {
assert (edge.client.supportsHint(bundle.source), "'B' channel carries Hint type unsupported by client")(sourceInfo) assert (edge.client.supportsHint(bundle.source), "'B' channel carries Hint type unsupported by client")
assert (address_ok, "'B' channel Hint carries unmanaged address")(sourceInfo) assert (address_ok, "'B' channel Hint carries unmanaged address")
assert (is_aligned, "'B' channel Hint address not aligned to size")(sourceInfo) assert (is_aligned, "'B' channel Hint address not aligned to size")
assert (bundle.mask === mask, "'B' channel Hint contains invalid mask")(sourceInfo) assert (bundle.mask === mask, "'B' channel Hint contains invalid mask")
} }
} }
def legalizeFormatC(bundle: TLBundleC, edge: TLEdgeOut, sourceInfo: SourceInfo) = { def legalizeFormatC(bundle: TLBundleC, edge: TLEdgeOut)(implicit sourceInfo: SourceInfo) = {
assert (TLMessages.isC(bundle.opcode), "'C' channel has invalid opcode")(sourceInfo) assert (TLMessages.isC(bundle.opcode), "'C' channel has invalid opcode")
val source_ok = edge.client.contains(bundle.source) val source_ok = edge.client.contains(bundle.source)
val is_aligned = edge.isAligned(bundle.address, bundle.size) val is_aligned = edge.isAligned(bundle.address, bundle.size)
val address_ok = edge.manager.contains(bundle.source) val address_ok = edge.manager.contains(bundle.source)
when (bundle.opcode === TLMessages.ProbeAck) { when (bundle.opcode === TLMessages.ProbeAck) {
assert (address_ok, "'C' channel ProbeAck carries unmanaged address")(sourceInfo) assert (address_ok, "'C' channel ProbeAck carries unmanaged address")
// source is ignored // source is ignored
assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'C' channel ProbeAck smaller than a beat")(sourceInfo) assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'C' channel ProbeAck smaller than a beat")
assert (is_aligned, "'C' channel ProbeAck address not aligned to size")(sourceInfo) assert (is_aligned, "'C' channel ProbeAck address not aligned to size")
assert (TLPermissions.isReport(bundle.param), "'C' channel ProbeAck carries invalid report param")(sourceInfo) assert (TLPermissions.isReport(bundle.param), "'C' channel ProbeAck carries invalid report param")
assert (!bundle.error, "'C' channel Probe carries an error")(sourceInfo) assert (!bundle.error, "'C' channel Probe carries an error")
} }
when (bundle.opcode === TLMessages.ProbeAckData) { when (bundle.opcode === TLMessages.ProbeAckData) {
assert (address_ok, "'C' channel ProbeAckData carries unmanaged address")(sourceInfo) assert (address_ok, "'C' channel ProbeAckData carries unmanaged address")
// source is ignored // source is ignored
assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'C' channel ProbeAckData smaller than a beat")(sourceInfo) assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'C' channel ProbeAckData smaller than a beat")
assert (is_aligned, "'C' channel ProbeAckData address not aligned to size")(sourceInfo) assert (is_aligned, "'C' channel ProbeAckData address not aligned to size")
assert (TLPermissions.isReport(bundle.param), "'C' channel ProbeAckData carries invalid report param")(sourceInfo) assert (TLPermissions.isReport(bundle.param), "'C' channel ProbeAckData carries invalid report param")
assert (!bundle.error, "'C' channel ProbeData carries an error")(sourceInfo) assert (!bundle.error, "'C' channel ProbeData carries an error")
} }
when (bundle.opcode === TLMessages.Release) { when (bundle.opcode === TLMessages.Release) {
assert (edge.manager.supportsAcquire(bundle.address, bundle.size), "'C' channel carries Release type unsupported by manager")(sourceInfo) assert (edge.manager.supportsAcquire(bundle.address, bundle.size), "'C' channel carries Release type unsupported by manager")
assert (source_ok, "'C' channel Release carries invalid source ID")(sourceInfo) assert (source_ok, "'C' channel Release carries invalid source ID")
assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'C' channel Release smaller than a beat")(sourceInfo) assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'C' channel Release smaller than a beat")
assert (is_aligned, "'C' channel Release address not aligned to size")(sourceInfo) assert (is_aligned, "'C' channel Release address not aligned to size")
assert (TLPermissions.isShrink(bundle.param), "'C' channel Release carries invalid shrink param")(sourceInfo) assert (TLPermissions.isShrink(bundle.param), "'C' channel Release carries invalid shrink param")
assert (!bundle.error, "'C' channel Release carries an error")(sourceInfo) assert (!bundle.error, "'C' channel Release carries an error")
} }
when (bundle.opcode === TLMessages.ReleaseData) { when (bundle.opcode === TLMessages.ReleaseData) {
assert (edge.manager.supportsAcquire(bundle.address, bundle.size), "'C' channel carries ReleaseData type unsupported by manager")(sourceInfo) assert (edge.manager.supportsAcquire(bundle.address, bundle.size), "'C' channel carries ReleaseData type unsupported by manager")
assert (source_ok, "'C' channel ReleaseData carries invalid source ID")(sourceInfo) assert (source_ok, "'C' channel ReleaseData carries invalid source ID")
assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'C' channel ReleaseData smaller than a beat")(sourceInfo) assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'C' channel ReleaseData smaller than a beat")
assert (is_aligned, "'C' channel ReleaseData address not aligned to size")(sourceInfo) assert (is_aligned, "'C' channel ReleaseData address not aligned to size")
assert (TLPermissions.isShrink(bundle.param), "'C' channel ReleaseData carries invalid shrink param")(sourceInfo) assert (TLPermissions.isShrink(bundle.param), "'C' channel ReleaseData carries invalid shrink param")
assert (!bundle.error, "'C' channel ReleaseData carries an error")(sourceInfo) assert (!bundle.error, "'C' channel ReleaseData carries an error")
} }
when (bundle.opcode === TLMessages.AccessAck) { when (bundle.opcode === TLMessages.AccessAck) {
assert (address_ok, "'C' channel AccessAck carries unmanaged address")(sourceInfo) assert (address_ok, "'C' channel AccessAck carries unmanaged address")
// source is ignored // source is ignored
assert (is_aligned, "'C' channel AccessAck address not aligned to size")(sourceInfo) assert (is_aligned, "'C' channel AccessAck address not aligned to size")
assert (bundle.param === UInt(0), "'C' channel AccessAck carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'C' channel AccessAck carries invalid param")
} }
when (bundle.opcode === TLMessages.AccessAckData) { when (bundle.opcode === TLMessages.AccessAckData) {
assert (address_ok, "'C' channel AccessAckData carries unmanaged address")(sourceInfo) assert (address_ok, "'C' channel AccessAckData carries unmanaged address")
// source is ignored // source is ignored
assert (is_aligned, "'C' channel AccessAckData address not aligned to size")(sourceInfo) assert (is_aligned, "'C' channel AccessAckData address not aligned to size")
assert (bundle.param === UInt(0), "'C' channel AccessAckData carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'C' channel AccessAckData carries invalid param")
} }
when (bundle.opcode === TLMessages.HintAck) { when (bundle.opcode === TLMessages.HintAck) {
assert (address_ok, "'C' channel HintAck carries unmanaged address")(sourceInfo) assert (address_ok, "'C' channel HintAck carries unmanaged address")
// source is ignored // source is ignored
assert (is_aligned, "'C' channel HintAck address not aligned to size")(sourceInfo) assert (is_aligned, "'C' channel HintAck address not aligned to size")
assert (bundle.param === UInt(0), "'C' channel HintAck carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'C' channel HintAck carries invalid param")
assert (!bundle.error, "'C' channel HintAck carries an error")(sourceInfo) assert (!bundle.error, "'C' channel HintAck carries an error")
} }
} }
def legalizeFormatD(bundle: TLBundleD, edge: TLEdgeIn, sourceInfo: SourceInfo) = { def legalizeFormatD(bundle: TLBundleD, edge: TLEdgeIn)(implicit sourceInfo: SourceInfo) = {
assert (TLMessages.isD(bundle.opcode), "'D' channel has invalid opcode")(sourceInfo) assert (TLMessages.isD(bundle.opcode), "'D' channel has invalid opcode")
val source_ok = edge.client.contains(bundle.source) val source_ok = edge.client.contains(bundle.source)
val sink_ok = edge.manager.containsById(bundle.sink) val sink_ok = edge.manager.containsById(bundle.sink)
when (bundle.opcode === TLMessages.ReleaseAck) { when (bundle.opcode === TLMessages.ReleaseAck) {
assert (source_ok, "'D' channel ReleaseAck carries invalid source ID")(sourceInfo) assert (source_ok, "'D' channel ReleaseAck carries invalid source ID")
// sink is ignored // sink is ignored
assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'D' channel ReleaseAck smaller than a beat")(sourceInfo) assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'D' channel ReleaseAck smaller than a beat")
assert (bundle.param === UInt(0), "'D' channel ReleaseeAck carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'D' channel ReleaseeAck carries invalid param")
assert (!bundle.error, "'D' channel ReleaseAck carries an error")(sourceInfo) assert (!bundle.error, "'D' channel ReleaseAck carries an error")
} }
when (bundle.opcode === TLMessages.Grant) { when (bundle.opcode === TLMessages.Grant) {
assert (source_ok, "'D' channel Grant carries invalid source ID")(sourceInfo) assert (source_ok, "'D' channel Grant carries invalid source ID")
assert (sink_ok, "'D' channel Grant carries invalid sink ID")(sourceInfo) assert (sink_ok, "'D' channel Grant carries invalid sink ID")
assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'D' channel Grant smaller than a beat")(sourceInfo) assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'D' channel Grant smaller than a beat")
assert (TLPermissions.isCap(bundle.param), "'D' channel Grant carries invalid cap param")(sourceInfo) assert (TLPermissions.isCap(bundle.param), "'D' channel Grant carries invalid cap param")
} }
when (bundle.opcode === TLMessages.GrantData) { when (bundle.opcode === TLMessages.GrantData) {
assert (source_ok, "'D' channel GrantData carries invalid source ID")(sourceInfo) assert (source_ok, "'D' channel GrantData carries invalid source ID")
assert (sink_ok, "'D' channel GrantData carries invalid sink ID")(sourceInfo) assert (sink_ok, "'D' channel GrantData carries invalid sink ID")
assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'D' channel GrantData smaller than a beat")(sourceInfo) assert (bundle.size >= UInt(log2Ceil(edge.manager.beatBytes)), "'D' channel GrantData smaller than a beat")
assert (TLPermissions.isCap(bundle.param), "'D' channel GrantData carries invalid cap param")(sourceInfo) assert (TLPermissions.isCap(bundle.param), "'D' channel GrantData carries invalid cap param")
} }
when (bundle.opcode === TLMessages.AccessAck) { when (bundle.opcode === TLMessages.AccessAck) {
assert (source_ok, "'D' channel AccessAck carries invalid source ID")(sourceInfo) assert (source_ok, "'D' channel AccessAck carries invalid source ID")
// sink is ignored // sink is ignored
// size is ignored // size is ignored
assert (bundle.param === UInt(0), "'D' channel AccessAck carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'D' channel AccessAck carries invalid param")
} }
when (bundle.opcode === TLMessages.AccessAckData) { when (bundle.opcode === TLMessages.AccessAckData) {
assert (source_ok, "'D' channel AccessAckData carries invalid source ID")(sourceInfo) assert (source_ok, "'D' channel AccessAckData carries invalid source ID")
// sink is ignored // sink is ignored
// size is ignored // size is ignored
assert (bundle.param === UInt(0), "'D' channel AccessAckData carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'D' channel AccessAckData carries invalid param")
} }
when (bundle.opcode === TLMessages.HintAck) { when (bundle.opcode === TLMessages.HintAck) {
assert (source_ok, "'D' channel HintAck carries invalid source ID")(sourceInfo) assert (source_ok, "'D' channel HintAck carries invalid source ID")
// sink is ignored // sink is ignored
// size is ignored // size is ignored
assert (bundle.param === UInt(0), "'D' channel HintAck carries invalid param")(sourceInfo) assert (bundle.param === UInt(0), "'D' channel HintAck carries invalid param")
assert (!bundle.error, "'D' channel HintAck carries an error")(sourceInfo) assert (!bundle.error, "'D' channel HintAck carries an error")
} }
} }
def legalizeFormatE(bundle: TLBundleE, edge: TLEdgeOut, sourceInfo: SourceInfo) = { def legalizeFormatE(bundle: TLBundleE, edge: TLEdgeOut)(implicit sourceInfo: SourceInfo) = {
assert (edge.manager.containsById(bundle.sink), "'E' channels carries invalid sink ID")(sourceInfo) assert (edge.manager.containsById(bundle.sink), "'E' channels carries invalid sink ID")
} }
def legalizeFormat(bundleOut: TLBundle, edgeOut: TLEdgeOut, bundleIn: TLBundle, edgeIn: TLEdgeIn, sourceInfo: SourceInfo) = { def legalizeFormat(bundleOut: TLBundle, edgeOut: TLEdgeOut, bundleIn: TLBundle, edgeIn: TLEdgeIn)(implicit sourceInfo: SourceInfo) = {
when (bundleOut.a.valid) { legalizeFormatA(bundleOut.a.bits, edgeOut, sourceInfo) } when (bundleOut.a.valid) { legalizeFormatA(bundleOut.a.bits, edgeOut) }
when (bundleIn .b.valid) { legalizeFormatB(bundleIn .b.bits, edgeIn, sourceInfo) } when (bundleIn .b.valid) { legalizeFormatB(bundleIn .b.bits, edgeIn) }
when (bundleOut.c.valid) { legalizeFormatC(bundleOut.c.bits, edgeOut, sourceInfo) } when (bundleOut.c.valid) { legalizeFormatC(bundleOut.c.bits, edgeOut) }
when (bundleIn .d.valid) { legalizeFormatD(bundleIn .d.bits, edgeIn, sourceInfo) } when (bundleIn .d.valid) { legalizeFormatD(bundleIn .d.bits, edgeIn) }
when (bundleOut.e.valid) { legalizeFormatE(bundleOut.e.bits, edgeOut, sourceInfo) } when (bundleOut.e.valid) { legalizeFormatE(bundleOut.e.bits, edgeOut) }
} }
def legalizeMultibeatA(a: DecoupledIO[TLBundleA], edge: TLEdgeOut, sourceInfo: SourceInfo) = { def legalizeMultibeatA(a: DecoupledIO[TLBundleA], edge: TLEdgeOut)(implicit sourceInfo: SourceInfo) = {
val counter = RegInit(UInt(0, width = log2Up(edge.maxTransfer))) val counter = RegInit(UInt(0, width = log2Up(edge.maxTransfer)))
val opcode = Reg(UInt()) val opcode = Reg(UInt())
val param = Reg(UInt()) val param = Reg(UInt())
@ -274,11 +274,11 @@ object TLMonitor
val source = Reg(UInt()) val source = Reg(UInt())
val address = Reg(UInt()) val address = Reg(UInt())
when (a.valid && counter =/= UInt(0)) { when (a.valid && counter =/= UInt(0)) {
assert (a.bits.opcode === opcode, "'A' channel opcode changed within multibeat operation")(sourceInfo) assert (a.bits.opcode === opcode, "'A' channel opcode changed within multibeat operation")
assert (a.bits.param === param, "'A' channel param changed within multibeat operation")(sourceInfo) assert (a.bits.param === param, "'A' channel param changed within multibeat operation")
assert (a.bits.size === size, "'A' channel size changed within multibeat operation")(sourceInfo) assert (a.bits.size === size, "'A' channel size changed within multibeat operation")
assert (a.bits.source === source, "'A' channel source changed within multibeat operation")(sourceInfo) assert (a.bits.source === source, "'A' channel source changed within multibeat operation")
assert (a.bits.address=== address,"'A' channel address changed with multibeat operation")(sourceInfo) assert (a.bits.address=== address,"'A' channel address changed with multibeat operation")
} }
when (a.fire()) { when (a.fire()) {
counter := counter - UInt(1) counter := counter - UInt(1)
@ -293,7 +293,7 @@ object TLMonitor
} }
} }
def legalizeMultibeatB(b: DecoupledIO[TLBundleB], edge: TLEdgeIn, sourceInfo: SourceInfo) = { def legalizeMultibeatB(b: DecoupledIO[TLBundleB], edge: TLEdgeIn)(implicit sourceInfo: SourceInfo) = {
val counter = RegInit(UInt(0, width = log2Up(edge.maxTransfer))) val counter = RegInit(UInt(0, width = log2Up(edge.maxTransfer)))
val opcode = Reg(UInt()) val opcode = Reg(UInt())
val param = Reg(UInt()) val param = Reg(UInt())
@ -301,11 +301,11 @@ object TLMonitor
val source = Reg(UInt()) val source = Reg(UInt())
val address = Reg(UInt()) val address = Reg(UInt())
when (b.valid && counter =/= UInt(0)) { when (b.valid && counter =/= UInt(0)) {
assert (b.bits.opcode === opcode, "'B' channel opcode changed within multibeat operation")(sourceInfo) assert (b.bits.opcode === opcode, "'B' channel opcode changed within multibeat operation")
assert (b.bits.param === param, "'B' channel param changed within multibeat operation")(sourceInfo) assert (b.bits.param === param, "'B' channel param changed within multibeat operation")
assert (b.bits.size === size, "'B' channel size changed within multibeat operation")(sourceInfo) assert (b.bits.size === size, "'B' channel size changed within multibeat operation")
assert (b.bits.source === source, "'B' channel source changed within multibeat operation")(sourceInfo) assert (b.bits.source === source, "'B' channel source changed within multibeat operation")
assert (b.bits.address=== address,"'B' channel address changed with multibeat operation")(sourceInfo) assert (b.bits.address=== address,"'B' channel address changed with multibeat operation")
} }
when (b.fire()) { when (b.fire()) {
counter := counter - UInt(1) counter := counter - UInt(1)
@ -320,7 +320,7 @@ object TLMonitor
} }
} }
def legalizeMultibeatC(c: DecoupledIO[TLBundleC], edge: TLEdgeOut, sourceInfo: SourceInfo) = { def legalizeMultibeatC(c: DecoupledIO[TLBundleC], edge: TLEdgeOut)(implicit sourceInfo: SourceInfo) = {
val counter = RegInit(UInt(0, width = log2Up(edge.maxTransfer))) val counter = RegInit(UInt(0, width = log2Up(edge.maxTransfer)))
val opcode = Reg(UInt()) val opcode = Reg(UInt())
val param = Reg(UInt()) val param = Reg(UInt())
@ -328,11 +328,11 @@ object TLMonitor
val source = Reg(UInt()) val source = Reg(UInt())
val address = Reg(UInt()) val address = Reg(UInt())
when (c.valid && counter =/= UInt(0)) { when (c.valid && counter =/= UInt(0)) {
assert (c.bits.opcode === opcode, "'C' channel opcode changed within multibeat operation")(sourceInfo) assert (c.bits.opcode === opcode, "'C' channel opcode changed within multibeat operation")
assert (c.bits.param === param, "'C' channel param changed within multibeat operation")(sourceInfo) assert (c.bits.param === param, "'C' channel param changed within multibeat operation")
assert (c.bits.size === size, "'C' channel size changed within multibeat operation")(sourceInfo) assert (c.bits.size === size, "'C' channel size changed within multibeat operation")
assert (c.bits.source === source, "'C' channel source changed within multibeat operation")(sourceInfo) assert (c.bits.source === source, "'C' channel source changed within multibeat operation")
assert (c.bits.address=== address,"'C' channel address changed with multibeat operation")(sourceInfo) assert (c.bits.address=== address,"'C' channel address changed with multibeat operation")
} }
when (c.fire()) { when (c.fire()) {
counter := counter - UInt(1) counter := counter - UInt(1)
@ -347,7 +347,7 @@ object TLMonitor
} }
} }
def legalizeMultibeatD(d: DecoupledIO[TLBundleD], edge: TLEdgeIn, sourceInfo: SourceInfo) = { def legalizeMultibeatD(d: DecoupledIO[TLBundleD], edge: TLEdgeIn)(implicit sourceInfo: SourceInfo) = {
val counter = RegInit(UInt(0, width = log2Up(edge.maxTransfer))) val counter = RegInit(UInt(0, width = log2Up(edge.maxTransfer)))
val opcode = Reg(UInt()) val opcode = Reg(UInt())
val param = Reg(UInt()) val param = Reg(UInt())
@ -355,11 +355,11 @@ object TLMonitor
val source = Reg(UInt()) val source = Reg(UInt())
val sink = Reg(UInt()) val sink = Reg(UInt())
when (d.valid && counter =/= UInt(0)) { when (d.valid && counter =/= UInt(0)) {
assert (d.bits.opcode === opcode, "'D' channel opcode changed within multibeat operation")(sourceInfo) assert (d.bits.opcode === opcode, "'D' channel opcode changed within multibeat operation")
assert (d.bits.param === param, "'D' channel param changed within multibeat operation")(sourceInfo) assert (d.bits.param === param, "'D' channel param changed within multibeat operation")
assert (d.bits.size === size, "'D' channel size changed within multibeat operation")(sourceInfo) assert (d.bits.size === size, "'D' channel size changed within multibeat operation")
assert (d.bits.source === source, "'D' channel source changed within multibeat operation")(sourceInfo) assert (d.bits.source === source, "'D' channel source changed within multibeat operation")
assert (d.bits.sink === sink, "'D' channel sink changed with multibeat operation")(sourceInfo) assert (d.bits.sink === sink, "'D' channel sink changed with multibeat operation")
} }
when (d.fire()) { when (d.fire()) {
counter := counter - UInt(1) counter := counter - UInt(1)
@ -374,15 +374,16 @@ object TLMonitor
} }
} }
def legalizeMultibeat(bundleOut: TLBundle, edgeOut: TLEdgeOut, bundleIn: TLBundle, edgeIn: TLEdgeIn, sourceInfo: SourceInfo) = { def legalizeMultibeat(bundleOut: TLBundle, edgeOut: TLEdgeOut, bundleIn: TLBundle, edgeIn: TLEdgeIn)(implicit sourceInfo: SourceInfo) = {
legalizeMultibeatA(bundleOut.a, edgeOut, sourceInfo) legalizeMultibeatA(bundleOut.a, edgeOut)
legalizeMultibeatB(bundleOut.b, edgeIn, sourceInfo) legalizeMultibeatB(bundleOut.b, edgeIn)
legalizeMultibeatC(bundleOut.c, edgeOut, sourceInfo) legalizeMultibeatC(bundleOut.c, edgeOut)
legalizeMultibeatD(bundleOut.d, edgeIn, sourceInfo) legalizeMultibeatD(bundleOut.d, edgeIn)
} }
def legalize(bundleOut: TLBundle, edgeOut: TLEdgeOut, bundleIn: TLBundle, edgeIn: TLEdgeIn, sourceInfo: SourceInfo) = { def legalize(bundleOut: TLBundle, edgeOut: TLEdgeOut, bundleIn: TLBundle, edgeIn: TLEdgeIn)(implicit sourceInfo: SourceInfo) = {
legalizeFormat(bundleOut, edgeOut, bundleIn, edgeIn, sourceInfo) legalizeFormat (bundleOut, edgeOut, bundleIn, edgeIn)
legalizeMultibeat(bundleOut, edgeOut, bundleIn, edgeIn, sourceInfo) legalizeMultibeat(bundleOut, edgeOut, bundleIn, edgeIn)
// !!! validate source uniqueness
} }
} }

View File

@ -21,7 +21,7 @@ object TLImp extends NodeImp[TLClientPortParameters, TLManagerPortParameters, TL
def connect(bo: TLBundle, eo: TLEdgeOut, bi: TLBundle, ei: TLEdgeIn)(implicit sourceInfo: SourceInfo): Unit = { def connect(bo: TLBundle, eo: TLEdgeOut, bi: TLBundle, ei: TLEdgeIn)(implicit sourceInfo: SourceInfo): Unit = {
require (eo.asInstanceOf[TLEdgeParameters] == ei.asInstanceOf[TLEdgeParameters]) require (eo.asInstanceOf[TLEdgeParameters] == ei.asInstanceOf[TLEdgeParameters])
TLMonitor.legalize(bo, eo, bi, ei, sourceInfo) TLMonitor.legalize(bo, eo, bi, ei)
bi <> bo bi <> bo
val mask = ~UInt(ei.manager.beatBytes - 1) val mask = ~UInt(ei.manager.beatBytes - 1)
bi.a.bits.address := (mask & bo.a.bits.address) bi.a.bits.address := (mask & bo.a.bits.address)