Legacy -- Use scopestack instead. A (naive) lookup operation that can find any name in the module's namespace.
(vl-find-moduleitem name x) → item?
This is our main, naive spec for what it means to look up a name in a module's namespace. Note that we don't look for port declarations! (But typically this will find the corresponding net/reg declaration for a port.)
Typically you will want to use vl-fast-find-moduleitem when looking up multiple items.
Function:
(defun vl-find-moduleitem (name x) (declare (xargs :guard (and (stringp name) (vl-module-p x)))) (let ((__function__ 'vl-find-moduleitem)) (declare (ignorable __function__)) (b* (((vl-module x) x) (name (string-fix name))) (or (vl-find-vardecl name x.vardecls) (vl-find-paramdecl name x.paramdecls) (vl-find-fundecl name x.fundecls) (vl-find-taskdecl name x.taskdecls) (vl-find-modinst name x.modinsts) (vl-find-gateinst name x.gateinsts)))))
Theorem:
(defthm vl-find-moduleitem-type-when-nothing-else (implies (and (vl-find-moduleitem name x) (not (vl-vardecl-p (vl-find-moduleitem name x))) (not (vl-paramdecl-p (vl-find-moduleitem name x))) (not (vl-fundecl-p (vl-find-moduleitem name x))) (not (vl-taskdecl-p (vl-find-moduleitem name x))) (not (vl-modinst-p (vl-find-moduleitem name x)))) (vl-gateinst-p (vl-find-moduleitem name x))) :rule-classes ((:rewrite :backchain-limit-lst 1)))
Theorem:
(defthm type-of-vl-find-moduleitem (and (equal (equal (tag (vl-find-moduleitem name x)) :vl-vardecl) (vl-vardecl-p (vl-find-moduleitem name x))) (equal (equal (tag (vl-find-moduleitem name x)) :vl-paramdecl) (vl-paramdecl-p (vl-find-moduleitem name x))) (equal (equal (tag (vl-find-moduleitem name x)) :vl-fundecl) (vl-fundecl-p (vl-find-moduleitem name x))) (equal (equal (tag (vl-find-moduleitem name x)) :vl-taskdecl) (vl-taskdecl-p (vl-find-moduleitem name x))) (equal (equal (tag (vl-find-moduleitem name x)) :vl-modinst) (vl-modinst-p (vl-find-moduleitem name x))) (equal (equal (tag (vl-find-moduleitem name x)) :vl-gateinst) (vl-gateinst-p (vl-find-moduleitem name x)))))
Theorem:
(defthm consp-of-vl-find-moduleitem (equal (consp (vl-find-moduleitem name x)) (if (vl-find-moduleitem name x) t nil)))
Theorem:
(defthm vl-find-moduleitem-when-in-namespace (implies (member-equal name (vl-module->modnamespace x)) (vl-find-moduleitem name x)))
Theorem:
(defthm vl-find-moduleitem-of-str-fix-name (equal (vl-find-moduleitem (str-fix name) x) (vl-find-moduleitem name x)))
Theorem:
(defthm vl-find-moduleitem-streqv-congruence-on-name (implies (streqv name name-equiv) (equal (vl-find-moduleitem name x) (vl-find-moduleitem name-equiv x))) :rule-classes :congruence)
Theorem:
(defthm vl-find-moduleitem-of-vl-module-fix-x (equal (vl-find-moduleitem name (vl-module-fix x)) (vl-find-moduleitem name x)))
Theorem:
(defthm vl-find-moduleitem-vl-module-equiv-congruence-on-x (implies (vl-module-equiv x x-equiv) (equal (vl-find-moduleitem name x) (vl-find-moduleitem name x-equiv))) :rule-classes :congruence)