VHDL Programming

(C. Jardin) #1

Appendix C Reading VHDL BNF


After the basic concepts of VHDL are understood, the designer might


want to try to write VHDL in a more elegant manner. To fully understand


how to apply all of the syntactic constructs available in VHDL, it is helpful


to know how to read the VHDL Bachus-Naur format (BNF) of the lan-


guage. This format is in Appendix A of the IEEE Std 1076-1987 VHDL


Language Reference Manual(LRM), pages A1 to A17. This format


specifies which constructs are necessary versus optional, or repeatable


versus singular, and how constructs can be associated.


BNF is basically a hierarchical description method, where complex

constructs are made of successive specifications of lower-level constructs.


Our purpose for examining BNF is not to understand every nuance of the


BNF but to put the basics to use to help build complex VHDL constructs.


To this end, let us examine some BNF and discuss what it means.


Following is the BNF for the IFstatement:

if_statement ::=
IF condition THEN
sequence_of_statements
{ELSIF condition THEN
sequence_of_statements}
[ELSE
sequence_of_statements]
END IF;

The first line of the BNF description specifies the name of the construct

being described. This line is read as follows:“The IFstatement consists


of,”or “The IFstatement is constructed from.”The rest of the description


represents the rules for constructing an IFstatement.


The second line of the description specifies that the IFstatement starts

with the keyword IF, is followed by a condition construct, and ends the


clause with the keyword THEN. The next line contains the construct


SEQUENCE_OF_STATEMENTS(which is discussed later in this appendix).


All of the constructs discussed so far are required for the IFstatement


because the constructs are not enclosed in any kind of punctuation.


Statements enclosed in brackets [ ], as in lines 6 and 7, are optional

constructs. An optional construct can be specified or left out depending on


the functionality required. The ELSEclause of the IFstatement is an


example of an optional construct. A legal IFstatement may or may not


have an ELSEclause.

Free download pdf