• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
        • Symbolic-test-vectors
          • Defstv
          • Stv-compile
          • Symbolic-test-vector-format
          • Stv-implementation-details
          • Compiled-stv-p
          • Stv-run-for-all-dontcares
          • Stv-run
          • Stv-process
          • Stv-run-check-dontcares
          • Symbolic-test-vector-composition
          • Stv-expand
            • Stv-hid-parse
            • Stv-expand-name
            • Stv-wirename-parse
            • Stv-maybe-match-select
              • Stv-hid-to-paths
              • Stv-hid-split
              • Stv-expand-hids-in-lines
              • Stv-expand-names-in-lines
              • Stv-expand-hid
              • Stv-check-noncanonical-paths
            • Stv-easy-bindings
            • Stv-debug
            • Stv-run-squash-dontcares
            • Stvdata-p
            • Stv-doc
            • Stv2c
            • Stv-widen
            • Stv-out->width
            • Stv-in->width
            • Stv->outs
            • Stv-number-of-phases
            • Stv->ins
            • Stv-suffix-signals
            • Stv->vars
          • Esim-primitives
          • E-conversion
          • Esim-steps
          • Patterns
          • Mod-internal-paths
          • Defmodules
          • Esim-simplify-update-fns
          • Esim-tutorial
          • Esim-vl
        • Vl2014
        • Sv
        • Fgl
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Testing-utilities
      • Math
    • Stv-expand

    Stv-maybe-match-select

    Match an expression with an optional bit- or part-select.

    Signature
    (stv-maybe-match-select x) → (mv err? from msb? lsb?)
    Arguments
    x — Guard (vl2014::vl-expr-p x).
    Returns
    err? — Type (maybe-stringp err?).
    from — Type (vl2014::vl-expr-p from), given the guard.
    msb? — Type (maybe-natp msb?).
    lsb? — Type (maybe-natp lsb?).

    Definitions and Theorems

    Function: stv-maybe-match-select

    (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: maybe-stringp-of-stv-maybe-match-select.err?

    (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: vl-expr-p-of-stv-maybe-match-select.from

    (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: maybe-natp-of-stv-maybe-match-select.msb?

    (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: maybe-natp-of-stv-maybe-match-select.lsb?

    (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)