Esempio n. 1
0
def run(args):
    level = logging.DEBUG if args.verbose else logging.INFO

    setup_logging(level=level, monchrome=args.monochrome)
    logger.debug("Command line arguments: " + str(sys.argv))
    if os.getenv("FUSESOC_CORES"):
        logger.debug("FUSESOC_CORES: " +
                     str(os.getenv("FUSESOC_CORES").split(':')))
    if args.verbose:
        logger.debug("Verbose output")
    else:
        logger.debug("Concise output")

    if args.monochrome:
        logger.debug("Monochrome output")
    else:
        logger.debug("Colorful output")

    if args.config:
        config = Config(file=args.config)
    else:
        config = Config()
    cm = CoreManager(config)

    # Get the environment variable for further cores
    env_cores_root = []
    if os.getenv("FUSESOC_CORES"):
        env_cores_root = os.getenv("FUSESOC_CORES").split(":")
    env_cores_root.reverse()

    for cores_root in [
            config.cores_root, config.systems_root, env_cores_root,
            args.cores_root
    ]:
        try:
            cm.add_cores_root(cores_root)
        except (RuntimeError, IOError) as e:
            logger.warning("Failed to register cores root '{}'".format(str(e)))

    for library in config.libraries.values():
        try:
            cm.add_cores_root(library['location'])
        except (RuntimeError, IOError) as e:
            logger.warning("Failed to register cores root '{}'".format(str(e)))

    # Process global options
    if vars(args)['32']:
        config.archbits = 32
        logger.debug("Forcing 32-bit mode")
    elif vars(args)['64']:
        config.archbits = 64
        logger.debug("Forcing 64-bit mode")
    else:
        config.archbits = 64 if platform.architecture()[0] == '64bit' else 32
        logger.debug("Autodetected " + str(config.archbits) + "-bit mode")
    # Run the function
    args.func(cm, args)
Esempio n. 2
0
def init_logging(verbose, monochrome, log_file=None):
    level = logging.DEBUG if verbose else logging.INFO

    setup_logging(level, monochrome, log_file)

    if verbose:
        logger.debug("Verbose output")
    else:
        logger.debug("Concise output")

    if monochrome:
        logger.debug("Monochrome output")
    else:
        logger.debug("Colorful output")
Esempio n. 3
0
def main():
    setup_logging(level=logging.INFO, monchrome=False)
    logger.debug("Command line arguments: " + str(sys.argv))
    if os.getenv("FUSESOC_CORES"):
        logger.debug("FUSESOC_CORES: " +
                     str(os.getenv("FUSESOC_CORES").split(':')))

    parser = argparse.ArgumentParser()
    subparsers = parser.add_subparsers()

    # Global actions
    parser.add_argument('--version',
                        help='Display the FuseSoC version',
                        action='version',
                        version=__version__)

    # Global options
    parser.add_argument('--cores-root',
                        help='Add additional directories containing cores',
                        action='append')
    parser.add_argument('--32',
                        help='Force 32 bit mode for invoked tools',
                        action='store_true')
    parser.add_argument('--64',
                        help='Force 64 bit mode for invoked tools',
                        action='store_true')
    parser.add_argument('--monochrome',
                        help='Don\'t use color for messages',
                        action='store_true')
    parser.add_argument('--verbose',
                        help='More info messages',
                        action='store_true')

    # build subparser
    parser_build = subparsers.add_parser('build',
                                         help='Build an FPGA load module')
    parser_build.add_argument(
        '--setup',
        action='store_true',
        help='Only create the project files without running the EDA tool')
    parser_build.add_argument('system')
    parser_build.add_argument('backendargs', nargs=argparse.REMAINDER)
    parser_build.set_defaults(func=build)

    # init subparser
    parser_init = subparsers.add_parser(
        'init', help='Initialize the FuseSoC core libraries')
    parser_init.add_argument('-y',
                             action='store_true',
                             help='Skip user input and use default settings')
    parser_init.set_defaults(func=init)

    # pgm subparser
    parser_pgm = subparsers.add_parser(
        'pgm', help='Program an FPGA with a system configuration')
    parser_pgm.add_argument('system')
    parser_pgm.add_argument('backendargs', nargs=argparse.REMAINDER)
    parser_pgm.set_defaults(func=pgm)

    # fetch subparser
    parser_fetch = subparsers.add_parser(
        'fetch',
        help='Fetch a remote core and its dependencies to local cache')
    parser_fetch.add_argument('core')
    parser_fetch.set_defaults(func=fetch)

    # list-systems subparser
    parser_list_systems = subparsers.add_parser('list-systems',
                                                help='List available systems')
    parser_list_systems.set_defaults(func=list_systems)

    # list-cores subparser
    parser_list_cores = subparsers.add_parser('list-cores',
                                              help='List available cores')
    parser_list_cores.set_defaults(func=list_cores)

    # core-info subparser
    parser_core_info = subparsers.add_parser(
        'core-info', help='Display details about a core')
    parser_core_info.add_argument('core')
    parser_core_info.set_defaults(func=core_info)

    # list-paths subparser
    parser_list_paths = subparsers.add_parser(
        'list-paths', help='Display the search order for core root paths')
    parser_list_paths.set_defaults(func=list_paths)

    # sim subparser
    parser_sim = subparsers.add_parser('sim',
                                       help='Setup and run a simulation')
    parser_sim.add_argument(
        '--sim',
        nargs=1,
        help='Override the simulator settings from the system file')
    parser_sim.add_argument(
        '--setup',
        action='store_true',
        help='Only create the project files without running the EDA tool')
    parser_sim.add_argument(
        '--build-only',
        action='store_true',
        help='Build the simulation binary without running the simulator')
    parser_sim.add_argument(
        '--force',
        action='store_true',
        help='Force rebuilding simulation model when directory exists')
    parser_sim.add_argument(
        '--keep',
        action='store_true',
        help='Prevent rebuilding simulation model if it exists')
    parser_sim.add_argument('--dry-run', action='store_true')
    parser_sim.add_argument('--testbench',
                            nargs=1,
                            help='Override default testbench')
    parser_sim.add_argument('system', help='Select a system to simulate'
                            )  #, choices = Config().get_systems())
    parser_sim.add_argument('plusargs', nargs=argparse.REMAINDER)
    parser_sim.set_defaults(func=sim)

    # update subparser
    parser_update = subparsers.add_parser(
        'update', help='Update the FuseSoC core libraries')
    parser_update.set_defaults(func=update)

    parsed_args = parser.parse_args()
    if hasattr(parsed_args, 'func'):
        run(parsed_args)
    else:
        parser.print_help()