projects
/
sifive-blocks.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove cloneTypes in favor of autoclonetype (#51)
[sifive-blocks.git]
/
src
/
main
/
scala
/
devices
/
spi
/
SPIPins.scala
diff --git
a/src/main/scala/devices/spi/SPIPins.scala
b/src/main/scala/devices/spi/SPIPins.scala
index 780e8cc35f5dc6fffa4321ede941769837cc6965..f8ce8e1d0332bd1b42c0202700001173d57c7432 100644
(file)
--- a/
src/main/scala/devices/spi/SPIPins.scala
+++ b/
src/main/scala/devices/spi/SPIPins.scala
@@
-5,29
+5,31
@@
import Chisel._
import chisel3.experimental.{withClockAndReset}
import sifive.blocks.devices.pinctrl.{PinCtrl, Pin}
import chisel3.experimental.{withClockAndReset}
import sifive.blocks.devices.pinctrl.{PinCtrl, Pin}
-class SPI
Pins[T <: Pin] (pingen: ()
=> T, c: SPIParamsBase) extends SPIBundle(c) {
+class SPI
Signals[T <: Data](private val pingen: ()
=> T, c: SPIParamsBase) extends SPIBundle(c) {
val sck = pingen()
val dq = Vec(4, pingen())
val cs = Vec(c.csWidth, pingen())
val sck = pingen()
val dq = Vec(4, pingen())
val cs = Vec(c.csWidth, pingen())
+}
- override def cloneType: this.type =
- this.getClass.getConstructors.head.newInstance(pingen, c).asInstanceOf[this.type]
+class SPIPins[T <: Pin] (pingen: ()=> T, c: SPIParamsBase) extends SPISignals(pingen, c)
- def fromPort(spi: SPIPortIO, clock: Clock, reset: Bool,
+object SPIPinsFromPort {
+
+ def apply[T <: Pin](pins: SPISignals[T], spi: SPIPortIO, clock: Clock, reset: Bool,
syncStages: Int = 0, driveStrength: Bool = Bool(false)) {
withClockAndReset(clock, reset) {
syncStages: Int = 0, driveStrength: Bool = Bool(false)) {
withClockAndReset(clock, reset) {
- sck.outputPin(spi.sck, ds = driveStrength)
+
pins.
sck.outputPin(spi.sck, ds = driveStrength)
- (dq zip spi.dq).foreach {case (p, s) =>
+ (
pins.
dq zip spi.dq).foreach {case (p, s) =>
p.outputPin(s.o, pue = Bool(true), ds = driveStrength)
p.o.oe := s.oe
p.o.ie := ~s.oe
s.i := ShiftRegister(p.i.ival, syncStages)
}
p.outputPin(s.o, pue = Bool(true), ds = driveStrength)
p.o.oe := s.oe
p.o.ie := ~s.oe
s.i := ShiftRegister(p.i.ival, syncStages)
}
- (cs zip spi.cs) foreach { case (c, s) =>
+ (
pins.
cs zip spi.cs) foreach { case (c, s) =>
c.outputPin(s, ds = driveStrength)
}
}
c.outputPin(s, ds = driveStrength)
}
}