コード例 #1
0
ファイル: base.py プロジェクト: skiphansen/litex-buildenv
    def __init__(self, platform, **kwargs):
        dict_set_max(kwargs, 'integrated_rom_size', 0x8000)
        dict_set_max(kwargs, 'integrated_sram_size', 0x8000)

        sys_clk_freq = 75 * 1000000
        # SoCSDRAM ---------------------------------------------------------------------------------
        SoCSDRAM.__init__(self, platform, clk_freq=sys_clk_freq, **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)
        self.platform.add_period_constraint(self.crg.cd_sys.clk,
                                            1e9 / sys_clk_freq)

        # DDR2 SDRAM -------------------------------------------------------------------------------
        if True:
            sdram_module = P3R1GE4JGF(sys_clk_freq, "1:2")
            self.submodules.ddrphy = s6ddrphy.S6HalfRateDDRPHY(
                platform.request("ddram"),
                memtype=sdram_module.memtype,
                rd_bitslip=0,
                wr_bitslip=4,
                dqs_ddr_alignment="C0")
            self.add_csr("ddrphy")
            controller_settings = ControllerSettings(with_bandwidth=True)
            self.register_sdram(self.ddrphy,
                                geom_settings=sdram_module.geom_settings,
                                timing_settings=sdram_module.timing_settings,
                                controller_settings=controller_settings)
            self.comb += [
                self.ddrphy.clk4x_wr_strb.eq(self.crg.clk4x_wr_strb),
                self.ddrphy.clk4x_rd_strb.eq(self.crg.clk4x_rd_strb),
            ]

        # Basic peripherals ------------------------------------------------------------------------
        # info module
        self.submodules.info = info.Info(platform, self.__class__.__name__)
        self.add_csr("info")
        # control and status module
        #self.submodules.cas = cas.ControlAndStatus(platform, sys_clk_freq)
        self.add_csr("cas")

        # Add debug interface if the CPU has one ---------------------------------------------------
        if hasattr(self.cpu, "debug_bus"):
            self.register_mem(name="vexriscv_debug",
                              address=0xf00f0000,
                              interface=self.cpu.debug_bus,
                              size=0x100)

        # Memory mapped SPI Flash ------------------------------------------------------------------
        self.submodules.spiflash = spi_flash.SpiFlash(
            platform.request("spiflash4x"),
            dummy=platform.spiflash_read_dummy_bits,
            div=platform.spiflash_clock_div,
            endianness=self.cpu.endianness)
        self.add_csr("spiflash")
        self.add_constant("SPIFLASH_PAGE_SIZE", platform.spiflash_page_size)
        self.add_constant("SPIFLASH_SECTOR_SIZE",
                          platform.spiflash_sector_size)
        self.add_constant("SPIFLASH_TOTAL_SIZE", platform.spiflash_total_size)
        self.add_wb_slave(self.mem_map["spiflash"], self.spiflash.bus,
                          platform.spiflash_total_size)
        self.add_memory_region("spiflash", self.mem_map["spiflash"],
                               platform.spiflash_total_size)

        bios_size = 0x8000
        self.flash_boot_address = self.mem_map[
            "spiflash"] + platform.gateware_size + bios_size
        define_flash_constants(self)
