Advertisement
natsfr

LiteX no clock constraint

Mar 9th, 2021
860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. from migen import *
  4.  
  5. from litex.build.generic_platform import *
  6. from litex.build.xilinx import XilinxPlatform
  7.  
  8. # Declare IOs
  9.  
  10. _io = [
  11.     ("clk50", 0, Pins("P123"), IOStandard("LVCMOS33")),
  12.     ("user_led", 0, Pins("P119"), IOStandard("LVCMOS33"), Drive(8)),
  13.     ("user_led", 1, Pins("P118"), IOStandard("LVCMOS33"), Drive(8)),
  14.     ("user_led", 2, Pins("P117"), IOStandard("LVCMOS33"), Drive(8)),
  15. ]
  16.  
  17. # Platform
  18. class Platform(XilinxPlatform):
  19.     default_clk_name    = "clk50"
  20.     default_clk_period  = 20        # period in ns
  21.  
  22.     # W25Q16DV - component U1
  23.     # 16Mb - 75 MHz clock frequency
  24.     spiflash_model = "w25q16dw"
  25.     spiflash_read_dummy_bits = 8
  26.     spiflash_clock_div = 4
  27.     spiflash_total_size = int((16/8)*1024*1024) # 16Mbit
  28.     spiflash_page_size = 256
  29.     spiflash_sector_size = 0x10000
  30.  
  31.     def __init__(self):
  32.         XilinxPlatform.__init__(self, "xc6slx9-tqg144-2", _io, toolchain="ise")
  33.  
  34.     def do_finalize(self, fragment):
  35.         XilinxPlatform.do_finalize(self, fragment)
  36.  
  37.     def create_programmer(self):
  38.         raise NotImplementedError
  39.  
  40. platform = Platform()
  41. ledb = platform.request("user_led", 0)
  42. ledg = platform.request("user_led", 1)
  43. ledr = platform.request("user_led", 2)
  44.  
  45. module = Module()
  46. counter = Signal(32)
  47.  
  48. module.sync += [
  49.     counter.eq(counter + 1),
  50.     If(counter == int(50e6),
  51.         counter.eq(0)
  52.         ),
  53.     ledb.eq(counter[23]),
  54.     ledg.eq(counter[24]),
  55.     ledr.eq(counter[25])
  56. ]
  57.  
  58. platform.build(module)
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement