Skip to content

Commit

Permalink
Merge pull request chipsalliance#443 from ucb-bar/tl2-tlb
Browse files Browse the repository at this point in the history
Tl2 tlb
  • Loading branch information
yunsup authored Nov 22, 2016
2 parents 94cc1ef + 3d644b9 commit 42b4013
Show file tree
Hide file tree
Showing 19 changed files with 114 additions and 119 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ addons:

env:
matrix:
- SUITE=RocketSuite
- SUITE=RocketSuiteA
- SUITE=RocketSuiteB
- SUITE=RocketSuiteC
- SUITE=GroundtestSuite
- SUITE=UnittestSuite

Expand All @@ -44,6 +46,9 @@ branches:
- boom
- /^hurricane.*$/

install:
- make tools verilator -C regression SUITE=none

before_install:
- export CXX=g++-4.8 CC=gcc-4.8

Expand All @@ -52,4 +57,4 @@ script:
- make emulator-regression-tests -C regression SUITE=$SUITE TORTURE_CONFIG=default

before_cache:
- ls -tr regression/install | tail -n+2 | sed s@^@regression/install/@ | xargs rm -rf
- ls -t regression/install | tail -n+2 | sed s@^@regression/install/@ | xargs rm -rf
2 changes: 2 additions & 0 deletions emulator/Makefrag-verilator
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ verilator/verilator-$(VERILATOR_VERSION).tar.gz:
mkdir -p $(dir $@)
wget http://www.veripool.org/ftp/verilator-$(VERILATOR_VERSION).tgz -O $@

verilator: $(INSTALLED_VERILATOR)

# Run Verilator to produce a fast binary to emulate this circuit.
VERILATOR := $(INSTALLED_VERILATOR) --cc --exe
VERILATOR_FLAGS := --top-module $(MODEL) \
Expand Down
18 changes: 15 additions & 3 deletions regression/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,26 @@ ifeq ($(SUITE),)
$(error Set SUITE to the regression suite you want to run)
endif

ifeq ($(SUITE),RocketSuite)
ifeq ($(SUITE),RocketSuiteA)
PROJECT=rocketchip
CONFIGS=DefaultConfig DefaultBufferlessConfig TinyConfig
CONFIGS=DefaultConfig
endif

ifeq ($(SUITE),RocketSuiteB)
PROJECT=rocketchip
CONFIGS=DefaultBufferlessConfig
endif

ifeq ($(SUITE),RocketSuiteC)
PROJECT=rocketchip
CONFIGS=DefaultL2Config TinyConfig
endif

ifeq ($(SUITE),GroundtestSuite)
PROJECT=groundtest
CONFIGS=MemtestConfig MemtestBufferlessConfig MemtestStatelessConfig FancyMemtestConfig \
BroadcastRegressionTestConfig BufferlessRegressionTestConfig CacheRegressionTestConfig \
ComparatorConfig ComparatorBufferlessConfig ComparatorStatelessConfig
ComparatorConfig ComparatorBufferlessConfig ComparatorL2Config ComparatorStatelessConfig
endif

ifeq ($(SUITE),UnittestSuite)
Expand All @@ -68,6 +78,8 @@ endif
# commandline a bit cleaner.
submodules: stamps/other-submodules.stamp
tools: $(RISCV)/install.stamp
verilator:
$(MAKE) RISCV=$(RISCV) -C $(abspath $(TOP)/emulator) verilator

EMU_DEBUG_STAMPS=$(foreach config,$(CONFIGS),stamps/$(config)/emulator-debug.stamp)
EMU_NDEBUG_STAMPS=$(foreach config,$(CONFIGS),stamps/$(config)/emulator-ndebug.stamp)
Expand Down
11 changes: 11 additions & 0 deletions src/main/scala/coreplex/BaseCoreplex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ trait CoreplexNetworkModule extends HasCoreplexParameters {
val io: CoreplexNetworkBundle

implicit val p = outer.p

println("\nGenerated Address Map")
for (manager <- outer.l1tol2.node.edgesIn(0).manager.managers) {
val prot = (if (manager.supportsGet) "R" else "") +
(if (manager.supportsPutFull) "W" else "") +
(if (manager.executable) "X" else "") +
(if (manager.supportsAcquire) " [C]" else "")
manager.address.foreach { a =>
println(f"\t${manager.name}%s ${a.base}%x - ${a.base+a.mask+1}%x, $prot")
}
}
}

