Ports: Rename the 'fromXYZPort' to 'fromPort' since it's redundant
[sifive-blocks.git] / src / main / scala / devices / i2c / I2CPins.scala
1 // See LICENSE for license details.
2 package sifive.blocks.devices.i2c
3
4 import Chisel._
5 import chisel3.experimental.{withClockAndReset}
6 import sifive.blocks.devices.pinctrl.{Pin, PinCtrl}
7 import sifive.blocks.util.ShiftRegisterInit
8
9
10 class I2CPins[T <: Pin](pingen: () => T) extends Bundle {
11
12 val scl: T = pingen()
13 val sda: T = pingen()
14
15 override def cloneType: this.type =
16 this.getClass.getConstructors.head.newInstance(pingen).asInstanceOf[this.type]
17
18 def fromPort(i2c: I2CPort, clock: Clock, reset: Bool, syncStages: Int = 0) = {
19 withClockAndReset(clock, reset) {
20 scl.outputPin(i2c.scl.out, pue=true.B, ie = true.B)
21 scl.o.oe := i2c.scl.oe
22 i2c.scl.in := ShiftRegisterInit(scl.i.ival, syncStages, Bool(true))
23
24 sda.outputPin(i2c.sda.out, pue=true.B, ie = true.B)
25 sda.o.oe := i2c.sda.oe
26 i2c.sda.in := ShiftRegisterInit(sda.i.ival, syncStages, Bool(true))
27 }
28 }
29 }