opencos-eda 0.3.8__tar.gz → 0.3.9__tar.gz

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 (105) hide show
  1. {opencos_eda-0.3.8/opencos_eda.egg-info → opencos_eda-0.3.9}/PKG-INFO +2 -1
  2. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/eda.py +62 -8
  3. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/eda_config_defaults.yml +14 -5
  4. opencos_eda-0.3.9/opencos/tools/modelsim_ase.py +82 -0
  5. opencos_eda-0.3.9/opencos/tools/questa.py +82 -0
  6. opencos_eda-0.3.8/opencos/tools/modelsim_ase.py → opencos_eda-0.3.9/opencos/tools/questa_common.py +79 -39
  7. opencos_eda-0.3.9/opencos/tools/questa_fe.py +84 -0
  8. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/questa_fse.py +7 -8
  9. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/riviera.py +27 -10
  10. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/utils/vsim_helper.py +8 -1
  11. {opencos_eda-0.3.8 → opencos_eda-0.3.9/opencos_eda.egg-info}/PKG-INFO +2 -1
  12. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos_eda.egg-info/SOURCES.txt +2 -0
  13. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos_eda.egg-info/requires.txt +1 -0
  14. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/pyproject.toml +2 -1
  15. opencos_eda-0.3.8/opencos/tools/questa.py +0 -287
  16. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/LICENSE +0 -0
  17. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/LICENSE.spdx +0 -0
  18. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/README.md +0 -0
  19. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/__init__.py +0 -0
  20. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/_version.py +0 -0
  21. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/_waves_pkg.sv +0 -0
  22. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/__init__.py +0 -0
  23. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/build.py +0 -0
  24. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/deps_help.py +0 -0
  25. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/elab.py +0 -0
  26. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/export.py +0 -0
  27. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/flist.py +0 -0
  28. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/lec.py +0 -0
  29. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/lint.py +0 -0
  30. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/multi.py +0 -0
  31. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/open.py +0 -0
  32. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/proj.py +0 -0
  33. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/shell.py +0 -0
  34. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/sim.py +0 -0
  35. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/sweep.py +0 -0
  36. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/synth.py +0 -0
  37. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/targets.py +0 -0
  38. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/upload.py +0 -0
  39. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/commands/waves.py +0 -0
  40. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/deps/__init__.py +0 -0
  41. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/deps/defaults.py +0 -0
  42. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/deps/deps_commands.py +0 -0
  43. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/deps/deps_file.py +0 -0
  44. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/deps/deps_processor.py +0 -0
  45. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/deps_schema.py +0 -0
  46. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/eda_base.py +0 -0
  47. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/eda_config.py +0 -0
  48. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/eda_config_max_verilator_waivers.yml +0 -0
  49. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/eda_config_reduced.yml +0 -0
  50. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/eda_deps_bash_completion.bash +0 -0
  51. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/eda_deps_sanitize.py +0 -0
  52. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/eda_extract_targets.py +0 -0
  53. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/eda_tool_helper.py +0 -0
  54. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/export_helper.py +0 -0
  55. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/export_json_convert.py +0 -0
  56. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/files.py +0 -0
  57. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/hw/__init__.py +0 -0
  58. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/hw/oc_cli.py +0 -0
  59. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/hw/pcie.py +0 -0
  60. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/names.py +0 -0
  61. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/peakrdl_cleanup.py +0 -0
  62. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/seed.py +0 -0
  63. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/__init__.py +0 -0
  64. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/custom_config.yml +0 -0
  65. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/deps_files/command_order/DEPS.yml +0 -0
  66. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/deps_files/error_msgs/DEPS.yml +0 -0
  67. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/deps_files/iverilog_test/DEPS.yml +0 -0
  68. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/deps_files/no_deps_here/DEPS.yml +0 -0
  69. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/deps_files/non_sv_reqs/DEPS.yml +0 -0
  70. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/deps_files/tags_with_tools/DEPS.yml +0 -0
  71. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/deps_files/test_err_fatal/DEPS.yml +0 -0
  72. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/helpers.py +0 -0
  73. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/test_build.py +0 -0
  74. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/test_deps_helpers.py +0 -0
  75. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/test_deps_schema.py +0 -0
  76. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/test_eda.py +0 -0
  77. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/test_eda_elab.py +0 -0
  78. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/test_eda_synth.py +0 -0
  79. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/test_oc_cli.py +0 -0
  80. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tests/test_tools.py +0 -0
  81. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/__init__.py +0 -0
  82. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/cocotb.py +0 -0
  83. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/invio.py +0 -0
  84. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/invio_helpers.py +0 -0
  85. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/invio_yosys.py +0 -0
  86. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/iverilog.py +0 -0
  87. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/quartus.py +0 -0
  88. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/slang.py +0 -0
  89. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/slang_yosys.py +0 -0
  90. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/surelog.py +0 -0
  91. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/tabbycad_yosys.py +0 -0
  92. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/verilator.py +0 -0
  93. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/vivado.py +0 -0
  94. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/tools/yosys.py +0 -0
  95. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/util.py +0 -0
  96. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/utils/__init__.py +0 -0
  97. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/utils/markup_helpers.py +0 -0
  98. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/utils/status_constants.py +0 -0
  99. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/utils/str_helpers.py +0 -0
  100. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/utils/subprocess_helpers.py +0 -0
  101. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos/utils/vscode_helper.py +0 -0
  102. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos_eda.egg-info/dependency_links.txt +0 -0
  103. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos_eda.egg-info/entry_points.txt +0 -0
  104. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/opencos_eda.egg-info/top_level.txt +0 -0
  105. {opencos_eda-0.3.8 → opencos_eda-0.3.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opencos-eda
3
- Version: 0.3.8
3
+ Version: 0.3.9
4
4
  Summary: A simple Python package for wrapping RTL simuliatons and synthesis
5
5
  Author-email: Simon Sabato <simon@cognichip.ai>, Drew Ranck <drew@cognichip.ai>
6
6
  Project-URL: Homepage, https://github.com/cognichip/opencos
@@ -20,6 +20,7 @@ Requires-Dist: supports_color>=0.2.0
20
20
  Provides-Extra: dev
21
21
  Requires-Dist: pylint>=3.0.0; extra == "dev"
22
22
  Requires-Dist: pytest>=8.3.5; extra == "dev"
23
+ Requires-Dist: twine>=6.1.0; extra == "dev"
23
24
  Provides-Extra: cocotb
24
25
  Requires-Dist: cocotb>=2.0; extra == "cocotb"
25
26
  Requires-Dist: pytest>=8.3.5; extra == "cocotb"
@@ -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("Didn't get a command!")
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
- util.info(f"--tool not specified, using default for {command=}: {use_tool}")
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
- util.warning(f"{command=} is using handling class '{type(sco)}' (but missing",
487
- f"requirement {cls}, likely because we aren't using a derived class",
488
- "for a specific tool)")
489
- parsed_tool = getattr(parsed_args, 'tool', '??')
490
- return util.error(f"EDA {command=} for tool '{parsed_tool}' is not",
491
- f"supported (this tool '{parsed_tool}' cannot run {command=})")
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
 
@@ -510,7 +510,7 @@ auto_tools_order:
510
510
  lec: opencos.tools.slang_yosys.CommandLecYosys
511
511
 
512
512
  questa:
513
- exe: qrun
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
- modelsim_ase:
531
+ questa_fe:
532
532
  exe: vsim
533
533
  requires_vsim_helper: True
534
534
  handlers:
535
- lint: opencos.tools.modelsim_ase.CommandLintModelsimAse
536
- elab: opencos.tools.modelsim_ase.CommandElabModelsimAse
537
- sim: opencos.tools.modelsim_ase.CommandSimModelsimAse
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:
@@ -0,0 +1,82 @@
1
+ ''' opencos.tools.modelsim_ase - Used by opencos.eda for sim/elab commands w/ --tool=modelsim_ase.
2
+
3
+ Contains classes for ToolModelsimAse, CommandSimModelsimAse, CommandElabModelsimAse.
4
+
5
+ Note that this is for 32-bit Modelsim Student Edition. Consider using --tool=questa_fse instead.
6
+ '''
7
+
8
+ # pylint: disable=R0801 # (duplicate code in derived classes, such as if-condition return.)
9
+
10
+ import os
11
+
12
+ from opencos.tools.questa_common import CommonSimQuesta, CommonFListQuesta
13
+
14
+ class CommandSimModelsimAse(CommonSimQuesta):
15
+ '''CommandSimModelsimAse is a command handler for: eda sim --tool=modelsim_ase'''
16
+
17
+ _TOOL = 'modelsim_ase'
18
+ _EXE = 'vsim'
19
+ use_vopt = False
20
+
21
+ def __init__(self, config: dict):
22
+ CommonSimQuesta.__init__(self, config=config)
23
+
24
+ # repairs: override self._TOOL, and run get_versions() again.
25
+ self._TOOL = 'modelsim_ase'
26
+
27
+ self.shell_command = os.path.join(self.sim_exe_base_path, 'vsim')
28
+ self.starter_edition = True
29
+ self.args.update({
30
+ 'tool': self._TOOL, # override
31
+ 'gui': False,
32
+ })
33
+
34
+
35
+ self.args_help.update({
36
+ 'vopt': (
37
+ 'Boolean to enable/disable use of vopt step prior to vsim step'
38
+ ' Note that vopt args can be controlled with --elab-args=<value1>'
39
+ ' --elab-args=<value2> ...'
40
+ )
41
+ })
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
+
56
+ class CommandElabModelsimAse(CommandSimModelsimAse):
57
+ '''CommandElabModelsimAse is a command handler for: eda elab --tool=modelsim_ase'''
58
+
59
+ command_name = 'elab'
60
+
61
+ def __init__(self, config:dict):
62
+ super().__init__(config)
63
+ self.args['stop-after-elaborate'] = True
64
+
65
+
66
+ class CommandLintModelsimAse(CommandSimModelsimAse):
67
+ '''CommandLintModelsimAse is a command handler for: eda lint --tool=modelsim_ase'''
68
+
69
+ command_name = 'lint'
70
+
71
+ def __init__(self, config:dict):
72
+ super().__init__(config)
73
+ self.args['stop-after-compile'] = True
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'
@@ -0,0 +1,82 @@
1
+ ''' opencos.tools.questa - Used by opencos.eda for sim/elab commands w/ --tool=questa.
2
+
3
+ Contains classes for CommandSimQuesta, CommandElabQuesta.
4
+ For: Questa Edition-64 vsim 20XX.X Simulator
5
+
6
+ '''
7
+
8
+ # pylint: disable=R0801 # (setting similar, but not identical, self.defines key/value pairs)
9
+
10
+ # TODO(drew): fix these pylint eventually:
11
+ # pylint: disable=too-many-branches, too-many-ancestors
12
+
13
+ import os
14
+
15
+ from opencos.tools.questa_common import CommonSimQuesta, CommonFListQuesta
16
+
17
+
18
+ class CommandSimQuesta(CommonSimQuesta):
19
+ '''CommandSimQuesta is a command handler for: eda sim --tool=questa
20
+
21
+ Note this inherits 99% from CommonSimQuesta for command handling
22
+ '''
23
+ _TOOL = 'questa'
24
+ _EXE = 'vsim'
25
+ use_vopt = True
26
+
27
+ def __init__(self, config: dict):
28
+ # this will setup with self._TOOL = questa, optionally repair it later
29
+ CommonSimQuesta.__init__(self, config=config)
30
+
31
+ # repairs: override self._TOOL, and run get_versions() again.
32
+ self._TOOL = 'questa'
33
+
34
+ self.shell_command = os.path.join(self.sim_exe_base_path, 'vsim')
35
+ self.starter_edition = False
36
+ self.args.update({
37
+ 'tool': self._TOOL, # override
38
+ 'gui': False,
39
+ })
40
+
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
+ class CommandElabQuesta(CommandSimQuesta):
57
+ '''CommandElabQuesta is a command handler for: eda elab --tool=questa'''
58
+
59
+ command_name = 'elab'
60
+
61
+ def __init__(self, config:dict):
62
+ super().__init__(config)
63
+ self.args['stop-after-elaborate'] = True
64
+
65
+
66
+ class CommandLintQuesta(CommandSimQuesta):
67
+ '''CommandLintQuesta is a command handler for: eda lint --tool=questa'''
68
+
69
+ command_name = 'lint'
70
+
71
+ def __init__(self, config:dict):
72
+ super().__init__(config)
73
+ self.args['stop-after-compile'] = True
74
+ self.args['stop-after-elaborate'] = True
75
+
76
+
77
+ class CommandFListQuesta(CommonFListQuesta):
78
+ '''CommandFListQuesta is a command handler for: eda flist --tool=questa'''
79
+
80
+ def __init__(self, config: dict):
81
+ CommonFListQuesta.__init__(self, config=config)
82
+ self._TOOL = 'questa'
@@ -1,32 +1,83 @@
1
- ''' opencos.tools.modelsim_ase - Used by opencos.eda for sim/elab commands w/ --tool=modelsim_ase.
1
+ ''' opencos.tools.questa - Used by opencos.eda for sim/elab commands w/ --tool=questa.
2
2
 
3
- Contains classes for ToolModelsimAse, CommandSimModelsimAse, CommandElabModelsimAse.
3
+ Contains classes for ToolQuesta, and CommonSimQuesta.
4
4
 
5
- Note that this is for 32-bit Modelsim Student Edition. Consider using --tool=questa_fse instead.
6
5
  '''
7
6
 
8
- # pylint: disable=R0801 # (duplicate code in derived classes, such as if-condition return.)
7
+ # pylint: disable=R0801 # (setting similar, but not identical, self.defines key/value pairs)
8
+
9
+ # TODO(drew): fix these pylint eventually:
10
+ # pylint: disable=too-many-branches
9
11
 
10
12
  import os
13
+ import re
14
+ import shutil
11
15
 
12
16
  from opencos import util
13
- from opencos.commands import sim, CommandSim
14
- from opencos.tools.questa import ToolQuesta
17
+ from opencos.commands import sim, CommandSim, CommandFList
18
+ from opencos.eda_base import Tool
15
19
  from opencos.utils.str_helpers import sanitize_defines_for_sh
16
20
 
17
- class ToolModelsimAse(ToolQuesta):
18
- '''ToolModelsimAse used by opencos.eda for --tool=modelsim_ase'''
21
+ class ToolQuesta(Tool):
22
+ '''Base class for CommandSimQuesta, collects version information about qrun'''
19
23
 
20
- _TOOL = 'modelsim_ase' # otherwise it's 'questa' from base class.
24
+ _TOOL = 'questa'
21
25
  _EXE = 'vsim'
22
- use_vopt = False
23
26
 
24
- class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
25
- '''CommandSimModelsimAse is a command handler for: eda sim --tool=modelsim_ase'''
27
+ starter_edition = False
28
+ use_vopt = shutil.which('vopt') # vopt exists in qrun/vsim framework, and we'll use it.
29
+ sim_exe = '' # vsim or qrun
30
+ sim_exe_base_path = ''
31
+ questa_major = None
32
+ questa_minor = None
33
+
34
+ def __init__(self, config: dict):
35
+ super().__init__(config=config)
36
+ self.args['part'] = 'xcu200-fsgd2104-2-e'
37
+
38
+ def get_versions(self) -> str:
39
+ if self._VERSION:
40
+ return self._VERSION
41
+ path = shutil.which(self._EXE)
42
+ if not path:
43
+ self.error(f"{self._EXE} not in path, need to setup",
44
+ "(i.e. source /opt/intelFPGA_pro/23.4/settings64.sh")
45
+ util.debug(f"{path=}")
46
+ if self._EXE.endswith('qrun') and \
47
+ any(x in path for x in ('modelsim_ase', 'questa_fse')):
48
+ util.warning(f"{self._EXE=} Questa path is for starter edition",
49
+ "(modelsim_ase, questa_fse), consider using --tool=modelsim_ase",
50
+ "or --tool=questa_fse, or similar")
51
+ else:
52
+ self.sim_exe = path
53
+ self.sim_exe_base_path, _ = os.path.split(path)
54
+
55
+ m = re.search(r'(\d+)\.(\d+)', path)
56
+ if m:
57
+ self.questa_major = int(m.group(1))
58
+ self.questa_minor = int(m.group(2))
59
+ self._VERSION = str(self.questa_major) + '.' + str(self.questa_minor)
60
+ else:
61
+ self.error("Questa path doesn't specificy version, expecting (d+.d+)")
62
+ return self._VERSION
63
+
64
+ def set_tool_defines(self):
65
+ # Will only be called from an object which also inherits from CommandDesign,
66
+ # i.e. has self.defines
67
+ self.defines['OC_TOOL_QUESTA'] = None
68
+ self.defines[f'OC_TOOL_QUESTA_{self.questa_major:d}_{self.questa_minor:d}'] = None
69
+
70
+
71
+
72
+ class CommonSimQuesta(CommandSim, ToolQuesta):
73
+ '''CommonSimQuesta is a the base command handler for:
74
+
75
+ eda sim --tool=[modelsim_ase|questa|questa_fse]
76
+ '''
26
77
 
27
78
  def __init__(self, config: dict):
28
79
  CommandSim.__init__(self, config=config)
29
- ToolModelsimAse.__init__(self, config=self.config)
80
+ ToolQuesta.__init__(self, config=self.config)
30
81
  self.shell_command = os.path.join(self.sim_exe_base_path, 'vsim')
31
82
  self.starter_edition = True
32
83
  self.args.update({
@@ -42,34 +93,15 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
42
93
  )
43
94
  })
44
95
 
45
- def set_tool_defines(self):
46
- # Update any defines from config.tools.modelsim_ase:
47
- self.defines.update(
48
- self.tool_config.get(
49
- 'defines',
50
- # defaults, if not set:
51
- {'OC_ASSERT_PROPERTY_NOT_SUPPORTED': 1,
52
- 'OC_TOOL_MODELSIM_ASE': 1}
53
- )
54
- )
55
96
 
56
97
  def run_in_batch_mode(self) -> bool:
57
98
  '''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
99
  if self.args['test-mode']:
60
100
  return True
61
101
  if self.args['gui']:
62
102
  return False
63
103
  return True
64
104
 
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
105
 
74
106
  def prepare_compile(self):
75
107
  self.set_tool_defines()
@@ -157,11 +189,11 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
157
189
  '''Returns none, creates filename (str) for a vlog.f'''
158
190
  vlog_dot_f_lines = []
159
191
 
160
- # Add compile args from config.tool.modelsim_ase:
192
+ # Add compile args from config.tool.TOOL (questa, etc):
161
193
  vlog_dot_f_lines += self.tool_config.get(
162
194
  'compile-args',
163
195
  '-sv -svinputport=net -lint').split()
164
- # Add waivers from config.tool.modelsim_ase:
196
+ # Add waivers from config.tool.TOOL (questa, modelsim_ase, etc)
165
197
  for waiver in self.tool_config.get(
166
198
  'compile-waivers',
167
199
  [ #defaults:
@@ -395,7 +427,7 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
395
427
 
396
428
  def _get_vsim_suppress_list_str(self) -> str:
397
429
  vsim_suppress_list = []
398
- # Add waivers from config.tool.modelsim_ase:
430
+ # Add waivers from config.tool.TOOL:
399
431
  for waiver in self.tool_config.get(
400
432
  'simulate-waivers', [
401
433
  #defaults:
@@ -420,8 +452,8 @@ class CommandSimModelsimAse(CommandSim, ToolModelsimAse):
420
452
  super().artifacts_add(name=name, typ=typ, description=description)
421
453
 
422
454
 
423
- class CommandElabModelsimAse(CommandSimModelsimAse):
424
- '''CommandElabModelsimAse is a command handler for: eda elab --tool=modelsim_ase'''
455
+ class CommonElabQuesta(CommonSimQuesta):
456
+ '''CommonElabQuesta is a command handler for: eda elab --tool=(questa family)'''
425
457
 
426
458
  command_name = 'elab'
427
459
 
@@ -430,8 +462,8 @@ class CommandElabModelsimAse(CommandSimModelsimAse):
430
462
  self.args['stop-after-elaborate'] = True
431
463
 
432
464
 
433
- class CommandLintModelsimAse(CommandSimModelsimAse):
434
- '''CommandLintModelsimAse is a command handler for: eda lint --tool=modelsim_ase'''
465
+ class CommonLintQuesta(CommonSimQuesta):
466
+ '''CommonSimQuesta is a command handler for: eda lint --tool=(questa family)'''
435
467
 
436
468
  command_name = 'lint'
437
469
 
@@ -439,3 +471,11 @@ class CommandLintModelsimAse(CommandSimModelsimAse):
439
471
  super().__init__(config)
440
472
  self.args['stop-after-compile'] = True
441
473
  self.args['stop-after-elaborate'] = True
474
+
475
+
476
+ class CommonFListQuesta(CommandFList, ToolQuesta):
477
+ '''CommonFListQuesta is a command handler for: eda flist --tool=(questa family)'''
478
+
479
+ def __init__(self, config: dict):
480
+ CommandFList.__init__(self, config=config)
481
+ ToolQuesta.__init__(self, config=self.config)
@@ -0,0 +1,84 @@
1
+ ''' opencos.tools.questa - Used by opencos.eda for sim/elab commands w/ --tool=questa.
2
+
3
+ Contains classes for CommandSimQuesta, CommandElabQuesta.
4
+ For: Questa Intel (FPGA) Edition-64 vsim 20XX.X Simulator
5
+
6
+ Note - NOT the starter edition (see questa_fse.py)
7
+
8
+ '''
9
+
10
+ # pylint: disable=R0801 # (setting similar, but not identical, self.defines key/value pairs)
11
+
12
+ # TODO(drew): fix these pylint eventually:
13
+ # pylint: disable=too-many-branches, too-many-ancestors
14
+
15
+ import os
16
+
17
+ from opencos.tools.questa_common import CommonSimQuesta, CommonFListQuesta
18
+
19
+
20
+ class CommandSimQuestaFe(CommonSimQuesta):
21
+ '''CommandSimQuestaFe is a command handler for: eda sim --tool=questa_fe
22
+
23
+ Note this inherits 99% from CommonSimQuesta for command handling
24
+ '''
25
+ _TOOL = 'questa_fe'
26
+ _EXE = 'vsim'
27
+ use_vopt = True
28
+
29
+ def __init__(self, config: dict):
30
+ # this will setup with self._TOOL = questa, optionally repair it later
31
+ CommonSimQuesta.__init__(self, config=config)
32
+
33
+ # repairs: override self._TOOL, and run get_versions() again.
34
+ self._TOOL = 'questa_fe'
35
+
36
+ self.shell_command = os.path.join(self.sim_exe_base_path, 'vsim')
37
+ self.starter_edition = False
38
+ self.args.update({
39
+ 'tool': self._TOOL, # override
40
+ 'gui': False,
41
+ })
42
+
43
+
44
+ def set_tool_defines(self):
45
+ '''Override from questa.ToolQuesta'''
46
+ # Update any defines from config.tools.questa_fse:
47
+ self.defines.update(
48
+ self.tool_config.get(
49
+ 'defines',
50
+ # defaults, if not set:
51
+ {
52
+ 'OC_TOOL_QUESTA_FE': 1
53
+ }
54
+ )
55
+ )
56
+
57
+
58
+ class CommandElabQuestaFe(CommandSimQuestaFe):
59
+ '''CommandElabQuesta is a command handler for: eda elab --tool=questa_fe'''
60
+
61
+ command_name = 'elab'
62
+
63
+ def __init__(self, config:dict):
64
+ super().__init__(config)
65
+ self.args['stop-after-elaborate'] = True
66
+
67
+
68
+ class CommandLintQuestaFe(CommandSimQuestaFe):
69
+ '''CommandLintQuesta is a command handler for: eda lint --tool=questa_fe'''
70
+
71
+ command_name = 'lint'
72
+
73
+ def __init__(self, config:dict):
74
+ super().__init__(config)
75
+ self.args['stop-after-compile'] = True
76
+ self.args['stop-after-elaborate'] = True
77
+
78
+
79
+ class CommandFListQuestaFe(CommonFListQuesta):
80
+ '''CommandFListQuesta is a command handler for: eda flist --tool=questa'''
81
+
82
+ def __init__(self, config: dict):
83
+ CommonFListQuesta.__init__(self, config=config)
84
+ self._TOOL = 'questa_fse'
@@ -10,23 +10,22 @@ For: Questa Intel Starter FPGA Edition-64 vsim 20XX.X Simulator
10
10
 
11
11
  import os
12
12
 
13
- from opencos.tools.modelsim_ase import CommandSimModelsimAse
14
- from opencos.tools.questa import CommandFListQuesta
13
+ from opencos.tools.questa_common import CommonSimQuesta, CommonFListQuesta
15
14
 
16
15
 
17
- class CommandSimQuestaFse(CommandSimModelsimAse):
16
+ class CommandSimQuestaFse(CommonSimQuesta):
18
17
  '''CommandSimQuestaFse is a command handler for: eda sim --tool=questa_fse
19
18
 
20
- Note this inherits 99% from CommandSimModelSimAse for command handling
19
+ Note this inherits 99% from CommonSimQuesta for command handling
21
20
  '''
22
21
  _TOOL = 'questa_fse'
23
22
  _EXE = 'vsim'
24
23
  use_vopt = True
25
24
 
26
25
  def __init__(self, config: dict):
27
- # this will setup with self._TOOL = modelsim_ase, which is not ideal so
26
+ # this will setup with self._TOOL = questa, which is not ideal so
28
27
  # we have to repait it later.
29
- CommandSimModelsimAse.__init__(self, config=config)
28
+ CommonSimQuesta.__init__(self, config=config)
30
29
 
31
30
  # repairs: override self._TOOL, and run get_versions() again.
32
31
  self._TOOL = 'questa_fse'
@@ -74,9 +73,9 @@ class CommandLintQuestaFse(CommandSimQuestaFse):
74
73
  self.args['stop-after-elaborate'] = True
75
74
 
76
75
 
77
- class CommandFListQuestaFse(CommandFListQuesta):
76
+ class CommandFListQuestaFse(CommonFListQuesta):
78
77
  '''CommandFListQuestaFse is a command handler for: eda flist --tool=questa_fse'''
79
78
 
80
79
  def __init__(self, config: dict):
81
- CommandFListQuesta.__init__(self, config=config)
80
+ CommonFListQuesta.__init__(self, config=config)
82
81
  self._TOOL = 'questa_fse'