opencos-eda 0.2.36__tar.gz → 0.2.38__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.
- {opencos_eda-0.2.36/opencos_eda.egg-info → opencos_eda-0.2.38}/PKG-INFO +1 -1
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/__init__.py +2 -0
- opencos_eda-0.2.38/opencos/commands/targets.py +49 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/eda.py +39 -99
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/eda_base.py +8 -3
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/eda_config.py +20 -11
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/eda_config_defaults.yml +28 -1
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/eda_config_reduced.yml +0 -1
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/eda_deps_bash_completion.bash +1 -1
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/eda_extract_targets.py +37 -19
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/files.py +2 -2
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/helpers.py +7 -6
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/test_eda.py +22 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/invio.py +4 -5
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/invio_yosys.py +28 -20
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/slang_yosys.py +10 -135
- opencos_eda-0.2.38/opencos/tools/yosys.py +239 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38/opencos_eda.egg-info}/PKG-INFO +1 -1
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos_eda.egg-info/SOURCES.txt +1 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/pyproject.toml +1 -1
- opencos_eda-0.2.36/opencos/tools/yosys.py +0 -104
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/LICENSE +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/LICENSE.spdx +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/README.md +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/__init__.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/_version.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/_waves_pkg.sv +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/build.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/elab.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/export.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/flist.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/multi.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/open.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/proj.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/sim.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/sweep.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/synth.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/upload.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/commands/waves.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/deps_helpers.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/deps_schema.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/eda_config_max_verilator_waivers.yml +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/eda_tool_helper.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/export_helper.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/export_json_convert.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/names.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/oc_cli.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/pcie.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/peakrdl_cleanup.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/seed.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/__init__.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/custom_config.yml +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/deps_files/command_order/DEPS.yml +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/deps_files/error_msgs/DEPS.yml +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/deps_files/iverilog_test/DEPS.yml +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/deps_files/no_deps_here/DEPS.yml +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/deps_files/non_sv_reqs/DEPS.yml +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/deps_files/tags_with_tools/DEPS.yml +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/deps_files/test_err_fatal/DEPS.yml +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/test_build.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/test_deps_helpers.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/test_deps_schema.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/test_eda_elab.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/test_eda_synth.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/test_oc_cli.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tests/test_tools.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/__init__.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/invio_helpers.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/iverilog.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/modelsim_ase.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/questa.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/slang.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/surelog.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/tabbycad_yosys.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/verilator.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/tools/vivado.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos/util.py +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos_eda.egg-info/dependency_links.txt +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos_eda.egg-info/entry_points.txt +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos_eda.egg-info/requires.txt +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/opencos_eda.egg-info/top_level.txt +0 -0
- {opencos_eda-0.2.36 → opencos_eda-0.2.38}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opencos-eda
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.38
|
|
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
|
|
@@ -17,6 +17,7 @@ from .sweep import CommandSweep
|
|
|
17
17
|
from .synth import CommandSynth
|
|
18
18
|
from .upload import CommandUpload
|
|
19
19
|
from .waves import CommandWaves
|
|
20
|
+
from .targets import CommandTargets
|
|
20
21
|
|
|
21
22
|
__all__ = [
|
|
22
23
|
'CommandBuild',
|
|
@@ -32,4 +33,5 @@ __all__ = [
|
|
|
32
33
|
'CommandToolsMulti',
|
|
33
34
|
'CommandUpload',
|
|
34
35
|
'CommandWaves',
|
|
36
|
+
'CommandTargets',
|
|
35
37
|
]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'''opencos.commands.targets - command handler for: eda targets [args]
|
|
2
|
+
|
|
3
|
+
Note this command is handled differently than others (such as CommandSim),
|
|
4
|
+
it is generally run as simply
|
|
5
|
+
|
|
6
|
+
> eda targets
|
|
7
|
+
> eda targets <directory>
|
|
8
|
+
> eda targets [directory/]<pattern> [directory2/]<pattern2> ...
|
|
9
|
+
|
|
10
|
+
uses no tools and will print a pretty list of targets to stdout.
|
|
11
|
+
'''
|
|
12
|
+
|
|
13
|
+
# Note - similar code waiver, tricky to eliminate it with inheritance when
|
|
14
|
+
# calling reusable methods.
|
|
15
|
+
# pylint: disable=R0801
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
|
|
19
|
+
from opencos import eda_extract_targets
|
|
20
|
+
from opencos.eda_base import Command
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CommandTargets:
|
|
24
|
+
'''command handler for: eda targets'''
|
|
25
|
+
|
|
26
|
+
command_name = 'targets'
|
|
27
|
+
|
|
28
|
+
def __init__(self, config: dict):
|
|
29
|
+
# We don't inherit opencos.eda_base.Command, so we have to set a few
|
|
30
|
+
# member vars for Command.help to work.
|
|
31
|
+
self.args = {}
|
|
32
|
+
self.args_help = {}
|
|
33
|
+
self.config = config
|
|
34
|
+
self.status = 0
|
|
35
|
+
|
|
36
|
+
def process_tokens( # pylint: disable=unused-argument
|
|
37
|
+
self, tokens: list, process_all: bool = True,
|
|
38
|
+
pwd: str = os.getcwd()
|
|
39
|
+
) -> list:
|
|
40
|
+
'''This is effectively our 'run' method, entrypoint from opencos.eda.main'''
|
|
41
|
+
|
|
42
|
+
eda_extract_targets.run(partial_paths=tokens, base_path=pwd)
|
|
43
|
+
return []
|
|
44
|
+
|
|
45
|
+
def help(self, tokens: list) -> None:
|
|
46
|
+
'''Since we don't inherit from opencos.eda_base.Command, need our own help
|
|
47
|
+
method
|
|
48
|
+
'''
|
|
49
|
+
Command.help(self, tokens=tokens)
|
|
@@ -10,6 +10,7 @@ import re
|
|
|
10
10
|
import signal
|
|
11
11
|
import argparse
|
|
12
12
|
import shlex
|
|
13
|
+
import importlib.util
|
|
13
14
|
|
|
14
15
|
import opencos
|
|
15
16
|
from opencos import util, files
|
|
@@ -19,7 +20,6 @@ from opencos.eda_base import Tool, which_tool
|
|
|
19
20
|
|
|
20
21
|
# Globals
|
|
21
22
|
|
|
22
|
-
debug_respawn = False
|
|
23
23
|
util.progname = "EDA"
|
|
24
24
|
|
|
25
25
|
|
|
@@ -30,37 +30,25 @@ util.progname = "EDA"
|
|
|
30
30
|
# eda command (such as, command: eda sim) is handled by which class (such as class: CommandSim)
|
|
31
31
|
# These are also overriden depending on the tool, for example --tool verilator sets
|
|
32
32
|
# "sim": CommandSimVerilator.
|
|
33
|
-
def init_config(
|
|
33
|
+
def init_config(
|
|
34
|
+
config: dict, quiet: bool = False, tool=None, run_auto_tool_setup: bool = True
|
|
35
|
+
) -> dict:
|
|
34
36
|
'''Sets or clears entries in config (dict) so tools can be re-loaded.'''
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
config['command_handler'] = {
|
|
46
|
-
"sim" : CommandSim,
|
|
47
|
-
"elab" : CommandElab,
|
|
48
|
-
"synth" : CommandSynth,
|
|
49
|
-
"flist" : CommandFList,
|
|
50
|
-
"proj" : CommandProj,
|
|
51
|
-
"multi" : CommandMulti,
|
|
52
|
-
"tools-multi" : CommandToolsMulti,
|
|
53
|
-
"sweep" : CommandSweep,
|
|
54
|
-
"build" : CommandBuild,
|
|
55
|
-
"waves" : CommandWaves,
|
|
56
|
-
"upload" : CommandUpload,
|
|
57
|
-
"open" : CommandOpen,
|
|
58
|
-
"export" : CommandExport,
|
|
59
|
-
}
|
|
38
|
+
# For key DEFAULT_HANDLERS, we'll update config['command_handler'] with
|
|
39
|
+
# the actual class using importlib (via opencos.util)
|
|
40
|
+
config['command_handler'] = {}
|
|
41
|
+
for command, str_class in config['DEFAULT_HANDLERS'].items():
|
|
42
|
+
cls = util.import_class_from_string(str_class)
|
|
43
|
+
if not cls:
|
|
44
|
+
util.error(f"config DEFAULT_HANDLERS {command=} {str_class=} could not import")
|
|
45
|
+
else:
|
|
46
|
+
config['command_handler'][command] = cls
|
|
60
47
|
|
|
61
48
|
config['auto_tools_found'] = dict()
|
|
62
49
|
config['tools_loaded'] = set()
|
|
63
|
-
|
|
50
|
+
if run_auto_tool_setup:
|
|
51
|
+
config = auto_tool_setup(config=config, quiet=quiet, tool=tool)
|
|
64
52
|
return config
|
|
65
53
|
|
|
66
54
|
|
|
@@ -154,7 +142,6 @@ def auto_tool_setup(warnings:bool=True, config=None, quiet=False, tool=None) ->
|
|
|
154
142
|
tool='verlator', tool='verilator=/path/to/verilator.exe'
|
|
155
143
|
If so, updates config['auto_tools_order'][tool]['exe']
|
|
156
144
|
'''
|
|
157
|
-
import importlib.util
|
|
158
145
|
|
|
159
146
|
tool = eda_config.update_config_auto_tool_order_for_tool(
|
|
160
147
|
tool=tool, config=config
|
|
@@ -237,7 +224,6 @@ def tool_setup(tool: str, config: dict, quiet: bool = False, auto_setup: bool =
|
|
|
237
224
|
tool='verlator', tool='verilator=/path/to/verilator.exe'
|
|
238
225
|
|
|
239
226
|
'''
|
|
240
|
-
import importlib
|
|
241
227
|
|
|
242
228
|
tool = eda_config.update_config_auto_tool_order_for_tool(
|
|
243
229
|
tool=tool, config=config
|
|
@@ -281,10 +267,7 @@ def tool_setup(tool: str, config: dict, quiet: bool = False, auto_setup: bool =
|
|
|
281
267
|
# skip, already has a tool associated with it, and we're in auto_setup=True
|
|
282
268
|
continue
|
|
283
269
|
|
|
284
|
-
|
|
285
|
-
cls = util.import_class_from_string(str_class_name)
|
|
286
|
-
else:
|
|
287
|
-
cls = globals().get(str_class_name, None)
|
|
270
|
+
cls = util.import_class_from_string(str_class_name)
|
|
288
271
|
|
|
289
272
|
assert issubclass(cls, Tool), f'{str_class_name=} is does not have Tool class associated with it'
|
|
290
273
|
util.debug(f'Setting {cls=} for {command=} in config.command_handler')
|
|
@@ -302,6 +285,7 @@ def process_tokens(tokens: list, original_args: list, config: dict, interactive=
|
|
|
302
285
|
|
|
303
286
|
deferred_tokens = []
|
|
304
287
|
command = ""
|
|
288
|
+
run_auto_tool_setup = True
|
|
305
289
|
|
|
306
290
|
parser = eda_base.get_argparser()
|
|
307
291
|
try:
|
|
@@ -324,22 +308,29 @@ def process_tokens(tokens: list, original_args: list, config: dict, interactive=
|
|
|
324
308
|
if parsed.eda_safe:
|
|
325
309
|
eda_config.update_config_for_eda_safe(config)
|
|
326
310
|
|
|
311
|
+
util.debug(f'eda process_tokens: {parsed=} {unparsed=}')
|
|
312
|
+
|
|
313
|
+
# Attempt to get the 'command' in the unparsed args before we've even
|
|
314
|
+
# set the command handlers (some commands don't use tools).
|
|
315
|
+
for value in unparsed:
|
|
316
|
+
if value in config['DEFAULT_HANDLERS'].keys():
|
|
317
|
+
command = value
|
|
318
|
+
if value in config['command_uses_no_tools']:
|
|
319
|
+
run_auto_tool_setup = False
|
|
320
|
+
unparsed.remove(value)
|
|
321
|
+
break
|
|
322
|
+
|
|
327
323
|
if not interactive:
|
|
328
324
|
# Run init_config() now, we deferred it in main(), but only run it
|
|
329
325
|
# for this tool (or tool=None to figure it out)
|
|
330
|
-
config = init_config(
|
|
326
|
+
config = init_config(
|
|
327
|
+
config, tool=parsed.tool,
|
|
328
|
+
run_auto_tool_setup=run_auto_tool_setup
|
|
329
|
+
)
|
|
331
330
|
if not config:
|
|
332
331
|
util.error(f'eda.py main: problem loading config, {args=}')
|
|
333
332
|
return 3
|
|
334
333
|
|
|
335
|
-
|
|
336
|
-
util.debug(f'eda process_tokens: {parsed=} {unparsed=}')
|
|
337
|
-
for value in unparsed:
|
|
338
|
-
if value in config['command_handler'].keys():
|
|
339
|
-
command = value
|
|
340
|
-
unparsed.remove(value)
|
|
341
|
-
break
|
|
342
|
-
|
|
343
334
|
# Deal with help, now that we have the command (if it was set).
|
|
344
335
|
if parsed.help:
|
|
345
336
|
if not command:
|
|
@@ -363,7 +354,9 @@ def process_tokens(tokens: list, original_args: list, config: dict, interactive=
|
|
|
363
354
|
util.debug(f'{command=}')
|
|
364
355
|
util.debug(f'{sco.config=}')
|
|
365
356
|
util.debug(f'{type(sco)=}')
|
|
366
|
-
if not parsed.tool and
|
|
357
|
+
if not parsed.tool and \
|
|
358
|
+
command not in config.get('command_determines_tool', []) and \
|
|
359
|
+
command not in config.get('command_uses_no_tools', []):
|
|
367
360
|
use_tool = which_tool(command, config)
|
|
368
361
|
util.info(f"--tool not specified, using default for {command=}: {use_tool}")
|
|
369
362
|
|
|
@@ -377,7 +370,7 @@ def process_tokens(tokens: list, original_args: list, config: dict, interactive=
|
|
|
377
370
|
sco.config['eda_original_args'] = original_args
|
|
378
371
|
|
|
379
372
|
setattr(sco, 'command_name', command) # as a safeguard, b/c 'command' is not always passed to 'sco'
|
|
380
|
-
unparsed = sco.process_tokens(deferred_tokens)
|
|
373
|
+
unparsed = sco.process_tokens(tokens=deferred_tokens, pwd=os.getcwd())
|
|
381
374
|
|
|
382
375
|
# query the status from the Command object (0 is pass, > 0 is fail)
|
|
383
376
|
rc = getattr(sco, 'status', 1)
|
|
@@ -439,7 +432,6 @@ def main(*args):
|
|
|
439
432
|
# Handle --config-yml= arg
|
|
440
433
|
config, unparsed = eda_config.get_eda_config(unparsed)
|
|
441
434
|
|
|
442
|
-
|
|
443
435
|
# Note - we used to call: config = init_config(config=config)
|
|
444
436
|
# However, we now defer calling init_config(..) until eda.process_tokens(..)
|
|
445
437
|
|
|
@@ -459,22 +451,8 @@ def main(*args):
|
|
|
459
451
|
config=config)
|
|
460
452
|
|
|
461
453
|
|
|
462
|
-
def main_cli(
|
|
454
|
+
def main_cli() -> None:
|
|
463
455
|
''' Returns None, will exit with return code. Entry point for package script or __main__.'''
|
|
464
|
-
|
|
465
|
-
if support_respawn and '--no-respawn' not in sys.argv:
|
|
466
|
-
# If someone called eda.py directly (aka, __name__ == '__main__'),
|
|
467
|
-
# then we still support a legacy mode of operation - where we check
|
|
468
|
-
# for OC_ROOT (in env, or git repo) to make sure this is the right
|
|
469
|
-
# location of eda.py by calling main_cli(support_respawn=True).
|
|
470
|
-
# Otherwise, we do not respawn $OC_ROOT/bin/eda.py
|
|
471
|
-
# Can also be avoided with --no-respawn.
|
|
472
|
-
|
|
473
|
-
# Note - respawn will never work if calling as a package executable script,
|
|
474
|
-
# which is why our package entrypoint will be main_cli() w/out support_respawn.
|
|
475
|
-
main_maybe_respawn()
|
|
476
|
-
|
|
477
|
-
|
|
478
456
|
signal.signal(signal.SIGINT, signal_handler)
|
|
479
457
|
util.global_exit_allowed = True
|
|
480
458
|
# Strip eda or eda.py from sys.argv, we know who we are if called from __main__:
|
|
@@ -482,46 +460,8 @@ def main_cli(support_respawn=False):
|
|
|
482
460
|
util.exit(rc)
|
|
483
461
|
|
|
484
462
|
|
|
485
|
-
def main_maybe_respawn():
|
|
486
|
-
''' Returns None, will respawn - run - exit, or will return and the command
|
|
487
|
-
|
|
488
|
-
is expected to run in main_cli()'''
|
|
489
|
-
|
|
490
|
-
# First we check if we are respawning
|
|
491
|
-
this_path = os.path.realpath(__file__)
|
|
492
|
-
if debug_respawn: util.info(f"RESPAWN: this_path : '{this_path}'")
|
|
493
|
-
oc_root = util.get_oc_root()
|
|
494
|
-
if debug_respawn: util.info(f"RESPAWN: oc_root : '{oc_root}'")
|
|
495
|
-
cwd = util.getcwd()
|
|
496
|
-
if debug_respawn: util.info(f"RESPAWN: cwd : '{cwd}'")
|
|
497
|
-
if oc_root:
|
|
498
|
-
new_paths = [
|
|
499
|
-
os.path.join(oc_root, 'opencos', 'eda.py'),
|
|
500
|
-
os.path.join(oc_root, 'bin', 'eda'),
|
|
501
|
-
]
|
|
502
|
-
if debug_respawn: util.info(f"RESPAWN: {new_paths=} {this_path=}")
|
|
503
|
-
if this_path not in new_paths and os.path.exists(new_paths[0]):
|
|
504
|
-
# we are not the correct version of EDA for this Git repo, we should respawn
|
|
505
|
-
util.info(f"{this_path} respawning {new_paths[0]} in {cwd} with --no-respawn")
|
|
506
|
-
sys.argv[0] = new_paths[0]
|
|
507
|
-
sys.argv.insert(1, '--no-respawn')
|
|
508
|
-
proc = subprocess.Popen(sys.argv, shell=0, cwd=cwd, universal_newlines=True)
|
|
509
|
-
while True:
|
|
510
|
-
try:
|
|
511
|
-
proc.communicate()
|
|
512
|
-
break
|
|
513
|
-
except KeyboardInterrupt:
|
|
514
|
-
continue
|
|
515
|
-
# get exit status from proc and return it
|
|
516
|
-
util.exit(proc.returncode, quiet=True)
|
|
517
|
-
else:
|
|
518
|
-
if debug_respawn: util.info(f"RESPAWN: {oc_root=} respawn not necessary")
|
|
519
|
-
else:
|
|
520
|
-
if debug_respawn: util.info("RESPAWN: respawn not necessary")
|
|
521
|
-
|
|
522
|
-
|
|
523
463
|
if __name__ == '__main__':
|
|
524
|
-
main_cli(
|
|
464
|
+
main_cli()
|
|
525
465
|
|
|
526
466
|
# IDEAS:
|
|
527
467
|
# * options with no default (i.e. if user doesn't override, THEN we set it, like "seed" or "work-dir") can be given a
|
|
@@ -550,7 +550,7 @@ class Command:
|
|
|
550
550
|
self.set_tool_defines()
|
|
551
551
|
|
|
552
552
|
|
|
553
|
-
def help(self, tokens: list = []):
|
|
553
|
+
def help(self, tokens: list = []) -> None:
|
|
554
554
|
'''Since we don't quite follow standard argparger help()/usage(), we'll format our own
|
|
555
555
|
|
|
556
556
|
if self.args_help has additional help information.
|
|
@@ -569,8 +569,13 @@ class Command:
|
|
|
569
569
|
|
|
570
570
|
print_base_help()
|
|
571
571
|
lines = []
|
|
572
|
+
if not self.args:
|
|
573
|
+
print(f'Unparsed args: {tokens}')
|
|
574
|
+
return
|
|
575
|
+
|
|
572
576
|
if self.command_name:
|
|
573
|
-
lines.append(f"Generic help for command='{self.command_name}'
|
|
577
|
+
lines.append(f"Generic help for command='{self.command_name}'"
|
|
578
|
+
f" (using '{self.__class__.__name__}')")
|
|
574
579
|
else:
|
|
575
580
|
lines.append(f"Generic help (from class Command):")
|
|
576
581
|
|
|
@@ -752,7 +757,7 @@ class CommandDesign(Command):
|
|
|
752
757
|
# token = '\'+define+OC_ROOT="/foo/bar/opencos"\''
|
|
753
758
|
# So we strip all outer ' or " on the plusarg:
|
|
754
759
|
plusarg = util.strip_outer_quotes(plusarg)
|
|
755
|
-
if pwd
|
|
760
|
+
if not pwd:
|
|
756
761
|
pwd = ''
|
|
757
762
|
|
|
758
763
|
if plusarg.startswith('+define+'):
|
|
@@ -15,9 +15,11 @@ class Defaults:
|
|
|
15
15
|
home_override_config_yml = os.path.join(
|
|
16
16
|
os.environ.get('HOME', ''), '.opencos-eda', 'EDA_CONFIG.yml'
|
|
17
17
|
)
|
|
18
|
-
|
|
18
|
+
opencos_config_yml = 'eda_config_defaults.yml'
|
|
19
|
+
config_yml = ''
|
|
19
20
|
|
|
20
21
|
supported_config_keys = set([
|
|
22
|
+
'DEFAULT_HANDLERS',
|
|
21
23
|
'defines',
|
|
22
24
|
'dep_command_enables',
|
|
23
25
|
'dep_tags_enables',
|
|
@@ -26,10 +28,11 @@ class Defaults:
|
|
|
26
28
|
'bare_plusarg_supported',
|
|
27
29
|
'dep_sub',
|
|
28
30
|
'vars',
|
|
29
|
-
'tools',
|
|
30
|
-
'auto_tools_order',
|
|
31
31
|
'file_extensions',
|
|
32
32
|
'command_determines_tool',
|
|
33
|
+
'command_uses_no_tools',
|
|
34
|
+
'tools',
|
|
35
|
+
'auto_tools_order',
|
|
33
36
|
])
|
|
34
37
|
supported_config_auto_tools_order_keys = set([
|
|
35
38
|
'exe', 'handlers', 'requires_env', 'requires_py', 'requires_cmd',
|
|
@@ -53,6 +56,14 @@ class Defaults:
|
|
|
53
56
|
])
|
|
54
57
|
|
|
55
58
|
|
|
59
|
+
if os.path.exists(Defaults.environ_override_config_yml):
|
|
60
|
+
Defaults.config_yml = Defaults.environ_override_config_yml
|
|
61
|
+
elif os.path.exists(Defaults.home_override_config_yml):
|
|
62
|
+
Defaults.config_yml = Defaults.home_override_config_yml
|
|
63
|
+
else:
|
|
64
|
+
Defaults.config_yml = Defaults.opencos_config_yml
|
|
65
|
+
|
|
66
|
+
|
|
56
67
|
def find_eda_config_yml_fpath(filename:str, package_search_only=False, package_search_enabled=True) -> str:
|
|
57
68
|
'''Locates the filename (.yml) either from fullpath provided or from the sys.path
|
|
58
69
|
opencos package paths.'''
|
|
@@ -192,15 +203,9 @@ def get_config_merged_with_defaults(config:dict) -> dict:
|
|
|
192
203
|
return default_config
|
|
193
204
|
|
|
194
205
|
def get_argparser() -> argparse.ArgumentParser:
|
|
195
|
-
if os.path.exists(Defaults.environ_override_config_yml):
|
|
196
|
-
default_config_yml = Defaults.environ_override_config_yml
|
|
197
|
-
elif os.path.exists(Defaults.home_override_config_yml):
|
|
198
|
-
default_config_yml = Defaults.home_override_config_yml
|
|
199
|
-
else:
|
|
200
|
-
default_config_yml = Defaults.config_yml
|
|
201
206
|
parser = argparse.ArgumentParser(prog='opencos eda config options', add_help=False, allow_abbrev=False)
|
|
202
|
-
parser.add_argument('--config-yml', type=str, default=
|
|
203
|
-
help=f'YAML filename to use for configuration (default {
|
|
207
|
+
parser.add_argument('--config-yml', type=str, default=Defaults.config_yml,
|
|
208
|
+
help=f'YAML filename to use for configuration (default {Defaults.config_yml})')
|
|
204
209
|
return parser
|
|
205
210
|
|
|
206
211
|
def get_argparser_short_help() -> str:
|
|
@@ -213,6 +218,8 @@ def get_eda_config(args:list, quiet=False) -> (dict, list):
|
|
|
213
218
|
|
|
214
219
|
Handles args for:
|
|
215
220
|
--config-yml=<YAMLFILE>
|
|
221
|
+
|
|
222
|
+
This will merge the result with the default config (if overriden)
|
|
216
223
|
'''
|
|
217
224
|
|
|
218
225
|
parser = get_argparser()
|
|
@@ -237,5 +244,7 @@ def get_eda_config(args:list, quiet=False) -> (dict, list):
|
|
|
237
244
|
else:
|
|
238
245
|
config = None
|
|
239
246
|
|
|
247
|
+
if parsed.config_yml != Defaults.config_yml:
|
|
248
|
+
config = get_config_merged_with_defaults(config)
|
|
240
249
|
|
|
241
250
|
return config, unparsed
|
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
# python mergedeep with Strategy.TYPESAFE_REPLACE. I considered doing TYPESAFE_ADDITIVE but then
|
|
4
4
|
# the user would lose full control over existing list values.
|
|
5
5
|
|
|
6
|
+
DEFAULT_HANDLERS:
|
|
7
|
+
# These commands (sim, elab, etc) require a tool, but have a default handler
|
|
8
|
+
# base class:
|
|
9
|
+
sim : opencos.commands.CommandSim
|
|
10
|
+
elab : opencos.commands.CommandElab
|
|
11
|
+
synth : opencos.commands.CommandSynth
|
|
12
|
+
flist : opencos.commands.CommandFList
|
|
13
|
+
proj : opencos.commands.CommandProj
|
|
14
|
+
build : opencos.commands.CommandBuild
|
|
15
|
+
upload : opencos.commands.CommandUpload
|
|
16
|
+
open : opencos.commands.CommandOpen
|
|
17
|
+
# These commands don't necessarily require a tool
|
|
18
|
+
multi : opencos.commands.CommandMulti
|
|
19
|
+
tools-multi : opencos.commands.CommandToolsMulti
|
|
20
|
+
sweep : opencos.commands.CommandSweep
|
|
21
|
+
# These commands (waves, export, targets) do not require a tool, or
|
|
22
|
+
# will self determine the tool:
|
|
23
|
+
waves : opencos.commands.CommandWaves
|
|
24
|
+
export : opencos.commands.CommandExport
|
|
25
|
+
targets : opencos.commands.CommandTargets
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
defines: { } # Add these defines to every eda call
|
|
7
29
|
|
|
8
30
|
dep_command_enables:
|
|
@@ -47,9 +69,14 @@ file_extensions:
|
|
|
47
69
|
- .vhdl
|
|
48
70
|
|
|
49
71
|
command_determines_tool:
|
|
50
|
-
# eda commands that will self-determine the tool to use
|
|
72
|
+
# eda commands that will self-determine the tool to use
|
|
51
73
|
- waves
|
|
52
74
|
|
|
75
|
+
command_uses_no_tools:
|
|
76
|
+
# eda commands that do not use a tool at all, will skip auto_tools_order
|
|
77
|
+
- export
|
|
78
|
+
- targets
|
|
79
|
+
|
|
53
80
|
|
|
54
81
|
tools:
|
|
55
82
|
|
|
@@ -35,7 +35,7 @@ _eda_script_completion() {
|
|
|
35
35
|
if [ -z "${completions}" ]; then
|
|
36
36
|
# If we didn't find anything in a DEPS.[yml|yaml|toml|json], then use:
|
|
37
37
|
# 1. a bunch of known eda words or args.
|
|
38
|
-
eda_words="multi sim elab flist build synth waves proj waves \
|
|
38
|
+
eda_words="multi sim elab flist build synth waves proj waves targets \
|
|
39
39
|
+define+ +incdirs+ \
|
|
40
40
|
--help --quiet --verbose --debug \
|
|
41
41
|
--tool --seed --top --keep --force --fake --lint --work-dir \
|
|
@@ -72,12 +72,8 @@ def print_columns_manual(data: list, num_columns: int = 4, auto_columns: bool =
|
|
|
72
72
|
if col_index == num_columns - 1 or i == len(data) - 1:
|
|
73
73
|
print() # New line at the end of a row or end of data
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
'''Returns None, prints DEPS keys into pretty columns, using arg
|
|
78
|
-
|
|
79
|
-
partial_path as a string filter for target completions.
|
|
80
|
-
'''
|
|
75
|
+
def get_path_and_pattern(partial_path: str = '', base_path=str(Path('.'))) -> (str, str):
|
|
76
|
+
'''Returns tuple of (partial_path, partial_target or filter)'''
|
|
81
77
|
partial_target = ''
|
|
82
78
|
if not partial_path or partial_path == str(Path('.')):
|
|
83
79
|
partial_path = PATH_LPREFIX
|
|
@@ -86,18 +82,40 @@ def run(partial_path: str = '', base_path=str(Path('.'))) -> None:
|
|
|
86
82
|
if not partial_path:
|
|
87
83
|
partial_path = PATH_LPREFIX
|
|
88
84
|
|
|
89
|
-
|
|
90
|
-
keys = get_all_targets(
|
|
91
|
-
dirs=[partial_path],
|
|
92
|
-
base_path=base_path,
|
|
93
|
-
filter_str=partial_target,
|
|
94
|
-
error_on_empty_return=False,
|
|
95
|
-
lstrip_path=True
|
|
96
|
-
)
|
|
97
|
-
except:
|
|
98
|
-
keys = []
|
|
85
|
+
return partial_path, partial_target
|
|
99
86
|
|
|
100
|
-
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def run(partial_paths: list, base_path=str(Path('.'))) -> None:
|
|
90
|
+
'''Returns None, prints DEPS keys into pretty columns, using arg
|
|
91
|
+
|
|
92
|
+
partial_path as a string filter for target completions.
|
|
93
|
+
'''
|
|
94
|
+
|
|
95
|
+
targets_set = set()
|
|
96
|
+
if not partial_paths:
|
|
97
|
+
partial_paths = [PATH_LPREFIX] # run on current directory.
|
|
98
|
+
|
|
99
|
+
for partial_path in partial_paths:
|
|
100
|
+
partial_path, partial_target = get_path_and_pattern(
|
|
101
|
+
partial_path=partial_path, base_path=base_path
|
|
102
|
+
)
|
|
103
|
+
try:
|
|
104
|
+
keys = get_all_targets(
|
|
105
|
+
dirs=[partial_path],
|
|
106
|
+
base_path=base_path,
|
|
107
|
+
filter_str=partial_target,
|
|
108
|
+
error_on_empty_return=False,
|
|
109
|
+
lstrip_path=True
|
|
110
|
+
)
|
|
111
|
+
except:
|
|
112
|
+
keys = []
|
|
113
|
+
for key in keys:
|
|
114
|
+
targets_set.add(key)
|
|
115
|
+
|
|
116
|
+
data = list(targets_set)
|
|
117
|
+
data.sort()
|
|
118
|
+
print_columns_manual(data=data, num_columns=4, auto_columns=True)
|
|
101
119
|
|
|
102
120
|
|
|
103
121
|
def main() -> None:
|
|
@@ -109,8 +127,8 @@ def main() -> None:
|
|
|
109
127
|
if len(sys.argv) > 1:
|
|
110
128
|
partial_path = sys.argv[1]
|
|
111
129
|
else:
|
|
112
|
-
partial_path =
|
|
113
|
-
run(partial_path)
|
|
130
|
+
partial_path = ''
|
|
131
|
+
run(partial_paths=[partial_path])
|
|
114
132
|
|
|
115
133
|
|
|
116
134
|
if __name__ == "__main__":
|
|
@@ -29,7 +29,7 @@ ALL_FORCED_PREFIXES = set(list(FORCE_PREFIX_DICT.keys()))
|
|
|
29
29
|
|
|
30
30
|
def get_source_file(target:str) -> (bool, str, str):
|
|
31
31
|
'''Returns tuple: bool if file exists, filepath str, and optional forced file type str'''
|
|
32
|
-
if os.path.
|
|
32
|
+
if os.path.isfile(target):
|
|
33
33
|
# target exists as a file, return True w/ original target:
|
|
34
34
|
return True, target, ''
|
|
35
35
|
|
|
@@ -37,7 +37,7 @@ def get_source_file(target:str) -> (bool, str, str):
|
|
|
37
37
|
for p in ALL_FORCED_PREFIXES:
|
|
38
38
|
if p in target:
|
|
39
39
|
fpath = ''.join(target.split(p)) # essentially just removing the "sv@" or whatever it is
|
|
40
|
-
if os.path.
|
|
40
|
+
if os.path.isfile(fpath):
|
|
41
41
|
return True, fpath, FORCE_PREFIX_DICT.get(p)
|
|
42
42
|
|
|
43
43
|
# target or fpath didn't exist, return False with the original target:
|
|
@@ -142,13 +142,14 @@ class Helpers:
|
|
|
142
142
|
# TODO(drew): There are some issues with log_it redirecting stdout from vivado
|
|
143
143
|
# and modelsim_ase. So this may not work for all tools, you may have to directly
|
|
144
144
|
# look at eda.work/{target}.sim/sim.log or xsim.log.
|
|
145
|
+
print(f'{os.getcwd()=}')
|
|
146
|
+
print(f'{command_str=}')
|
|
145
147
|
with open(logfile, 'w', encoding='utf-8') as f:
|
|
146
|
-
with redirect_stdout(f):
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
rc = eda.main(*(command_str.split()))
|
|
148
|
+
with redirect_stdout(f), redirect_stderr(f):
|
|
149
|
+
if use_eda_wrap:
|
|
150
|
+
rc = eda_wrap(*(command_str.split()))
|
|
151
|
+
else:
|
|
152
|
+
rc = eda.main(*(command_str.split()))
|
|
152
153
|
print(f'Wrote: {os.path.abspath(logfile)=}')
|
|
153
154
|
return rc
|
|
154
155
|
|
|
@@ -53,6 +53,28 @@ def test_args_sim_default_tool():
|
|
|
53
53
|
assert rc == 0
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
class TestTargets(Helpers):
|
|
57
|
+
'''Tests for: eda targets'''
|
|
58
|
+
|
|
59
|
+
DEFAULT_DIR = os.path.join(THISPATH, '..', '..', 'lib', 'tests')
|
|
60
|
+
|
|
61
|
+
def test_lib_tests__no_pattern(self):
|
|
62
|
+
'''Test that this works: eda targets'''
|
|
63
|
+
self.chdir()
|
|
64
|
+
rc = self.log_it('targets --debug', use_eda_wrap=False)
|
|
65
|
+
assert rc == 0
|
|
66
|
+
assert self.is_in_log('oclib_fifo_test')
|
|
67
|
+
assert self.is_in_log('oclib_rrarb_test')
|
|
68
|
+
|
|
69
|
+
def test_lib_tests__with_pattern(self):
|
|
70
|
+
'''Test that this works: eda targets oclib_fifo*test'''
|
|
71
|
+
self.chdir()
|
|
72
|
+
rc = self.log_it('targets oclib_fifo*test', use_eda_wrap=False)
|
|
73
|
+
assert rc == 0
|
|
74
|
+
assert self.is_in_log('oclib_fifo_test')
|
|
75
|
+
assert not self.is_in_log('oclib_rrarb_test')
|
|
76
|
+
|
|
77
|
+
|
|
56
78
|
@pytest.mark.skipif(
|
|
57
79
|
'verilator' not in tools_loaded, reason="requires verilator"
|
|
58
80
|
)
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
# pylint: disable=R0801 # (duplicate code in derived classes, such as if-condition return.)
|
|
4
4
|
|
|
5
|
-
import shutil
|
|
6
5
|
import importlib.util
|
|
7
6
|
|
|
8
7
|
from opencos import util
|
|
@@ -22,11 +21,11 @@ class ToolInvio(Tool):
|
|
|
22
21
|
if self._VERSION:
|
|
23
22
|
return self._VERSION
|
|
24
23
|
|
|
25
|
-
# We also have to make sure
|
|
26
|
-
invio_py_path = shutil.which('invio-py')
|
|
24
|
+
# We also have to make sure we can import invio within python.
|
|
27
25
|
spec = importlib.util.find_spec('invio')
|
|
28
|
-
if not spec
|
|
29
|
-
self.error('"invio
|
|
26
|
+
if not spec:
|
|
27
|
+
self.error('"invio" package not in python env')
|
|
28
|
+
|
|
30
29
|
|
|
31
30
|
return super().get_versions()
|
|
32
31
|
|