Helper function for creating ports in generated modules.
(vl-occform-mkwire name width &key (loc '*vl-fakeloc*)) → (mv expr vardecl)
Imagine that we are trying to programmatically generate a module, and we want to add a wire with the given name and width. This function just generates the corresponding expression and net declaration.
Function:
(defun vl-occform-mkwire-fn (name width loc) (declare (xargs :guard (and (stringp name) (posp width) (vl-location-p loc)))) (let ((__function__ 'vl-occform-mkwire)) (declare (ignorable __function__)) (b* ((name (hons-copy (string-fix name))) (width (lposfix width)) (expr (vl-idexpr name width :vl-unsigned)) (range (vl-make-n-bit-range width)) (type (hons-copy (make-vl-coretype :name :vl-logic :signedp nil :pdims (list range)))) (vardecl (make-vl-vardecl :name name :type type :nettype :vl-wire :loc loc))) (mv expr vardecl))))
Theorem:
(defthm vl-expr-p-of-vl-occform-mkwire.expr (b* (((mv ?expr ?vardecl) (vl-occform-mkwire-fn name width loc))) (vl-expr-p expr)) :rule-classes :rewrite)
Theorem:
(defthm vl-vardecl-p-of-vl-occform-mkwire.vardecl (b* (((mv ?expr ?vardecl) (vl-occform-mkwire-fn name width loc))) (vl-vardecl-p vardecl)) :rule-classes :rewrite)
Theorem:
(defthm vl-occform-mkwire-fn-of-str-fix-name (equal (vl-occform-mkwire-fn (str-fix name) width loc) (vl-occform-mkwire-fn name width loc)))
Theorem:
(defthm vl-occform-mkwire-fn-streqv-congruence-on-name (implies (streqv name name-equiv) (equal (vl-occform-mkwire-fn name width loc) (vl-occform-mkwire-fn name-equiv width loc))) :rule-classes :congruence)
Theorem:
(defthm vl-occform-mkwire-fn-of-pos-fix-width (equal (vl-occform-mkwire-fn name (pos-fix width) loc) (vl-occform-mkwire-fn name width loc)))
Theorem:
(defthm vl-occform-mkwire-fn-pos-equiv-congruence-on-width (implies (acl2::pos-equiv width width-equiv) (equal (vl-occform-mkwire-fn name width loc) (vl-occform-mkwire-fn name width-equiv loc))) :rule-classes :congruence)
Theorem:
(defthm vl-occform-mkwire-fn-of-vl-location-fix-loc (equal (vl-occform-mkwire-fn name width (vl-location-fix loc)) (vl-occform-mkwire-fn name width loc)))
Theorem:
(defthm vl-occform-mkwire-fn-vl-location-equiv-congruence-on-loc (implies (vl-location-equiv loc loc-equiv) (equal (vl-occform-mkwire-fn name width loc) (vl-occform-mkwire-fn name width loc-equiv))) :rule-classes :congruence)