Rewrite an output pattern to eliminate multiple drivers.
Signature: (vl-res-rewrite-pat pat mds idx sigma) returns
We replace any multiply driven wires with new, freshly generated names, and
update
Function:
(defun vl-res-rewrite-pat (pat mds idx sigma) "Returns (MV PAT' IDX' SIGMA')" (declare (xargs :guard (and (natp idx) (vl-emodwirelist-p (alist-keys mds)) (vl-res-sigma-p sigma)))) (b* ((idx (lnfix idx)) ((when (not pat)) (mv pat idx sigma)) ((when (atom pat)) (b* ((look (hons-get pat mds)) ((unless look) (mv pat idx sigma)) (idx (+ 1 idx)) (fresh (make-vl-emodwire :basename "vl_res" :index idx)) (prev (cdr (hons-get pat sigma))) (sigma (hons-acons pat (cons fresh prev) sigma))) (mv fresh idx sigma))) ((mv car idx sigma) (vl-res-rewrite-pat (car pat) mds idx sigma)) ((mv cdr idx sigma) (vl-res-rewrite-pat (cdr pat) mds idx sigma))) (mv (cons car cdr) idx sigma)))
Theorem:
(defthm vl-res-rewrite-pat-mvtypes-1 (natp (mv-nth 1 (vl-res-rewrite-pat pat mds idx sigma))) :rule-classes :type-prescription)
Theorem:
(defthm vl-res-sigma-p-of-vl-res-rewrite-pat (implies (and (vl-emodwirelist-p (alist-keys mds)) (vl-res-sigma-p sigma)) (vl-res-sigma-p (mv-nth 2 (vl-res-rewrite-pat pat mds idx sigma)))))
Theorem:
(defthm similar-patternsp-of-vl-res-rewrite-pat (similar-patternsp (mv-nth 0 (vl-res-rewrite-pat pat mds idx sigma)) pat))