yowasp-yosys 0.55.0.3.post946.dev0__py3-none-any.whl → 0.56.0.141.post974.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. yowasp_yosys/sby.py +39 -8
  2. yowasp_yosys/share/include/frontends/ast/ast.h +34 -38
  3. yowasp_yosys/share/include/kernel/celltypes.h +6 -0
  4. yowasp_yosys/share/include/kernel/consteval.h +5 -1
  5. yowasp_yosys/share/include/kernel/constids.inc +1 -0
  6. yowasp_yosys/share/include/kernel/ffinit.h +3 -3
  7. yowasp_yosys/share/include/kernel/ffmerge.h +1 -1
  8. yowasp_yosys/share/include/kernel/hashlib.h +43 -16
  9. yowasp_yosys/share/include/kernel/io.h +382 -8
  10. yowasp_yosys/share/include/kernel/json.h +2 -2
  11. yowasp_yosys/share/include/kernel/log.h +1 -0
  12. yowasp_yosys/share/include/kernel/register.h +42 -4
  13. yowasp_yosys/share/include/kernel/rtlil.h +6 -2
  14. yowasp_yosys/share/include/kernel/satgen.h +6 -4
  15. yowasp_yosys/share/include/kernel/sigtools.h +130 -26
  16. yowasp_yosys/share/include/kernel/yosys_common.h +9 -0
  17. yowasp_yosys/share/include/passes/techmap/libparse.h +235 -0
  18. yowasp_yosys/share/python3/sby_autotune.py +1 -1
  19. yowasp_yosys/share/python3/sby_cmdline.py +13 -0
  20. yowasp_yosys/share/python3/sby_core.py +208 -85
  21. yowasp_yosys/share/python3/sby_design.py +4 -0
  22. yowasp_yosys/share/python3/sby_engine_abc.py +15 -4
  23. yowasp_yosys/share/python3/sby_engine_aiger.py +14 -9
  24. yowasp_yosys/share/python3/sby_engine_btor.py +15 -4
  25. yowasp_yosys/share/python3/sby_engine_smtbmc.py +40 -27
  26. yowasp_yosys/share/python3/sby_status.py +388 -115
  27. yowasp_yosys/yosys.wasm +0 -0
  28. {yowasp_yosys-0.55.0.3.post946.dev0.dist-info → yowasp_yosys-0.56.0.141.post974.dev0.dist-info}/METADATA +1 -1
  29. {yowasp_yosys-0.55.0.3.post946.dev0.dist-info → yowasp_yosys-0.56.0.141.post974.dev0.dist-info}/RECORD +32 -31
  30. {yowasp_yosys-0.55.0.3.post946.dev0.dist-info → yowasp_yosys-0.56.0.141.post974.dev0.dist-info}/WHEEL +0 -0
  31. {yowasp_yosys-0.55.0.3.post946.dev0.dist-info → yowasp_yosys-0.56.0.141.post974.dev0.dist-info}/entry_points.txt +0 -0
  32. {yowasp_yosys-0.55.0.3.post946.dev0.dist-info → yowasp_yosys-0.56.0.141.post974.dev0.dist-info}/top_level.txt +0 -0
