Tải bản đầy đủ (.pdf) (4 trang)

Reading VHDL BNF

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (86.59 KB, 4 trang )

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 AϪ1 to AϪ17. 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
IF
statement:
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
IF
statement consists
of,” or “The


IF
statement is constructed from.” The rest of the description
represents the rules for constructing an
IF
statement.
The second line of the description specifies that the
IF
statement 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
IF
statement
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
ELSE
clause of the
IF
statement is an
example of an optional construct. A legal

IF
statement may or may not
have an
ELSE
clause.
Statements enclosed in curly braces
{ }
, as in lines 4 and 5, are
optional and repeatable constructs. An optional and repeatable construct
can either be left out or have one or more of the construct exist. The
ELSIF
clause is an example of an optional and repeatable construct. The
IF
statement can be constructed without an
ELSIF
clause, or have one or
more
ELSIF
clauses, depending on the desired behavior.
The last line of the
IF_STATEMENT
description contains the
END IF
clause. This is a required clause because it is not optional
[ ]
and is not
optional and repeatable
{ }
.
The

IF
statement contains two other constructs that need more
description: the
SEQUENCE_OF_STATEMENTS
and the
CONDITION
. The
SEQUENCE_OF_STATEMENTS
construct is described by the BNF shown here:
sequence_of_statements ::=
{sequential_statement}
The
SEQUENCE_OF_STATEMENTS
construct is described by one or more
sequential statements, where a sequential statement is described in the
following:
sequential_statement ::=
wait_statement
| assertion_statement
| signal_assignment_statement
| variable_assignment_statement
| procedure_call_statement
| if_statement
| case_statement
| loop_statement
| next_statement
| exit_statement
| return_statement
| null_statement
The

|
character means
OR
, such that a sequential statement can be a
WAIT
statement, or an
ASSERT
statement, or a
SIGNAL ASSIGNMENT
state-
ment, and so on. From this description, we can see that the statement part
of the
IF
statement can contain one or more sequential statements, such
as
WAIT
statements,
ASSERT
statements, and so on.
The
CONDITION
construct is specified with the BNF description shown
here:
condition ::= boolean_expression
Notice that the keyword
boolean
is italic. The italic indicates the type
of the expression required for the
CONDITION
. If a designer looks for a

Appendix C: Reading VHDL BNF
446
boolean expression construct to describe the syntax required, none will be
found. The reason is that all expressions share the same syntax description.
For our purposes, the boolean type of the expression is ignored, and the
construct description can be found under the following description:
expression ::=
relation {and relation}
|relation {or relation}
|relation {xor relation}
| relation [nand relation]
|relation [nor relation]
To summarize, curly braces
{ }
are optional and repeatable constructs,
square brackets
[ ]
are optional constructs, and italic pieces of a con-
struct can be ignored for purposes of finding descriptions.
447
Appendix C: Reading VHDL BNF
This page intentionally left blank.

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×