Merge pull request #52 from sifive/spi_sync
SPI: Use the standard synchronizer primitive for the SPI DQ inputs
This commit is contained in:
commit
48a9acc8a4
@ -3,6 +3,7 @@ package sifive.blocks.devices.spi
|
|||||||
|
|
||||||
import Chisel._
|
import Chisel._
|
||||||
import chisel3.experimental.{withClockAndReset}
|
import chisel3.experimental.{withClockAndReset}
|
||||||
|
import freechips.rocketchip.util.{SynchronizerShiftReg}
|
||||||
import sifive.blocks.devices.pinctrl.{PinCtrl, Pin}
|
import sifive.blocks.devices.pinctrl.{PinCtrl, Pin}
|
||||||
|
|
||||||
class SPISignals[T <: Data](private val pingen: () => T, c: SPIParamsBase) extends SPIBundle(c) {
|
class SPISignals[T <: Data](private val pingen: () => T, c: SPIParamsBase) extends SPIBundle(c) {
|
||||||
@ -22,11 +23,11 @@ object SPIPinsFromPort {
|
|||||||
withClockAndReset(clock, reset) {
|
withClockAndReset(clock, reset) {
|
||||||
pins.sck.outputPin(spi.sck, ds = driveStrength)
|
pins.sck.outputPin(spi.sck, ds = driveStrength)
|
||||||
|
|
||||||
(pins.dq zip spi.dq).foreach {case (p, s) =>
|
(pins.dq zip spi.dq).zipWithIndex.foreach {case ((p, s), i) =>
|
||||||
p.outputPin(s.o, pue = Bool(true), ds = driveStrength)
|
p.outputPin(s.o, pue = Bool(true), ds = driveStrength)
|
||||||
p.o.oe := s.oe
|
p.o.oe := s.oe
|
||||||
p.o.ie := ~s.oe
|
p.o.ie := ~s.oe
|
||||||
s.i := ShiftRegister(p.i.ival, syncStages)
|
s.i := SynchronizerShiftReg(p.i.ival, syncStages, name = Some(s"spi_dq_${i}_sync"))
|
||||||
}
|
}
|
||||||
|
|
||||||
(pins.cs zip spi.cs) foreach { case (c, s) =>
|
(pins.cs zip spi.cs) foreach { case (c, s) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user