#!/usr/bin/env python3 """Prove actual RTL arithmetic expressions and require four mutations to fail. This is an unconstrained combinational proof, not a sequential motor proof. """ from pathlib import Path import argparse,datetime,hashlib,json,os,re,signal,subprocess,sys ROOT=Path(__file__).resolve().parents[1] if str(ROOT) not in sys.path:sys.path.insert(0,str(ROOT)) from tools.source_identity import source_identity def prove_selector(out): source=ROOT/'src/motor/motor_engine.v' raw=source.read_text(encoding='utf-8') start=raw.index(' always @* begin',raw.index('// Factor one-bit eligibility/priority')) end=raw.index('\n end\n',start)+len('\n end\n') actual=raw[start:end] inputs={str(p.relative_to(ROOT)):hashlib.sha256(p.read_bytes()).hexdigest() for p in (source,Path(__file__).resolve(),ROOT/'projects/mrdimm-chamber/project.json')} result={'schema':'prod2u-queue-selector-proof-v1','scope':'extracted combinational eligibility and circular winner only; no sequential or STEP proof', 'source':source_identity(ROOT),'inputs':inputs,'source_manifest_sha256':hashlib.sha256(json.dumps(inputs,sort_keys=True).encode()).hexdigest(), 'tool':subprocess.check_output(['yosys','-V'],text=True).strip(), 'assumptions':['fx_round is a legal axis index; all eligibility/control/depth input bits otherwise arbitrary'], 'results':[],'hardware':'NOT_RUN','status':'RUNNING'} for axes in (3,12): width=(axes-1).bit_length() prefix=f'''module selector(input [{width-1}:0] fx_round, input [{axes-1}:0] ax_load_ready,ax_seg_load,queue_paused_r,cs_start_mask,cs_mask,urgent_valid_r, input [1:0] cs_state,input seek_context,input [{axes*6-1}:0] depths, output bad,output reg [7:0] fx_candidate,output reg fx_candidate_valid); localparam AXIS_COUNT={axes}; wire [5:0] depth_r[0:AXIS_COUNT-1]; genvar g;generate for(g=0;g=fx_round ? axis-fx_round : axis+AXIS_COUNT-fx_round; if(allowed && distance=0;fx_k=fx_k-1)','for(fx_k=0;fx_k