wavekit 0.7.0__tar.gz → 0.7.1__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.
- {wavekit-0.7.0 → wavekit-0.7.1}/PKG-INFO +1 -1
- {wavekit-0.7.0 → wavekit-0.7.1}/pyproject.toml +1 -1
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/__init__.py +1 -1
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/readers/fsdb/npi_fsdb_reader.pyx +181 -281
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/readers/fsdb/reader.py +17 -48
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/readers/hierarchy.py +165 -74
- wavekit-0.7.1/src/wavekit/readers/matcher.py +410 -0
- wavekit-0.7.0/src/wavekit/readers/matcher.py +0 -425
- {wavekit-0.7.0 → wavekit-0.7.1}/LICENSE +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/README.md +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/build.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/pattern/__init__.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/pattern/compiler.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/pattern/dsl.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/pattern/errors.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/pattern/result.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/pattern/runtime.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/pattern/steps.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/readers/base.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/readers/expr_parser.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/readers/fsdb/npi_fsdb.pxd +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/readers/fst/reader.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/readers/range.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/readers/value_change.pyx +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/readers/vcd/reader.py +0 -0
- {wavekit-0.7.0 → wavekit-0.7.1}/src/wavekit/waveform.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# cython: language_level=3
|
|
2
2
|
import ctypes.util
|
|
3
3
|
import os
|
|
4
|
+
import sys
|
|
4
5
|
import numpy as np
|
|
5
6
|
cimport numpy as np
|
|
6
7
|
import cython
|
|
@@ -54,32 +55,33 @@ ctypedef npiFsdbSigIter (*npi_fsdb_iter_member_fn)(npiFsdbSigHandle sig)
|
|
|
54
55
|
ctypedef NPI_INT32 (*npi_fsdb_iter_scope_stop_fn)(npiFsdbScopeIter iter)
|
|
55
56
|
ctypedef NPI_INT32 (*npi_fsdb_iter_sig_stop_fn)(npiFsdbSigIter iter)
|
|
56
57
|
ctypedef NPI_INT32 (*npi_fsdb_release_vct_fn)(npiFsdbVctHandle vct)
|
|
58
|
+
ctypedef NPI_INT32 (*npi_init_fn)(int* argc, char*** argv)
|
|
57
59
|
|
|
58
60
|
cdef void* _npi_lib_handle = NULL
|
|
59
|
-
cdef
|
|
60
|
-
cdef
|
|
61
|
-
cdef
|
|
62
|
-
cdef
|
|
63
|
-
cdef
|
|
64
|
-
cdef
|
|
65
|
-
cdef
|
|
66
|
-
cdef
|
|
67
|
-
cdef
|
|
68
|
-
cdef
|
|
69
|
-
cdef
|
|
70
|
-
cdef
|
|
71
|
-
cdef
|
|
72
|
-
cdef
|
|
73
|
-
cdef
|
|
74
|
-
cdef
|
|
75
|
-
cdef
|
|
76
|
-
cdef
|
|
77
|
-
cdef
|
|
78
|
-
cdef
|
|
79
|
-
cdef
|
|
80
|
-
cdef
|
|
81
|
-
cdef
|
|
82
|
-
cdef
|
|
61
|
+
cdef npi_fsdb_open_fn npi_fsdb_open = NULL
|
|
62
|
+
cdef npi_fsdb_close_fn npi_fsdb_close = NULL
|
|
63
|
+
cdef npi_fsdb_min_time_fn npi_fsdb_min_time = NULL
|
|
64
|
+
cdef npi_fsdb_max_time_fn npi_fsdb_max_time = NULL
|
|
65
|
+
cdef npi_fsdb_sig_by_name_fn npi_fsdb_sig_by_name = NULL
|
|
66
|
+
cdef npi_fsdb_create_vct_fn npi_fsdb_create_vct = NULL
|
|
67
|
+
cdef npi_fsdb_goto_time_fn npi_fsdb_goto_time = NULL
|
|
68
|
+
cdef npi_fsdb_goto_first_fn npi_fsdb_goto_first = NULL
|
|
69
|
+
cdef npi_fsdb_goto_next_fn npi_fsdb_goto_next = NULL
|
|
70
|
+
cdef npi_fsdb_vct_time_fn npi_fsdb_vct_time = NULL
|
|
71
|
+
cdef npi_fsdb_vct_value_fn npi_fsdb_vct_value = NULL
|
|
72
|
+
cdef npi_fsdb_sig_property_fn npi_fsdb_sig_property = NULL
|
|
73
|
+
cdef npi_fsdb_sig_property_str_fn npi_fsdb_sig_property_str = NULL
|
|
74
|
+
cdef npi_fsdb_scope_property_str_fn npi_fsdb_scope_property_str = NULL
|
|
75
|
+
cdef npi_fsdb_iter_top_scope_fn npi_fsdb_iter_top_scope = NULL
|
|
76
|
+
cdef npi_fsdb_iter_child_scope_fn npi_fsdb_iter_child_scope = NULL
|
|
77
|
+
cdef npi_fsdb_iter_scope_next_fn npi_fsdb_iter_scope_next = NULL
|
|
78
|
+
cdef npi_fsdb_iter_sig_next_fn npi_fsdb_iter_sig_next = NULL
|
|
79
|
+
cdef npi_fsdb_iter_sig_fn npi_fsdb_iter_sig = NULL
|
|
80
|
+
cdef npi_fsdb_iter_member_fn npi_fsdb_iter_member = NULL
|
|
81
|
+
cdef npi_fsdb_iter_scope_stop_fn npi_fsdb_iter_scope_stop = NULL
|
|
82
|
+
cdef npi_fsdb_iter_sig_stop_fn npi_fsdb_iter_sig_stop = NULL
|
|
83
|
+
cdef npi_fsdb_release_vct_fn npi_fsdb_release_vct = NULL
|
|
84
|
+
cdef npi_init_fn npi_init = NULL
|
|
83
85
|
|
|
84
86
|
# Verdi's libNPI.so exports these APIs as C++ symbols on some releases, so the
|
|
85
87
|
# runtime binder must fall back to the mangled names when the plain C names are
|
|
@@ -108,70 +110,60 @@ cdef dict _NPI_CPP_SYMBOL_ALIASES = {
|
|
|
108
110
|
b'npi_fsdb_iter_scope_stop': (b'_Z24npi_fsdb_iter_scope_stopPv',),
|
|
109
111
|
b'npi_fsdb_iter_sig_stop': (b'_Z22npi_fsdb_iter_sig_stopPv',),
|
|
110
112
|
b'npi_fsdb_release_vct': (b'_Z20npi_fsdb_release_vctPv',),
|
|
113
|
+
b'npi_init': (b'_Z8npi_initRiRPPc',),
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
|
|
114
|
-
cdef str _decode_cstr(const char* value):
|
|
115
|
-
if value == NULL:
|
|
116
|
-
return ''
|
|
117
|
-
return (<bytes>value).decode('utf-8', 'replace')
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
cdef str _last_dlerror():
|
|
121
|
-
return _decode_cstr(dlerror())
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
cdef tuple _symbol_candidates(object symbol_name):
|
|
125
|
-
cdef bytes symbol_bytes
|
|
126
|
-
cdef tuple aliases
|
|
127
|
-
|
|
128
|
-
symbol_bytes = symbol_name if isinstance(symbol_name, bytes) else str(symbol_name).encode('ascii')
|
|
129
|
-
aliases = _NPI_CPP_SYMBOL_ALIASES.get(symbol_bytes, ())
|
|
130
|
-
return (symbol_bytes,) + aliases
|
|
131
|
-
|
|
132
|
-
|
|
133
117
|
cdef void _clear_npi_symbols():
|
|
134
|
-
global
|
|
135
|
-
global
|
|
136
|
-
global
|
|
137
|
-
global
|
|
138
|
-
global
|
|
139
|
-
global
|
|
140
|
-
global
|
|
141
|
-
global
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
118
|
+
global npi_fsdb_open, npi_fsdb_close, npi_fsdb_min_time, npi_fsdb_max_time
|
|
119
|
+
global npi_fsdb_sig_by_name, npi_fsdb_create_vct, npi_fsdb_goto_time
|
|
120
|
+
global npi_fsdb_goto_first, npi_fsdb_goto_next, npi_fsdb_vct_time
|
|
121
|
+
global npi_fsdb_vct_value, npi_fsdb_sig_property, npi_fsdb_sig_property_str
|
|
122
|
+
global npi_fsdb_scope_property_str, npi_fsdb_iter_top_scope
|
|
123
|
+
global npi_fsdb_iter_child_scope, npi_fsdb_iter_scope_next, npi_fsdb_iter_sig_next
|
|
124
|
+
global npi_fsdb_iter_sig, npi_fsdb_iter_member, npi_fsdb_iter_scope_stop
|
|
125
|
+
global npi_fsdb_iter_sig_stop, npi_fsdb_release_vct, npi_init
|
|
126
|
+
npi_fsdb_open = NULL
|
|
127
|
+
npi_fsdb_close = NULL
|
|
128
|
+
npi_fsdb_min_time = NULL
|
|
129
|
+
npi_fsdb_max_time = NULL
|
|
130
|
+
npi_fsdb_sig_by_name = NULL
|
|
131
|
+
npi_fsdb_create_vct = NULL
|
|
132
|
+
npi_fsdb_goto_time = NULL
|
|
133
|
+
npi_fsdb_goto_first = NULL
|
|
134
|
+
npi_fsdb_goto_next = NULL
|
|
135
|
+
npi_fsdb_vct_time = NULL
|
|
136
|
+
npi_fsdb_vct_value = NULL
|
|
137
|
+
npi_fsdb_sig_property = NULL
|
|
138
|
+
npi_fsdb_sig_property_str = NULL
|
|
139
|
+
npi_fsdb_scope_property_str = NULL
|
|
140
|
+
npi_fsdb_iter_top_scope = NULL
|
|
141
|
+
npi_fsdb_iter_child_scope = NULL
|
|
142
|
+
npi_fsdb_iter_scope_next = NULL
|
|
143
|
+
npi_fsdb_iter_sig_next = NULL
|
|
144
|
+
npi_fsdb_iter_sig = NULL
|
|
145
|
+
npi_fsdb_iter_member = NULL
|
|
146
|
+
npi_fsdb_iter_scope_stop = NULL
|
|
147
|
+
npi_fsdb_iter_sig_stop = NULL
|
|
148
|
+
npi_fsdb_release_vct = NULL
|
|
149
|
+
npi_init = NULL
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
cdef void* _require_symbol(void* handle, object symbol_name, str lib_path) except NULL:
|
|
153
|
+
cdef bytes symbol_bytes
|
|
168
154
|
cdef void* symbol
|
|
169
|
-
cdef tuple
|
|
155
|
+
cdef tuple candidates
|
|
170
156
|
cdef bytes candidate
|
|
171
157
|
cdef const char* candidate_name
|
|
172
158
|
cdef list tried_names = []
|
|
159
|
+
cdef const char* dlerror_cstr
|
|
173
160
|
|
|
174
|
-
|
|
161
|
+
symbol_bytes = (
|
|
162
|
+
symbol_name if isinstance(symbol_name, bytes) else str(symbol_name).encode('ascii')
|
|
163
|
+
)
|
|
164
|
+
candidates = (symbol_bytes,) + _NPI_CPP_SYMBOL_ALIASES.get(symbol_bytes, ())
|
|
165
|
+
|
|
166
|
+
for candidate in candidates:
|
|
175
167
|
candidate_name = candidate
|
|
176
168
|
dlerror()
|
|
177
169
|
symbol = dlsym(handle, candidate_name)
|
|
@@ -179,70 +171,86 @@ cdef void* _require_symbol(void* handle, object symbol_name) except NULL:
|
|
|
179
171
|
return symbol
|
|
180
172
|
tried_names.append(repr(candidate.decode('ascii')))
|
|
181
173
|
|
|
174
|
+
dlerror_cstr = dlerror()
|
|
182
175
|
raise OSError(
|
|
183
|
-
f"Failed to resolve symbol {
|
|
184
|
-
f"
|
|
185
|
-
f"{
|
|
176
|
+
f"Failed to resolve symbol {candidates[0].decode('ascii')!r} from {lib_path}; "
|
|
177
|
+
f"tried {', '.join(tried_names)}: "
|
|
178
|
+
f"{'' if dlerror_cstr == NULL else (<bytes>dlerror_cstr).decode('utf-8', 'replace') or 'symbol not found'}"
|
|
186
179
|
)
|
|
187
180
|
|
|
188
181
|
|
|
189
|
-
cdef void _bind_npi_symbols(void* handle) except *:
|
|
190
|
-
global
|
|
191
|
-
global
|
|
192
|
-
global
|
|
193
|
-
global
|
|
194
|
-
global
|
|
195
|
-
global
|
|
196
|
-
global
|
|
197
|
-
global
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
handle, b'npi_fsdb_sig_by_name'
|
|
182
|
+
cdef void _bind_npi_symbols(void* handle, str lib_path) except *:
|
|
183
|
+
global npi_fsdb_open, npi_fsdb_close, npi_fsdb_min_time, npi_fsdb_max_time
|
|
184
|
+
global npi_fsdb_sig_by_name, npi_fsdb_create_vct, npi_fsdb_goto_time
|
|
185
|
+
global npi_fsdb_goto_first, npi_fsdb_goto_next, npi_fsdb_vct_time
|
|
186
|
+
global npi_fsdb_vct_value, npi_fsdb_sig_property, npi_fsdb_sig_property_str
|
|
187
|
+
global npi_fsdb_scope_property_str, npi_fsdb_iter_top_scope
|
|
188
|
+
global npi_fsdb_iter_child_scope, npi_fsdb_iter_scope_next, npi_fsdb_iter_sig_next
|
|
189
|
+
global npi_fsdb_iter_sig, npi_fsdb_iter_member, npi_fsdb_iter_scope_stop
|
|
190
|
+
global npi_fsdb_iter_sig_stop, npi_fsdb_release_vct, npi_init
|
|
191
|
+
npi_fsdb_open = <npi_fsdb_open_fn>_require_symbol(handle, b'npi_fsdb_open', lib_path)
|
|
192
|
+
npi_fsdb_close = <npi_fsdb_close_fn>_require_symbol(handle, b'npi_fsdb_close', lib_path)
|
|
193
|
+
npi_fsdb_min_time = <npi_fsdb_min_time_fn>_require_symbol(handle, b'npi_fsdb_min_time', lib_path)
|
|
194
|
+
npi_fsdb_max_time = <npi_fsdb_max_time_fn>_require_symbol(handle, b'npi_fsdb_max_time', lib_path)
|
|
195
|
+
npi_fsdb_sig_by_name = <npi_fsdb_sig_by_name_fn>_require_symbol(
|
|
196
|
+
handle, b'npi_fsdb_sig_by_name', lib_path
|
|
204
197
|
)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
handle, b'npi_fsdb_sig_property'
|
|
198
|
+
npi_fsdb_create_vct = <npi_fsdb_create_vct_fn>_require_symbol(handle, b'npi_fsdb_create_vct', lib_path)
|
|
199
|
+
npi_fsdb_goto_time = <npi_fsdb_goto_time_fn>_require_symbol(handle, b'npi_fsdb_goto_time', lib_path)
|
|
200
|
+
npi_fsdb_goto_first = <npi_fsdb_goto_first_fn>_require_symbol(handle, b'npi_fsdb_goto_first', lib_path)
|
|
201
|
+
npi_fsdb_goto_next = <npi_fsdb_goto_next_fn>_require_symbol(handle, b'npi_fsdb_goto_next', lib_path)
|
|
202
|
+
npi_fsdb_vct_time = <npi_fsdb_vct_time_fn>_require_symbol(handle, b'npi_fsdb_vct_time', lib_path)
|
|
203
|
+
npi_fsdb_vct_value = <npi_fsdb_vct_value_fn>_require_symbol(handle, b'npi_fsdb_vct_value', lib_path)
|
|
204
|
+
npi_fsdb_sig_property = <npi_fsdb_sig_property_fn>_require_symbol(
|
|
205
|
+
handle, b'npi_fsdb_sig_property', lib_path
|
|
213
206
|
)
|
|
214
|
-
|
|
215
|
-
handle, b'npi_fsdb_sig_property_str'
|
|
207
|
+
npi_fsdb_sig_property_str = <npi_fsdb_sig_property_str_fn>_require_symbol(
|
|
208
|
+
handle, b'npi_fsdb_sig_property_str', lib_path
|
|
216
209
|
)
|
|
217
|
-
|
|
218
|
-
handle, b'npi_fsdb_scope_property_str'
|
|
210
|
+
npi_fsdb_scope_property_str = <npi_fsdb_scope_property_str_fn>_require_symbol(
|
|
211
|
+
handle, b'npi_fsdb_scope_property_str', lib_path
|
|
219
212
|
)
|
|
220
|
-
|
|
221
|
-
handle, b'npi_fsdb_iter_top_scope'
|
|
213
|
+
npi_fsdb_iter_top_scope = <npi_fsdb_iter_top_scope_fn>_require_symbol(
|
|
214
|
+
handle, b'npi_fsdb_iter_top_scope', lib_path
|
|
222
215
|
)
|
|
223
|
-
|
|
224
|
-
handle, b'npi_fsdb_iter_child_scope'
|
|
216
|
+
npi_fsdb_iter_child_scope = <npi_fsdb_iter_child_scope_fn>_require_symbol(
|
|
217
|
+
handle, b'npi_fsdb_iter_child_scope', lib_path
|
|
225
218
|
)
|
|
226
|
-
|
|
227
|
-
handle, b'npi_fsdb_iter_scope_next'
|
|
219
|
+
npi_fsdb_iter_scope_next = <npi_fsdb_iter_scope_next_fn>_require_symbol(
|
|
220
|
+
handle, b'npi_fsdb_iter_scope_next', lib_path
|
|
228
221
|
)
|
|
229
|
-
|
|
230
|
-
handle, b'npi_fsdb_iter_sig_next'
|
|
222
|
+
npi_fsdb_iter_sig_next = <npi_fsdb_iter_sig_next_fn>_require_symbol(
|
|
223
|
+
handle, b'npi_fsdb_iter_sig_next', lib_path
|
|
231
224
|
)
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
handle, b'npi_fsdb_iter_scope_stop'
|
|
225
|
+
npi_fsdb_iter_sig = <npi_fsdb_iter_sig_fn>_require_symbol(handle, b'npi_fsdb_iter_sig', lib_path)
|
|
226
|
+
npi_fsdb_iter_member = <npi_fsdb_iter_member_fn>_require_symbol(handle, b'npi_fsdb_iter_member', lib_path)
|
|
227
|
+
npi_fsdb_iter_scope_stop = <npi_fsdb_iter_scope_stop_fn>_require_symbol(
|
|
228
|
+
handle, b'npi_fsdb_iter_scope_stop', lib_path
|
|
236
229
|
)
|
|
237
|
-
|
|
238
|
-
handle, b'npi_fsdb_iter_sig_stop'
|
|
230
|
+
npi_fsdb_iter_sig_stop = <npi_fsdb_iter_sig_stop_fn>_require_symbol(
|
|
231
|
+
handle, b'npi_fsdb_iter_sig_stop', lib_path
|
|
239
232
|
)
|
|
240
|
-
|
|
241
|
-
handle, b'npi_fsdb_release_vct'
|
|
233
|
+
npi_fsdb_release_vct = <npi_fsdb_release_vct_fn>_require_symbol(
|
|
234
|
+
handle, b'npi_fsdb_release_vct', lib_path
|
|
242
235
|
)
|
|
236
|
+
npi_init = <npi_init_fn>_require_symbol(handle, b'npi_init', lib_path)
|
|
237
|
+
|
|
243
238
|
|
|
239
|
+
cdef void _call_npi_init(bint quiet) except *:
|
|
240
|
+
cdef bytes quiet_flag = b'-quiet'
|
|
241
|
+
cdef bytes exec_path = sys.executable.encode('utf-8')
|
|
242
|
+
cdef char* argv_buf[3]
|
|
243
|
+
cdef char** argv = argv_buf
|
|
244
|
+
cdef int argc = 2 if quiet else 1
|
|
244
245
|
|
|
245
|
-
|
|
246
|
+
argv[0] = exec_path
|
|
247
|
+
if quiet:
|
|
248
|
+
argv[1] = quiet_flag
|
|
249
|
+
argv[argc] = NULL
|
|
250
|
+
npi_init(&argc, &argv)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
cdef list _npi_library_candidates(object preferred_path=None):
|
|
246
254
|
cdef list candidates = []
|
|
247
255
|
cdef set seen = set()
|
|
248
256
|
cdef object candidate
|
|
@@ -267,160 +275,12 @@ cdef list _npi_library_candidates(object preferred_path):
|
|
|
267
275
|
return candidates
|
|
268
276
|
|
|
269
277
|
|
|
270
|
-
cdef void _ensure_npi_loaded(object preferred_path=None) except *:
|
|
271
|
-
global _npi_lib_handle, _npi_lib_path
|
|
272
|
-
|
|
273
|
-
cdef void* handle
|
|
274
|
-
cdef list errors = []
|
|
275
|
-
cdef bytes path_bytes
|
|
276
|
-
cdef object candidate
|
|
277
|
-
|
|
278
|
-
if _npi_lib_handle != NULL:
|
|
279
|
-
return
|
|
280
|
-
|
|
281
|
-
for candidate in _npi_library_candidates(preferred_path):
|
|
282
|
-
path_bytes = str(candidate).encode('utf-8')
|
|
283
|
-
handle = dlopen(path_bytes, RTLD_NOW | RTLD_LOCAL)
|
|
284
|
-
if handle == NULL:
|
|
285
|
-
errors.append(f'{candidate}: {_last_dlerror() or "dlopen failed"}')
|
|
286
|
-
continue
|
|
287
|
-
try:
|
|
288
|
-
_npi_lib_path = str(candidate)
|
|
289
|
-
_bind_npi_symbols(handle)
|
|
290
|
-
except Exception as exc:
|
|
291
|
-
_clear_npi_symbols()
|
|
292
|
-
dlclose(handle)
|
|
293
|
-
errors.append(f'{candidate}: {exc}')
|
|
294
|
-
_npi_lib_path = None
|
|
295
|
-
continue
|
|
296
|
-
_npi_lib_handle = handle
|
|
297
|
-
return
|
|
298
|
-
|
|
299
|
-
raise OSError(
|
|
300
|
-
'Failed to load Verdi FSDB runtime library (libNPI.so). Configure via:\n'
|
|
301
|
-
' - WAVEKIT_NPI_LIB — direct path to libNPI.so\n'
|
|
302
|
-
' - VERDI_HOME — Verdi installation directory\n'
|
|
303
|
-
' - LD_LIBRARY_PATH — system library search path\n'
|
|
304
|
-
+ '\n'.join(errors)
|
|
305
|
-
)
|
|
306
|
-
|
|
307
|
-
|
|
308
278
|
cpdef bint fsdb_runtime_available(object preferred_path=None):
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return False
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
cpdef object fsdb_runtime_library_path():
|
|
317
|
-
return _npi_lib_path
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
cdef inline npiFsdbFileHandle npi_fsdb_open(const NPI_BYTE8* name):
|
|
321
|
-
return _npi_fsdb_open(name)
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
cdef inline NPI_INT32 npi_fsdb_close(npiFsdbFileHandle file):
|
|
325
|
-
return _npi_fsdb_close(file)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
cdef inline NPI_INT32 npi_fsdb_min_time(npiFsdbFileHandle file, npiFsdbTime* time):
|
|
329
|
-
return _npi_fsdb_min_time(file, time)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
cdef inline NPI_INT32 npi_fsdb_max_time(npiFsdbFileHandle file, npiFsdbTime* time):
|
|
333
|
-
return _npi_fsdb_max_time(file, time)
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
cdef inline npiFsdbSigHandle npi_fsdb_sig_by_name(
|
|
337
|
-
npiFsdbFileHandle file,
|
|
338
|
-
const NPI_BYTE8* name,
|
|
339
|
-
npiFsdbScopeHandle scope,
|
|
340
|
-
):
|
|
341
|
-
return _npi_fsdb_sig_by_name(file, name, scope)
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
cdef inline npiFsdbVctHandle npi_fsdb_create_vct(npiFsdbSigHandle sig):
|
|
345
|
-
return _npi_fsdb_create_vct(sig)
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
cdef inline NPI_INT32 npi_fsdb_goto_time(npiFsdbVctHandle vct, npiFsdbTime time):
|
|
349
|
-
return _npi_fsdb_goto_time(vct, time)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
cdef inline NPI_INT32 npi_fsdb_goto_first(npiFsdbVctHandle vct):
|
|
353
|
-
return _npi_fsdb_goto_first(vct)
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
cdef inline NPI_INT32 npi_fsdb_goto_next(npiFsdbVctHandle vct):
|
|
357
|
-
return _npi_fsdb_goto_next(vct)
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
cdef inline NPI_INT32 npi_fsdb_vct_time(npiFsdbVctHandle vct, npiFsdbTime* time):
|
|
361
|
-
return _npi_fsdb_vct_time(vct, time)
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
cdef inline NPI_INT32 npi_fsdb_vct_value(npiFsdbVctHandle vct, npiFsdbValue* value):
|
|
365
|
-
return _npi_fsdb_vct_value(vct, value)
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
cdef inline NPI_INT32 npi_fsdb_sig_property(
|
|
369
|
-
npiFsdbSigPropertyType type,
|
|
370
|
-
npiFsdbSigHandle sig,
|
|
371
|
-
NPI_INT32* prop,
|
|
372
|
-
):
|
|
373
|
-
return _npi_fsdb_sig_property(type, sig, prop)
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
cdef inline const NPI_BYTE8* npi_fsdb_sig_property_str(
|
|
377
|
-
npiFsdbSigPropertyType type,
|
|
378
|
-
npiFsdbSigHandle sig,
|
|
379
|
-
):
|
|
380
|
-
return _npi_fsdb_sig_property_str(type, sig)
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
cdef inline const NPI_BYTE8* npi_fsdb_scope_property_str(
|
|
384
|
-
npiFsdbScopePropertyType type,
|
|
385
|
-
npiFsdbScopeHandle scope,
|
|
386
|
-
):
|
|
387
|
-
return _npi_fsdb_scope_property_str(type, scope)
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
cdef inline npiFsdbScopeIter npi_fsdb_iter_top_scope(npiFsdbFileHandle file):
|
|
391
|
-
return _npi_fsdb_iter_top_scope(file)
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
cdef inline npiFsdbScopeIter npi_fsdb_iter_child_scope(npiFsdbScopeHandle scope):
|
|
395
|
-
return _npi_fsdb_iter_child_scope(scope)
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
cdef inline npiFsdbScopeHandle npi_fsdb_iter_scope_next(npiFsdbScopeIter iter):
|
|
399
|
-
return _npi_fsdb_iter_scope_next(iter)
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
cdef inline npiFsdbSigHandle npi_fsdb_iter_sig_next(npiFsdbSigIter iter):
|
|
403
|
-
return _npi_fsdb_iter_sig_next(iter)
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
cdef inline npiFsdbSigIter npi_fsdb_iter_sig(npiFsdbScopeHandle scope):
|
|
407
|
-
return _npi_fsdb_iter_sig(scope)
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
cdef inline npiFsdbSigIter npi_fsdb_iter_member(npiFsdbSigHandle sig):
|
|
411
|
-
return _npi_fsdb_iter_member(sig)
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
cdef inline NPI_INT32 npi_fsdb_iter_scope_stop(npiFsdbScopeIter iter):
|
|
415
|
-
return _npi_fsdb_iter_scope_stop(iter)
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
cdef inline NPI_INT32 npi_fsdb_iter_sig_stop(npiFsdbSigIter iter):
|
|
419
|
-
return _npi_fsdb_iter_sig_stop(iter)
|
|
420
|
-
|
|
279
|
+
for candidate in _npi_library_candidates(preferred_path):
|
|
280
|
+
if os.path.isfile(candidate):
|
|
281
|
+
return True
|
|
282
|
+
return False
|
|
421
283
|
|
|
422
|
-
cdef inline NPI_INT32 npi_fsdb_release_vct(npiFsdbVctHandle vct):
|
|
423
|
-
return _npi_fsdb_release_vct(vct)
|
|
424
284
|
|
|
425
285
|
NPI_FSDB_CT_ARRAY = <int>npiFsdbSigCtArray
|
|
426
286
|
NPI_FSDB_CT_STRUCT = <int>npiFsdbSigCtStruct
|
|
@@ -647,15 +507,55 @@ cdef class NpiFsdbReader:
|
|
|
647
507
|
cdef npiFsdbFileHandle fsdb_handle
|
|
648
508
|
cdef str file
|
|
649
509
|
|
|
650
|
-
def __init__(self, str file):
|
|
651
|
-
|
|
510
|
+
def __init__(self, str file, bint quiet):
|
|
511
|
+
global _npi_lib_handle
|
|
512
|
+
|
|
513
|
+
cdef void* handle = NULL
|
|
514
|
+
cdef list errors = []
|
|
515
|
+
cdef str lib_path = ''
|
|
516
|
+
cdef bytes path_bytes
|
|
517
|
+
cdef const char* dlerror_cstr
|
|
518
|
+
cdef str dlerror_text
|
|
519
|
+
|
|
520
|
+
if _npi_lib_handle == NULL:
|
|
521
|
+
for candidate in _npi_library_candidates(None):
|
|
522
|
+
path_bytes = str(candidate).encode('utf-8')
|
|
523
|
+
handle = dlopen(path_bytes, RTLD_NOW | RTLD_LOCAL)
|
|
524
|
+
if handle == NULL:
|
|
525
|
+
dlerror_cstr = dlerror()
|
|
526
|
+
dlerror_text = (
|
|
527
|
+
'' if dlerror_cstr == NULL
|
|
528
|
+
else (<bytes>dlerror_cstr).decode('utf-8', 'replace')
|
|
529
|
+
)
|
|
530
|
+
errors.append(f'{candidate}: {dlerror_text or "dlopen failed"}')
|
|
531
|
+
continue
|
|
532
|
+
lib_path = str(candidate)
|
|
533
|
+
try:
|
|
534
|
+
_bind_npi_symbols(handle, lib_path)
|
|
535
|
+
_call_npi_init(quiet)
|
|
536
|
+
except Exception as exc:
|
|
537
|
+
_clear_npi_symbols()
|
|
538
|
+
dlclose(handle)
|
|
539
|
+
errors.append(f'{candidate}: {exc}')
|
|
540
|
+
continue
|
|
541
|
+
_npi_lib_handle = handle
|
|
542
|
+
break
|
|
543
|
+
|
|
544
|
+
if _npi_lib_handle == NULL:
|
|
545
|
+
raise OSError(
|
|
546
|
+
'Failed to load Verdi FSDB runtime library (libNPI.so). Configure via:\n'
|
|
547
|
+
' - WAVEKIT_NPI_LIB — direct path to libNPI.so\n'
|
|
548
|
+
' - VERDI_HOME — Verdi installation directory\n'
|
|
549
|
+
' - LD_LIBRARY_PATH — system library search path\n'
|
|
550
|
+
+ '\n'.join(errors)
|
|
551
|
+
)
|
|
652
552
|
|
|
653
553
|
file_str = file.encode('utf-8')
|
|
654
554
|
cdef char* file_s = file_str
|
|
655
555
|
self.fsdb_handle = npi_fsdb_open(file_s)
|
|
656
556
|
if(self.fsdb_handle == NULL):
|
|
657
557
|
raise OSError(
|
|
658
|
-
f"Failed to open fsdb file {file!r} using {
|
|
558
|
+
f"Failed to open fsdb file {file!r} using {lib_path or 'libNPI.so'}"
|
|
659
559
|
)
|
|
660
560
|
|
|
661
561
|
def get_signal(self, str signal) -> NpiFsdbSignal:
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import importlib
|
|
4
3
|
from dataclasses import dataclass, field
|
|
5
4
|
from functools import cached_property
|
|
6
|
-
from typing import Any
|
|
7
5
|
|
|
8
6
|
import numpy as np
|
|
9
7
|
|
|
@@ -120,58 +118,29 @@ class FsdbReader(Reader[FsdbSignal]):
|
|
|
120
118
|
``FsdbReader`` requires the Verdi runtime library (``libNPI.so``). Configure
|
|
121
119
|
it with ``WAVEKIT_NPI_LIB``, ``VERDI_HOME``, or ``LD_LIBRARY_PATH`` before
|
|
122
120
|
opening FSDB files.
|
|
123
|
-
"""
|
|
124
|
-
|
|
125
|
-
pynpi: dict[str, Any] = {}
|
|
126
|
-
|
|
127
|
-
@classmethod
|
|
128
|
-
def _maybe_init_pynpi(cls) -> Exception | None:
|
|
129
|
-
if cls.pynpi:
|
|
130
|
-
return None
|
|
131
|
-
|
|
132
|
-
import os
|
|
133
|
-
import sys
|
|
134
|
-
|
|
135
|
-
verdi_home = os.environ.get('VERDI_HOME')
|
|
136
|
-
if verdi_home is None:
|
|
137
|
-
return None
|
|
138
121
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
cls.pynpi['waveform'] = importlib.import_module('pynpi.waveform')
|
|
146
|
-
cls.pynpi['npisys'].init([''])
|
|
147
|
-
except Exception as exc:
|
|
148
|
-
cls.pynpi.clear()
|
|
149
|
-
return exc
|
|
150
|
-
return None
|
|
122
|
+
``quiet`` (default ``True``) suppresses the NPI console banner via the
|
|
123
|
+
``-quiet`` initialization argument. Pass ``quiet=False`` to keep the banner.
|
|
124
|
+
NPI initialization is process-global, so ``quiet`` only takes effect on the
|
|
125
|
+
first ``FsdbReader`` created in the process; later readers cannot reliably
|
|
126
|
+
re-enable the banner.
|
|
127
|
+
"""
|
|
151
128
|
|
|
152
|
-
|
|
153
|
-
def _runtime_error(init_error: Exception | None, open_error: Exception) -> RuntimeError:
|
|
154
|
-
details = [
|
|
155
|
-
'Failed to initialize FSDB runtime.',
|
|
156
|
-
'FsdbReader requires the Verdi runtime library (libNPI.so). Configure via:',
|
|
157
|
-
' - WAVEKIT_NPI_LIB — direct path to libNPI.so',
|
|
158
|
-
' - VERDI_HOME — Verdi installation directory',
|
|
159
|
-
' - LD_LIBRARY_PATH — system library search path',
|
|
160
|
-
f'Open error: {open_error}',
|
|
161
|
-
]
|
|
162
|
-
if init_error is not None:
|
|
163
|
-
details.append(f'Optional pynpi bootstrap error: {init_error}')
|
|
164
|
-
return RuntimeError('\n'.join(details))
|
|
165
|
-
|
|
166
|
-
def __init__(self, file: str):
|
|
129
|
+
def __init__(self, file: str, *, quiet: bool = True):
|
|
167
130
|
super().__init__()
|
|
168
|
-
init_error = self._maybe_init_pynpi()
|
|
169
|
-
|
|
170
131
|
self.file = file
|
|
171
132
|
try:
|
|
172
|
-
self.file_handle = NpiFsdbReader(file)
|
|
133
|
+
self.file_handle = NpiFsdbReader(file, quiet=quiet)
|
|
173
134
|
except Exception as exc:
|
|
174
|
-
|
|
135
|
+
details = [
|
|
136
|
+
'Failed to initialize FSDB runtime.',
|
|
137
|
+
'FsdbReader requires the Verdi runtime library (libNPI.so). Configure via:',
|
|
138
|
+
' - WAVEKIT_NPI_LIB — direct path to libNPI.so',
|
|
139
|
+
' - VERDI_HOME — Verdi installation directory',
|
|
140
|
+
' - LD_LIBRARY_PATH — system library search path',
|
|
141
|
+
f'Open error: {exc}',
|
|
142
|
+
]
|
|
143
|
+
raise RuntimeError('\n'.join(details)) from exc
|
|
175
144
|
|
|
176
145
|
def _load_value_changes(
|
|
177
146
|
self,
|