Esempio n. 1
0
    def test_hyperram_syntax(self):
        pads = Record([("clk", 1), ("cs_n", 1), ("dq", 8), ("rwds", 1)])
        hyperram = HyperRAM(pads)

        pads = Record([("clk_p", 1), ("clk_n", 1), ("cs_n", 1), ("dq", 8),
                       ("rwds", 1)])
        hyperram = HyperRAM(pads)
Esempio n. 2
0
    def __init__(self,
                 sys_clk_freq=int(100e6),
                 with_led_chaser=True,
                 **kwargs):
        platform = trenz_te0725.Platform()

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         sys_clk_freq,
                         ident="LiteX SoC on Trenz TE0725 Board",
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)

        # Use HyperRAM generic PHY as SRAM ---------------------------------------------------------
        size = int((64 * 1024 * 1024) / 8)
        hr_pads = platform.request("hyperram", 0)
        self.submodules.hyperram = HyperRAM(hr_pads)
        self.bus.add_slave("hyperram",
                           slave=self.hyperram.bus,
                           region=SoCRegion(origin=0x20000000, size=size))

        # Leds -------------------------------------------------------------------------------------
        if with_led_chaser:
            self.submodules.leds = LedChaser(
                pads=platform.request_all("user_led"),
                sys_clk_freq=sys_clk_freq)
            self.add_csr("leds")
Esempio n. 3
0
    def __init__(self, sys_clk_freq=int(75e6), hyperram="none", **kwargs):
        platform = crosslink_nx_vip.Platform()
        platform.add_platform_command("ldc_set_sysconfig {{MASTER_SPI_PORT=SERIAL}}")

        # Disable Integrated SRAM since we want to instantiate LRAM specifically for it
        kwargs["integrated_sram_size"] = 0

        # SoCCore -----------------------------------------_----------------------------------------
        SoCCore.__init__(self, platform, sys_clk_freq,
            ident          = "LiteX SoC on Crosslink-NX VIP Input Board",
            ident_version  = True,
            **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)

        if hyperram == "none":
            # 128KB LRAM (used as SRAM) ------------------------------------------------------------
            size = 128*kB
            self.submodules.spram = NXLRAM(32, size)
            self.register_mem("sram", self.mem_map["sram"], self.spram.bus, size)
        else:
            # Use HyperRAM generic PHY as SRAM -----------------------------------------------------
            size = 8*1024*kB
            hr_pads = platform.request("hyperram", int(hyperram))
            self.submodules.hyperram = HyperRAM(hr_pads)
            self.register_mem("sram", self.mem_map["sram"], self.hyperram.bus, size)

        # Leds -------------------------------------------------------------------------------------
        self.submodules.leds = LedChaser(
            pads         = Cat(*[platform.request("user_led", i) for i in range(4)]),
            sys_clk_freq = sys_clk_freq)
        self.add_csr("leds")
