Split up a multi-input
(vl-gatesplit-and/or/xor x nf warnings) → (mv warnings new-decls new-gateinsts nf)
From Section 7.2,
gate(out, i1, i2, ..., iN); --> gate(temp1, i1, i2); gate(temp2, temp1, i3); ... gate(out, tempN-2, iN);
Function:
(defun vl-gatesplit-and/or/xor (x nf warnings) (declare (xargs :guard (and (vl-gateinst-p x) (vl-namefactory-p nf) (vl-warninglist-p warnings)))) (declare (xargs :guard (member (vl-gateinst->type x) '(:vl-and :vl-or :vl-xor)))) (let ((__function__ 'vl-gatesplit-and/or/xor)) (declare (ignorable __function__)) (b* ((type (vl-gateinst->type x)) (args (list-fix (vl-gateinst->args x))) (nargs (length args)) (range (vl-gateinst->range x)) (loc (vl-gateinst->loc x)) (origname (or (vl-gateinst->name x) "unnamed")) ((when range) (mv (fatal :type :vl-bad-gate :msg "~a0: expected no instance arrays; did you forget to ~ run the replicate-insts transform?" :args (list x)) nil (list x) nf)) ((when (< nargs 2)) (mv (fatal :type :vl-bad-gate :msg "~a0: expected at least 2 arguments, but found ~x1." :args (list x nargs)) nil (list x) nf)) ((when (eql nargs 2)) (b* (((mv warnings new-x) (vl-degenerate-gate-to-buf x warnings))) (mv warnings nil (list new-x) nf))) ((when (eql nargs 3)) (mv (ok) nil (list x) nf)) ((mv temp-exprs temp-decls nf) (vl-make-temporary-wires origname (- nargs 3) nf loc)) (atts (cons (cons "VL_GATESPLIT" (make-vl-atom :guts (vl-string origname))) (vl-gateinst->atts x))) (temp-args-out (vl-exprlist-to-plainarglist temp-exprs :dir :vl-output)) (temp-args-in (vl-exprlist-to-plainarglist temp-exprs :dir :vl-input)) (o (car args)) (i1 (cadr args)) (i2-n (cddr args)) (outs (append temp-args-out (list o))) (lhses (cons i1 temp-args-in)) (rhses i2-n) ((mv warnings gateinsts nf) (vl-make-gates-for-and/or/xor outs lhses rhses type origname loc atts nf warnings))) (mv warnings temp-decls gateinsts nf))))
Theorem:
(defthm vl-warninglist-p-of-vl-gatesplit-and/or/xor.warnings (b* (((mv ?warnings ?new-decls ?new-gateinsts ?nf) (vl-gatesplit-and/or/xor x nf warnings))) (vl-warninglist-p warnings)) :rule-classes :rewrite)
Theorem:
(defthm vl-vardecllist-p-of-vl-gatesplit-and/or/xor.new-decls (implies (and (force (vl-gateinst-p x)) (force (vl-namefactory-p nf)) (force (vl-warninglist-p warnings)) (force ((lambda (acl2::x acl2::l) (return-last 'acl2::mbe1-raw (acl2::member-eql-exec acl2::x acl2::l) (return-last 'progn (acl2::member-eql-exec$guard-check acl2::x acl2::l) (member-equal acl2::x acl2::l)))) (vl-gateinst->type$inline x) '(:vl-and :vl-or :vl-xor)))) (b* (((mv ?warnings ?new-decls ?new-gateinsts ?nf) (vl-gatesplit-and/or/xor x nf warnings))) (vl-vardecllist-p new-decls))) :rule-classes :rewrite)
Theorem:
(defthm vl-gateinstlist-p-of-vl-gatesplit-and/or/xor.new-gateinsts (implies (and (force (vl-gateinst-p x)) (force (vl-namefactory-p nf)) (force (vl-warninglist-p warnings)) (force ((lambda (acl2::x acl2::l) (return-last 'acl2::mbe1-raw (acl2::member-eql-exec acl2::x acl2::l) (return-last 'progn (acl2::member-eql-exec$guard-check acl2::x acl2::l) (member-equal acl2::x acl2::l)))) (vl-gateinst->type$inline x) '(:vl-and :vl-or :vl-xor)))) (b* (((mv ?warnings ?new-decls ?new-gateinsts ?nf) (vl-gatesplit-and/or/xor x nf warnings))) (vl-gateinstlist-p new-gateinsts))) :rule-classes :rewrite)
Theorem:
(defthm vl-namefactory-p-of-vl-gatesplit-and/or/xor.nf (implies (and (force (vl-gateinst-p x)) (force (vl-namefactory-p nf)) (force (vl-warninglist-p warnings)) (force ((lambda (acl2::x acl2::l) (return-last 'acl2::mbe1-raw (acl2::member-eql-exec acl2::x acl2::l) (return-last 'progn (acl2::member-eql-exec$guard-check acl2::x acl2::l) (member-equal acl2::x acl2::l)))) (vl-gateinst->type$inline x) '(:vl-and :vl-or :vl-xor)))) (b* (((mv ?warnings ?new-decls ?new-gateinsts ?nf) (vl-gatesplit-and/or/xor x nf warnings))) (vl-namefactory-p nf))) :rule-classes :rewrite)
Theorem:
(defthm vl-gatesplit-and/or/xor-mvtypes-1 (true-listp (mv-nth 1 (vl-gatesplit-and/or/xor x nf warnings))) :rule-classes :type-prescription)
Theorem:
(defthm vl-gatesplit-and/or/xor-mvtypes-2 (true-listp (mv-nth 2 (vl-gatesplit-and/or/xor x nf warnings))) :rule-classes :type-prescription)