コード例 #2
0
ファイル: base.py プロジェクト: skiphansen/litex-buildenv
    def __init__(self, platform, **kwargs):
        dict_set_max(kwargs, 'integrated_sram_size', 0x4000)

        # disable ROM, it'll be added later
        kwargs['integrated_rom_size'] = 0x0
        kwargs['cpu_reset_address'] = self.mem_map[
            "spiflash"] + platform.gateware_size
        if os.environ.get('JIMMO', '0') == '0':
            kwargs['uart_baudrate'] = 19200
        else:
            kwargs['uart_baudrate'] = 115200

        sys_clk_freq = (83 + Fraction(1, 3)) * 1000 * 1000
        # SoCSDRAM ---------------------------------------------------------------------------------
        SoCSDRAM.__init__(self, platform, clk_freq=sys_clk_freq, **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)
        self.platform.add_period_constraint(self.crg.cd_sys.clk,
                                            1e9 / sys_clk_freq)

        # DDR2 SDRAM -------------------------------------------------------------------------------
        if True:
            sdram_module = MT46H32M16(self.clk_freq, "1:2")
            self.submodules.ddrphy = s6ddrphy.S6HalfRateDDRPHY(
                platform.request("ddram"),
                memtype=sdram_module.memtype,
                rd_bitslip=1,
                wr_bitslip=3,
                dqs_ddr_alignment="C1")
            self.add_csr("ddrphy")
            controller_settings = ControllerSettings(with_bandwidth=True)
            self.register_sdram(self.ddrphy,
                                geom_settings=sdram_module.geom_settings,
                                timing_settings=sdram_module.timing_settings,
                                controller_settings=controller_settings)
            self.comb += [
                self.ddrphy.clk4x_wr_strb.eq(self.crg.clk4x_wr_strb),
                self.ddrphy.clk4x_rd_strb.eq(self.crg.clk4x_rd_strb),
            ]

        # Basic peripherals ------------------------------------------------------------------------
        self.submodules.info = info.Info(platform, self.__class__.__name__)
        self.add_csr("info")
        self.submodules.cas = cas.ControlAndStatus(platform, sys_clk_freq)
        self.add_csr("cas")

        # Add debug interface if the CPU has one ---------------------------------------------------
        if hasattr(self.cpu, "debug_bus"):
            self.register_mem(name="vexriscv_debug",
                              address=0xf00f0000,
                              interface=self.cpu.debug_bus,
                              size=0x100)

        # Memory mapped SPI Flash ------------------------------------------------------------------
        self.submodules.spiflash = spi_flash.SpiFlashSingle(
            platform.request("spiflash"),
            dummy=platform.spiflash_read_dummy_bits,
            div=platform.spiflash_clock_div,
            endianness=self.cpu.endianness)
        self.add_csr("spiflash")
        self.add_constant("SPIFLASH_PAGE_SIZE", platform.spiflash_page_size)
        self.add_constant("SPIFLASH_SECTOR_SIZE",
                          platform.spiflash_sector_size)
        self.add_constant("SPIFLASH_TOTAL_SIZE", platform.spiflash_total_size)
        self.add_wb_slave(self.mem_map["spiflash"], self.spiflash.bus,
                          platform.spiflash_total_size)
        self.add_memory_region("spiflash", self.mem_map["spiflash"],
                               platform.spiflash_total_size)

        bios_size = 0x8000
        self.add_constant("ROM_DISABLE", 1)
        self.add_memory_region("rom",
                               kwargs['cpu_reset_address'],
                               bios_size,
                               type="cached+linker")
        self.flash_boot_address = self.mem_map[
            "spiflash"] + platform.gateware_size + bios_size
        define_flash_constants(self)
コード例 #3
0
    def __init__(self, platform, spiflash="spiflash_1x", **kwargs):
        dict_set_max(kwargs, 'integrated_rom_size', 0x10000)
        dict_set_max(kwargs, 'integrated_sram_size', 0x10000)

        sys_clk_freq = int(100e6)
        # SoCSDRAM ---------------------------------------------------------------------------------
        SoCSDRAM.__init__(self, platform, clk_freq=sys_clk_freq, **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)
        self.platform.add_period_constraint(self.crg.cd_sys.clk, 1e9/sys_clk_freq)

        # DDR3 SDRAM -------------------------------------------------------------------------------
        if True:
            sdram_module = MT41K128M16(sys_clk_freq, "1:4")
            self.submodules.ddrphy = s7ddrphy.A7DDRPHY(
                platform.request("ddram"),
                memtype      = sdram_module.memtype,
                nphases      = 4,
                sys_clk_freq = sys_clk_freq)
            self.add_csr("ddrphy")
            self.register_sdram(
                self.ddrphy,
                geom_settings   = sdram_module.geom_settings,
                timing_settings = sdram_module.timing_settings,
                controller_settings=ControllerSettings(
                    with_bandwidth=True,
                    cmd_buffer_depth=8,
                    with_refresh=True))

        # Basic peripherals ------------------------------------------------------------------------
        self.submodules.info = info.Info(platform, self.__class__.__name__)
        self.add_csr("info")
        self.submodules.cas = cas.ControlAndStatus(platform, sys_clk_freq)
        self.add_csr("cas")

        # Add debug interface if the CPU has one ---------------------------------------------------
        if hasattr(self.cpu, "debug_bus"):
            self.register_mem(
                name="vexriscv_debug",
                address=0xf00f0000,
                interface=self.cpu.debug_bus,
                size=0x100)

        # Memory mapped SPI Flash ------------------------------------------------------------------
        spiflash_pads = platform.request(spiflash)
        spiflash_pads.clk = Signal()
        self.specials += Instance(
            "STARTUPE2",
            i_CLK=0, i_GSR=0, i_GTS=0, i_KEYCLEARB=0, i_PACK=0,
            i_USRCCLKO=spiflash_pads.clk, i_USRCCLKTS=0, i_USRDONEO=1, i_USRDONETS=1)
        spiflash_dummy = {
            "spiflash_1x": 9,
            "spiflash_4x": 11,
        }
        self.submodules.spiflash = spi_flash.SpiFlash(

            spiflash_pads,
            dummy=spiflash_dummy[spiflash],
            div=2,
            endianness=self.cpu.endianness)
        self.add_csr("spiflash")
        self.add_constant("SPIFLASH_PAGE_SIZE", platform.spiflash_page_size)
        self.add_constant("SPIFLASH_SECTOR_SIZE", platform.spiflash_sector_size)
        self.add_constant("SPIFLASH_TOTAL_SIZE", platform.spiflash_total_size)
        self.add_wb_slave(
            self.mem_map["spiflash"],
            self.spiflash.bus,
            platform.spiflash_total_size)
        self.add_memory_region(
            "spiflash",
            self.mem_map["spiflash"],
            platform.spiflash_total_size)

        bios_size = 0x8000
        self.flash_boot_address = self.mem_map["spiflash"]+platform.gateware_size+bios_size
        self.add_constant("FLASH_BOOT_ADDRESS", self.flash_boot_address)
