opencos-eda 0.2.52__py3-none-any.whl → 0.2.54__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.
Files changed (44) hide show
  1. opencos/commands/__init__.py +2 -0
  2. opencos/commands/build.py +1 -1
  3. opencos/commands/deps_help.py +259 -0
  4. opencos/commands/export.py +1 -1
  5. opencos/commands/flist.py +4 -1
  6. opencos/commands/lec.py +1 -1
  7. opencos/commands/open.py +2 -0
  8. opencos/commands/proj.py +1 -1
  9. opencos/commands/shell.py +1 -1
  10. opencos/commands/sim.py +76 -8
  11. opencos/commands/synth.py +1 -1
  12. opencos/commands/upload.py +3 -0
  13. opencos/commands/waves.py +1 -0
  14. opencos/deps/defaults.py +1 -0
  15. opencos/deps/deps_file.py +30 -4
  16. opencos/deps/deps_processor.py +72 -2
  17. opencos/deps_schema.py +3 -0
  18. opencos/eda.py +50 -26
  19. opencos/eda_base.py +177 -33
  20. opencos/eda_config.py +1 -1
  21. opencos/eda_config_defaults.yml +49 -3
  22. opencos/eda_extract_targets.py +1 -58
  23. opencos/tests/helpers.py +16 -0
  24. opencos/tests/test_eda.py +14 -3
  25. opencos/tests/test_tools.py +159 -132
  26. opencos/tools/cocotb.py +15 -14
  27. opencos/tools/iverilog.py +4 -24
  28. opencos/tools/modelsim_ase.py +70 -57
  29. opencos/tools/quartus.py +680 -0
  30. opencos/tools/questa.py +158 -90
  31. opencos/tools/questa_fse.py +10 -0
  32. opencos/tools/riviera.py +1 -0
  33. opencos/tools/verilator.py +9 -15
  34. opencos/tools/vivado.py +30 -23
  35. opencos/util.py +89 -15
  36. opencos/utils/status_constants.py +1 -0
  37. opencos/utils/str_helpers.py +85 -0
  38. {opencos_eda-0.2.52.dist-info → opencos_eda-0.2.54.dist-info}/METADATA +1 -1
  39. {opencos_eda-0.2.52.dist-info → opencos_eda-0.2.54.dist-info}/RECORD +44 -42
  40. {opencos_eda-0.2.52.dist-info → opencos_eda-0.2.54.dist-info}/WHEEL +0 -0
  41. {opencos_eda-0.2.52.dist-info → opencos_eda-0.2.54.dist-info}/entry_points.txt +0 -0
  42. {opencos_eda-0.2.52.dist-info → opencos_eda-0.2.54.dist-info}/licenses/LICENSE +0 -0
  43. {opencos_eda-0.2.52.dist-info → opencos_eda-0.2.54.dist-info}/licenses/LICENSE.spdx +0 -0
  44. {opencos_eda-0.2.52.dist-info → opencos_eda-0.2.54.dist-info}/top_level.txt +0 -0
@@ -19,6 +19,7 @@ class ToolModelsimAse(ToolQuesta):
19
19
 
20
20
  _TOOL = 'modelsim_ase' # otherwise it's 'questa' from base class.
21
21
  _EXE = 'vsim'
22
+ use_vopt = False
22
23
 
23
24
  class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
24
25
  '''CommandSimModelsimAse is a command handler for: eda sim --tool=modelsim_ase'''
@@ -44,6 +45,15 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
44
45
  )
45
46
  )
46
47
 
48
+ def run_in_batch_mode(self) -> bool:
49
+ '''Returns bool if we should run in batch mode (-c) from command line'''
50
+ # TODO(drew): make CommandSimQuesta a parent and inherit this method instead.
51
+ if self.args['test-mode']:
52
+ return True
53
+ if self.args['gui']:
54
+ return False
55
+ return True
56
+
47
57
  # We do override do_it() to avoid using CommandSimQuesta.do_it()
48
58
  def do_it(self):
49
59
  CommandSim.do_it(self)
@@ -72,15 +82,12 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
72
82
  command_lists=vsim_command_lists
73
83
  )
74
84
 
85
+ # Write simulate.sh and all.sh to work-dir:
75
86
  vsim_command_lists = self.get_simulate_command_lists()
