2014-09-12 19:15:04 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
2014-09-01 05:26:55 +02:00
|
|
|
package rocketchip
|
2012-10-09 22:05:56 +02:00
|
|
|
|
|
|
|
import Chisel._
|
2015-07-30 02:56:19 +02:00
|
|
|
import junctions._
|
2012-10-09 22:05:56 +02:00
|
|
|
import uncore._
|
|
|
|
import rocket._
|
2013-01-25 08:56:45 +01:00
|
|
|
import rocket.Util._
|
2012-10-09 22:05:56 +02:00
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
/** Top-level parameters of RocketChip, values set in e.g. PublicConfigs.scala */
|
|
|
|
|
|
|
|
/** Number of tiles */
|
2014-08-08 21:27:47 +02:00
|
|
|
case object NTiles extends Field[Int]
|
2015-06-26 08:17:35 +02:00
|
|
|
/** Number of memory channels */
|
|
|
|
case object NMemoryChannels extends Field[Int]
|
|
|
|
/** Number of banks per memory channel */
|
|
|
|
case object NBanksPerMemoryChannel extends Field[Int]
|
|
|
|
/** Least significant bit of address used for bank partitioning */
|
2014-08-08 21:27:47 +02:00
|
|
|
case object BankIdLSB extends Field[Int]
|
2015-06-26 08:17:35 +02:00
|
|
|
/** Number of outstanding memory requests */
|
|
|
|
case object NOutstandingMemReqsPerChannel extends Field[Int]
|
|
|
|
/** Whether to use the slow backup memory port [VLSI] */
|
2014-08-25 04:30:53 +02:00
|
|
|
case object UseBackupMemoryPort extends Field[Boolean]
|
2015-06-26 08:17:35 +02:00
|
|
|
/** Function for building some kind of coherence manager agent */
|
|
|
|
case object BuildL2CoherenceManager extends Field[() => CoherenceAgent]
|
|
|
|
/** Function for building some kind of tile connected to a reset signal */
|
|
|
|
case object BuildTiles extends Field[Seq[(Bool) => Tile]]
|
2015-08-06 21:51:18 +02:00
|
|
|
/** Start address of the "io" region in the memory map */
|
|
|
|
case object ExternalIOStart extends Field[BigInt]
|
2015-06-26 08:17:35 +02:00
|
|
|
|
|
|
|
/** Utility trait for quick access to some relevant parameters */
|
|
|
|
trait TopLevelParameters extends UsesParameters {
|
2014-08-25 04:30:53 +02:00
|
|
|
val htifW = params(HTIFWidth)
|
|
|
|
val nTiles = params(NTiles)
|
2015-06-26 08:17:35 +02:00
|
|
|
val nMemChannels = params(NMemoryChannels)
|
|
|
|
val nBanksPerMemChannel = params(NBanksPerMemoryChannel)
|
|
|
|
val nBanks = nMemChannels*nBanksPerMemChannel
|
2014-08-25 04:30:53 +02:00
|
|
|
val lsb = params(BankIdLSB)
|
2015-06-26 08:17:35 +02:00
|
|
|
val nMemReqs = params(NOutstandingMemReqsPerChannel)
|
|
|
|
val mifAddrBits = params(MIFAddrBits)
|
|
|
|
val mifDataBeats = params(MIFDataBeats)
|
2015-08-06 21:51:18 +02:00
|
|
|
val scrAddrBits = log2Up(params(HTIFNSCR))
|
2015-09-25 21:13:22 +02:00
|
|
|
val pcrAddrBits = 12
|
|
|
|
val xLen = params(XLen)
|
2015-06-26 08:17:35 +02:00
|
|
|
require(lsb + log2Up(nBanks) < mifAddrBits)
|
2014-08-25 04:30:53 +02:00
|
|
|
}
|
2014-09-24 22:08:45 +02:00
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
class MemBackupCtrlIO extends Bundle {
|
|
|
|
val en = Bool(INPUT)
|
|
|
|
val in_valid = Bool(INPUT)
|
|
|
|
val out_ready = Bool(INPUT)
|
|
|
|
val out_valid = Bool(OUTPUT)
|
|
|
|
}
|
2012-10-09 22:05:56 +02:00
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
/** Top-level io for the chip */
|
|
|
|
class BasicTopIO extends Bundle {
|
|
|
|
val host = new HostIO
|
|
|
|
val mem_backup_ctrl = new MemBackupCtrlIO
|
|
|
|
}
|
2012-10-09 22:05:56 +02:00
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
class TopIO extends BasicTopIO {
|
|
|
|
val mem = new MemIO
|
|
|
|
}
|
|
|
|
|
|
|
|
class MultiChannelTopIO extends BasicTopIO with TopLevelParameters {
|
2015-09-25 01:59:13 +02:00
|
|
|
val mem = Vec(new NASTIIO, nMemChannels)
|
|
|
|
val mmio = new NASTIIO
|
2015-06-26 08:17:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Top-level module for the chip */
|
|
|
|
//TODO: Remove this wrapper once multichannel DRAM controller is provided
|
|
|
|
class Top extends Module with TopLevelParameters {
|
|
|
|
val io = new TopIO
|
2015-07-14 00:46:42 +02:00
|
|
|
if(!params(UseZscale)) {
|
|
|
|
val temp = Module(new MultiChannelTop)
|
2015-08-06 21:51:18 +02:00
|
|
|
val arb = Module(new NASTIArbiter(nMemChannels))
|
2015-09-25 01:59:13 +02:00
|
|
|
val conv = Module(new MemIONASTIIOConverter(params(CacheBlockOffsetBits)))
|
2015-08-06 21:51:18 +02:00
|
|
|
arb.io.master <> temp.io.mem
|
|
|
|
conv.io.nasti <> arb.io.slave
|
|
|
|
io.mem.req_cmd <> Queue(conv.io.mem.req_cmd)
|
|
|
|
io.mem.req_data <> Queue(conv.io.mem.req_data, mifDataBeats)
|
|
|
|
conv.io.mem.resp <> Queue(io.mem.resp, mifDataBeats)
|
2015-07-14 00:46:42 +02:00
|
|
|
io.mem_backup_ctrl <> temp.io.mem_backup_ctrl
|
|
|
|
io.host <> temp.io.host
|
2015-08-06 21:51:18 +02:00
|
|
|
|
|
|
|
// tie off the mmio port
|
|
|
|
val errslave = Module(new NASTIErrorSlave)
|
|
|
|
errslave.io <> temp.io.mmio
|
2015-07-14 00:46:42 +02:00
|
|
|
} else {
|
|
|
|
val temp = Module(new ZscaleTop)
|
|
|
|
io.host <> temp.io.host
|
|
|
|
}
|
2015-06-26 08:17:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class MultiChannelTop extends Module with TopLevelParameters {
|
|
|
|
val io = new MultiChannelTopIO
|
|
|
|
|
|
|
|
// Build an Uncore and a set of Tiles
|
|
|
|
val uncore = Module(new Uncore, {case TLId => "L1ToL2"})
|
|
|
|
val tileList = uncore.io.htif zip params(BuildTiles) map { case(hl, bt) => bt(hl.reset) }
|
|
|
|
|
|
|
|
// Connect each tile to the HTIF
|
|
|
|
uncore.io.htif.zip(tileList).zipWithIndex.foreach {
|
|
|
|
case ((hl, tile), i) =>
|
|
|
|
tile.io.host.id := UInt(i)
|
|
|
|
tile.io.host.reset := Reg(next=Reg(next=hl.reset))
|
2015-08-06 21:51:18 +02:00
|
|
|
tile.io.host.pcr.req <> Queue(hl.pcr.req)
|
|
|
|
hl.pcr.resp <> Queue(tile.io.host.pcr.resp)
|
2015-06-26 08:17:35 +02:00
|
|
|
hl.ipi_req <> Queue(tile.io.host.ipi_req)
|
|
|
|
tile.io.host.ipi_rep <> Queue(hl.ipi_rep)
|
|
|
|
hl.debug_stats_pcr := tile.io.host.debug_stats_pcr
|
2014-08-25 04:30:53 +02:00
|
|
|
}
|
2015-06-26 08:17:35 +02:00
|
|
|
|
|
|
|
// Connect the uncore to the tile memory ports, HostIO and MemIO
|
|
|
|
uncore.io.tiles_cached <> tileList.map(_.io.cached)
|
|
|
|
uncore.io.tiles_uncached <> tileList.map(_.io.uncached)
|
2015-08-04 03:54:56 +02:00
|
|
|
io.host <> uncore.io.host
|
|
|
|
io.mem <> uncore.io.mem
|
2015-08-06 21:51:18 +02:00
|
|
|
io.mmio <> uncore.io.mmio
|
2015-08-04 03:54:56 +02:00
|
|
|
if(params(UseBackupMemoryPort)) { io.mem_backup_ctrl <> uncore.io.mem_backup_ctrl }
|
2012-10-09 22:05:56 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
/** Wrapper around everything that isn't a Tile.
|
|
|
|
*
|
|
|
|
* Usually this is clocked and/or place-and-routed separately from the Tiles.
|
|
|
|
* Contains the Host-Target InterFace module (HTIF).
|
|
|
|
*/
|
2014-08-25 04:30:53 +02:00
|
|
|
class Uncore extends Module with TopLevelParameters {
|
2012-10-09 22:05:56 +02:00
|
|
|
val io = new Bundle {
|
2014-08-25 04:30:53 +02:00
|
|
|
val host = new HostIO
|
2015-09-25 01:59:13 +02:00
|
|
|
val mem = Vec(new NASTIIO, nMemChannels)
|
2015-09-20 22:43:39 +02:00
|
|
|
val tiles_cached = Vec(new ClientTileLinkIO, nTiles).flip
|
|
|
|
val tiles_uncached = Vec(new ClientUncachedTileLinkIO, nTiles).flip
|
|
|
|
val htif = Vec(new HTIFIO, nTiles).flip
|
2015-06-26 08:17:35 +02:00
|
|
|
val mem_backup_ctrl = new MemBackupCtrlIO
|
2015-09-25 01:59:13 +02:00
|
|
|
val mmio = new NASTIIO
|
2013-04-23 02:38:13 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
val htif = Module(new HTIF(CSRs.mreset)) // One HTIF module per chip
|
2014-08-25 04:30:53 +02:00
|
|
|
val outmemsys = Module(new OuterMemorySystem) // NoC, LLC and SerDes
|
2015-06-26 08:17:35 +02:00
|
|
|
outmemsys.io.incoherent := htif.io.cpu.map(_.reset)
|
|
|
|
outmemsys.io.htif_uncached <> htif.io.mem
|
|
|
|
outmemsys.io.tiles_uncached <> io.tiles_uncached
|
|
|
|
outmemsys.io.tiles_cached <> io.tiles_cached
|
2013-09-25 10:21:41 +02:00
|
|
|
|
2015-08-06 21:51:18 +02:00
|
|
|
for (i <- 0 until nTiles) {
|
|
|
|
io.htif(i).reset := htif.io.cpu(i).reset
|
|
|
|
io.htif(i).id := htif.io.cpu(i).id
|
|
|
|
htif.io.cpu(i).ipi_req <> io.htif(i).ipi_req
|
|
|
|
io.htif(i).ipi_rep <> htif.io.cpu(i).ipi_rep
|
|
|
|
htif.io.cpu(i).debug_stats_pcr <> io.htif(i).debug_stats_pcr
|
|
|
|
|
|
|
|
val pcr_arb = Module(new SMIArbiter(2, 64, 12))
|
|
|
|
pcr_arb.io.in(0) <> htif.io.cpu(i).pcr
|
|
|
|
pcr_arb.io.in(1) <> outmemsys.io.pcr(i)
|
|
|
|
io.htif(i).pcr <> pcr_arb.io.out
|
|
|
|
}
|
|
|
|
|
|
|
|
// Arbitrate SCR access between MMIO and HTIF
|
|
|
|
val scrArb = Module(new SMIArbiter(2, 64, scrAddrBits))
|
|
|
|
val scrFile = Module(new SCRFile)
|
|
|
|
|
|
|
|
scrArb.io.in(0) <> htif.io.scr
|
|
|
|
scrArb.io.in(1) <> outmemsys.io.scr
|
|
|
|
scrFile.io.smi <> scrArb.io.out
|
|
|
|
// scrFile.io.scr <> (... your SCR connections ...)
|
|
|
|
|
2014-08-25 04:30:53 +02:00
|
|
|
// Wire the htif to the memory port(s) and host interface
|
2013-09-25 10:21:41 +02:00
|
|
|
io.host.debug_stats_pcr := htif.io.host.debug_stats_pcr
|
2015-08-04 03:54:56 +02:00
|
|
|
io.mem <> outmemsys.io.mem
|
2015-08-06 21:51:18 +02:00
|
|
|
io.mmio <> outmemsys.io.mmio
|
2014-08-25 04:30:53 +02:00
|
|
|
if(params(UseBackupMemoryPort)) {
|
2015-06-26 08:17:35 +02:00
|
|
|
outmemsys.io.mem_backup_en := io.mem_backup_ctrl.en
|
2015-08-06 21:51:18 +02:00
|
|
|
VLSIUtils.padOutHTIFWithDividedClock(htif.io.host, scrFile.io.scr,
|
|
|
|
outmemsys.io.mem_backup, io.mem_backup_ctrl, io.host, htifW)
|
2014-08-25 04:30:53 +02:00
|
|
|
} else {
|
|
|
|
htif.io.host.out <> io.host.out
|
|
|
|
htif.io.host.in <> io.host.in
|
|
|
|
}
|
2012-10-09 22:05:56 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
/** The whole outer memory hierarchy, including a NoC, some kind of coherence
|
|
|
|
* manager agent, and a converter from TileLink to MemIO.
|
|
|
|
*/
|
|
|
|
class OuterMemorySystem extends Module with TopLevelParameters {
|
|
|
|
val io = new Bundle {
|
2015-09-20 22:43:39 +02:00
|
|
|
val tiles_cached = Vec(new ClientTileLinkIO, nTiles).flip
|
|
|
|
val tiles_uncached = Vec(new ClientUncachedTileLinkIO, nTiles).flip
|
2015-06-26 08:17:35 +02:00
|
|
|
val htif_uncached = (new ClientUncachedTileLinkIO).flip
|
2015-09-20 22:43:39 +02:00
|
|
|
val incoherent = Vec(Bool(), nTiles).asInput
|
2015-09-25 01:59:13 +02:00
|
|
|
val mem = Vec(new NASTIIO, nMemChannels)
|
2015-06-26 08:17:35 +02:00
|
|
|
val mem_backup = new MemSerializedIO(htifW)
|
|
|
|
val mem_backup_en = Bool(INPUT)
|
2015-09-25 21:13:22 +02:00
|
|
|
val pcr = Vec(new SMIIO(xLen, pcrAddrBits), nTiles)
|
|
|
|
val scr = new SMIIO(xLen, scrAddrBits)
|
2015-09-25 01:59:13 +02:00
|
|
|
val mmio = new NASTIIO
|
2012-10-09 22:05:56 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
// Create a simple L1toL2 NoC between the tiles+htif and the banks of outer memory
|
|
|
|
// Cached ports are first in client list, making sharerToClientId just an indentity function
|
|
|
|
// addrToBank is sed to hash physical addresses (of cache blocks) to banks (and thereby memory channels)
|
|
|
|
val ordered_clients = (io.tiles_cached ++ (io.tiles_uncached :+ io.htif_uncached).map(TileLinkIOWrapper(_)))
|
|
|
|
def sharerToClientId(sharerId: UInt) = sharerId
|
|
|
|
def addrToBank(addr: Bits): UInt = if(nBanks > 1) addr(lsb + log2Up(nBanks) - 1, lsb) else UInt(0)
|
|
|
|
val preBuffering = TileLinkDepths(2,2,2,2,2)
|
|
|
|
val postBuffering = TileLinkDepths(0,0,1,0,0) //TODO: had EOS24 crit path on inner.release
|
|
|
|
val l1tol2net = Module(
|
|
|
|
if(nBanks == 1) new RocketChipTileLinkArbiter(sharerToClientId, preBuffering, postBuffering)
|
|
|
|
else new RocketChipTileLinkCrossbar(addrToBank, sharerToClientId, preBuffering, postBuffering))
|
|
|
|
|
|
|
|
// Create point(s) of coherence serialization
|
2015-08-06 21:51:18 +02:00
|
|
|
val nManagers = nMemChannels * nBanksPerMemChannel
|
|
|
|
val managerEndpoints = List.fill(nManagers) { params(BuildL2CoherenceManager)()}
|
|
|
|
managerEndpoints.foreach { _.incoherent := io.incoherent }
|
2015-06-26 08:17:35 +02:00
|
|
|
|
|
|
|
// Wire the tiles and htif to the TileLink client ports of the L1toL2 network,
|
|
|
|
// and coherence manager(s) to the other side
|
|
|
|
l1tol2net.io.clients <> ordered_clients
|
2015-08-06 21:51:18 +02:00
|
|
|
l1tol2net.io.managers <> managerEndpoints.map(_.innerTL)
|
2015-06-26 08:17:35 +02:00
|
|
|
|
|
|
|
// Create a converter between TileLinkIO and MemIO for each channel
|
|
|
|
val outerTLParams = params.alterPartial({ case TLId => "L2ToMC" })
|
|
|
|
val backendBuffering = TileLinkDepths(0,0,0,0,0)
|
2015-08-06 21:51:18 +02:00
|
|
|
|
|
|
|
val addrMap = params(NASTIAddrHashMap)
|
|
|
|
|
|
|
|
println("Generated Address Map")
|
|
|
|
for ((name, base, size, _) <- addrMap.sortedEntries) {
|
|
|
|
println(f"\t$name%s $base%x - ${base + size - 1}%x")
|
2015-06-26 08:17:35 +02:00
|
|
|
}
|
2014-08-25 04:30:53 +02:00
|
|
|
|
2015-08-06 21:51:18 +02:00
|
|
|
val interconnect = Module(new NASTITopInterconnect)
|
|
|
|
|
|
|
|
for ((bank, i) <- managerEndpoints.zipWithIndex) {
|
2015-10-13 21:46:23 +02:00
|
|
|
val factor = params(TLDataBits) / params(MIFDataBits)
|
|
|
|
val outermostTLParams = outerTLParams.alterPartial({
|
|
|
|
case TLDataBeats => params(MIFDataBeats)
|
|
|
|
case TLDataBits => params(MIFDataBits)
|
|
|
|
})
|
2015-08-06 21:51:18 +02:00
|
|
|
val unwrap = Module(new ClientTileLinkIOUnwrapper)(outerTLParams)
|
2015-10-13 21:46:23 +02:00
|
|
|
val narrow = Module(new TileLinkIONarrower(factor))(outerTLParams)
|
|
|
|
val conv = Module(new NASTIIOTileLinkIOConverter)(outermostTLParams)
|
2015-08-06 21:51:18 +02:00
|
|
|
unwrap.io.in <> bank.outerTL
|
2015-10-13 21:46:23 +02:00
|
|
|
narrow.io.in <> unwrap.io.out
|
|
|
|
conv.io.tl <> narrow.io.out
|
2015-08-06 21:51:18 +02:00
|
|
|
interconnect.io.masters(i) <> conv.io.nasti
|
|
|
|
}
|
|
|
|
|
|
|
|
val rtc = Module(new RTC(CSRs.mtime))
|
|
|
|
interconnect.io.masters(nManagers) <> rtc.io
|
|
|
|
|
|
|
|
for (i <- 0 until nTiles) {
|
|
|
|
val csrName = s"conf:csr$i"
|
|
|
|
val csrPort = addrMap(csrName).port
|
2015-09-25 21:13:22 +02:00
|
|
|
val conv = Module(new SMIIONASTIIOConverter(xLen, pcrAddrBits))
|
2015-08-06 21:51:18 +02:00
|
|
|
conv.io.nasti <> interconnect.io.slaves(csrPort)
|
|
|
|
io.pcr(i) <> conv.io.smi
|
|
|
|
}
|
|
|
|
|
2015-09-25 21:13:22 +02:00
|
|
|
val conv = Module(new SMIIONASTIIOConverter(xLen, scrAddrBits))
|
2015-08-06 21:51:18 +02:00
|
|
|
conv.io.nasti <> interconnect.io.slaves(addrMap("conf:scr").port)
|
|
|
|
io.scr <> conv.io.smi
|
|
|
|
|
|
|
|
io.mmio <> interconnect.io.slaves(addrMap("io").port)
|
|
|
|
|
|
|
|
val mem_channels = interconnect.io.slaves.take(nMemChannels)
|
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
// Create a SerDes for backup memory port
|
2014-08-25 04:30:53 +02:00
|
|
|
if(params(UseBackupMemoryPort)) {
|
2015-08-06 21:51:18 +02:00
|
|
|
VLSIUtils.doOuterMemorySystemSerdes(
|
|
|
|
mem_channels, io.mem, io.mem_backup, io.mem_backup_en,
|
|
|
|
nMemChannels, params(HTIFWidth), params(CacheBlockOffsetBits))
|
2015-06-26 08:17:35 +02:00
|
|
|
} else { io.mem <> mem_channels }
|
2012-10-09 22:05:56 +02:00
|
|
|
}
|