Selected portions of the Verilog BNF (from http://www.verilog.com/VerilogBNF.html) verishort vitalog Definition of Items in Formal Syntax Specifications: +-----------------------+------------------------------------------------------------+ | Item | Meaning | +-----------------------+------------------------------------------------------------+ | White space | may be used to separate lexical tokens | +-----------------------+------------------------------------------------------------+ | Angle brackets | surround each description item and are not literal sym- | | | bols. That is, they do not appear in the source descrip- | | | tion. Any text outside angle brackets is literal. | +-----------------------+------------------------------------------------------------+ | in lower case | is a syntax construct item | +-----------------------+------------------------------------------------------------+ | in upper case | is a lexical token item. Its definition is a terminal node | | | in the description hierarchy -- that is, its definition | | | does not contain any syntax construct items | +-----------------------+------------------------------------------------------------+ | ? | is an optional item | +-----------------------+------------------------------------------------------------+ | * | is zero, one, or more items | +-----------------------+------------------------------------------------------------+ | + | is one or more items | +-----------------------+------------------------------------------------------------+ | <,>* | is a comma-separated list of items with at least one | | | item in the list | +-----------------------+------------------------------------------------------------+ | ::= | gives a syntax definition to an item | +-----------------------+------------------------------------------------------------+ | ||= | introduces an alternative syntax definition | +-----------------------+------------------------------------------------------------+ 1. Source Text ::= * ::= // Modules are similar to functions in other programming languages; // they contain inputs, outputs, bidirectional ports, wires, // and registers--relationships between these elements are expressed // by concurrent and sequential statements. ::= module ? ; * endmodule ::= ::= ( <,>* ) // An implicit internal connection is created connecting the port to a // net or register of the same name as the port. ::= ? ::= ::= ::= // Parameters are constants, usually used to specify delays and // width of variables. ::= ||= ||= ||= // Only wire type nets appear in this restricted grammar. ||= // Registers are data storage elements (nets and registers are the // two main data groups). ||= // Continuous assignment statements occur outside of procedures // (initial, always, function and task are the 4 types of procedures). ||= // An always block will run, simultaneous with other always blocks, // whenever one or more of its conditions is fulfilled. ||= ||= 2. Declarations // ************************ Parameter (constants) related ::= parameter ; ::=<,* ::= = // ************************ end Parameter (constants) related // ************************ Input/Output ports declaration related ::= input ? ; ::= output ? ; ::= inout ? ; // ************************ end Input/Output ports declaration related // ************************ Net declaration related ::= ? ? ; is one of the following keywords: wire ::= // ************************ end Net declaration related // ************************ Gate declaration related // Drive strength option eliminated. ::= ? <,>* ; is one of the following keywords: and nand or nor xor xnor ::= ? ( <,>* ) ::= ? ::= ||= // ************************ end Gate declaration related ::= reg ? ; // Removed ? from after assign keyword. ::= assign ? ; ::= <,>* ::= ::= <,>* ::= ::= ::= [ : ] ::= <,>* 3. Primitive Instances ::= # ||= # 4. Module Instantiations 5. Behavioral Statements ::= always ::= ||= ; // Blocking assignments contain the = token and block the // continuation of the procedure until they are completed. ::= ; // Non-blocking assignments contain the <= token. The RHS of the // assignment is executed immidiately, but the LHS is evaluated only // after all other operations in the current time step are executed. ||= ; ||= if ( ) ||= if ( ) else ||= // Block of statements to exceute sequentially, enclosed by begin/end. ||= // System tasks serve to generate input and output in a simulation. ||= // This is the proceduaral type of assignment, used for assigning // values to register variables (continuous assingments assign to // wire and tri data types). ||= assign ; ::= = ::= = // Use of #, @ (posedge clk) are delay and event control. ||= = ; ::= <= ||= = ; ::= ||= ::= begin * end ::= ; ||= ( <,>* ) ; ::= $ (Note: the $ may not be followed by a space.) An assigned to an existing system task or function 6. Specify Section 7. Expressions ::= ||= [ ] ||= [ : ] ::= ::= ||= : : ::= ||= ||= ||= : ||= is one of the following tokens: + - ! ~ & ~& | ^| ^ ~^ is one of the following tokens: + - * / % == != === !== && || < <= > >= & | ^ ^~ >> << is ? (a literal question mark). is text enclosed in "" and contained on one line. ::= ||= ||= [ ] ||= [ : ] ||= ( ) ::= ||= ? ||= . ||= <.>? E ||= <.>? e (Note: embedded spaces are illegal in Verilog numbers, but embedded underscore characters can be used for spacing in any type of number.) ::= A number containing a set of any of the following characters, optionally preceded by + or - 0123456789_ ::= A number containing a set of any of the following characters: 0123456789_ Numbers can be specified in decimal, hexadecimal, octal or binary, and may optionally start with a + or -. The token controls what number digits are legal. must be one of d, h, o, or b, for the bases decimal, hexadecimal, octal, and binary respectively. A number can contain any set of the following characters that is consistent with : 0123456789abcdefABCDEFxXzZ? is one of the following tokens: 'b 'B 'o 'O 'd 'D 'h 'H 8. General ::= ||= ::= // ::= /* */ ::= The comment text is zero or more ASCII characters ::= <.>* (Note: the period may not be preceded or followed by a space.) An identifier is any sequence of letters, digits, dollar signs ($), and underscore (_) symbol, except that the first must be a letter or the underscore; the first character may not be a digit or $. Upper and lower case letters are considered to be different. Identifiers may be up to 1024 characters long. Some Verilog-based tools do not recognize identifier characters beyond the 1024th as a significant part of the identifier. Escaped identifiers start with the backslash character (\) and may include any printable ASCII character. An escaped identifier ends with white space. The leading backslash character is not considered to be part of the identifier. ::= # ||= # ||= # ( ) ::= @ ||= @ ( ) ::= ||= posedge ||= negedge ||= or Scalar event expression is an expression that resolves to a one bit value.