de086bf9f5dbd94d83fbc672c26d1c33ad2ae082
[sifive-blocks.git] / src / main / scala / devices / gpio / GPIOPins.scala
1 // See LICENSE for license details.
2 package sifive.blocks.devices.gpio
3
4 import Chisel._
5 import sifive.blocks.devices.pinctrl.{Pin}
6
7 // While this is a bit pendantic, it keeps the GPIO
8 // device more similar to the other devices. It's not 'special'
9 // even though it looks like something that more directly talks to
10 // a pin. It also makes it possible to change the exact
11 // type of pad this connects to.
12 class GPIOPins[T <: Pin] (pingen: ()=> T, c: GPIOParams) extends Bundle {
13
14 val pins = Vec(c.width, pingen())
15
16 override def cloneType: this.type =
17 this.getClass.getConstructors.head.newInstance(pingen, c).asInstanceOf[this.type]
18
19 def fromPort(port: GPIOPortIO){
20
21 // This will just match up the components of the Bundle that
22 // exist in both.
23 (pins zip port.pins) foreach {case (pin, port) =>
24 pin <> port
25 }
26 }
27 }