Function:
(defun vl-partselect-width (x) (declare (xargs :guard (vl-partselect-p x))) (declare (xargs :guard (not (vl-partselect-case x :none)))) (let ((__function__ 'vl-partselect-width)) (declare (ignorable __function__)) (b* ((x (vl-partselect-fix x))) (vl-partselect-case x :range (b* (((unless (and (vl-expr-resolved-p x.msb) (vl-expr-resolved-p x.lsb))) (mv (vmsg "Unresolved partselect: ~a0" x) nil)) (msb (vl-resolved->val x.msb)) (lsb (vl-resolved->val x.lsb))) (mv nil (+ 1 (abs (- msb lsb))))) :plusminus (b* (((unless (vl-expr-resolved-p x.width)) (mv (vmsg "Unresolved partselect width: ~a0" x) nil)) (width (vl-resolved->val x.width)) ((when (<= width 0)) (mv (vmsg "Non-positive-width partselect not allowed: ~a0" x) nil))) (mv nil width)) :otherwise (mv (vmsg "Impossible") (impossible))))))
Theorem:
(defthm return-type-of-vl-partselect-width.err (b* (((mv ?err ?width) (vl-partselect-width x))) (iff (vl-msg-p err) err)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-partselect-width.width (b* (((mv ?err ?width) (vl-partselect-width x))) (implies (not err) (posp width))) :rule-classes :type-prescription)
Theorem:
(defthm vl-partselect-width-of-vl-partselect-fix-x (equal (vl-partselect-width (vl-partselect-fix x)) (vl-partselect-width x)))
Theorem:
(defthm vl-partselect-width-vl-partselect-equiv-congruence-on-x (implies (vl-partselect-equiv x x-equiv) (equal (vl-partselect-width x) (vl-partselect-width x-equiv))) :rule-classes :congruence)