1 // See LICENSE for license details.
2 package sifive.blocks.devices.gpio
6 import diplomacy.{LazyModule,LazyMultiIOModuleImp}
7 import rocketchip.HasSystemNetworks
8 import uncore.tilelink2.TLFragmenter
9 import util.HeterogeneousBag
11 case object PeripheryGPIOKey extends Field[Seq[GPIOParams]]
13 trait HasPeripheryGPIO extends HasSystemNetworks {
14 val gpioParams = p(PeripheryGPIOKey)
15 val gpio = gpioParams map {params =>
16 val gpio = LazyModule(new TLGPIO(peripheryBusBytes, params))
17 gpio.node := TLFragmenter(peripheryBusBytes, cacheBlockBytes)(peripheryBus.node)
18 intBus.intnode := gpio.intnode
23 trait HasPeripheryGPIOBundle {
24 val gpio: HeterogeneousBag[GPIOPortIO]
27 trait HasPeripheryGPIOModuleImp extends LazyMultiIOModuleImp with HasPeripheryGPIOBundle {
28 val outer: HasPeripheryGPIO
29 val gpio = IO(HeterogeneousBag(outer.gpioParams.map(new GPIOPortIO(_))))
31 (gpio zip outer.gpio) foreach { case (io, device) =>
32 io <> device.module.io.port