コード例 #4
0
ファイル: base.py プロジェクト: nickoe/litex-buildenv
    def __init__(self, platform, **kwargs):
        dict_set_max(kwargs, 'integrated_sram_size', 0x4000)

        # disable ROM, it'll be added later
        kwargs['integrated_rom_size'] = 0x0

        kwargs['cpu_reset_address']=self.mem_map["spiflash"]+platform.gateware_size

        sys_clk_freq = 80*1000000
        # SoCSDRAM ---------------------------------------------------------------------------------
        SoCSDRAM.__init__(self, platform, sys_clk_freq, **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)
        self.platform.add_period_constraint(self.crg.cd_sys.clk, 1e9/sys_clk_freq)

        # DDR2 SDRAM -------------------------------------------------------------------------------
        if True:
            sdram_module = AS4C16M16(sys_clk_freq, "1:1")
            self.submodules.ddrphy = gensdrphy.GENSDRPHY(
                platform.request("sdram"))
            self.add_csr("ddrphy")
            self.register_sdram(
                self.ddrphy,
                geom_settings   = sdram_module.geom_settings,
                timing_settings = sdram_module.timing_settings)

        # Basic peripherals ------------------------------------------------------------------------
        self.submodules.info = info.Info(platform, self.__class__.__name__)
        self.add_csr("info")
        self.submodules.cas = cas.ControlAndStatus(platform, sys_clk_freq)
        self.add_csr("cas")

        # Add debug interface if the CPU has one ---------------------------------------------------
        if hasattr(self.cpu, "debug_bus"):
            self.register_mem(
                name="vexriscv_debug",
                address=0xf00f0000,
                interface=self.cpu.debug_bus,
                size=0x100)

        # Memory mapped SPI Flash ------------------------------------------------------------------
        self.submodules.spiflash = spi_flash.SpiFlash(
            platform.request("spiflash2x"),
            dummy=platform.spiflash_read_dummy_bits,
            div=platform.spiflash_clock_div,
            endianness=self.cpu.endianness)
        self.add_csr("spiflash")
        self.add_constant("SPIFLASH_PAGE_SIZE", platform.spiflash_page_size)
        self.add_constant("SPIFLASH_SECTOR_SIZE", platform.spiflash_sector_size)
        self.add_constant("SPIFLASH_TOTAL_SIZE", platform.spiflash_total_size)
        self.add_wb_slave(
            self.mem_map["spiflash"],
            self.spiflash.bus,
            platform.spiflash_total_size)
        self.add_memory_region(
            "spiflash",
            self.mem_map["spiflash"],
            platform.spiflash_total_size)

        if kwargs.get('cpu_type', None) == "mor1kx":
            bios_size = 0x10000
        else:
            bios_size = 0x8000

        self.add_constant("ROM_DISABLE", 1)
        self.add_memory_region(
            "rom", kwargs['cpu_reset_address'], bios_size,
            type="cached+linker")
        self.flash_boot_address = self.mem_map["spiflash"]+platform.gateware_size+bios_size
        define_flash_constants(self)
