opencos-eda 0.3.12__py3-none-any.whl → 0.3.14__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 (36) hide show
  1. opencos/commands/flist.py +222 -39
  2. opencos/commands/multi.py +4 -2
  3. opencos/commands/sim.py +192 -8
  4. opencos/deps/deps_file.py +4 -1
  5. opencos/deps_schema.py +2 -2
  6. opencos/eda.py +12 -9
  7. opencos/eda_base.py +39 -8
  8. opencos/eda_config.py +37 -6
  9. opencos/eda_config_defaults.yml +30 -5
  10. opencos/eda_tool_helper.py +4 -4
  11. opencos/tools/cocotb.py +0 -11
  12. opencos/tools/invio.py +0 -6
  13. opencos/tools/iverilog.py +17 -16
  14. opencos/tools/modelsim_ase.py +0 -12
  15. opencos/tools/quartus.py +21 -1
  16. opencos/tools/questa.py +0 -14
  17. opencos/tools/questa_common.py +54 -25
  18. opencos/tools/questa_fe.py +0 -14
  19. opencos/tools/questa_fse.py +0 -14
  20. opencos/tools/riviera.py +104 -25
  21. opencos/tools/slang.py +12 -9
  22. opencos/tools/slang_yosys.py +0 -6
  23. opencos/tools/surelog.py +11 -8
  24. opencos/tools/tabbycad_yosys.py +1 -7
  25. opencos/tools/verilator.py +18 -11
  26. opencos/tools/vivado.py +92 -25
  27. opencos/tools/yosys.py +8 -5
  28. opencos/util.py +14 -5
  29. opencos/utils/str_helpers.py +4 -1
  30. {opencos_eda-0.3.12.dist-info → opencos_eda-0.3.14.dist-info}/METADATA +1 -2
  31. {opencos_eda-0.3.12.dist-info → opencos_eda-0.3.14.dist-info}/RECORD +36 -36
  32. {opencos_eda-0.3.12.dist-info → opencos_eda-0.3.14.dist-info}/WHEEL +0 -0
  33. {opencos_eda-0.3.12.dist-info → opencos_eda-0.3.14.dist-info}/entry_points.txt +0 -0
  34. {opencos_eda-0.3.12.dist-info → opencos_eda-0.3.14.dist-info}/licenses/LICENSE +0 -0
  35. {opencos_eda-0.3.12.dist-info → opencos_eda-0.3.14.dist-info}/licenses/LICENSE.spdx +0 -0
  36. {opencos_eda-0.3.12.dist-info → opencos_eda-0.3.14.dist-info}/top_level.txt +0 -0
