opencos-eda 0.2.34__py3-none-any.whl → 0.2.35__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
opencos/deps_helpers.py CHANGED
@@ -261,7 +261,8 @@ def get_all_targets(
261
261
  base_path: str = os.getcwd(),
262
262
  filter_str: str = '',
263
263
  filter_using_multi: str = '',
264
- error_on_empty_return: bool = True
264
+ error_on_empty_return: bool = True,
265
+ lstrip_path: bool = True
265
266
  ) -> list:
266
267
  '''Returns a list of [dir/target, ... ] using relpath from base_path
267
268
 
@@ -273,6 +274,8 @@ def get_all_targets(
273
274
  To all targets from dirs.
274
275
  '''
275
276
 
277
+ _path_lprefix = str(Path('.')) + os.path.sep
278
+
276
279
  if filter_using_multi:
277
280
  targets = []
278
281
  orig_dir = os.path.abspath(os.getcwd())
@@ -295,9 +298,10 @@ def get_all_targets(
295
298
  this_dir, leaf_target = os.path.split(target)
296
299
  if fnmatch_or_re(pattern=filter_str,
297
300
  string=leaf_target):
298
- targets.add(
299
- os.path.join(os.path.relpath(this_dir, start=base_path), leaf_target)
300
- )
301
+ t = os.path.join(os.path.relpath(this_dir, start=base_path), leaf_target)
302
+ if lstrip_path:
303
+ t = t.removeprefix(_path_lprefix)
304
+ targets.add(t)
301
305
  targets = list(targets)
302
306
  if not targets and error_on_empty_return:
303
307
  error(f'get_all_targets: {base_path=} {filter_using_multi=} returned no targets')
@@ -314,9 +318,10 @@ def get_all_targets(
314
318
  for leaf_target in deps_data_get_all_targets(data):
315
319
  if not filter_str or fnmatch_or_re(pattern=filter_str,
316
320
  string=leaf_target):
317
- targets.add(
318
- os.path.join(os.path.relpath(this_dir, start=base_path), leaf_target)
319
- )
321
+ t = os.path.join(os.path.relpath(this_dir, start=base_path), leaf_target)
322
+ if lstrip_path:
323
+ t = t.removeprefix(_path_lprefix)
324
+ targets.add(t)
320
325
 
321
326
  if not targets and error_on_empty_return:
322
327
  error(f'get_all_targets: {base_path=} {dirs=} {filter_str=} returned no targets')
@@ -144,7 +144,6 @@ tools:
144
144
 
145
145
  coverage-args: |
146
146
  --annotate logs/annotated
147
- --annotate-min 1
148
147
  coverage.dat
149
148
 
150
149
  # If you want to set your own run-time plusarg on all verilator exe's for --waves,
@@ -7,75 +7,111 @@ targets from DEPS files
7
7
 
8
8
  import sys
9
9
  import os
10
+ from pathlib import Path
10
11
  import json
11
12
 
12
13
  import yaml
13
14
  import toml
14
15
 
15
- from opencos.deps_helpers import get_deps_markup_file
16
+ from opencos.deps_helpers import get_all_targets
16
17
 
17
- def get_markup_table_keys(partial_path='./') -> list:
18
- '''Returns a list of root level keys for DEPS.[yml|yaml|toml|json]
18
+ PATH_LPREFIX = str(Path('.')) + os.path.sep
19
19
 
20
- Does not include DEFAULTS.
20
+
21
+ def get_terminal_columns():
22
+ """
23
+ Retrieves the number of columns (width) of the terminal window.
24
+
25
+ Returns:
26
+ int: The number of columns in the terminal, or a default value (e.g., 80)
27
+ if the terminal size cannot be determined.
28
+ """
29
+ try:
30
+ size = os.get_terminal_size()
31
+ return size.columns
32
+ except OSError:
33
+ # Handle cases where the terminal size cannot be determined (e.g., not in a TTY)
34
+ return 80 # Default to 80 columns
35
+ else:
36
+ return 80
37
+
38
+
39
+ def print_columns_manual(data: list, num_columns: int = 4, auto_columns: bool = True) -> None:
40
+ """Prints a list of strings in columns, manually aligning them."""
41
+ if not data:
42
+ print()
43
+ return
44
+
45
+ _spacing = 2
46
+
47
+ # Calculate maximum width for each column
48
+ max_lengths = [0] * num_columns
49
+ max_item_len = 0
50
+ for i, item in enumerate(data):
51
+ col_index = i % num_columns
52
+ max_lengths[col_index] = max(max_lengths[col_index], len(item))
53
+ max_item_len = max(max_item_len, len(item))
54
+
55
+ if auto_columns and num_columns > 1:
56
+ window_cols = get_terminal_columns()
57
+ max_line_len = 0
58
+ for x in max_lengths:
59
+ max_line_len += x + _spacing
60
+ if max_line_len > window_cols:
61
+ # subtract a column (already >= 2):
62
+ return print_columns_manual(data=data, num_columns=num_columns-1, auto_columns=True)
63
+ if max_line_len + max_item_len + _spacing < window_cols:
64
+ # add 1 more column if we're guaranteed to have room.
65
+ return print_columns_manual(data=data, num_columns=num_columns+1, auto_columns=True)
66
+ # else continue
67
+
68
+ # Print data in columns
69
+ for i, item in enumerate(data):
70
+ col_index = i % num_columns
71
+ print(item.ljust(max_lengths[col_index] + _spacing), end="") # Add padding
72
+ if col_index == num_columns - 1 or i == len(data) - 1:
73
+ print() # New line at the end of a row or end of data
74
+
75
+
76
+ def run(partial_path: str = '', base_path=str(Path('.'))) -> None:
77
+ '''Returns None, prints DEPS keys into pretty columns, using arg
78
+
79
+ partial_path as a string filter for target completions.
21
80
  '''
22
81
  partial_target = ''
23
- if not partial_path or partial_path == '.':
24
- partial_path = './'
25
-
82
+ if not partial_path or partial_path == str(Path('.')):
83
+ partial_path = PATH_LPREFIX
26
84
  if not os.path.exists(partial_path):
27
85
  partial_path, partial_target = os.path.split(partial_path)
28
86
  if not partial_path:
29
- partial_path = './'
87
+ partial_path = PATH_LPREFIX
30
88
 
31
- filepath = get_deps_markup_file(base_path=partial_path)
32
- if not filepath:
33
- # Couldn't find a DEPS file, let bash completion handle it (with -W words or -G glob)
34
- return []
35
-
36
- data = {}
37
- _, file_ext = os.path.splitext(filepath)
38
89
  try:
39
- if file_ext in ['', '.yml', 'yaml']:
40
- with open(filepath, 'r', encoding='utf-8') as f:
41
- data = yaml.safe_load(f)
42
- elif file_ext == '.toml':
43
- data = toml.load(filepath)
44
- elif file_ext == '.json':
45
- with open(filepath, 'r', encoding='utf-8') as f:
46
- data = json.load(f)
47
- except Exception: # pylint: disable=broad-exception-caught
48
- return []
49
-
50
- if not isinstance(data, dict):
51
- # We found a DEPS file, but it wasn't a table/dict so we can't return root keys
52
- return []
53
-
54
- # Try to resolve path/to/target/partial_target_
55
- # -- prepend path information to found targets in path/to/target/DEPS
56
- prepend = ''
57
- if partial_path and partial_path != './':
58
- prepend = partial_path
59
- if not partial_path.endswith('/'):
60
- prepend += '/'
61
-
62
- # Return the list of keys w/ prepended path information, and don't include
63
- # uppercase strings like 'DEFAULTS' or 'METADATA'
64
- return [
65
- prepend + x for x in list(data.keys()) if x.startswith(partial_target) and not x.isupper()
66
- ]
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 = []
99
+
100
+ print_columns_manual(data=keys, num_columns=4, auto_columns=True)
67
101
 
68
102
 
69
103
  def main() -> None:
70
- '''Returns None, prints DEPS keys space separated, uses sys.argv for a single
71
- partial path arg (DEPS file to examine)'''
104
+ '''Returns None, prints DEPS keys into pretty columns, uses sys.argv[1] for args:
105
+
106
+ sys.args[1] -- optional partial path for target completions
107
+ '''
72
108
 
73
109
  if len(sys.argv) > 1:
74
110
  partial_path = sys.argv[1]
75
111
  else:
76
- partial_path = './'
77
- keys = get_markup_table_keys(partial_path)
78
- print(" ".join(keys))
112
+ partial_path = PATH_LPREFIX
113
+ run(partial_path)
114
+
79
115
 
80
116
  if __name__ == "__main__":
81
117
  main()
@@ -78,6 +78,7 @@ class VerilatorSim(CommandSim, ToolVerilator):
78
78
  'dump-vcd': False,
79
79
  'lint-only': False,
80
80
  'cc-mode': False,
81
+ 'verilator-coverage-args': [],
81
82
  })
82
83
 
83
84
  self.args_help.update({
@@ -303,9 +304,11 @@ class VerilatorSim(CommandSim, ToolVerilator):
303
304
  verilated_post_exec_coverage_command_list = [self.verilator_coverage_exe]
304
305
  config_coverage_args = self.tool_config.get(
305
306
  'coverage-args',
306
- '--annotate logs/annotated --annotate-min 1 coverage.dat').split()
307
+ '--annotate logs/annotated coverage.dat').split()
308
+
309
+ verilated_post_exec_coverage_command_list += \
310
+ config_coverage_args + self.args['verilator-coverage-args']
307
311
 
308
- verilated_post_exec_coverage_command_list += config_coverage_args
309
312
 
310
313
  return [ util.ShellCommandList(verilated_post_exec_coverage_command_list,
311
314
  tee_fpath='coverage.log') ] # single entry list
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opencos-eda
3
- Version: 0.2.34
3
+ Version: 0.2.35
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
@@ -1,16 +1,16 @@
1
1
  opencos/__init__.py,sha256=ZQ7aOCbP0jkIMYGdVrb-mkZX3rnvaK8epBkmp506tXU,85
2
2
  opencos/_version.py,sha256=qN7iBoOv-v4tEZz-Pu9sVUJwefshJOsgdaddn8HcHio,510
3
3
  opencos/_waves_pkg.sv,sha256=1lbhQOVGc3t_R8czYjP40hssP0I3FlZOpHTkI7yKFbI,1251
4
- opencos/deps_helpers.py,sha256=zM9n6k61jaW9SE7VTtfMNaF8oA9UFloEcI685NLOpIQ,56711
4
+ opencos/deps_helpers.py,sha256=Pgo3dO_QBHzGB0lE2B0uf2vWWDy3dSDN0pvW-eA6ocs,56939
5
5
  opencos/deps_schema.py,sha256=MhytzXwp071F14RwxqHt78ak8Qruoe4FeK5XSzkO2f0,14658
6
6
  opencos/eda.py,sha256=NCsSAnWANumzP2EzlsT-TvGUEuY8ONpHo-cvTcWC2wM,21261
7
7
  opencos/eda_base.py,sha256=Fi21IIKvYIzyj_vQtaqPwrUXDaszfIixoB80-TQMM2k,77455
8
8
  opencos/eda_config.py,sha256=CXfFVW4QOtP1gpMcX8JhCe93_aibcdbGoS7RAiYQnOs,8561
9
- opencos/eda_config_defaults.yml,sha256=V4Pns5x77GzN6O-azBHwpOEKRDrLmlqIa89GFQnrrJ8,9218
9
+ opencos/eda_config_defaults.yml,sha256=4ryY9THfaeL2kclo5KLkC7F1_g7FbjVzDMQFdAsvTl0,9195
10
10
  opencos/eda_config_max_verilator_waivers.yml,sha256=lTAU4IOEbUWVlPzuer1YYhIyxpPINeA4EJqcRIT-Ymk,840
11
11
  opencos/eda_config_reduced.yml,sha256=2mV9CiUEj_tyJnQsC9_k0RlxuBrky0zW1HX2xlDVEjU,1469
12
12
  opencos/eda_deps_bash_completion.bash,sha256=X0ennY88UmwevqW9Ihi_kPyOnmkGa-23_k1v_zvRvkc,1960
13
- opencos/eda_extract_deps_keys.py,sha256=o3GR-W3wLERRa36f_2jOcyM5iemMYHD8oBq_RQQKM-0,2411
13
+ opencos/eda_extract_deps_keys.py,sha256=Qc4IEx82ZNY2bLNYY0htpB4XLT-Mr2JQfPriyRigWkI,3467
14
14
  opencos/eda_tool_helper.py,sha256=MxNd_ImyA13DZbzMol1R5H8tJZddJfqyDgFVR2ad374,1666
15
15
  opencos/export_helper.py,sha256=EBlfJcA5dN176UnaXjUgLhCN1Vu5jBTI1EzL9w4j5gM,19662
16
16
  opencos/export_json_convert.py,sha256=KsP1ESmSWs8ouecDC5ikuwOFZNJtLjmiYOvYLeN5UZU,3768
@@ -63,13 +63,13 @@ opencos/tools/slang.py,sha256=74EDAAnN7mrrYxgxaPDaoRJZK7Se9B_HsW8Ioi2Nw44,7425
63
63
  opencos/tools/slang_yosys.py,sha256=8zLwScd3PjouuLQpLvpX837kGqYQiJ9bnButCwrmSqI,15047
64
64
  opencos/tools/surelog.py,sha256=JOMs8SqnzJ_ZL5mEdyyn3Z1r1Kc8hfbV3Pnen1YzxWA,4980
65
65
  opencos/tools/tabbycad_yosys.py,sha256=h9kkAi479cZzYfb4R9WBNY_JmR6BgVFj4s3VShnGpoA,7813
66
- opencos/tools/verilator.py,sha256=NNn9xF-YWFE6B8a9BNeuK-10xNCXPzACqyfKdwuqKTY,17996
66
+ opencos/tools/verilator.py,sha256=0ZHAkkUqnsM1A4B8-u6tff3lhl-cgfDUx-Dq7DaRwkI,18080
67
67
  opencos/tools/vivado.py,sha256=cL5IZdudqquddvZqHQGDVmaHSxgBZsMUmAq18q8AgoM,39134
68
68
  opencos/tools/yosys.py,sha256=Nov3zKyliZ6rHwMbH4f8XEkoo9H66T2-MN-KNQTjWFk,3530
69
- opencos_eda-0.2.34.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
70
- opencos_eda-0.2.34.dist-info/licenses/LICENSE.spdx,sha256=8gn1610RMP6eFgT3Hm6q9VKXt0RvdTItL_oxMo72jII,189
71
- opencos_eda-0.2.34.dist-info/METADATA,sha256=aaIwkGXIKulNSdvr33AIA_v89iT4i5YiTp6rYwt_3ZM,604
72
- opencos_eda-0.2.34.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
73
- opencos_eda-0.2.34.dist-info/entry_points.txt,sha256=777csZnOi0t9uC8lrdTchl9_Lu11t0UTo9xIKLNabNE,176
74
- opencos_eda-0.2.34.dist-info/top_level.txt,sha256=J4JDP-LpRyJqPNeh9bSjx6yrLz2Mk0h6un6YLmtqql4,8
75
- opencos_eda-0.2.34.dist-info/RECORD,,
69
+ opencos_eda-0.2.35.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
70
+ opencos_eda-0.2.35.dist-info/licenses/LICENSE.spdx,sha256=8gn1610RMP6eFgT3Hm6q9VKXt0RvdTItL_oxMo72jII,189
71
+ opencos_eda-0.2.35.dist-info/METADATA,sha256=g8JQBIB51DyH1TV6wEs9vhTUB654EW5Xw1cGIs0jxg8,604
72
+ opencos_eda-0.2.35.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
73
+ opencos_eda-0.2.35.dist-info/entry_points.txt,sha256=777csZnOi0t9uC8lrdTchl9_Lu11t0UTo9xIKLNabNE,176
74
+ opencos_eda-0.2.35.dist-info/top_level.txt,sha256=J4JDP-LpRyJqPNeh9bSjx6yrLz2Mk0h6un6YLmtqql4,8
75
+ opencos_eda-0.2.35.dist-info/RECORD,,