2013-11-24 17:52:05 -05:00
|
|
|
from migen.fhdl.std import *
|
2014-04-08 09:25:49 -04:00
|
|
|
from migen.bus import wishbone
|
2013-11-24 17:52:05 -05:00
|
|
|
|
2014-04-13 18:23:41 -04:00
|
|
|
from misoclib import spiflash
|
2014-02-14 09:48:15 -05:00
|
|
|
from misoclib.gensoc import GenSoC
|
2013-11-24 17:52:05 -05:00
|
|
|
|
2014-04-14 11:44:12 -04:00
|
|
|
class PowerOnRst(Module):
|
|
|
|
def __init__(self, cd, overwrite_cd_rst=True):
|
|
|
|
self.clock_domains.cd_pwr_on = ClockDomain(reset_less=True)
|
|
|
|
self.cd_pwr_on.clk = cd.clk
|
|
|
|
self.pwr_on_rst = Signal()
|
|
|
|
|
|
|
|
rst_n = Signal()
|
|
|
|
self.sync.pwr_on += rst_n.eq(1)
|
|
|
|
self.comb += self.pwr_on_rst.eq(~rst_n)
|
|
|
|
|
|
|
|
if overwrite_cd_rst:
|
|
|
|
self.comb += cd.rst.eq(self.pwr_on_rst)
|
|
|
|
|
2014-02-14 09:48:15 -05:00
|
|
|
class SimpleSoC(GenSoC):
|
2014-02-16 08:51:52 -05:00
|
|
|
default_platform = "papilio_pro"
|
|
|
|
|
2013-11-24 17:52:05 -05:00
|
|
|
def __init__(self, platform):
|
|
|
|
GenSoC.__init__(self, platform,
|
|
|
|
clk_freq=32*1000000,
|
2014-02-14 09:48:15 -05:00
|
|
|
cpu_reset_address=0x60000)
|
2013-11-24 17:52:05 -05:00
|
|
|
|
|
|
|
# We can't use reset_less as LM32 does require a reset signal
|
|
|
|
self.clock_domains.cd_sys = ClockDomain()
|
2014-04-14 11:44:12 -04:00
|
|
|
self.submodules += PowerOnRst(self.cd_sys)
|
2013-11-24 17:52:05 -05:00
|
|
|
self.comb += self.cd_sys.clk.eq(platform.request("clk32"))
|
|
|
|
|
2014-02-16 08:51:52 -05:00
|
|
|
# BIOS is in SPI flash
|
2013-11-25 09:08:53 -05:00
|
|
|
self.submodules.spiflash = spiflash.SpiFlash(platform.request("spiflash2x"),
|
|
|
|
cmd=0xefef, cmd_width=16, addr_width=24, dummy=4)
|
2014-04-08 09:25:49 -04:00
|
|
|
self.flash_boot_address = 0x70000
|
2014-02-14 09:48:15 -05:00
|
|
|
self.register_rom(self.spiflash.bus)
|
2013-11-25 09:08:53 -05:00
|
|
|
|
2014-04-08 09:25:49 -04:00
|
|
|
# TODO: use on-board SDRAM instead of block RAM
|
|
|
|
sys_ram_size = 32*1024
|
|
|
|
self.submodules.sys_ram = wishbone.SRAM(sys_ram_size)
|
|
|
|
self.add_wb_slave(lambda a: a[27:29] == 2, self.sys_ram.bus)
|
|
|
|
self.add_cpu_memory_region("sdram", 0x40000000, sys_ram_size)
|
|
|
|
|
2014-02-16 08:51:52 -05:00
|
|
|
default_subtarget = SimpleSoC
|