X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmain%2Fscala%2Fdevices%2Fgpio%2FGPIOPins.scala;h=e2f279eeacc6da9892fe81a99f6dbcd154b8c76a;hb=81e301f9f75bfdb495d72951f33cada08786d83a;hp=de086bf9f5dbd94d83fbc672c26d1c33ad2ae082;hpb=86010395adffd9ee4a42f5240b08bb0f243972ff;p=sifive-blocks.git diff --git a/src/main/scala/devices/gpio/GPIOPins.scala b/src/main/scala/devices/gpio/GPIOPins.scala index de086bf..e2f279e 100644 --- a/src/main/scala/devices/gpio/GPIOPins.scala +++ b/src/main/scala/devices/gpio/GPIOPins.scala @@ -9,18 +9,19 @@ import sifive.blocks.devices.pinctrl.{Pin} // even though it looks like something that more directly talks to // a pin. It also makes it possible to change the exact // type of pad this connects to. -class GPIOPins[T <: Pin] (pingen: ()=> T, c: GPIOParams) extends Bundle { - +class GPIOSignals[T <: Data] (pingen: ()=> T, c: GPIOParams) extends Bundle { val pins = Vec(c.width, pingen()) +} + +class GPIOPins[T <: Pin] (pingen: ()=> T, c: GPIOParams) extends GPIOSignals[T](pingen, c) - override def cloneType: this.type = - this.getClass.getConstructors.head.newInstance(pingen, c).asInstanceOf[this.type] +object GPIOPinsFromPort { - def fromPort(port: GPIOPortIO){ + def apply[T <: Pin](pins: GPIOSignals[T], port: GPIOPortIO){ // This will just match up the components of the Bundle that // exist in both. - (pins zip port.pins) foreach {case (pin, port) => + (pins.pins zip port.pins) foreach {case (pin, port) => pin <> port } }