コード例 #5
0
ファイル: base.py プロジェクト: skiphansen/litex-buildenv
    def __init__(self, platform, spiflash="spiflash_1x", **kwargs):
        dict_set_max(kwargs, 'integrated_rom_size', 0x8000)
        dict_set_max(kwargs, 'integrated_sram_size', 0x8000)

        sys_clk_freq = int(100e6)

        # disable uart
        kwargs['with_uart'] = False

        # SoCSDRAM ---------------------------------------------------------------------------------
        SoCSDRAM.__init__(self, platform, clk_freq=sys_clk_freq, **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)
        self.crg.cd_sys.clk.attr.add("keep")
        self.platform.add_period_constraint(self.crg.cd_sys.clk, 1e9/sys_clk_freq)

        # DDR3 SDRAM -------------------------------------------------------------------------------
        if True:
            sdram_module = MT41K256M16(sys_clk_freq, "1:4")
            self.submodules.ddrphy = s7ddrphy.A7DDRPHY(
                platform.request("ddram"),
                memtype      = sdram_module.memtype,
                nphases      = 4,
                sys_clk_freq = sys_clk_freq)
            self.add_csr("ddrphy")
            self.add_constant("READ_LEVELING_BITSLIP", 3)
            self.add_constant("READ_LEVELING_DELAY", 14)
            self.register_sdram(
                self.ddrphy,
                geom_settings   = sdram_module.geom_settings,
                timing_settings = sdram_module.timing_settings,
                controller_settings=ControllerSettings(
                    with_bandwidth=True,
                    cmd_buffer_depth=8,
                    with_refresh=True))

        # Extended UART ----------------------------------------------------------------------------
        uart_interfaces = [RS232PHYInterface() for i in range(2)]
        self.submodules.uart = UART(uart_interfaces[0])
        self.submodules.bridge = WishboneStreamingBridge(uart_interfaces[1], sys_clk_freq)
        self.add_wb_master(self.bridge.wishbone)
        self.add_csr("uart")
        self.add_interrupt("uart")

        self.submodules.uart_phy = RS232PHY(platform.request("serial"), self.clk_freq, 115200)
        self.submodules.uart_multiplexer = RS232PHYMultiplexer(uart_interfaces, self.uart_phy)
        self.comb += self.uart_multiplexer.sel.eq(platform.request("user_sw", 0))
        self.add_csr("uart_phy")

        # Basic peripherals ------------------------------------------------------------------------
        self.submodules.info = info.Info(platform, self.__class__.__name__)
        self.add_csr("info")
        # self.submodules.cas = cas.ControlAndStatus(platform, sys_clk_freq)
        # self.add_csr("cas")
        self.submodules.oled = oled.OLED(platform.request("oled"))
        self.add_csr("oled")

        # Add debug interface if the CPU has one ---------------------------------------------------
        if hasattr(self.cpu, "debug_bus"):
            self.register_mem(
                name="vexriscv_debug",
                address=0xf00f0000,
                interface=self.cpu.debug_bus,
                size=0x100)

        # Memory mapped SPI Flash ------------------------------------------------------------------
        spiflash_pads = platform.request(spiflash)
        spiflash_pads.clk = Signal()
        self.specials += Instance(
            "STARTUPE2",
            i_CLK=0, i_GSR=0, i_GTS=0, i_KEYCLEARB=0, i_PACK=0,
            i_USRCCLKO=spiflash_pads.clk, i_USRCCLKTS=0, i_USRDONEO=1, i_USRDONETS=1)
        spiflash_dummy = {
            "spiflash_1x": 9,
            "spiflash_4x": 11,
        }
        self.submodules.spiflash = spi_flash.SpiFlash(
            spiflash_pads,
            dummy=spiflash_dummy[spiflash],
            div=platform.spiflash_clock_div,
            endianness=self.cpu.endianness)
        self.add_csr("spiflash")
        self.add_constant("SPIFLASH_PAGE_SIZE", platform.spiflash_page_size)
        self.add_constant("SPIFLASH_SECTOR_SIZE", platform.spiflash_sector_size)
        self.add_constant("SPIFLASH_TOTAL_SIZE", platform.spiflash_total_size)
        self.add_wb_slave(
            self.mem_map["spiflash"],
            self.spiflash.bus,
            platform.spiflash_total_size)
        self.add_memory_region(
            "spiflash",
            self.mem_map["spiflash"],
            platform.spiflash_total_size)

        bios_size = 0x8000
        self.flash_boot_address = self.mem_map["spiflash"]+platform.gateware_size+bios_size
        self.add_constant("FLASH_BOOT_ADDRESS", self.flash_boot_address)
コード例 #6
0
ファイル: base.py プロジェクト: skiphansen/litex-buildenv
    def __init__(self, platform, **kwargs):
        dict_set_max(kwargs, 'integrated_sram_size', 0x2800)

        # We save the ROM size passed in as the BIOS size, and then force the
        # integrated ROM size to 0 to avoid integrated ROM.
        bios_size = kwargs['integrated_rom_size']
        kwargs['integrated_rom_size'] = 0x0

        # FIXME: Force either lite or minimal variants of CPUs; full is too big.

        platform.add_extension(serial)
        clk_freq = int(16e6)

        # Extra 0x28000 is due to bootloader bitstream.
        kwargs['cpu_reset_address'] = self.mem_map[
            "spiflash"] + platform.gateware_size + platform.bootloader_size
        SoCCore.__init__(self, platform, clk_freq, **kwargs)

        self.submodules.crg = _CRG(platform)
        self.platform.add_period_constraint(self.crg.cd_sys.clk,
                                            1e9 / clk_freq)

        # Control and Status
        self.submodules.cas = cas.ControlAndStatus(platform, clk_freq)
        self.add_csr("cas")

        # SPI flash peripheral
        self.submodules.spiflash = spi_flash.SpiFlashSingle(
            platform.request("spiflash"),
            dummy=platform.spiflash_read_dummy_bits,
            div=platform.spiflash_clock_div)
        self.add_csr("spiflash")
        self.add_constant("SPIFLASH_PAGE_SIZE", platform.spiflash_page_size)
        self.add_constant("SPIFLASH_SECTOR_SIZE",
                          platform.spiflash_sector_size)
        self.register_mem("spiflash",
                          self.mem_map["spiflash"],
                          self.spiflash.bus,
                          size=platform.spiflash_total_size)

        self.add_constant("ROM_DISABLE", 1)
        self.add_memory_region("rom",
                               kwargs['cpu_reset_address'],
                               bios_size,
                               type="cached+linker")
        self.flash_boot_address = self.mem_map[
            "spiflash"] + platform.gateware_size + bios_size + platform.bootloader_size
        define_flash_constants(self)

        # We don't have a DRAM, so use the remaining SPI flash for user
        # program.
        self.add_memory_region(
            "user_flash",
            self.flash_boot_address,
            # Leave a grace area- possible one-by-off bug in add_memory_region?
            # Possible fix: addr < origin + length - 1
            platform.spiflash_total_size -
            (self.flash_boot_address - self.mem_map["spiflash"]) - 0x100,
            type="cached+linker")

        # Disable USB activity until we switch to a USB UART.
        self.comb += [platform.request("usb").pullup.eq(0)]
