Dependency-order sort the modules of a design.
(vl-design-deporder-modules x) → (mv successp new-x)
Function:
(defun vl-design-deporder-modules (x) (declare (xargs :guard (vl-design-p x))) (let ((__function__ 'vl-design-deporder-modules)) (declare (ignorable __function__)) (b* (((vl-design x) (vl-design-fix x)) (downgraph (vl-design-downgraph x)) ((unless (uniquep (alist-keys downgraph))) (mv (cw "Global dependency graph has name clashes: ~x0.~%" (duplicated-members (alist-keys downgraph))) x)) ((mv okp deporder) (depgraph::toposort downgraph)) ((unless okp) (mv (cw "Global dependency loop: ~x0.~%" deporder) x)) ((unless (string-listp deporder)) (mv (raise "Type error, dependency order should be strings.") x)) (new-mods (vl-reorder-modules deporder x.mods)) ((unless (equal (mergesort x.mods) (mergesort new-mods))) (mv (raise "Dependency ordering changed the modules somehow??") x))) (mv t (change-vl-design x :mods new-mods)))))
Theorem:
(defthm booleanp-of-vl-design-deporder-modules.successp (b* (((mv ?successp ?new-x) (vl-design-deporder-modules x))) (booleanp successp)) :rule-classes :type-prescription)
Theorem:
(defthm vl-design-p-of-vl-design-deporder-modules.new-x (b* (((mv ?successp ?new-x) (vl-design-deporder-modules x))) (vl-design-p new-x)) :rule-classes :rewrite)
Theorem:
(defthm vl-design-deporder-modules-of-vl-design-fix-x (equal (vl-design-deporder-modules (vl-design-fix x)) (vl-design-deporder-modules x)))
Theorem:
(defthm vl-design-deporder-modules-vl-design-equiv-congruence-on-x (implies (vl-design-equiv x x-equiv) (equal (vl-design-deporder-modules x) (vl-design-deporder-modules x-equiv))) :rule-classes :congruence)