Define a mapping between some user-provided names and internal signals of a design, with convenient macros for accessing them and looking them up in environments.
SV designs use fairly verbose and ugly variable names internally. To access signals of a design less painfully, this macro supports the definition of maps from user-provided names to SV-internal signals, with macro support for converting them at translation time and conveniently looking them up in environments.
Usage:
(defnamemap myname :design *my-sv-design* :names '(("foo.bar[3].baz" baz3) ;; Verilog-style signal names paired with user variable names ("src_data[1]" src2) ("result_flags[0]" ie)) :pkg-sym my-pkg ;; optional, defaults to basename :stobj my-svtv-stobj) ;; optional, defaults to sv::svtv-data
The invocation above produces three things:
(b* (((myname-sigs baz3 (my-src src2)) env)) (list baz3 my-src))Here the variables
For convenience, this macro supports a few different syntactic forms for the
elements of the
Additionally, the macro should be able to determine whether the user wanted to evaluate the names or not. E.g., the following three forms should all have the same result:
:names (("foo" bar) ...) :names '(("foo" bar) ...) :names (cons (list "foo" 'bar) ...)
The internal representations of these signals are as lhs objects. An
LHS is a fixed-width concatenation of fixed segments of signals. The design
hierarchy has to be consulted to determine the particular LHS that a given
Verilog-style name maps to. To compute the mapping (in particular, to
translate the Verilog-style names to proper SV-internal LHS objects), the
design is first flattened and its moddb and
Since the signal names map to LHS objects, the values extracted for them from the environment are computed with lhs-eval-zx. This zero-extends the value of the signal at its width. The following is a possible expansion for the B* binding:
(b* (((myname-sigs baz3 (my-src src2)) env)) (list baz3 my-src)) --> (let* ((baz3 (lhs-eval-zx '((5 :VAR ("foo" "bar" 3 . "baz") . 0)) env)) (my-src (lhs-eval-zx '((64 "src_data" . 64)) env))) (list baz3 my-src))