コード例 #7
0
    def __init__(self, platform, **kwargs):
        dict_set_max(kwargs, 'integrated_rom_size', 0x8000)
        dict_set_max(kwargs, 'integrated_sram_size', 0x8000)
        #kwargs['uart_name']="stub" #stub
        #kwargs['with_uart'] = False
        sys_clk_freq = 50*1000000
        # SoCSDRAM ---------------------------------------------------------------------------------
        SoCSDRAM.__init__(self, platform, clk_freq=sys_clk_freq, **kwargs)
        self.submodules.uartbone  = uart.UARTWishboneBridge(
                pads     = self.platform.request("serial"),
                clk_freq = self.sys_clk_freq,
                baudrate = 115200)
        self.bus.add_master(name="uartbone", master=self.uartbone.wishbone)
        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)
        
        self.platform.add_period_constraint(self.crg.cd_sys.clk, 1e9/sys_clk_freq)

        #self.submodules.uartbone  = uart.UARTWishboneBridge(
        #        pads     = self.platform.request("serial"),
        #        clk_freq = self.sys_clk_freq,
        #        baudrate = 115200)
        #self.bus.add_master(name="uartbone", master=self.uartbone.wishbone)


        # DDR2 SDRAM -------------------------------------------------------------------------------
        #if True:
        #    sdram_module = MT46H64M16(50*1000000, "1:2") #P3R1GE4JGF  MT46H64M16
        #    self.submodules.ddrphy = s6ddrphy.S6HalfRateDDRPHY(
        #        platform.request("ddram"),
        #        memtype      = sdram_module.memtype,
        #        rd_bitslip   = 0, #0 1
        #        wr_bitslip   = 4, #4 3
        #        dqs_ddr_alignment="C0") #C0 C1
        #    self.add_csr("ddrphy")
        #    controller_settings = ControllerSettings(
        #        with_bandwidth=True)
        #    self.register_sdram(
        #        self.ddrphy,
        #        geom_settings   = sdram_module.geom_settings,
        #        timing_settings = sdram_module.timing_settings,
        #        controller_settings=controller_settings)
        #    print(sdram_module.timing_settings.__dict__)
        ##    print(sdram_module.geom_settings.__dict__)
        #    self.comb += [
        #        self.ddrphy.clk4x_wr_strb.eq(self.crg.clk4x_wr_strb),
        #        self.ddrphy.clk4x_rd_strb.eq(self.crg.clk4x_rd_strb),
        #    ]
        # Basic peripherals ------------------------------------------------------------------------
        # info module
        self.submodules.info = info.Info(platform, self.__class__.__name__)
        self.add_csr("info")
        # control and status module
        #self.submodules.cas = cas.ControlAndStatus(platform, sys_clk_freq)
        self.add_csr("cas")

        # Add debug interface if the CPU has one ---------------------------------------------------
        #if hasattr(self.cpu, "debug_bus"):
        #self.register_mem(
        #    name="vexriscv_debug",
        #    address=0xf00f0000,
        #    interface=self.cpu.debug_bus, #debug_bus,
        #    size=0x100)
    
        #analyzer_signals = [
        #    #self.ddrphy.sys_clk,
        #    #platform.lookup_request("ddram").a,
        #    platform.lookup_request("ddram").ba
        #    platform.lookup_request("ddram").ras_n,
        #    platform.lookup_request("ddram").cas_n,
        #    platform.lookup_request("ddram").we_n,
        #    platform.lookup_request("ddram").cs_n,
        #     platform.lookup_request("ddram").cke,
            #self.cpu.ibus.stb,
        #    self.cpu.ibus.cyc
        #]    
        #self.submodules.analyzer = LiteScopeAnalyzer(analyzer_signals,
        #    depth        = 4096, # 512
        #    clock_domain = "sys",
        #    csr_csv      = "analyzer.csv")
        #self.add_csr("analyzer")
        # Memory mapped SPI Flash ------------------------------------------------------------------
        #self.submodules.spiflash = spi_flash.SpiFlash(
        #    platform.request("spiflash"),
        #    dummy=platform.spiflash_read_dummy_bits,
        #    div=platform.spiflash_clock_div,
        #    endianness=self.cpu.endianness)
        #self.add_csr("spiflash")
        #self.add_constant("SPIFLASH_PAGE_SIZE", platform.spiflash_page_size)
        #self.add_constant("SPIFLASH_SECTOR_SIZE", platform.spiflash_sector_size)
        #self.add_constant("SPIFLASH_TOTAL_SIZE", platform.spiflash_total_size)
        #self.add_wb_slave(
        #    self.mem_map["spiflash"],
        #    self.spiflash.bus,
        #    platform.spiflash_total_size)
        #self.add_memory_region(
        #    "spiflash",
        #    self.mem_map["spiflash"],
        #    platform.spiflash_total_size)

        bios_size = 0x8000
