uart.c: rx overflow fix and tx simplification
[litex.git] / targets / simple.py
index ed8fbdee09dcaeff8cd537c6648630ea7d46fa42..3d2568483ac7f9b719ca33dc6cdcf05268ca8ac2 100644 (file)
@@ -1,26 +1,48 @@
 from migen.fhdl.std import *
+from migen.bus import wishbone
+from migen.genlib.io import CRG
 
-from misoclib import gpio, spiflash
-from misoclib.gensoc import GenSoC
+from misoclib.soc import SoC, mem_decoder
+from misoclib.com.liteeth.phy import LiteEthPHY
+from misoclib.com.liteeth.core.mac import LiteEthMAC
 
-class SimpleSoC(GenSoC):
-       default_platform = "papilio_pro"
 
-       def __init__(self, platform):
-               GenSoC.__init__(self, platform,
-                       clk_freq=32*1000000,
-                       cpu_reset_address=0x60000)
+class BaseSoC(SoC):
+    def __init__(self, platform, **kwargs):
+        SoC.__init__(self, platform,
+            clk_freq=int((1/(platform.default_clk_period))*1000000000),
+            integrated_rom_size=0x8000,
+            integrated_main_ram_size=16*1024,
+            **kwargs)
+        self.submodules.crg = CRG(platform.request(platform.default_clk_name))
 
-               # We can't use reset_less as LM32 does require a reset signal
-               self.clock_domains.cd_sys = ClockDomain()
-               self.comb += self.cd_sys.clk.eq(platform.request("clk32"))
-               self.specials += Instance("FD", p_INIT=1, i_D=0, o_Q=self.cd_sys.rst, i_C=ClockSignal())
 
-               # BIOS is in SPI flash
-               self.submodules.spiflash = spiflash.SpiFlash(platform.request("spiflash2x"),
-                       cmd=0xefef, cmd_width=16, addr_width=24, dummy=4)
-               self.register_rom(self.spiflash.bus)
+class MiniSoC(BaseSoC):
+    csr_map = {
+        "ethphy": 20,
+        "ethmac": 21
+    }
+    csr_map.update(BaseSoC.csr_map)
 
-               self.submodules.leds = gpio.GPIOOut(platform.request("user_led"))
+    interrupt_map = {
+        "ethmac": 2,
+    }
+    interrupt_map.update(BaseSoC.interrupt_map)
 
-default_subtarget = SimpleSoC
+    mem_map = {
+        "ethmac": 0x30000000,  # (shadow @0xb0000000)
+    }
+    mem_map.update(BaseSoC.mem_map)
+
+    def __init__(self, platform, **kwargs):
+        BaseSoC.__init__(self, platform, **kwargs)
+
+        self.submodules.ethphy = LiteEthPHY(platform.request("eth_clocks"),
+                                            platform.request("eth"))
+        self.submodules.ethmac = LiteEthMAC(phy=self.ethphy, dw=32,
+                                            interface="wishbone",
+                                            with_preamble_crc=False)
+        self.add_wb_slave(mem_decoder(self.mem_map["ethmac"]), self.ethmac.bus)
+        self.add_memory_region("ethmac", self.mem_map["ethmac"] | self.shadow_base, 0x2000)
+
+default_subtarget = BaseSoC