opencos/eda.py CHANGED
@@ -75,7 +75,7 @@ def init_config(
75
75
  config['command_handler'][_cmd] = cls
76
76
 
77
77
  config['auto_tools_found'] = {}
78
- config['tools_loaded'] = set()
78
+ config['tools_loaded'] = []
79
79
 
80
80
  # If this is a sub_command sitation, then use that for setting up tools, otherwise
81
81
  # use the command. If there's no command, blank str is fine will load all the tools, or
@@ -192,7 +192,7 @@ def auto_tool_setup( # pylint: disable=too-many-locals,too-many-branches,too-man
192
192
  '''Returns an updated config, uses config['auto_tools_order'] dict and
193
193
  config['tools'] dict, calls tool_setup(..)
194
194
 
195
- -- adds items to config['tools_loaded'] set
195
+ -- adds items to config['tools_loaded'] list
196
196
  -- updates config['command_handler'][command] with a Tool class
197
197
 
198
198
  Input arg tool can be in the form (for example):
@@ -210,7 +210,7 @@ def auto_tool_setup( # pylint: disable=too-many-locals,too-many-branches,too-man
210
210
  if 'auto_tools_found' not in config:
211
211
  config['auto_tools_found'] = {}
212
212
  if 'tools_loaded' not in config:
213
- config['tools_loaded'] = set()
213
+ config['tools_loaded'] = []
214
214
 
215
215
  util.debug(f'Calling auto_tool_setup for {tool=} {command=}')
216
216
 
@@ -223,12 +223,14 @@ def auto_tool_setup( # pylint: disable=too-many-locals,too-many-branches,too-man
223
223
 
224
224
  # Step 1 - Load tools (do not set config['command_handler'][command])
225
225
 
226
- for name, tool_cfg in config['tools'].items():
226
+ if tool:
227
+ # if called with tool=(some_name), then only load that tool (which is not
228
+ # this one). Also delete this entry from config['tools'] because we don't need it.
229
+ for name in list(config['tools'].keys()):
230
+ if tool != name:
231
+ del config['tools'][name]
227
232
 
228
- if tool and tool != name:
229
- # if called with tool=(some_name), then only load that tool (which is not
230
- # this one)
231
- continue
233
+ for name, tool_cfg in config['tools'].items():
232
234
 
233
235
  if name in config['auto_tools_found']:
234
236
  # we already loaded this tool.
@@ -326,7 +328,8 @@ def auto_tool_setup( # pylint: disable=too-many-locals,too-many-branches,too-man
326
328
  else:
327
329
  p = safe_shutil_which(exe_list[0])
328
330
  config['auto_tools_found'][name] = p # populate key-value pairs w/ first exe in list
329
- config['tools_loaded'].add(name)
331
+ if name not in config['tools_loaded']:
332
+ config['tools_loaded'].append(name)
330
333
  if not quiet:
331
334
  util.info(f"Detected {name} ({p})")
332
335
  else:
opencos/eda_base.py CHANGED
@@ -26,7 +26,8 @@ from opencos import eda_config
26
26
 
27
27
  from opencos.util import Colors, safe_emoji
28
28
  from opencos.utils.str_helpers import sprint_time, strip_outer_quotes, string_or_space, \
29
- indent_wrap_long_text, pretty_list_columns_manual, get_terminal_columns
29
+ indent_wrap_long_text, pretty_list_columns_manual, get_terminal_columns, \
30
+ PARAMETER_NAME_RSTR
30
31
  from opencos.utils.subprocess_helpers import subprocess_run_background
31
32
  from opencos.utils import status_constants
32
33
 
@@ -192,6 +193,8 @@ class Tool:
192
193
  self.args_help = {}
193
194
  if getattr(self, 'defines', None) is None:
194
195
  self.defines = {}
196
+ if getattr(self, 'config', None) is None:
197
+ self.config = config
195
198
  self.args.update({
196
199
  'tool': self._TOOL, # Set for all derived classes.
197
200
  })
@@ -261,8 +264,20 @@ class Tool:
261
264
  )
262
265
 
263
266
  def set_tool_defines(self) -> None:
264
- '''Derived classes may override, sets any additional defines based on tool.'''
265
- return
267
+ '''Derived classes may override, sets any additional defines based on tool.
268
+
269
+ If overriding, you likely want to call:
270
+ super().set_tool_defines()
271
+ to pick up anything from self.config['tools'] (from the eda_config YAML)
272
+ '''
273
+ if not self._TOOL:
274
+ return
275
+
276
+ _tool_config = self.config.get('tools', {}).get(self._TOOL, {})
277
+ self.defines.update(
278
+ _tool_config.get('defines', {})
279
+ )
280
+
266
281
 
267
282
 
268
283
  class Command: # pylint: disable=too-many-public-methods,too-many-instance-attributes
@@ -1501,7 +1516,14 @@ class CommandDesign(Command): # pylint: disable=too-many-instance-attributes
1501
1516
  def process_parameter_arg(
1502
1517
  self, text: str, pwd: str = os.getcwd()
1503
1518
  ) -> None:
1504
- '''Retuns None, parses -G<Name>=<Value> adds to internal self.parameters.'''
1519
+ '''Retuns None, parses -G<Name>=<Value> adds to internal self.parameters.
1520
+
1521
+ Note that not all tools will allow hierarchy path information when setting
1522
+ parameters. The Queta/Modelsim family can handle -G/Path/To/Name=Value,
1523
+ but other tools may crash.
1524
+
1525
+ Also note - we do not currently accept [0] in the /Path/To/generate[1]/Name=Value
1526
+ '''
1505
1527
 
1506
1528
  # Deal with raw CLI/bash/powershell argparser, strip all outer quotes.
1507
1529
  text = strip_outer_quotes(text)
@@ -1514,14 +1536,14 @@ class CommandDesign(Command): # pylint: disable=too-many-instance-attributes
1514
1536
  return
1515
1537
 
1516
1538
  text = text[2:] # strip leading -G
1517
- m = re.match(r'^(\w+)$', text)
1539
+ m = re.match(rf'^({PARAMETER_NAME_RSTR})$', text)
1518
1540
  if m:
1519
1541
  k = m.group(1)
1520
1542
  util.warning(f"Parameter {k} has no value and will not be applied")
1521
1543
  return
1522
- m = re.match(r'^(\w+)\=(\S+)$', text)
1544
+ m = re.match(rf'^({PARAMETER_NAME_RSTR})\=(\S+)$', text)
1523
1545
  if not m:
1524
- m = re.match(r'^(\w+)\=(\"[^\"]*\")$', text)
1546
+ m = re.match(rf'^({PARAMETER_NAME_RSTR})\=(\"[^\"]*\")$', text)
1525
1547
  if m:
1526
1548
  k = m.group(1)
1527
1549
  v = m.group(2)
@@ -1536,7 +1558,11 @@ class CommandDesign(Command): # pylint: disable=too-many-instance-attributes
1536
1558
  v = int(v)
1537
1559
  except ValueError:
1538
1560
  pass
1561
+ util.debug('set parameter Name={k} Value={v}')
1539
1562
  self.set_parameter(k, v)
1563
+ else:
1564
+ util.warning(f'Unable to set parameter from token (-G removed): {text}')
1565
+
1540
1566
 
1541
1567
 
1542
1568
  def process_plusarg( # pylint: disable=too-many-branches
@@ -1924,19 +1950,24 @@ class CommandDesign(Command): # pylint: disable=too-many-instance-attributes
1924
1950
  m = re.match(r"^\'?\+\w+", token)
1925
1951
  if m:
1926
1952
  # Copy and strip all outer ' or " on the plusarg:
1953
+ util.debug(f'plusarg found at {token=}')
1927
1954
  plusarg = strip_outer_quotes(token)
1928
1955
  self.process_plusarg(plusarg, pwd=pwd)
1929
1956
  remove_list.append(token)
1930
1957
  continue
1931
1958
 
1932
1959
  # Parameters in -G<word>=<something>
1933
- m = re.match(r"^\'?\-G\w+\=.+", token)
1960
+ # Parameters in -Gpath.to.<word>=<something>
1961
+ # Parameters in -G/path/to/<word>=<something>
1962
+ m = re.match(rf"^\'?\-G{PARAMETER_NAME_RSTR}\=.+", token)
1934
1963
  if m:
1935
1964
  # Copy and strip all outer ' or " on the text:
1965
+ util.debug(f'found parameter at {token=}')
1936
1966
  param = strip_outer_quotes(token)
1937
1967
  self.process_parameter_arg(param, pwd=pwd)
1938
1968
  remove_list.append(token)
1939
1969
 
1970
+
1940
1971
  for x in remove_list:
1941
1972
  unparsed.remove(x)
1942
1973
 
opencos/eda_config.py CHANGED
@@ -33,6 +33,7 @@ class Defaults:
33
33
  opencos_config_yml = 'eda_config_defaults.yml'
34
34
  config_yml = ''
35
35
  config_yml_set_from = ''
36
+ non_default_config_yml_arg_used = ''
36
37
 
37
38
  supported_config_keys = set([
38
39
  'DEFAULT_HANDLERS', 'DEFAULT_HANDLERS_HELP',
@@ -314,11 +315,35 @@ def get_eda_config(args:list, quiet=False) -> (dict, list):
314
315
  config = None
315
316
 
316
317
  if parsed.config_yml != Defaults.config_yml:
318
+ Defaults.non_default_config_yml_arg_used = parsed.config_yml
317
319
  config = get_config_merged_with_defaults(config)
318
320
 
319
321
  return config, unparsed
320
322
 
321
323
 
324
+ def get_config_yml_args_for_flist() -> list:
325
+ '''Returns list of args, or empty list. Used by CommandFList when we want to get the args
326
+
327
+ to reproduce a target to be run again in `eda`'''
328
+ ret = []
329
+
330
+ if Defaults.non_default_config_yml_arg_used:
331
+ ret.append(f'--config-yml={Defaults.non_default_config_yml_arg_used}')
332
+
333
+ if Defaults.config_yml_set_from:
334
+ # a default config-yml was used, but it wasn't from eda, was from
335
+ # ENV or HOME dir. This is not included in the flist, so warn about it.
336
+ # Since we don't support > 1 config-yml args, need to warn about this.
337
+ util.warning('Note: for command "flist", picked up',
338
+ f'--config-yml={Defaults.config_yml},',
339
+ f'from: {Defaults.config_yml_set_from}')
340
+
341
+ elif Defaults.config_yml_set_from:
342
+ ret.append(f'--config-yml={Defaults.config_yml}')
343
+
344
+ return ret
345
+
346
+
322
347
  def write_eda_config_and_args(
323
348
  dirpath : str, filename: str = EDA_OUTPUT_CONFIG_FNAME,
324
349
  command_obj_ref: object = None
@@ -334,16 +359,22 @@ def write_eda_config_and_args(
334
359
  # Use deep copy b/c otherwise these are references to opencos.eda.
335
360
  data[x] = copy.deepcopy(getattr(command_obj_ref, x, ''))
336
361
 
337
- # copy util.args
338
- data['util'] = {
339
- 'args': util.args
340
- }
362
+ # copy util.args, and other util globals:
363
+ data['util'] = {}
364
+ for x in ['INITIAL_CWD', 'args', 'dot_f_files_expanded', 'env_files_loaded', 'max_error_code']:
365
+ data['util'][x] = getattr(util, x, '')
366
+
367
+ # copy some information about which eda_config YAML was used:
368
+ for member in ['config_yml', 'config_yml_set_from', 'non_default_config_yml_arg_used']:
369
+ data[member] = getattr(Defaults, member, '')
341
370
 
342
371
  # fix some burried class references in command_obj_ref.config,
343
372
  # otherwise we won't be able to safe load this yaml, so cast as str repr.
344
- for k, v in getattr(command_obj_ref, 'config', {}).items():
373
+ config = getattr(command_obj_ref, 'config', {})
374
+ for k, v in config.items():
345
375
  if k == 'command_handler':
346
- data['config'][k] = str(v)
376
+ data['config']['command_handler'] = str(v)
377
+
347
378
 
348
379
  yaml_safe_writer(data=data, filepath=fullpath)
349
380
 
@@ -116,6 +116,7 @@ command_determines_tool:
116
116
 
117
117
  command_tool_is_optional:
118
118
  # eda commands that may not need to use a tool at all, will skip auto_tools_order if --tool=None (default)
119
+ - shell
119
120
  - flist
120
121
  - export
121
122
  - targets
@@ -254,6 +255,7 @@ tools:
254
255
 
255
256
  defines:
256
257
  OC_TOOL_SLANG: null
258
+ SLANG: 1
257
259
  log-bad-strings:
258
260
  - 'Build failed: '
259
261
  log-must-strings:
@@ -273,7 +275,8 @@ tools:
273
275
  elab: opencos.tools.verilator.VerilatorElab
274
276
  sim: opencos.tools.verilator.VerilatorSim
275
277
 
276
- defines: { }
278
+ defines:
279
+ SIMULATION: 1
277
280
  log-warning-strings:
278
281
  - "%Warning"
279
282
  log-bad-strings:
@@ -382,11 +385,14 @@ tools:
382
385
  lint: opencos.tools.riviera.CommandLintRiviera
383
386
  elab: opencos.tools.riviera.CommandElabRiviera
384
387
  sim: opencos.tools.riviera.CommandSimRiviera
388
+ flist: opencos.tools.riviera.CommandFListRiviera
385
389
  waves: opencos.commands.waves.CommandWaves
386
390
 
387
391
  defines:
388
392
  OC_TOOL_RIVIERA: 1
389
393
  RIVIERA: 1
394
+ # see oclib_defines.vh, this is to prevent type comparisons
395
+ OC_TOOL_BROKEN_TYPE_COMPARISON: 1
390
396
  log-warning-strings:
391
397
  - "Warning: "
392
398
  log-bad-strings:
@@ -396,7 +402,7 @@ tools:
396
402
  log-must-strings:
397
403
  - "VSIM: Simulation has finished"
398
404
  compile-args: |
399
- -echo -sv -input_ports net -lcu -dbg +accb +accr +accs +dacc
405
+ -echo -sv -input_ports net -dbg +accb +accr +accs +dacc
400
406
  compile-coverage-args: |
401
407
  -coverage sbecam -coverage_options count
402
408
  # -uvm -ovm
@@ -406,7 +412,8 @@ tools:
406
412
  -acdb -acdb_cov sbfectapm
407
413
  simulate-coverage-tcl:
408
414
  - acdb save
409
- - acdb report -db work.acdb -txt -o cov.txt
415
+ - acdb report -i work.acdb -txt -o cov.txt
416
+ - acdb report -i work.acdb -txt -o covg.txt -show covergroups
410
417
 
411
418
 
412
419
  modelsim_ase:
@@ -416,11 +423,14 @@ tools:
416
423
  lint: opencos.tools.modelsim_ase.CommandLintModelsimAse
417
424
  elab: opencos.tools.modelsim_ase.CommandElabModelsimAse
418
425
  sim: opencos.tools.modelsim_ase.CommandSimModelsimAse
426
+ flist: opencos.tools.modelsim_ase.CommandFListModelsimAse
419
427
  waves: opencos.commands.waves.CommandWaves
420
428
 
421
429
  defines:
422
430
  OC_ASSERT_PROPERTY_NOT_SUPPORTED: 1
423
431
  OC_TOOL_MODELSIM_ASE: 1
432
+ # see oclib_defines.vh, this is to prevent type comparisons
433
+ OC_TOOL_BROKEN_TYPE_COMPARISON: 1
424
434
  log-warning-strings:
425
435
  - "Warning: "
426
436
  log-bad-strings:
@@ -457,7 +467,7 @@ tools:
457
467
  waves: opencos.commands.waves.CommandWaves
458
468
 
459
469
  defines:
460
- OC_TOOL_QUESTA_FSE: 1
470
+ OC_TOOL_QUESTA_FE: 1
461
471
  log-warning-strings:
462
472
  - "Warning: "
463
473
  log-bad-strings:
@@ -531,7 +541,7 @@ tools:
531
541
  waves: opencos.commands.waves.CommandWaves
532
542
 
533
543
  defines:
534
- OC_TOOL_QUESTA_FSE: 1
544
+ OC_TOOL_QUESTA: 1
535
545
  log-warning-strings:
536
546
  - "Warning: "
537
547
  log-bad-strings:
@@ -563,6 +573,10 @@ tools:
563
573
  lint: opencos.tools.iverilog.CommandLintIverilog
564
574
  elab: opencos.tools.iverilog.CommandElabIverilog
565
575
  sim: opencos.tools.iverilog.CommandSimIverilog
576
+ defines:
577
+ SIMULATION: 1
578
+ IVERILOG: 1
579
+ OC_ASSERT_PROPERTY_NOT_SUPPORTED: 1
566
580
 
567
581
  log-warning-strings:
568
582
  - "Warning:"
@@ -595,6 +609,8 @@ tools:
595
609
 
596
610
  defines:
597
611
  OC_TOOL_COCOTB: null
612
+ COCOTB: 1
613
+ SIMULATION: 1
598
614
  log-warning-strings:
599
615
  - "Warning:"
600
616
  - "WARNING:"
@@ -669,6 +685,10 @@ tools:
669
685
  elab: opencos.tools.slang_yosys.CommandElabSlangYosys
670
686
  synth: opencos.tools.slang_yosys.CommandSynthSlangYosys
671
687
  lec: opencos.tools.slang_yosys.CommandLecSlangYosys
688
+ defines:
689
+ OC_TOOL_YOSYS: null
690
+ OC_TOOL_SLANG: null
691
+ SLANG: 1
672
692
 
673
693
  tabbycad_yosys:
674
694
  exe: yosys
@@ -676,6 +696,9 @@ tools:
676
696
  - YOSYSHQ_LICENSE
677
697
  handlers:
678
698
  synth: opencos.tools.tabbycad_yosys.CommandSynthTabbyCadYosys
699
+ defines:
700
+ OC_TOOL_YOSYS: null
701
+ OC_TOOL_TABBYCAD: null
679
702
 
680
703
  invio_yosys:
681
704
  exe: yosys
@@ -686,6 +709,8 @@ tools:
686
709
  handlers:
687
710
  elab: opencos.tools.invio_yosys.CommandElabInvioYosys
688
711
  synth: opencos.tools.invio_yosys.CommandSynthInvioYosys
712
+ OC_TOOL_YOSYS: null
713
+ OC_TOOL_INVIO: null
689
714
 
690
715
  yosys:
691
716
  exe: yosys
@@ -21,7 +21,7 @@ from opencos.utils import str_helpers
21
21
  def get_config_and_tools_loaded( # pylint: disable=dangerous-default-value
22
22
  quiet: bool = False, args: list = []
23
23
  ) -> (dict, set):
24
- '''Returns config dict and set tools_loaded, given the found config.
24
+ '''Returns config dict and list tools_loaded, given the found config.
25
25
 
26
26
  Can BYO args such as --config-yml=MY_OWN_EDA_CONFIG.yml
27
27
  '''
@@ -34,7 +34,7 @@ def get_config_and_tools_loaded( # pylint: disable=dangerous-default-value
34
34
  # within eda, etc, if you already have a valid config or tools_loaded.
35
35
  eda = import_module("opencos.eda")
36
36
  config = eda.init_config(config=config, quiet=quiet)
37
- tools_loaded = config.get('tools_loaded', set()).copy()
37
+ tools_loaded = config.get('tools_loaded', []).copy()
38
38
 
39
39
  return config, tools_loaded
40
40
 
@@ -55,7 +55,7 @@ def get_all_handler_commands(config=None, tools_loaded=None) -> dict:
55
55
  config, tools_loaded = get_config_and_tools_loaded()
56
56
 
57
57
  assert isinstance(config, dict)
58
- assert isinstance(tools_loaded, set)
58
+ assert isinstance(tools_loaded, list)
59
59
 
60
60
  # Let's re-walk auto_tools_order to get this ordered per eda command:
61
61
  for command, tools_list in config.get('auto_tools_order', {}).items():
@@ -130,7 +130,7 @@ def get_handler_info_with_versions( # pylint: disable=too-many-branches
130
130
  if not config:
131
131
  config, tools_loaded = get_config_and_tools_loaded()
132
132
  else:
133
- tools_loaded = list(config.get('tools_loaded', set()))
133
+ tools_loaded = list(config.get('tools_loaded', []))
134
134
 
135
135
  eda_commands = list(config.get('DEFAULT_HANDLERS', {}).keys())
136
136
  show_versions = config.get('show_tool_versions', False)
opencos/tools/cocotb.py CHANGED
@@ -51,14 +51,6 @@ class ToolCocotb(Tool):
51
51
 
52
52
  return ''
53
53
 
54
- def set_tool_defines(self):
55
- super().set_tool_defines()
56
- self.defines.update({
57
- 'SIMULATION': 1,
58
- 'COCOTB': 1,
59
- 'OC_TOOL_COCOTB': None,
60
- })
61
-
62
54
 
63
55
  class CommandSimCocotb(CommandSim, ToolCocotb):
64
56
  '''CommandSimCocotb is a command handler for: eda sim --tool=cocotb'''
@@ -103,9 +95,6 @@ class CommandSimCocotb(CommandSim, ToolCocotb):
103
95
  self.cocotb_test_files = []
104
96
 
105
97
 
106
- def set_tool_defines(self):
107
- ToolCocotb.set_tool_defines(self)
108
-
109
98
  def help( # pylint: disable=dangerous-default-value
110
99
  self, tokens: list = [], no_targets: bool = False
111
100
  ) -> None:
opencos/tools/invio.py CHANGED
@@ -26,14 +26,8 @@ class ToolInvio(Tool):
26
26
  if not spec:
27
27
  self.error('"invio" package not in python env')
28
28
 
29
-
30
29
  return super().get_versions()
31
30
 
32
- def set_tool_defines(self):
33
- super().set_tool_defines()
34
- self.defines.update({
35
- 'OC_TOOL_INVIO': None,
36
- })
37
31
 
38
32
  class CommandElabInvio(CommandElab, ToolInvio):
39
33
  '''Command handler for: eda elab --tool=invio'''
opencos/tools/iverilog.py CHANGED
@@ -44,14 +44,6 @@ class ToolIverilog(Tool):
44
44
  self._VERSION = version
45
45
  return self._VERSION
46
46
 
47
- def set_tool_defines(self):
48
- # TODO(drew): come back to this, Tool doesn't have self.defines. Command does.
49
- self.defines.update({
50
- 'SIMULATION': 1,
51
- 'IVERILOG': 1,
52
- 'OC_ASSERT_PROPERTY_NOT_SUPPORTED': 1,
53
- })
54
-
55
47
 
56
48
  class CommandSimIverilog(CommandSim, ToolIverilog):
57
49
  '''CommandSimIverilog is a command handler for: eda sim --tool=iverilog'''
@@ -78,6 +70,7 @@ class CommandSimIverilog(CommandSim, ToolIverilog):
78
70
  # We do not override CommandSim.do_it()
79
71
  def prepare_compile(self):
80
72
  self.set_tool_defines()
73
+ self.update_library_map()
81
74
 
82
75
  self.iverilog_command_lists = self.get_compile_command_lists()
83
76
  self.iverilog_exec_command_lists = self.get_simulate_command_lists()
@@ -128,17 +121,25 @@ class CommandSimIverilog(CommandSim, ToolIverilog):
128
121
  for value in self.incdirs:
129
122
  command_list += [ '-I', value ]
130
123
 
131
- for k,v in self.defines.items():
132
- if v is None:
133
- command_list += [ '-D', k ]
134
- else:
135
- # Generally we should only support int and str python types passed as
136
- # +define+{k}={v}, but also for SystemVerilog plusargs
137
- command_list += [ '-D', f'{k}={sanitize_defines_for_sh(v)}' ]
124
+ if self.args['ext-defines-sv-fname']:
125
+ self.create_ext_defines_sv()
126
+ else:
127
+ for k,v in self.defines.items():
128
+ if v is None:
129
+ command_list += [ '-D', k ]
130
+ else:
131
+ # Generally we should only support int and str python types passed as
132
+ # +define+{k}={v}, but also for SystemVerilog plusargs
133
+ command_list += [ '-D', f'{k}={sanitize_defines_for_sh(v)}' ]
138
134
 
139
135
  # parameters
136
+ # If you do -PName=Value, all parameters in the hierachy with Name will be set,
137
+ # so to only do top level parameters, if hierarchy isn't mentioned in the Name,
138
+ # would need to do -P{self.args['top'].Name=Value
140
139
  command_list.extend(
141
- self.process_parameters_get_list(arg_prefix=f'-P{self.args["top"]}.')
140
+ self.process_parameters_get_list(
141
+ arg_prefix='-P', hier_delimiter='.', top_hier_str=f'{self.args["top"]}.'
142
+ )
142
143
  )
143
144
 
144
145
  if not self.files_sv and not self.files_v:
@@ -40,18 +40,6 @@ class CommandSimModelsimAse(CommonSimQuesta):
40
40
  )
41
41
  })
42
42
 
43
- def set_tool_defines(self):
44
- # Update any defines from config.tools.modelsim_ase:
45
- self.defines.update(
46
- self.tool_config.get(
47
- 'defines',
48
- # defaults, if not set:
49
- {'OC_ASSERT_PROPERTY_NOT_SUPPORTED': 1,
50
- 'OC_TOOL_MODELSIM_ASE': 1}
51
- )
52
- )
53
-
54
-
55
43
 
56
44
  class CommandElabModelsimAse(CommandSimModelsimAse):
57
45
  '''CommandElabModelsimAse is a command handler for: eda elab --tool=modelsim_ase'''
opencos/tools/quartus.py CHANGED
@@ -550,9 +550,29 @@ class CommandFListQuartus(CommandFList, ToolQuartus):
550
550
  CommandFList.__init__(self, config=config)
551
551
  ToolQuartus.__init__(self, config=self.config)
552
552
  self.args.update({
553
- 'emit-parameter': False
553
+ # synth/project style Flist, can't emit these:
554
+ 'emit-parameter': False,
555
+ 'emit-plusargs': False,
554
556
  })
555
557
 
558
+ def get_flist_plusargs_list(self) -> list:
559
+ '''Overriden from CommandFList.'''
560
+ if self.args['unprocessed-plusargs']:
561
+ util.warning('Command "flist" for --tool=quartus is not intended for simulation',
562
+ 'and plusargs were present. They will NOT be included in the flist:',
563
+ f'{self.args["unprocessed-plusargs"]}')
564
+
565
+ return []
566
+
567
+ def get_flist_parameter_list(self) -> list:
568
+ '''Overriden from CommandFList.'''
569
+ if self.parameters:
570
+ util.warning('Command "flist" for --tool=quartus is not intended for simulation',
571
+ 'and parameters were present. They will NOT be included in the flist:',
572
+ f'{self.parameters}')
573
+
574
+ return []
575
+
556
576
 
557
577
  class CommandProjQuartus(CommandProj, ToolQuartus):
558
578
  '''CommandProjQuartus is a command handler for: eda proj --tool=quartus'''
opencos/tools/questa.py CHANGED
@@ -39,20 +39,6 @@ class CommandSimQuesta(CommonSimQuesta):
39
39
  })
40
40
 
41
41
 
42
- def set_tool_defines(self):
43
- '''Override from questa.ToolQuesta'''
44
- # Update any defines from config.tools.questa_fse:
45
- self.defines.update(
46
- self.tool_config.get(
47
- 'defines',
48
- # defaults, if not set:
49
- {
50
- 'OC_TOOL_QUESTA': 1
51
- }
52
- )
53
- )
54
-
55
-
56
42
  class CommandElabQuesta(CommandSimQuesta):
57
43
  '''CommandElabQuesta is a command handler for: eda elab --tool=questa'''
58
44