def __init__(self, core_file=None, name=None, core_root=None): if core_file: basename = os.path.basename(core_file) self.depend = [] self.simulators = [] self.plusargs = None self.provider = None self.system = None for s in section.SECTION_MAP: assert (not hasattr(self, s)) setattr(self, s, None) self.core_root = os.path.dirname(core_file) self.files_root = self.core_root if core_file: self.name = basename.split('.core')[0] config = FusesocConfigParser(core_file) #FIXME : Make simulators part of the core object self.simulator = config.get_section('simulator') for s in section.load_all(config, name=self.name): setattr(self, s.TAG, s) self.depend = self.main.depend self.simulators = self.main.simulators self.pre_build_scripts = config.get_list('scripts', 'pre_build_scripts') self.pre_run_scripts = config.get_list('scripts', 'pre_run_scripts') self.post_run_scripts = config.get_list('scripts', 'post_run_scripts') cache_root = os.path.join(Config().cache_root, self.name) if config.has_section('plusargs'): self.plusargs = Plusargs(dict(config.items('plusargs'))) if config.has_section('provider'): items = dict(config.items('provider')) provider_name = items.get('name') if provider_name is None: raise RuntimeError('Missing "name" in section [provider]') try: provider_module = importlib.import_module( 'fusesoc.provider.%s' % provider_name) self.provider = provider_module.PROVIDER_CLASS( self.name, items, self.core_root, cache_root) except ImportError: raise if self.provider: self.files_root = self.provider.files_root system_file = os.path.join(self.core_root, self.name + '.system') if os.path.exists(system_file): self.system = System(system_file) else: self.name = name self.provider = None
def __init__(self, core_file=None, name=None, core_root=None): if core_file: basename = os.path.basename(core_file) self.depend = [] self.simulators = [] self.plusargs = None self.provider = None self.system = None for s in section.SECTION_MAP: assert(not hasattr(self, s)) if(section.SECTION_MAP[s].named): setattr(self, s, OrderedDict()) else: setattr(self, s, None) self.core_root = os.path.dirname(core_file) self.files_root = self.core_root self.export_files = [] if core_file: config = FusesocConfigParser(core_file) #FIXME : Make simulators part of the core object self.simulator = config.get_section('simulator') for s in section.load_all(config, core_file): if type(s) == tuple: _l = getattr(self, s[0].TAG) _l[s[1]] = s[0] setattr(self, s[0].TAG, _l) else: setattr(self, s.TAG, s) if self.main.name: self.name = self.main.name else: self.name = basename.split('.core')[0] self.sanitized_name = self.name self.depend = self.main.depend self.simulators = self.main.simulators self._collect_filesets() cache_root = os.path.join(Config().cache_root, self.sanitized_name) if config.has_section('plusargs'): utils.pr_warn("plusargs section is deprecated and will not be parsed by FuseSoC. Please migrate to parameters in " + str(self.name)) self.plusargs = Plusargs(dict(config.items('plusargs'))) if config.has_section('provider'): items = dict(config.items('provider')) provider_name = items.get('name') if provider_name is None: raise RuntimeError('Missing "name" in section [provider]') try: provider_module = importlib.import_module( 'fusesoc.provider.%s' % provider_name) self.provider = provider_module.PROVIDER_CLASS(self.name, items, self.core_root, cache_root) except ImportError: raise if self.provider: self.files_root = self.provider.files_root # We need the component file here, but it might not be # available until the core is fetched. Try to fetch first if any # of the component files are missing if False in [os.path.exists(f) for f in self.main.component]: self.setup() for f in self.main.component: self._parse_component(os.path.join(self.files_root, f)) system_file = os.path.join(self.core_root, basename.split('.core')[0]+'.system') if os.path.exists(system_file): self.system = System(system_file) else: self.name = name self.provider = None
def __init__(self, core_file=None, name=None, core_root=None): logger.debug('__init__() *Entered*' + '\n core_file=' + str(core_file) + '\n name=' + str(name) + '\n core_root=' + str(core_root)) if core_file: basename = os.path.basename(core_file) self.depend = [] self.simulators = [] self.plusargs = None self.provider = None self.system = None self.verilog = None self.vpi = None if core_file: config = FusesocConfigParser(core_file) if config.has_option('main', 'name'): self.name = config.get('main', 'name') else: self.name = basename.split('.core')[0] self.depend = config.get_list('main', 'depend') self.simulators = config.get_list('main', 'simulators') #FIXME : Make simulators part of the core object self.simulator = config.get_section('simulator') self.icarus = IcarusSection(config.get_section('icarus')) self.modelsim = ModelsimSection(config.get_section('modelsim')) self.verilator = VerilatorSection(config.get_section('verilator')) self.pre_run_scripts = config.get_list('scripts', 'pre_run_scripts') self.post_run_scripts = config.get_list('scripts', 'post_run_scripts') logger.debug('name=' + str(self.name)) self.core_root = os.path.dirname(core_file) if config.has_section('plusargs'): self.plusargs = Plusargs(dict(config.items('plusargs'))) if config.has_section('provider'): self.cache_dir = os.path.join(Config().cache_root, self.name) self.files_root = self.cache_dir items = config.items('provider') self.provider = ProviderFactory(dict(items)) else: self.files_root = self.core_root if config.has_section('verilog'): self.verilog = Verilog() items = config.items('verilog') self.verilog.load_items((dict(items))) logger.debug('verilog.src_files=' + str(self.verilog.src_files)) logger.debug('verilog.include_files=' + str(self.verilog.include_files)) logger.debug('verilog.include_dirs=' + str(self.verilog.include_dirs)) if config.has_section('vpi'): items = config.items('vpi') self.vpi = VPI(dict(items)) system_file = os.path.join(self.core_root, self.name + '.system') if os.path.exists(system_file): self.system = System(system_file) else: self.name = name self.core_root = core_root self.cache_root = core_root self.files_root = core_root self.provider = None logger.debug('__init__() -Done-')