76
- util.write_shell_command_file(
77
- dirpath=self.args['work-dir'],
78
- filename='all.sh',
79
- command_lists = [['./pre_compile_dep_shell_commands.sh']] + vsim_command_lists
87
+ self.write_sh_scripts_to_work_dir(
88
+ compile_lists=[], elaborate_lists=[], simulate_lists=vsim_command_lists
80
89
  )
81
90
 
82
- self.write_eda_config_and_args()
83
-
84
91
  def compile(self):
85
92
  if self.args['stop-before-compile']:
86
93
  # don't run anything, save everyting we've already run in _prep_compile()
@@ -111,7 +118,7 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
111
118
  # This will also set up a compile.
112
119
  vsim_command_list = [
113
120
  self.sim_exe,
114
- '' if self.args['gui'] else '-c',
121
+ '-c' if self.run_in_batch_mode() else '',
115
122
  '-do', 'vsim_vlogonly.do', '-logfile', 'sim.log',
116
123
  ]
117
124
  return [vsim_command_list]
@@ -120,7 +127,7 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
120
127
  # This will also set up a compile, for vlog + vsim (0 time)
121
128
  vsim_command_list = [
122
129
  self.sim_exe,
123
- '' if self.args['gui'] else '-c',
130
+ '-c' if self.run_in_batch_mode() else '',
124
131
  '-do', 'vsim_lintonly.do', '-logfile', 'sim.log',
125
132
  ]
126
133
  return [vsim_command_list]
@@ -129,7 +136,7 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
129
136
  # This will also set up a compile, for vlog + vsim (with run -a)
130
137
  vsim_command_list = [
131
138
  self.sim_exe,
132
- '' if self.args['gui'] else '-c',
139
+ '-c' if self.run_in_batch_mode() else '',
133
140
  '-do', 'vsim.do', '-logfile', 'sim.log',
134
141
  ]
135
142
  return [vsim_command_list]
@@ -193,7 +200,9 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
193
200
  with open(vlog_dot_f_fpath, 'w', encoding='utf-8') as f:
194
201
  f.writelines(line + "\n" for line in vlog_dot_f_lines)
195
202
 
196
- def write_vsim_dot_do(self, dot_do_to_write: list) -> None:
203
+ def write_vsim_dot_do( # pylint: disable=too-many-locals
204
+ self, dot_do_to_write: list
205
+ ) -> None:
197
206
  '''Writes files(s) based on dot_do_to_write(list of str)
198
207
 
199
208
  list arg values can be empty (all) or have items 'all', 'sim', 'lint', 'vlog'.'''
@@ -216,27 +225,28 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
216
225
  # TODO(drew): support self.args['sim_libary', 'elab-args', sim-args'] (3 lists)
217
226
  # to add to vsim_one_liner.
218
227
 
219
- vsim_one_liner = "vsim -onfinish stop" \
220
- + f" -sv_seed {self.args['seed']} {sim_plusargs_str} {vsim_suppress_list_str}" \
221
- + f" {voptargs_str} work.{self.args['top']}"
228
+ vopt_one_liner = ""
229
+ if self.use_vopt:
230
+ vopt_one_liner = (
231
+ f"vopt {voptargs_str} work.{self.args['top']} -o opt__{self.args['top']}"
232
+ )
233
+ vopt_one_liner = vopt_one_liner.replace('\n', ' ') # needs to be a one-liner
234
+ # vopt doesn't need -voptargs=(value) like vsim does, simply use (value).
235
+ vopt_one_liner = vopt_one_liner.replace('-voptargs=', '')
222
236
 
223
- vsim_one_liner = vsim_one_liner.replace('\n', ' ') # needs to be a one-liner
237
+ vsim_one_liner = "vsim -onfinish stop" \
238
+ + f" -sv_seed {self.args['seed']} {sim_plusargs_str} {vsim_suppress_list_str}" \
239
+ + f" opt__{self.args['top']}"
240
+ else:
241
+ # vopt doesn't exist, use single vsim call after vlog call:
242
+ vsim_one_liner = "vsim -onfinish stop" \
243
+ + f" -sv_seed {self.args['seed']} {sim_plusargs_str} {vsim_suppress_list_str}" \
244
+ + f" {voptargs_str} work.{self.args['top']}"
224
245
 
225
- vsim_vlogonly_dot_do_lines = [
226
- "if {[file exists work]} { vdel -all work; }",
227
- "vlib work;",
228
- "if {[catch {vlog -f vlog.f} result]} {",
229
- " echo \"Caught $result \";",
230
- " if {[batch_mode]} {",
231
- " quit -f -code 20;",
232
- " }",
233
- "}",
234
- "if {[batch_mode]} {",
235
- " quit -f -code 0;",
236
- "}",
237
- ]
238
246
 
239
- vsim_lintonly_dot_do_lines = [
247
+ vsim_one_liner = vsim_one_liner.replace('\n', ' ')
248
+
249
+ vlog_do_lines = [
240
250
  "if {[file exists work]} { vdel -all work; }",
241
251
  "vlib work;",
242
252
  "quietly set qc 30;",
@@ -246,44 +256,35 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
246
256
  " quit -f -code 20;",
247
257
  " }",
248
258
  "}",
259
+ ]
260
+
261
+ vopt_do_lines = []
262
+ if self.use_vopt:
263
+ vopt_do_lines = [
264
+ "if {[catch { " + vopt_one_liner + " } result] } {",
265
+ " echo \"Caught $result\";",
266
+ " if {[batch_mode]} {",
267
+ " quit -f -code 19;",
268
+ " }",
269
+ "}",
270
+ ]
271
+
272
+ vsim_do_lines = [
249
273
  "if {[catch { " + vsim_one_liner + " } result] } {",
250
274
  " echo \"Caught $result\";",
251
275
  " if {[batch_mode]} {",
252
- " quit -f -code 19;",
276
+ " quit -f -code 18;",
253
277
  " }",
254
278
  "}",
255
- "set TestStatus [coverage attribute -name SEED -name TESTSTATUS];",
256
- "if {[regexp \"TESTSTATUS += 0\" $TestStatus]} {",
257
- " quietly set qc 0;",
258
- "} elseif {[regexp \"TESTSTATUS += 1\" $TestStatus]} {",
259
- " quietly set qc 0;",
260
- "} else {",
261
- " quietly set qc 2;",
262
- "}",
279
+ ]
280
+
281
+ vsim_vlogonly_dot_do_lines = vlog_do_lines + [
263
282
  "if {[batch_mode]} {",
264
- " quit -f -code $qc;",
283
+ " quit -f -code 0;",
265
284
  "}",
266
285
  ]
267
286
 
268
- vsim_dot_do_lines = [
269
- "if {[file exists work]} { vdel -all work; }",
270
- "vlib work;",
271
- "quietly set qc 30;",
272
- "if {[catch {vlog -f vlog.f} result]} {",
273
- " echo \"Caught $result \";",
274
- " if {[batch_mode]} {",
275
- " quit -f -code 20;",
276
- " }",
277
- "}",
278
- "if {[catch { " + vsim_one_liner + " } result] } {",
279
- " echo \"Caught $result\";",
280
- " if {[batch_mode]} {",
281
- " quit -f -code 19;",
282
- " }",
283
- "}",
284
- "onbreak { resume; };",
285
- "catch {log -r *};",
286
- "run -a;",
287
+ final_check_teststatus_do_lines = [
287
288
  "set TestStatus [coverage attribute -name SEED -name TESTSTATUS];",
288
289
  "if {[regexp \"TESTSTATUS += 0\" $TestStatus]} {",
289
290
  " quietly set qc 0;",
@@ -297,6 +298,18 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
297
298
  "}",
298
299
  ]
299
300
 
301
+ # final vlog/vopt/vsim lint-only .do command (want to make sure it can completely
302
+ # build for 'elab' style eda job), runs for 0ns, logs nothing for a waveform, quits
303
+ vsim_lintonly_dot_do_lines = vlog_do_lines + vopt_do_lines + vsim_do_lines \
304
+ + final_check_teststatus_do_lines
305
+
306
+ # final vlog/opt/vsim full simulation .do command.
307
+ vsim_dot_do_lines = vlog_do_lines + vopt_do_lines + vsim_do_lines + [
308
+ "onbreak { resume; };",
309
+ "catch {log -r *};",
310
+ "run -a;",
311
+ ] + final_check_teststatus_do_lines
312
+
300
313
  write_all = len(dot_do_to_write) == 0 or 'all' in dot_do_to_write
301
314
  if write_all or 'sim' in dot_do_to_write:
302
315
  with open(vsim_dot_do_fpath, 'w', encoding='utf-8') as f: