2015-09-29 06:14:54 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import importlib
|
|
|
|
|
2015-09-22 12:36:47 -04:00
|
|
|
from migen import *
|
2015-03-16 20:07:44 -04:00
|
|
|
from migen.genlib.io import CRG
|
2014-09-20 16:48:53 -04:00
|
|
|
|
2015-09-25 06:43:20 -04:00
|
|
|
from misoc.cores.liteeth_mini.phy import LiteEthPHY
|
|
|
|
from misoc.cores.liteeth_mini.mac import LiteEthMAC
|
2015-09-29 06:14:54 -04:00
|
|
|
from misoc.integration.soc_core import *
|
|
|
|
from misoc.integration.builder import *
|
2014-09-20 16:48:53 -04:00
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2015-09-25 06:43:20 -04:00
|
|
|
class BaseSoC(SoCCore):
|
2015-04-13 10:19:55 -04:00
|
|
|
def __init__(self, platform, **kwargs):
|
2015-09-25 06:43:20 -04:00
|
|
|
SoCCore.__init__(self, platform,
|
2015-04-13 10:19:55 -04:00
|
|
|
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))
|
2014-09-20 16:48:53 -04:00
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2015-03-06 04:10:58 -05:00
|
|
|
class MiniSoC(BaseSoC):
|
2015-04-13 10:19:55 -04:00
|
|
|
csr_map = {
|
2015-04-13 11:16:12 -04:00
|
|
|
"ethphy": 20,
|
|
|
|
"ethmac": 21
|
2015-04-13 10:19:55 -04:00
|
|
|
}
|
|
|
|
csr_map.update(BaseSoC.csr_map)
|
|
|
|
|
|
|
|
interrupt_map = {
|
2015-04-13 11:16:12 -04:00
|
|
|
"ethmac": 2,
|
2015-04-13 10:19:55 -04:00
|
|
|
}
|
|
|
|
interrupt_map.update(BaseSoC.interrupt_map)
|
|
|
|
|
|
|
|
mem_map = {
|
2015-04-13 11:16:12 -04:00
|
|
|
"ethmac": 0x30000000, # (shadow @0xb0000000)
|
2015-04-13 10:19:55 -04:00
|
|
|
}
|
|
|
|
mem_map.update(BaseSoC.mem_map)
|
|
|
|
|
|
|
|
def __init__(self, platform, **kwargs):
|
|
|
|
BaseSoC.__init__(self, platform, **kwargs)
|
|
|
|
|
2015-04-13 11:56:51 -04:00
|
|
|
self.submodules.ethphy = LiteEthPHY(platform.request("eth_clocks"),
|
|
|
|
platform.request("eth"))
|
|
|
|
self.submodules.ethmac = LiteEthMAC(phy=self.ethphy, dw=32,
|
|
|
|
interface="wishbone",
|
2015-04-24 05:30:35 -04:00
|
|
|
with_preamble_crc=False)
|
2015-04-13 10:19:55 -04:00
|
|
|
self.add_wb_slave(mem_decoder(self.mem_map["ethmac"]), self.ethmac.bus)
|
2015-05-02 10:57:32 -04:00
|
|
|
self.add_memory_region("ethmac", self.mem_map["ethmac"] | self.shadow_base, 0x2000)
|
2015-03-06 04:10:58 -05:00
|
|
|
|
2015-09-29 06:14:54 -04:00
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(description="Generic MiSoC port")
|
|
|
|
builder_args(parser)
|
|
|
|
soc_core_args(parser)
|
|
|
|
parser.add_argument("--with-ethernet", action="store_true",
|
|
|
|
help="enable Ethernet support")
|
|
|
|
parser.add_argument("platform",
|
|
|
|
help="module name of the Migen platform to build for")
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
platform_module = importlib.import_module(args.platform)
|
|
|
|
platform = platform_module.Platform()
|
|
|
|
cls = MiniSoC if args.with_ethernet else BaseSoC
|
|
|
|
soc = cls(platform, **soc_core_argdict(args))
|
|
|
|
builder = Builder(soc, **builder_argdict(args))
|
|
|
|
builder.build()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|