(vl-emodwire-p x) recognizes symbols that VL generates as wire names for E modules.
E uses a permissive pattern system that allows almost any atom to
be used as a wire name. But when VL is used to translate Verilog modules, we
always produce wire names that are symbols, whose names are either simple
names like
We always generate wire names in the
Function:
(defun vl-emodwire-scan$inline (name) (declare (type string name)) (b* ((open (position #\[ name)) (close (position #\] name)) (escape (if (position #\{ name) t nil)) (illegal (if (or (position #\. name) (position #\! name) (position #\/ name)) t nil))) (mv open close escape illegal)))
Function:
(defun vl-emodwire-get-index$inline (name open close) (declare (xargs :guard (and (stringp name) (natp open) (natp close) (< open close) (= close (- (length name) 1))))) (b* ((index-str (subseq name (+ open 1) close)) ((mv index-val len) (str::parse-nat-from-string index-str 0 0 0 (length index-str))) (ok1 (= len (length index-str))) (ok2 (equal index-str (natstr index-val)))) (mv (and ok1 ok2) index-val)))
Function:
(defun vl-emodwire-p (x) (declare (xargs :guard t)) (b* (((unless (and (symbolp x) x)) nil) (name (symbol-name x)) ((unless (eq (intern name "ACL2") x)) nil) ((mv open close escape illegal) (vl-emodwire-scan name)) ((when (or illegal (and escape (not (vl-emodwire-encoding-valid-p (explode name)))))) nil) ((when (and (not open) (not close))) t) ((unless (and open close (< open close) (= close (- (length name) 1)))) nil) ((mv okp ?idx) (vl-emodwire-get-index name open close))) okp))
Theorem:
(defthm booleanp-of-vl-emodwire-p (booleanp (vl-emodwire-p x)) :rule-classes :type-prescription)
Theorem:
(defthm type-of-vl-emodwire-p (implies (vl-emodwire-p x) (and (symbolp x) (not (equal x nil)))) :rule-classes :compound-recognizer)