1
0

Merge pull request #52 from sifive/spi_sync

SPI: Use the standard synchronizer primitive for the SPI DQ inputs
This commit is contained in:
Megan Wachs 2018-03-07 14:45:44 -08:00 committed by GitHub
commit 48a9acc8a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) =>