rocket: change connection between rocketchip and coreplex
* rtc and dtm are now crossed half-and-half on the two sides * groundtest no longer uses riscv platform traits
This commit is contained in:
@ -15,16 +15,13 @@ import coreplex._
|
||||
|
||||
// the following parameters will be refactored properly with TL2
|
||||
case object GlobalAddrMap extends Field[AddrMap]
|
||||
case object NCoreplexExtClients extends Field[Int]
|
||||
/** Enable or disable monitoring of Diplomatic buses */
|
||||
case object TLEmitMonitors extends Field[Bool]
|
||||
|
||||
abstract class BareTop[+C <: BaseCoreplex](_coreplex: Parameters => C)(implicit val q: Parameters) extends LazyModule {
|
||||
abstract class BareTop[+C <: BaseCoreplex](_coreplex: Parameters => C)(implicit val p: Parameters) extends LazyModule {
|
||||
// Fill in the TL1 legacy parameters; remove these once rocket/groundtest/unittest are TL2
|
||||
val pBusMasters = new RangeManager
|
||||
lazy val legacyAddrMap = GenerateGlobalAddrMap(q, coreplex.l1tol2.node.edgesIn(0).manager.managers)
|
||||
val coreplex : C = LazyModule(_coreplex(q.alterPartial {
|
||||
case NCoreplexExtClients => pBusMasters.sum
|
||||
lazy val legacyAddrMap = GenerateGlobalAddrMap(p, coreplex.l1tol2.node.edgesIn(0).manager.managers)
|
||||
val coreplex : C = LazyModule(_coreplex(p.alterPartial {
|
||||
case GlobalAddrMap => legacyAddrMap
|
||||
}))
|
||||
|
||||
@ -42,8 +39,8 @@ abstract class BareTopModule[+L <: BareTop[BaseCoreplex], +B <: BareTopBundle[L]
|
||||
|
||||
/** Base Top with no Periphery */
|
||||
trait TopNetwork extends HasPeripheryParameters {
|
||||
this: BareTop[BaseCoreplex] =>
|
||||
implicit val p = q
|
||||
val module: TopNetworkModule
|
||||
|
||||
TLImp.emitMonitors = p(TLEmitMonitors)
|
||||
|
||||
// Add a SoC and peripheral bus
|
||||
@ -60,26 +57,14 @@ trait TopNetwork extends HasPeripheryParameters {
|
||||
}
|
||||
|
||||
trait TopNetworkBundle extends HasPeripheryParameters {
|
||||
this: BareTopBundle[BareTop[BaseCoreplex]] =>
|
||||
implicit val p = outer.q
|
||||
val success = Bool(OUTPUT)
|
||||
val outer: TopNetwork
|
||||
implicit val p = outer.p
|
||||
}
|
||||
|
||||
trait TopNetworkModule extends HasPeripheryParameters {
|
||||
this: {
|
||||
val outer: BareTop[BaseCoreplex] with TopNetwork
|
||||
val io: TopNetworkBundle
|
||||
} =>
|
||||
val io: TopNetworkBundle
|
||||
val outer: TopNetwork
|
||||
implicit val p = outer.p
|
||||
|
||||
val coreplexSlave: Vec[ClientUncachedTileLinkIO] = Wire(outer.coreplex.module.io.slave)
|
||||
val coreplexDebug: DebugBusIO = Wire(outer.coreplex.module.io.debug)
|
||||
val coreplexRtc : Bool = Wire(outer.coreplex.module.io.rtcTick)
|
||||
|
||||
io.success := outer.coreplex.module.io.success
|
||||
|
||||
outer.coreplex.module.io.rtcTick := coreplexRtc
|
||||
coreplexRtc := Counter(p(rocketchip.RTCPeriod)).inc()
|
||||
}
|
||||
|
||||
/** Base Top with no Periphery */
|
||||
@ -94,20 +79,11 @@ class BaseTopBundle[+L <: BaseTop[BaseCoreplex]](_outer: L) extends BareTopBundl
|
||||
class BaseTopModule[+L <: BaseTop[BaseCoreplex], +B <: BaseTopBundle[L]](_outer: L, _io: () => B) extends BareTopModule(_outer, _io)
|
||||
with TopNetworkModule
|
||||
|
||||
trait DirectConnection {
|
||||
this: BareTop[BaseCoreplex] with TopNetwork =>
|
||||
trait DirectConnection extends TopNetwork {
|
||||
val coreplex: BaseCoreplex
|
||||
|
||||
socBus.node := coreplex.mmio
|
||||
coreplex.mmioInt := intBus.intnode
|
||||
|
||||
coreplexMem = coreplex.mem
|
||||
}
|
||||
|
||||
trait DirectConnectionModule {
|
||||
this: TopNetworkModule {
|
||||
val outer: BaseTop[BaseCoreplex]
|
||||
} =>
|
||||
|
||||
outer.coreplex.module.io.slave <> coreplexSlave
|
||||
outer.coreplex.module.io.debug <> coreplexDebug
|
||||
}
|
||||
|
@ -62,8 +62,6 @@ class BasePlatformConfig extends Config(
|
||||
case TMemoryChannels => BusType.AXI
|
||||
case ExtMemSize => Dump("MEM_SIZE", 0x10000000L)
|
||||
case RTCPeriod => 100 // gives 10 MHz RTC assuming 1 GHz uncore clock
|
||||
case BuildExampleTop =>
|
||||
(p: Parameters) => LazyModule(new ExampleTop(new DefaultCoreplex()(_))(p))
|
||||
case SimMemLatency => 0
|
||||
case _ => throw new CDEMatchError
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package rocketchip
|
||||
|
||||
import Chisel._
|
||||
import uncore.devices.{DebugBusIO, AsyncDebugBusCrossing, DebugBusReq, DebugBusResp, DMKey}
|
||||
import uncore.devices._
|
||||
import junctions._
|
||||
import util._
|
||||
import cde.{Parameters, Field}
|
||||
@ -45,13 +45,13 @@ class JtagDTMWithSync(depth: Int = 1, sync: Int = 3)(implicit val p: Parameters)
|
||||
|
||||
val io = new Bundle {
|
||||
|
||||
val jtag = new JTAGIO(true).flip()
|
||||
val debug = new DebugBusIO()(p)
|
||||
val jtag = new JTAGIO(true).flip
|
||||
val debug = new AsyncDebugBusIO
|
||||
|
||||
}
|
||||
|
||||
val req_width = io.debug.req.bits.getWidth
|
||||
val resp_width = io.debug.resp.bits.getWidth
|
||||
val req_width = io.debug.req.mem(0).getWidth
|
||||
val resp_width = io.debug.resp.mem(0).getWidth
|
||||
|
||||
val jtag_dtm = Module (new DebugTransportModuleJtag(req_width, resp_width))
|
||||
|
||||
@ -62,7 +62,8 @@ class JtagDTMWithSync(depth: Int = 1, sync: Int = 3)(implicit val p: Parameters)
|
||||
|
||||
val io_debug_bus = Wire (new DebugBusIO)
|
||||
|
||||
io.debug <> AsyncDebugBusCrossing(io.jtag.TCK, io.jtag.TRST, io_debug_bus, clock, reset, depth, sync)
|
||||
io.debug.req <> ToAsyncBundle(io_debug_bus.req)
|
||||
io_debug_bus.resp <> FromAsyncBundle(io.debug.resp)
|
||||
|
||||
// Translate from straight 'bits' interface of the blackboxes
|
||||
// into the Resp/Req data structures.
|
||||
|
@ -12,31 +12,40 @@ import rocketchip._
|
||||
class ExampleTop[+C <: BaseCoreplex](_coreplex: Parameters => C)(implicit p: Parameters) extends BaseTop(_coreplex)
|
||||
with DirectConnection
|
||||
with PeripheryBootROM
|
||||
with PeripheryDebug
|
||||
with PeripheryExtInterrupts
|
||||
with PeripheryMasterAXI4Mem
|
||||
with PeripheryMasterAXI4MMIO
|
||||
with PeripherySlave {
|
||||
with PeripheryMasterAXI4MMIO {
|
||||
override lazy val module = new ExampleTopModule(this, () => new ExampleTopBundle(this))
|
||||
}
|
||||
|
||||
class ExampleTopBundle[+L <: ExampleTop[BaseCoreplex]](_outer: L) extends BaseTopBundle(_outer)
|
||||
with PeripheryBootROMBundle
|
||||
with PeripheryDebugBundle
|
||||
with PeripheryExtInterruptsBundle
|
||||
with PeripheryMasterAXI4MemBundle
|
||||
with PeripheryMasterAXI4MMIOBundle
|
||||
with PeripherySlaveBundle
|
||||
|
||||
class ExampleTopModule[+L <: ExampleTop[BaseCoreplex], +B <: ExampleTopBundle[L]](_outer: L, _io: () => B) extends BaseTopModule(_outer, _io)
|
||||
with DirectConnectionModule
|
||||
with PeripheryBootROMModule
|
||||
with PeripheryDebugModule
|
||||
with PeripheryExtInterruptsModule
|
||||
with PeripheryMasterAXI4MemModule
|
||||
with PeripheryMasterAXI4MMIOModule
|
||||
with PeripherySlaveModule
|
||||
with HardwiredResetVector
|
||||
|
||||
class ExampleRocketTop[+C <: DefaultCoreplex](_coreplex: Parameters => C)(implicit p: Parameters) extends ExampleTop(_coreplex)
|
||||
with PeripheryDTM
|
||||
with PeripheryCounter
|
||||
with HardwiredResetVector {
|
||||
override lazy val module = new ExampleRocketTopModule(this, () => new ExampleRocketTopBundle(this))
|
||||
}
|
||||
|
||||
class ExampleRocketTopBundle[+L <: ExampleRocketTop[DefaultCoreplex]](_outer: L) extends ExampleTopBundle(_outer)
|
||||
with PeripheryDTMBundle
|
||||
with PeripheryCounterBundle
|
||||
with HardwiredResetVectorBundle
|
||||
|
||||
class ExampleRocketTopModule[+L <: ExampleRocketTop[DefaultCoreplex], +B <: ExampleRocketTopBundle[L]](_outer: L, _io: () => B) extends ExampleTopModule(_outer, _io)
|
||||
with PeripheryDTMModule
|
||||
with PeripheryCounterModule
|
||||
with HardwiredResetVectorModule
|
||||
|
||||
/** Example Top with TestRAM */
|
||||
class ExampleTopWithTestRAM[+C <: BaseCoreplex](_coreplex: Parameters => C)(implicit p: Parameters) extends ExampleTop(_coreplex)
|
||||
|
@ -92,41 +92,6 @@ trait HasPeripheryParameters {
|
||||
|
||||
/////
|
||||
|
||||
trait PeripheryDebug {
|
||||
this: TopNetwork =>
|
||||
}
|
||||
|
||||
trait PeripheryDebugBundle {
|
||||
this: TopNetworkBundle {
|
||||
val outer: PeripheryDebug
|
||||
} =>
|
||||
val debug_clk = (p(AsyncDebugBus) && !p(IncludeJtagDTM)).option(Clock(INPUT))
|
||||
val debug_rst = (p(AsyncDebugBus) && !p(IncludeJtagDTM)).option(Bool(INPUT))
|
||||
val debug = (!p(IncludeJtagDTM)).option(new DebugBusIO()(p).flip)
|
||||
val jtag = p(IncludeJtagDTM).option(new JTAGIO(true).flip)
|
||||
}
|
||||
|
||||
trait PeripheryDebugModule {
|
||||
this: TopNetworkModule {
|
||||
val outer: PeripheryDebug
|
||||
val io: PeripheryDebugBundle
|
||||
} =>
|
||||
|
||||
if (p(IncludeJtagDTM)) {
|
||||
// JtagDTMWithSync is a wrapper which
|
||||
// handles the synchronization as well.
|
||||
val dtm = Module (new JtagDTMWithSync()(p))
|
||||
dtm.io.jtag <> io.jtag.get
|
||||
coreplexDebug <> dtm.io.debug
|
||||
} else {
|
||||
coreplexDebug <>
|
||||
(if (p(AsyncDebugBus)) AsyncDebugBusFrom(io.debug_clk.get, io.debug_rst.get, io.debug.get)
|
||||
else io.debug.get)
|
||||
}
|
||||
}
|
||||
|
||||
/////
|
||||
|
||||
trait PeripheryExtInterrupts {
|
||||
this: TopNetwork =>
|
||||
|
||||
@ -238,48 +203,6 @@ trait PeripheryMasterAXI4MMIOModule {
|
||||
|
||||
/////
|
||||
|
||||
trait PeripherySlave {
|
||||
this: TopNetwork {
|
||||
val pBusMasters: RangeManager
|
||||
} =>
|
||||
|
||||
if (p(NExtBusAXIChannels) > 0) pBusMasters.add("ext", 1) // NExtBusAXIChannels are arbitrated into one TL port
|
||||
}
|
||||
|
||||
trait PeripherySlaveBundle {
|
||||
this: TopNetworkBundle {
|
||||
val outer: PeripherySlave
|
||||
} =>
|
||||
val bus_clk = p(AsyncBusChannels).option(Vec(p(NExtBusAXIChannels), Clock(INPUT)))
|
||||
val bus_rst = p(AsyncBusChannels).option(Vec(p(NExtBusAXIChannels), Bool (INPUT)))
|
||||
val bus_axi = Vec(p(NExtBusAXIChannels), new NastiIO).flip
|
||||
}
|
||||
|
||||
trait PeripherySlaveModule {
|
||||
this: TopNetworkModule {
|
||||
val outer: PeripherySlave { val pBusMasters: RangeManager }
|
||||
val io: PeripherySlaveBundle
|
||||
} =>
|
||||
|
||||
if (p(NExtBusAXIChannels) > 0) {
|
||||
val arb = Module(new NastiArbiter(p(NExtBusAXIChannels)))
|
||||
((io.bus_axi zip arb.io.master) zipWithIndex) foreach { case ((bus, port), idx) =>
|
||||
port <> (
|
||||
if (!p(AsyncBusChannels)) bus
|
||||
else AsyncNastiFrom(io.bus_clk.get(idx), io.bus_rst.get(idx), bus)
|
||||
)
|
||||
}
|
||||
val conv = Module(new TileLinkIONastiIOConverter()(edgeSlaveParams))
|
||||
conv.io.nasti <> arb.io.slave
|
||||
|
||||
val (r_start, r_end) = outer.pBusMasters.range("ext")
|
||||
require(r_end - r_start == 1, "RangeManager should return 1 slot")
|
||||
TileLinkWidthAdapter(coreplexSlave(r_start), conv.io.tl)
|
||||
}
|
||||
}
|
||||
|
||||
/////
|
||||
|
||||
trait PeripheryBootROM {
|
||||
this: TopNetwork =>
|
||||
|
||||
@ -344,12 +267,3 @@ trait PeripheryTestBusMasterModule {
|
||||
val io: PeripheryTestBusMasterBundle
|
||||
} =>
|
||||
}
|
||||
|
||||
/////
|
||||
|
||||
trait HardwiredResetVector {
|
||||
this: TopNetworkModule {
|
||||
val outer: BaseTop[BaseCoreplex]
|
||||
} =>
|
||||
outer.coreplex.module.io.resetVector := UInt(0x1000) // boot ROM
|
||||
}
|
||||
|
92
src/main/scala/rocketchip/RISCVPlatform.scala
Normal file
92
src/main/scala/rocketchip/RISCVPlatform.scala
Normal file
@ -0,0 +1,92 @@
|
||||
// See LICENSE for license details.
|
||||
|
||||
package rocketchip
|
||||
|
||||
import Chisel._
|
||||
import cde.{Parameters, Field, Dump}
|
||||
import diplomacy._
|
||||
import uncore.tilelink2._
|
||||
import uncore.devices._
|
||||
import util._
|
||||
import junctions.JTAGIO
|
||||
import coreplex._
|
||||
|
||||
trait PeripheryJTAG extends TopNetwork {
|
||||
val module: PeripheryJTAGModule
|
||||
val coreplex: CoreplexRISCVPlatform
|
||||
}
|
||||
|
||||
trait PeripheryJTAGBundle extends TopNetworkBundle {
|
||||
val outer: PeripheryJTAG
|
||||
|
||||
val jtag = new JTAGIO(true).flip
|
||||
}
|
||||
|
||||
trait PeripheryJTAGModule extends TopNetworkModule {
|
||||
val outer: PeripheryJTAG
|
||||
val io: PeripheryJTAGBundle
|
||||
|
||||
val dtm = Module (new JtagDTMWithSync)
|
||||
dtm.io.jtag <> io.jtag
|
||||
outer.coreplex.module.io.debug <> dtm.io.debug
|
||||
|
||||
dtm.clock := io.jtag.TCK
|
||||
dtm.reset := io.jtag.TRST
|
||||
}
|
||||
|
||||
trait PeripheryDTM extends TopNetwork {
|
||||
val module: PeripheryDTMModule
|
||||
val coreplex: CoreplexRISCVPlatform
|
||||
}
|
||||
|
||||
trait PeripheryDTMBundle extends TopNetworkBundle {
|
||||
val outer: PeripheryDTM
|
||||
|
||||
val debug = new DebugBusIO().flip
|
||||
}
|
||||
|
||||
trait PeripheryDTMModule extends TopNetworkModule {
|
||||
val outer: PeripheryDTM
|
||||
val io: PeripheryDTMBundle
|
||||
|
||||
outer.coreplex.module.io.debug <> ToAsyncDebugBus(io.debug)
|
||||
}
|
||||
|
||||
trait PeripheryCounter extends TopNetwork {
|
||||
val module: PeripheryCounterModule
|
||||
val coreplex: CoreplexRISCVPlatform
|
||||
}
|
||||
|
||||
trait PeripheryCounterBundle extends TopNetworkBundle {
|
||||
val outer: PeripheryCounter
|
||||
}
|
||||
|
||||
trait PeripheryCounterModule extends TopNetworkModule {
|
||||
val outer: PeripheryCounter
|
||||
val io: PeripheryCounterBundle
|
||||
|
||||
{
|
||||
val period = p(rocketchip.RTCPeriod)
|
||||
val rtcCounter = RegInit(UInt(0, width = log2Up(period)))
|
||||
val rtcWrap = rtcCounter === UInt(period-1)
|
||||
rtcCounter := Mux(rtcWrap, UInt(0), rtcCounter + UInt(1))
|
||||
|
||||
outer.coreplex.module.io.rtcToggle := rtcCounter(log2Up(period)-1)
|
||||
}
|
||||
}
|
||||
|
||||
trait HardwiredResetVector extends TopNetwork {
|
||||
val module: HardwiredResetVectorModule
|
||||
val coreplex: CoreplexRISCVPlatform
|
||||
}
|
||||
|
||||
trait HardwiredResetVectorBundle extends TopNetworkBundle {
|
||||
val outer: HardwiredResetVector
|
||||
}
|
||||
|
||||
trait HardwiredResetVectorModule extends TopNetworkModule {
|
||||
val outer: HardwiredResetVector
|
||||
val io: HardwiredResetVectorBundle
|
||||
|
||||
outer.coreplex.module.io.resetVector := UInt(0x1000) // boot ROM
|
||||
}
|
@ -5,6 +5,8 @@ package rocketchip
|
||||
import Chisel._
|
||||
import cde.{Parameters, Field}
|
||||
import junctions._
|
||||
import diplomacy._
|
||||
import coreplex._
|
||||
import junctions.NastiConstants._
|
||||
import util.LatencyPipe
|
||||
|
||||
@ -15,12 +17,8 @@ class TestHarness(q: Parameters) extends Module {
|
||||
val io = new Bundle {
|
||||
val success = Bool(OUTPUT)
|
||||
}
|
||||
val dut = Module(q(BuildExampleTop)(q).module)
|
||||
implicit val p = dut.p
|
||||
|
||||
// This test harness isn't especially flexible yet
|
||||
require(dut.io.bus_clk.isEmpty)
|
||||
require(dut.io.bus_rst.isEmpty)
|
||||
implicit val p = q
|
||||
val dut = Module(LazyModule(new ExampleRocketTop(new DefaultCoreplex()(_))).module)
|
||||
|
||||
for (int <- dut.io.interrupts(0))
|
||||
int := Bool(false)
|
||||
@ -38,26 +36,7 @@ class TestHarness(q: Parameters) extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
if (!p(IncludeJtagDTM)) {
|
||||
// Todo: enable the usage of different clocks
|
||||
// to test the synchronizer more aggressively.
|
||||
val dtm_clock = clock
|
||||
val dtm_reset = reset
|
||||
if (dut.io.debug_clk.isDefined) dut.io.debug_clk.get := dtm_clock
|
||||
if (dut.io.debug_rst.isDefined) dut.io.debug_rst.get := dtm_reset
|
||||
val dtm = Module(new SimDTM).connect(dtm_clock, dtm_reset, dut.io.debug.get,
|
||||
dut.io.success, io.success)
|
||||
} else {
|
||||
val jtag = Module(new JTAGVPI).connect(dut.io.jtag.get, reset, io.success)
|
||||
}
|
||||
|
||||
for (bus_axi <- dut.io.bus_axi) {
|
||||
bus_axi.ar.valid := Bool(false)
|
||||
bus_axi.aw.valid := Bool(false)
|
||||
bus_axi.w.valid := Bool(false)
|
||||
bus_axi.r.ready := Bool(false)
|
||||
bus_axi.b.ready := Bool(false)
|
||||
}
|
||||
val dtm = Module(new SimDTM).connect(clock, reset, dut.io.debug, io.success)
|
||||
|
||||
for (mmio_axi <- dut.io.mmio_axi) {
|
||||
val slave = Module(new NastiErrorSlave)
|
||||
@ -128,13 +107,12 @@ class SimDTM(implicit p: Parameters) extends BlackBox {
|
||||
val exit = UInt(OUTPUT, 32)
|
||||
}
|
||||
|
||||
def connect(tbclk: Clock, tbreset: Bool, dutio: uncore.devices.DebugBusIO,
|
||||
dutsuccess: Bool, tbsuccess: Bool) = {
|
||||
def connect(tbclk: Clock, tbreset: Bool, dutio: uncore.devices.DebugBusIO, tbsuccess: Bool) = {
|
||||
io.clk := tbclk
|
||||
io.reset := tbreset
|
||||
dutio <> io.debug
|
||||
|
||||
tbsuccess := dutsuccess || io.exit === UInt(1)
|
||||
tbsuccess := io.exit === UInt(1)
|
||||
when (io.exit >= UInt(2)) {
|
||||
printf("*** FAILED *** (exit code = %d)\n", io.exit >> UInt(1))
|
||||
stop(1)
|
||||
|
Reference in New Issue
Block a user