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._
|
|
|
|
import uncore._
|
|
|
|
import rocket._
|
2013-01-25 08:56:45 +01:00
|
|
|
import rocket.Util._
|
2012-10-09 22:05:56 +02:00
|
|
|
|
2014-08-08 21:27:47 +02:00
|
|
|
case object NTiles extends Field[Int]
|
|
|
|
case object NBanks extends Field[Int]
|
|
|
|
case object BankIdLSB extends Field[Int]
|
2014-08-23 10:26:03 +02:00
|
|
|
case object CacheBlockBytes extends Field[Int]
|
|
|
|
case object CacheBlockOffsetBits extends Field[Int]
|
2014-08-25 04:30:53 +02:00
|
|
|
case object BuildDRAMSideLLC extends Field[(Int) => DRAMSideLLCLike]
|
|
|
|
case object BuildCoherenceMaster extends Field[(Int) => CoherenceAgent]
|
|
|
|
case object UseBackupMemoryPort extends Field[Boolean]
|
2014-08-08 21:27:47 +02:00
|
|
|
case object Coherence extends Field[CoherencePolicyWithUncached]
|
2013-08-24 22:20:38 +02:00
|
|
|
|
2014-08-25 04:30:53 +02:00
|
|
|
abstract trait TopLevelParameters extends UsesParameters {
|
|
|
|
val htifW = params(HTIFWidth)
|
|
|
|
val nTiles = params(NTiles)
|
|
|
|
val nBanks = params(NBanks)
|
|
|
|
val lsb = params(BankIdLSB)
|
|
|
|
val refillCycles = params(MIFDataBeats)
|
|
|
|
}
|
|
|
|
class OuterMemorySystem extends Module with TopLevelParameters {
|
2012-10-09 22:05:56 +02:00
|
|
|
val io = new Bundle {
|
2014-08-08 21:27:47 +02:00
|
|
|
val tiles = Vec.fill(params(NTiles)){new TileLinkIO}.flip
|
2013-01-07 23:19:55 +01:00
|
|
|
val htif = (new TileLinkIO).flip
|
2014-08-08 21:27:47 +02:00
|
|
|
val incoherent = Vec.fill(params(LNClients)){Bool()}.asInput
|
2014-03-30 17:13:05 +02:00
|
|
|
val mem = new MemIO
|
2014-08-08 21:27:47 +02:00
|
|
|
val mem_backup = new MemSerializedIO(params(HTIFWidth))
|
2012-10-09 22:05:56 +02:00
|
|
|
val mem_backup_en = Bool(INPUT)
|
|
|
|
}
|
|
|
|
|
2014-08-25 04:30:53 +02:00
|
|
|
// Create a simple NoC and points of coherence serialization
|
2014-09-01 05:26:55 +02:00
|
|
|
val net = Module(new RocketChipCrossbarNetwork)
|
2014-08-25 04:30:53 +02:00
|
|
|
val masterEndpoints = (0 until params(NBanks)).map(params(BuildCoherenceMaster))
|
2014-01-21 21:37:47 +01:00
|
|
|
net.io.clients zip (io.tiles :+ io.htif) map { case (net, end) => net <> end }
|
2014-04-30 01:50:07 +02:00
|
|
|
net.io.masters zip (masterEndpoints.map(_.io.inner)) map { case (net, end) => net <> end }
|
2013-08-03 00:02:09 +02:00
|
|
|
masterEndpoints.map{ _.io.incoherent zip io.incoherent map { case (m, c) => m := c } }
|
2013-03-20 22:11:54 +01:00
|
|
|
|
2014-08-25 04:30:53 +02:00
|
|
|
// Create a converter between TileLinkIO and MemIO
|
2013-08-12 19:46:22 +02:00
|
|
|
val conv = Module(new MemIOUncachedTileLinkIOConverter(2))
|
2014-08-08 21:27:47 +02:00
|
|
|
if(params(NBanks) > 1) {
|
|
|
|
val arb = Module(new UncachedTileLinkIOArbiterThatAppendsArbiterId(params(NBanks)))
|
2014-04-30 01:50:07 +02:00
|
|
|
arb.io.in zip masterEndpoints.map(_.io.outer) map { case (arb, cache) => arb <> cache }
|
2013-03-20 22:11:54 +01:00
|
|
|
conv.io.uncached <> arb.io.out
|
|
|
|
} else {
|
2014-04-30 01:50:07 +02:00
|
|
|
conv.io.uncached <> masterEndpoints.head.io.outer
|
2012-10-09 22:05:56 +02:00
|
|
|
}
|
|
|
|
|
2014-08-25 04:30:53 +02:00
|
|
|
// Create a DRAM-side LLC
|
|
|
|
val llc = params(BuildDRAMSideLLC)(refillCycles)
|
|
|
|
llc.io.cpu.req_cmd <> Queue(conv.io.mem.req_cmd, 2)
|
|
|
|
llc.io.cpu.req_data <> Queue(conv.io.mem.req_data, refillCycles)
|
|
|
|
conv.io.mem.resp <> llc.io.cpu.resp
|
|
|
|
|
|
|
|
// Create a SerDes for backup memory port
|
|
|
|
if(params(UseBackupMemoryPort)) {
|
|
|
|
VLSIUtils.doOuterMemorySystemSerdes(llc.io.mem, io.mem, io.mem_backup,
|
2014-08-28 22:07:54 +02:00
|
|
|
io.mem_backup_en, htifW)
|
2014-08-25 04:30:53 +02:00
|
|
|
} else {
|
|
|
|
io.mem <> llc.io.mem
|
|
|
|
}
|
2012-10-09 22:05:56 +02:00
|
|
|
}
|
|
|
|
|
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
|
2014-03-30 17:13:05 +02:00
|
|
|
val mem = new MemIO
|
2014-08-25 04:30:53 +02:00
|
|
|
val tiles = Vec.fill(nTiles){new TileLinkIO}.flip
|
|
|
|
val htif = Vec.fill(nTiles){new HTIFIO}.flip
|
|
|
|
val incoherent = Vec.fill(nTiles){Bool()}.asInput
|
|
|
|
val mem_backup = new MemSerializedIO(htifW)
|
2012-10-09 22:05:56 +02:00
|
|
|
val mem_backup_en = Bool(INPUT)
|
|
|
|
}
|
|
|
|
|
2014-08-25 04:30:53 +02:00
|
|
|
// Used to hash physical addresses to banks
|
|
|
|
require(params(BankIdLSB) + log2Up(params(NBanks)) < params(MIFAddrBits))
|
|
|
|
def addrToBank(addr: Bits): UInt = {
|
|
|
|
if(nBanks > 1) addr( lsb + log2Up(nBanks) - 1, lsb)
|
|
|
|
else UInt(0)
|
2013-04-23 02:38:13 +02:00
|
|
|
}
|
|
|
|
|
2014-08-25 04:30:53 +02:00
|
|
|
val htif = Module(new HTIF(CSRs.reset)) // One HTIF module per chip
|
|
|
|
val outmemsys = Module(new OuterMemorySystem) // NoC, LLC and SerDes
|
|
|
|
|
|
|
|
// Wire outer mem system to tiles and htif, adding
|
|
|
|
// networking headers and endpoint queues
|
|
|
|
(outmemsys.io.tiles :+ outmemsys.io.htif) // Collect outward-facing TileLink ports
|
|
|
|
.zip(io.tiles :+ htif.io.mem) // Zip them with matching ports from clients
|
|
|
|
.zipWithIndex // Index them
|
|
|
|
.map { case ((outer, client), i) => // Then use the index and bank hash to
|
|
|
|
// overwrite the networking header
|
|
|
|
outer.acquire <> Queue(TileLinkHeaderOverwriter(client.acquire, i, nBanks, addrToBank _))
|
|
|
|
outer.release <> Queue(TileLinkHeaderOverwriter(client.release, i, nBanks, addrToBank _))
|
2014-04-27 04:16:37 +02:00
|
|
|
outer.finish <> Queue(TileLinkHeaderOverwriter(client.finish, i, true))
|
2013-03-20 22:11:54 +01:00
|
|
|
client.grant <> Queue(outer.grant, 1, pipe = true)
|
|
|
|
client.probe <> Queue(outer.probe)
|
2014-08-25 04:30:53 +02:00
|
|
|
}
|
|
|
|
outmemsys.io.incoherent := (io.incoherent :+ Bool(true).asInput)
|
2013-09-25 10:21:41 +02:00
|
|
|
|
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
|
2014-08-25 04:30:53 +02:00
|
|
|
htif.io.cpu <> io.htif
|
|
|
|
outmemsys.io.mem <> io.mem
|
|
|
|
if(params(UseBackupMemoryPort)) {
|
|
|
|
outmemsys.io.mem_backup_en := io.mem_backup_en
|
|
|
|
VLSIUtils.padOutHTIFWithDividedClock(htif.io, outmemsys.io.mem_backup,
|
|
|
|
io.mem_backup, io.host, io.mem_backup_en, htifW)
|
|
|
|
} else {
|
|
|
|
htif.io.host.out <> io.host.out
|
|
|
|
htif.io.host.in <> io.host.in
|
|
|
|
}
|
2012-10-09 22:05:56 +02:00
|
|
|
}
|
|
|
|
|
2014-08-25 04:30:53 +02:00
|
|
|
class TopIO extends Bundle {
|
|
|
|
val host = new HostIO
|
2014-03-30 17:13:05 +02:00
|
|
|
val mem = new MemIO
|
2012-10-09 22:05:56 +02:00
|
|
|
val mem_backup_en = Bool(INPUT)
|
2012-10-23 12:31:34 +02:00
|
|
|
val in_mem_ready = Bool(OUTPUT)
|
|
|
|
val in_mem_valid = Bool(INPUT)
|
|
|
|
val out_mem_ready = Bool(INPUT)
|
|
|
|
val out_mem_valid = Bool(OUTPUT)
|
2012-10-09 22:05:56 +02:00
|
|
|
}
|
|
|
|
|
2014-08-25 04:30:53 +02:00
|
|
|
class Top extends Module with TopLevelParameters {
|
|
|
|
val io = new TopIO
|
2014-08-08 21:27:47 +02:00
|
|
|
|
|
|
|
val resetSigs = Vec.fill(nTiles){Bool()}
|
2014-08-23 10:26:03 +02:00
|
|
|
val tileList = (0 until nTiles).map(r => Module(new Tile(resetSignal = resetSigs(r))))
|
|
|
|
val uncore = Module(new Uncore)
|
2014-08-08 21:27:47 +02:00
|
|
|
|
|
|
|
for (i <- 0 until nTiles) {
|
2012-10-09 22:05:56 +02:00
|
|
|
val hl = uncore.io.htif(i)
|
|
|
|
val tl = uncore.io.tiles(i)
|
2013-01-07 23:19:55 +01:00
|
|
|
val il = uncore.io.incoherent(i)
|
2012-10-19 02:51:41 +02:00
|
|
|
|
2012-12-13 01:41:21 +01:00
|
|
|
resetSigs(i) := hl.reset
|
|
|
|
val tile = tileList(i)
|
2014-04-27 04:16:37 +02:00
|
|
|
|
2013-03-20 22:11:54 +01:00
|
|
|
tile.io.tilelink <> tl
|
|
|
|
il := hl.reset
|
2014-04-27 04:16:37 +02:00
|
|
|
tile.io.host.id := UInt(i)
|
2013-08-16 01:37:58 +02:00
|
|
|
tile.io.host.reset := Reg(next=Reg(next=hl.reset))
|
2014-08-25 04:30:53 +02:00
|
|
|
tile.io.host.pcr_req <> Queue(hl.pcr_req)
|
|
|
|
hl.pcr_rep <> Queue(tile.io.host.pcr_rep)
|
|
|
|
hl.ipi_req <> Queue(tile.io.host.ipi_req)
|
|
|
|
tile.io.host.ipi_rep <> Queue(hl.ipi_rep)
|
2013-09-25 10:21:41 +02:00
|
|
|
hl.debug_stats_pcr := tile.io.host.debug_stats_pcr
|
2012-10-09 22:05:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
io.host <> uncore.io.host
|
|
|
|
io.mem <> uncore.io.mem
|
2014-08-25 04:30:53 +02:00
|
|
|
|
|
|
|
if(params(UseBackupMemoryPort)) {
|
|
|
|
uncore.io.mem_backup.resp.valid := io.in_mem_valid
|
|
|
|
io.out_mem_valid := uncore.io.mem_backup.req.valid
|
|
|
|
uncore.io.mem_backup.req.ready := io.out_mem_ready
|
|
|
|
io.mem_backup_en <> uncore.io.mem_backup_en
|
|
|
|
}
|
2012-10-09 22:05:56 +02:00
|
|
|
}
|