-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rocket cosim framework #3271
Rocket cosim framework #3271
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
// See LICENSE.SiFive for license details. | ||
// See LICENSE.Berkeley for license details. | ||
|
||
package freechips.rocketchip.tile | ||
package tile | ||
midnighter95 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import Chisel._ | ||
import org.chipsalliance.cde.config._ | ||
import freechips.rocketchip.config._ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't touch |
||
import freechips.rocketchip.devices.tilelink._ | ||
import freechips.rocketchip.diplomacy._ | ||
import freechips.rocketchip.interrupts._ | ||
|
@@ -36,11 +36,11 @@ case class RocketTileParams( | |
} | ||
|
||
class RocketTile private( | ||
val rocketParams: RocketTileParams, | ||
crossing: ClockCrossingType, | ||
lookup: LookupByHartIdImpl, | ||
q: Parameters) | ||
extends BaseTile(rocketParams, crossing, lookup, q) | ||
val rocketParams: RocketTileParams, | ||
crossing: ClockCrossingType, | ||
lookup: LookupByHartIdImpl, | ||
q: Parameters) | ||
extends BaseTile(rocketParams, crossing, lookup, q) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't touch |
||
with SinksExternalInterrupts | ||
with SourcesExternalNotifications | ||
with HasLazyRoCC // implies CanHaveSharedFPU with CanHavePTW with HasHellaCache | ||
|
@@ -87,20 +87,7 @@ class RocketTile private( | |
val itimProperty = frontend.icache.itimProperty.toSeq.flatMap(p => Map("sifive,itim" -> p)) | ||
|
||
val beuProperty = bus_error_unit.map(d => Map( | ||
"sifive,buserror" -> d.device.asProperty)).getOrElse(Nil) | ||
|
||
val cpuDevice: SimpleDevice = new SimpleDevice("cpu", Seq("sifive,rocket0", "riscv")) { | ||
override def parent = Some(ResourceAnchors.cpus) | ||
override def describe(resources: ResourceBindings): Description = { | ||
val Description(name, mapping) = super.describe(resources) | ||
Description(name, mapping ++ cpuProperties ++ nextLevelCacheProperty | ||
++ tileProperties ++ dtimProperty ++ itimProperty ++ beuProperty) | ||
} | ||
} | ||
|
||
ResourceBinding { | ||
Resource(cpuDevice, "reg").bind(ResourceAddress(staticIdForMetadataUseOnly)) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't touch |
||
"sifive,buserror" -> d.device.asProperty)).getOrElse(Nil) | ||
|
||
override lazy val module = new RocketTileModuleImp(this) | ||
|
||
|
@@ -120,9 +107,9 @@ class RocketTile private( | |
} | ||
|
||
class RocketTileModuleImp(outer: RocketTile) extends BaseTileModuleImp(outer) | ||
with HasFpuOpt | ||
with HasLazyRoCCModule | ||
with HasICacheFrontendModule { | ||
with HasFpuOpt | ||
with HasLazyRoCCModule | ||
with HasICacheFrontendModule { | ||
Annotated.params(this, outer.rocketParams) | ||
|
||
val core = Module(new Rocket(outer)(outer.p)) | ||
|
@@ -133,9 +120,9 @@ class RocketTileModuleImp(outer: RocketTile) extends BaseTileModuleImp(outer) | |
// Report when the tile has ceased to retire instructions; for now the only cause is clock gating | ||
outer.reportCease(outer.rocketParams.core.clockGate.option( | ||
!outer.dcache.module.io.cpu.clock_enabled && | ||
!outer.frontend.module.io.cpu.clock_enabled && | ||
!ptw.io.dpath.clock_enabled && | ||
core.io.cease)) | ||
!outer.frontend.module.io.cpu.clock_enabled && | ||
!ptw.io.dpath.clock_enabled && | ||
core.io.cease)) | ||
|
||
outer.reportWFI(Some(core.io.wfi)) | ||
|
||
|
@@ -182,8 +169,8 @@ class RocketTileModuleImp(outer: RocketTile) extends BaseTileModuleImp(outer) | |
require(h == c, s"port list size was $h, core expected $c") | ||
require(h == o, s"port list size was $h, outer counted $o") | ||
// TODO figure out how to move the below into their respective mix-ins | ||
dcacheArb.io.requestor <> dcachePorts.toSeq | ||
ptw.io.requestor <> ptwPorts.toSeq | ||
dcacheArb.io.requestor <> dcachePorts | ||
ptw.io.requestor <> ptwPorts | ||
} | ||
|
||
trait HasFpuOpt { this: RocketTileModuleImp => | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.global _start | ||
_start: | ||
auipc t1, 0x0 | ||
addi a1, t1, 32 | ||
csrr a0, mhartid | ||
lui t0, 0x80000 | ||
slli t0,t0,32 | ||
srli t0,t0,32 | ||
jr t0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.global _start | ||
_start: | ||
add t0,t0,x0 | ||
addi t0, x0, 0x1 | ||
addi t1, x0, 0x0 | ||
addi t3, x0, 0xa | ||
loop: | ||
add t1, t1, t0 | ||
add t0, t0, 0x1 | ||
add t3, t3, -1 | ||
bne t3, x0, loop | ||
sd t1, 0x10(x0) | ||
ld t2, 0x10(x0) | ||
addi x20, x0, 0x1 | ||
addi x21, x0, 0x1 | ||
addi x22, x0, 0x1 | ||
addi x23, x0, 0x1 | ||
addi x24, x0, 0x1 | ||
addi x25, x0, 0x1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package cosim.elabotate | ||
|
||
import chisel3._ | ||
import freechips.rocketchip.diplomacy.{AddressSet, BundleBridgeSource, InModuleBody, LazyModule, RegionType, SimpleLazyModule, TransferSizes} | ||
import freechips.rocketchip.interrupts.{IntSinkNode, IntSinkPortSimple, IntSourceNode, IntSourcePortSimple} | ||
import freechips.rocketchip.subsystem._ | ||
import freechips.rocketchip.tilelink.{TLManagerNode, TLSlaveParameters, TLSlavePortParameters} | ||
import org.chipsalliance.cde.config.Parameters | ||
import freechips.rocketchip.tile.{NMI, PriorityMuxHartIdFromSeq, RocketTile} | ||
|
||
import org.chipsalliance.cde.config.{Config, Field} | ||
|
||
class DUT(p: Parameters) extends Module { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can directly use |
||
implicit val implicitP = p | ||
val tileParams = p(RocketTileParamsKey) | ||
val ldut = LazyModule(new SimpleLazyModule { | ||
implicit val implicitP = p | ||
val rocketTile = LazyModule(new RocketTile(tileParams, RocketCrossingParams(), PriorityMuxHartIdFromSeq(Seq(tileParams)))) | ||
val masterNode = TLManagerNode(Seq(TLSlavePortParameters.v1( | ||
Seq(TLSlaveParameters.v1( | ||
address = List(AddressSet(0x0, 0xffffffffL)), | ||
regionType = RegionType.UNCACHED, | ||
executable = true, | ||
supportsGet = TransferSizes(1, 64), | ||
supportsAcquireT = TransferSizes(1, 64), | ||
supportsAcquireB = TransferSizes(1, 64), | ||
supportsPutPartial = TransferSizes(1, 64), | ||
supportsPutFull = TransferSizes(1, 64), | ||
supportsLogical = TransferSizes(1, 64), | ||
supportsArithmetic = TransferSizes(1, 64), | ||
fifoId = Some(0))), | ||
beatBytes = 8, | ||
endSinkId = 4, | ||
minLatency = 1 | ||
))) | ||
masterNode :=* rocketTile.masterNode | ||
val memory = InModuleBody { | ||
masterNode.makeIOs() | ||
} | ||
|
||
val intNode = IntSourceNode(IntSourcePortSimple()) | ||
rocketTile.intInwardNode :=* intNode | ||
val intIn = InModuleBody { | ||
intNode.makeIOs() | ||
} | ||
|
||
val haltNode = IntSinkNode(IntSinkPortSimple()) | ||
haltNode :=* rocketTile.haltNode | ||
val haltOut = InModuleBody { | ||
haltNode.makeIOs() | ||
} | ||
|
||
val ceaseNode = IntSinkNode(IntSinkPortSimple()) | ||
ceaseNode :=* rocketTile.ceaseNode | ||
val ceaseOut = InModuleBody { | ||
ceaseNode.makeIOs() | ||
} | ||
|
||
val wfiNode = IntSinkNode(IntSinkPortSimple()) | ||
wfiNode :=* rocketTile.wfiNode | ||
val wfiOut = InModuleBody { | ||
wfiNode.makeIOs() | ||
} | ||
val resetVectorNode = BundleBridgeSource(() => UInt(32.W)) | ||
rocketTile.resetVectorNode := resetVectorNode | ||
val resetVector = InModuleBody { | ||
resetVectorNode.makeIO() | ||
} | ||
val hartidNode = BundleBridgeSource(() => UInt(4.W)) | ||
rocketTile.hartIdNode := hartidNode | ||
InModuleBody { | ||
hartidNode.bundle := 0.U | ||
} | ||
val nmiNode = BundleBridgeSource(Some(() => new NMI(32))) | ||
rocketTile.nmiNode := nmiNode | ||
val nmi = InModuleBody { | ||
nmiNode.makeIO() | ||
} | ||
Comment on lines
+19
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These logic is already implemented in the |
||
}) | ||
chisel3.experimental.DataMirror.fullModulePorts( | ||
// instantiate the LazyModule | ||
Module(ldut.module) | ||
).filterNot(_._2.isInstanceOf[Aggregate]).foreach { case (name, ele) => | ||
if (!(name == "clock" || name == "reset")) { | ||
chisel3.experimental.DataMirror.directionOf(ele) match { | ||
case ActualDirection.Output => | ||
val io = IO(Output(chiselTypeOf(ele))).suggestName(name) | ||
println(s"output $name") | ||
io := ele | ||
case ActualDirection.Input => | ||
val io = IO(Input(chiselTypeOf(ele))).suggestName(name) | ||
println(s"input $name") | ||
ele := io | ||
} | ||
} | ||
} | ||
Comment on lines
+80
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC this hack should be fixed. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only need to add necessary dependencies.