-trait PeripheryI2C {
- this: TopNetwork { val i2cConfigs: Seq[I2CConfig] } =>
- val i2cDevices = i2cConfigs.zipWithIndex.map { case (c, i) =>
- val i2c = LazyModule(new TLI2C(c))
- i2c.suggestName(s"i2c$i")
- i2c.node := TLFragmenter(peripheryBusConfig.beatBytes, cacheBlockBytes)(peripheryBus.node)
- intBus.intnode := i2c.intnode
+case object PeripheryI2CKey extends Field[Seq[I2CParams]]
+
+trait HasPeripheryI2C extends HasPeripheryBus {
+ val i2cParams = p(PeripheryI2CKey)
+ val i2c = i2cParams map { params =>
+ val i2c = LazyModule(new TLI2C(pbus.beatBytes, params))
+ i2c.node := pbus.toVariableWidthSlaves
+ ibus.fromSync := i2c.intnode