• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
        • Syntax
        • Loader
        • Warnings
        • Getting-started
        • Utilities
        • Printer
        • Kit
        • Mlib
        • Transforms
          • Unparameterization
          • Elaborate
          • Addnames
          • Annotate
            • Increment-elim
            • Make-implicit-wires
              • Shadowcheck
                • Vl-shadowcheck-genelement
                • Vl-shadowcheck-reference-name
                  • Vl-shadowcheck-declare-name
                  • Deltemps
                  • Vl-shadowcheck-modelement
                  • Vl-lexscope
                  • Vl-shadowcheck-reference-scopeexpr
                  • Vl-shadowcheck-reference-names
                  • Vl-shadowcheck-declare-names
                  • Vl-shadowcheck-paramtype
                  • Vl-shadowcheck-fun/task-loaditems
                  • Vl-shadowcheck-fun/task-loaditem
                  • Vl-shadowcheck-fundecl
                  • Vl-shadowcheck-declare-typedefs
                  • Vl-shadowcheck-blockitemlist
                  • Vl-shadowcheck-portdecllist
                  • Vl-shadowcheck-paramdecls
                  • Vl-shadowcheck-dpiimports
                  • Vl-shadowcheck-taskdecls
                  • Vl-shadowcheck-taskdecl
                  • Vl-shadowcheck-push-scope
                  • Vl-shadowcheck-blockitem
                  • Vl-shadowcheck-vardecls
                  • Vl-shadowcheck-vardecl
                  • Vl-shadowcheck-typedef
                  • Vl-shadowcheck-portdecl
                  • Vl-shadowcheck-paramdecl
                  • Vl-shadowcheck-modport
                  • Vl-shadowcheck-modinst
                  • Vl-shadowcheck-imports
                  • Vl-shadowcheck-import
                  • Vl-shadowcheck-gateinst
                  • Vl-shadowcheck-fundecls
                  • Vl-shadowcheck-dpiimport
                  • Vl-shadowcheck-ports
                  • Vl-shadowcheck-port
                  • Vl-shadowcheck-initial
                  • Vl-shadowcheck-assign
                  • Vl-shadowcheck-always
                  • Vl-shadowcheck-final
                  • Vl-shadowcheck-alias
                  • Vl-shadowcheck-state
                  • Vl-shadowcheck-module
                  • Vl-shadowcheck-interface
                  • Vl-shadowcheck-interfaces
                  • Vl-shadowcheck-modules
                  • Vl-packagemap-find-packages-for-name
                  • Vl-shadowcheck-design
                  • Vl-lexscopes
                  • Vl-expr->maybe-subtype
                  • Vl-shadowcheck-pop-scope
                  • Nameclash
                  • Vl-portdecl-or-blockitem
                  • Vl-lexscope-decls
                  • Vl-packagemap
                  • Vl-portdecl-or-blockitem-list
                • Implicit-wires-minutia
                • Implicit-wires-generate-scoping
                • Vl-genbase-make-implicit-wires
                • Vl-expr-names-for-implicit
                • Vl-make-implicit-wires-main
                • Vl-implicitst
                • Vl-make-port-implicit-wires
                • Vl-import-update-implicit
                • Vl-blockitemlist-update-implicit
                • Vl-blockitem-update-implicit
                • Vl-make-ordinary-implicit-wires
                • Vl-remove-declared-wires
                • Vl-implicitsts-restore-fast-alists
                • Vl-genblock-under-cond-make-implicit-wires
                • Vl-collect-exprs-for-implicit-wires-from-namedargs
                • Vl-genblock-make-implicit-wires
                • Vl-collect-exprs-for-implicit-wires-from-portargs
                • Vl-collect-exprs-for-implicit-wires-from-namedarg
                • Vl-gateinst-exprs-for-implicit-wires
                • Vl-modinst-exprs-for-implicit-wires
                • Vl-genelementlist-make-implicit-wires
                • Vl-packagemap-find-name
              • Basic-bind-elim
              • Argresolve
              • Basicsanity
              • Portdecl-sign
              • Enum-names
              • Port-resolve
              • Udp-elim
              • Vl-annotate-design
              • Vl-annotate-module
            • Clean-warnings
            • Eliminitial
            • Custom-transform-hooks
            • Problem-modules
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Shadowcheck

    Vl-shadowcheck-reference-name

    Signature
    (vl-shadowcheck-reference-name name ctx st warnings) 
      → 
    (mv st warnings)
    Arguments
    name — Guard (stringp name).
    ctx — Guard (any-p ctx).
    st — Guard (vl-shadowcheck-state-p st).
    warnings — Guard (vl-warninglist-p warnings).
    Returns
    st — Type (vl-shadowcheck-state-p st).
    warnings — Type (vl-warninglist-p warnings).

    Definitions and Theorems

    Function: vl-shadowcheck-reference-name

    (defun vl-shadowcheck-reference-name (name ctx st warnings)
     (declare (xargs :guard (and (stringp name)
                                 (any-p ctx)
                                 (vl-shadowcheck-state-p st)
                                 (vl-warninglist-p warnings))))
     (let ((__function__ 'vl-shadowcheck-reference-name))
      (declare (ignorable __function__))
      (b*
       ((name (string-fix name))
        ((vl-shadowcheck-state st)
         (vl-shadowcheck-state-fix st))
        (- (vl-shadowcheck-debug
                "    vl-shadowcheck-reference-name: ~s0 for ~a1.~%"
                name ctx))
        ((mv entry tail)
         (vl-lexscopes-find name st.lexscopes))
        ((unless entry)
         (mv st
             (warn :type :vl-warn-undeclared
                   :msg "~a0: reference to undeclared identifier ~s1.~%"
                   :args (list ctx name))))
        ((vl-lexscope-entry entry))
        ((when (and (not entry.decl)
                    (not entry.direct-pkg)
                    (>= (len entry.wildpkgs) 2)))
         (mv
          st
          (fatal
           :type :vl-bad-import
           :msg
           "~a0: the name ~s1 is imported by multiple wildcard ~
                             imports: ~&2."
           :args (list ctx name entry.wildpkgs))))
        ((mv item scopestack-at-import pkg-name)
         (vl-scopestack-find-item/context name st.ss))
        ((unless (or item pkg-name))
         (if entry.genblockp (mv st (ok))
          (mv
           st
           (fatal
            :type :vl-programming-error
            :msg
            "~a0: scopestack can't resolve ~s1 but it is found ~
                             in the lexical scope, so how could that happen? ~x2."
            :args (list ctx name entry)))))
        ((unless pkg-name)
         (b*
          (((unless entry.decl)
            (mv
             st
             (warn
              :type :vl-tricky-scope
              :msg
              "~a0: the name ~s1 has complex scoping that ~
                                      we do not support.  Lexically it appears to ~
                                      be imported from a package, but there is a ~
                                      subsequent declaration (~a2) which makes ~
                                      scoping confusing."
              :args (list ctx name item))))
           (ss-level (vl-scopestack-nesting-level scopestack-at-import))
           (lex-level (len tail))
           ((when (and entry.genblockp (< ss-level lex-level)))
            (mv st (ok)))
           ((unless (equal ss-level lex-level))
            (mv
             st
             (warn
              :type :vl-tricky-scope
              :msg
              "~a0: the name ~s1 has complex scoping that we ~
                                   do not support.  Lexical level ~x2, scopestack ~
                                   level ~x3."
              :args (list ctx name lex-level ss-level))))
           ((when entry.genblockp)
            (mv
             st
             (warn
              :type :vl-tricky-scope
              :msg
              "~a0: the name ~s1 is bound to ~a2 but it is ~
                                     also the name of a generate block in the ~
                                     same scope."
              :args (list ctx name item)))))
          (mv st (ok))))
        ((when entry.genblockp)
         (mv
          st
          (warn
           :type :vl-tricky-scope
           :msg
           "~a0: the name ~s1 might be imported from package ~
                               ~s2 (item: ~a3), but it is also the name of a ~
                               generate block."
           :args (list ctx name pkg-name item))))
        ((when entry.decl)
         (mv
          st
          (fatal
           :type :vl-programming-error
           :msg
           "~a0: scopestack thinks ~s1 is imported from ~s2 ~
                                but lexically it seems to be locally declared, ~
                                ~a3."
           :args (list ctx name pkg-name entry.decl))))
        ((when entry.direct-pkg)
         (b*
          (((unless (equal entry.direct-pkg pkg-name))
            (mv
             st
             (warn
              :type :vl-tricky-scope
              :msg
              "~a0: scopestack thinks ~s1 is imported from ~
                                      ~s2, but lexically it is directly imported from ~s3."
              :args (list ctx name pkg-name entry.direct-pkg)))))
          (mv st (ok))))
        ((unless (consp entry.wildpkgs))
         (mv
          st
          (fatal
           :type :vl-programming-error
           :msg
           "~a0: name ~s1 has a lexscope entry with no local ~
                                declaration, direct package, or wild packages.  ~
                                How did this happen?"
           :args (list ctx name))))
        (lex-pkg (and (mbt (equal (len entry.wildpkgs) 1))
                      (first entry.wildpkgs)))
        ((unless (equal lex-pkg pkg-name))
         (mv
          st
          (warn
           :type :vl-tricky-scope
           :msg
           "~a0: scopestack thinks ~s1 is imported from ~s2, ~
                                but lexically it is wildly imported from ~s3."
           :args (list ctx name pkg-name lex-pkg)))))
       (mv st (ok)))))

    Theorem: vl-shadowcheck-state-p-of-vl-shadowcheck-reference-name.st

    (defthm vl-shadowcheck-state-p-of-vl-shadowcheck-reference-name.st
      (b* (((mv ?st ?warnings)
            (vl-shadowcheck-reference-name name ctx st warnings)))
        (vl-shadowcheck-state-p st))
      :rule-classes :rewrite)

    Theorem: vl-warninglist-p-of-vl-shadowcheck-reference-name.warnings

    (defthm vl-warninglist-p-of-vl-shadowcheck-reference-name.warnings
      (b* (((mv ?st ?warnings)
            (vl-shadowcheck-reference-name name ctx st warnings)))
        (vl-warninglist-p warnings))
      :rule-classes :rewrite)

    Theorem: vl-shadowcheck-reference-name-of-str-fix-name

    (defthm vl-shadowcheck-reference-name-of-str-fix-name
      (equal (vl-shadowcheck-reference-name (str-fix name)
                                            ctx st warnings)
             (vl-shadowcheck-reference-name name ctx st warnings)))

    Theorem: vl-shadowcheck-reference-name-streqv-congruence-on-name

    (defthm vl-shadowcheck-reference-name-streqv-congruence-on-name
     (implies
       (streqv name name-equiv)
       (equal
            (vl-shadowcheck-reference-name name ctx st warnings)
            (vl-shadowcheck-reference-name name-equiv ctx st warnings)))
     :rule-classes :congruence)

    Theorem: vl-shadowcheck-reference-name-of-identity-ctx

    (defthm vl-shadowcheck-reference-name-of-identity-ctx
      (equal (vl-shadowcheck-reference-name name (identity ctx)
                                            st warnings)
             (vl-shadowcheck-reference-name name ctx st warnings)))

    Theorem: vl-shadowcheck-reference-name-equal-congruence-on-ctx

    (defthm vl-shadowcheck-reference-name-equal-congruence-on-ctx
     (implies
       (equal ctx ctx-equiv)
       (equal
            (vl-shadowcheck-reference-name name ctx st warnings)
            (vl-shadowcheck-reference-name name ctx-equiv st warnings)))
     :rule-classes :congruence)

    Theorem: vl-shadowcheck-reference-name-of-vl-shadowcheck-state-fix-st

    (defthm vl-shadowcheck-reference-name-of-vl-shadowcheck-state-fix-st
      (equal (vl-shadowcheck-reference-name
                  name ctx (vl-shadowcheck-state-fix st)
                  warnings)
             (vl-shadowcheck-reference-name name ctx st warnings)))

    Theorem: vl-shadowcheck-reference-name-vl-shadowcheck-state-equiv-congruence-on-st

    (defthm
     vl-shadowcheck-reference-name-vl-shadowcheck-state-equiv-congruence-on-st
     (implies
       (vl-shadowcheck-state-equiv st st-equiv)
       (equal
            (vl-shadowcheck-reference-name name ctx st warnings)
            (vl-shadowcheck-reference-name name ctx st-equiv warnings)))
     :rule-classes :congruence)

    Theorem: vl-shadowcheck-reference-name-of-vl-warninglist-fix-warnings

    (defthm vl-shadowcheck-reference-name-of-vl-warninglist-fix-warnings
      (equal (vl-shadowcheck-reference-name
                  name
                  ctx st (vl-warninglist-fix warnings))
             (vl-shadowcheck-reference-name name ctx st warnings)))

    Theorem: vl-shadowcheck-reference-name-vl-warninglist-equiv-congruence-on-warnings

    (defthm
     vl-shadowcheck-reference-name-vl-warninglist-equiv-congruence-on-warnings
     (implies
       (vl-warninglist-equiv warnings warnings-equiv)
       (equal
            (vl-shadowcheck-reference-name name ctx st warnings)
            (vl-shadowcheck-reference-name name ctx st warnings-equiv)))
     :rule-classes :congruence)