Esempio n. 4
0
    def test_hyperram_read(self):
        def fpga_gen(dut):
            dat = yield from dut.bus.read(0x1234)
            self.assertEqual(dat, 0xdeadbeef)

        def hyperram_gen(dut):
            clk = "___--__--__--__--__--__--__--__--__--__--__--__--__--__--__--__--_______"
            cs_n = "--________________________________________________________________------"
            dq_oe = "__------------__________________________________________________________"
            dq_o = "00a000048d00000000000000000000000000000000000000000000000000000000000000"
            dq_i = "0000000000000000000000000000000000000000000000000000000000deadbeef000000"
            rwds_oe = "________________________________________________________________________"
            for i in range(3):
                yield
            for i in range(len(clk)):
                yield dut.pads.dq.i.eq(
                    int(dq_i[2 * (i // 2):2 * (i // 2) + 2], 16))
                self.assertEqual(c2bool(clk[i]), (yield dut.pads.clk))
                self.assertEqual(c2bool(cs_n[i]), (yield dut.pads.cs_n))
                self.assertEqual(c2bool(dq_oe[i]), (yield dut.pads.dq.oe))
                self.assertEqual(int(dq_o[2 * (i // 2):2 * (i // 2) + 2], 16),
                                 (yield dut.pads.dq.o))
                self.assertEqual(c2bool(rwds_oe[i]), (yield dut.pads.rwds.oe))
                yield

        dut = HyperRAM(HyperRamPads())
        run_simulation(dut, [fpga_gen(dut), hyperram_gen(dut)])
Esempio n. 5
0
    def __init__(self, sys_clk_freq=int(100e6), **kwargs):
        platform = trenz_te0725.Platform()

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         sys_clk_freq,
                         ident="LiteX SoC on Trenz TE0725 Board",
                         ident_version=True,
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)

        # Use HyperRAM generic PHY as SRAM ---------------------------------------------------------
        size = int((64 * 1024 * 1024) / 8)
        hr_pads = platform.request("hyperram", 0)
        self.submodules.hyperram = HyperRAM(hr_pads)
        self.register_mem("hyperram", self.mem_map["hyperram"],
                          self.hyperram.bus, size)

        # Leds -------------------------------------------------------------------------------------
        self.submodules.leds = LedChaser(pads=platform.request_all("user_led"),
                                         sys_clk_freq=sys_clk_freq)
        self.add_csr("leds")
Esempio n. 6
0
    def __init__(self,
                 sys_clk_freq=int(50e6),
                 x5_clk_freq=None,
                 toolchain="trellis",
                 **kwargs):
        platform = ecp5_evn.Platform(toolchain=toolchain)

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         clk_freq=sys_clk_freq,
                         integrated_main_ram_size=0x8000,
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        crg = _CRG(platform, sys_clk_freq, x5_clk_freq)
        self.submodules.crg = crg

        # HyperRam ---------------------------------------------------------------------------------
        self.submodules.hyperram = HyperRAM(platform.request("hyperram"))
        self.add_wb_slave(self.mem_map["hyperram"], self.hyperram.bus)
        self.add_memory_region("hyperram", self.mem_map["hyperram"],
                               8 * 1024 * 1024)

        # ADC --------------------------------------------------------------------------------------
        trig_pad = platform.request("adc_trig", 0)
        self.submodules.adc = ADC3321_DMA(trig_pad)
        self.add_wb_master(self.adc.wishbone)
        self.add_csr("adc")

        # Leds -------------------------------------------------------------------------------------
        self.submodules.leds = LedChaser(
            pads=Cat(*[platform.request("user_led", i) for i in range(8)]),
            sys_clk_freq=sys_clk_freq)
        self.add_csr("leds")

        # Wishbone Debug
        # added io to platform, serial_wb
        self.submodules.bridge = UARTWishboneBridge(platform.request(
            "serial_wb", 1),
                                                    sys_clk_freq,
                                                    baudrate=115200)
        self.add_wb_master(self.bridge.wishbone)

        self.add_csr("analyzer")
        analyzer_signals = [
            trig_pad,
            #            self.adc.wishbone.stb,
            #            self.adc.wishbone.dat_w,
            #            self.adc.wishbone.ack,
            #            self.adc.wishbone.adr,
        ]

        analyzer_depth = 256  # samples
        analyzer_clock_domain = "sys"
        self.submodules.analyzer = LiteScopeAnalyzer(
            analyzer_signals,
            analyzer_depth,
            clock_domain=analyzer_clock_domain)
    def __init__(self, *, sys_clk_freq=int(50e6), iodelay_clk_freq=200e6,
            with_ethernet=False, with_etherbone=False, eth_ip="192.168.1.50", eth_dynamic_ip=False,
            with_hyperram=False, with_sdcard=False, with_jtagbone=True, with_uartbone=False,
            ident_version=True, **kwargs):
        platform = lpddr4_test_board.Platform()

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self, platform, sys_clk_freq,
            ident         = "LiteX SoC on LPDDR4 Test Board",
            ident_version = ident_version,
            **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq, iodelay_clk_freq=iodelay_clk_freq)

        # LDDR4 SDRAM ------------------------------------------------------------------------------
        if not self.integrated_main_ram_size:
            self.submodules.ddrphy = lpddr4.K7LPDDR4PHY(platform.request("lpddr4"),
                iodelay_clk_freq = iodelay_clk_freq,
                sys_clk_freq     = sys_clk_freq,
            )
            self.add_sdram("sdram",
                phy                     = self.ddrphy,
                module                  = MT53E256M16D1(sys_clk_freq, "1:8"),
                l2_cache_size           = kwargs.get("l2_size", 8192),
                l2_cache_min_data_width = 256,
            )

        # HyperRAM ---------------------------------------------------------------------------------
        if with_hyperram:
            self.submodules.hyperram = HyperRAM(platform.request("hyperram"))
            self.register_mem("hyperram", self.mem_map["hyperram"], self.hyperram.bus, 8*1024*1024)

        # SD Card ----------------------------------------------------------------------------------
        if with_sdcard:
            self.add_sdcard()

        # Ethernet / Etherbone ---------------------------------------------------------------------
        if with_ethernet or with_etherbone:
            self.submodules.ethphy = LiteEthS7PHYRGMII(
                clock_pads = self.platform.request("eth_clocks"),
                pads       = self.platform.request("eth"))
            if with_ethernet:
                self.add_ethernet(phy=self.ethphy, dynamic_ip=eth_dynamic_ip)
            if with_etherbone:
                self.add_etherbone(phy=self.ethphy, ip_address=eth_ip)

        # Jtagbone ---------------------------------------------------------------------------------
        if with_jtagbone:
            self.add_jtagbone()

        # UartBone ---------------------------------------------------------------------------------
        if with_uartbone:
            self.add_uartbone("serial", baudrate=1e6)

        # Leds -------------------------------------------------------------------------------------
        self.submodules.leds = LedChaser(
            pads         = platform.request_all("user_led"),
            sys_clk_freq = sys_clk_freq)
Esempio n. 8
0
    def __init__(self,
                 sys_clk_freq=int(48e6),
                 x5_clk_freq=None,
                 toolchain="trellis",
                 **kwargs):
        platform = evb_platform.Platform(toolchain=toolchain)

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         sys_clk_freq,
                         ident="LiteX SOC on @loxodes ECP5 Evaluation Board",
                         ident_version=True,
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        crg = _CRG(platform, sys_clk_freq)
        self.submodules.crg = crg

        # HyperRam ---------------------------------------------------------------------------------
        self.mem_map["hyperram"] = 0x20000000
        self.submodules.hyperram = HyperRAM(platform.request("hyperram"))
        self.add_wb_slave(self.mem_map["hyperram"], self.hyperram.bus)
        self.add_memory_region("hyperram", self.mem_map["hyperram"],
                               8 * 1024 * 1024)

        # SPIFlash ---------------------------------------------------------------------------------
        self.submodules.spiflash = ECP5SPIFlash(
            pads=platform.request("spiflash"),
            sys_clk_freq=sys_clk_freq,
            spi_clk_freq=5e6,
        )
        self.add_csr("spiflash")

        # Wishbone  usb debug port
        # see https://gist.github.com/enjoy-digital/82ed88b77ef0b1e3e91b0592e44eaa14
        os.system(
            "git clone https://github.com/litex-hub/valentyusb -b hw_cdc_eptri"
        )
        sys.path.append("valentyusb")
        from valentyusb.usbcore.cpu import dummyusb, epfifo
        from valentyusb.usbcore import io as usbio
        usb_debug = True
        usb_pads = platform.request("usb_aux")
        usb_iobuf = usbio.IoBuf(usb_pads.d_p, usb_pads.d_n, usb_pads.pullup)
        self.submodules.usb = dummyusb.DummyUsb(
            usb_iobuf, debug=usb_debug
        )  #epfifo.PerEndpointFifoInterface(usb_iobuf, debug=usb_debug)
        self.add_wb_master(self.usb.debug_bridge.wishbone)
        #self.register_mem("vexriscv_debug", 0xf00f0000, self.cpu.debug_bus, 0x100)
        # https://github.com/enjoy-digital/litex/issues/345
        # Leds -------------------------------------------------------------------------------------
        self.submodules.leds = LedChaser(pads=platform.request_all("user_led"),
                                         sys_clk_freq=sys_clk_freq)
        self.add_csr("leds")
Esempio n. 9
0
    def __init__(self,
                 sys_clk_freq=int(50e6),
                 with_led_chaser=True,
                 with_ethernet=False,
                 with_etherbone=False,
                 **kwargs):
        platform = c10lprefkit.Platform()

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         sys_clk_freq,
                         ident="LiteX SoC on C10 LP RefKit",
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)

        # HyperRam ---------------------------------------------------------------------------------
        self.submodules.hyperram = HyperRAM(platform.request("hyperram"))
        self.add_wb_slave(self.mem_map["hyperram"], self.hyperram.bus)
        self.add_memory_region("hyperram", self.mem_map["hyperram"],
                               8 * 1024 * 1024)

        # SDR SDRAM --------------------------------------------------------------------------------
        if not self.integrated_main_ram_size:
            self.submodules.sdrphy = GENSDRPHY(platform.request("sdram"),
                                               sys_clk_freq)
            self.add_sdram("sdram",
                           phy=self.sdrphy,
                           module=MT48LC16M16(sys_clk_freq, "1:1"),
                           l2_cache_size=kwargs.get("l2_size", 8192))

        # Ethernet / Etherbone ---------------------------------------------------------------------
        if with_ethernet or with_etherbone:
            self.submodules.ethphy = LiteEthPHYMII(
                clock_pads=self.platform.request("eth_clocks"),
                pads=self.platform.request("eth"))
            if with_ethernet:
                self.add_ethernet(phy=self.ethphy)
            if with_etherbone:
                self.add_etherbone(phy=self.ethphy)

        # Leds -------------------------------------------------------------------------------------
        if with_led_chaser:
            self.submodules.leds = LedChaser(
                pads=platform.request_all("user_led"),
                sys_clk_freq=sys_clk_freq)
Esempio n. 10
0
    def __init__(self, sys_clk_freq=int(50e6), with_ethernet=False, **kwargs):
        platform = c10lprefkit.Platform()

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         sys_clk_freq,
                         ident="LiteX SoC on C10 LP RefKit",
                         ident_version=True,
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)

        # HyperRam ---------------------------------------------------------------------------------
        self.submodules.hyperram = HyperRAM(platform.request("hyperram"))
        self.add_wb_slave(self.mem_map["hyperram"], self.hyperram.bus)
        self.add_memory_region("hyperram", self.mem_map["hyperram"],
                               8 * 1024 * 1024)

        # SDR SDRAM --------------------------------------------------------------------------------
        if not self.integrated_main_ram_size:
            self.submodules.sdrphy = GENSDRPHY(platform.request("sdram"))
            self.add_sdram("sdram",
                           phy=self.sdrphy,
                           module=MT48LC16M16(sys_clk_freq, "1:1"),
                           origin=self.mem_map["main_ram"],
                           size=kwargs.get("max_sdram_size", 0x40000000),
                           l2_cache_size=kwargs.get("l2_size", 8192),
                           l2_cache_min_data_width=kwargs.get(
                               "min_l2_data_width", 128),
                           l2_cache_reverse=True)

        # Ethernet ---------------------------------------------------------------------------------
        if with_ethernet:
            self.submodules.ethphy = LiteEthPHYMII(
                clock_pads=self.platform.request("eth_clocks"),
                pads=self.platform.request("eth"))
            self.add_csr("ethphy")
            self.add_ethernet(phy=self.ethphy)

        # Leds -------------------------------------------------------------------------------------
        self.submodules.leds = LedChaser(
            pads=Cat(*[platform.request("user_led", i) for i in range(5)]),
            sys_clk_freq=sys_clk_freq)
        self.add_csr("leds")
    def __init__(self, sys_clk_freq=int(200e6), with_spi_flash=False, with_hyperram=False, **kwargs):
        platform = efinix_titanium_ti60_f225_dev_kit.Platform()

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self, platform, sys_clk_freq,
            ident = "LiteX SoC on Efinix Titanium Ti60 F225 Dev Kit",
            **kwargs
        )

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)

        # SPI Flash --------------------------------------------------------------------------------
        if with_spi_flash:
            from litespi.modules import W25Q64JW
            from litespi.opcodes import SpiNorFlashOpCodes as Codes
            self.add_spi_flash(mode="1x", module=W25Q64JW(Codes.READ_1_1_1), with_master=True)

        # HyperRAM ---------------------------------------------------------------------------------
        if with_hyperram:
            self.submodules.hyperram = HyperRAM(platform.request("hyperram"), latency=7)
            self.bus.add_slave("main_ram", slave=self.hyperram.bus, region=SoCRegion(origin=0x40000000, size=32*1024*1024))
Esempio n. 12
0
    def __init__(self,
                 sys_clk_freq=int(48e6),
                 x5_clk_freq=None,
                 toolchain="trellis",
                 **kwargs):
        platform = evb_platform.Platform(toolchain=toolchain)

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         sys_clk_freq,
                         ident="LiteX SOC on @loxodes ECP5 Evaluation Board",
                         ident_version=True,
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        crg = _CRG(platform, sys_clk_freq)
        self.submodules.crg = crg

        # HyperRam ---------------------------------------------------------------------------------
        self.mem_map["hyperram"] = 0x20000000
        self.submodules.hyperram = HyperRAM(platform.request("hyperram"))
        self.add_wb_slave(self.mem_map["hyperram"], self.hyperram.bus)
        self.add_memory_region("hyperram", self.mem_map["hyperram"],
                               8 * 1024 * 1024)

        # SPIFlash ---------------------------------------------------------------------------------
        self.submodules.spiflash = ECP5SPIFlash(
            pads=platform.request("spiflash"),
            sys_clk_freq=sys_clk_freq,
            spi_clk_freq=5e6,
        )
        self.add_csr("spiflash")

        # Leds -------------------------------------------------------------------------------------
        self.submodules.leds = LedChaser(pads=platform.request_all("user_led"),
                                         sys_clk_freq=sys_clk_freq)
        self.add_csr("leds")
Esempio n. 13
0
    def __init__(self,
                 sys_clk_freq=int(50e6),
                 x5_clk_freq=None,
                 toolchain="trellis",
                 **kwargs):
        from litex.build.generic_platform import Subsignal, Pins, IOStandard
        platform = ecp5_evn.Platform(toolchain=toolchain)
        self._add_extentions(platform)

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         clk_freq=sys_clk_freq,
                         integrated_main_ram_size=0x8000,
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        crg = _CRG(platform, sys_clk_freq, x5_clk_freq)
        self.submodules.crg = crg

        # HyperRam ---------------------------------------------------------------------------------
        self.submodules.hyperram = HyperRAM(platform.request("hyperram"))
        #self.submodules.hyperram = HyperRAMX2(platform.request("hyperram"))

        self.add_wb_slave(self.mem_map["hyperram"], self.hyperram.bus)
        self.add_memory_region("hyperram", self.mem_map["hyperram"],
                               8 * 1024 * 1024)

        # ADC RAM
        self.add_ram("adc_sram", self.mem_map["adc_sram"], 8 * 4 * 4096)

        # ADC --------------------------------------------------------------------------------------
        adc_ctrl = platform.request("adc_ctrl", 0)
        adc_data = platform.request("adc_data", 0)

        self.add_csr("adc")
        self.submodules.adc = ADC3321_DMA(adc_ctrl, adc_data)
        self.add_wb_master(self.adc.wishbone)

        # Leds -------------------------------------------------------------------------------------
        self.submodules.leds = LedChaser(
            pads=Cat(*[platform.request("user_led", i) for i in range(8)]),
            sys_clk_freq=sys_clk_freq)
        self.add_csr("leds")

        # ADC SPI bus ------------------------------------------------------------------------------
        # max SPI frequency is 20 MHz
        self.add_csr("adc_spi")
        self.submodules.adc_spi = SPIMaster(platform.request("adc_spi", 1),
                                            24,
                                            sys_clk_freq,
                                            int(sys_clk_freq / 80),
                                            with_csr=True)

        # Wishbone Debug
        # added io to platform, serial_wb
        self.submodules.bridge = UARTWishboneBridge(platform.request(
            "serial_wb", 1),
                                                    sys_clk_freq,
                                                    baudrate=3000000)
        self.add_wb_master(self.bridge.wishbone)
        self.add_csr("analyzer")
        analyzer_signals = [
            #           self.adc.adc_frontend.adc_buffer.adc_dout0,
            #           self.adc.adc_frontend.adc_buffer.adc_dout1,
            #           self.adc.adc_frontend.adc_buffer.i_fclk,
            self.adc.adc_frontend_a.i_we,
            #            self.adc.adc_frontend.i_re,
            #            self.adc.adc_frontend.o_readable,
            #           self.adc.adc_frontend.adc_buffer.o_dout,
            #           self.adc.adc_frontend.adc_buffer.pulser.output,
            #           self.adc.adc_frontend.adc_buffer.fifo.din,
            #           self.adc.adc_frontend.o_dout,
        ]

        #t = Signal()
        #self.comb += [t.eq(clk_outputs.hr_p)]

        analyzer_depth = 512  # samples
        analyzer_clock_domain = "sys"
        self.submodules.analyzer = LiteScopeAnalyzer(
            analyzer_signals,
            analyzer_depth,
            clock_domain=analyzer_clock_domain)

        # put pulser on pin..
        debug_pins = platform.request("debug_pins")
        self.comb += debug_pins.dbg1.eq(
            self.adc.adc_frontend_a.adc_buffer.pulser.output)
Esempio n. 14
0
    def __init__(self,
                 *,
                 sys_clk_freq=int(100e6),
                 iodelay_clk_freq=200e6,
                 with_ethernet=False,
                 with_etherbone=False,
                 eth_ip="192.168.1.50",
                 eth_dynamic_ip=False,
                 with_hyperram=False,
                 with_sdcard=False,
                 with_jtagbone=True,
                 with_uartbone=False,
                 with_led_chaser=True,
                 ident_version=True,
                 **kwargs):
        platform = datacenter_ddr4_test_board.Platform()

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         sys_clk_freq,
                         ident="LiteX SoC on data center test board",
                         ident_version=ident_version,
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform,
                                   sys_clk_freq,
                                   iodelay_clk_freq=iodelay_clk_freq)

        # DDR4 SDRAM RDIMM -------------------------------------------------------------------------
        if not self.integrated_main_ram_size:
            self.submodules.ddrphy = K7DDRPHY(
                platform.request("ddr4"),
                memtype="DDR4",
                iodelay_clk_freq=iodelay_clk_freq,
                sys_clk_freq=sys_clk_freq,
                is_rdimm=True,
            )
            self.add_sdram(
                "sdram",
                phy=self.ddrphy,
                module=MTA18ASF2G72PZ(sys_clk_freq, "1:4"),
                l2_cache_size=kwargs.get("l2_size", 8192),
                l2_cache_min_data_width=256,
                size=0x40000000,
            )

        # HyperRAM ---------------------------------------------------------------------------------
        if with_hyperram:
            self.submodules.hyperram = HyperRAM(platform.request("hyperram"))
            self.bus.add_slave("hyperram",
                               slave=self.hyperram.bus,
                               region=SoCRegion(origin=0x20000000,
                                                size=8 * 1024 * 1024))

        # SD Card ----------------------------------------------------------------------------------
        if with_sdcard:
            self.add_sdcard()

        # Ethernet / Etherbone ---------------------------------------------------------------------
        if with_ethernet or with_etherbone:
            # Traces between PHY and FPGA introduce ignorable delays of ~0.165ns +/- 0.015ns.
            # PHY chip does not introduce delays on TX (FPGA->PHY), however it includes 1.2ns
            # delay for RX CLK so we only need 0.8ns to match the desired 2ns.
            self.submodules.ethphy = LiteEthS7PHYRGMII(
                clock_pads=self.platform.request("eth_clocks"),
                pads=self.platform.request("eth"),
                rx_delay=0.8e-9,
            )
            if with_ethernet:
                self.add_ethernet(phy=self.ethphy, dynamic_ip=eth_dynamic_ip)
            if with_etherbone:
                self.add_etherbone(phy=self.ethphy, ip_address=eth_ip)

        # UartBone ---------------------------------------------------------------------------------
        if with_uartbone:
            self.add_uartbone("serial", baudrate=1e6)

        # Leds -------------------------------------------------------------------------------------
        if with_led_chaser:
            self.submodules.leds = LedChaser(
                pads=platform.request_all("user_led"),
                sys_clk_freq=sys_clk_freq)
