• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
        • Syntax
        • Loader
          • Preprocessor
          • Vl-loadconfig
          • Vl-loadstate
          • Lexer
          • Parser
            • Parse-expressions
              • Vl-expressions->paramvalues
              • Vl-erange-p
              • Vl-mixed-binop-list-p
              • Vl-parse-very-simple-type
              • Vl-parse-0+-scope-prefixes
              • Vl-parse-0+-attribute-instances
              • Vl-parse-hierarchical-identifier
              • Vl-parse-op
              • Vl-mark-as-explicit-parens
              • Vl-parse-expression-top
              • Vl-parse-any-sort-of-concatenation-aux
              • Vl-parse-datatype-or-implicit
              • Vl-vardeclassignlist-p
              • Vl-build-range-select
              • Vl-parse-scopename
              • Vl-parse-optional-edge-identifier
              • Vl-make-structmembers
              • Vl-erangetypelist-p
              • Vl-coretypekwd->info
              • Vl-streamexpr-with
              • Vl-parse-simple-type
              • Vl-expr-has-any-atts-p
              • Vl-vardeclassignlist-newfree-p
              • Vl-tack-scopes-onto-hid
              • Vl-left-associate-mixed-binop-list
              • Vl-extend-atts-with-linestart
              • Vl-parse-op-alist-p
              • Vl-make-guts-from-inttoken
              • Vl-extend-expr-with-linestart
              • Vl-interpret-expr-as-type
              • Vl-initial-patternkey-from-expr
              • Vl-parse-range-expression
              • Vl-parse-slice-size
              • Vl-parse-concatenation
              • Vl-parse-stream-expression
              • Vl-plausible-start-of-range-p
              • Vl-parse-any-sort-of-concatenation
              • Vl-parse-1+-stream-expressions-separated-by-commas
              • Vl-parse-stream-concatenation
              • Vl-parse-primary
                • Vl-maybe-parse-base-primary
                • Vl-parse-datatype
                • Vl-parse-0+-bracketed-expressions
                • Vl-parse-variable-decl-assignment
                • Vl-parse-system-function-call
                • Vl-parse-shift-expression-aux
                • Vl-parse-power-expression-aux
                • Vl-parse-parameter-value-assignment
                • Vl-parse-named-parameter-assignment
                • Vl-parse-mult-expression-aux
                • Vl-parse-mintypmax-expression
                • Vl-parse-logor-expression-aux
                • Vl-parse-logand-expression-aux
                • Vl-parse-list-of-parameter-assignments
                • Vl-parse-indexed-id-2012
                • Vl-parse-indexed-id-2005
                • Vl-parse-expression-without-failure
                • Vl-parse-expr-or-clocking-event
                • Vl-parse-event-expression-2012
                • Vl-parse-event-expression-2005
                • Vl-parse-event-expression
                • Vl-parse-equality-expression-aux
                • Vl-parse-equality-expression
                • Vl-parse-enum-name-declaration
                • Vl-parse-compare-expression-aux
                • Vl-parse-bitxor-expression-aux
                • Vl-parse-bitor-expression-aux
                • Vl-parse-bitand-expression-aux
                • Vl-parse-associative-dimension
                • Vl-parse-1+-variable-decl-assignments-separated-by-commas
                • Vl-parse-1+-open-value-ranges
                • Vl-parse-1+-keyval-expression-pairs
                • Vl-parse-1+-enum-name-declarations-separated-by-commas
                • Vl-parse-0+-variable-dimensions
                • Vl-parse-0+-unpacked-dimensions
                • Vl-parse-0+-packed-dimensions
                • Vl-parse-variable-dimension
                • Vl-parse-unpacked-dimension
                • Vl-parse-unary-expression
                • Vl-parse-sysfuncall-args
                • Vl-parse-structmembers
                • Vl-parse-structmember
                • Vl-parse-shift-expression
                • Vl-parse-scoped-hid
                • Vl-parse-rhs
                • Vl-parse-range
                • Vl-parse-queue-dimension
                • Vl-parse-qmark-expression
                • Vl-parse-pva-tail
                • Vl-parse-primary-main
                • Vl-parse-primary-cast
                • Vl-parse-power-expression
                • Vl-parse-patternkey
                • Vl-parse-param-expression
                • Vl-parse-packeddimension
                • Vl-parse-open-value-range
                • Vl-parse-nonprimary-cast
                • Vl-parse-mult-expression
                • Vl-parse-logor-expression
                • Vl-parse-logand-expression
                • Vl-parse-list-of-ordered-parameter-assignments
                • Vl-parse-list-of-named-parameter-assignments
                • Vl-parse-indexed-id
                • Vl-parse-impl-expression
                • Vl-parse-function-call
                • Vl-parse-expression
                • Vl-parse-enum-base-type
                • Vl-parse-datatype-or-void
                • Vl-parse-core-data-type
                • Vl-parse-compare-expression
                • Vl-parse-clocking-event
                • Vl-parse-call-plainargs-aux
                • Vl-parse-call-plainargs
                • Vl-parse-call-namedargs-aux
                • Vl-parse-call-namedargs
                • Vl-parse-call-namedarg-pair
                • Vl-parse-bitxor-expression
                • Vl-parse-bitor-expression
                • Vl-parse-bitand-expression
                • Vl-parse-assignment-pattern
                • Vl-parse-add-expression-aux
                • Vl-parse-add-expression
                • Vl-parse-1+-expressions-separated-by-commas
                • Vl-parse-0+-ranges
              • Parse-udps
              • Parse-statements
              • Parse-property
              • Vl-genelements
              • Parse-paramdecls
              • Parse-blockitems
              • Parse-utils
              • Parse-insts
              • Parse-functions
              • Parse-assignments
              • Parse-clocking
              • Parse-strengths
              • Vl-parse-genvar-declaration
              • Vl-parse
              • Parse-netdecls
              • Parse-asserts
              • Vl-maybe-parse-lifetime
              • Parse-dpi-import-export
              • Parse-ports
              • Parse-timeunits
              • Seq
              • Parse-packages
              • Parse-eventctrl
            • Vl-load-merge-descriptions
            • Vl-find-basename/extension
            • Vl-load-file
            • Vl-loadresult
            • Scope-of-defines
            • Vl-find-file
            • Vl-flush-out-descriptions
            • Vl-description
            • Vl-read-file
            • Vl-includeskips-report-gather
            • Vl-load-main
            • Extended-characters
            • Vl-load
            • Vl-load-description
            • Vl-descriptions-left-to-load
            • Inject-warnings
            • Vl-preprocess-debug
            • Vl-write-preprocessor-debug-file
            • Vl-read-file-report-gather
            • Vl-load-descriptions
            • Vl-load-files
            • Translate-off
            • Vl-load-read-file-hook
            • Vl-read-file-report
            • Vl-loadstate-pad
            • Vl-load-summary
            • Vl-collect-modules-from-descriptions
            • Vl-loadstate->warnings
            • Vl-iskips-report
            • Vl-descriptionlist
          • Warnings
          • Getting-started
          • Utilities
          • Printer
          • Kit
          • Mlib
          • Transforms
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Vl-parse-primary

    Vl-maybe-parse-base-primary

    Match basic, atomic kinds of primary expressions, such as primary_literal, this, $, and null, returns a vl-expr-p.

    Signature
    (vl-maybe-parse-base-primary &key (tokstream 'tokstream) 
                                 (config 'config)) 
     
      → 
    (mv errmsg? value new-tokstream)
    Arguments
    config — Guard (vl-loadconfig-p config).

    In SystemVerilog-2012, we have:

    primary ::= primary_literal
              | 'this'
              | '$'
              | 'null'
              | ... other, more complex things ...
    
    primary_literal ::= number
                      | time_literal
                      | unbased_unsized_literal
                      | string_literal
    
    number ::= integral_number
             | real_number
    
    integral_number ::= decimal_number
                      | octal_number
                      | binary_number
                      | hex_number

    This is very similar to the primary production in Verilog-2005:

    primary ::= number
              | string
              | ... other, more complex things ...
    
    number ::= decimal_number
             | octal_number
             | binary_number
             | hex_number
             | real_number

    We ignore the "other, more complex things" here, and just focus on the simple primaries. Aside from some minor lexical differences at the tips which are handled by the lexer (see for instance lex-strings and lex-numbers) the main difference here is that SystemVerilog adds time literals, unbased unsized literals, this, $, and null.

    Definitions and Theorems

    Function: vl-maybe-parse-base-primary-fn

    (defun vl-maybe-parse-base-primary-fn (tokstream config)
     (declare (xargs :stobjs (tokstream)))
     (declare (xargs :guard (vl-loadconfig-p config)))
     (declare (ignorable config))
     (let ((__function__ 'vl-maybe-parse-base-primary))
      (declare (ignorable __function__))
      (seq
       tokstream
       (linestart := (vl-linestart-indent))
       (when
        (vl-is-token? :vl-inttoken)
        (int := (vl-match))
        (return
             (make-vl-literal
                  :val (vl-make-guts-from-inttoken int)
                  :atts (vl-extend-atts-with-linestart linestart nil))))
       (when
        (vl-is-token? :vl-realtoken)
        (real := (vl-match))
        (return
         (b* ((value (vl-echarlist->string (vl-realtoken->etext real))))
           (make-vl-literal
                :val (make-vl-real :value value)
                :atts (vl-extend-atts-with-linestart linestart nil)))))
       (when
        (vl-is-token? :vl-stringtoken)
        (str := (vl-match))
        (return
          (b* ((value (vl-stringtoken->expansion str)))
            (make-vl-literal
                 :val (make-vl-string :value value)
                 :atts (vl-extend-atts-with-linestart linestart nil)))))
       (when (eq (vl-loadconfig->edition config)
                 :verilog-2005)
             (return nil))
       (when
        (vl-is-token? :vl-extinttoken)
        (ext := (vl-match))
        (return
          (b* ((value (vl-extinttoken->value ext)))
            (make-vl-literal
                 :val (make-vl-extint :value value)
                 :atts (vl-extend-atts-with-linestart linestart nil)))))
       (when
        (vl-is-token? :vl-timetoken)
        (time := (vl-match))
        (return
          (b* (((vl-timetoken time) time))
            (make-vl-literal
                 :val (make-vl-time :quantity time.quantity
                                    :units time.units)
                 :atts (vl-extend-atts-with-linestart linestart nil)))))
       (when
        (vl-is-token? :vl-kwd-null)
        (:= (vl-match))
        (return
         (hons-copy
            (make-vl-special
                 :key :vl-null
                 :atts (vl-extend-atts-with-linestart linestart nil)))))
       (when
        (vl-is-token? :vl-$)
        (:= (vl-match))
        (return
         (hons-copy
            (make-vl-special
                 :key :vl-$
                 :atts (vl-extend-atts-with-linestart linestart nil)))))
       (return nil))))

    Theorem: vl-maybe-parse-base-primary-never-fails

    (defthm vl-maybe-parse-base-primary-never-fails
      (not (mv-nth 0 (vl-maybe-parse-base-primary))))

    Theorem: vl-maybe-parse-base-primary-result

    (defthm vl-maybe-parse-base-primary-result
      (implies
           (and (not (mv-nth 0 (vl-maybe-parse-base-primary)))
                (and t))
           (vl-maybe-expr-p (mv-nth 1 (vl-maybe-parse-base-primary)))))

    Theorem: vl-maybe-parse-base-primary-count-strong-on-value

    (defthm vl-maybe-parse-base-primary-count-strong-on-value
     (and
       (<= (vl-tokstream-measure
                :tokstream (mv-nth 2 (vl-maybe-parse-base-primary)))
           (vl-tokstream-measure))
       (implies
            (mv-nth 1 (vl-maybe-parse-base-primary))
            (< (vl-tokstream-measure
                    :tokstream (mv-nth 2 (vl-maybe-parse-base-primary)))
               (vl-tokstream-measure))))
     :rule-classes ((:rewrite) (:linear)))

    Theorem: tokens-nonempty-when-vl-maybe-parse-base-primary

    (defthm tokens-nonempty-when-vl-maybe-parse-base-primary
      (b* (((mv ?errmsg val ?new-tokstream)
            (vl-maybe-parse-base-primary)))
        (implies val (consp (vl-tokstream->tokens)))))