• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
        • Syntax
        • Loader
          • Preprocessor
          • Vl-loadconfig
          • Vl-loadstate
          • Lexer
          • Parser
            • Parse-expressions
            • Parse-udps
            • Parse-statements
            • Parse-property
            • Vl-genelements
            • Parse-paramdecls
            • Parse-blockitems
              • Vl-ranges->dimensions
              • Vl-2005-parse-block-item-declaration-noatts
              • Vl-2012-parse-block-item-declaration-noatts
              • Vl-parse-main-data-declaration
              • Vl-parse-type-declaration
              • Vl-parse-fwd-typedef
              • Vl-parse-0+-block-item-declarations
              • Vl-parse-list-of-event-identifiers
              • Vl-parse-list-of-variable-identifiers
              • Vl-parse-realtime-declaration
              • Vl-parse-block-item-declaration-noatts
              • Vl-parse-time-declaration
              • Vl-parse-reg-declaration
              • Vl-parse-real-declaration
              • Vl-parse-integer-declaration
              • Vl-build-vardecls
              • Vl-parse-event-declaration
              • Vl-parse-block-item-declaration
              • Vl-parse-1+-let-ports
              • Vl-parse-variable-type
              • Vl-parse-let-declaration
              • Vl-parse-0+-let-ports
            • 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
  • Parser

Parse-blockitems

Functions for parsing Verilog and SystemVerilog block items.

The Verilog-2005 grammar for regs and variables is, after filtering out some duplication and indirection:

integer_declaration  ::= 'integer'  list_of_variable_identifiers ';'
real_declaration     ::= 'real'     list_of_variable_identifiers ';'
time_declaration     ::= 'time'     list_of_variable_identifiers ';'
realtime_declaration ::= 'realtime' list_of_variable_identifiers ';'
reg_declaration      ::= 'reg' [ 'signed' ] [ range ] list_of_variable_identifiers ';'

list_of_variable_identifiers ::= variable_type { ',' variable_type }

variable_type ::= identifier { range }
                | identifier '=' expression

For SystemVerilog-2012 this is quite a bit more complex. Quick rundown:

  • additional 'const', 'var', and lifetime specifiers
  • variables can be of many new built-in or user-defined types
  • initializers can have "new", etc., instead of just being expressions
  • ranges for each variable_type can now be lists of variable_dimensions
  • package import statements and typedefs are also considered data declarations, for whatever reason.

The new grammar looks like this:

data_declaration ::=
    ['const'] ['var'] [lifetime] data_type_or_implicit list_of_variable_decl_assignments ';'
  | ...

data_type_or_implicit ::= data_type
                        | implicit_data_type

implicit_data_type ::= [ signing ] { packed_dimension }

list_of_variable_decl_assignments ::= variable_decl_assignment { ',' variable_decl_assignment }

variable_decl_assignment ::=
     identifier { variable_dimension } [ '=' expression ]
   | identifier unsized_dimension { variable_dimension } [ '=' dynamic_array_new ]
   | identifier [ '=' class_new ]

dynamic_array_new ::= 'new' '[' expression ']' [ '(' expression ')' ]

class_new ::= [ class_scope ] 'new' [ '(' list_of_arguments ')' ]
            | 'new' expression


variable_dimension ::= unsized_dimension
                     | unpacked_dimension
                     | associative_dimension
                     | queue_dimension

unsized_dimension     ::= '[' ']'
packed_dimension      ::= '[' constant_range ']' | unsized_dimension
associative_dimension ::= '[' data_type ']' | '[' '*' ']'
queue_dimension       ::= '[' '$' [ ':' expression ] ']'

list_of_arguments ::= [expression] { ',' [expression] } { ',' '.' identifier '(' [expression] ')' }
                    | '.' identifier '(' [expression] ')' { ',' '.' identifier '(' [expression] ')' }

Subtopics

Vl-ranges->dimensions
(vl-ranges->dimensions x) maps vl-range->dimension across a list.
Vl-2005-parse-block-item-declaration-noatts
Match a whole block_item_declaration, except for any attributes, for Verilog-2005.
Vl-2012-parse-block-item-declaration-noatts
Match a whole block_item_declaration, except for any attributes, for SystemVerilog-2012.
Vl-parse-main-data-declaration
Parse the main variable declaration part of a data_declaration for SystemVerilog-2012.
Vl-parse-type-declaration
Match any kind of type_declaration for SystemVerilog-2012.
Vl-parse-fwd-typedef
Match a forward type_declaration for SystemVeriog-2012.
Vl-parse-0+-block-item-declarations
Match as many block_item_declarations as we can find.
Vl-parse-list-of-event-identifiers
Match list_of_event_identifiers for Verilog-2005.
Vl-parse-list-of-variable-identifiers
Match list_of_variable_identifiers for Verilog-2005.
Vl-parse-realtime-declaration
Match realtime_declaration for Verilog-2005.
Vl-parse-block-item-declaration-noatts
Match a whole block_item_declaration, except for any attributes.
Vl-parse-time-declaration
Match time_declaration for Verilog-2005.
Vl-parse-reg-declaration
Match reg_declaration for Verilog-2005.
Vl-parse-real-declaration
Match real_declaration for Verilog-2005.
Vl-parse-integer-declaration
Match integer_declaration for Verilog-2005.
Vl-build-vardecls
Vl-parse-event-declaration
Match event_declaration for Verilog-2005.
Vl-parse-block-item-declaration
Match a whole block_item_declaration, including initial attributes.
Vl-parse-1+-let-ports
Vl-parse-variable-type
Match variable_type for Verilog-2005.
Vl-parse-let-declaration
Vl-parse-0+-let-ports