Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. diff --git a/litex/boards/platforms/beaglewire.py b/litex/boards/platforms/beaglewire.py
  2. new file mode 100644
  3. index 00000000..074b7aee
  4. --- /dev/null
  5. +++ b/litex/boards/platforms/beaglewire.py
  6. @@ -0,0 +1,64 @@
  7. +from litex.build.generic_platform import *
  8. +from litex.build.lattice import LatticePlatform
  9. +from litex.build.lattice.programmer import IceStormProgrammer
  10. +
  11. +
  12. +_io = [
  13. + ("user_led", 0, Pins("28"), IOStandard("LVCMOS33")),
  14. + ("user_led", 1, Pins("29"), IOStandard("LVCMOS33")),
  15. + ("user_led", 2, Pins("31"), IOStandard("LVCMOS33")),
  16. + ("user_led", 3, Pins("32"), IOStandard("LVCMOS33")),
  17. +
  18. + ("user_sw", 0, Pins("33"), IOStandard("LVCMOS33")),
  19. + ("user_sw", 1, Pins("34"), IOStandard("LVCMOS33")),
  20. +
  21. + ("spiflash", 0,
  22. + Subsignal("cs_n", Pins("71"), IOStandard("LVCMOS33")),
  23. + Subsignal("clk", Pins("70"), IOStandard("LVCMOS33")),
  24. + Subsignal("mosi", Pins("67"), IOStandard("LVCMOS33")),
  25. + Subsignal("miso", Pins("68"), IOStandard("LVCMOS33"))
  26. + ),
  27. +
  28. + ("sdram_clock", 0, Pins("93"), IOStandard("LVCMOS33"), Misc("SLEW=FAST")),
  29. + ("sdram", 0,
  30. + Subsignal("a", Pins("118 117 116 101 81 83 90 91 82 84 119 85 87")),
  31. + Subsignal("dq", Pins("96 97 98 99 95 80 79 78")),
  32. + Subsignal("we_n", Pins("128")),
  33. + Subsignal("ras_n", Pins("124")),
  34. + Subsignal("cas_n", Pins("125")),
  35. + Subsignal("cs_n", Pins("137")),
  36. + Subsignal("cke", Pins("88")),
  37. + Subsignal("ba", Pins("121 120")),
  38. + Subsignal("dm", Pins("94")),
  39. + IOStandard("LVCMOS33"), Misc("SLEW=FAST")
  40. + ),
  41. +
  42. + ("serial", 0,
  43. + Subsignal("tx", Pins("105"), IOStandard("LVCMOS33")), # Grove4 D0
  44. + Subsignal("rx", Pins("106"), IOStandard("LVCMOS33")) # GROVE4 D1
  45. + ),
  46. +
  47. + ("clk100", 0, Pins("61"), IOStandard("LVCMOS33"))
  48. +]
  49. +
  50. +_connectors = [
  51. + ("PMOD1", "38 41 43 45 37 39 42 44"),
  52. + ("PMOD2", "48 52 56 62 47 49 55 60"),
  53. + ("PMOD3", "107 112 114 129 110 113 115 130"),
  54. + ("PMOD4", "4 8 10 11 7 9 15 12"),
  55. + ("GROVE1", "73 74"),
  56. + ("GROVE2", "75 76"),
  57. + ("GROVE3", "102 104")
  58. +]
  59. +
  60. +
  61. +class Platform(LatticePlatform):
  62. + default_clk_name = "clk100"
  63. + default_clk_period = 10
  64. +
  65. + def __init__(self):
  66. + LatticePlatform.__init__(self, "ice40-hx8k-tq144:4k", _io, _connectors,
  67. + toolchain="icestorm")
  68. +
  69. + def create_programmer(self):
  70. + return IceStormProgrammer()
  71. diff --git a/litex/boards/targets/beaglewire.py b/litex/boards/targets/beaglewire.py
  72. new file mode 100755
  73. index 00000000..1bba7e5a
  74. --- /dev/null
  75. +++ b/litex/boards/targets/beaglewire.py
  76. @@ -0,0 +1,70 @@
  77. +#!/usr/bin/env python3
  78. +
  79. +import argparse
  80. +from fractions import Fraction
  81. +
  82. +from migen import *
  83. +from migen.genlib.resetsync import AsyncResetSynchronizer
  84. +
  85. +from litex.boards.platforms import beaglewire
  86. +
  87. +from litex.soc.integration.soc_sdram import *
  88. +from litex.soc.integration.builder import *
  89. +
  90. +from litedram.modules import SDRAMModule
  91. +from litedram.phy import GENSDRPHY
  92. +
  93. +class IS42S83200(SDRAMModule):
  94. + memtype = "SDR"
  95. + # geometry
  96. + nbanks = 4
  97. + nrows = 8192
  98. + ncols = 1024
  99. + # timings (-7 speedgrade)
  100. + tRP = 20
  101. + tRCD = 20
  102. + tWR = 20
  103. + tWTR = 2
  104. + tREFI = 64*1000*1000/8192
  105. + tRFC = 70
  106. +
  107. +class _CRG(Module):
  108. + def __init__(self, platform):
  109. + self.clock_domains.cd_sys = ClockDomain()
  110. + self.clock_domains.cd_sys_ps = ClockDomain()
  111. + self.clock_domains.cd_por = ClockDomain(reset_less=True)
  112. +
  113. + clk100 = platform.request("clk100")
  114. +
  115. + self.comb += platform.request("sdram_clock").eq(clk100)
  116. + self.comb += self.cd_sys.clk.eq(clk100)
  117. + self.comb += self.cd_sys_ps.clk.eq(clk100)
  118. +
  119. +class BaseSoC(SoCSDRAM):
  120. + def __init__(self, **kwargs):
  121. + clk_freq = 100*1000000
  122. + platform = beaglewire.Platform()
  123. + SoCSDRAM.__init__(self, platform, clk_freq,
  124. + **kwargs)
  125. +
  126. + self.submodules.crg = _CRG(platform)
  127. +
  128. + if not self.integrated_main_ram_size:
  129. + self.submodules.sdrphy = GENSDRPHY(platform.request("sdram"))
  130. + sdram_module = IS42S83200(clk_freq, "1:1")
  131. + self.register_sdram(self.sdrphy,
  132. + sdram_module.geom_settings,
  133. + sdram_module.timing_settings)
  134. +
  135. +def main():
  136. + parser = argparse.ArgumentParser(description="LiteX SoC port to Beaglewire")
  137. + builder_args(parser)
  138. + soc_sdram_args(parser)
  139. + args = parser.parse_args()
  140. +
  141. + soc = BaseSoC(**soc_sdram_argdict(args))
  142. + builder = Builder(soc, **builder_argdict(args))
  143. + builder.build()
  144. +
  145. +if __name__ == "__main__":
  146. + main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement