Unit 5 VHDL
Unit 5 VHDL
1. PAL Devices
PAL (programmable array logic) chips were introduced by Monolithic Memories in the mid 1970s.
Its basic architecture is illustrated in Figure 18.2, where the little ovals represent programmable
connections. As can be seen, the circuit is composed of a programmable array of AND gates
followed by a fixed array of OR gates. This implementation is based on the fact that any
combinational function can be represented by a sum-of-products (SOP)
A PAL-based example is depicted in Figure 18.3, which computes the combinational functions
The dark ovals indicate a connection. The outputs of nonprogrammed AND gates are set to zero.
2. PLA Devices
PLA (programmable logic array) chips were introduced in the mid 1970s by Signetics. The basic
architecture of a PLA is illustrated in Figure 18.4. Comparing it to that in Figure 18.2, we observe
that the only fundamental difference between them is that while a PAL has programmable AND
connections and fi xed OR connections, both are programmable in a PLA. The obvious advantage
is greater flexibility because more combinational functions (more product terms) can be
implemented with the same amount of hardware. On the other hand, the extra propagation delay
introduced by the additional programmable interconnections lowered their speed.
The technology then employed in the fabrication of PLAs was the same as that of PALs
CPLDs
A Complex Programmable Logic Device (CPLD) is a digital integrated circuit that can be
programmed to implement a variety of digital logic functions. CPLDs are used in a wide range of
applications, including system control, signal processing, and interface management.
1. Programmable Logic Unit
The role is the same as the basic I/O port of FPGA, but the application scope of CPLD is more
limited, and the performance and complexity of I/O has a certain gap compared with FPGA, and
the I/O standard supported is less, and the frequency is also lower.
FPGAs
Field programmable gate array (FPGA)
FPGA consists of 6 parts, which are programmable input/output unit, basic programmable logic
unit, embedded block RAM, rich wiring resources, underlying embedded functional unit and
embedded dedicated hard core.
1. Programmable Input/Output Unit (IOB)
The programmable I/O unit is the interface part between the chip and the external circuit, which
fulfills the requirements of driving and matching the input/output signals under different electrical
characteristics. the I/Os inside the FPGA are classified by groups, and each group can support
different I/O standards independently. Through flexible software configuration, it can adapt to
different electrical standards and I/O physical characteristics, adjust matching impedance
characteristics, change pull-up and pull-down resistors, and adjust the magnitude of drive current.
The external input signal can be input to the internal of FPGA through the memory cell of IOB
module, or directly input to the internal of FPGA. When the external input signal is input to the
internal of FPGA through the memory cell of IOB module, its hold time (Hold Time) requirement
can be reduced and usually defaulted to 0.
Code Structure
1. Library declarations
The std library contains definitions for the standard data types (BIT, BOOLEAN, INTEGER,
BIT, BIT_VECTOR, etc.), plus information for text and fi le handling,
As illustrated below.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
2. Entity
Entity is a list with specifi cations of all I/O ports of the circuit under design. It also allows generic
parameters to be declared, as well as several other declarations, subprogram bodies, and concurrent
statements. Its syntax is shown below.
ENTITY entity_name IS
GENERIC (constant_name: constant_type := constant_value; constant_name:
constant_type := constant_value; ...);
PORT (port_name: signal_mode signal_type; port_name: signal_mode signal_type;
...); [declarative part]
[BEGIN]
[statement part]
END entity_name;
3. Architecture
This part contains the code proper (the intended circuit’s structural or behavioral description). It
can be concurrent or sequential. The former is adequate for the design of combinational circuits,
while the latter can be used for sequential as well as combinational circuits. Its syntax is shown
below.
ARCHITECTURE architecture_name OF entity_name IS
[declarative part]
BEGIN
(code)
END architecture_name;
• Declarative part: Can contain the same items as the entity’s declarative part, plus
COMPONENT and CONFIGURATION declarations.
• Code: Can be concurrent, sequential, or mixed. To be sequential, the statements must be
placed
inside a PROCESS.
Data Types
The predefined data types are from the libraries/packages listed above. Those that are synthesizable
are listed in Figure 19.4, which shows their names, library/package of origin, and synthesizable
values.
1. Operators
VHDL provides a series of operators that are divided into the six categories below.
a. Assignment operators
"<=", ":=", "=>" "<=" Used to assign values to signals.
":=" Used to assign values to variables, constants, or initial values.
"=>" Used with the keyword OTHERS to assign values to arrays.
Examples:
sig1 <= '1';
--assignment to a single-bit signal
sig2 <= "00001111";
--assignment to a multibit signal
sig3 <= (OTHERS =>'0');
--result is sig3<= "00...0"
VARIABLE var1:
--assignment of initial value
INTEGER := 0;
--assignment to a multibit variable
var2 := "0101";
b. Concatenation operators
"&" and "," These operators are employed to group values.
Example: The assignments to x, y, and z below are equivalent.
k: CONSTANT BIT_VECTOR(1 TO 4) := "1100";
x <= ('Z', k(2 TO 3), "11111"); -- result: x <= "Z1011111"
y <= 'Z' & k(2 TO 3) & "11111"; -- result: y <= "Z1011111"
z <= (7 =>'Z', 5=>'0', OTHERS=> '1'); -- result: z < ="Z1011111"
c. Logical operators
NOT, AND, NAND, OR, NOR, XOR, XNOR
The only logical operator with precedence over the others is NOT.
Examples:
x <= a NAND b;
-- result: x = (a.b)'
y <= NOT(a AND
-- result: same as above
b);
-- result: x = a'. b
z <= NOT a AND b;
d. Arithmetic operators
+, –, *, /, **, ABS, REM, MOD
These are the classical operators: addition, subtraction, multiplication, division, exponentiation,
absolute-value, remainder, and modulo. They are also summarized in Figure 19.5 along with the
allowed data types.
Examples:
x <= (a + b)**N;
y <= ABS(a) + ABS(b);
z <= a/(a + b);
e. Shift operators
SLL, SRL, SLA, SRA, ROL, ROR
Shift operators are shown in Figure 19.5 along with the allowed data types. Their meanings are
described below.
SLL (shift left logical): Data are shifted to the left with '0's in the empty positions.
SRL (shift right logical): Data are shifted to the right with '0's in the empty positions.
SLA (shift left arithmetic): Data are shifted to the left with the rightmost bit in the empty positions.
SRA (shift right arithmetic): Data are shifted to the right with the leftmost bit in the empty
positions.
ROL (rotate left): Circular shift to the left.
ROR (rotate right): Circular shift to the right.
Examples:
a <= "11001";
x <= a SLL 2; --result: x <= "00100"
y <= a SLA 2; --result: y <= "00111"
z <= a SLL –3; --result: z <= "00011"
f. Comparison operators
=, /=, >, <, >=, <=
Comparison operators are also shown in Figure 19.5 along with the allowed data types.
Example:
IF a >= b THEN x <= '1';
Attributes
The main purposes of VHDL attributes are to allow the construction of generic (fl exible) codes as
well as event-driven codes. They also serve for communicating with the synthesis tool to modify
synthesis directives.
The predefined VHDL attributes can be divided into the following three categories:
(i) range related
(ii) position related, and
(iii) event related.
Example 1:
The Circuit looks like this: implement all the above three models for given circuit.
Then the Karnaugh Map and Function look like this:
Using those 3 Things we can then write down the 3 Models like that:
Behavioral:
library ieee;
use ieee.std_logic_1164.all;
entity c_behavioral is
port(
A, B, C: in std_logic;
Y: out std_logic
);
end c_behavioral;
Dataflow:
library ieee;
use ieee.std_logic_1164.all;
entity c_dataflow is
port(
A, B, C: in std_logic;
Y: out std_logic
);
end c_dataflow;
Structural:
library ieee;
use ieee.std_logic_1164.all;
entity c_structural is
port(
A, B, C: in std_logic;
Y: out std_logic
);
end c_structural;
component not_gate
port(
a: in std_logic;
b: out std_logic
);
end component;
component or2_gate
port(
a, b: in std_logic;
c: out std_logic
);
end component;
component and2_gate
port(
a, b: in std_logic;
c: out std_logic
);
end component;
begin
Examples
1. VHDL Code for AND gate
library IEEE;
use IEEE.std_logic_1164.all;
---------------------------------- Entity Declarations -------------------------
entity andgate is
Port( A : in std_logic;
B : in std_logic;
Y : out std_logic );
end andgate;
architecture Behavioral of andgate is
begin
Y<= A and B ;
end Behavioral;
2. VHDL Code for OR gate
library IEEE;
use IEEE.std_logic_1164.all;
-- Entity declaration
entity orGate is
port(A : in std_logic; -- OR gate input
B : in std_logic; -- OR gate input
Y : out std_logic); -- OR gate output
end orGate;
library IEEE;
use IEEE.std_logic_1164.all;
-- Entity declaration
entity notGate is
port(A : in std_logic; -- NOT gate input
Y : out std_logic); -- NOT gate output
end notGate;
library IEEE;
use IEEE.std_logic_1164.all;
---------------------------------- Entity Declarations -------------------------
entity mux8_1 is
port ( D: in STD_LOGIC_VECTOR (7 downto 0);
EN: in STD_LOGIC;
SEL: in STD_LOGIC_VECTOR (2 downto 0);
Y: out STD_LOGIC );
end mux8_1;
architecture mux8_1_arch of mux8_1 is
begin
process(EN,SEL,D)
begin
if(EN='1')then
y<='0';
else
case SEL is
when "000" => y <= D(0);
when "001" => y <= D(1);
when "010" => y <= D(2);
when "011" => y <= D(3);
when "100" => y <= D(4);
when "101" => y <= D(5);
when "110" => y <= D(6);
when others=> y <= D(7);
end case;
end if;
end process;
end mux8_1_arch;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
---------------------------------- Entity Declarations -------------------------
entity bitcomp is
port ( A: in STD_LOGIC;
B: in STD_LOGIC;
sel: in STD_LOGIC_VECTOR(1 DOWNTO 0);
Y: out BOOLEAN );
end bitcomp;