projects
/
sifive-blocks.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
device pins: Create classes that can be something other than a Pin subclass
[sifive-blocks.git]
/
src
/
main
/
scala
/
devices
/
pwm
/
PWMPeriphery.scala
diff --git
a/src/main/scala/devices/pwm/PWMPeriphery.scala
b/src/main/scala/devices/pwm/PWMPeriphery.scala
index f83cbafdfe9780ea83e865a8d94b65c4de9a8c4a..94f65dd760e8c5d75537fc380140492a689526d8 100644
(file)
--- a/
src/main/scala/devices/pwm/PWMPeriphery.scala
+++ b/
src/main/scala/devices/pwm/PWMPeriphery.scala
@@
-3,25
+3,31
@@
package sifive.blocks.devices.pwm
import Chisel._
import freechips.rocketchip.config.Field
import Chisel._
import freechips.rocketchip.config.Field
-import freechips.rocketchip.diplomacy.{LazyModule,LazyMultiIOModuleImp}
-import freechips.rocketchip.chip.HasSystemNetworks
-import freechips.rocketchip.tilelink.TLFragmenter
+import freechips.rocketchip.coreplex.{HasPeripheryBus, HasInterruptBus}
+import freechips.rocketchip.diplomacy.{LazyModule, LazyMultiIOModuleImp}
import freechips.rocketchip.util.HeterogeneousBag
import freechips.rocketchip.util.HeterogeneousBag
-import sifive.blocks.devices.pinctrl.{Pin
Ctrl, Pin
}
+import sifive.blocks.devices.pinctrl.{Pin}
class PWMPortIO(val c: PWMParams) extends Bundle {
val port = Vec(c.ncmp, Bool()).asOutput
override def cloneType: this.type = new PWMPortIO(c).asInstanceOf[this.type]
}
class PWMPortIO(val c: PWMParams) extends Bundle {
val port = Vec(c.ncmp, Bool()).asOutput
override def cloneType: this.type = new PWMPortIO(c).asInstanceOf[this.type]
}
-class PWM
Pins[T <: Pin
] (pingen: ()=> T, val c: PWMParams) extends Bundle {
+class PWM
Signals[T <: Data
] (pingen: ()=> T, val c: PWMParams) extends Bundle {
val pwm: Vec[T] = Vec(c.ncmp, pingen())
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, val c: PWMParams) extends PWMSignals[T](pingen, c) {
+
override def cloneType: this.type =
this.getClass.getConstructors.head.newInstance(pingen, c).asInstanceOf[this.type]
override def cloneType: this.type =
this.getClass.getConstructors.head.newInstance(pingen, c).asInstanceOf[this.type]
- def fromP
WMP
ort(port: PWMPortIO) {
+ def fromPort(port: PWMPortIO) {
(pwm zip port.port) foreach {case (pin, port) =>
pin.outputPin(port)
}
(pwm zip port.port) foreach {case (pin, port) =>
pin.outputPin(port)
}
@@
-30,12
+36,12
@@
class PWMPins[T <: Pin] (pingen: ()=> T, val c: PWMParams) extends Bundle {
case object PeripheryPWMKey extends Field[Seq[PWMParams]]
case object PeripheryPWMKey extends Field[Seq[PWMParams]]
-trait HasPeripheryPWM extends Has
SystemNetwork
s {
+trait HasPeripheryPWM extends Has
PeripheryBus with HasInterruptBu
s {
val pwmParams = p(PeripheryPWMKey)
val pwms = pwmParams map { params =>
val pwmParams = p(PeripheryPWMKey)
val pwms = pwmParams map { params =>
- val pwm = LazyModule(new TLPWM(p
eripheryBus
Bytes, params))
- pwm.node :=
TLFragmenter(peripheryBusBytes, cacheBlockBytes)(peripheryBus.node)
- i
ntBus.intnode
:= pwm.intnode
+ val pwm = LazyModule(new TLPWM(p
bus.beat
Bytes, params))
+ pwm.node :=
pbus.toVariableWidthSlaves
+ i
bus.fromSync
:= pwm.intnode
pwm
}
}
pwm
}
}