Esempio n. 15
0
    def __init__(self,
                 sys_clk_freq=int(27e6),
                 with_hyperram=False,
                 with_led_chaser=True,
                 with_video_terminal=True,
                 **kwargs):
        platform = tang_nano_4k.Platform()

        # Put BIOS in SPIFlash to save BlockRAMs.
        kwargs["integrated_rom_size"] = 0
        kwargs["cpu_reset_address"] = self.mem_map["spiflash"] + 0

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         sys_clk_freq,
                         ident="LiteX SoC on Tang Nano 4K",
                         ident_version=True,
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform,
                                   sys_clk_freq,
                                   with_video_pll=with_video_terminal)

        # SPI Flash --------------------------------------------------------------------------------
        from litespi.modules import W25Q32
        from litespi.opcodes import SpiNorFlashOpCodes as Codes
        self.add_spi_flash(mode="1x",
                           module=W25Q32(Codes.READ_1_1_1),
                           with_master=False)

        # Add ROM linker region --------------------------------------------------------------------
        self.bus.add_region(
            "rom",
            SoCRegion(origin=self.mem_map["spiflash"] + 0,
                      size=64 * kB,
                      linker=True))

        # HyperRAM ---------------------------------------------------------------------------------
        if with_hyperram:

            class HyperRAMPads:
                def __init__(self):
                    self.clk = Signal()
                    self.rst_n = platform.request("O_hpram_reset_n")
                    self.dq = platform.request("IO_hpram_dq")
                    self.cs_n = platform.request("O_hpram_cs_n")
                    self.rwds = platform.request("IO_hpram_rwds")

            hyperram_pads = HyperRAMPads()
            self.comb += platform.request("O_hpram_ck").eq(hyperram_pads.clk)
            self.comb += platform.request("O_hpram_ck_n").eq(
                ~hyperram_pads.clk)
            self.submodules.hyperram = HyperRAM(hyperram_pads)
            self.bus.add_slave("main_ram",
                               slave=self.hyperram.bus,
                               region=SoCRegion(origin=0x40000000,
                                                size=8 * 1024 * 1024))

        # Video ------------------------------------------------------------------------------------
        if with_video_terminal:
            self.submodules.videophy = VideoHDMIPHY(platform.request("hdmi"),
                                                    clock_domain="hdmi")
            self.add_video_colorbars(phy=self.videophy,
                                     timings="640x480@75Hz",
                                     clock_domain="hdmi")
            #self.add_video_terminal(phy=self.videophy, timings="640x480@75Hz", clock_domain="hdmi") # FIXME: Free up BRAMs.

        # Leds -------------------------------------------------------------------------------------
        if with_led_chaser:
            self.submodules.leds = LedChaser(
                pads=platform.request_all("user_led"),
                sys_clk_freq=sys_clk_freq)
