コード例 #1
0
def main():
    parser = argparse.ArgumentParser(description="Opsis LiteX SoC",
                                     conflict_handler='resolve')
    get_args(parser)
    builder_args(parser)
    soc_sdram_args(parser)

    args = parser.parse_args()

    platform = get_platform(args)

    soc = get_soc(args, platform)

    builddir = get_builddir(args)
    testdir = get_testdir(args)

    buildargs = builder_argdict(args)
    if not buildargs.get('output_dir', None):
        buildargs['output_dir'] = builddir

    if hasattr(soc, 'cpu_type'):
        if not buildargs.get('csr_csv', None):
            buildargs['csr_csv'] = os.path.join(testdir, "csr.csv")

        if not buildargs.get('csr_json', None):
            buildargs['csr_json'] = os.path.join(testdir, "csr.json")

        builder = Builder(soc, **buildargs)
        if not args.no_compile_firmware or args.override_firmware:
            builder.add_software_package("uip",
                                         "{}/firmware/uip".format(os.getcwd()))

            # FIXME: All platforms which current run their user programs from
            # SPI flash lack the block RAM resources to run the default
            # firmware. Check whether to use the stub or default firmware
            # should be refined (perhaps soc attribute?).
            if "main_ram" in soc.mem_regions:
                builder.add_software_package("firmware",
                                             "{}/firmware".format(os.getcwd()))
            else:
                builder.add_software_package(
                    "stub", "{}/firmware/stub".format(os.getcwd()))
        vns = builder.build(**dict(args.build_option))
    else:
        vns = platform.build(soc, build_dir=os.path.join(builddir, "gateware"))

    if hasattr(soc, 'pcie_phy'):
        from targets.common import cpu_interface
        csr_header = cpu_interface.get_csr_header(soc.get_csr_regions(),
                                                  soc.get_constants())
        kerneldir = os.path.join(builddir, "software", "pcie", "kernel")
        os.makedirs(kerneldir, exist_ok=True)
        write_to_file(os.path.join(kerneldir, "csr.h"), csr_header)

    if hasattr(soc, 'do_exit'):
        soc.do_exit(vns, filename="{}/analyzer.csv".format(testdir))
コード例 #2
0
ファイル: make.py プロジェクト: shenki/litex-buildenv
def main():
    parser = argparse.ArgumentParser(description="Opsis LiteX SoC",
                                     conflict_handler='resolve')
    get_args(parser)
    builder_args(parser)
    soc_sdram_args(parser)

    args = parser.parse_args()

    platform = get_platform(args)

    exec(
        "from targets.{}.{} import SoC".format(args.platform,
                                               args.target.lower(),
                                               args.target), globals())
    soc = SoC(platform, **soc_sdram_argdict(args), **dict(args.target_option))
    if hasattr(soc, 'configure_iprange'):
        soc.configure_iprange(args.iprange)

    builddir = get_builddir(args)
    testdir = get_testdir(args)

    buildargs = builder_argdict(args)
    if not buildargs.get('output_dir', None):
        buildargs['output_dir'] = builddir

    if hasattr(soc, 'cpu_type'):
        if not buildargs.get('csr_csv', None):
            buildargs['csr_csv'] = os.path.join(testdir, "csr.csv")

        builder = Builder(soc, **buildargs)
        if not args.no_compile_firmware or args.override_firmware:
            builder.add_software_package("uip",
                                         "{}/firmware/uip".format(os.getcwd()))
            builder.add_software_package("firmware",
                                         "{}/firmware".format(os.getcwd()))
        vns = builder.build(**dict(args.build_option))
    else:
        vns = platform.build(soc, build_dir=os.path.join(builddir, "gateware"))

    if hasattr(soc, 'pcie_phy'):
        from targets.common import cpu_interface
        csr_header = cpu_interface.get_csr_header(soc.get_csr_regions(),
                                                  soc.get_constants())
        kerneldir = os.path.join(builddir, "software", "pcie", "kernel")
        os.makedirs(kerneldir, exist_ok=True)
        write_to_file(os.path.join(kerneldir, "csr.h"), csr_header)

    if hasattr(soc, 'do_exit'):
        soc.do_exit(vns, filename="{}/analyzer.csv".format(testdir))