Try to convert a single gate into one of VL's primitive modules.
(vl-gateinst-gate-elim x primalist warnings) → (mv warnings gateinsts modinsts addmods)
We try to convert the gate instance
We may fail to eliminate
In case of such a failure, we add non-fatal warnings to explain what happened and leave the gate unchanged.
Function:
(defun vl-gateinst-gate-elim (x primalist warnings) (declare (xargs :guard (and (vl-gateinst-p x) (vl-primalist-p primalist) (vl-warninglist-p warnings)))) (let ((__function__ 'vl-gateinst-gate-elim)) (declare (ignorable __function__)) (b* (((vl-gateinst x) x) (target (cdr (hons-assoc-equal x.type primalist))) (exprs (vl-plainarglist->exprs x.args)) ((unless target) (mv (warn :type :vl-gate-elim-fail :msg "~a0: gates of type ~x1 are not supported by ~ gate-elim; leaving this gate unchanged." :args (list x x.type)) (list x) nil nil)) (target (vl-module-fix target)) (ports (vl-module->ports target)) ((unless (and (not x.range) (not (vl-collect-interface-ports ports)) (same-lengthp x.args ports) (not (member nil exprs)) (all-equalp 1 (vl-exprlist->finalwidths exprs)))) (mv (warn :type :vl-gate-elim-fail :msg "~a0: gates with ~s1 are not supported by gate-elim; ~ leaving this gate unchanged." :args (list x (cond (x.range "arrays") ((not (same-lengthp x.args ports)) "extra arguments") ((member nil exprs) "blank arguments") (t "wide arguments")))) (list x) nil nil)) (args (vl-add-portnames-to-plainargs x.args ports)) (modinst (make-vl-modinst :instname x.name :modname (vl-module->name target) :portargs (make-vl-arguments-plain :args args) :paramargs (make-vl-paramargs-plain :args nil) :loc x.loc))) (mv (ok) nil (list modinst) (list target)))))
Theorem:
(defthm vl-warninglist-p-of-vl-gateinst-gate-elim.warnings (b* (((mv ?warnings ?gateinsts ?modinsts ?addmods) (vl-gateinst-gate-elim x primalist warnings))) (vl-warninglist-p warnings)) :rule-classes :rewrite)
Theorem:
(defthm vl-gateinstlist-p-of-vl-gateinst-gate-elim.gateinsts (implies (force (vl-gateinst-p x)) (b* (((mv ?warnings ?gateinsts ?modinsts ?addmods) (vl-gateinst-gate-elim x primalist warnings))) (vl-gateinstlist-p gateinsts))) :rule-classes :rewrite)
Theorem:
(defthm vl-modinstlist-p-of-vl-gateinst-gate-elim.modinsts (implies (force (vl-gateinst-p x)) (b* (((mv ?warnings ?gateinsts ?modinsts ?addmods) (vl-gateinst-gate-elim x primalist warnings))) (vl-modinstlist-p modinsts))) :rule-classes :rewrite)
Theorem:
(defthm vl-modulelist-p-of-vl-gateinst-gate-elim.addmods (implies (force (vl-gateinst-p x)) (b* (((mv ?warnings ?gateinsts ?modinsts ?addmods) (vl-gateinst-gate-elim x primalist warnings))) (vl-modulelist-p addmods))) :rule-classes :rewrite)
Theorem:
(defthm vl-gateinst-gate-elim-mvtypes-1 (true-listp (mv-nth 1 (vl-gateinst-gate-elim x primalist warnings))) :rule-classes :type-prescription)
Theorem:
(defthm vl-gateinst-gate-elim-mvtypes-2 (true-listp (mv-nth 2 (vl-gateinst-gate-elim x primalist warnings))) :rule-classes :type-prescription)
Theorem:
(defthm vl-gateinst-gate-elim-mvtypes-3 (true-listp (mv-nth 3 (vl-gateinst-gate-elim x primalist warnings))) :rule-classes :type-prescription)