Esempio n. 16
0
    def __init__(self,
                 sys_clk_freq=int(27e6),
                 with_hyperram=False,
                 with_led_chaser=True,
                 with_video_terminal=True,
                 **kwargs):
        platform = tang_nano_4k.Platform()

        if "cpu_type" in kwargs and kwargs["cpu_type"] == "gowin_emcu":
            kwargs["with_uart"] = False  # CPU has own UART
            kwargs[
                "integrated_sram_size"] = 0  # SRAM is directly attached to CPU
            kwargs[
                "integrated_rom_size"] = 0  # boot flash directly attached to CPU
        else:
            # Disable Integrated ROM
            kwargs["integrated_rom_size"] = 0

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         sys_clk_freq,
                         ident="LiteX SoC on Tang Nano 4K",
                         **kwargs)

        if self.cpu_type == 'vexriscv':
            assert self.cpu_variant == 'minimal', 'use --cpu-variant=minimal to fit into number of BSRAMs'

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform,
                                   sys_clk_freq,
                                   with_video_pll=with_video_terminal)

        # SPI Flash --------------------------------------------------------------------------------
        from litespi.modules import W25Q32
        from litespi.opcodes import SpiNorFlashOpCodes as Codes
        self.add_spi_flash(mode="1x",
                           module=W25Q32(Codes.READ_1_1_1),
                           with_master=False)

        if self.cpu_type == "gowin_emcu":
            self.cpu.connect_uart(platform.request("serial"))
        else:
            # Add ROM linker region --------------------------------------------------------------------
            self.bus.add_region(
                "rom",
                SoCRegion(origin=self.bus.regions["spiflash"].origin,
                          size=32 * kB,
                          linker=True))
            self.cpu.set_reset_address(self.bus.regions["rom"].origin)

        # HyperRAM ---------------------------------------------------------------------------------
        if with_hyperram:

            class HyperRAMPads:
                def __init__(self):
                    self.clk = Signal()
                    self.rst_n = platform.request("O_hpram_reset_n")
                    self.dq = platform.request("IO_hpram_dq")
                    self.cs_n = platform.request("O_hpram_cs_n")
                    self.rwds = platform.request("IO_hpram_rwds")

            hyperram_pads = HyperRAMPads()
            self.comb += platform.request("O_hpram_ck").eq(hyperram_pads.clk)
            self.comb += platform.request("O_hpram_ck_n").eq(
                ~hyperram_pads.clk)
            self.submodules.hyperram = HyperRAM(hyperram_pads)
            self.bus.add_slave("main_ram",
                               slave=self.hyperram.bus,
                               region=SoCRegion(origin=0x40000000,
                                                size=8 * 1024 * 1024))

        # Video ------------------------------------------------------------------------------------
        if with_video_terminal:
            self.submodules.videophy = VideoHDMIPHY(platform.request("hdmi"),
                                                    clock_domain="hdmi")
            self.add_video_colorbars(phy=self.videophy,
                                     timings="640x480@75Hz",
                                     clock_domain="hdmi")
            #self.add_video_terminal(phy=self.videophy, timings="640x480@75Hz", clock_domain="hdmi") # FIXME: Free up BRAMs.

        # Leds -------------------------------------------------------------------------------------
        if with_led_chaser:
            self.submodules.leds = LedChaser(
                pads=platform.request_all("user_led"),
                sys_clk_freq=sys_clk_freq)
