Main function for transforming a Verilog module instance into an (preliminary) E language occurrence.
(vl-modinst-to-eocc x walist mods modalist eal warnings) → (mv successp warnings eocc)
We do a lot of sanity checking to make sure the module instance is
simple enough to transform, that the submodule exists and was translated into
an E module successfully, etc. Then, we figure out the bindings to use for the
Function:
(defun vl-modinst-to-eocc (x walist mods modalist eal warnings) (declare (xargs :guard (and (vl-modinst-p x) (vl-wirealist-p walist) (vl-modulelist-p mods) (vl-ealist-p eal) (vl-warninglist-p warnings) (equal modalist (vl-modalist mods))))) (let ((__function__ 'vl-modinst-to-eocc)) (declare (ignorable __function__)) (b* (((vl-modinst x) x) ((unless x.instname) (mv nil (fatal :type :vl-bad-instance :msg "~a0: expected all module instances to be named. Did ~ you run the addinstnames transform?" :args (list x)) nil)) ((when x.range) (mv nil (fatal :type :vl-bad-instance :msg "~a0: expected only simple module instances, but ~s1 ~ is an array of module instances. Did you run the ~ replicate transform?" :args (list x x.instname)) nil)) ((unless (vl-paramargs-empty-p x.paramargs)) (mv nil (fatal :type :vl-bad-instance :msg "~a0: expected only simple module instances, but ~s1 ~ still has parameters. Did you run the ~ unparameterization transform?" :args (list x x.instname)) nil)) ((when (eq (vl-arguments-kind x.portargs) :vl-arguments-named)) (mv nil (fatal :type :vl-bad-instance :msg "~a0: expected only resolved module instances, but ~ ~s1 still has named arguments. Did you run the ~ argresolve transform?" :args (list x x.instname)) nil)) (sub (vl-fast-find-module x.modname mods modalist)) ((unless sub) (mv nil (fatal :type :vl-bad-instance :msg "~a0 refers to undefined module ~m1." :args (list x x.modname)) nil)) (sub-esim (cdr (hons-get x.modname eal))) ((unless sub-esim) (mv nil (fatal :type :vl-bad-submodule :msg "~a0 refers to module ~m1, but we failed to build an ~ E module for ~m1." :args (list x x.modname)) nil)) ((mv okp & sub-walist) (vl-module-wirealist sub nil)) ((unless okp) (mv nil (fatal :type :vl-programming-error :msg "~a0: failed to build a wire alist for ~x0? Jared ~ thinks this should never happen since we were able ~ to build the ESIM module for it." :args (list x.modname)) nil)) ((mv successp & portpat) (vl-portlist-msb-bit-pattern (vl-module->ports sub) sub-walist)) ((unless successp) (mv nil (fatal :type :vl-programming-error :msg "~a0: failed to build a portlist pattern for module ~ ~m1. Jared thinks this should never happen because ~ we check that these lists can be built before trying ~ to make E occurrences from module instances." :args (list x x.modname)) nil)) (actuals (vl-arguments-plain->args x.portargs)) ((unless (same-lengthp actuals portpat)) (mv nil (fatal :type :vl-bad-instance :msg "~a0: wrong arity. Expected ~x1 arguments but found ~x2." :args (list x (len portpat) (len actuals))) nil)) ((mv successp warnings binding-alist) (vl-modinst-eocc-bindings actuals portpat walist warnings x)) ((unless successp) (mv nil warnings nil)) ((mv successp & in-pat out-pat) (vl-portdecls-to-i/o (vl-module->portdecls sub) sub-walist)) ((unless successp) (mv nil (fatal :type :vl-programming-error :msg "~a0: failed to build :i and :o patterns for module ~ ~m1. Jared thinks this should never happen because ~ we already built its esim and should have checked ~ that this was all okay due to port-bit-checking." :args (list x x.modname)) nil)) ((unless (and (equal in-pat (gpl :i sub-esim)) (equal out-pat (gpl :o sub-esim)))) (mv nil (fatal :type :vl-programming-error :msg "~a0: the :i and :o patterns we built for ~m1 do ~ not agree with the :i and :o patterns of its ESIM? ~ Jared thinks this should never happen because the ~ patterns should be being built in the same way. ~% ~ - in-pat: ~x2~% ~ - found: ~x3~% ~ - out-pat: ~x4~% ~ - found: ~x5~%" :args (list x x.modname in-pat (gpl :i sub-esim) out-pat (gpl :o sub-esim))) nil)) ((with-fast binding-alist)) (all-formal-bits (pat-flatten out-pat (pat-flatten1 in-pat))) (all-actual-bits (alist-keys binding-alist)) ((unless (equal (mergesort all-formal-bits) (mergesort all-actual-bits))) (mv nil (fatal :type :vl-programming-error :msg "~a0: the binding alist we produced doesn't contain ~ bindings for exactly the right bits. Jared thinks ~ vl-modinst-to-eocc-bindings should ensure that this ~ never happens." :args (list x)) nil)) (inputs (al->pat in-pat binding-alist nil)) (outputs (al->pat out-pat binding-alist nil)) (instname (vl-plain-wire-name x.instname)) (eocc (list* :u instname :op sub-esim :o outputs :i inputs (if x.atts (list :a x.atts) nil)))) (mv t (ok) eocc))))
Theorem:
(defthm booleanp-of-vl-modinst-to-eocc.successp (b* (((mv ?successp ?warnings ?eocc) (vl-modinst-to-eocc x walist mods modalist eal warnings))) (booleanp successp)) :rule-classes :type-prescription)
Theorem:
(defthm vl-warninglist-p-of-vl-modinst-to-eocc.warnings (b* (((mv ?successp ?warnings ?eocc) (vl-modinst-to-eocc x walist mods modalist eal warnings))) (vl-warninglist-p warnings)) :rule-classes :rewrite)
Theorem:
(defthm good-esim-occp-of-vl-modinst-to-eocc (let ((ret (vl-modinst-to-eocc x walist mods modalist eal warnings))) (implies (and (mv-nth 0 ret) (force (vl-modinst-p x)) (force (vl-wirealist-p walist)) (force (vl-modulelist-p mods)) (force (equal modalist (vl-modalist mods))) (force (vl-ealist-p eal))) (good-esim-occp (mv-nth 2 ret)))))