VHDL (VHSIC Hardware Description Language) Is A Language
VHDL (VHSIC Hardware Description Language) Is A Language
INTRODUCTION
VHDL (VHSIC Hardware Description Language) is a language
for describing hardware. Its requirement emerged during the VHSIC
development program of the US Department of Defense. The
department organized a work shop in 1981 to lay down the
specifications of a language which could describe hardware at
various levels of abstractions, could generate test signals and record
responses, and could act as a medium of information exchange
between the chip foundries and the CAD tool operators. However,
due to military restrictions, it remained classified till 1985.
Structural Descriptions
We will discuss the first of the three approaches to design with
VHDL, the structural description.
Building Blocks
To make designs more understandable and maintainable, a
design is typically decomposed into several blocks. These blocks are
then connected together to form a complete design. Using the
schematic capture approach to design, this might be done with a
block diagram editor. Every portion of a VHDL design is considered a
block. A VHDL design may be completely described in a single block,
or it may be decomposed in several blocks. Each block in VHDL is
analogous to an off-the-shelf part and is called an entity. The entity
describes the interface to that block and a separate part associated
with the entity describes how that block operates. The interface
description is like a pin description in a data book, specifying the
inputs and outputs to the block. The description of the operation of
the part is like a schematic for the block.
entity latch is
port (s,r: in bit;
q,nq: out bit);
end latch;
Connecting Blocks
Once we have defined the basic building blocks of our design
using entities and their associated architectures, we can combine
them together to form other designs. This section describes how to
combine these blocks together in a structural description.
entity latch is
port (s,r: in bit;
q,nq: out bit);
end latch;
The schematic for the latch might be
The lines between the first and the keyword begin are a
component declaration. It describes the interface of the entity
nor_gate that we would like to use as a component in (or part of) this
design. Between the begin and end keywords, the first two lines and
second two lines define two component instances.
A First Example
In the data flow approach, circuits are described by indicating
how the inputs and outputs of built-in primitive components (ex. an
and gate) are connected together. In other words we describe how
signals (data) flow through the circuit. Let's look at the first example.
entity latch is
port (s,r : in bit;
q,nq : out bit);
end latch;
Note: the <= symbol was chosen carefully to avoid confusion with the
variable assignment operator (usually = or :=) of typical programming
languages. The signal assignment operator in VHDL specifies a
relationship between signals, not a transfer of data as in
programming languages.
Seminar on VHDL 7
How it Works ?
In the last section we saw an example of a data flow description and
what it describes. In this section we will learn how a simulator uses
that description to model the design.
The VHDL standard not only describes how designs are specified,
but also how they should be interpreted. This is the purpose of having
standards, so that we can all agree on the meaning of a design. It is
important to understand how a VHDL simulator interprets a design
because that dictates what the "correct" interpretation is according to
the standard (Hopefully, simulators are not all 100% correct).
Seminar on VHDL 8
Let us examine how the event time simulation proceeds for the
previous example of an SR latch. The following is a schematic
version of the SR latch.
start : r='0',s='0',q='1',nq='0'
round 1: r='1',s='0',q='1',nq='0', The value '0' is scheduled on q.
round 2: r='1',s='0',q='0',nq='0', The value '1' is scheduled on nq.
round 3: r='1',s='0',q='0',nq='1', No new events are scheduled.
round 4: r='0',s='0',q='0',nq='1', No new events are scheduled.
Seminar on VHDL 10
Now during simulation, say signal r changes and will cause the signal
q to change, rather than schedule the event on q to occur during the
next round, it is scheduled to occur 1ns form the current time. Thus
the simulator must maintain a current time value. When no more
events exist to be processed at the current time value, time is
updated to the time of the next earliest event and all events
scheduled for that time will be processed. A timing diagram for this
modified SR latch produced by a simulator might be:
Notice the change did not occur in q until 1ns after the change
in r. Likewise the change in nq did not occur until 1ns after the
change in q. Thus, the "after 1ns" models an internal delay of the nor
gate.
Seminar on VHDL 11
If the transport delay model were used, the result of the same
simulation shown in the last diagram would result in the following
timing diagram.
Other Types
In the previous sections all of the signals in the examples have
been of the type bit. VHDL provides several other types, some of
which are described here. Often times we use several bit signals
together to represent a binary number in a design. VHDL provides a
mechanism for defining new types which represent a collection of
several data items of the same type. These kinds of types are called
arrays. There is a predefined array type called bit_vector which
represents a collection of bits. The following example demonstrates
how the bit_vector type can be used to define a 1-to-4-line
demultiplexer.
entity demux is
port (e: in bit_vector (3 downto 0); -- enables for each output
s: in bit_vector (1 downto 0); -- select signals
d: out bit_vector (3 downto 0)); -- four output signals
end demux;
architecture rtl of demux is
signal t : bit_vector(3 downto 0); -- an internal signal
begin
t(3)<=s(1) and s(0);
t(2)<=s(1) and not s(0);
t(1)<=not s(1) and s(0);
t(0)<=not s(1) and not s(0);
d<=e and t;
end rtl;
Seminar on VHDL 13
Other Operators
The previous sectioned mentioned a few different types that are
available in VHDL. There are also several built-in operators that can
be used with those types. This section mentions some of these.
The logical operators NOT, AND, OR, NAND, NOR, and XOR
can be used with any bit type or bit_vector. When used as operators
on bits they have their usual meaning. When used with bit_vectors,
the bit_vectors must have the same number of elements, and the
operation is performed bitwise. For example, "00101001" xor
"11100101" results in "11001100".
note: just as '0' and '1' represent constant bit values, constant
bit_vectors can be written in VHDL as a list of bit values in double
quotes. For example, if d is a bit_vector(1 to 4) the following
statement gives d the permanent values d(1)='1', d(2)='1', d(3)='0',
and d(4)='0'.
d<="1100";
d<=X"C";
Seminar on VHDL 15
The & appends the a to the end of the "0000" to form a result that
contains 8 bits.
Seminar on VHDL 16
Behavioral Descriptions
There are three different paradigms for describing digital components
with VHDL, structural, data flow, and behavioral descriptions. This
chapter dicusses the behavioral approach.
Using Variables
There are two major kinds of objects used to hold data. The first
kind, used mostly in structural and data flow descriptions, is the
signal. The second, which can only be used in processes, is called a
variable. A variable behaves like you would expect in a software
programming language, which is much different than the behavior of
a signal.
a:=b;
Sequential Statements
There are several statements that may only be used in the body
of a process. These statements are called sequential statements
because they are executed sequentially. That is, one after the other
as they appear in the design from the top of the process body to the
bottom. In this section we will examine some of these statements.
The first example illustrates the if statement and a common use of the
VHDL attribute.
This if statement has two main parts, the condition and the
statement body. A condition is any Boolean expression (an
expression that evaluates to TRUE and FALSE, such as expressions
using relational operators). The condition in the example uses the
attribute last value, which is used to determine the last value that a
signal had. Attributes can be used to obtain a lot of auxiliary
information about signals.
Seminar on VHDL 20
if (inc='1') then
cnt:=cnt+1;
else
cnt:=cnt-1;
end if;
p:='0';
p:=p xor x(7);
p:=p xor x(6);
p:=p xor x(5);
p:=p xor x(4);
p:=p xor x(3);
p:=p xor x(2);
p:=p xor x(1);
p:=p xor x(0);
process (y)
variable x,z : bit;
begin
x:=y;
z:=not x;
end process;
The value of the variable z would be the opposite of the value of y
because the value of the variable x is changed immediately.
Seminar on VHDL 23
Program Output
In most programming languages there is a mechanism for
printing text on the monitor and getting input from the user through
the keyboard. Even though your simulator will let you monitor the
value of signals and variables in your design, it is also nice to be able
to output certain information during simulation. It is not provided as a
language feature in VHDL, but rather as a standard library that comes
with every VHDL language system. In VHDL, common code can be
put in a separate file to be used by many designs. This common code
is called a library. In order to use the library that provides input and
output capabilities you must add the statement
use textio.all;
Text is input and output using textio via a variable of the type
line. Since variables are used for textio, input and output is done in
processes. The procedure for outputting information is to first place it
in text form into the variable of type line and then to request that the
line be output. This is shown in the following example.
use textio.all;
begin
process (x)
variable s : line;
variable cnt : integer:=0;
Seminar on VHDL 24
begin
if (x='1' and x'last_value='0') then
cnt:=cnt+1;
f (cnt>MAX_COUNT) then
write(s,"Counter overflow - ");
write(s,cnt);
writeline(output,s);
end if;
end if;
end process;
end behavior;
Counter overflow - 16
CONCLUSION
i.e.
Sequential language +
Concurrent languages+
Net-listing language+
Timing specifications+