Académique Documents
Professionnel Documents
Culture Documents
ELECTRONIC SYSTEMS:
A VHDL OVERVIEW”
By
Luis E. Navarrete, MSEE
Orlando J. Hernandez, Ph.D.
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en Procesamiento
Digital de Señales y Diseño Digital con VHDL
UNIVERSIDAD DEL NORTE
May 21 - 23, 2003
Presentation Overview
Modern Electronic Design Overview
Digital Logic Technologies
Programmable Logic Devices - FPGAs
Introduction to VHDL – Part I
Introduction to VHDL – Part II
AND, OR, HALF ADDER, FULL ADDER
Introduction to VHDL – Part III
ALU Design
Control and Data Path Organization
Finite State Machines, Digital Filter
Introduction to MAX+PLUS II
Implementations and Examples on the ALTERA UP1
Board
Q&A Sessions
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 2
Modern Electronic Design
Analog Design
Digital Design
Digital Logic
PAL Gate
Array
CMOS Microproc.
4xxx CPLD Configurable & RAMs
Standard
FPGA Cells
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 4
Digital Logic Technologies
Programmable Logic Devices PLD:
PLA, Schematic:
PAL, Schematic:
CPLDs, Schematics:
FPGAs, Schematics:
Full Custom
VLSI Design
Speed, ASICs
Density,
Complexity,
CPLDs
Market Volume
FPGAs
PLDs
Design Entry
Schematic Capture
SET
S Q
R CLR
Q
Design Portability
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 33
What is VHDL?
Device
Industry Standard
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 39
Getting Started with VHDL
Comparator Specifications:
Two 8-bit inputs
1-bit Output
Output is 1 if the inputs match or 0 if they
differ.
Comparator
A[8]
B[8] EQ
0 1 2 3 4 5 6 7
A 1 0 1 1 0 0 1 1
B 1 0 1 1 0 0 1 1
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 43
Comparator VHDL Source Code
-- Eight-bit Comparator
entity compare is
port (A, B : in std_logic_vector (0 to 7);
EQ : out std_logic);
end compare;
entity compare is
port (A, B : in std_logic_vector (0 to 7);
EQ : out std_logic);
end compare;
Configuration
(or default configuration)
Package
Package Body
Entity
Architecture (s)
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 56
Package Design unit
Syntax of package
package my_package is
function my_global_function ( ……. )
return bit;
end my_package;
Performance Specification
Behavior Test Benches
Sequential Description
State Machines
Register Transfers
Dataflow Selected Assignments
Arithmetic Operation
Boolean Equations
Hierarchy
Structure Physical Information
sum
a
carry
b
Half_adder
Inputs a, b : 1 bit each.
Output Sum, Carry : 1 bit each.
a
sum
b
carry
-- Half Adder
library IEEE; --refer IEEE library.
use IEEE.std_logic_1164.all;
entity half_adder is
port (a, b : in std_logic; --declaring I/O ports
sum, carry : out std_logic);
end half_adder;
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 72
half_adder code (cont…)
architecture behavior of
half_adder is
begin
sum <= (a xor b);
carry <= (a and b);
end behavior;
a
sum
b
carry
MAX+PLUS II is a Development
software created by ALTERA
This software supports schematic
capture and text-based hardware
description language (HDL) design
entry, including Verilog® HDL, VHDL,
and the Altera® Hardware Description
Language (AHDLTM)
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 74
Max+Plus II
Development Software
Design
Compilation
Graphical Entry
Compiler
HDL Model
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 79
Max+Plus II
2nd Part of The Process !!!!
Simulation
Compilation
Timing Diagram
Compiler
Timing Analysis
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 80
Max+Plus II
3rd Part of The Process !!!!
Verification
Compilation
Programming
Compiler
UP1 Board
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 81
Max+Plus II
Development Software
Begin
Statement
Statement
Statement
End
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 92
Example of Concurrent VHDL
Full Adder
a
Sum
b Full-Adder
C_out
C_in
a s1
b sum
s2
s3 c_out
c_in
-- Full_Adder
library IEEE;
use IEEE.std_logic_1164.all;
entity full_adder is
port (a, b, c_in : in std_logic;
sum, c_out : out std_logic);
end full_adder;
Begin
Statement
Statement
Statement
End
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 107
Process Construct
Sensitivity List
Process declaration part
Statement Part
library IEEE;
use IEEE.std_logic_1164.all;
entity nand2 is
port (a, b : in std_logic;
c : out std_logic);
end nand2;
architecture arch1 of nand2 is
begin
process (a, b)
variable temp: std_logic;
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 111
Process Example
begin
temp = not (a and b);
if (temp = ‘1’) then
c <= temp after 5 ns;
elseif (temp = ‘0’) then
c <= temp after 6 ns;
end if;
end process;
end arch;
library IEEE;
use IEEE.std_logic.all
entity nand2 is
port (a, b : in std_logic;
c : out std_logic);
end nand2;
process (a, b)
for i in 1 to 10 loop
i_squared(i) := i*i;
end loop;
process
begin
wait until clock = ‘1’ and clock’ event;
q <= d ;
end process;
An XOR gate
A Half Adder
A Full Adder
A Multiplexer
ALU
s1 s0
a
b
4 to 1 Z
mux
half C_out
adder
full
adder
c_in
S1 S0 Z C_out
0 0 a or b 0
0 1 a xor b 0
1 0 ha_sum ha_c_out
1 1 fa_sum fa_c_out
s1 s0
a
b
4 to 1 Z
mux
half C_out
adder
full
adder
c_in
library IEEE;
use IEEE.std_logic_1164.all;
entity t_or is
port (a, b : in std_logic;
ored : out std_logic);
end t_or;
architecture concurrent_behavior of t_or is
begin
ored <= (a or b);
end concurrent_behavior;
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 148
Max+Plus II
T_OR, Code Entry
library IEEE;
use IEEE.std_logic_1164.all;
entity t_xor is
port (a,b : in std_logic;
xored : out std_logic);
end t_xor;
architecture concurrent_behavior of t_xor is
begin
xored <= (a xor b);
end concurrent_behavior;
-- Half Adder
library IEEE; --refer IEEE library.
use IEEE.std_logic_1164.all;
entity half_adder is
port (a, b : in std_logic; --declaring I/O ports
sum, c_out : out std_logic);
end half_adder;
architecture behavior of
half_adder is
begin
sum <= (a xor b);
c_out <= (a and b);
end behavior;
a
sum
b
carry
a s1
b sum
s2
s3 c_out
c_in
--Full_Adder
library IEEE;
use IEEE.std_logic_1164.all;
entity full_adder is
port (a, b, c_in : in std_logic;
sum, c_out : out std_logic);
end full_adder;
library IEEE;
use IEEE.std_logic_1164.all;
package alu_pack is
component t_or
port (a, b : in std_logic;
ored : out std_logic);
end component;
component t_xor
port (a ,b : in std_logic;
xored : out std_logic);
end component;
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 167
Declaration of ALU Package
component half_adder
port (a, b : in std_logic;
ha_sum, c_out : out std_logic);
end component;
component full_adder
port (a, b, c_in : in std_logic;
sum, c_out : out std_logic);
end component;
end alu_pack;
library IEEE;
use IEEE.std_logic_1164.all;
library work;
use work.alu_pack.all;
entity alu is
port (a, b, c_in, s0, s1 : in std_logic;
z, c_out : out std_logic);
end alu;
CONTROL
DATA
INPUTS
CONTROL
CONTROL DATA
PROCESSING PROCESSING
BLOCK BLOCK
OBSERVATION
STATUS
INPUTS
OUTPUTS
NEXT STATE STATE OUTPUTS
PROCESSING VECTOR PROCESSING
CLOCK
INPUTS
OUTPUTS
NEXT STATE STATE OUTPUTS
PROCESSING VECTOR PROCESSING
RSTN
CLK
PD1
PD2
PD3 SYNC
G3 Clock Generation
G2
M
G1
G0
L L
V1P Digital Filter
PGA Integrators / Comparator CMP1 (Sinc3)
V21P
L Digital Filter
Integrators / Comparator CMP2 (Sinc3)
PGA
V21N x1, x2, x8, x16
Digital Design
2nd Order Σ−∆ Modulators
Bandgap
~ 1.25V
Analog Design
IN z-1
CY / CFB
z-1
CREF
VCMI
B2 T2 CAZ
AMP1 B1 S2 AMP2
AZB VCMI
B1 S2
B2 T2 STRB
CAZ
AZ
IN- B1 CIN T1 AZB B2 CX S1 CFB
VCMI
VCMI
CFA CY
FL CREF B1
REF+
“1”
B2
“0”
“0” B2
REF-
“1”
FL CREF B1
VCMI
IN
fs fs / OSR
OUT
fs / OSR
Cubic sinc
Bits of noise free accuracy for delta-
sigma ADC's:
BITS = 3 * LOG(OSR) / LOG(2) + 2
Assume OSR=32, then BITS=17, and set
BITS=16
URy
URx
S1
CONTROLLER
S2 x2, PASS S1
S2
S3 1’S COMP., PASS, 2, 3
S3
S4
DATA-
PATH URy
xn
S4 URx
OSS
ACCUMULATOR
ISS
OUT
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 193
VHDL code for Data_Path
--Data_Path
library IEEE;
use IEEE.std_logic_1164.all;
entity Data_Path is
port (CLK, reset, xn, URy, URx, S2 : in std_logic;
S3, S4 : in std_logic_vector(1 downto 0);
S1 : in std_logic_vector(2 downto 0);
OUTPUT : out std_logic_vector(15 downto 0));
end Data_Path;
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 194
VHDL code for Data_Path
architecture behave of Data_Path is when “010” => T1 <= Ry1_n_3;
signal Ry1_n_1, Ry1_n_2, Ry1_n_3 : when “011” => T1 <= Rx1_n_1;
std_logic_vector(15 downto 0); when “100” => T1 <= Rx1_n_2;
signal Rx1_n_1, Rx1_n_2, Rx1_n_3 : when “101” => T1 <= Rx1_n_3;
std_logic_vector(15 downto 0); end case;
signal ACCUMULATOR : std_logic_vector(15 downto 0); case S2 is
begin when ‘0’ =>
OUTPUT <= ACCUMULATOR; my_msb <= T1(15);
process (CLK, reset) begin T2 <= T1 sll 1;
constant my_zero : std_logic_vector(15 downto 0) := T3 <= T2 and “0111111111111111”;
“0000000000000000”; T4 <= T3 or (my_msb & “000000000000000”);
variable T1, T2, T3, T4, T5 : std_logic_vector(15 downto 0); when ‘1’ => T4 <= T1;
variable my_msb : std_logic; end case;
if reset = ‘1’ then case S3 is
Ry1_n_1 <= my_zero; Ry1_n_2 <= my_zero; Ry1_n_3 <= my_zero; when “00” => T5 <= not T4;
Rx1_n_1 <= my_zero; Rx1_n_2 <= my_zero; Rx1_n_3 <= my_zero; when “01” => T5 <= T4;
ACCUMULATOR <= my_zero; when “10” => T5 <= “0000000000000010”;
elseif CLK’EVENT and CLK = ‘1’ then when “11” => T5 <= “0000000000000011”;
if URy = ‘1’ then end case;
Ry1_n_3 <= Ry1_n_2; Ry1_n_2 <= Ry1_n_1; case S4 is
Ry1_n_1 <= ACCUMULATOR; when “00” =>
end if; ACCUMULATOR <= “000000000000000“ & xn;
if URx = ‘1’ then when “01” => ACCUMULATOR <= Ry1_n_1;
Rx1_n_3 <= Rx1_n_2; Rx1_n_2 <= Rx1_n_1; when “10” =>
Rx1_n_1 <= ACCUMULATOR; ACCUMULATOR <= ACCUMULATOR + T5;
end if; end case;
case S1 is end if;
when “000” => T1 <= Ry1_n_1; end process;
when “001” => T1 <= Ry1_n_2; end behave;
--Controller
library IEEE;
use IEEE.std_logic_1164.all;
entity Controller is
generic (TPD : TIME := 1 nS);
port (CLK, reset, ISS : in std_logic;
URy, URx, S2, OSS : out std_logic;
S3, S4 : out std_logic_vector(1 downto 0);
S1 : out std_logic_vector(2 downto 0));
end Controller;
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 196
VHDL code for Controller
architecture Moore of Controller is S2 <= ‘0’ after TPD when State = S03 or
type STATETYPE is (S00, S01, S02, S03, S04, S05, State = S05 or State = S10 or State = S12
S06, S07, S08, S09, S10, S11, S12, S13, S14, S15,
else ‘1’ after TPD;
S16, S17);
signal State : STATETYPE; with State select
signal Counter : std_logic_vector(4 downto 0); S3 <= “00” after TPD when S05 | S06 | S10 |
begin S11 | S14,
URy <= ‘1’ after TPD when State = S09 “01” after TPD when S03 | S04 | S08 | S12 |
else ‘0’ after TPD;
S13 | S16,
URx <= ‘1’ after TPD when State = S17
else ‘0’ after TPD; “10” after TPD when S07,
with State select “11” after TPD when S15;
S1 <= “000” after TPD when S03 | S04 | S16, with State select
“001” after TPD when S05 | S06, S4 <= “00” after TPD when S02,
“010” after TPD when S08,
“011” after TPD when S10 | S11, “01” after TPD when S16,
“100” after TPD when S12 | S13, “10” after TPD when S03 | S04 | S05 | S06 |
“101” after TPD when S14; S07 | S08 | S10 | S11 | S12 | S13 | S14 | S15;
OSS <= ‘1’ after TPD when State = S15
else ‘0’ after TPD;
library IEEE;
use IEEE.std_logic_1164.all;
entity FILTER is
port (reset, CLK, ISS, xn : in std_logic;
OSS : out std_logic;
OUTPUT : out
std_logic_vector(15 downto 0));
end entity FILTER;
begin
c: Controller port map (CLK => CLK, reset => reset,
ISS => ISS, URy => URy, URx => URx, S2 => S2,
OSS => OSS, S3 => S3, S4 => S4, S1 => S1);
dp: Data_Path port map (CLK => CLK, reset => reset,
xn => xn, URy => URy, URx => URx, S2 => S2,
S3 => S3, S4 => S4, S1 => S1, OUTPUT => OUTPUT);
end architecture structural;
lenavarr@eng.usf.edu
hernande@a-wit.com
Tecnologías de la Información: Telecomunicaciones, Aplicaciones en
Procesamiento Digital de Señales y Diseño Digital con VHDL
May 21 - 23, 2003 UNIVERSIDAD DEL NORTE 204