Partition a plain argument into slices.
(vl-partition-plainarg arg port-width insts ss elem warnings) → (mv okp warnings plainargs)
Our goal is to create a list of the
We might fail with a fatal warning if there is some problem with the actual;
we expect the actual to be already sized,
Function:
(defun vl-partition-plainarg (arg port-width insts ss elem warnings) (declare (xargs :guard (and (vl-plainarg-p arg) (posp port-width) (posp insts) (vl-scopestack-p ss) (vl-modelement-p elem) (vl-warninglist-p warnings)))) (let ((__function__ 'vl-partition-plainarg)) (declare (ignorable __function__)) (b* ((arg (vl-plainarg-fix arg)) (port-width (lposfix port-width)) (insts (lposfix insts)) (ss (vl-scopestack-fix ss)) (elem (vl-modelement-fix elem)) (warnings (vl-warninglist-fix warnings)) ((vl-plainarg arg) arg) ((unless arg.expr) (mv t (ok) (replicate insts arg))) (expr-width (vl-expr->finalwidth arg.expr)) ((unless (posp expr-width)) (mv nil (fatal :type :vl-bad-argument :msg "~a0: expected argument widths to be computed, but ~ found argument ~a1 without any width assigned." :args (list elem arg.expr)) nil)) ((when (eql expr-width port-width)) (mv t (ok) (replicate insts arg))) ((unless (eql expr-width (* port-width insts))) (mv nil (fatal :type :vl-bad-argument :msg "~a0: argument ~a1 has width ~x2, which is not ~ compatible with this array instance. (Since the ~ port has width ~x3, the only acceptable widths are ~ ~x3 and ~x4.)" :args (list elem arg.expr expr-width port-width (* port-width insts))) nil)) ((unless (vl-expr-sliceable-p arg.expr)) (mv nil (fatal :type :vl-bad-argument :msg "~a0: trying to slice an unsliceable argument, ~a1." :args (list elem arg.expr)) nil)) ((unless (vl-expr-welltyped-p arg.expr)) (mv nil (fatal :type :vl-bad-argument :msg "~a0: trying to slice up ill-typed argument ~a1." :args (list elem arg.expr)) nil)) ((mv successp warnings bits) (vl-msb-bitslice-expr arg.expr ss warnings)) ((unless successp) (mv nil warnings nil)) (partitions (vl-partition-msb-bitslices port-width bits)) (plainargs (vl-exprlist-to-plainarglist partitions :dir arg.dir :atts arg.atts))) (mv t warnings plainargs))))
Theorem:
(defthm booleanp-of-vl-partition-plainarg.okp (b* (((mv ?okp ?warnings ?plainargs) (vl-partition-plainarg arg port-width insts ss elem warnings))) (booleanp okp)) :rule-classes :type-prescription)
Theorem:
(defthm vl-warninglist-p-of-vl-partition-plainarg.warnings (b* (((mv ?okp ?warnings ?plainargs) (vl-partition-plainarg arg port-width insts ss elem warnings))) (vl-warninglist-p warnings)) :rule-classes :rewrite)
Theorem:
(defthm vl-plainarglist-p-of-vl-partition-plainarg.plainargs (b* (((mv ?okp ?warnings ?plainargs) (vl-partition-plainarg arg port-width insts ss elem warnings))) (vl-plainarglist-p plainargs)) :rule-classes :rewrite)
Theorem:
(defthm len-of-vl-partition-plainarg (let ((ret (vl-partition-plainarg arg port-width insts ss elem warnings))) (implies (mv-nth 0 ret) (equal (len (mv-nth 2 ret)) (pos-fix insts)))))
Theorem:
(defthm vl-partition-plainarg-of-vl-plainarg-fix-arg (equal (vl-partition-plainarg (vl-plainarg-fix arg) port-width insts ss elem warnings) (vl-partition-plainarg arg port-width insts ss elem warnings)))
Theorem:
(defthm vl-partition-plainarg-vl-plainarg-equiv-congruence-on-arg (implies (vl-plainarg-equiv arg arg-equiv) (equal (vl-partition-plainarg arg port-width insts ss elem warnings) (vl-partition-plainarg arg-equiv port-width insts ss elem warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-partition-plainarg-of-pos-fix-port-width (equal (vl-partition-plainarg arg (pos-fix port-width) insts ss elem warnings) (vl-partition-plainarg arg port-width insts ss elem warnings)))
Theorem:
(defthm vl-partition-plainarg-pos-equiv-congruence-on-port-width (implies (acl2::pos-equiv port-width port-width-equiv) (equal (vl-partition-plainarg arg port-width insts ss elem warnings) (vl-partition-plainarg arg port-width-equiv insts ss elem warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-partition-plainarg-of-pos-fix-insts (equal (vl-partition-plainarg arg port-width (pos-fix insts) ss elem warnings) (vl-partition-plainarg arg port-width insts ss elem warnings)))
Theorem:
(defthm vl-partition-plainarg-pos-equiv-congruence-on-insts (implies (acl2::pos-equiv insts insts-equiv) (equal (vl-partition-plainarg arg port-width insts ss elem warnings) (vl-partition-plainarg arg port-width insts-equiv ss elem warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-partition-plainarg-of-vl-scopestack-fix-ss (equal (vl-partition-plainarg arg port-width insts (vl-scopestack-fix ss) elem warnings) (vl-partition-plainarg arg port-width insts ss elem warnings)))
Theorem:
(defthm vl-partition-plainarg-vl-scopestack-equiv-congruence-on-ss (implies (vl-scopestack-equiv ss ss-equiv) (equal (vl-partition-plainarg arg port-width insts ss elem warnings) (vl-partition-plainarg arg port-width insts ss-equiv elem warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-partition-plainarg-of-vl-modelement-fix-elem (equal (vl-partition-plainarg arg port-width insts ss (vl-modelement-fix elem) warnings) (vl-partition-plainarg arg port-width insts ss elem warnings)))
Theorem:
(defthm vl-partition-plainarg-vl-modelement-equiv-congruence-on-elem (implies (vl-modelement-equiv elem elem-equiv) (equal (vl-partition-plainarg arg port-width insts ss elem warnings) (vl-partition-plainarg arg port-width insts ss elem-equiv warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-partition-plainarg-of-vl-warninglist-fix-warnings (equal (vl-partition-plainarg arg port-width insts ss elem (vl-warninglist-fix warnings)) (vl-partition-plainarg arg port-width insts ss elem warnings)))
Theorem:
(defthm vl-partition-plainarg-vl-warninglist-equiv-congruence-on-warnings (implies (vl-warninglist-equiv warnings warnings-equiv) (equal (vl-partition-plainarg arg port-width insts ss elem warnings) (vl-partition-plainarg arg port-width insts ss elem warnings-equiv))) :rule-classes :congruence)