Match an expression with an optional bit- or part-select.
(stv-maybe-match-select x) → (mv err? from msb? lsb?)
Function:
(defun stv-maybe-match-select (x) (declare (xargs :guard (vl2014::vl-expr-p x))) (let ((__function__ 'stv-maybe-match-select)) (declare (ignorable __function__)) (b* (((when (vl2014::vl-atom-p x)) (mv nil x nil nil)) (op (vl2014::vl-nonatom->op x)) (args (vl2014::vl-nonatom->args x)) ((when (eq op :vl-select-colon)) (b* ((from (first args)) (msb (second args)) (lsb (third args)) ((unless (and (vl2014::vl-expr-resolved-p msb) (vl2014::vl-expr-resolved-p lsb))) (mv (str::cat (symbol-name __function__) ": part select indicies are not resolved: " (vl2014::vl-pps-expr x)) x nil nil))) (mv nil from (vl2014::vl-resolved->val msb) (vl2014::vl-resolved->val lsb)))) ((when (eq op :vl-index)) (b* ((from (first args)) (bit (second args)) ((unless (vl2014::vl-expr-resolved-p bit)) (mv (str::cat (symbol-name __function__) ": bit select index is not resolved: " (vl2014::vl-pps-expr x)) x nil nil)) (val (vl2014::vl-resolved->val bit))) (mv nil from val val)))) (mv nil x nil nil))))
Theorem:
(defthm maybe-stringp-of-stv-maybe-match-select.err? (b* (((mv ?err? ?from ?msb? ?lsb?) (stv-maybe-match-select x))) (maybe-stringp err?)) :rule-classes :type-prescription)
Theorem:
(defthm vl-expr-p-of-stv-maybe-match-select.from (implies (and (force (vl2014::vl-expr-p x))) (b* (((mv ?err? ?from ?msb? ?lsb?) (stv-maybe-match-select x))) (vl2014::vl-expr-p from))) :rule-classes :rewrite)
Theorem:
(defthm maybe-natp-of-stv-maybe-match-select.msb? (b* (((mv ?err? ?from ?msb? ?lsb?) (stv-maybe-match-select x))) (maybe-natp msb?)) :rule-classes :type-prescription)
Theorem:
(defthm maybe-natp-of-stv-maybe-match-select.lsb? (b* (((mv ?err? ?from ?msb? ?lsb?) (stv-maybe-match-select x))) (maybe-natp lsb?)) :rule-classes :type-prescription)