trait BankedL2CoherenceManagers extends CoreplexNetwork {
Expand Down
28 changes: 7 additions & 21 deletions src/main/scala/coreplex/RISCVPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ trait CoreplexRISCVPlatform extends CoreplexNetwork {
clint.node := TLFragmenter(cbus_beatBytes, cbus_lineBytes)(cbus.node)

plic.intnode := intBar.intnode

lazy val configString = {
val managers = l1tol2.node.edgesIn(0).manager.managers
rocketchip.GenerateConfigString(p, clint, plic, managers)
}
}

trait CoreplexRISCVPlatformBundle extends CoreplexNetworkBundle {
Expand All @@ -48,25 +53,6 @@ trait CoreplexRISCVPlatformModule extends CoreplexNetworkModule {
val rtcLast = Reg(init = Bool(false), next=rtcSync)
outer.clint.module.io.rtcTick := Reg(init = Bool(false), next=(rtcSync & (~rtcLast)))

println("\nGenerated Address Map")
for (entry <- p(rocketchip.GlobalAddrMap).flatten) {
val name = entry.name
val start = entry.region.start
val end = entry.region.start + entry.region.size - 1
val prot = entry.region.attr.prot
val protStr = (if ((prot & AddrMapProt.R) > 0) "R" else "") +
(if ((prot & AddrMapProt.W) > 0) "W" else "") +
(if ((prot & AddrMapProt.X) > 0) "X" else "")
val cacheable = if (entry.region.attr.cacheable) " [C]" else ""
println(f"\t$name%s $start%x - $end%x, $protStr$cacheable")
}

// Create and export the ConfigString
val managers = outer.l1tol2.node.edgesIn(0).manager.managers
val configString = rocketchip.GenerateConfigString(p, outer.clint, outer.plic, managers)
// Allow something else to have override the config string
if (!ConfigStringOutput.contents.isDefined) {
ConfigStringOutput.contents = Some(configString)
}
println(s"\nGenerated Configuration String\n${ConfigStringOutput.contents.get}")
println(s"\nGenerated Configuration String\n${outer.configString}")
ConfigStringOutput.contents = Some(outer.configString)
}
7 changes: 5 additions & 2 deletions src/main/scala/groundtest/Tile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ abstract class GroundTest(implicit val p: Parameters) extends Module
}

class GroundTestTile(implicit val p: Parameters) extends LazyModule with HasGroundTestParameters {
val dcacheParams = p.alterPartial({ case CacheName => CacheName("L1D") })
val dcacheParams = p.alterPartial {
case CacheName => CacheName("L1D")
case rocket.TLCacheEdge => cachedOut.edgesOut(0)
}
val slave = None
val dcache = HellaCache(p(DCacheKey))(dcacheParams)
val ucLegacy = LazyModule(new TLLegacy()(p))
Expand Down Expand Up @@ -141,7 +144,7 @@ class GroundTestTile(implicit val p: Parameters) extends LazyModule with HasGrou
}

if (ptwPorts.size > 0) {
val ptw = Module(new DummyPTW(ptwPorts.size))
val ptw = Module(new DummyPTW(ptwPorts.size)(dcacheParams))
ptw.io.requestors <> ptwPorts
}

Expand Down
7 changes: 0 additions & 7 deletions src/main/scala/junctions/addrmap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import scala.collection.mutable.HashMap

case object PAddrBits extends Field[Int]

trait HasAddrMapParameters {
implicit val p: Parameters

val paddrBits = p(PAddrBits)
def addrMap = p(rocketchip.GlobalAddrMap)
}

case class MemAttr(prot: Int, cacheable: Boolean = false)

sealed abstract class MemRegion {
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/rocket/Dcache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DCacheDataArray(implicit p: Parameters) extends L1HellaCacheModule()(p) {
}
}

class DCache(cfg: DCacheConfig)(implicit p: Parameters) extends HellaCache(cfg)(p) {
class DCache(cfg: DCacheConfig, val scratch: () => Option[AddressSet])(implicit p: Parameters) extends HellaCache(cfg)(p) {
override lazy val module = new DCacheModule(this)
}

Expand Down Expand Up @@ -123,7 +123,7 @@ class DCacheModule(outer: DCache)(implicit p: Parameters) extends HellaCacheModu
require(nWays == 1)
metaWriteArb.io.out.ready := true
metaReadArb.io.out.ready := !metaWriteArb.io.out.valid
val inScratchpad = addrMap(s"TL2:dmem${p(TileId)}").containsAddress(s1_paddr)
val inScratchpad = outer.scratch().map(_.contains(s1_paddr)).getOrElse(Bool(false))
val hitState = Mux(inScratchpad, ClientMetadata.maximum, ClientMetadata.onReset)
(inScratchpad, hitState, L1Metadata(UInt(0), ClientMetadata.onReset))
} else {
Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/rocket/HellaCache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class HellaCacheModule(outer: HellaCache)(implicit val p: Parameters) extends La
with HasL1HellaCacheParameters {
implicit val cfg = outer.cfg
val io = new HellaCacheBundle(outer)
val edge = outer.node.edgesOut(0)
val tl_out = io.mem(0)

/* TODO
Expand All @@ -160,8 +159,8 @@ class HellaCacheModule(outer: HellaCache)(implicit val p: Parameters) extends La
}

object HellaCache {
def apply(cfg: DCacheConfig)(implicit p: Parameters) = {
if (cfg.nMSHRs == 0) LazyModule(new DCache(cfg))
def apply(cfg: DCacheConfig, scratch: () => Option[AddressSet] = () => None)(implicit p: Parameters) = {
if (cfg.nMSHRs == 0) LazyModule(new DCache(cfg, scratch))
else LazyModule(new NonBlockingDCache(cfg))
}
}
1 change: 1 addition & 0 deletions src/main/scala/rocket/NBDcache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ class NonBlockingDCache(cfg: DCacheConfig)(implicit p: Parameters) extends Hella
class NonBlockingDCacheModule(outer: NonBlockingDCache)(implicit p: Parameters) extends HellaCacheModule(outer)(p) {

require(isPow2(nWays)) // TODO: relax this
require(p(DataScratchpadSize) == 0)

val wb = Module(new WritebackUnit(edge))
val prober = Module(new ProbeUnit(edge))
Expand Down
8 changes: 2 additions & 6 deletions src/main/scala/rocket/ScratchpadSlavePort.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import uncore.constants._
import uncore.tilelink2._
import uncore.util._

class ScratchpadSlavePort(implicit val p: Parameters) extends LazyModule with HasCoreParameters {
class ScratchpadSlavePort(implicit val p: Parameters) extends LazyModule {
val coreDataBytes = p(XLen)/8
val node = TLManagerNode(TLManagerPortParameters(
Seq(TLManagerParameters(
address = List(AddressSet(0x80000000L, BigInt(p(DataScratchpadSize)-1))),
Expand All @@ -26,9 +27,6 @@ class ScratchpadSlavePort(implicit val p: Parameters) extends LazyModule with Ha
beatBytes = coreDataBytes,
minLatency = 1))

// Make sure this ends up with the same name as before
override def name = "dmem0"

lazy val module = new LazyModuleImp(this) {
val io = new Bundle {
val tl_in = node.bundleIn
Expand All @@ -38,8 +36,6 @@ class ScratchpadSlavePort(implicit val p: Parameters) extends LazyModule with Ha
val tl_in = io.tl_in(0)
val edge = node.edgesIn(0)

require(usingDataScratchpad)

val s_ready :: s_wait :: s_replay :: s_grant :: Nil = Enum(UInt(), 4)
val state = Reg(init = s_ready)
when (io.dmem.resp.valid) { state := s_grant }
Expand Down
1 change: 0 additions & 1 deletion src/main/scala/rocket/csr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import config._
import uncore.devices._
import util._
import Chisel.ImplicitConversions._
import junctions.AddrMap

class MStatus extends Bundle {
// not truly part of mstatus, but convenient
Expand Down
7 changes: 5 additions & 2 deletions src/main/scala/rocket/rocket.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Chisel._
import uncore.devices._
import uncore.agents.CacheName
import uncore.constants._
import junctions.HasAddrMapParameters
import uncore.tilelink2._
import util._
import Chisel.ImplicitConversions._
import config._
Expand All @@ -32,12 +32,14 @@ case object NBreakpoints extends Field[Int]
case object NPerfCounters extends Field[Int]
case object NPerfEvents extends Field[Int]
case object DataScratchpadSize extends Field[Int]
case object TLCacheEdge extends Field[TLEdgeOut]

trait HasCoreParameters extends HasAddrMapParameters {
trait HasCoreParameters {
implicit val p: Parameters
val xLen = p(XLen)
val fLen = xLen // TODO relax this

val edge = p(TLCacheEdge)
val usingVM = p(UseVM)
val usingUser = p(UseUser) || usingVM
val usingDebug = p(UseDebug)
Expand Down Expand Up @@ -67,6 +69,7 @@ trait HasCoreParameters extends HasAddrMapParameters {
def pgIdxBits = 12
def pgLevelBits = 10 - log2Ceil(xLen / 32)
def vaddrBits = pgIdxBits + pgLevels * pgLevelBits
val paddrBits = edge.bundle.addressBits
def ppnBits = paddrBits - pgIdxBits
def vpnBits = vaddrBits - pgIdxBits
val pgLevels = p(PgLevels)
Expand Down
26 changes: 18 additions & 8 deletions src/main/scala/rocket/tile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,30 @@ case class RoccParameters(
useFPU: Boolean = false)

class RocketTile(tileId: Int)(implicit p: Parameters) extends LazyModule {
val dcacheParams = p.alterPartial({
val coreParams = p.alterPartial {
case TLCacheEdge => cachedOut.edgesOut(0)
}
val dcacheParams = coreParams.alterPartial({
case CacheName => CacheName("L1D")
case TLId => "L1toL2"
case TileId => tileId // TODO using this messes with Heirarchical P&R: change to io.hartid?
})
val icacheParams = p.alterPartial({
val icacheParams = coreParams.alterPartial({
case CacheName => CacheName("L1I")
case TLId => "L1toL2"
})

//TODO val intNode = IntInputNode()
val slaveNode = if (p(DataScratchpadSize) == 0) None else Some(TLInputNode())
val scratch = if (p(DataScratchpadSize) == 0) None else Some(LazyModule(new ScratchpadSlavePort()(dcacheParams)))
val dcache = HellaCache(p(DCacheKey))(dcacheParams)
def findScratch() = scratch.map { s =>
val finalNode = uncachedOut.edgesOut(0).manager.managers.find(_.nodePath.last == s.node)
require (finalNode.isDefined, "Could not find the scratch pad; not reachable via icache?")
require (finalNode.get.address.size == 1, "Scratchpad address space was fragmented!")
finalNode.get.address(0)
}

val dcache = HellaCache(p(DCacheKey), findScratch)(dcacheParams)
val ucLegacy = LazyModule(new TLLegacy()(icacheParams))

val cachedOut = TLOutputNode()
Expand All @@ -54,7 +64,7 @@ class RocketTile(tileId: Int)(implicit p: Parameters) extends LazyModule {
val uncached = uncachedOut.bundleOut
val slave = slaveNode.map(_.bundleIn)
val hartid = UInt(INPUT, p(XLen))
val interrupts = new TileInterrupts().asInput
val interrupts = new TileInterrupts()(coreParams).asInput
val resetVector = UInt(INPUT, p(XLen))
}

Expand All @@ -74,15 +84,15 @@ class RocketTile(tileId: Int)(implicit p: Parameters) extends LazyModule {
icache.io.cpu <> core.io.imem
icache.io.resetVector := io.resetVector

val fpuOpt = p(FPUKey).map(cfg => Module(new FPU(cfg)))
val fpuOpt = p(FPUKey).map(cfg => Module(new FPU(cfg)(coreParams)))
fpuOpt.foreach(fpu => core.io.fpu <> fpu.io)

if (usingRocc) {
val respArb = Module(new RRArbiter(new RoCCResponse, nRocc))
val respArb = Module(new RRArbiter(new RoCCResponse()(coreParams), nRocc))
core.io.rocc.resp <> respArb.io.out

val roccOpcodes = buildRocc.map(_.opcodes)
val cmdRouter = Module(new RoccCommandRouter(roccOpcodes))
val cmdRouter = Module(new RoccCommandRouter(roccOpcodes)(coreParams))
cmdRouter.io.in <> core.io.rocc.cmd

val roccs = buildRocc.zipWithIndex.map { case (accelParams, i) =>
Expand All @@ -101,7 +111,7 @@ class RocketTile(tileId: Int)(implicit p: Parameters) extends LazyModule {

if (nFPUPorts > 0) {
fpuOpt.foreach { fpu =>
val fpArb = Module(new InOrderArbiter(new FPInput, new FPResult, nFPUPorts))
val fpArb = Module(new InOrderArbiter(new FPInput()(coreParams), new FPResult()(coreParams), nFPUPorts))
val fp_roccs = roccs.zip(buildRocc)
.filter { case (_, params) => params.useFPU }
.map { case (rocc, _) => rocc.io }
Expand Down
Loading

0 comments on commit 42b4013

Please sign in to comment.