VHDL Material
VHDL Material
VEDANT
VLSI DESIGN EDUCATION AND TRAINING LUCKNOW CENTRE
VLSI DESIGN FLOW
DESIGN
SPECIFICATION
DESIGN ENTRY
SIMULATION
SYNTHESIS
POST SYNTHESIS
SIMULATION
TIMING SIMULATION
IC IMPLEMENTATION
2. MSI
(Medium Scale Integration) 100-1000 Counter, Mux
3. LSI
(Large Scale Integration) 1000-20,000 8-bit Microprcessor,
ROM, RAM
4. VLSI
(Very Large Scale Integration)20,000-1,000,000 16,32-bit
Microprocessor
5. ULSI
(Ultra Large Scale Integration)1,000,000-10,000,000 Special Processor,
Smart Sensor
6. GSI
(Giant Scale Integration) >10,000,000
VHDL can wear many hats. It is being used for documentation, verification, and
synthesis of large digital designs. This is actually one of the key features of VHDL, since the
name VHDL code can theoretically achieve all the 3 goals, thus saving a lot of effort .In
addition to being used for these purposes VHDL can be used to take 3 different hardware
describing approaches structural, data flow and behavioral methods.
Designing with VHDL means that the designer writes code and then verifies the
function in a simulator, for which the code is synthesized in to a net list. Synthesis can be
compared to a compiler, which translates the code in to machines code.
In hardware the VHDL codes are translated into a schematic with gates and flip-flops.
It supports both synchronous and asynchronous timing models.
Two important reasons for using VHDL instead of traditional schematic design are
shorter developed for electronics design and simpler maintenance.
It is easy to move VHDL code between different commercial platforms (tools). The
way in which several thousand gates and flip flops can be programmed as an IC circuit in
just a few minutes on a single PC with out the need for expensive equipment.
The mode of a port defines the directions of the singals on that pirt, and is one of: in, out,
buffer, or inout.
Port Modes:
An in port
can be read but not updated within the module, carrying information into the module.
(An in port cannot appear on the left hand side of a signal assignment.)
An out port
can be updated but not read within the module, carrying information out of the
module. (An out port cannot appear on the right hand side of a signal assigment.)
A buffer port
likewise carries information out of a module, but can be both updated and read within
the module.
An inout port
is bidirectional and can be both read and updated, with multiple update sources
possible.
NOTE: A buffer is strictly an output port, i.e. can only be driven from within the
module, while inout is truly bidirectional with drivers both within and external to the
module.
Example
entity and_gate is
port(a,b: in bit;
c: out bit);
generic (gate_delay: time := 5ns);
end and_gate;
Architecture
An architecture defines one particular implementation of a design unit, at some desired level
of abstraction.
architecture arch_name of entity_name is
... declarations ...
begin
... concurrent statements ...
end
0attributes, subprograms, and other information to be used in the implementation
description. Concurrent statements describe a design unit at one or more levels of modeling
abstraction, including dataflow, structure, and/or behavior.
Behavioral Model: No structure or technology implied. Usually written in sequential,
procedural style.
Dataflow Model: All datapaths shown, plus all control signals.
Structural Model: Interconnection of components.
Example:
package ee530 is
constant maxint: integer := 16#ffff#;
type arith_mode_type is (signed, unsigned);
function minimum(constant a,b: in integer) return
integer;
end ee530;
Example:
package body ee530 is
function minimum (constant a,b: integer) return integer
is
variable c: integer; -- local variable
begin
if a < b then
Package Visibility
To make all items of a package "visible" to a design unit, precede the desired design unit
with a "use" statement:
Example:
use library_name.package_name.all
A "use" statement may precede the declaration of any entity or architecture which is to
utilize items from the package. If the "use" statement precedes the entity declaration, the
package is also visible to the architecture.
User-Developed Packages
Compile user-developed packages in your current working library. To make it visible:
use package_name.all;
Note: 'std' and 'work' (your current working library) are the two default libraries. The VHDL
'library' statement is needed to make the 'ieee' library and/or additional libraries visible.
Example
library lib_name; -- make library visible
use lib_name.pkg_name.all; -- make package visible
Identifiers
Identifiers in VHDL must begin with a letter, and may comprise any combination of letters,
digits, and underscores. Note that VHDL internally converts all characters to UPPER CASE.
Examples
Memory1, Adder_Module, Bus_16_Bit
Numeric Constants
Numeric contants can be defined, and can be of any base (default is decimal). Numbers may
include embedded underscores to improve readability.
Examples
16#9fba# (hexadecimal)
2#1111_1101_1011# (binary)
16#f.1f#E+2 (floating-point, exponent is decimal)
Examples
x"ffe" (12-bit hexadecimal value)
o"777" (9-bit octal value)
b"1111_1101_1101" (12-bit binary value)
Examples
a <= b nand c;
d := g1 * g2 / 3;
Bus_16 <= Bus1_8 & Bus2_8;
VHDL Standard:
bit values: '0', '1'
boolean values: TRUE, FALSE
integer values: -(231) to +(231 - 1) {SUN Limit}
natural values: 0 to integer'high (subtype of integer)
positive values: 1 to integer'high (subtype of integer)
character values: ASCII characters (eg. 'A')
time values include units (eg. 10ns, 20us)
'U' = uninitialized
'X' = unknown
'W' = weak 'X'
'Z' = floating
'H'/'L' = weak '1'/'0'
'-' = don't care
Example
type opcodes is (add, sub, jump, call); -- Type with 4
values
signal instruc: opcodes; -- Signal of this
type
...
Example
type word is array (0 to 15) of bit;
Unconstrained array: Indexes are specified when a signal or variable of that type is
declared.
Examples
type memory is array (integer range <>) of
bit_vector(0 to 7);
-- a type which is an arbitrary-sized array of 8-bit
vectors
variable memory256: memory(0 to 255); -- a 256-byte
memory array
variable stack: memory(15 downto 0); -- a 16-byte
memory array
Subtype: A selected subset of values of a given type. Elements of different subtypes
having the same base type may be combined in expressions (elements of different
types cannot). Subtypes can be used to detect out-of-range values during simulation.
Examples
subtype byte_signed is integer range -128 to 127;
subtype byte_unsigned is integer range 0 to 255;
Constants
A constant associates a value to a symbol of a given data type. The use of constants may
improve the readability of VHDL code and reduce the likelihood of making errors. The
declaration syntax is:
Examples
constant Vcc: signal:= '1'; --logic 1 constant
constant zero4: bit_vector(0 to 3) := ('0','0','0','0');
Variables
A variable is declared within a blocks, process, procedure, or function, and is updated
immediately when an assignment statement is executed. A variable can be of any scalar or
aggregate data type, and is utilized primarily in behavioral descriptions. It can optionally be
assigned initial values (done only once prior to simulation). The declaration syntax is:
Examples
process
variable count: integer := 0;
variable rega: bit_vector(7 downto 0);
begin
...
count := 7; -- assign values to variables
rega := x"01";
...
end;
Signals
A signal is an object with a history of values (related to "event" times, i.e. times at which the
signal value changes).
Signals are declared via signal declaration statements or entity port definitions, and may be
of any data type. The declaration syntax is:
Each signal has one or more "drivers" which determine the value and timing of changes to
the signal. Each driver is a queue of events which indicate when and to what value a signal is
to be changed. Each signal assignment results in the corresponding event queue being
modified to schedule the new event.
signal line x
Event Values
Times
NOTE: If no delay is specified, the signal event is scheduled for one infinitessimally-small
"delta" delay from the current time. The signal change will occur in the next simulation
cycle.
Examples
(Assume current time is T)
clock <= not clock after 10ns; -- change at T +
10ns
databus <= mem1 and mem2 after delay; -- change at T +
delay
x <= '1'; -- change to '1' at
time T + "delta";
Element delay models may be specified as either "inertial" or "transport". Inertial delay is
the default, and should be used in most cases.
Examples
Where there are multiple drivers for one signal, a "resolution function" must be provided to
determine the value to be assigned to the signal from the values supplied by the multiple
drivers. This allows simulation of buses with multiple sources/drivers.
NOTE: The std_logic and std_logic_vector types from the ieee library have predefined
resolution functions:
Example
signal data_line: std_logic;
begin
block1:
data_line <= '1'; -- one driver
...
block2:
data_line <= 'Z'; -- 2nd driver
The resolved value is '1' since '1' overrides a 'Z' (floating) value. If the two values had been
'1' and '0', the resolved value would have been 'X', indicating an unknown result.
For each of the above, waveforms (time-value pairs) can also be specified.
Examples
A <= B after 10ns when condition1 else
C after 12ns when condition2 else
D after 11ns;
-- A is a 16-bit vector
The keyword "others" in the last example indicates that all elements of A not explicitly listed
are to be set to '0'.
Process Statement
An independent sequential process represents the behavior of some portion of a design. The
body of a process is a list of sequential statements.
Syntax:
label: process (sensitivity list)
... local declarations ...
begin
... sequential statements ...
end process label;
Example
DFF: process (clock)
begin
if clock = '1' then
Q <= D after 5ns;
QN <= not D after 5ns;
end if;
end process DFF;
The sequential statements in the process are executed in order, commencing with the
beginning of simulation. After the last statement of a process has been executed, the process
is repeated from the first statement, and continues to repeat until suspended. If the optional
sensitivity list is given, a wait on ... statement is inserted after the last sequential statement,
causing the process to be suspended at that point until there is an event on one of the signals
in the list, at which time processing resumes with the first statement in the process.
Block Statement
A block is a grouping of related concurrent statements that can be used in representing
designs in a hierarchical manner.
Syntax:
label: block (guard expression)
... local declarations ...
Examples
-- D Latch: Transfer D input to Q output when Enable =
'1'
block (Enable = '1')
begin
Q <= guarded D after 5ns;
end block;
In the last example, B is assigned to signal A only when GUARD is true, which implies
Enable = '1'.
Example
ReadMemory (DataIn, DataOut, RW, Clk);
Component instantiation
Instantiates (i.e. create instances of) predefined components within a design architecture.
Each such component is first declared in the declaration section of that architecture, and then
"instantiated" one or more times in the body of the architecture.
In the declaration section: list the "component declaration" and one or more
"configuration specifications".
Example
component adder
port(a,b: in bit_vector(7 downto 0);
s: out bit_vector(7 downto 0);
cin: in bit;
cout: out bit);
end component;
The "configuration specification" identifies specific architecture(s) to be used for each
instance of the component. (There may be multiple architectures for a given
component.)
Examples
for ALL: comp1 use entity work.comp1 (equations);
for ADDER1: adder use entity work.adder (equations);
for ADDER2: adder use entity work.adder (dataflow);
In all three examples, the prefix work. indicates that the current
working library contains the indicated component models. In the first example,
architecture equations of entity comp1 is used for all instances of comp1. In the other
examples, architecture equations is to be used for instance ADDER1 of component
adder, and architecture dataflow is to be used for instance ADDER2 of component
adder.
(1) "Positional association": signals are connected to ports in the order listed in the
component declaration.
Ex. A1: adder port map (v,w,x,y,z)
v,w, and y must be bit_vectors, y and z bits
Example
A1: adder port map(a=>v, b=>w, s=>y, cin->x, cout->z);
Example:
architecture r1 of register is
component jkff
port(J,K,CLK: in bit;
Q,QN: out bit);
end component;
for ALL: jkff use entity work.jkff (equations);
-- Use architecture equations of entity jkff
for all instances
component dff
port(D,CLK: in bit;
Q,QN: out bit);
end component;
for DFF1: dff use entity work.dff (equations);
for DFF2: dff use entity work.dff (circuit);
--Use different architectures of dff for instances
DFF1 and DFF2
begin
JKFF1: jkff port map (j1,k1,clk,q1,qn1);
Generate statement
A generate statement is an iterative or conditional elaboration of a portion of a description.
This provides a compact way to represent what would ordinarily be a group of statements.
Example
Generate a 4-bit full adder from 1-bit full_adder stages:
add_label: -- Note that a label is required here
for i in 4 downto 1 generate
FA: full_adder port map(C(i-1), A(i), B(i), C(i),
Sum(i));
end generate;
The resulting code would look like:
SEQUENTIAL STATEMENTS
Sequential statements are used to define algorithms to express the behavior of a design
entity. These statements appear in process statements and in subprograms (procedures and
functions).
Wait statement
- suspends process/subprogram execution until a signal changes, a condition becomes true,
or a defined time period has elapsed. Combinations of these can also be used.
Syntax:
wait [on signal_name {,signal_name}]
[until condition]
[for time expression]
Example
A <= B after 10ns;
C <= A after 10ns; -- value of C is current A value
Example
A := B and C;
D := A; -- value of D is new A value
Procedure call
Invoke an externally-defined subprogram in the same manner as a concurrent procedure call.
Conditional Statements
Standard if..then and case constructs can be used for selective operations.
if condition then
... sequence of statements...
elsif condition then
... sequence of statements...
else
... sequence of statements...
end if;
case expression is
Loop statements
Sequences of statements can be repeated some number of times under the control of while or
for constructs.
PROCEDURES
A procedure is a subprogram that is passed parameters and may return values via a
parameter list.
FUNCTIONS
A function is a subprogram that is passed parameters and returns a single value. Unlike
procedures, functions are primarily used in expressions.
Example
-- Convert bit_vector to IEEE std_logic_vector format
-- (attributes LENGTH and RANGE are described below)
OBJECT ATTRIBUTES
An object attribute returns information about a signal or data type.
Examples
if (clock'STABLE(0ns)) then -- change in clock?
... -- action if no clock edge
else
... -- action on edge of clock
end if;
if clock'EVENT and clock = '1' then
Q <= D after 5ns; -- set Q to D on rising edge
of clock
end if;
Examples
for i in (data_bus'RANGE) loop
...
for i in (d'LEFT(1) to d'RIGHT(1)) loop
...
use std.textio.all;
Data Types:
text - a file of character strings
line - one string from a text file
Example Declarations
file Prog: text is in "file_name"; --text file "file_name"
variable L: line; -- read lines from file to L
Introduction
FPGA (Field Programmable Gate Array) have emerged as the technology that has
finally given users what they need…”The power to design their own custom integrated
circuit without going to the foundaries”. The high densities of FPGA devices coupled with
their user programmability make them attractive choices for implementing application
specific logic functions. Designers can rapidly convert their design concepts into FPGA chip.
When an FPGA device exceeds the capacity of even the largest device available the
design must be partitioned into multiple FPGA devices. This brings about short product
design cycles as well as low product development cost, enabling quick time to market, vital
point to consider especially when product life cycles are becoming shorter and the market is
becoming more and more competitive.
2. Design implementation
3. Design verification
With the advent of million gate devices the tool industry is grappling with the
challenges posed, some of them are:
1. Place – and – route tools fail due to increase in the complexity of routing logic on
an FPGA device
2. Speed, unpredictability of logic paths laid out randomly on silicon makes it
difficult for the tool to achieve required speeds.
3. Algorithms, bigger FPGA’s need robust, more sophisticated algorithms.
4. Cost factor, as prices of silicon fall, users are not willing to pay large amounts for
tools.
5. Compatibility, portability of designs across an array of tools is the key issue.
Why FPGAs?
1. Ideal for customized design.
engineering workstations.
2. Development of Electronic CAD for IC technologies and design styles, including
5. Faster than Microcontrollers and microprocessors and much faster the DSP
engines.
6. More flexible than dedicated chipsets and allow unlimited product differentiation.
7. More affordable and less risky than ASIC’s due to no NRE, minimum order size or
inventory risk.
8. Programmable at any time, that is, in design, in manufacturing and after
installation.
When a designer wants to design a circuit before it is actually implemented we need to
test the circuit .For this purpose FPGA is used. When the logic for the circuit is simulated the
required hardware is generated on the FPGA and by giving appropriate inputs the articles we
discuss about various types of FPGA and how they are implemented.
FPGA is an array of logic cells. These logic cells communicate with each other and input
output devices via wires within the routing channels. Generally high–density programmable
gate arrays include three major configurable elements. They are:
1. Configurable logic block (CLB’s).
2. Input/output block (IOB’s).
3. Programmable interconnections.