コード例 #8
0
ファイル: base.py プロジェクト: nickoe/litex-buildenv
    def __init__(self, platform, spiflash="spiflash_1x", **kwargs):
        if kwargs.get('cpu_type', None) == 'mor1kx':
            dict_set_max(kwargs, 'integrated_rom_size', 0x10000)
        else:
            dict_set_max(kwargs, 'integrated_rom_size', 0x8000)
        dict_set_max(kwargs, 'integrated_sram_size', 0x8000)

        sys_clk_freq = int(100e6)
        # SoCCore ----------------------------------------------------------------------------------
        SoCCore.__init__(self, platform, clk_freq=sys_clk_freq, **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)
        self.crg.cd_sys.clk.attr.add("keep")
        self.platform.add_period_constraint(self.crg.cd_sys.clk,
                                            period_ns(sys_clk_freq))

        # Basic peripherals ------------------------------------------------------------------------
        self.submodules.info = info.Info(platform, self.__class__.__name__)
        self.add_csr("info")
        self.submodules.cas = cas.ControlAndStatus(platform, sys_clk_freq)
        self.add_csr("cas")

        # Add debug interface if the CPU has one ---------------------------------------------------
        if hasattr(self.cpu, "debug_bus"):
            self.register_mem(name="vexriscv_debug",
                              address=0xf00f0000,
                              interface=self.cpu.debug_bus,
                              size=0x100)

        # Memory mapped SPI Flash ------------------------------------------------------------------
        spiflash_pads = platform.request(spiflash)
        spiflash_pads.clk = Signal()
        self.specials += Instance("STARTUPE2",
                                  i_CLK=0,
                                  i_GSR=0,
                                  i_GTS=0,
                                  i_KEYCLEARB=0,
                                  i_PACK=0,
                                  i_USRCCLKO=spiflash_pads.clk,
                                  i_USRCCLKTS=0,
                                  i_USRDONEO=1,
                                  i_USRDONETS=1)
        spiflash_dummy = {
            "spiflash_1x": 9,
            "spiflash_4x": 11,
        }
        self.submodules.spiflash = spi_flash.SpiFlash(
            spiflash_pads,
            dummy=spiflash_dummy[spiflash],
            div=2,
            endianness=self.cpu.endianness)
        self.add_csr("spiflash")
        self.add_constant("SPIFLASH_PAGE_SIZE", platform.spiflash_page_size)
        self.add_constant("SPIFLASH_SECTOR_SIZE",
                          platform.spiflash_sector_size)
        self.add_constant("SPIFLASH_TOTAL_SIZE", platform.spiflash_total_size)
        self.add_wb_slave(self.mem_map["spiflash"], self.spiflash.bus,
                          platform.spiflash_total_size)
        self.add_memory_region("spiflash", self.mem_map["spiflash"],
                               platform.spiflash_total_size)

        bios_size = 0x8000
        self.flash_boot_address = self.mem_map[
            "spiflash"] + platform.gateware_size + bios_size
        self.add_constant("FLASH_BOOT_ADDRESS", self.flash_boot_address)
