コード例 #1
0
    def __init__(self,
                 bios_flash_offset,
                 sys_clk_freq=int(12e6),
                 with_led_chaser=True,
                 **kwargs):
        platform = lattice_ice40up5k_evn.Platform()

        # Disable Integrated ROM/SRAM since too large for iCE40 and UP5K has specific SPRAM.
        kwargs["integrated_sram_size"] = 0
        kwargs["integrated_rom_size"] = 0

        # Set CPU variant / reset address
        kwargs[
            "cpu_reset_address"] = self.mem_map["spiflash"] + bios_flash_offset

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(
            self,
            platform,
            sys_clk_freq,
            ident="LiteX SoC on Lattice iCE40UP5k EVN breakout board",
            ident_version=True,
            **kwargs)

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

        # 128KB SPRAM (used as SRAM) ---------------------------------------------------------------
        self.submodules.spram = Up5kSPRAM(size=128 * kB)
        self.bus.add_slave("sram", self.spram.bus, SoCRegion(size=128 * kB))

        # SPI Flash --------------------------------------------------------------------------------
        # 4x mode is not possible on this board since WP and HOLD pins are not connected to the FPGA
        from litespi.modules import N25Q032A
        from litespi.opcodes import SpiNorFlashOpCodes as Codes
        self.add_spi_flash(mode="1x", module=N25Q032A(Codes.READ_1_1_1))

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

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

        # Add a UART-Wishbone bridge -----------------------------------------
        debug_uart = False
        if debug_uart:
            # This will add a bridge on the second serial port defined in platform
            from litex.soc.cores.uart import UARTWishboneBridge
            self.submodules.uart_bridge = UARTWishboneBridge(
                platform.request("serial"), sys_clk_freq, baudrate=115200)
            self.add_wb_master(self.uart_bridge.wishbone)
コード例 #2
0
    def __init__(self,
                 bios_flash_offset,
                 sys_clk_freq=int(12e6),
                 with_led_chaser=True,
                 **kwargs):
        platform = lattice_ice40up5k_evn.Platform()

        # Disable Integrated ROM/SRAM since too large for iCE40 and UP5K has specific SPRAM.
        kwargs["integrated_sram_size"] = 0
        kwargs["integrated_rom_size"] = 0

        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(
            self,
            platform,
            sys_clk_freq,
            ident="LiteX SoC on Lattice iCE40UP5k EVN breakout board",
            **kwargs)

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

        # 128KB SPRAM (used as SRAM) ---------------------------------------------------------------
        self.submodules.spram = Up5kSPRAM(size=128 * kB)
        self.bus.add_slave("sram", self.spram.bus, SoCRegion(size=128 * kB))

        # SPI Flash --------------------------------------------------------------------------------
        # 4x mode is not possible on this board since WP and HOLD pins are not connected to the FPGA
        from litespi.modules import N25Q032A
        from litespi.opcodes import SpiNorFlashOpCodes as Codes
        self.add_spi_flash(mode="1x", module=N25Q032A(Codes.READ_1_1_1))

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

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

        # Add a UARTBone bridge --------------------------------------------------------------------
        debug_uart = False
        if debug_uart:
            self.add_uartbone(name="serial")