@@ -202,11 +202,13 @@ def aigsmt_trace_callback(task, engine_idx, proc_status, *, run_aigsmt, smtbmc_v
202
202
  proc2_status = None
203
203
 
204
204
  last_prop = []
205
+ recorded_last = False
205
206
  current_step = None
206
207
 
207
208
  def output_callback2(line):
208
209
  nonlocal proc2_status
209
210
  nonlocal last_prop
211
+ nonlocal recorded_last
210
212
  nonlocal current_step
211
213
 
212
214
  smt2_trans = {'\\':'/', '|':'/'}
@@ -218,6 +220,8 @@ def aigsmt_trace_callback(task, engine_idx, proc_status, *, run_aigsmt, smtbmc_v
218
220
 
219
221
  match = re.match(r"^## [0-9: ]+ .* in step ([0-9]+)\.\.", line)
220
222
  if match:
223
+ last_prop = []
224
+ recorded_last = False
221
225
  current_step = int(match[1])
222
226
  return line
223
227
 
@@ -233,32 +237,33 @@ def aigsmt_trace_callback(task, engine_idx, proc_status, *, run_aigsmt, smtbmc_v
233
237
  cell_name = match[3] or match[2]
234
238
  prop = task.design.hierarchy.find_property(path, cell_name, trans_dict=smt2_trans)
235
239
  prop.status = "FAIL"
236
- task.status_db.set_task_property_status(prop, data=dict(source="aigsmt", engine=f"engine_{engine_idx}"))
237
240
  last_prop.append(prop)
238
241
  return line
239
242
 
240
- match = re.match(r"^## [0-9: ]+ Writing trace to VCD file: (\S+)", line)
243
+ match = re.match(r"^## [0-9: ]+ Writing trace to (VCD|Yosys witness) file: (\S+)", line)
241
244
  if match:
242
- tracefile = match[1]
243
- trace = os.path.basename(tracefile)[:-4]
245
+ tracefile = match[2]
246
+ trace, _ = os.path.splitext(os.path.basename(tracefile))
244
247
  task.summary.add_event(engine_idx=engine_idx, trace=trace, path=tracefile)
245
-
246
- if match and last_prop:
247
248
  for p in last_prop:
248
249
  task.summary.add_event(
249
250
  engine_idx=engine_idx, trace=trace,
250
- type=p.celltype, hdlname=p.hdlname, src=p.location, step=current_step)
251
- p.tracefiles.append(tracefile)
252
- last_prop = []
251
+ type=p.celltype, hdlname=p.hdlname, src=p.location,
252
+ step=current_step, prop=p,
253
+ )
254
+ recorded_last = True
253
255
  return line
254
256
 
255
257
  return line
256
258
 
257
259
  def exit_callback2(retcode):
260
+ nonlocal last_prop, recorded_last
258
261
  if proc2_status is None:
259
262
  task.error(f"engine_{engine_idx}: Could not determine aigsmt status.")
260
263
  if proc2_status != "FAIL":
261
264
  task.error(f"engine_{engine_idx}: Unexpected aigsmt status.")
265
+ if len(last_prop) and not recorded_last:
266
+ task.error(f"engine_{engine_idx}: Found properties without trace.")
262
267
 
263
268
  proc2.output_callback = output_callback2
264
269
  proc2.register_exit_callback(exit_callback2)
@@ -77,6 +77,7 @@ def run(mode, task, engine_idx, engine):
77
77
  common_state.wit_file = None
78
78
  common_state.assert_fail = False
79
79
  common_state.running_procs = 0
80
+ common_state.current_step = None
80
81
 
81
82
  def print_traces_and_terminate():
82
83
  if mode == "cover":
@@ -90,6 +91,7 @@ def run(mode, task, engine_idx, engine):
90
91
  proc_status = "FAIL"
91
92
  else:
92
93
  task.error(f"engine_{engine_idx}: Engine terminated without status.")
94
+ task.update_unknown_props(dict(source="btor", engine=f"engine_{engine_idx}"))
93
95
  else:
94
96
  if common_state.expected_cex == 0:
95
97
  proc_status = "pass"
@@ -100,7 +102,7 @@ def run(mode, task, engine_idx, engine):
100
102
  else:
101
103
  task.error(f"engine_{engine_idx}: Engine terminated without status.")
102
104
 
103
- task.update_status(proc_status.upper())
105
+ task.update_status(proc_status.upper(), common_state.current_step)
104
106
  task.summary.set_engine_status(engine_idx, proc_status)
105
107
 
106
108
  task.terminate()
@@ -117,9 +119,11 @@ def run(mode, task, engine_idx, engine):
117
119
 
118
120
  def make_exit_callback(suffix):
119
121
  def exit_callback2(retcode):
120
- vcdpath = f"engine_{engine_idx}/trace{suffix}.vcd"
121
- if os.path.exists(f"{task.workdir}/{vcdpath}"):
122
- task.summary.add_event(engine_idx=engine_idx, trace=f'trace{suffix}', path=vcdpath, type="$cover" if mode == "cover" else "$assert")
122
+ trace = f"trace{suffix}"
123
+ vcdpath = f"engine_{engine_idx}/{trace}.vcd"
124
+ trace_path = f"{task.workdir}/{vcdpath}"
125
+ if os.path.exists(trace_path):
126
+ task.summary.add_event(engine_idx=engine_idx, trace=trace, path=vcdpath, type="$cover" if mode == "cover" else "$assert")
123
127
 
124
128
  common_state.running_procs -= 1
125
129
  if (common_state.running_procs == 0):
@@ -140,6 +144,7 @@ def run(mode, task, engine_idx, engine):
140
144
  common_state.expected_cex = int(match[1])
141
145
  if common_state.produced_cex != 0:
142
146
  task.error(f"engine_{engine_idx}: Unexpected engine output (property count).")
147
+ task.update_unknown_props(dict(source="btor_init", engine=f"engine_{engine_idx}"))
143
148
 
144
149
  else:
145
150
  task.error(f"engine_{engine_idx}: BTOR solver '{solver_args[0]}' is currently not supported in cover mode.")
@@ -205,6 +210,9 @@ def run(mode, task, engine_idx, engine):
205
210
  if solver_args[0] == "btormc":
206
211
  if "calling BMC on" in line:
207
212
  return line
213
+ match = re.match(r".*at bound k = (\d+).*", line)
214
+ if match:
215
+ common_state.current_step = int(match[1])
208
216
  if "SATISFIABLE" in line:
209
217
  return line
210
218
  if "bad state properties at bound" in line:
@@ -215,6 +223,9 @@ def run(mode, task, engine_idx, engine):
215
223
  return line
216
224
 
217
225
  elif solver_args[0] == "pono":
226
+ match = re.match(r".*at bound (\d+).*", line)
227
+ if match:
228
+ common_state.current_step = int(match[1])
218
229
  if line == "unknown":
219
230
  if common_state.solver_status is None:
220
231
  common_state.solver_status = "unsat"
@@ -184,16 +184,20 @@ def run(mode, task, engine_idx, engine):
184
184
 
185
185
  proc_status = None
186
186
  last_prop = []
187
+ recorded_last = False
187
188
  pending_sim = None
188
189
  current_step = None
189
190
  procs_running = 1
191
+ failed_assert = False
190
192
 
191
193
  def output_callback(line):
192
194
  nonlocal proc_status
193
195
  nonlocal last_prop
196
+ nonlocal recorded_last
194
197
  nonlocal pending_sim
195
198
  nonlocal current_step
196
199
  nonlocal procs_running
200
+ nonlocal failed_assert
197
201
 
198
202
  if pending_sim:
199
203
  sim_proc = sim_witness_trace(procname, task, engine_idx, pending_sim, append=sim_append, inductive=mode == "prove_induction")
@@ -210,7 +214,14 @@ def run(mode, task, engine_idx, engine):
210
214
 
211
215
  match = re.match(r"^## [0-9: ]+ .* in step ([0-9]+)\.\.", line)
212
216
  if match:
217
+ last_prop = []
218
+ recorded_last = False
219
+ if mode == "prove_induction":
220
+ return line
221
+ last_step = current_step
213
222
  current_step = int(match[1])
223
+ if current_step != last_step and last_step is not None:
224
+ task.update_unknown_props(dict(source="smtbmc", engine=f"engine_{engine_idx}", step=last_step))
214
225
  return line
215
226
 
216
227
  match = re.match(r"^## [0-9: ]+ Status: FAILED", line)
@@ -235,11 +246,11 @@ def run(mode, task, engine_idx, engine):
235
246
 
236
247
  match = re.match(r"^## [0-9: ]+ Assert failed in ([^:]+): (\S+)(?: \((\S+)\))?", line)
237
248
  if match:
249
+ failed_assert = not keep_going
238
250
  path = parse_mod_path(match[1])
239
251
  cell_name = match[3] or match[2]
240
252
  prop = task.design.hierarchy.find_property(path, cell_name, trans_dict=smt2_trans)
241
253
  prop.status = "FAIL"
242
- task.status_db.set_task_property_status(prop, data=dict(source="smtbmc", engine=f"engine_{engine_idx}"))
243
254
  last_prop.append(prop)
244
255
  return line
245
256
 
@@ -249,39 +260,37 @@ def run(mode, task, engine_idx, engine):
249
260
  cell_name = match[3] or match[2]
250
261
  prop = task.design.hierarchy.find_property(path, cell_name, trans_dict=smt2_trans)
251
262
  prop.status = "PASS"
252
- task.status_db.set_task_property_status(prop, data=dict(source="smtbmc", engine=f"engine_{engine_idx}"))
253
263
  last_prop.append(prop)
254
264
  return line
255
265
 
256
- if smtbmc_vcd and not task.opt_fst:
257
- match = re.match(r"^## [0-9: ]+ Writing trace to VCD file: (\S+)", line)
258
- if match:
259
- tracefile = match[1]
260
- trace = os.path.basename(tracefile)[:-4]
261
- engine_case = mode.split('_')[1] if '_' in mode else None
262
- task.summary.add_event(engine_idx=engine_idx, trace=trace, path=tracefile, engine_case=engine_case)
263
-
264
- if match and last_prop:
265
- for p in last_prop:
266
- task.summary.add_event(
267
- engine_idx=engine_idx, trace=trace,
268
- type=p.celltype, hdlname=p.hdlname, src=p.location, step=current_step)
269
- p.tracefiles.append(tracefile)
270
- last_prop = []
271
- return line
272
- else:
273
- match = re.match(r"^## [0-9: ]+ Writing trace to Yosys witness file: (\S+)", line)
274
- if match:
275
- tracefile = match[1]
266
+ match = re.match(r"^## [0-9: ]+ Writing trace to (VCD|Yosys witness) file: (\S+)", line)
267
+ if match:
268
+ tracefile = match[2]
269
+ if match[1] == "Yosys witness" and (task.opt_fst or task.opt_vcd_sim):
276
270
  pending_sim = tracefile
271
+ trace, _ = os.path.splitext(os.path.basename(tracefile))
272
+ engine_case = mode.split('_')[1] if '_' in mode else None
273
+ task.summary.add_event(engine_idx=engine_idx, trace=trace, path=tracefile, engine_case=engine_case)
274
+ for p in last_prop:
275
+ task.summary.add_event(
276
+ engine_idx=engine_idx, trace=trace,
277
+ type=p.celltype, hdlname=p.hdlname, src=p.location,
278
+ step=current_step, prop=p,
279
+ )
280
+ recorded_last = True
281
+ return line
277
282
 
278
283
  match = re.match(r"^## [0-9: ]+ Unreached cover statement at ([^:]+): (\S+)(?: \((\S+)\))?", line)
279
- if match:
284
+ if match and not failed_assert:
280
285
  path = parse_mod_path(match[1])
281
286
  cell_name = match[3] or match[2]
282
287
  prop = task.design.hierarchy.find_property(path, cell_name, trans_dict=smt2_trans)
283
288
  prop.status = "FAIL"
284
- task.status_db.set_task_property_status(prop, data=dict(source="smtbmc", engine=f"engine_{engine_idx}"))
289
+ task.summary.add_event(
290
+ engine_idx=engine_idx, trace=None,
291
+ hdlname=prop.hdlname, src=prop.location,
292
+ step=current_step, prop=prop,
293
+ )
285
294
 
286
295
  return line
287
296
 
@@ -292,15 +301,19 @@ def run(mode, task, engine_idx, engine):
292
301
  last_exit_callback()
293
302
 
294
303
  def exit_callback(retcode):
304
+ nonlocal last_prop, recorded_last
295
305
  if proc_status is None:
296
306
  task.error(f"engine_{engine_idx}: Engine terminated without status.")
307
+ if len(last_prop) and not recorded_last:
308
+ task.error(f"engine_{engine_idx}: Found properties without trace.")
297
309
  simple_exit_callback(retcode)
298
310
 
299
311
  def last_exit_callback():
312
+ nonlocal current_step
300
313
  if mode == "bmc" or mode == "cover":
301
- task.update_status(proc_status)
314
+ task.update_status(proc_status, current_step)
302
315
  if proc_status == "FAIL" and mode == "bmc" and keep_going:
303
- task.pass_unknown_asserts(dict(source="smtbmc", keep_going=True, engine=f"engine_{engine_idx}"))
316
+ task.pass_unknown_asserts(dict(source="smtbmc", keep_going=True, engine=f"engine_{engine_idx}", step=current_step))
304
317
  proc_status_lower = proc_status.lower() if proc_status == "PASS" else proc_status
305
318
  task.summary.set_engine_status(engine_idx, proc_status_lower)
306
319
  if not keep_going:
@@ -332,7 +345,7 @@ def run(mode, task, engine_idx, engine):
332
345
  assert False
333
346
 
334
347
  if task.basecase_pass and task.induction_pass:
335
- task.update_status("PASS")
348
+ task.update_status("PASS", current_step)
336
349
  task.summary.append("successful proof by k-induction.")
337
350
  if not keep_going:
338
351
  task.terminate()