Advertisement
Guest User

Untitled

a guest
Mar 8th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.12 KB | None | 0 0
  1. diff --git a/valentyusb/usbcore/rx/nrzi.py b/valentyusb/usbcore/rx/nrzi.py
  2. index ca371e6..fec39f1 100644
  3. --- a/valentyusb/usbcore/rx/nrzi.py
  4. +++ b/valentyusb/usbcore/rx/nrzi.py
  5. @@ -116,7 +116,7 @@ class RxNRZIDecoder(Module):
  6.                  If(self.i_valid,
  7.                      last_data.eq(self.i_dk),
  8.                      self.o_data.eq(~(self.i_dk ^ last_data)),
  9. -                    self.o_valid.eq(self.i_dj ^ ~self.i_dk),
  10.                      self.o_se0.eq((~self.i_dj) & (~self.i_dk)),
  11.                  ),
  12. +               self.o_valid.eq(self.i_valid),
  13.              ]
  14. diff --git a/valentyusb/usbcore/rx/pipeline.py b/valentyusb/usbcore/rx/pipeline.py
  15. index 744952d..251412e 100644
  16. --- a/valentyusb/usbcore/rx/pipeline.py
  17. +++ b/valentyusb/usbcore/rx/pipeline.py
  18. @@ -53,11 +53,40 @@ class RxPipeline(Module):
  19.          # Cross the data from the 48MHz domain to the 12MHz domain
  20.          bit_dat = Signal()
  21.          bit_se0 = Signal()
  22. +#        self.comb += [
  23. +#            bit_dat.eq(nrzi.o_data),
  24. +#            bit_se0.eq(nrzi.o_se0),
  25. +#        ]
  26. +
  27. +        fifo_idle = Signal(4)
  28. +        fifo_delay = Signal(4)
  29. +        fifo_filling = Signal()
  30. +
  31. +        self.sync.usb_48 += If(nrzi.o_valid,
  32. +            If(nrzi.o_data, If(~fifo_idle[3], fifo_idle.eq(fifo_idle + 1))).Else(fifo_idle.eq(0))
  33. +        )
  34. +
  35. +        fifo = genlib.fifo.AsyncFIFO(2, 32)
  36. +        self.submodules.fifo = fifo = ClockDomainsRenamer({"write":"usb_48", "read":"usb_12"})(fifo)
  37. +
  38.          self.comb += [
  39. -            bit_dat.eq(nrzi.o_data),
  40. -            bit_se0.eq(nrzi.o_se0),
  41. +            fifo.din[0].eq(nrzi.o_data),
  42. +            fifo.din[1].eq(nrzi.o_se0),
  43. +            fifo.we.eq(nrzi.o_valid & (~fifo_idle[3] | ~nrzi.o_data)),
  44. +            bit_dat.eq(fifo.dout[0]),
  45. +            bit_se0.eq(fifo.dout[1]),
  46. +            fifo.re.eq(fifo_delay[3]),
  47. +            fifo_filling.eq(~fifo_delay[3]),
  48.          ]
  49.  
  50. +        self.sync.usb_12 += If(fifo.readable,
  51. +            fifo_delay.eq(fifo_delay + fifo_filling),
  52. +        ).Else(
  53. +            fifo_delay.eq(0)
  54. +        )
  55. +
  56. +
  57. +
  58.          # The packet detector resets the reset of the pipeline.
  59.          reset = Signal()
  60.          detect = RxPacketDetect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement