Extending Rocket Chip with Verilog Peripheral IPs
Wei Song (宋威)
Former hardware designer for lowRISC (v0.1 – v0.4)
8th September, 2018
Verilog Peripheral IPs Wei Song ( ) Former hardware designer for - - PowerPoint PPT Presentation
Extending Rocket Chip with Verilog Peripheral IPs Wei Song ( ) Former hardware designer for lowRISC (v0.1 v0.4) 8 th September, 2018 lowRISC Project lowRISC is a not for profit organization from the University of Cambridge.
Former hardware designer for lowRISC (v0.1 – v0.4)
8th September, 2018
2
3
Today’s topic: A generic and extendable AXI interface.
4
TileLink Node, either an AXI4Port or a dedicated TLNode.
propagated to each L1 cache and the global device tree.
violations accordingly.
bootrom: 0x00000000 – 0x00004000 RX RTC: 0x10000000 – 0x10004000 WR uart: 0x10004000 – 0x10008000 WR bram: 0x20000000 – 0x20800000 WRX
5
single AXI bus using Verilog.
propagated to the global device tree and all L1 $.
bootrom: 0x00000000 – 0x00004000 RX RTC: 0x10000000 – 0x10004000 WR AXI: 0x20000000 – 0x40000000 WRX (shared by UART and BRAM)
6
– Manually calculate the combined address map for the IO bus. – Manually allocate interrupt lines. – No direct method to add device into the generated device tree.
– Extend the diplomacy package to implement an AXI4VirtualBusNode which is the root of a virtual tree representing the IO bus. – This AXI4VirtualBusNode can automatically derive the parameters, add nodes in the device tree and connect interrupts. – It also produces an AXI4 port like the AXI4MMIOPort for the external Verilog peripherals.
7
protocol implementations.
8
Produce an AXI port to the external Verilog and act as the root diplomacy node for the external AXI bus.
For each peripheral added to the global configuration, the SoC generator adds a slave node accordingly.
back-propagates address map, interrupts for the global device tree similar to normal diplomacy nodes.
9
– MixedNode is the common base class
– Bus(crossbar)
– Peripheral device
– VirtualNode is the common base class
– Bus(port)
– Peripheral device (diplomacy node only)
10
// define a peripheral case class ExSlaveParams( name: String, device: () => SimpleDevice, base: BigInt, size: BigInt, resource: Option[String] = None, interrupts: Int = 0, burstBytes: Int = 64, // needs to be set >= 64 readable: Boolean = true, writeable: Boolean = true, executable: Boolean = false ) // a collection of all Verilog peripherals case class ExPeriperalsParams( beatBytes: Int, idBits: Int, slaves: Seq[ExSlaveParams] )
Define the parameters
Collect all peripherals in a global object
11
trait HasAXI4VirtualBus extends HasPeripheryBus { val mmio_axi4 = AXI4VirtualBusNode(…) p(ExPeriperals).slaves.foreach( d => { val slave = AXI4VirtualSlaveNode( Seq(AXI4SlavePortParameters(slaves = Seq(AXI4SlaveParameters( address = Seq(AddressSet(d.base, d.size - 1)), resources = d.resource.map(device.reg(_)).getOrElse(device.reg), … )), beatBytes = p(ExPeriperals).beatBytes ))) slave :*= mmio_axi4 if(d.interrupts > 0) { val intnode = IntInternalInputNode(…) ibus.fromSync := intnode }) mmio_axi4 := AXI4Buffer()(AXI4UserYanker()(AXI4Deinterleaver()(AXI4IdIndexer(p(ExPeriperals).idBits)( TLToAXI4(p(ExPeriperals).beatBytes)(pbus.toVariableWidthSlaves))))) }
AXI port Generate virtual node for each peripheral connect port
12
class LoRCCoreplexModule[+L <: LoRCCoreplex](_outer: L) extends RocketCoreplexModule(_outer) with HasRTCModuleImp with HasMasterAXI4MemPortModuleImp with HasAXI4VirtualBusModuleImp with HasSlaveAXI4PortModuleImp with HasPeripheryBootROMModuleImp class WithUART extends Config(Parameters.empty) { SlaveDevice.entries += ExSlaveParams( name = "uart", device = () => new SimpleDevice("serial",Seq("xlnx,uart16550")), base = 0x41002000, size = 0x00002000, // 8KB interrupts = 1 ) } class LoRCNexys4Config extends Config( new WithUART ++ new WithBootRAM ++ new WithNBigCores(1) ++ new LoRCBaseConfig)
Add VirtualBus into the cake pattern Write a configuration class for the UART Use the UART configuration
13
parameter negotiation, much powerful than the parameters in SystemVerilog.
module.
Rocket-Chip generator, we can easily support automatic device tree generation for Verilog peripherals.
– Diplomacy: 190 lines
https://github.com/lowRISC/lowrisc-chip/blob/update/src/main/scala/diplomacy/VNodes.scala
– Rocket-Chip generator: 300 lines
https://github.com/lowRISC/lowrisc-chip/tree/update/src/main/scala/lowrisc
14