2013-11-24 07:37:32 -05:00
|
|
|
import os
|
2012-02-16 12:02:37 -05:00
|
|
|
from fractions import Fraction
|
|
|
|
|
2013-05-22 11:10:13 -04:00
|
|
|
from migen.fhdl.std import *
|
2013-07-04 13:19:39 -04:00
|
|
|
from mibuild.generic_platform import ConstraintError
|
2011-12-16 10:02:49 -05:00
|
|
|
|
2014-04-17 13:38:13 -04:00
|
|
|
from misoclib import lasmicon, mxcrg, norflash16, minimac3, framebuffer, dvisampler, gpio
|
|
|
|
from misoclib.sdramphy import s6ddrphy
|
2013-11-24 04:30:02 -05:00
|
|
|
from misoclib.gensoc import SDRAMSoC
|
2011-12-13 11:33:12 -05:00
|
|
|
|
2013-11-24 04:30:02 -05:00
|
|
|
class _MXClockPads:
|
2013-03-26 12:57:17 -04:00
|
|
|
def __init__(self, platform):
|
|
|
|
self.clk50 = platform.request("clk50")
|
2013-07-04 13:19:39 -04:00
|
|
|
self.trigger_reset = 0
|
|
|
|
try:
|
|
|
|
self.trigger_reset = platform.request("user_btn", 1)
|
|
|
|
except ConstraintError:
|
|
|
|
pass
|
2013-03-26 12:57:17 -04:00
|
|
|
self.norflash_rst_n = platform.request("norflash_rst_n")
|
|
|
|
ddram_clock = platform.request("ddram_clock")
|
|
|
|
self.ddr_clk_p = ddram_clock.p
|
|
|
|
self.ddr_clk_n = ddram_clock.n
|
|
|
|
eth_clocks = platform.request("eth_clocks")
|
|
|
|
self.eth_phy_clk = eth_clocks.phy
|
|
|
|
self.eth_rx_clk = eth_clocks.rx
|
|
|
|
self.eth_tx_clk = eth_clocks.tx
|
2012-05-16 19:41:41 -04:00
|
|
|
|
2013-11-24 04:30:02 -05:00
|
|
|
class MiniSoC(SDRAMSoC):
|
2014-02-16 08:51:52 -05:00
|
|
|
default_platform = "mixxeo" # also supports m1
|
|
|
|
|
2013-03-25 09:42:48 -04:00
|
|
|
csr_map = {
|
2013-11-24 04:30:02 -05:00
|
|
|
"minimac": 10,
|
|
|
|
"fb": 11,
|
|
|
|
"dvisampler0": 12,
|
|
|
|
"dvisampler0_edid_mem": 13,
|
|
|
|
"dvisampler1": 14,
|
|
|
|
"dvisampler1_edid_mem": 15,
|
2013-03-25 09:42:48 -04:00
|
|
|
}
|
2013-11-24 04:30:02 -05:00
|
|
|
csr_map.update(SDRAMSoC.csr_map)
|
|
|
|
|
2013-03-25 09:42:48 -04:00
|
|
|
interrupt_map = {
|
|
|
|
"minimac": 2,
|
2013-05-28 09:56:14 -04:00
|
|
|
"dvisampler0": 3,
|
|
|
|
"dvisampler1": 4,
|
2013-03-25 09:42:48 -04:00
|
|
|
}
|
2013-11-24 04:30:02 -05:00
|
|
|
interrupt_map.update(SDRAMSoC.interrupt_map)
|
2013-03-25 09:42:48 -04:00
|
|
|
|
2013-11-24 07:37:32 -05:00
|
|
|
def __init__(self, platform, with_memtest=False):
|
2013-11-24 04:30:02 -05:00
|
|
|
SDRAMSoC.__init__(self, platform,
|
|
|
|
clk_freq=(83 + Fraction(1, 3))*1000000,
|
2013-11-24 13:50:17 -05:00
|
|
|
cpu_reset_address=0x00180000,
|
2013-11-24 04:30:02 -05:00
|
|
|
with_memtest=with_memtest)
|
2013-07-17 07:58:58 -04:00
|
|
|
|
2013-11-24 04:30:02 -05:00
|
|
|
sdram_geom = lasmicon.GeomSettings(
|
|
|
|
bank_a=2,
|
|
|
|
row_a=13,
|
|
|
|
col_a=10
|
|
|
|
)
|
|
|
|
sdram_timing = lasmicon.TimingSettings(
|
|
|
|
tRP=self.ns(15),
|
|
|
|
tRCD=self.ns(15),
|
|
|
|
tWR=self.ns(15),
|
|
|
|
tWTR=2,
|
|
|
|
tREFI=self.ns(7800, False),
|
|
|
|
tRFC=self.ns(70),
|
2013-07-17 07:58:58 -04:00
|
|
|
|
2013-11-24 04:30:02 -05:00
|
|
|
req_queue_size=8,
|
|
|
|
read_time=32,
|
|
|
|
write_time=16
|
|
|
|
)
|
|
|
|
self.submodules.ddrphy = s6ddrphy.S6DDRPHY(platform.request("ddram"), memtype="DDR",
|
|
|
|
nphases=2, cl=3, rd_bitslip=0, wr_bitslip=3, dqs_ddr_alignment="C1")
|
2013-11-24 14:16:19 -05:00
|
|
|
self.register_sdram_phy(self.ddrphy.dfi, self.ddrphy.phy_settings, sdram_geom, sdram_timing)
|
2012-02-17 17:50:10 -05:00
|
|
|
|
2013-11-24 04:30:02 -05:00
|
|
|
# Wishbone
|
2013-11-30 14:37:56 -05:00
|
|
|
self.submodules.norflash = norflash16.NorFlash16(platform.request("norflash"),
|
|
|
|
self.ns(110), self.ns(50))
|
2014-02-21 11:55:05 -05:00
|
|
|
self.flash_boot_address = 0x001a0000
|
2013-11-24 14:16:19 -05:00
|
|
|
self.register_rom(self.norflash.bus)
|
2014-02-21 11:55:05 -05:00
|
|
|
|
|
|
|
self.submodules.minimac = minimac3.MiniMAC(platform.request("eth"))
|
2013-11-24 04:30:02 -05:00
|
|
|
self.add_wb_slave(lambda a: a[26:29] == 3, self.minimac.membus)
|
2014-02-21 11:55:05 -05:00
|
|
|
self.add_cpu_memory_region("minimac_mem", 0xb0000000, 0x1800)
|
2013-02-11 12:23:06 -05:00
|
|
|
|
|
|
|
# CSR
|
2013-11-24 04:30:02 -05:00
|
|
|
self.submodules.crg = mxcrg.MXCRG(_MXClockPads(platform), self.clk_freq)
|
|
|
|
if platform.name == "mixxeo":
|
2013-09-13 17:07:46 -04:00
|
|
|
self.submodules.leds = gpio.GPIOOut(platform.request("user_led"))
|
2013-11-24 04:30:02 -05:00
|
|
|
if platform.name == "m1":
|
2013-07-04 13:19:39 -04:00
|
|
|
self.submodules.buttons = gpio.GPIOIn(Cat(platform.request("user_btn", 0), platform.request("user_btn", 2)))
|
2013-12-05 17:55:14 -05:00
|
|
|
self.submodules.leds = gpio.GPIOOut(Cat(platform.request("user_led", i) for i in range(2)))
|
2013-03-10 14:32:38 -04:00
|
|
|
|
2013-11-24 04:30:02 -05:00
|
|
|
# Clock glue
|
2013-03-10 14:32:38 -04:00
|
|
|
self.comb += [
|
2013-02-11 12:23:06 -05:00
|
|
|
self.ddrphy.clk4x_wr_strb.eq(self.crg.clk4x_wr_strb),
|
|
|
|
self.ddrphy.clk4x_rd_strb.eq(self.crg.clk4x_rd_strb)
|
|
|
|
]
|
2013-11-24 07:37:32 -05:00
|
|
|
platform.add_platform_command("""
|
|
|
|
INST "mxcrg/wr_bufpll" LOC = "BUFPLL_X0Y2";
|
|
|
|
INST "mxcrg/rd_bufpll" LOC = "BUFPLL_X0Y3";
|
|
|
|
|
|
|
|
PIN "mxcrg/bufg_x1.O" CLOCK_DEDICATED_ROUTE = FALSE;
|
|
|
|
""")
|
|
|
|
|
|
|
|
# add Verilog sources
|
|
|
|
for d in ["mxcrg", "minimac3"]:
|
|
|
|
platform.add_source_dir(os.path.join("verilog", d))
|
2013-11-24 04:30:02 -05:00
|
|
|
|
|
|
|
def _get_vga_dvi(platform):
|
|
|
|
try:
|
|
|
|
pads_vga = platform.request("vga_out")
|
|
|
|
except ConstraintError:
|
|
|
|
pads_vga = None
|
|
|
|
try:
|
|
|
|
pads_dvi = platform.request("dvi_out")
|
|
|
|
except ConstraintError:
|
|
|
|
pads_dvi = None
|
2013-11-24 07:37:32 -05:00
|
|
|
else:
|
|
|
|
platform.add_platform_command("""
|
|
|
|
PIN "dviout_pix_bufg.O" CLOCK_DEDICATED_ROUTE = FALSE;
|
|
|
|
""")
|
2013-11-24 04:30:02 -05:00
|
|
|
return pads_vga, pads_dvi
|
|
|
|
|
2013-11-24 07:37:32 -05:00
|
|
|
def _add_vga_tig(platform, fb):
|
|
|
|
platform.add_platform_command("""
|
|
|
|
NET "{vga_clk}" TNM_NET = "GRPvga_clk";
|
|
|
|
NET "sys_clk" TNM_NET = "GRPsys_clk";
|
|
|
|
TIMESPEC "TSise_sucks1" = FROM "GRPvga_clk" TO "GRPsys_clk" TIG;
|
|
|
|
TIMESPEC "TSise_sucks2" = FROM "GRPsys_clk" TO "GRPvga_clk" TIG;
|
|
|
|
""", vga_clk=fb.driver.clocking.cd_pix.clk)
|
|
|
|
|
2013-11-24 04:30:02 -05:00
|
|
|
class FramebufferSoC(MiniSoC):
|
2013-11-24 07:37:32 -05:00
|
|
|
def __init__(self, platform, with_memtest=False):
|
2013-11-24 04:30:02 -05:00
|
|
|
MiniSoC.__init__(self, platform, with_memtest)
|
|
|
|
pads_vga, pads_dvi = _get_vga_dvi(platform)
|
|
|
|
self.submodules.fb = framebuffer.Framebuffer(pads_vga, pads_dvi, self.lasmixbar.get_master())
|
2013-11-24 07:37:32 -05:00
|
|
|
_add_vga_tig(platform, self.fb)
|
2013-11-24 04:30:02 -05:00
|
|
|
|
|
|
|
class VideomixerSoC(MiniSoC):
|
2013-11-24 07:37:32 -05:00
|
|
|
def __init__(self, platform, with_memtest=False):
|
2013-11-24 04:30:02 -05:00
|
|
|
MiniSoC.__init__(self, platform, with_memtest)
|
|
|
|
pads_vga, pads_dvi = _get_vga_dvi(platform)
|
|
|
|
self.submodules.fb = framebuffer.MixFramebuffer(pads_vga, pads_dvi,
|
|
|
|
self.lasmixbar.get_master(), self.lasmixbar.get_master())
|
2013-11-24 07:37:32 -05:00
|
|
|
_add_vga_tig(platform, self.fb)
|
2014-02-13 16:07:23 -05:00
|
|
|
self.submodules.dvisampler0 = dvisampler.DVISampler(platform.request("dvi_in", 2), self.lasmixbar.get_master())
|
|
|
|
self.submodules.dvisampler1 = dvisampler.DVISampler(platform.request("dvi_in", 3), self.lasmixbar.get_master())
|
2013-11-24 04:30:02 -05:00
|
|
|
|
2014-02-16 08:51:52 -05:00
|
|
|
default_subtarget = VideomixerSoC
|