• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • 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-lexscopes-fix
                  • Vl-lexscopes-direct-import-name
                    • Vl-lexscopes-declare-name
                    • Vl-lexscopes-do-import
                    • Vl-lexscopes-find
                    • Vl-lexscopes-equiv
                    • Vl-lexscopes-p
                    • Vl-lexscopes-exit-scope
                    • Vl-lexscopes-enter-new-scope
                  • 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
    • Vl-lexscopes

    Vl-lexscopes-direct-import-name

    Extend the lexscopes with a direct import of a single name.

    Signature
    (vl-lexscopes-direct-import-name pkgname name scopes ctx warnings) 
      → 
    (mv scopes warnings)
    Arguments
    pkgname — Name of the package being imported from.
        Guard (stringp pkgname).
    name — Name being directly imported from the package.
        Guard (stringp name).
    scopes — Guard (vl-lexscopes-p scopes).
    ctx — Guard (vl-import-p ctx).
    warnings — Guard (vl-warninglist-p warnings).
    Returns
    scopes — Type (vl-lexscopes-p scopes).
    warnings — Type (vl-warninglist-p warnings).

    Definitions and Theorems

    Function: vl-lexscopes-direct-import-name

    (defun vl-lexscopes-direct-import-name
           (pkgname name scopes ctx warnings)
     (declare (xargs :guard (and (stringp pkgname)
                                 (stringp name)
                                 (vl-lexscopes-p scopes)
                                 (vl-import-p ctx)
                                 (vl-warninglist-p warnings))))
     (let ((__function__ 'vl-lexscopes-direct-import-name))
      (declare (ignorable __function__))
      (b*
       ((pkgname (string-fix pkgname))
        (name (string-fix name))
        (scopes (vl-lexscopes-fix scopes))
        (ctx (vl-import-fix ctx))
        (warnings (vl-warninglist-fix warnings))
        ((when (atom scopes))
         (raise "Expected at least one scope.")
         (mv scopes warnings))
        (scope1 (car scopes))
        (decls (vl-lexscope->decls scope1))
        (entry (vl-lexscope-find name scope1))
        ((unless entry)
         (mv
          (cons
            (change-vl-lexscope
                 scope1
                 :decls
                 (hons-acons name
                             (make-vl-lexscope-entry :direct-pkg pkgname
                                                     :decl nil
                                                     :wildpkgs nil)
                             decls))
            (cdr scopes))
          warnings))
        ((vl-lexscope-entry entry))
        (warnings
         (if entry.decl
          (fatal
               :type :vl-name-clash
               :msg
               "~a0: can't import ~s1 after locally declaring it (~a2)."
               :args (list ctx name entry.decl))
          warnings))
        (warnings
         (if
          (and entry.direct-pkg
               (not (equal entry.direct-pkg pkgname)))
          (fatal
           :type :vl-name-clash
           :msg
           "~a0: can't import ~s1 from ~s2 after previously importing ~
                             it from ~s3."
           :args (list ctx name pkgname entry.direct-pkg))
          warnings))
        (new-entry (if (or entry.decl entry.direct-pkg)
                       entry
                     (change-vl-lexscope-entry entry
                                               :direct-pkg pkgname)))
        (new-scope1
          (change-vl-lexscope scope1
                              :decls (hons-acons name new-entry decls)))
        (new-scopes (cons new-scope1 (cdr scopes))))
       (mv new-scopes warnings))))

    Theorem: vl-lexscopes-p-of-vl-lexscopes-direct-import-name.scopes

    (defthm vl-lexscopes-p-of-vl-lexscopes-direct-import-name.scopes
      (b* (((mv ?scopes ?warnings)
            (vl-lexscopes-direct-import-name
                 pkgname name scopes ctx warnings)))
        (vl-lexscopes-p scopes))
      :rule-classes :rewrite)

    Theorem: vl-warninglist-p-of-vl-lexscopes-direct-import-name.warnings

    (defthm vl-warninglist-p-of-vl-lexscopes-direct-import-name.warnings
      (b* (((mv ?scopes ?warnings)
            (vl-lexscopes-direct-import-name
                 pkgname name scopes ctx warnings)))
        (vl-warninglist-p warnings))
      :rule-classes :rewrite)

    Theorem: vl-lexscopes-direct-import-name-of-str-fix-pkgname

    (defthm vl-lexscopes-direct-import-name-of-str-fix-pkgname
      (equal (vl-lexscopes-direct-import-name (str-fix pkgname)
                                              name scopes ctx warnings)
             (vl-lexscopes-direct-import-name
                  pkgname name scopes ctx warnings)))

    Theorem: vl-lexscopes-direct-import-name-streqv-congruence-on-pkgname

    (defthm vl-lexscopes-direct-import-name-streqv-congruence-on-pkgname
     (implies
       (streqv pkgname pkgname-equiv)
       (equal
            (vl-lexscopes-direct-import-name
                 pkgname name scopes ctx warnings)
            (vl-lexscopes-direct-import-name pkgname-equiv
                                             name scopes ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-lexscopes-direct-import-name-of-str-fix-name

    (defthm vl-lexscopes-direct-import-name-of-str-fix-name
      (equal (vl-lexscopes-direct-import-name pkgname (str-fix name)
                                              scopes ctx warnings)
             (vl-lexscopes-direct-import-name
                  pkgname name scopes ctx warnings)))

    Theorem: vl-lexscopes-direct-import-name-streqv-congruence-on-name

    (defthm vl-lexscopes-direct-import-name-streqv-congruence-on-name
      (implies (streqv name name-equiv)
               (equal (vl-lexscopes-direct-import-name
                           pkgname name scopes ctx warnings)
                      (vl-lexscopes-direct-import-name
                           pkgname
                           name-equiv scopes ctx warnings)))
      :rule-classes :congruence)

    Theorem: vl-lexscopes-direct-import-name-of-vl-lexscopes-fix-scopes

    (defthm vl-lexscopes-direct-import-name-of-vl-lexscopes-fix-scopes
      (equal (vl-lexscopes-direct-import-name
                  pkgname name (vl-lexscopes-fix scopes)
                  ctx warnings)
             (vl-lexscopes-direct-import-name
                  pkgname name scopes ctx warnings)))

    Theorem: vl-lexscopes-direct-import-name-vl-lexscopes-equiv-congruence-on-scopes

    (defthm
     vl-lexscopes-direct-import-name-vl-lexscopes-equiv-congruence-on-scopes
     (implies (vl-lexscopes-equiv scopes scopes-equiv)
              (equal (vl-lexscopes-direct-import-name
                          pkgname name scopes ctx warnings)
                     (vl-lexscopes-direct-import-name
                          pkgname
                          name scopes-equiv ctx warnings)))
     :rule-classes :congruence)

    Theorem: vl-lexscopes-direct-import-name-of-vl-import-fix-ctx

    (defthm vl-lexscopes-direct-import-name-of-vl-import-fix-ctx
      (equal (vl-lexscopes-direct-import-name
                  pkgname name scopes (vl-import-fix ctx)
                  warnings)
             (vl-lexscopes-direct-import-name
                  pkgname name scopes ctx warnings)))

    Theorem: vl-lexscopes-direct-import-name-vl-import-equiv-congruence-on-ctx

    (defthm
      vl-lexscopes-direct-import-name-vl-import-equiv-congruence-on-ctx
      (implies (vl-import-equiv ctx ctx-equiv)
               (equal (vl-lexscopes-direct-import-name
                           pkgname name scopes ctx warnings)
                      (vl-lexscopes-direct-import-name
                           pkgname
                           name scopes ctx-equiv warnings)))
      :rule-classes :congruence)

    Theorem: vl-lexscopes-direct-import-name-of-vl-warninglist-fix-warnings

    (defthm
         vl-lexscopes-direct-import-name-of-vl-warninglist-fix-warnings
      (equal (vl-lexscopes-direct-import-name
                  pkgname name scopes
                  ctx (vl-warninglist-fix warnings))
             (vl-lexscopes-direct-import-name
                  pkgname name scopes ctx warnings)))

    Theorem: vl-lexscopes-direct-import-name-vl-warninglist-equiv-congruence-on-warnings

    (defthm
     vl-lexscopes-direct-import-name-vl-warninglist-equiv-congruence-on-warnings
     (implies (vl-warninglist-equiv warnings warnings-equiv)
              (equal (vl-lexscopes-direct-import-name
                          pkgname name scopes ctx warnings)
                     (vl-lexscopes-direct-import-name
                          pkgname
                          name scopes ctx warnings-equiv)))
     :rule-classes :congruence)