Esempio n. 17
0
    def __init__(self,
                 sys_clk_freq=int(27e6),
                 bios_flash_offset=0x0,
                 with_led_chaser=True,
                 **kwargs):
        platform = tang_nano_9k.Platform()

        # Disable Integrated ROM
        kwargs["integrated_rom_size"] = 0

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self,
                         platform,
                         sys_clk_freq,
                         ident="LiteX SoC on Tang Nano 9K",
                         **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)

        # SPI Flash --------------------------------------------------------------------------------
        from litespi.modules import W25Q32
        from litespi.opcodes import SpiNorFlashOpCodes as Codes
        self.add_spi_flash(mode="1x",
                           module=W25Q32(Codes.READ_1_1_1),
                           with_master=False)

        # Add ROM linker region --------------------------------------------------------------------
        self.bus.add_region(
            "rom",
            SoCRegion(origin=self.bus.regions["spiflash"].origin +
                      bios_flash_offset,
                      size=64 * kB,
                      linker=True))
        self.cpu.set_reset_address(self.bus.regions["rom"].origin)

        # HyperRAM ---------------------------------------------------------------------------------
        if not self.integrated_main_ram_size:
            # TODO: Use second 32Mbit PSRAM chip.
            dq = platform.request("IO_psram_dq")
            rwds = platform.request("IO_psram_rwds")
            reset_n = platform.request("O_psram_reset_n")
            cs_n = platform.request("O_psram_cs_n")
            ck = platform.request("O_psram_ck")
            ck_n = platform.request("O_psram_ck_n")

            class HyperRAMPads:
                def __init__(self, n):
                    self.clk = Signal()
                    self.rst_n = reset_n[n]
                    self.dq = dq[8 * n:8 * (n + 1)]
                    self.cs_n = cs_n[n]
                    self.rwds = rwds[n]

            hyperram_pads = HyperRAMPads(0)
            self.comb += ck[0].eq(hyperram_pads.clk)
            self.comb += ck_n[0].eq(~hyperram_pads.clk)
            self.submodules.hyperram = HyperRAM(hyperram_pads)
            self.bus.add_slave("main_ram",
                               slave=self.hyperram.bus,
                               region=SoCRegion(
                                   origin=self.mem_map["main_ram"],
                                   size=4 * mB))

        # Leds -------------------------------------------------------------------------------------
        if with_led_chaser:
            self.submodules.leds = LedChaser(
                pads=platform.request_all("user_led"),
                sys_clk_freq=sys_clk_freq)