from nmigen_boards.test.blinky import Blinky
from crg import ECPIX5CRG
+from icarusversa import IcarusVersaPlatform
import sys
import os
# DRAM Module
if ddr_pins is not None or fpga == 'sim':
- ddrmodule = MT41K256M16(clk_freq, "1:2") # match DDR3 ASIC P/N
+ ddrmodule = dram_cls(clk_freq, "1:2") # match DDR3 ASIC P/N
+
+ drs = lambda x: x
+ #drs = DomainRenamer("dramsync")
- drs = DomainRenamer("dramsync")
if fpga == 'sim':
self.ddrphy = FakePHY(module=ddrmodule,
settings=sim_ddr3_settings(clk_freq),
- verbosity=SDRAM_VERBOSE_DBG)
+ verbosity=SDRAM_VERBOSE_DBG,
+ clk_freq=clk_freq)
else:
self.ddrphy = drs(ECP5DDRPHY(ddr_pins, sys_clk_freq=clk_freq))
- self._decoder.add(self.ddrphy.bus, addr=ddrphy_addr)
+ self._decoder.add(self.ddrphy.bus, addr=ddrphy_addr)
dramcore = gramCore(phy=self.ddrphy,
geom_settings=ddrmodule.geom_settings,
comb += uartbus.dat_w.eq(self.cvtuartbus.dat_w) # drops 8..31
comb += self.cvtuartbus.dat_r.eq(uartbus.dat_r) # drops 8..31
comb += self.cvtuartbus.ack.eq(uartbus.ack)
- m.submodules.arbiter = self._arbiter
- m.submodules.decoder = self._decoder
- if hasattr(self, "ddrphy"):
- m.submodules.ddrphy = self.ddrphy
- m.submodules.dramcore = self.dramcore
- m.submodules.drambone = self.drambone
if hasattr(self, "cpu"):
m.submodules.intc = self.intc
m.submodules.extcore = self.cpu
comb += ibus.stall.eq(ibus.stb & ~ibus.ack)
comb += dbus.stall.eq(dbus.stb & ~dbus.ack)
+ m.submodules.arbiter = self._arbiter
+ m.submodules.decoder = self._decoder
+ if hasattr(self, "ddrphy"):
+ m.submodules.ddrphy = self.ddrphy
+ m.submodules.dramcore = self.dramcore
+ m.submodules.drambone = self.drambone
# add blinky lights so we know FPGA is alive
if platform is not None:
m.submodules.blinky = Blinky()
for phase in self.dramcore.dfii._inti.phases:
print ("dfi master", phase)
ports += list(phase.fields.values())
+ ports += [ClockSignal(), ClockSignal("dramsync"), ResetSignal()]
return ports
if __name__ == "__main__":
platform_kls = {'versa_ecp5': VersaECP5Platform,
'ulx3s': ULX3S_85F_Platform,
'arty_a7': ArtyA7_100Platform,
+ 'isim': IcarusVersaPlatform,
'sim': None,
}[fpga]
toolchain = {'arty_a7': "yosys_nextpnr",
'versa_ecp5': 'Trellis',
+ 'isim': 'Trellis',
'ulx3s': 'Trellis',
'sim': None,
}.get(fpga, None)
dram_cls = {'arty_a7': None,
'versa_ecp5': MT41K64M16,
+ #'versa_ecp5': MT41K256M16,
'ulx3s': None,
- 'sim': None,
+ 'sim': MT41K256M16,
+ 'isim': MT41K64M16,
}.get(fpga, None)
if platform_kls is not None:
platform = platform_kls(toolchain=toolchain)
platform = None
# set clock frequency
- clk_freq = 50e6
- #if fpga == 'sim':
- #clk_freq = 100e6
+ clk_freq = 70e6
+ if fpga == 'sim':
+ clk_freq = 100e6
# select a firmware file
firmware = None
# get DDR resource pins
ddr_pins = None
- if platform is not None and fpga in ['versa_ecp5', 'arty_a7']:
+ if platform is not None and fpga in ['versa_ecp5', 'arty_a7', 'isim']:
ddr_pins = platform.request("ddr3", 0,
dir={"dq":"-", "dqs":"-"},
- xdr={"clk":4, "a":4, "ba":4, "clk_en":4,
+ xdr={"rst": 4, "clk":4, "a":4,
+ "ba":4, "clk_en":4,
"odt":4, "ras":4, "cas":4, "we":4,
"cs": 4})
if platform is not None:
# build and upload it
- platform.build(soc, do_program=True)
+ if fpga == 'isim':
+ platform.build(soc, do_program=False,
+ do_build=True, build_dir="build_simsoc")
+ else:
+ platform.build(soc, do_program=True)
else:
# for now, generate verilog
vl = verilog.convert(soc, ports=soc.ports())