Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def abort_handler(signal, frame):
print('');
pr_info('****************************')
pr_info('**** FuseSoC aborted ****')
pr_info('****************************')
print('');
sys.exit(0)
def _checkout(self):
pr_info("Using Xilinx Vivado to generate LogiCORE(tm) project " + self.project_file)
if not os.path.isdir(self.files_root):
os.mkdir(self.files_root)
src_files = [self.script_file, self.project_file]
if self.extra_files:
src_files += self.extra_files.split()
for f in src_files:
f_src = os.path.join(self.core_root, f)
f_dst = os.path.join(self.files_root, f)
if(os.path.exists(f_src)):
shutil.copyfile(f_src, f_dst)
else:
pr_err('Cannot find file %s' % f_src)
args = ['-mode', 'batch',
'-source', self.script_file]
Launcher('vivado', args, cwd=self.files_root).run()
def _checkout(self, local_dir):
#TODO : Sanitize URL
url = URL.format(user=self.user,
repo=self.repo,
version=self.version)
pr_info("Downloading {}/{} from github".format(self.user,
self.repo))
try:
(filename, headers) = urllib.urlretrieve(url)
except URLError as e:
raise RuntimeError("Failed to download '{}'. '{}'".format(url, e.reason))
t = tarfile.open(filename)
(cache_root, core) = os.path.split(local_dir)
#Ugly hack to get the first part of the directory name of the extracted files
tmp = t.getnames()[0]
t.extractall(cache_root)
os.rename(os.path.join(cache_root, tmp),
os.path.join(cache_root, core))
def _checkout(self, local_dir, core_name):
pr_info("Checking out " + self.url + " to " + local_dir)
try:
(filename, headers) = urllib.urlretrieve(self.url)
except URLError:
raise
except HTTPError:
raise
(cache_root, core) = os.path.split(local_dir)
if self.filetype == 'tar':
t = tarfile.open(filename)
t.extractall(local_dir)
elif self.filetype == 'zip':
with zipfile.ZipFile(filename, "r") as z:
z.extractall(local_dir)
elif self.filetype == 'simple':
def build(self, args):
for script in self.system.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 run(self, args):
fusesoc_cli_parser = (self.system.verilator.cli_parser == 'fusesoc')
super(Verilator, self).run(args)
if fusesoc_cli_parser:
_args = []
for key, value in self.plusarg.items():
_args += ['+{}={}'.format(key, value)]
for key, value in self.cmdlinearg.items():
_args += ['--{}={}'.format(key, value)]
else:
_args = args
pr_info("Running simulation")
utils.Launcher('./V' + self.system.verilator.top_module,
_args,
cwd=self.work_root,
env = self.env).run()
def _checkout(self, local_dir):
pr_info("Downloading " + self.repo_name + " from OpenCores")
Launcher('svn', ['co', '-q', '--no-auth-cache',
'-r', self.revision_number,
'--username', 'orpsoc',
'--password', 'orpsoc',
self.repo_path,
local_dir]).run()
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 _checkout(self, local_dir):
#TODO : Sanitize URL
pr_info("Checking out " + self.repo + " to " + local_dir)
args = ['clone', '-q', self.repo, local_dir]
Launcher('git', args).run()
if self.version:
args = ['-C', local_dir, 'checkout', '-q', self.version]
Launcher('git', args).run()
def build(self):
super(Verilator, self).build()
pr_info("Building simulation model")
if not os.getenv('VERILATOR_ROOT') and not utils.which('verilator'):
raise RuntimeError("VERILATOR_ROOT not set and there is no verilator program in your PATH")
# Do parallel builds with * 2 jobs.
make_job_count = multiprocessing.cpu_count() * 2
_s = os.path.join(self.work_root, 'verilator.{}.log')
l = utils.Launcher('make',
['-j', str(make_job_count)],
cwd=self.work_root,
stderr = open(_s.format('err'),'w'),
stdout = open(_s.format('out'),'w')).run()