本文整理汇总了Python中fusesoc.coremanager.CoreManager.get_core方法的典型用法代码示例。如果您正苦于以下问题:Python CoreManager.get_core方法的具体用法?Python CoreManager.get_core怎么用?Python CoreManager.get_core使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fusesoc.coremanager.CoreManager
的用法示例。
在下文中一共展示了CoreManager.get_core方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure
# 需要导入模块: from fusesoc.coremanager import CoreManager [as 别名]
# 或者: from fusesoc.coremanager.CoreManager import get_core [as 别名]
def configure(self):
if os.path.exists(self.work_root):
shutil.rmtree(self.work_root)
os.makedirs(self.work_root)
cm = CoreManager()
for name in self.cores:
pr_info("Preparing " + name)
core = cm.get_core(name)
dst_dir = os.path.join(Config().build_root, self.system.name, 'src', name)
core.setup()
core.export(dst_dir)
示例2: configure
# 需要导入模块: from fusesoc.coremanager import CoreManager [as 别名]
# 或者: from fusesoc.coremanager.CoreManager import get_core [as 别名]
def configure(self):
logger.debug('configure() *Entered*')
if os.path.exists(self.work_root):
shutil.rmtree(self.work_root)
os.makedirs(self.work_root)
cm = CoreManager()
for name in self.cores:
print("Preparing " + name)
core = cm.get_core(name)
dst_dir = os.path.join(Config().build_root, self.system.name, 'src', name)
core.setup()
core.export(dst_dir)
logger.debug('configure() -Done-')
示例3: main
# 需要导入模块: from fusesoc.coremanager import CoreManager [as 别名]
# 或者: from fusesoc.coremanager.CoreManager import get_core [as 别名]
def main():
# VUnit steals the command line args so we use an environment variable
# to determine which core we're picking up
toplevel = os.getenv("CORE", "")
if not toplevel:
sys.stderr.write("Need to provide CORE environment variable")
sys.exit(1)
# Create VUnit instance by parsing command line arguments
vu = VUnit.from_argv()
#Create singleton instances for core manager and configuration handler
#Configuration manager is not needed in this example
cm = CoreManager()
# Assume we're running in the same directory containing the cores
cm.add_cores_root(".")
#Get the sorted list of dependencies starting from the top-level core
try:
cores = cm.get_depends(toplevel)
except DependencyError as e:
print("'{}' or any of its dependencies requires '{}', but this core was not found".format(top_core, e.value))
sys.exit(2)
#Iterate over cores, filesets and files and add all relevant sources files to vunit
incdirs = set()
src_files = []
#'usage' is a list of tags to look for in the filesets.
# Only look at filesets where any of these tags are present
usage = ['sim']
for core_name in cores:
core = cm.get_core(core_name)
core.setup()
basepath = core.files_root
for fs in core.file_sets:
if (set(fs.usage) & set(usage)) and ((core_name == toplevel) or not fs.private):
for file in fs.file:
if file.is_include_file:
#TODO: incdirs not used right now
incdirs.add(os.path.join(basepath, os.path.dirname(file.name)))
else:
try:
vu.library(file.logical_name)
except KeyError:
vu.add_library(file.logical_name)
vu.add_source_file(os.path.join(basepath, file.name), file.logical_name)
# Run vunit function
vu.main()
示例4: configure
# 需要导入模块: from fusesoc.coremanager import CoreManager [as 别名]
# 或者: from fusesoc.coremanager.CoreManager import get_core [as 别名]
def configure(self):
if os.path.exists(self.work_root):
shutil.rmtree(self.work_root)
os.makedirs(self.work_root)
cm = CoreManager()
for name in self.cores:
pr_info("Preparing " + name)
core = cm.get_core(name)
dst_dir = os.path.join(Config().build_root, self.system.name, 'src', name)
try:
core.setup()
except URLError as e:
raise RuntimeError("Problem while fetching '" + core.name + "': " + str(e.reason))
except urllib.HTTPError as e:
raise RuntimeError("Problem while fetching '" + core.name + "': " + str(e.reason))
core.export(dst_dir)
示例5: EdaTool
# 需要导入模块: from fusesoc.coremanager import CoreManager [as 别名]
# 或者: from fusesoc.coremanager.CoreManager import get_core [as 别名]
class EdaTool(object):
def __init__(self, system):
config = Config()
self.system = system
self.build_root = os.path.join(config.build_root, self.system.sanitized_name)
self.src_root = os.path.join(self.build_root, 'src')
self.cm = CoreManager()
self.cores = self.cm.get_depends(self.system.name)
self.env = os.environ.copy()
self.env['BUILD_ROOT'] = os.path.abspath(self.build_root)
self.plusarg = {}
self.vlogparam = {}
self.generic = {}
self.cmdlinearg = {}
def configure(self, args):
if os.path.exists(self.work_root):
for f in os.listdir(self.work_root):
if os.path.isdir(os.path.join(self.work_root, f)):
shutil.rmtree(os.path.join(self.work_root, f))
else:
os.remove(os.path.join(self.work_root, f))
else:
os.makedirs(self.work_root)
for name in self.cores:
pr_info("Preparing " + str(name))
core = self.cm.get_core(name)
dst_dir = os.path.join(Config().build_root, self.system.sanitized_name, 'src', core.sanitized_name)
try:
core.setup()
except URLError as e:
raise RuntimeError("Problem while fetching '" + core.name + "': " + str(e.reason))
except HTTPError as e:
raise RuntimeError("Problem while fetching '" + core.name + "': " + str(e.reason))
core.export(dst_dir)
def parse_args(self, args, prog, paramtypes):
typedict = {'bool' : {'action' : 'store_true'},
'file' : {'type' : str , 'nargs' : 1, 'action' : FileAction},
'int' : {'type' : int , 'nargs' : 1},
'str' : {'type' : str , 'nargs' : 1},
}
progname = 'fusesoc {} {}'.format(prog,
self.system.name)
parser = argparse.ArgumentParser(prog = progname,
conflict_handler='resolve')
param_groups = {}
_descr = {'plusarg' : 'Verilog plusargs (Run-time option)',
'vlogparam' : 'Verilog parameters (Compile-time option)',
'generic' : 'VHDL generic (Run-time option)',
'cmdlinearg' : 'Command-line arguments (Run-time option)'}
all_params = {}
for name in self.cores:
core = self.cm.get_core(name)
for param_name, param in core.parameter.items():
if param.paramtype in paramtypes and \
(name == self.system.name or \
param.scope == 'public'):
if not param.paramtype in param_groups:
param_groups[param.paramtype] = \
parser.add_argument_group(_descr[param.paramtype])
default = None
if not param.default == '':
try:
default = [typedict[param.datatype]['type'](param.default)]
print("Converted to " + str(default[0]))
except KeyError as e:
pass
try:
param_groups[param.paramtype].add_argument('--'+param_name,
help=param.description,
default=default,
**typedict[param.datatype])
except KeyError as e:
raise RuntimeError("Invalid data type {} for parameter '{}' in '{}'".format(str(e),
param_name,
core.name))
all_params[param_name.replace('-','_')] = param.paramtype
p = parser.parse_args(args)
for key,value in vars(p).items():
paramtype = all_params[key]
if value == True:
getattr(self, paramtype)[key] = "true"
elif value == False or value is None:
pass
else:
if type(value[0]) == str and paramtype == 'vlogparam':
_value = '"'+str(value[0])+'"'
else:
_value = str(value[0])
getattr(self, paramtype)[key] = _value
示例6: Backend
# 需要导入模块: from fusesoc.coremanager import CoreManager [as 别名]
# 或者: from fusesoc.coremanager.CoreManager import get_core [as 别名]
class Backend(object):
def __init__(self, system):
logger.debug('__init__() *Entered*')
config = Config()
self.system = system
self.build_root = os.path.join(config.build_root, self.system.name)
self.systems_root = config.systems_root
self.src_root = os.path.join(self.build_root, 'src')
self.include_dirs = []
self.src_files = []
self.vhdl_src_files = []
self.cm = CoreManager()
self.env = os.environ.copy()
self.env['SYSTEM_ROOT'] = os.path.abspath(os.path.join(self.systems_root, self.system.name))
self.env['BUILD_ROOT'] = os.path.abspath(self.build_root)
self.env['BACKEND'] = self.TOOL_NAME
self.cores = self.cm.get_depends(self.system.name)
for core_name in self.cores:
logger.debug('core_name=' + core_name)
core = self.cm.get_core(core_name)
if core.verilog:
if core.verilog.include_dirs:
logger.debug('core.include_dirs=' + str(core.verilog.include_dirs))
else:
logger.debug('core.include_dirs=None')
self.include_dirs += [os.path.join(self.src_root, core_name, d) for d in core.verilog.include_dirs]
self.src_files += [os.path.join(self.src_root, core_name, f) for f in core.verilog.src_files]
if core.vhdl:
self.vhdl_src_files += [os.path.join(self.src_root, core_name, f) for f in core.vhdl.src_files]
logger.debug('__init__() -Done-')
def configure(self):
logger.debug('configure() *Entered*')
if os.path.exists(self.work_root):
shutil.rmtree(self.work_root)
os.makedirs(self.work_root)
cm = CoreManager()
for name in self.cores:
pr_info("Preparing " + name)
core = cm.get_core(name)
dst_dir = os.path.join(Config().build_root, self.system.name, 'src', name)
core.setup()
core.export(dst_dir)
logger.debug('configure() -Done-')
def build(self, args):
for script in self.system.pre_build_scripts:
script = os.path.abspath(os.path.join(self.systems_root, self.system.name, script))
pr_info("Running " + script);
try:
Launcher(script, cwd = os.path.abspath(self.build_root), env = self.env, shell=True).run()
except RuntimeError:
print("Error: script " + script + " failed")
def done(self):
for script in self.system.post_build_scripts:
script = os.path.abspath(os.path.join(self.systems_root, self.system.name, script))
pr_info("Running " + script);
try:
Launcher(script, cwd = os.path.abspath(self.build_root), env = self.env, shell=True).run()
except RuntimeError:
print("Error: script " + script + " failed")
示例7: Simulator
# 需要导入模块: from fusesoc.coremanager import CoreManager [as 别名]
# 或者: from fusesoc.coremanager.CoreManager import get_core [as 别名]
class Simulator(object):
def __init__(self, system):
logger.debug('__init__() *Entered*')
config = Config()
self.system = system
self.build_root = os.path.join(config.build_root, self.system.name)
self.src_root = os.path.join(self.build_root, 'src')
if 'toplevel' in self.system.simulator:
self.toplevel = self.system.simulator['toplevel']
else:
self.toplevel = 'orpsoc_tb'
self.vpi_modules = []
self.cm = CoreManager()
self.cores = self.cm.get_depends(self.system.name)
logger.debug( "depend --> " +str (self.cores))
self.env = os.environ.copy()
self.env['CORE_ROOT'] = os.path.abspath(self.system.core_root)
self.env['BUILD_ROOT'] = os.path.abspath(self.build_root)
self.env['SIMULATOR'] = self.TOOL_NAME
self.verilog = _Verilog()
for core_name in self.cores:
logger.debug('core_name=' + core_name)
core = self.cm.get_core(core_name)
if core.verilog:
if core.verilog.include_dirs:
logger.debug('core.include_dirs=' + str(core.verilog.include_dirs))
else:
logger.debug('core.include_dirs=None')
self.verilog.include_dirs += [os.path.join(self.src_root, core_name, d) for d in core.verilog.include_dirs]
self.verilog.tb_include_dirs += [os.path.join(self.src_root, core_name, d) for d in core.verilog.tb_include_dirs]
self.verilog.src_files += [os.path.join(self.src_root, core_name, f) for f in core.verilog.src_files]
self.verilog.tb_src_files += [os.path.join(self.src_root, core_name, f) for f in core.verilog.tb_src_files]
if core_name == self.system.name:
self.verilog.tb_src_files += [os.path.join(self.src_root, core_name, f) for f in core.verilog.tb_private_src_files]
if core.vpi:
vpi_module = {}
core_root = os.path.join(self.src_root, core_name)
vpi_module['include_dirs'] = [os.path.abspath(os.path.join(core_root, d)) for d in core.vpi.include_dirs]
vpi_module['src_files'] = [os.path.abspath(os.path.join(core_root, f)) for f in core.vpi.src_files]
vpi_module['name'] = core.name
vpi_module['libs'] = [l for l in core.vpi.libs]
self.vpi_modules += [vpi_module]
logger.debug('__init__() -Done-')
def configure(self):
logger.debug('configure() *Entered*')
if os.path.exists(self.sim_root):
for f in os.listdir(self.sim_root):
if os.path.isdir(os.path.join(self.sim_root, f)):
shutil.rmtree(os.path.join(self.sim_root, f))
else:
os.remove(os.path.join(self.sim_root, f))
else:
os.makedirs(self.sim_root)
self.env['SIM_ROOT'] = os.path.abspath(self.sim_root)
for name in self.cores:
pr_info("Preparing " + name)
dst_dir = os.path.join(Config().build_root, self.system.name, 'src', name)
core = self.cm.get_core(name)
core.setup()
core.export(dst_dir)
logger.debug('configure() -Done-')
def build(self):
return
def run(self, args):
logger.debug('run() *Entered*')
parser = argparse.ArgumentParser(prog ='fusesoc sim '+self.system.name, conflict_handler='resolve')
for name in self.cores:
core = self.cm.get_core(name)
if core.plusargs:
core.plusargs.add_arguments(parser)
p = parser.parse_args(args)
self.plusargs = []
for key,value in vars(p).items():
if value == True:
self.plusargs += [key]
elif value == False or value is None:
pass
else:
self.plusargs += [key+'='+str(value[0])]
for script in self.system.pre_run_scripts:
script = os.path.abspath(os.path.join(self.system.core_root, script))
#.........这里部分代码省略.........
示例8: Backend
# 需要导入模块: from fusesoc.coremanager import CoreManager [as 别名]
# 或者: from fusesoc.coremanager.CoreManager import get_core [as 别名]
class Backend(object):
def __init__(self, system):
config = Config()
self.system = system
self.build_root = os.path.join(config.build_root, self.system.name)
self.system_root = system.system_root
self.src_root = os.path.join(self.build_root, 'src')
self.cm = CoreManager()
self.env = os.environ.copy()
self.env['SYSTEM_ROOT'] = os.path.abspath(self.system_root)
self.env['BUILD_ROOT'] = os.path.abspath(self.build_root)
self.env['BACKEND'] = self.TOOL_NAME
self.cores = self.cm.get_depends(self.system.name)
def _get_fileset_files(self, usage):
incdirs = set()
src_files = []
for core_name in self.cores:
core = self.cm.get_core(core_name)
basepath = os.path.relpath(os.path.join(self.src_root, core_name), self.work_root)
for fs in core.file_sets:
if (set(fs.usage) & set(usage)) and ((core_name == self.system.name) or not fs.private):
for file in fs.file:
if file.is_include_file:
incdirs.add(os.path.join(basepath, os.path.dirname(file.name)))
else:
file.name = os.path.join(basepath, file.name)
src_files.append(file)
return (src_files, incdirs)
def configure(self):
if os.path.exists(self.work_root):
shutil.rmtree(self.work_root)
os.makedirs(self.work_root)
cm = CoreManager()
for name in self.cores:
pr_info("Preparing " + name)
core = cm.get_core(name)
dst_dir = os.path.join(Config().build_root, self.system.name, 'src', name)
try:
core.setup()
except URLError as e:
raise RuntimeError("Problem while fetching '" + core.name + "': " + str(e.reason))
except HTTPError as e:
raise RuntimeError("Problem while fetching '" + core.name + "': " + str(e.reason))
core.export(dst_dir)
self._export_backend_files()
def _export_backend_files(self):
src_dir = self.system.system_root
dst_dir = os.path.join(self.src_root, self.system.name)
export_files = self.system.backend.export()
dirs = list(set(map(os.path.dirname, export_files)))
for d in dirs:
if not os.path.exists(os.path.join(dst_dir, d)):
os.makedirs(os.path.join(dst_dir, d))
for f in export_files:
if(os.path.exists(os.path.join(src_dir, f))):
shutil.copyfile(os.path.join(src_dir, f),
os.path.join(dst_dir, f))
else:
pr_warn("File " + os.path.join(src_dir, f) + " doesn't exist")
def build(self, args):
for script in self.system.pre_build_scripts:
script = os.path.abspath(os.path.join(self.system_root, script))
pr_info("Running " + script);
try:
Launcher(script, cwd = os.path.abspath(self.build_root), env = self.env, shell=True).run()
except RuntimeError:
print("Error: script " + script + " failed")
def done(self):
for script in self.system.post_build_scripts:
script = os.path.abspath(os.path.join(self.system_root, script))
pr_info("Running " + script);
try:
Launcher(script, cwd = os.path.abspath(self.build_root), env = self.env, shell=True).run()
except RuntimeError:
print("Error: script " + script + " failed")
示例9: Simulator
# 需要导入模块: from fusesoc.coremanager import CoreManager [as 别名]
# 或者: from fusesoc.coremanager.CoreManager import get_core [as 别名]
class Simulator(object):
def __init__(self, system):
config = Config()
self.system = system
self.build_root = os.path.join(config.build_root, self.system.name)
self.src_root = os.path.join(self.build_root, 'src')
if 'toplevel' in self.system.simulator:
self.toplevel = self.system.simulator['toplevel']
else:
self.toplevel = 'orpsoc_tb'
self.vpi_modules = []
self.cm = CoreManager()
self.cores = self.cm.get_depends(self.system.name)
logger.debug( "depend --> " +str (self.cores))
self.env = os.environ.copy()
self.env['CORE_ROOT'] = os.path.abspath(self.system.core_root)
self.env['BUILD_ROOT'] = os.path.abspath(self.build_root)
self.env['SIMULATOR'] = self.TOOL_NAME
self.verilog = _Verilog()
for core_name in self.cores:
logger.debug('core_name=' + core_name)
core = self.cm.get_core(core_name)
if core.verilog:
if core.verilog.include_dirs:
logger.debug('core.include_dirs=' + str(core.verilog.include_dirs))
else:
logger.debug('core.include_dirs=None')
self.verilog.include_dirs += [os.path.join(self.src_root, core_name, d) for d in core.verilog.include_dirs]
self.verilog.tb_include_dirs += [os.path.join(self.src_root, core_name, d) for d in core.verilog.tb_include_dirs]
self.verilog.src_files += [os.path.join(self.src_root, core_name, f) for f in core.verilog.src_files]
self.verilog.tb_src_files += [os.path.join(self.src_root, core_name, f) for f in core.verilog.tb_src_files]
if core_name == self.system.name:
self.verilog.tb_src_files += [os.path.join(self.src_root, core_name, f) for f in core.verilog.tb_private_src_files]
if core.vpi:
vpi_module = {}
core_root = os.path.join(self.src_root, core_name)
vpi_module['include_dirs'] = [os.path.abspath(os.path.join(core_root, d)) for d in core.vpi.include_dirs]
vpi_module['src_files'] = [os.path.abspath(os.path.join(core_root, f)) for f in core.vpi.src_files]
vpi_module['name'] = core.name
vpi_module['libs'] = [l for l in core.vpi.libs]
self.vpi_modules += [vpi_module]
def configure(self):
if os.path.exists(self.sim_root):
for f in os.listdir(self.sim_root):
if os.path.isdir(os.path.join(self.sim_root, f)):
shutil.rmtree(os.path.join(self.sim_root, f))
else:
os.remove(os.path.join(self.sim_root, f))
else:
os.makedirs(self.sim_root)
self.env['SIM_ROOT'] = os.path.abspath(self.sim_root)
for name in self.cores:
pr_info("Preparing " + name)
dst_dir = os.path.join(Config().build_root, self.system.name, 'src', name)
core = self.cm.get_core(name)
try:
core.setup()
except URLError as e:
raise RuntimeError("Problem while fetching '" + core.name + "': " + str(e.reason))
except HTTPError as e:
raise RuntimeError("Problem while fetching '" + core.name + "': " + str(e.reason))
core.export(dst_dir)
def build(self):
for core_name in self.cores:
core = self.cm.get_core(core_name)
if core.scripts:
run_scripts(core.scripts.pre_build_scripts,
core.core_root,
self.sim_root,
self.env)
return
def run(self, args):
typedict = {'bool' : {'action' : 'store_true'},
'file' : {'type' : str , 'nargs' : 1, 'action' : FileAction},
'int' : {'type' : int , 'nargs' : 1},
'str' : {'type' : str , 'nargs' : 1},
}
parser = argparse.ArgumentParser(prog ='fusesoc sim '+self.system.name, conflict_handler='resolve')
for name in self.cores:
core = self.cm.get_core(name)
if core.plusargs:
core.plusargs.add_arguments(parser)
for param_name, param in core.parameter.items():
if name == self.system.name or param.scope == 'public':
#.........这里部分代码省略.........
示例10: print
# 需要导入模块: from fusesoc.coremanager import CoreManager [as 别名]
# 或者: from fusesoc.coremanager.CoreManager import get_core [as 别名]
try:
cores = cm.get_depends(top_core)
except DependencyError as e:
print("'{}' or any of its dependencies requires '{}', but this core was not found".format(top_core, e.value))
exit(1)
#Hack 2. Disable for now. Should probably be hooked up to vunit_simulator
#CoreManager().tool = sim_name
#Iterate over cores, filesets and files and add all relevant sources files to vunit
incdirs = set()
src_files = []
#'usage' is a list of tags to look for in the filesets. Only look at filesets where any of these tags are present
usage = ['sim']
for core_name in cores:
core = cm.get_core(core_name)
core.setup()
basepath = core.files_root
for fs in core.file_sets:
if (set(fs.usage) & set(usage)) and ((core_name == top_core) or not fs.private):
for file in fs.file:
if file.is_include_file:
#TODO: incdirs not used right now
incdirs.add(os.path.join(basepath, os.path.dirname(file.name)))
else:
try:
vu.library(file.logical_name)
except KeyError:
vu.add_library(file.logical_name)
vu.add_source_file(os.path.join(basepath, file.name), file.logical_name)