コード例 #9
0
ファイル: base.py プロジェクト: galberding/litex-buildenv
    def __init__(self, platform, **kwargs):
        dict_set_max(kwargs, 'integrated_rom_size', 0x8000)
        dict_set_max(kwargs, 'integrated_sram_size', 0x8000)

        sys_clk_freq = int(50e6)
        # SoCSDRAM ---------------------------------------------------------------------------------
        SoCSDRAM.__init__(self, platform, clk_freq=sys_clk_freq, **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)
        self.platform.add_period_constraint(self.crg.cd_sys.clk,
                                            1e9 / sys_clk_freq)

        # DDR2 SDRAM -------------------------------------------------------------------------------
        if True:
            sdram_module = MT47H32M16(sys_clk_freq, "1:2")
            self.submodules.ddrphy = s6ddrphy.S6HalfRateDDRPHY(
                platform.request("ddram_b"),
                memtype=sdram_module.memtype,
                rd_bitslip=0,
                wr_bitslip=4,
                dqs_ddr_alignment="C0")
            self.add_csr("ddrphy")
            controller_settings = ControllerSettings(with_bandwidth=True)
            self.register_sdram(self.ddrphy,
                                geom_settings=sdram_module.geom_settings,
                                timing_settings=sdram_module.timing_settings,
                                controller_settings=controller_settings)
            self.comb += [
                self.ddrphy.clk4x_wr_strb.eq(self.crg.clk4x_wr_strb),
                self.ddrphy.clk4x_rd_strb.eq(self.crg.clk4x_rd_strb),
            ]

        # Basic peripherals ------------------------------------------------------------------------
        # info module
        self.submodules.info = info.Info(platform, self.__class__.__name__)
        self.add_csr("info")
        # control and status module
        self.submodules.cas = cas.ControlAndStatus(platform, sys_clk_freq)
        self.add_csr("cas")

        # Add debug interface if the CPU has one ---------------------------------------------------
        if hasattr(self.cpu, "debug_bus"):
            self.register_mem(name="vexriscv_debug",
                              address=0xf00f0000,
                              interface=self.cpu.debug_bus,
                              size=0x100)

        # Memory mapped SPI Flash ------------------------------------------------------------------
        self.submodules.spiflash = spi_flash.SpiFlash(
            platform.request("spiflash"),
            dummy=platform.spiflash_read_dummy_bits,
            div=platform.spiflash_clock_div,
            endianness=self.cpu.endianness)
        self.add_csr("spiflash")
        self.add_constant("SPIFLASH_PAGE_SIZE", platform.spiflash_page_size)
        self.add_constant("SPIFLASH_SECTOR_SIZE",
                          platform.spiflash_sector_size)
        self.add_constant("SPIFLASH_TOTAL_SIZE", platform.spiflash_total_size)
        self.register_mem("spiflash",
                          self.mem_map["spiflash"],
                          self.spiflash.bus,
                          size=platform.spiflash_total_size)
        self.flash_boot_address = self.mem_map[
            "spiflash"] + platform.gateware_size
        self.add_constant("FLASH_BOOT_ADDRESS", self.flash_boot_address)
        self.add_constant("DEVICE_TREE_IMAGE_FLASH_OFFSET", 0x00000000)
        self.add_constant("EMULATOR_IMAGE_FLASH_OFFSET", 0x4000)
        self.add_constant("KERNEL_IMAGE_FLASH_OFFSET", 0x30000)
        self.add_constant("ROOTFS_IMAGE_FLASH_OFFSET", 0x5b0000)

        # Take Ethernet Phy out of reset for SYSCLK of 125 Mhz
        gmii_rst_n = platform.request("gmii_rst_n")
        self.comb += [gmii_rst_n.eq(1)]
コード例 #10
0
    def __init__(self, platform, **kwargs):
        dict_set_max(kwargs, 'integrated_rom_size', 0x8000)
        dict_set_max(kwargs, 'integrated_sram_size', 0x8000)

        sys_clk_freq = 50 * 1000000

        if 'expansion' in kwargs:
            tofe_board_name = kwargs.get('expansion')
            del kwargs['expansion']
        else:
            tofe_board_name = None

        # disable uart
        kwargs['with_uart'] = False

        # SoCSDRAM ---------------------------------------------------------------------------------
        SoCSDRAM.__init__(self, platform, clk_freq=sys_clk_freq, **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)
        self.platform.add_period_constraint(self.crg.cd_sys.clk,
                                            1e9 / sys_clk_freq)

        # Add specialized uart ---------------------------------------------------------------------
        self.submodules.suart = shared_uart.SharedUART(self.clk_freq, 115200)
        self.suart.add_uart_pads(platform.request('fx2_serial'))
        self.submodules.uart = self.suart.uart
        self.add_csr("uart")
        self.add_interrupt("uart")

        # DDR3 SDRAM -------------------------------------------------------------------------------
        if True:
            sdram_module = MT41J128M16(sys_clk_freq, "1:4")
            self.submodules.ddrphy = s6ddrphy.S6QuarterRateDDRPHY(
                platform.request("ddram"),
                rd_bitslip=0,
                wr_bitslip=4,
                dqs_ddr_alignment="C0")
            self.add_csr("ddrphy")
            controller_settings = ControllerSettings(with_bandwidth=True)
            self.register_sdram(self.ddrphy,
                                geom_settings=sdram_module.geom_settings,
                                timing_settings=sdram_module.timing_settings,
                                controller_settings=controller_settings)
            self.comb += [
                self.ddrphy.clk8x_wr_strb.eq(self.crg.clk8x_wr_strb),
                self.ddrphy.clk8x_rd_strb.eq(self.crg.clk8x_rd_strb),
            ]

        # Basic peripherals ------------------------------------------------------------------------
        # info module
        self.submodules.info = info.Info(platform, self.__class__.__name__)
        self.add_csr("info")
        # control and status module
        #self.submodules.cas = cas.ControlAndStatus(platform, sys_clk_freq)
        self.add_csr("cas")
        # opsis specific i2c module
        self.submodules.opsis_i2c = opsis_i2c.OpsisI2C(platform)
        self.add_csr("opsis_i2c")
        # front panel (ATX) module
        self.submodules.front_panel = FrontPanelGPIO(platform, sys_clk_freq)
        self.comb += self.crg.reset.eq(self.front_panel.reset)
        self.add_csr("front_panel")

        # Expansion boards -------------------------------------------------------------------------
        if tofe_board_name:
            if tofe_board_name == 'lowspeedio':
                self.submodules.tofe = tofe.TOFEBoard(tofe_board_name)(
                    platform, self.suart)
            else:
                self.submodules.tofe = tofe.TOFEBoard(tofe_board_name)(
                    platform)

        # Add debug interface if the CPU has one ---------------------------------------------------
        if hasattr(self.cpu, "debug_bus"):
            self.register_mem(name="vexriscv_debug",
                              address=0xf00f0000,
                              interface=self.cpu.debug_bus,
                              size=0x100)

        # Memory mapped SPI Flash ------------------------------------------------------------------
        self.submodules.spiflash = spi_flash.SpiFlash(
            platform.request("spiflash4x"),
            dummy=platform.spiflash_read_dummy_bits,
            div=platform.spiflash_clock_div,
            endianness=self.cpu.endianness)
        self.add_csr("spiflash")
        self.add_constant("SPIFLASH_PAGE_SIZE", platform.spiflash_page_size)
        self.add_constant("SPIFLASH_SECTOR_SIZE",
                          platform.spiflash_sector_size)
        self.add_constant("SPIFLASH_TOTAL_SIZE", platform.spiflash_total_size)
        self.add_wb_slave(self.mem_map["spiflash"], self.spiflash.bus,
                          platform.spiflash_total_size)
        self.add_memory_region("spiflash", self.mem_map["spiflash"],
                               platform.spiflash_total_size)

        bios_size = 0x8000
        self.flash_boot_address = self.mem_map[
            "spiflash"] + platform.gateware_size + bios_size
        define_flash_constants(self)
