opencos-eda 0.3.8__py3-none-any.whl → 0.3.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opencos/eda.py +62 -8
- opencos/eda_config_defaults.yml +14 -5
- opencos/tools/modelsim_ase.py +19 -378
- opencos/tools/questa.py +42 -247
- opencos/tools/questa_common.py +481 -0
- opencos/tools/questa_fe.py +84 -0
- opencos/tools/questa_fse.py +7 -8
- opencos/tools/riviera.py +27 -10
- opencos/utils/vsim_helper.py +8 -1
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.9.dist-info}/METADATA +2 -1
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.9.dist-info}/RECORD +16 -14
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.9.dist-info}/WHEEL +0 -0
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.9.dist-info}/entry_points.txt +0 -0
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.9.dist-info}/licenses/LICENSE +0 -0
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.9.dist-info}/licenses/LICENSE.spdx +0 -0
- {opencos_eda-0.3.8.dist-info → opencos_eda-0.3.9.dist-info}/top_level.txt +0 -0
opencos/eda.py
CHANGED
|
@@ -410,7 +410,8 @@ def process_tokens( # pylint: disable=too-many-branches,too-many-statements,too-
|
|
|
410
410
|
|
|
411
411
|
deferred_tokens = unparsed
|
|
412
412
|
if not command:
|
|
413
|
-
util.error("
|
|
413
|
+
util.error("'eda' didn't get a command, or command is invalid (run with --help to see",
|
|
414
|
+
"valid commands)!")
|
|
414
415
|
return 2
|
|
415
416
|
|
|
416
417
|
sco = config['command_handler'][command](config=config) # sub command object
|
|
@@ -430,7 +431,12 @@ def process_tokens( # pylint: disable=too-many-branches,too-many-statements,too-
|
|
|
430
431
|
command not in config.get('command_determines_tool', []) and \
|
|
431
432
|
command not in config.get('command_tool_is_optional', []):
|
|
432
433
|
use_tool = which_tool(command, config)
|
|
433
|
-
|
|
434
|
+
if use_tool:
|
|
435
|
+
util.info(f"--tool not specified, using default for {command=}: {use_tool}")
|
|
436
|
+
else:
|
|
437
|
+
# Not all commands have a hard requirement on tool (such as 'multi') because we
|
|
438
|
+
# haven't examined sub-commands yet.
|
|
439
|
+
util.info(f'--tool not specified, will attempt to determine tool(s) for {command=}.')
|
|
434
440
|
setattr(sco, 'auto_tool_applied', True)
|
|
435
441
|
|
|
436
442
|
rc = check_command_handler_cls(command_obj=sco, command=command, parsed_args=parsed)
|
|
@@ -483,12 +489,60 @@ def check_command_handler_cls(command_obj:object, command:str, parsed_args) -> i
|
|
|
483
489
|
if not isinstance(sco, cls):
|
|
484
490
|
# If someone set --tool verilator for command=synth, then our 'sco' will have defaulted
|
|
485
491
|
# to CommandSynth with no tool attached. If we don't have a tool set, error and return.
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
parsed_tool
|
|
490
|
-
|
|
491
|
-
|
|
492
|
+
parsed_tool = getattr(parsed_args, 'tool', '')
|
|
493
|
+
auto_tool_entry = command_obj.config.get(
|
|
494
|
+
'auto_tools_order', [{}])[0].get(parsed_tool, {})
|
|
495
|
+
if parsed_tool and not auto_tool_entry:
|
|
496
|
+
util.warning(
|
|
497
|
+
f"{command=} for tool '{parsed_tool}' is using handling class '{type(sco)}',",
|
|
498
|
+
f"but missing requirement {cls}, likely because the tool was not loaded",
|
|
499
|
+
"(not in PATH) or mis-configured (such as missing a Tool based class)"
|
|
500
|
+
)
|
|
501
|
+
return util.error(
|
|
502
|
+
f"EDA {command=} for tool '{parsed_tool}' cannot be run because tool",
|
|
503
|
+
f"'{parsed_tool}' is not known to `eda`. It does not exist in the config:",
|
|
504
|
+
"see informational message for --config-yml, and check that file's",
|
|
505
|
+
"auto_tools_order."
|
|
506
|
+
)
|
|
507
|
+
if parsed_tool:
|
|
508
|
+
util.warning(
|
|
509
|
+
f"{command=} for tool '{parsed_tool}' is using handling class '{type(sco)}',",
|
|
510
|
+
f"but missing requirement {cls}, likely because the tool was not loaded",
|
|
511
|
+
"(not in PATH) or mis-configured (such as missing a Tool based class)"
|
|
512
|
+
)
|
|
513
|
+
for k,v in auto_tool_entry.items():
|
|
514
|
+
if k == 'exe' or k.startswith('requires_cmd'):
|
|
515
|
+
util.warning(
|
|
516
|
+
f"tool '{parsed_tool}' has requirements that may not have been met --",
|
|
517
|
+
f"{k}: {v}"
|
|
518
|
+
)
|
|
519
|
+
if k == 'requires_vsim_helper':
|
|
520
|
+
if found_tool := vsim_helper.found():
|
|
521
|
+
util.warning(
|
|
522
|
+
f"tool '{parsed_tool}' was not found, vsim appears to be for tool",
|
|
523
|
+
f"'{found_tool}'"
|
|
524
|
+
)
|
|
525
|
+
|
|
526
|
+
return util.error(
|
|
527
|
+
f"EDA {command=} for tool '{parsed_tool}' is not supported (tool",
|
|
528
|
+
f"'{parsed_tool}' cannot run {command=}). It is likely that tool",
|
|
529
|
+
f"'{parsed_tool}' is not in PATH, or was unable to be loaded due to missing",
|
|
530
|
+
"requirements, or missing information when checking the exe version."
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
# No parsed_tool.
|
|
534
|
+
util.warning(
|
|
535
|
+
f"{command=} for default tool (--tool not set) is using handling class",
|
|
536
|
+
f"'{type(sco)}', but missing requirement {cls}, likely because the tool was not",
|
|
537
|
+
"loaded (not in PATH) or mis-configured (such as missing a Tool based class)"
|
|
538
|
+
)
|
|
539
|
+
return util.error(
|
|
540
|
+
f"EDA {command=} for default tool (--tool not set) is not supported (default",
|
|
541
|
+
f"tool cannot run {command=}). It appears that no suitable default tool to run",
|
|
542
|
+
f"{command=} was automatically found, was not in PATH, or was unable to be loaded",
|
|
543
|
+
"due to missing requirements, or missing information when checking the exe version."
|
|
544
|
+
)
|
|
545
|
+
|
|
492
546
|
return 0
|
|
493
547
|
|
|
494
548
|
|
opencos/eda_config_defaults.yml
CHANGED
|
@@ -510,7 +510,7 @@ auto_tools_order:
|
|
|
510
510
|
lec: opencos.tools.slang_yosys.CommandLecYosys
|
|
511
511
|
|
|
512
512
|
questa:
|
|
513
|
-
exe:
|
|
513
|
+
exe: vsim
|
|
514
514
|
requires_vsim_helper: True
|
|
515
515
|
handlers:
|
|
516
516
|
lint: opencos.tools.questa.CommandLintQuesta
|
|
@@ -528,13 +528,14 @@ auto_tools_order:
|
|
|
528
528
|
elab: opencos.tools.riviera.CommandElabRiviera
|
|
529
529
|
sim: opencos.tools.riviera.CommandSimRiviera
|
|
530
530
|
|
|
531
|
-
|
|
531
|
+
questa_fe:
|
|
532
532
|
exe: vsim
|
|
533
533
|
requires_vsim_helper: True
|
|
534
534
|
handlers:
|
|
535
|
-
lint: opencos.tools.
|
|
536
|
-
elab: opencos.tools.
|
|
537
|
-
sim:
|
|
535
|
+
lint: opencos.tools.questa_fe.CommandLintQuestaFe
|
|
536
|
+
elab: opencos.tools.questa_fe.CommandElabQuestaFe
|
|
537
|
+
sim: opencos.tools.questa_fe.CommandSimQuestaFe
|
|
538
|
+
flist: opencos.tools.questa_fe.CommandFListQuestaFe
|
|
538
539
|
|
|
539
540
|
questa_fse: # free student edition, works similar to modelsim_ase
|
|
540
541
|
exe: vsim
|
|
@@ -545,6 +546,14 @@ auto_tools_order:
|
|
|
545
546
|
sim: opencos.tools.questa_fse.CommandSimQuestaFse
|
|
546
547
|
flist: opencos.tools.questa_fse.CommandFListQuestaFse
|
|
547
548
|
|
|
549
|
+
modelsim_ase:
|
|
550
|
+
exe: vsim
|
|
551
|
+
requires_vsim_helper: True
|
|
552
|
+
handlers:
|
|
553
|
+
lint: opencos.tools.modelsim_ase.CommandLintModelsimAse
|
|
554
|
+
elab: opencos.tools.modelsim_ase.CommandElabModelsimAse
|
|
555
|
+
sim: opencos.tools.modelsim_ase.CommandSimModelsimAse
|
|
556
|
+
|
|
548
557
|
iverilog:
|
|
549
558
|
exe: iverilog
|
|
550
559
|
handlers:
|
opencos/tools/modelsim_ase.py
CHANGED
|
@@ -9,31 +9,29 @@ Note that this is for 32-bit Modelsim Student Edition. Consider using --tool=que
|
|
|
9
9
|
|
|
10
10
|
import os
|
|
11
11
|
|
|
12
|
-
from opencos import
|
|
13
|
-
from opencos.commands import sim, CommandSim
|
|
14
|
-
from opencos.tools.questa import ToolQuesta
|
|
15
|
-
from opencos.utils.str_helpers import sanitize_defines_for_sh
|
|
12
|
+
from opencos.tools.questa_common import CommonSimQuesta, CommonFListQuesta
|
|
16
13
|
|
|
17
|
-
class
|
|
18
|
-
'''
|
|
14
|
+
class CommandSimModelsimAse(CommonSimQuesta):
|
|
15
|
+
'''CommandSimModelsimAse is a command handler for: eda sim --tool=modelsim_ase'''
|
|
19
16
|
|
|
20
|
-
_TOOL = 'modelsim_ase'
|
|
17
|
+
_TOOL = 'modelsim_ase'
|
|
21
18
|
_EXE = 'vsim'
|
|
22
19
|
use_vopt = False
|
|
23
20
|
|
|
24
|
-
class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
|
|
25
|
-
'''CommandSimModelsimAse is a command handler for: eda sim --tool=modelsim_ase'''
|
|
26
|
-
|
|
27
21
|
def __init__(self, config: dict):
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
CommonSimQuesta.__init__(self, config=config)
|
|
23
|
+
|
|
24
|
+
# repairs: override self._TOOL, and run get_versions() again.
|
|
25
|
+
self._TOOL = 'modelsim_ase'
|
|
26
|
+
|
|
30
27
|
self.shell_command = os.path.join(self.sim_exe_base_path, 'vsim')
|
|
31
28
|
self.starter_edition = True
|
|
32
29
|
self.args.update({
|
|
33
30
|
'tool': self._TOOL, # override
|
|
34
31
|
'gui': False,
|
|
35
|
-
'vopt': self.use_vopt,
|
|
36
32
|
})
|
|
33
|
+
|
|
34
|
+
|
|
37
35
|
self.args_help.update({
|
|
38
36
|
'vopt': (
|
|
39
37
|
'Boolean to enable/disable use of vopt step prior to vsim step'
|
|
@@ -53,371 +51,6 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
|
|
|
53
51
|
)
|
|
54
52
|
)
|
|
55
53
|
|
|
56
|
-
def run_in_batch_mode(self) -> bool:
|
|
57
|
-
'''Returns bool if we should run in batch mode (-c) from command line'''
|
|
58
|
-
# TODO(drew): make CommandSimQuesta a parent and inherit this method instead.
|
|
59
|
-
if self.args['test-mode']:
|
|
60
|
-
return True
|
|
61
|
-
if self.args['gui']:
|
|
62
|
-
return False
|
|
63
|
-
return True
|
|
64
|
-
|
|
65
|
-
# We do override do_it() to avoid using CommandSimQuesta.do_it()
|
|
66
|
-
def do_it(self):
|
|
67
|
-
CommandSim.do_it(self)
|
|
68
|
-
# self.compile() # runs if stop-before-compile is False, stop-after-compile is True
|
|
69
|
-
# self.elaborate() # runs if stop-before-compile is False, stop-after-compile is False,
|
|
70
|
-
# stop-after-elaborate is True
|
|
71
|
-
# self.simulate() # runs if stop-* are all False (run the whole thing)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def prepare_compile(self):
|
|
75
|
-
self.set_tool_defines()
|
|
76
|
-
self.write_vlog_dot_f()
|
|
77
|
-
self.write_vsim_dot_do(dot_do_to_write='all')
|
|
78
|
-
|
|
79
|
-
vsim_command_lists = self.get_compile_command_lists()
|
|
80
|
-
util.write_shell_command_file(
|
|
81
|
-
dirpath=self.args['work-dir'],
|
|
82
|
-
filename='compile_only.sh',
|
|
83
|
-
command_lists=vsim_command_lists
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
vsim_command_lists = self.get_elaborate_command_lists()
|
|
87
|
-
util.write_shell_command_file(
|
|
88
|
-
dirpath=self.args['work-dir'],
|
|
89
|
-
filename='compile_elaborate_only.sh',
|
|
90
|
-
command_lists=vsim_command_lists
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
# Write simulate.sh and all.sh to work-dir:
|
|
94
|
-
vsim_command_lists = self.get_simulate_command_lists()
|
|
95
|
-
self.write_sh_scripts_to_work_dir(
|
|
96
|
-
compile_lists=[], elaborate_lists=[], simulate_lists=vsim_command_lists
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
def compile(self):
|
|
100
|
-
if self.args['stop-before-compile']:
|
|
101
|
-
# don't run anything, save everyting we've already run in _prep_compile()
|
|
102
|
-
return
|
|
103
|
-
if self.args['stop-after-compile']:
|
|
104
|
-
vsim_command_lists = self.get_compile_command_lists()
|
|
105
|
-
self.run_commands_check_logs(vsim_command_lists, log_filename='sim.log',
|
|
106
|
-
must_strings=['Errors: 0'], use_must_strings=False)
|
|
107
|
-
|
|
108
|
-
def elaborate(self):
|
|
109
|
-
if self.args['stop-before-compile']:
|
|
110
|
-
return
|
|
111
|
-
if self.args['stop-after-compile']:
|
|
112
|
-
return
|
|
113
|
-
if self.args['stop-after-elaborate']:
|
|
114
|
-
# only run this if we stop after elaborate (simulate run it all)
|
|
115
|
-
vsim_command_lists = self.get_elaborate_command_lists()
|
|
116
|
-
self.run_commands_check_logs(vsim_command_lists, log_filename='sim.log')
|
|
117
|
-
|
|
118
|
-
def simulate(self):
|
|
119
|
-
if self.args['stop-before-compile'] or self.args['stop-after-compile'] or \
|
|
120
|
-
self.args['stop-after-elaborate']:
|
|
121
|
-
# don't run this if we're stopping before/after compile/elab
|
|
122
|
-
return
|
|
123
|
-
vsim_command_lists = self.get_simulate_command_lists()
|
|
124
|
-
self.run_commands_check_logs(vsim_command_lists, log_filename='sim.log')
|
|
125
|
-
|
|
126
|
-
def get_compile_command_lists(self, **kwargs) -> list:
|
|
127
|
-
# This will also set up a compile.
|
|
128
|
-
vsim_command_list = [
|
|
129
|
-
self.sim_exe,
|
|
130
|
-
'-c' if self.run_in_batch_mode() else '',
|
|
131
|
-
'-do', 'vsim_vlogonly.do', '-logfile', 'sim.log',
|
|
132
|
-
]
|
|
133
|
-
return [vsim_command_list]
|
|
134
|
-
|
|
135
|
-
def get_elaborate_command_lists(self, **kwargs) -> list:
|
|
136
|
-
# This will also set up a compile, for vlog + vsim (0 time)
|
|
137
|
-
vsim_command_list = [
|
|
138
|
-
self.sim_exe,
|
|
139
|
-
'-c' if self.run_in_batch_mode() else '',
|
|
140
|
-
'-do', 'vsim_lintonly.do', '-logfile', 'sim.log',
|
|
141
|
-
]
|
|
142
|
-
return [vsim_command_list]
|
|
143
|
-
|
|
144
|
-
def get_simulate_command_lists(self, **kwargs) -> list:
|
|
145
|
-
# This will also set up a compile, for vlog + vsim (with run -a)
|
|
146
|
-
vsim_command_list = [
|
|
147
|
-
self.sim_exe,
|
|
148
|
-
'-c' if self.run_in_batch_mode() else '',
|
|
149
|
-
'-do', 'vsim.do', '-logfile', 'sim.log',
|
|
150
|
-
]
|
|
151
|
-
return [vsim_command_list]
|
|
152
|
-
|
|
153
|
-
def get_post_simulate_command_lists(self, **kwargs) -> list:
|
|
154
|
-
return []
|
|
155
|
-
|
|
156
|
-
def write_vlog_dot_f(self, filename='vlog.f') -> None:
|
|
157
|
-
'''Returns none, creates filename (str) for a vlog.f'''
|
|
158
|
-
vlog_dot_f_lines = []
|
|
159
|
-
|
|
160
|
-
# Add compile args from config.tool.modelsim_ase:
|
|
161
|
-
vlog_dot_f_lines += self.tool_config.get(
|
|
162
|
-
'compile-args',
|
|
163
|
-
'-sv -svinputport=net -lint').split()
|
|
164
|
-
# Add waivers from config.tool.modelsim_ase:
|
|
165
|
-
for waiver in self.tool_config.get(
|
|
166
|
-
'compile-waivers',
|
|
167
|
-
[ #defaults:
|
|
168
|
-
'2275', # 2275 - Existing package 'foo_pkg' will be overwritten.
|
|
169
|
-
]) + self.args['compile-waivers']:
|
|
170
|
-
vlog_dot_f_lines += ['-suppress', str(waiver)]
|
|
171
|
-
|
|
172
|
-
if self.args['gui'] or self.args['waves']:
|
|
173
|
-
vlog_dot_f_lines += self.tool_config.get('compile-waves-args', '').split()
|
|
174
|
-
|
|
175
|
-
vlog_dot_f_fname = filename
|
|
176
|
-
vlog_dot_f_fpath = os.path.join(self.args['work-dir'], vlog_dot_f_fname)
|
|
177
|
-
|
|
178
|
-
for value in self.incdirs:
|
|
179
|
-
vlog_dot_f_lines += [ f"+incdir+{value}" ]
|
|
180
|
-
|
|
181
|
-
for k,v in self.defines.items():
|
|
182
|
-
if v is None:
|
|
183
|
-
vlog_dot_f_lines += [ f'+define+{k}' ]
|
|
184
|
-
else:
|
|
185
|
-
|
|
186
|
-
# if the value v is a double-quoted string, such as v='"hi"', the
|
|
187
|
-
# entire +define+NAME="hi" needs to wrapped in double quotes with the
|
|
188
|
-
# value v double-quotes escaped: "+define+NAME=\"hi\""
|
|
189
|
-
if isinstance(v, str) and v.startswith('"') and v.endswith('"'):
|
|
190
|
-
str_v = v.replace('"', '\\"')
|
|
191
|
-
vlog_dot_f_lines += [ f'"+define+{k}={str_v}"' ]
|
|
192
|
-
else:
|
|
193
|
-
# Generally we should only support int and str python types passed as
|
|
194
|
-
# +define+{k}={v}, but also for SystemVerilog plusargs
|
|
195
|
-
vlog_dot_f_lines += [ f'+define+{k}={sanitize_defines_for_sh(v)}' ]
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
vlog_dot_f_lines += self.args['compile-args']
|
|
199
|
-
|
|
200
|
-
vlog_dot_f_lines += [
|
|
201
|
-
'-source',
|
|
202
|
-
] + list(self.files_sv) + list(self.files_v)
|
|
203
|
-
|
|
204
|
-
if not self.files_sv and not self.files_v:
|
|
205
|
-
if not self.args['stop-before-compile']:
|
|
206
|
-
self.error(f'{self.target=} {self.files_sv=} and {self.files_v=} are empty,',
|
|
207
|
-
'cannot create a valid vlog.f')
|
|
208
|
-
|
|
209
|
-
with open(vlog_dot_f_fpath, 'w', encoding='utf-8') as f:
|
|
210
|
-
f.writelines(line + "\n" for line in vlog_dot_f_lines)
|
|
211
|
-
|
|
212
|
-
def vopt_handle_parameters(self) -> (str, list):
|
|
213
|
-
'''Returns str for vopt or voptargs, and list of vopt tcl
|
|
214
|
-
|
|
215
|
-
Note this is used for self.use_vopt = True or False.
|
|
216
|
-
'''
|
|
217
|
-
|
|
218
|
-
voptargs_str = ''
|
|
219
|
-
vopt_do_lines = []
|
|
220
|
-
|
|
221
|
-
# Note that if self.use_vopt=True, we have to do some workarounds for how
|
|
222
|
-
# some questa-like tools behave for: tcl/.do + vopt arg processing
|
|
223
|
-
# This affects string based parameters that have spaces (vopt treats spaces unique args,
|
|
224
|
-
# vsim does not). Since we'd like to keep the vopt/vsim split into separate steps, we can
|
|
225
|
-
# work around this by setting tcl varaibles for each parameter.
|
|
226
|
-
if self.parameters:
|
|
227
|
-
if not self.use_vopt:
|
|
228
|
-
voptargs_str += ' ' + ' '.join(self.process_parameters_get_list(arg_prefix='-G'))
|
|
229
|
-
else:
|
|
230
|
-
for k,v in self.parameters.items():
|
|
231
|
-
s = sim.parameters_dict_get_command_list(params={k: v}, arg_prefix='')[0]
|
|
232
|
-
# At this point, s should be a str in form {k}={v}
|
|
233
|
-
if not s or '=' not in s:
|
|
234
|
-
continue
|
|
235
|
-
if ' ' in s:
|
|
236
|
-
# Instead of:
|
|
237
|
-
# vopt -GMyParam="hi bye"
|
|
238
|
-
# we'll do:
|
|
239
|
-
# set PARAMETERS(MyParam) "hi bye"
|
|
240
|
-
# vopt -GMyParam=$PARAMETERS(MyParam)
|
|
241
|
-
s = s.replace(f'{k}=', f'set PARAMETERS({k}) ')
|
|
242
|
-
vopt_do_lines.append(s)
|
|
243
|
-
voptargs_str += f' -G{k}=$PARAMETERS({k}) '
|
|
244
|
-
else:
|
|
245
|
-
voptargs_str += f' -G{s} '
|
|
246
|
-
|
|
247
|
-
return voptargs_str, vopt_do_lines
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
def write_vsim_dot_do( # pylint: disable=too-many-locals
|
|
251
|
-
self, dot_do_to_write: list
|
|
252
|
-
) -> None:
|
|
253
|
-
'''Writes files(s) based on dot_do_to_write(list of str)
|
|
254
|
-
|
|
255
|
-
list arg values can be empty (all) or have items 'all', 'sim', 'lint', 'vlog'.'''
|
|
256
|
-
|
|
257
|
-
vsim_dot_do_fpath = os.path.join(self.args['work-dir'], 'vsim.do')
|
|
258
|
-
vsim_lintonly_dot_do_fpath = os.path.join(self.args['work-dir'], 'vsim_lintonly.do')
|
|
259
|
-
vsim_vlogonly_dot_do_fpath = os.path.join(self.args['work-dir'], 'vsim_vlogonly.do')
|
|
260
|
-
|
|
261
|
-
sim_plusargs_str = self._get_sim_plusargs_str()
|
|
262
|
-
vsim_suppress_list_str = self._get_vsim_suppress_list_str()
|
|
263
|
-
vsim_ext_args = ' '.join(self.args.get('sim-args', []))
|
|
264
|
-
|
|
265
|
-
voptargs_str = self.tool_config.get('elab-args', '')
|
|
266
|
-
voptargs_str += ' '.join(self.args.get('elab-args', []))
|
|
267
|
-
if self.args['gui'] or self.args['waves']:
|
|
268
|
-
voptargs_str += ' ' + self.tool_config.get('simulate-waves-args', '+acc')
|
|
269
|
-
util.artifacts.add_extension(
|
|
270
|
-
search_paths=self.args['work-dir'], file_extension='wlf',
|
|
271
|
-
typ='waveform', description='Modelsim/Questa Waveform WLF (Wave Log Format) file'
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
# TODO(drew): support self.args['sim_libary'] (1 lists)
|
|
275
|
-
vlog_do_lines = []
|
|
276
|
-
vsim_do_lines = []
|
|
277
|
-
|
|
278
|
-
# parameters, use helper method to get voptargs_str and vopt_do_lines
|
|
279
|
-
more_voptargs_str, vopt_do_lines = self.vopt_handle_parameters()
|
|
280
|
-
voptargs_str += more_voptargs_str
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
vopt_one_liner = ""
|
|
284
|
-
if self.use_vopt:
|
|
285
|
-
vopt_one_liner = (
|
|
286
|
-
f"vopt {voptargs_str} work.{self.args['top']} -o opt__{self.args['top']}"
|
|
287
|
-
)
|
|
288
|
-
vopt_one_liner = vopt_one_liner.replace('\n', ' ') # needs to be a one-liner
|
|
289
|
-
# vopt doesn't need -voptargs=(value) like vsim does, simply use (value).
|
|
290
|
-
vopt_one_liner = vopt_one_liner.replace('-voptargs=', '')
|
|
291
|
-
|
|
292
|
-
vsim_one_liner = "vsim -onfinish stop" \
|
|
293
|
-
+ f" -sv_seed {self.args['seed']} {sim_plusargs_str} {vsim_suppress_list_str}" \
|
|
294
|
-
+ f" {vsim_ext_args} opt__{self.args['top']}"
|
|
295
|
-
else:
|
|
296
|
-
# vopt doesn't exist, use single vsim call after vlog call:
|
|
297
|
-
vsim_one_liner = "vsim -onfinish stop" \
|
|
298
|
-
+ f" -sv_seed {self.args['seed']} {sim_plusargs_str} {vsim_suppress_list_str}" \
|
|
299
|
-
+ f" {voptargs_str} {vsim_ext_args} work.{self.args['top']}"
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
vsim_one_liner = vsim_one_liner.replace('\n', ' ')
|
|
303
|
-
|
|
304
|
-
vlog_do_lines += [
|
|
305
|
-
"if {[file exists work]} { vdel -all work; }",
|
|
306
|
-
"vlib work;",
|
|
307
|
-
"quietly set qc 30;",
|
|
308
|
-
"if {[catch {vlog -f vlog.f} result]} {",
|
|
309
|
-
" echo \"Caught $result \";",
|
|
310
|
-
" if {[batch_mode]} {",
|
|
311
|
-
" quit -f -code 20;",
|
|
312
|
-
" }",
|
|
313
|
-
"}",
|
|
314
|
-
]
|
|
315
|
-
|
|
316
|
-
if self.use_vopt:
|
|
317
|
-
vopt_do_lines += [
|
|
318
|
-
"if {[catch { " + vopt_one_liner + " } result] } {",
|
|
319
|
-
" echo \"Caught $result\";",
|
|
320
|
-
" if {[batch_mode]} {",
|
|
321
|
-
" quit -f -code 19;",
|
|
322
|
-
" }",
|
|
323
|
-
"}",
|
|
324
|
-
]
|
|
325
|
-
|
|
326
|
-
vsim_do_lines += [
|
|
327
|
-
"if {[catch { " + vsim_one_liner + " } result] } {",
|
|
328
|
-
" echo \"Caught $result\";",
|
|
329
|
-
" if {[batch_mode]} {",
|
|
330
|
-
" quit -f -code 18;",
|
|
331
|
-
" }",
|
|
332
|
-
"}",
|
|
333
|
-
]
|
|
334
|
-
|
|
335
|
-
vsim_vlogonly_dot_do_lines = vlog_do_lines + [
|
|
336
|
-
"if {[batch_mode]} {",
|
|
337
|
-
" quit -f -code 0;",
|
|
338
|
-
"}",
|
|
339
|
-
]
|
|
340
|
-
|
|
341
|
-
final_check_teststatus_do_lines = [
|
|
342
|
-
"set TestStatus [coverage attribute -name SEED -name TESTSTATUS];",
|
|
343
|
-
"if {[regexp \"TESTSTATUS += 0\" $TestStatus]} {",
|
|
344
|
-
" quietly set qc 0;",
|
|
345
|
-
"} elseif {[regexp \"TESTSTATUS += 1\" $TestStatus]} {",
|
|
346
|
-
" quietly set qc 0;",
|
|
347
|
-
"} else {",
|
|
348
|
-
" quietly set qc 2;",
|
|
349
|
-
"}",
|
|
350
|
-
"if {[batch_mode]} {",
|
|
351
|
-
" quit -f -code $qc;",
|
|
352
|
-
"}",
|
|
353
|
-
]
|
|
354
|
-
|
|
355
|
-
# final vlog/vopt/vsim lint-only .do command (want to make sure it can completely
|
|
356
|
-
# build for 'elab' style eda job), runs for 0ns, logs nothing for a waveform, quits
|
|
357
|
-
vsim_lintonly_dot_do_lines = vlog_do_lines + vopt_do_lines + vsim_do_lines \
|
|
358
|
-
+ final_check_teststatus_do_lines
|
|
359
|
-
|
|
360
|
-
# final vlog/opt/vsim full simulation .do command.
|
|
361
|
-
vsim_dot_do_lines = vlog_do_lines + vopt_do_lines + vsim_do_lines + [
|
|
362
|
-
"onbreak { resume; };",
|
|
363
|
-
"catch {log -r *};",
|
|
364
|
-
"run -a;",
|
|
365
|
-
] + final_check_teststatus_do_lines
|
|
366
|
-
|
|
367
|
-
write_all = len(dot_do_to_write) == 0 or 'all' in dot_do_to_write
|
|
368
|
-
if write_all or 'sim' in dot_do_to_write:
|
|
369
|
-
with open(vsim_dot_do_fpath, 'w', encoding='utf-8') as f:
|
|
370
|
-
f.writelines(line + "\n" for line in vsim_dot_do_lines)
|
|
371
|
-
|
|
372
|
-
if write_all or 'lint' in dot_do_to_write:
|
|
373
|
-
with open(vsim_lintonly_dot_do_fpath, 'w', encoding='utf-8') as f:
|
|
374
|
-
f.writelines(line + "\n" for line in vsim_lintonly_dot_do_lines)
|
|
375
|
-
|
|
376
|
-
if write_all or 'vlog' in dot_do_to_write:
|
|
377
|
-
with open(vsim_vlogonly_dot_do_fpath, 'w', encoding='utf-8') as f:
|
|
378
|
-
f.writelines(line + "\n" for line in vsim_vlogonly_dot_do_lines)
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
def _get_sim_plusargs_str(self) -> str:
|
|
382
|
-
sim_plusargs = []
|
|
383
|
-
|
|
384
|
-
assert isinstance(self.args["sim-plusargs"], list), \
|
|
385
|
-
f'{self.target=} {type(self.args["sim-plusargs"])=} but must be list'
|
|
386
|
-
|
|
387
|
-
for x in self.args['sim-plusargs']:
|
|
388
|
-
# For vsim we need to add a +key=value if the + is missing
|
|
389
|
-
if x[0] != '+':
|
|
390
|
-
x = f'+{x}'
|
|
391
|
-
sim_plusargs.append(x)
|
|
392
|
-
|
|
393
|
-
return ' '.join(sim_plusargs)
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
def _get_vsim_suppress_list_str(self) -> str:
|
|
397
|
-
vsim_suppress_list = []
|
|
398
|
-
# Add waivers from config.tool.modelsim_ase:
|
|
399
|
-
for waiver in self.tool_config.get(
|
|
400
|
-
'simulate-waivers', [
|
|
401
|
-
#defaults:
|
|
402
|
-
'3009', # 3009: [TSCALE] - Module 'foo' does not have a timeunit/timeprecision
|
|
403
|
-
# specification in effect, but other modules do.
|
|
404
|
-
]) + self.args['sim-waivers']:
|
|
405
|
-
vsim_suppress_list += ['-suppress', str(waiver)]
|
|
406
|
-
|
|
407
|
-
return ' '.join(vsim_suppress_list)
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
def artifacts_add(self, name: str, typ: str, description: str) -> None:
|
|
411
|
-
'''Override from Command.artifacts_add, so we can catch known file
|
|
412
|
-
|
|
413
|
-
names to make their typ/description better, such as CommandSim using
|
|
414
|
-
sim.log
|
|
415
|
-
'''
|
|
416
|
-
_, leafname = os.path.split(name)
|
|
417
|
-
if leafname == 'sim.log':
|
|
418
|
-
description = 'Modelsim/Questa Transcript log file'
|
|
419
|
-
|
|
420
|
-
super().artifacts_add(name=name, typ=typ, description=description)
|
|
421
54
|
|
|
422
55
|
|
|
423
56
|
class CommandElabModelsimAse(CommandSimModelsimAse):
|
|
@@ -439,3 +72,11 @@ class CommandLintModelsimAse(CommandSimModelsimAse):
|
|
|
439
72
|
super().__init__(config)
|
|
440
73
|
self.args['stop-after-compile'] = True
|
|
441
74
|
self.args['stop-after-elaborate'] = True
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class CommandFListModelsimAse(CommonFListQuesta):
|
|
78
|
+
'''CommandFListModelsimAse is a command handler for: eda flist --tool=modelsim_ase'''
|
|
79
|
+
|
|
80
|
+
def __init__(self, config: dict):
|
|
81
|
+
CommonFListQuesta.__init__(self, config=config)
|
|
82
|
+
self._TOOL = 'questa_fse'
|