Convert a single user-level input value (e.g., 17, X, abus, etc) into a list of 4v-sexprs.
(stv-expand-input-entry name width pnum entry gensyms usersyms prev-val) → (mv new-val gensyms usersyms)
This function basically defines what each value in an :input line means. We transform each such value into a list of 4v-sexprs. These are the sexprs that will be given to this input during this phase. At a high level, our expansion strategy is:
Function:
(defun stv-expand-input-entry (name width pnum entry gensyms usersyms prev-val) (declare (xargs :guard (and (and (atom-listp name) (consp name)) (natp pnum) (equal width (len name))))) (let ((__function__ 'stv-expand-input-entry)) (declare (ignorable __function__)) (b* (((when (natp entry)) (or (< entry (ash 1 width)) (raise "Phase ~x0 for ~x1: value ~x2 is too wide to fit in ~x3 ~ bits!" pnum name entry width)) (mv (bool-to-4v-sexpr-lst (int-to-v entry width)) gensyms usersyms)) ((when (eq entry 'x)) (mv (replicate width *4vx-sexpr*) gensyms usersyms)) ((when (eq entry :ones)) (mv (replicate width *4vt-sexpr*) gensyms usersyms)) ((when (eq entry '~)) (or (= width 1) (raise "Phase ~x0 for ~x1: value ~~ is not legal here. It can ~ only be used in one-bit inputs, but this input is ~x2 ~ bits wide." pnum name width)) (or prev-val (raise "Phase ~x0 for ~x1: value ~~ is not legal here. It must ~ be preceeded by a constant true or false, so it cannot be ~ used at the start of a line." pnum name)) (or (equal prev-val (list *4vt-sexpr*)) (equal prev-val (list *4vf-sexpr*)) (raise "Phase ~x0 for ~x1: value ~~ is not legal here. It must ~ be preceeded by a constant true or false, but the ~ previous value was ~x2." pnum name prev-val)) (mv (if (equal prev-val (list *4vt-sexpr*)) (list *4vf-sexpr*) (list *4vt-sexpr*)) gensyms usersyms)) ((when (eq entry '_)) (let ((my-syms (stv-suffix-signals name (str::cat ".P" (str::natstr pnum))))) (mv my-syms (append my-syms gensyms) usersyms))) ((unless (and (symbolp entry) (not (keywordp entry)))) (raise "Phase ~x0 for ~x1: value ~x2 is not legal for input lines of ~ symbolic test vectors. See :xdoc symbolic-test-vector-format ~ for help." pnum name entry) (mv (replicate width *4vx-sexpr*) gensyms usersyms)) (my-syms (stv-gensyms (symbol-name entry) width)) (look (hons-get entry usersyms))) (or (not look) (equal (cdr look) my-syms) (raise "Phase ~x0 for ~x1: variable ~x2 cannnot be used here. This ~ input is ~x3 bits wide, but ~x2 was previously used for a ~ ~x4-bit input." pnum name entry width (len (cdr look)))) (mv my-syms gensyms (if look usersyms (hons-acons entry my-syms usersyms))))))
Theorem:
(defthm true-listp-of-stv-expand-input-entry-gensyms (implies (true-listp gensyms) (b* (((mv ?new-val gensyms ?usersyms) (stv-expand-input-entry name width pnum entry gensyms usersyms prev-val))) (true-listp gensyms))))