コード例 #11
0
ファイル: base.py プロジェクト: antmicro-labs/litex-buildenv
    def __init__(self, platform, **kwargs):
        dict_set_max(kwargs, 'integrated_rom_size', 0x8000)
        dict_set_max(kwargs, 'integrated_sram_size', 0x8000)

        sys_clk_freq = int(50e6)
        # SoCSDRAM ---------------------------------------------------------------------------------
        SoCSDRAM.__init__(self, platform, clk_freq=sys_clk_freq, **kwargs)

        # CRG --------------------------------------------------------------------------------------
        self.submodules.crg = _CRG(platform, sys_clk_freq)
        self.platform.add_period_constraint(self.crg.cd_sys.clk, 1e9/sys_clk_freq)

        # DDR2 SDRAM -------------------------------------------------------------------------------
        if True:
            sdram_module = MT47H32M16(sys_clk_freq, "1:2")
            self.submodules.ddrphy = s6ddrphy.S6HalfRateDDRPHY(
                platform.request("ddram_b"),
                memtype      = sdram_module.memtype,
                rd_bitslip   = 0,
                wr_bitslip   = 4,
                dqs_ddr_alignment="C0")
            self.add_csr("ddrphy")
            controller_settings = ControllerSettings(
                with_bandwidth=True)
            self.register_sdram(
                self.ddrphy,
                geom_settings   = sdram_module.geom_settings,
                timing_settings = sdram_module.timing_settings,
                controller_settings=controller_settings)
            self.comb += [
                self.ddrphy.clk4x_wr_strb.eq(self.crg.clk4x_wr_strb),
                self.ddrphy.clk4x_rd_strb.eq(self.crg.clk4x_rd_strb),
            ]

        # Basic peripherals ------------------------------------------------------------------------
        # info module
        self.submodules.info = info.Info(platform, self.__class__.__name__)
        self.add_csr("info")
        # control and status module
        self.submodules.cas = cas.ControlAndStatus(platform, sys_clk_freq)
        self.add_csr("cas")

        # Add debug interface if the CPU has one ---------------------------------------------------
        if hasattr(self.cpu, "debug_bus"):
            self.register_mem(
                name="vexriscv_debug",
                address=0xf00f0000,
                interface=self.cpu.debug_bus,
                size=0x100)

        # ??????
        gmii_rst_n = platform.request("gmii_rst_n")
        self.comb += [
            gmii_rst_n.eq(1)
        ]


        # Support for soft-emulation for full Linux support ----------------------------------------
        if self.cpu_type == "vexriscv" and self.cpu_variant == "linux":
            size = 0x4000
            self.submodules.emulator_ram = wishbone.SRAM(size)
            self.register_mem("emulator_ram", self.mem_map["emulator_ram"], self.emulator_ram.bus, size)