2016-08-31 00:01:49 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
|
|
|
package uncore.tilelink2
|
|
|
|
|
|
|
|
import Chisel._
|
|
|
|
import cde.Parameters
|
|
|
|
import uncore.tilelink._
|
|
|
|
import uncore.constants._
|
|
|
|
|
2016-09-06 22:12:33 +02:00
|
|
|
// Instantiate 'val p' before HasTileLinkParameters tries to use it
|
|
|
|
abstract class LegacyLazyModuleImp(module: LazyModule)(implicit val p: Parameters)
|
|
|
|
extends LazyModuleImp(module) with HasTileLinkParameters
|
|
|
|
|
2016-08-31 19:25:46 +02:00
|
|
|
class TLLegacy(implicit val p: Parameters) extends LazyModule with HasTileLinkParameters
|
2016-08-31 00:01:49 +02:00
|
|
|
{
|
|
|
|
// TL legacy clients don't support anything fancy
|
|
|
|
val node = TLClientNode(TLClientParameters(
|
|
|
|
sourceId = IdRange(0, 1 << tlClientXactIdBits)))
|
|
|
|
|
2016-09-06 22:12:33 +02:00
|
|
|
lazy val module = new LegacyLazyModuleImp(this) {
|
2016-08-31 00:01:49 +02:00
|
|
|
val io = new Bundle {
|
|
|
|
val legacy = new ClientUncachedTileLinkIO()(p).flip
|
|
|
|
val out = node.bundleOut
|
|
|
|
}
|
|
|
|
|
|
|
|
// TL legacy is dumb. All managers must support it's accesses.
|
|
|
|
val edge = node.edgesOut(0)
|
|
|
|
require (edge.manager.beatBytes == tlDataBytes)
|
2016-09-06 06:12:51 +02:00
|
|
|
edge.manager.managers.foreach { m =>
|
|
|
|
// If a slave supports read at all, it must support all TL Legacy requires
|
|
|
|
if (m.supportsGet) {
|
|
|
|
require (m.supportsGet.contains(TransferSizes(tlDataBytes)))
|
|
|
|
require (m.supportsGet.contains(TransferSizes(tlDataBeats * tlDataBytes)))
|
|
|
|
}
|
|
|
|
// Likewise, any put support must mean full put support
|
|
|
|
if (m.supportsPutPartial) {
|
|
|
|
require (m.supportsPutPartial.contains(TransferSizes(tlDataBytes)))
|
|
|
|
require (m.supportsPutPartial.contains(TransferSizes(tlDataBeats * tlDataBytes)))
|
|
|
|
}
|
|
|
|
// Any atomic support => must support 32-bit up to beat size of all types
|
|
|
|
if (m.supportsArithmetic || m.supportsLogical) {
|
|
|
|
require (m.supportsArithmetic.contains(TransferSizes(4, tlDataBytes)))
|
|
|
|
require (m.supportsLogical .contains(TransferSizes(4, tlDataBytes)))
|
|
|
|
}
|
|
|
|
// We straight-up require hints
|
|
|
|
require (edge.manager.allSupportHint)
|
|
|
|
}
|
|
|
|
// TL legacy will not generate PutFull
|
|
|
|
// During conversion from TL Legacy, we won't support Acquire
|
2016-08-31 00:01:49 +02:00
|
|
|
|
|
|
|
// Must be able to fit TL2 sink_id into TL legacy
|
2016-09-15 04:52:03 +02:00
|
|
|
require ((1 << tlManagerXactIdBits) >= edge.manager.endSinkId || !edge.manager.anySupportAcquire)
|
2016-08-31 00:01:49 +02:00
|
|
|
|
|
|
|
val out = io.out(0)
|
|
|
|
out.a.valid := io.legacy.acquire.valid
|
|
|
|
out.d.ready := io.legacy.grant .ready
|
|
|
|
io.legacy.acquire.ready := out.a.ready
|
|
|
|
io.legacy.grant .valid := out.d.valid
|
|
|
|
|
|
|
|
val source = io.legacy.acquire.bits.client_xact_id
|
|
|
|
val data = io.legacy.acquire.bits.data
|
|
|
|
val wmask = io.legacy.acquire.bits.wmask()
|
|
|
|
val address = io.legacy.acquire.bits.full_addr()
|
|
|
|
|
|
|
|
val beat = UInt(log2Ceil(tlDataBytes))
|
|
|
|
val block = UInt(log2Ceil(tlDataBytes*tlDataBeats))
|
|
|
|
|
2016-09-06 22:12:33 +02:00
|
|
|
// Only create atomic messages if TL2 managers support them
|
|
|
|
val atomics = if (edge.manager.anySupportLogical) {
|
2016-09-22 09:48:52 +02:00
|
|
|
val size = io.legacy.acquire.bits.op_size()
|
2016-09-06 22:12:33 +02:00
|
|
|
MuxLookup(io.legacy.acquire.bits.op_code(), Wire(new TLBundleA(edge.bundle)), Array(
|
2016-09-22 09:48:52 +02:00
|
|
|
MemoryOpConstants.M_XA_SWAP -> edge.Logical(source, address, size, data, TLAtomics.SWAP)._2,
|
|
|
|
MemoryOpConstants.M_XA_XOR -> edge.Logical(source, address, size, data, TLAtomics.XOR) ._2,
|
|
|
|
MemoryOpConstants.M_XA_OR -> edge.Logical(source, address, size, data, TLAtomics.OR) ._2,
|
|
|
|
MemoryOpConstants.M_XA_AND -> edge.Logical(source, address, size, data, TLAtomics.AND) ._2,
|
|
|
|
MemoryOpConstants.M_XA_ADD -> edge.Arithmetic(source, address, size, data, TLAtomics.ADD)._2,
|
|
|
|
MemoryOpConstants.M_XA_MIN -> edge.Arithmetic(source, address, size, data, TLAtomics.MIN)._2,
|
|
|
|
MemoryOpConstants.M_XA_MAX -> edge.Arithmetic(source, address, size, data, TLAtomics.MAX)._2,
|
|
|
|
MemoryOpConstants.M_XA_MINU -> edge.Arithmetic(source, address, size, data, TLAtomics.MINU)._2,
|
|
|
|
MemoryOpConstants.M_XA_MAXU -> edge.Arithmetic(source, address, size, data, TLAtomics.MAXU)._2))
|
2016-09-06 22:12:33 +02:00
|
|
|
} else {
|
2016-09-16 06:15:30 +02:00
|
|
|
// If no managers support atomics, assert fail if TL1 asks for them
|
|
|
|
assert (!io.legacy.acquire.valid || io.legacy.acquire.bits.a_type =/= Acquire.putAtomicType)
|
2016-09-06 22:12:33 +02:00
|
|
|
Wire(new TLBundleA(edge.bundle))
|
|
|
|
}
|
|
|
|
|
|
|
|
out.a.bits := MuxLookup(io.legacy.acquire.bits.a_type, Wire(new TLBundleA(edge.bundle)), Array(
|
|
|
|
Acquire.getType -> edge.Get (source, address, beat) ._2,
|
|
|
|
Acquire.getBlockType -> edge.Get (source, address, block)._2,
|
|
|
|
Acquire.putType -> edge.Put (source, address, beat, data, wmask)._2,
|
|
|
|
Acquire.putBlockType -> edge.Put (source, address, block, data, wmask)._2,
|
|
|
|
Acquire.getPrefetchType -> edge.Hint(source, address, block, UInt(0))._2,
|
|
|
|
Acquire.putPrefetchType -> edge.Hint(source, address, block, UInt(1))._2,
|
|
|
|
Acquire.putAtomicType -> atomics))
|
2016-08-31 00:01:49 +02:00
|
|
|
|
|
|
|
val beatMask = UInt(tlDataBytes-1)
|
|
|
|
val blockMask = UInt(tlDataBytes*tlDataBeats-1)
|
|
|
|
val addressMask = MuxLookup(io.legacy.acquire.bits.a_type, beatMask, Array(
|
|
|
|
Acquire.getType -> beatMask,
|
|
|
|
Acquire.getBlockType -> blockMask,
|
|
|
|
Acquire.putType -> beatMask,
|
|
|
|
Acquire.putBlockType -> blockMask,
|
|
|
|
Acquire.getPrefetchType -> blockMask,
|
|
|
|
Acquire.putPrefetchType -> blockMask,
|
|
|
|
Acquire.putAtomicType -> beatMask))
|
|
|
|
|
|
|
|
// Get rid of some unneeded muxes
|
|
|
|
out.a.bits.source := source
|
|
|
|
out.a.bits.data := data
|
2016-09-07 08:46:44 +02:00
|
|
|
out.a.bits.addr_hi := ~(~address | addressMask) >> log2Ceil(tlDataBytes)
|
2016-08-31 00:01:49 +02:00
|
|
|
|
|
|
|
// TL legacy does not support bus errors
|
2016-09-09 06:09:40 +02:00
|
|
|
assert (!out.d.valid || !out.d.bits.error)
|
2016-08-31 00:01:49 +02:00
|
|
|
|
|
|
|
// Recreate the beat address counter
|
|
|
|
val beatCounter = RegInit(UInt(0, width = tlBeatAddrBits))
|
2016-09-07 08:46:44 +02:00
|
|
|
when (out.d.fire() && edge.hasData(out.d.bits) && out.d.bits.size === block) {
|
2016-08-31 00:01:49 +02:00
|
|
|
beatCounter := beatCounter + UInt(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
val grant = io.legacy.grant.bits
|
|
|
|
grant.g_type := MuxLookup(out.d.bits.opcode, Grant.prefetchAckType, Array(
|
|
|
|
TLMessages.AccessAck -> Grant.putAckType,
|
2016-09-22 09:48:52 +02:00
|
|
|
TLMessages.AccessAckData -> Mux(out.d.bits.size === block, Grant.getDataBlockType, Grant.getDataBeatType),
|
2016-08-31 00:01:49 +02:00
|
|
|
TLMessages.HintAck -> Grant.prefetchAckType))
|
|
|
|
grant.is_builtin_type := Bool(true)
|
|
|
|
grant.client_xact_id := out.d.bits.source
|
|
|
|
grant.manager_xact_id := out.d.bits.sink
|
|
|
|
grant.data := out.d.bits.data
|
|
|
|
grant.addr_beat := beatCounter
|
2016-09-05 01:47:18 +02:00
|
|
|
|
|
|
|
// Tie off unused channels
|
|
|
|
out.b.ready := Bool(true)
|
|
|
|
out.c.valid := Bool(false)
|
|
|
|
out.e.valid := Bool(false)
|
2016-09-02 20:13:43 +02:00
|
|
|
}
|
2016-08-31 00:01:49 +02:00
|
|
|
}
|