from litex.boards.platforms import sim
from litex.gen.genlib.io import CRG
-from litex.soc.integration.soc_core import *
+from litex.soc.integration.soc_sdram import *
from litex.soc.integration.builder import *
from litex.soc.cores import uart
+from litex.soc.cores.sdram.settings import PhySettings, IS42S16160
+from litex.soc.cores.sdram.model import SDRAMPHYModel
-class BaseSoC(SoCCore):
+class BaseSoC(SoCSDRAM):
def __init__(self, **kwargs):
platform = sim.Platform()
- SoCCore.__init__(self, platform,
+ SoCSDRAM.__init__(self, platform,
clk_freq=int((1/(platform.default_clk_period))*1000000000),
integrated_rom_size=0x8000,
- integrated_main_ram_size=16*1024,
with_uart=False,
**kwargs)
self.submodules.crg = CRG(platform.request(platform.default_clk_name))
self.submodules.uart_phy = uart.RS232PHYModel(platform.request("serial"))
self.submodules.uart = uart.UART(self.uart_phy)
+ if not self.integrated_main_ram_size:
+ sdram_module = IS42S16160(self.clk_freq)
+ phy_settings = PhySettings(
+ memtype="SDR",
+ dfi_databits=1*16,
+ nphases=1,
+ rdphase=0,
+ wrphase=0,
+ rdcmdphase=0,
+ wrcmdphase=0,
+ cl=2,
+ read_latency=4,
+ write_latency=0
+ )
+ self.submodules.sdrphy = SDRAMPHYModel(sdram_module, phy_settings)
+ self.register_sdram(self.sdrphy, "minicon",
+ sdram_module.geom_settings, sdram_module.timing_settings)
+
+
def main():
parser = argparse.ArgumentParser(description="Generic LiteX SoC Simulation")
builder_args(parser)
- soc_core_args(parser)
+ soc_sdram_args(parser)
args = parser.parse_args()
- soc = BaseSoC(**soc_core_argdict(args))
+ soc = BaseSoC(**soc_sdram_argdict(args))
builder = Builder(soc, **builder_argdict(args))
builder.build()
from litex.build.xilinx.platform import XilinxPlatform
-from litex.build.xilinx.programmer import UrJTAG, XC3SProg, FpgaProg, VivadoProgrammer, iMPACT, Adept
+from litex.build.xilinx.programmer import XC3SProg, FpgaProg, VivadoProgrammer, iMPACT
from litex.gen import *
from litex.gen.fhdl.specials import *
-from litex.soc.mem.sdram.phy.dfi import *
-from litex.soc.mem import sdram
+from litex.soc.interconnect.dfi import *
+
+from functools import reduce
+from operator import or_
class Bank(Module):
self.read_col = Signal(max=ncols)
self.read_data = Signal(data_width)
- ###
+ # # #
+
active = Signal()
row = Signal(max=nrows)
self.write = Signal()
self.read = Signal()
- ###
+ # # #
+
self.comb += [
If(~phase.cs_n & ~phase.ras_n & phase.cas_n,
self.activate.eq(phase.we_n),
]
-class SDRAMPHYSim(Module):
+class SDRAMPHYModel(Module):
def __init__(self, module, settings):
if settings.memtype in ["SDR"]:
burst_length = settings.nphases*1 # command multiplication*SDR
self.dfi = Interface(addressbits, bankbits, self.settings.dfi_databits, self.settings.nphases)
- ###
+ # # #
+
nbanks = 2**bankbits
nrows = 2**rowbits
ncols = 2**colbits
banks_read = Signal()
banks_read_data = Signal(data_width)
self.comb += [
- banks_read.eq(optree("|", [bank.read for bank in banks])),
- banks_read_data.eq(optree("|", [bank.read_data for bank in banks]))
+ banks_read.eq(reduce(or_, [bank.read for bank in banks])),
+ banks_read_data.eq(reduce(or_, [bank.read_data for bank in banks]))
]
+
# simulate read latency
for i in range(self.settings.read_latency):
new_banks_read = Signal()
#endif /* CSR_DDRPHY_BASE */
-#define TEST_DATA_SIZE (2*1024*1024)
+#define TEST_DATA_SIZE (32*1024) // FIXME add #define
#define TEST_DATA_RANDOM 1
#define TEST_ADDR_SIZE (32*1024)