def _generate_includes(self): cpu_type = self.soc.cpu_type memory_regions = self.soc.get_memory_regions() flash_boot_address = getattr(self.soc, "flash_boot_address", None) shadow_base = getattr(self.soc, "shadow_base", None) csr_regions = self.soc.get_csr_regions() constants = self.soc.get_constants() buildinc_dir = os.path.join(self.output_dir, "software", "include") generated_dir = os.path.join(buildinc_dir, "generated") os.makedirs(generated_dir, exist_ok=True) if cpu_type is not None: variables_contents = [] def define(k, v): variables_contents.append("{}={}\n".format( k, _makefile_escape(v))) for k, v in cpu_interface.get_cpu_mak(self.soc.cpu, self.compile_software): define(k, v) # Distinguish between LiteX and MiSoC. define("LITEX", "1") # Distinguish between applications running from main RAM and # flash for user-provided software packages. exec_profiles = {"COPY_TO_MAIN_RAM": "0", "EXECUTE_IN_PLACE": "0"} if "main_ram" in (m[0] for m in memory_regions): exec_profiles["COPY_TO_MAIN_RAM"] = "1" else: exec_profiles["EXECUTE_IN_PLACE"] = "1" for k, v in exec_profiles.items(): define(k, v) define("SOC_DIRECTORY", soc_directory) variables_contents.append("export BUILDINC_DIRECTORY\n") define("BUILDINC_DIRECTORY", buildinc_dir) for name, src_dir in self.software_packages: define(name.upper() + "_DIRECTORY", src_dir) write_to_file(os.path.join(generated_dir, "variables.mak"), "".join(variables_contents)) write_to_file(os.path.join(generated_dir, "output_format.ld"), cpu_interface.get_linker_output_format(self.soc.cpu)) write_to_file(os.path.join(generated_dir, "regions.ld"), cpu_interface.get_linker_regions(memory_regions)) write_to_file( os.path.join(generated_dir, "mem.h"), cpu_interface.get_mem_header(memory_regions, flash_boot_address, shadow_base)) write_to_file(os.path.join(generated_dir, "csr.h"), cpu_interface.get_csr_header(csr_regions, constants)) write_to_file(os.path.join(generated_dir, "git.h"), cpu_interface.get_git_header()) if isinstance(self.soc, soc_sdram.SoCSDRAM): if hasattr(self.soc, "sdram"): write_to_file( os.path.join(generated_dir, "sdram_phy.h"), get_sdram_phy_c_header( self.soc.sdram.controller.settings.phy, self.soc.sdram.controller.settings.timing))
def _generate_includes(self): cpu_type = self.soc.cpu_type memory_regions = self.soc.get_memory_regions() flash_boot_address = getattr(self.soc, "flash_boot_address", None) csr_regions = self.soc.get_csr_regions() constants = self.soc.get_constants() buildinc_dir = os.path.join(self.output_dir, "software", "include") generated_dir = os.path.join(buildinc_dir, "generated") os.makedirs(generated_dir, exist_ok=True) variables_contents = [] def define(k, v): variables_contents.append("{}={}\n".format(k, _makefile_escape(v))) for k, v in cpu_interface.get_cpu_mak(self.soc.cpu): define(k, v) # Distinguish between LiteX and MiSoC. define("LITEX", "1") # Distinguish between applications running from main RAM and # flash for user-provided software packages. exec_profiles = { "COPY_TO_MAIN_RAM" : "0", "EXECUTE_IN_PLACE" : "0" } if "main_ram" in (m[0] for m in memory_regions): exec_profiles["COPY_TO_MAIN_RAM"] = "1" else: exec_profiles["EXECUTE_IN_PLACE"] = "1" for k, v in exec_profiles.items(): define(k, v) define("SOC_DIRECTORY", soc_directory) variables_contents.append("export BUILDINC_DIRECTORY\n") define("BUILDINC_DIRECTORY", buildinc_dir) for name, src_dir in self.software_packages: define(name.upper() + "_DIRECTORY", src_dir) write_to_file( os.path.join(generated_dir, "variables.mak"), "".join(variables_contents)) write_to_file( os.path.join(generated_dir, "output_format.ld"), cpu_interface.get_linker_output_format(self.soc.cpu)) write_to_file( os.path.join(generated_dir, "regions.ld"), cpu_interface.get_linker_regions(memory_regions)) write_to_file( os.path.join(generated_dir, "mem.h"), cpu_interface.get_mem_header(memory_regions, flash_boot_address)) write_to_file( os.path.join(generated_dir, "csr.h"), cpu_interface.get_csr_header(csr_regions, constants)) if isinstance(self.soc, soc_sdram.SoCSDRAM): if hasattr(self.soc, "sdram"): write_to_file( os.path.join(generated_dir, "sdram_phy.h"), sdram_init.get_sdram_phy_c_header( self.soc.sdram.controller.settings.phy, self.soc.sdram.controller.settings.timing))
def _generate_includes(self): os.makedirs(self.include_dir, exist_ok=True) os.makedirs(self.generated_dir, exist_ok=True) if self.soc.cpu_type is not None: variables_contents = [] def define(k, v): variables_contents.append("{}={}\n".format( k, _makefile_escape(v))) for k, v in cpu_interface.get_cpu_mak(self.soc.cpu, self.compile_software): define(k, v) # Distinguish between LiteX and MiSoC. define("LITEX", "1") # Distinguish between applications running from main RAM and # flash for user-provided software packages. exec_profiles = {"COPY_TO_MAIN_RAM": "0", "EXECUTE_IN_PLACE": "0"} if "main_ram" in self.soc.mem_regions.keys(): exec_profiles["COPY_TO_MAIN_RAM"] = "1" else: exec_profiles["EXECUTE_IN_PLACE"] = "1" for k, v in exec_profiles.items(): define(k, v) define("SOC_DIRECTORY", soc_directory) variables_contents.append("export BUILDINC_DIRECTORY\n") define("BUILDINC_DIRECTORY", self.include_dir) for name, src_dir in self.software_packages: define(name.upper() + "_DIRECTORY", src_dir) write_to_file(os.path.join(self.generated_dir, "variables.mak"), "".join(variables_contents)) write_to_file(os.path.join(self.generated_dir, "output_format.ld"), cpu_interface.get_linker_output_format(self.soc.cpu)) write_to_file( os.path.join(self.generated_dir, "regions.ld"), cpu_interface.get_linker_regions(self.soc.mem_regions)) write_to_file(os.path.join(self.generated_dir, "mem.h"), cpu_interface.get_mem_header(self.soc.mem_regions)) write_to_file(os.path.join(self.generated_dir, "soc.h"), cpu_interface.get_soc_header(self.soc.constants)) write_to_file( os.path.join(self.generated_dir, "csr.h"), cpu_interface.get_csr_header(self.soc.csr_regions, self.soc.constants)) write_to_file(os.path.join(self.generated_dir, "git.h"), cpu_interface.get_git_header()) if hasattr(self.soc, "sdram"): from litedram.init import get_sdram_phy_c_header write_to_file( os.path.join(self.generated_dir, "sdram_phy.h"), get_sdram_phy_c_header( self.soc.sdram.controller.settings.phy, self.soc.sdram.controller.settings.timing))
def _generate_includes(self): cpu_type = self.soc.cpu_type cpu_variant = self.soc.cpu_variant memory_regions = self.soc.get_memory_regions() flash_boot_address = getattr(self.soc, "flash_boot_address", None) csr_regions = self.soc.get_csr_regions() constants = self.soc.get_constants() buildinc_dir = os.path.join(self.output_dir, "software", "include") generated_dir = os.path.join(buildinc_dir, "generated") os.makedirs(generated_dir, exist_ok=True) variables_contents = [] def define(k, v): variables_contents.append("{}={}\n".format(k, _makefile_escape(v))) for k, v in cpu_interface.get_cpu_mak(cpu_type, cpu_variant): define(k, v) # Distinguish between applications running from main RAM and # flash for user-provided software packages. if "main_ram" in (m[0] for m in memory_regions): define("COPY_TO_MAIN_RAM", "1") else: define("COPY_TO_MAIN_RAM", "0") define("SOC_DIRECTORY", soc_directory) variables_contents.append("export BUILDINC_DIRECTORY\n") define("BUILDINC_DIRECTORY", buildinc_dir) for name, src_dir in self.software_packages: define(name.upper() + "_DIRECTORY", src_dir) write_to_file(os.path.join(generated_dir, "variables.mak"), "".join(variables_contents)) write_to_file(os.path.join(generated_dir, "output_format.ld"), cpu_interface.get_linker_output_format(cpu_type)) write_to_file(os.path.join(generated_dir, "regions.ld"), cpu_interface.get_linker_regions(memory_regions)) write_to_file( os.path.join(generated_dir, "mem.h"), cpu_interface.get_mem_header(memory_regions, flash_boot_address)) write_to_file(os.path.join(generated_dir, "csr.h"), cpu_interface.get_csr_header(csr_regions, constants)) if isinstance(self.soc, soc_sdram.SoCSDRAM): if hasattr(self.soc, "sdram"): write_to_file( os.path.join(generated_dir, "sdram_phy.h"), sdram_init.get_sdram_phy_c_header( self.soc.sdram.controller.settings.phy, self.soc.sdram.controller.settings.timing))
def _generate_includes(self): cpu_type = self.soc.cpu_type memory_regions = self.soc.get_memory_regions() flash_boot_address = getattr(self.soc, "flash_boot_address", None) csr_regions = self.soc.get_csr_regions() constants = self.soc.get_constants() if isinstance(self.soc, soc_sdram.SoCSDRAM) and self.soc._sdram_phy: sdram_phy_settings = self.soc._sdram_phy[0].settings else: sdram_phy_settings = None buildinc_dir = os.path.join(self.output_dir, "software", "include") generated_dir = os.path.join(buildinc_dir, "generated") os.makedirs(generated_dir, exist_ok=True) variables_contents = [] def define(k, v): variables_contents.append("{}={}\n".format(k, _makefile_escape(v))) for k, v in cpu_interface.get_cpu_mak(cpu_type): define(k, v) define("SOC_DIRECTORY", soc_directory) variables_contents.append("export BUILDINC_DIRECTORY\n") define("BUILDINC_DIRECTORY", buildinc_dir) for name, src_dir in self.software_packages: define(name.upper() + "_DIRECTORY", src_dir) write_to_file( os.path.join(generated_dir, "variables.mak"), "".join(variables_contents)) write_to_file( os.path.join(generated_dir, "output_format.ld"), cpu_interface.get_linker_output_format(cpu_type)) write_to_file( os.path.join(generated_dir, "regions.ld"), cpu_interface.get_linker_regions(memory_regions)) write_to_file( os.path.join(generated_dir, "mem.h"), cpu_interface.get_mem_header(memory_regions, flash_boot_address)) write_to_file( os.path.join(generated_dir, "csr.h"), cpu_interface.get_csr_header(csr_regions, constants)) if sdram_phy_settings is not None: write_to_file( os.path.join(generated_dir, "sdram_phy.h"), sdram_init.get_sdram_phy_header(sdram_phy_settings))
def _generate_includes(self): cpu_type = self.soc.cpu_type memory_regions = self.soc.get_memory_regions() flash_boot_address = getattr(self.soc, "flash_boot_address", None) csr_regions = self.soc.get_csr_regions() constants = self.soc.get_constants() if isinstance(self.soc, soc_sdram.SoCSDRAM) and self.soc._sdram_phy: sdram_phy_settings = self.soc._sdram_phy[0].settings else: sdram_phy_settings = None buildinc_dir = os.path.join(self.output_dir, "software", "include") generated_dir = os.path.join(buildinc_dir, "generated") os.makedirs(generated_dir, exist_ok=True) variables_contents = [] def define(k, v): variables_contents.append("{}={}\n".format(k, _makefile_escape(v))) for k, v in cpu_interface.get_cpu_mak(cpu_type): define(k, v) define("SOC_DIRECTORY", soc_directory) define("BUILDINC_DIRECTORY", buildinc_dir) for name, src_dir in self.software_packages: define(name.upper() + "_DIRECTORY", src_dir) write_to_file( os.path.join(generated_dir, "variables.mak"), "".join(variables_contents)) write_to_file( os.path.join(generated_dir, "output_format.ld"), cpu_interface.get_linker_output_format(cpu_type)) write_to_file( os.path.join(generated_dir, "regions.ld"), cpu_interface.get_linker_regions(memory_regions)) write_to_file( os.path.join(generated_dir, "mem.h"), cpu_interface.get_mem_header(memory_regions, flash_boot_address)) write_to_file( os.path.join(generated_dir, "csr.h"), cpu_interface.get_csr_header(csr_regions, constants)) if sdram_phy_settings is not None: write_to_file( os.path.join(generated_dir, "sdram_phy.h"), sdram_init.get_sdram_phy_header(sdram_phy_settings))