Assumes x was NOT just a plain identifier (or we are in the erroneous case where it was a plain identifier, but there was no previous port to base it on.) Type and nettype info comes from x itself; only the direction may come from the previous port.
(vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings) → (mv warnings port portdecl? vardecl?)
Function:
(defun vl-ansi-portdecl-to-regularport (x ports-acc portdecls-acc warnings) (declare (xargs :guard (and (vl-ansi-portdecl-p x) (vl-portlist-p ports-acc) (vl-portdecllist-p portdecls-acc) (vl-warninglist-p warnings)))) (declare (xargs :guard (equal (len portdecls-acc) (len (vl-collect-regular-ports ports-acc))))) (let ((__function__ 'vl-ansi-portdecl-to-regularport)) (declare (ignorable __function__)) (b* (((vl-ansi-portdecl x) (vl-ansi-portdecl-fix x)) ((mv dir warnings) (cond (x.dir (mv x.dir (ok))) ((atom ports-acc) (mv :vl-inout nil)) (t (b* ((port1 (car ports-acc))) (vl-port-case port1 :vl-regularport (mv (vl-portdecl->dir (car portdecls-acc)) (ok)) :vl-interfaceport (mv :vl-inout (fatal :type :vl-bad-ports :msg "~a0: can't infer direction for port ~a1 ~ since it follows an interface port. ~ Please explicitly specify a direction ~ (input, output, ...)" :args (list x.loc x.name)))))))) (nettype (vl-nettype-for-parsed-ansi-port dir x)) (type (vl-ansi-portdecl-regularport-type x))) (mv (ok) (make-vl-regularport :name x.name :expr (vl-idexpr x.name) :loc x.loc) (list (make-vl-portdecl :name x.name :dir dir :nettype nettype :type type :atts x.atts :loc x.loc)) (list (make-vl-vardecl :name x.name :nettype nettype :type type :varp x.varp :atts (if x.atts (hons '("VL_ANSI_PORT_VARDECL") x.atts) (hons-copy '(("VL_ANSI_PORT_VARDECL")))) :loc x.loc))))))
Theorem:
(defthm vl-warninglist-p-of-vl-ansi-portdecl-to-regularport.warnings (b* (((mv ?warnings ?port ?portdecl? ?vardecl?) (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings))) (vl-warninglist-p warnings)) :rule-classes :rewrite)
Theorem:
(defthm vl-regularport-p-of-vl-ansi-portdecl-to-regularport.port (b* (((mv ?warnings ?port ?portdecl? ?vardecl?) (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings))) (vl-regularport-p port)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-ansi-portdecl-to-regularport.portdecl? (b* (((mv ?warnings ?port ?portdecl? ?vardecl?) (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings))) (and (vl-portdecllist-p portdecl?) (equal (len portdecl?) (vl-port-case port :vl-interfaceport 0 :vl-regularport 1)))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-ansi-portdecl-to-regularport.vardecl? (b* (((mv ?warnings ?port ?portdecl? ?vardecl?) (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings))) (and (vl-vardecllist-p vardecl?) (equal (len vardecl?) (vl-port-case port :vl-interfaceport 0 :vl-regularport 1)))) :rule-classes :rewrite)
Theorem:
(defthm vl-ansi-portdecl-to-regularport-of-vl-ansi-portdecl-fix-x (equal (vl-ansi-portdecl-to-regularport (vl-ansi-portdecl-fix x) ports-acc portdecls-acc warnings) (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings)))
Theorem:
(defthm vl-ansi-portdecl-to-regularport-vl-ansi-portdecl-equiv-congruence-on-x (implies (vl-ansi-portdecl-equiv x x-equiv) (equal (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings) (vl-ansi-portdecl-to-regularport x-equiv ports-acc portdecls-acc warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-ansi-portdecl-to-regularport-of-vl-portlist-fix-ports-acc (equal (vl-ansi-portdecl-to-regularport x (vl-portlist-fix ports-acc) portdecls-acc warnings) (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings)))
Theorem:
(defthm vl-ansi-portdecl-to-regularport-vl-portlist-equiv-congruence-on-ports-acc (implies (vl-portlist-equiv ports-acc ports-acc-equiv) (equal (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings) (vl-ansi-portdecl-to-regularport x ports-acc-equiv portdecls-acc warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-ansi-portdecl-to-regularport-of-vl-portdecllist-fix-portdecls-acc (equal (vl-ansi-portdecl-to-regularport x ports-acc (vl-portdecllist-fix portdecls-acc) warnings) (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings)))
Theorem:
(defthm vl-ansi-portdecl-to-regularport-vl-portdecllist-equiv-congruence-on-portdecls-acc (implies (vl-portdecllist-equiv portdecls-acc portdecls-acc-equiv) (equal (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings) (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc-equiv warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-ansi-portdecl-to-regularport-of-vl-warninglist-fix-warnings (equal (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc (vl-warninglist-fix warnings)) (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings)))
Theorem:
(defthm vl-ansi-portdecl-to-regularport-vl-warninglist-equiv-congruence-on-warnings (implies (vl-warninglist-equiv warnings warnings-equiv) (equal (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings) (vl-ansi-portdecl-to-regularport x ports-acc portdecls-acc warnings-equiv))) :rule-classes :congruence)