VHDL Unit 2 Part 1
VHDL Unit 2 Part 1
HDLs are indeed similar to programming languages but not exactly the same. We
utilize a programming language to build or create software, whereas we use a
hardware description language to describe or express the behavioral characteristics
of digital logic circuits.
Hardware description languages allow you to describe a circuit using words and
symbols, and then development software can convert that textual description into
configuration data that is loaded into the FPGA in order to implement the desired
functionality.
VHDL is a hardware description language that is used to describe the behavior and
structure of digital systems. The acronym VHDL stands for VHSIC Hardware
Description Language, and VHSIC in turn stands for Very High Speed Integrated
Circuit. However, VHDL is a general-purpose hardware description language which
can be used to describe and simulate the operation of a wide variety of digital
systems. Keep in mind it’s H D L…
Advantages of VHDL
– It’s like the assembly language of HDLs.
– Simple
VHDL a1 b1
VHDL 2
a2 b2
6
CODE Synthsize 3
a3
FPLD b3
7
4 8
Software a4
GND
0
b4
Widely used for FPGAs and military A better grasp on hardware modeling
VHDL Terminologies
1) Entity: All designs are expressed in terms of entities. An entity is
the most basic building block in a design.
2) Architecture: All entities that can be simulated have an architecture
description. The architecture describes the behavior
of the entity. A single entity can have multiple
architectures. One architecture might be behavioral while
another might be a structural description of the design.
3) Configuration: A configuration statement is used to bind a
component instance to an entity-architecture pair. A
configuration can be considered like a parts list
for a design. It describes which behavior to use for each entity,
much like a parts list describes which part to use for each part in
the design.
4) Package: A package is a collection (library) of
commonly used data types and subprograms
used in a design. Think of a package as a tool- box that
contains tools used to build designs.
5) Driver. This is a source on a signal. If a signal is driven by two
sources, then when both sources are active, the signal will have
two drivers.
6) Bus. The term “bus” usually brings to mind a group of signals
or a particular method of communication used in the design of
hardware. In VHDL, a bus is a special kind of signal that may
have its drivers turned off.
7) Attribute: An attribute is data that are
attached to VHDL objects or predefined data
about VHDL objects (type of objects like type
of variables in C). Examples are the current drive
capability of a buffer or the maximum operating temperature
of the device.
8) Generic: A generic is VHDL’s term for a parameter
that passes information to an entity. For
instance, if an entity is a gate level model with a
rise and a fall delay, values for the rise and
fall delays could be passed into the entity
with generics.
The following is an example of an entity for an AND gate that
has three generics associated with it:
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
ENTITY test IS
COMPONENT AND2
GENERIC(rise, fall : TIME; load : INTEGER);
PORT ( a, b : IN std_logic;
c : OUT std_logic);
END COMPONENT;
BEGIN
U1: AND2
GENERIC MAP(10 ns, 12 ns, 3 )
PORT MAP (ina, inb, out1 );
U2: AND2
GENERIC MAP(9 ns, 11 ns, 5 )
Structural Description
The circuit of Figure can also be described using structural VHDL code. To do so
requires that a two-input AND-gate component and a two-input
OR-gate component be declared and defined. Components may be
declared and defined either in a library or within the
architecture part of the VHDL code.
Lexical Elements
Lexical elements are basic syntactical units in a VHDL program and include
1) Comments:
Comments start with two dashes, e.g.,
-- This is a comment in VHDL
2) Identifiers:
An identifier can only contain alphabetic letters, decimal digits
and underscore; the first character must be a letter and the last character
cannot be an underscore. Also, two successive underscores are not allowed.
Valid examples:
A10, next_state, NextState, mem_addr_enable
Invalid examples:
sig#3, _X10, 7segment, X10_, hi_ _there
3) Reserved words
4) Numbers:
Integer: 0, 1234, 98E7
Real: 0.0, 1.23456 or 9.87E6
Base 2: 2#101101#
5) Characters
‘A’, ‘Z’, ‘1’
6) Strings
“Hello”, “1100111”
Note that 0 and ‘0’ are different
7) VHDL is case INsensitive, i.e., the following identifiers are the same
nextstate, NextState, NEXTSTATE, nEXTsTATE.
8) Use CAPITAL_LETTERs for constant names and the suffix_n to indicate active
low signals
Propagation Delay
When we initially describe a circuit, we may not be concerned about propagation
delays. If we write
C <= A and B;
E <= C or D;
this implies that the propagation delays are 0 ns. In this case, the
simulator will assume an infinitesimal delay referred to as Δ (delta).
Assume that initially A = 1 and B = C = D = E = 0. If B is changed to 1 at time = 1
ns, then C will change at time 1 + Δ and E will change at time 1 + 2 Δ.
Unlike a sequential program, the order of the above
concurrent statements is unimportant. If we write
E <= C or D;
C <= A and B;
the simulation results would be exactly the same as before. In general, a signal
assignment statement has the form
value of ‘sel’)
i1 AFTER 10 ns WHEN 1,
i2 AFTER 10 ns WHEN 2,
i3 AFTER 10 ns WHEN 3,
‘X’ AFTER 10 ns WHEN OTHERS;
Repeated Execution
Even if a VHDL program has no explicit loops, concurrent statements may execute
repeatedly as if they were in a loop. Figure shows an inverter with the output
connected back to the input. If the output is ‘0’, then this ‘0’ feeds back to the input
and the inverter output changes to ‘1’ after the inverter delay, assumed to be 10 ns.
Then, the ‘1’ feeds back to the input, and the output changes to ‘0’ after the inverter
delay. The signal CLK will continue to oscillate between ‘0’ and ‘1’, as shown in
the waveform. The corresponding concurrent VHDL statement will produce the
same result. If CLK is initialized to ‘0’, the statement executes and CLK changes to
‘1’ after 10 ns. Because CLK has changed, the statement executes again, and CLK
will change back to ‘0’ after another 10 ns. This process will continue indefinitely.
Syntax Rules
In general, VHDL is not case sensitive, that is, capital and
lower case letters are treated the same by the compiler and
the simulator. Thus, the statements
Clk <= NOT clk After 10 NS;
and CLK <= not CLK after 10 ns;
would be treated exactly the same.
Signal names and other VHDL identifiers may contain letters, numbers, and the
underscore character (_). An identifier must start with a letter, and it cannot end with
an underscore. Thus, C123 and ab_23 are legal identifiers, but 1ABC and ABC_ are
not. Every VHDL statement must be terminated with a
semicolon. Spaces, tabs, and carriage returns are treated in the same way. This
means that a VHDL statement can be continued over several lines, or several
statements can be placed on one line. In a line of VHDL code, anything
following a double dash (--) is treated as a comment. Words such
as and, or, and after are reserved words (or keywords) which have a special
meaning to the VHDL compiler.
Figure shows three gates that have the signal A as a common input and the corresponding
VHDL code. The three concurrent statements execute simultaneously
whenever A changes, just as the three gates start processing the
signal change at the same time. This is Instantiation. If all 3 gates
have same propagation delays, output D,E and F after at the same
time. However, if the gates have different delays, the gate outputs
can change at different times. If the gates have delays of 2 ns, 1 ns,
and 3 ns, respectively, and A changes at time 5 ns, then the gate
outputs D, E, and F can change at times 7 ns, 6 ns, and 8 ns,
respectively. The VHDL statements work in the same way. Even
though the statements execute simultaneously, the signals D, E,
and F are updated at times 7 ns, 6 ns, and 8 ns.
Figure shows a 2-to-1 multiplexer (MUX) with two data inputs and one
control input. The MUX output is F = A’.I0 + A·I1. The corresponding
when condition1
condition2
[else expressionN];
else
I1 when
A&B
=“01”
else
I2 when
A&B
=“10”
else I3;
else I1 when A =
Select Statement
A third way to model the MUX is to use a selected signal
assignment state- ment, as shown in Figure . A&B cannot be used
in this type of statement, so
...