Advertisement
Guest User

Untitled

a guest
Aug 6th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. from migen import *
  2. from migen.build.platforms import papilio_pro
  3.  
  4. from misoc.cores.uart.core import RS232PHY
  5. import wishbonebridge
  6.  
  7. from misoc.interconnect import wishbone, csr_bus
  8.  
  9. platform = papilio_pro.Platform()
  10.  
  11.  
  12. class MyWishbone(Module):
  13.     def __init__(self):
  14.         self.wb = wb = wishbone.Interface()
  15.  
  16.         counter1 = Signal(32, reset=0xdeadbeef)
  17.         counter2 = Signal(32, reset=0x12345678)
  18.  
  19.         self.sync += [
  20.             If(wb.adr[0],
  21.                wb.dat_r.eq(counter1)
  22.             ).Else(
  23.                 wb.dat_r.eq(counter2)
  24.             ),
  25.  
  26.             wb.ack.eq(0),
  27.             If(wb.cyc & wb.stb & ~wb.ack,
  28.                wb.ack.eq(1),
  29.                If(wb.we,
  30.                   If(wb.adr[0],
  31.                      counter1.eq(wb.dat_w)
  32.                   ).Else(counter2.eq(wb.dat_w))
  33.                )
  34.             )
  35.             ]
  36.  
  37. class WBTest(Module):
  38.     def __init__(self):
  39.         counter = Signal(32)
  40.  
  41.         self.submodules.phy = RS232PHY(platform.request("serial"), 32000000, 115200)
  42.         self.submodules.bridge = wishbonebridge.WishboneStreamingBridge(self.phy, 32000000)
  43.  
  44.         self.submodules.mywb = MyWishbone()
  45.  
  46.         wishbone.InterconnectPointToPoint(self.bridge.wishbone, self.mywb.wb)
  47.  
  48. if __name__ == "__main__":
  49.  
  50.     top = WBTest()
  51.     platform.build(top, build_dir="wbtest")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement