diff --git a/src/main/scala/devices/pwm/PWMPins.scala b/src/main/scala/devices/pwm/PWMPins.scala new file mode 100644 index 0000000..7ab76f0 --- /dev/null +++ b/src/main/scala/devices/pwm/PWMPins.scala @@ -0,0 +1,27 @@ +// See LICENSE for license details. +package sifive.blocks.devices.pwm + +import Chisel._ +import freechips.rocketchip.config.Field +import freechips.rocketchip.coreplex.{HasPeripheryBus, HasInterruptBus} +import freechips.rocketchip.diplomacy.{LazyModule, LazyMultiIOModuleImp} +import freechips.rocketchip.util.HeterogeneousBag +import sifive.blocks.devices.pinctrl.{Pin} + +class PWMSignals[T <: Data] (pingen: ()=> T, val c: PWMParams) extends Bundle { + + val pwm: Vec[T] = Vec(c.ncmp, pingen()) + + override def cloneType: this.type = + this.getClass.getConstructors.head.newInstance(pingen, c).asInstanceOf[this.type] +} + +class PWMPins[T <: Pin] (pingen: ()=> T, c: PWMParams) extends PWMSignals[T](pingen, c) + +object PWMPinsFromPort { + def apply[T <: Pin] (pins: PWMSignals[T], port: PWMPortIO): Unit = { + (pins.pwm zip port.port) foreach {case (pin, port) => + pin.outputPin(port) + } + } +}