Chipyardには、RISC-VのインオーダCPUであるArianeを試すための環境が用意されている。もともとSubrepoとしてArianeが配置されていたのは知っていたので何らかのビルド・実行できる環境があるとは思っていたが、どうやら本当に実行できるようだ。
ArianeはSystemVerilogで記述されているのだが、ChiselにはもともとSystemVerilogをWrappingする機能があるので簡単に実現できるだろうとは思っていた。
make CONFIG=ArianeConfig debug -j4
このArianeConfig
というのは、ChiselのConfigを用いて記述されている。Rocket-ChipのDefaultConfig
みたいなものだ。
generators/chipyard/src/main/scala/config/ArianeConfigs.scala
class ArianeConfig extends Config( new chipyard.iobinders.WithUARTAdapter ++ // display UART with a SimUARTAdapter new chipyard.iobinders.WithTieOffInterrupts ++ // tie off top-level interrupts new chipyard.iobinders.WithSimAXIMem ++ // drive the master AXI4 memory with a SimAXIMem new chipyard.iobinders.WithTiedOffDebug ++ // tie off debug (since we are using SimSerial for testing) new chipyard.iobinders.WithSimSerial ++ // drive TSI with SimSerial for testing new testchipip.WithTSI ++ // use testchipip serial offchip link new chipyard.config.WithBootROM ++ // use default bootrom new chipyard.config.WithUART ++ // add a UART new freechips.rocketchip.subsystem.WithNoMMIOPort ++ // no top-level MMIO master port (overrides default set in rocketchip) new freechips.rocketchip.subsystem.WithNoSlavePort ++ // no top-level MMIO slave port (overrides default set in rocketchip) new freechips.rocketchip.subsystem.WithInclusiveCache ++ // use Sifive L2 cache new freechips.rocketchip.subsystem.WithNExtTopInterrupts(0) ++ // no external interrupts new ariane.WithNArianeCores(1) ++ // single Ariane core new freechips.rocketchip.subsystem.WithCoherentBusTopology ++ // hierarchical buses including mbus+l2 new freechips.rocketchip.system.BaseConfig) // "base" rocketchip system
なるほど、Rocket-Chipと基本的にバス周りを同じように固めているのか。ariane.WithNArianeCores(1)
がAriane
のコンフィグレーションを示している。
generators/chipyard/src/main/scala/config/ArianeConfigs.scala
/** * Create multiple copies of a Ariane tile (and thus a core). * Override with the default mixins to control all params of the tiles. * * @param n amount of tiles to duplicate */ class WithNArianeCores(n: Int) extends Config( new WithNormalArianeSys ++ new Config((site, here, up) => { case ArianeTilesKey => { List.tabulate(n)(i => ArianeTileParams(hartId = i)) } }) )
ArianeTile
は以下で定義されていた。
generators/ariane/src/main/scala/ArianeTile.scala
class ArianeTile( val arianeParams: ArianeTileParams, crossing: ClockCrossingType, lookup: LookupByHartIdImpl, q: Parameters, logicalTreeNode: LogicalTreeNode) extends BaseTile(arianeParams, crossing, lookup, q) with SinksExternalInterrupts with SourcesExternalNotifications { ...
Arianeコアのインスタンスは以下で行われている。
generators/ariane/src/main/scala/ArianeTile.scala
// connect the ariane core val core = Module(new ArianeCoreBlackbox( // traceport params traceportEnabled = outer.arianeParams.trace, ...
実行結果は以下のようになった。
./simulator-chipyard-ArianeConfig-debug --verbose $RISCV/riscv64-unknown-elf/share/riscv-tests/benchmarks/dhrystone.riscv 2>&1 | tee dhrystone.ariane.log
using random seed 1610846131 This emulator compiled with JTAG Remote Bitbang client. To enable, use +jtag_rbb_enable=1. Listening on port 56520 Microseconds for one run through Dhrystone: 4049 Dhrystones per Second: 246 mcycle = 2024987 minstret = 196530
ただし、まあけた外れに遅いな...なんでこんなに遅いんだろ?
SmallBoomConfig | 211123 |
---|---|
MediumBoomConfig | 116078 |
LargeBoomConfig | 88391 |
MegaBoomConfig | 74496 |
GigaBoomConfig | 68039 |
ArianeConfig | 2024987 |