Unit-1 PPT-Concepts in VHDL New
Unit-1 PPT-Concepts in VHDL New
Unit-1 PPT-Concepts in VHDL New
PROGRAMMING IN HDL(SECA1605)
MENTOR
Dr.T.VINO
Mr.Muthiah
Department of ECE
Sathyabama Institute of Science and Technology
SYLLABUS
Course Outcome
After the completion of course student will be able to
HDL
It is a specialized computer language
Used to describe structure and behavior of electronic circuits
HDL include the notion of time
HDL support concurrency
1. Verilog HDL
Difference between Verilog and C
2. VHDL
Requirements
• Design flows operate at
multiple levels of abstraction
Functional Design Behavioral Simulation
• Need a uniform description to
Register Transfer RTL Simulation
translate between levels
Level Design Validation
• Increasing costs of design and
Logic Simulation fabrication necessitate greater
Logic Design Verification
Fault Simulation
reliance on automation via CAD
tools
Timing Simulation
Circuit Design
Circuit Analysis – $5M - $100M to design
new chips
Design Rule Checking
– Increasing time to market
Physical Design
pressures
Description for Manufacture
HDL – Hardware Description Language
1. VHDL
2. Verilog HDL
VHDL
V H SIC Very High Speed Integrated Circuit
Hardware
Description
Language
VHDL
based on 5 languages 4 Different Styles of Description
•Net list Language 1. Structural Modelling
•Concurrent Language 2. Data flow Modelling
•Sequential Language 3. Behavioral Modelling
•Timing Specification 4. Mixed Modelling
•Waveform Generation
VHDL
History of VHDL
1981 - DoD US for developing VHSIC
1983 - DoD - IBM, Texas Instruments, Intermetrics for standard of VHDL
1985 - Version 7.2 of VHDL
1986 - Applied for IEEE Standard
1987 - Standardized by IEEE - IEEE 1076-1987
1993 - Enhanced version of the language is defined -IEEE 1076-1993
Additional standardized packages provide definitions of data types and
expressions of timing data
– IEEE 1164 (data types)
– IEEE 1076.3 (numeric)
– IEEE 1076.4 (timing)
VHDL
VHDL Capabilities
•Exchange medium between chip vendors and CAD tool users.
•Support Hierarchy
•Support Flexible design methodology
•Language not a technology specific
•Supports both synchronous and asynchronous timing models.
•Various delay constraints can be described.
•Allows defining new data types.
•IEEE and ANSI standard, therefore very portable.
•Supports a wide range of abstraction levels, design modelling styles.
•Language Publically available, Human readable, Machine readable
•Test benches are available in the same Language.
VHDL
Hardware Abstraction
VHDL
Primary Design Constructs
Five primary design constructs, also known as “Design Units” used to describe logic
Entity Declaration
Architecture Body
Configuration Declaration
Package declaration
– Convenient way to define and group functions, procedures, types, components etc.
Package body
VHDL
ENTITY DECLARATION
External view of an entity is called Entity declaration, Defines
the interface of the hardware module to the outside
environment in which it is used.
Entity declaration syntax
entity entity_name is
port(port_list);
end entity_name;
Half Adder
entity half_adder is
port (a, b: in std_logic; sum, carry: out std_logic);
end half_adder;
VHDL
Full Adder
entity full_adder is
port ( a,b,cin : in std_logic; sum,cout : out std_logic);
end full_adder;
2*4 Decoder
entity decoder is
port ( a,b: in std_logic; y: out std_logic_vector(0 to 3));
end decoder;
VHDL
Multiplexer
entity multiplexer is
port ( d: in std_logic_vector(0 to 3);a,b:in std_logic; y: out std_logic);
end multiplexer;
Code convertor
entity g2b is
port ( g: in std_logic_vector(0 to 3); b: inout std_logic_vector(0 to 3));
end g2b;
VHDL
Architecture Body
Architecture body specifies internal view of an entity, internal view can be represented in 4
different styles of description, they are
1. Structural model
3. Behavioral model
4. Mixed Model
3. Behavioral model
4. Mixed Model
Structural model.
1.Component Declaration
2.Component Instantiation
The parameters which declared in component declaration to describe the structure of component
VHDL - Structural Model
Half Adder
architecture HA_STR of half_adder is
component xor_gate
end component;
component and_gate
end HA_STR;
VHDL - Structural Model
Half Sutractor
architecture HS_STR of half_subtractor is
component xor_gate
port(x,y : in std_logic; z : out std_logic);
end component;
component and_gate
port(p,q : in std_logic; r : out std_logic);
end component;
component not_gate
port(m : in std_logic; n : out std_logic);
end component;
entity half_subtractor is
signal s1:std_logic;
port (a, b: in std_logic; diff,bor: out std_logic);
begin
end half_subtractor;
L1 : xor_gate port map (a,b,diff);
L2 : not_gate port map (a,s1);
L3 : and_gate port map (s1,b,bor);
end HS_STR;
VHDL - Structural Model
Full Adder
architecture FA_STR of full_adder is
component xor_gate
port(x,y : in std_logic; z : out std_logic);
end component;
component and_gate
port(p,q : in std_logic; r : out std_logic);
end component;
component or_gate
port(m,n : in std_logic; o : out std_logic);
end component;
signal s1,s2,s3 : std_logic;
entity full_adder is
begin
port (a, b, cin: in std_logic; sum,carry: out std_logic);
L1 : xor_gate port map (a,b,s1);
L2 : xor_gate port map (s1,cin,sum); end full_adder;
L3 : and_gate port map (a,b,s2);
L4 : and_gate port map (s1,cin,s3);
L5 : or_gate port map (s3,s2,carry);
end FA_STR;
VHDL - Structural Model
Decoder
architecture DEC_STR of decoder is
component not_gate
port(m : in std_logic; n : out std_logic);
end component;
component and_gate
port(p,q : in std_logic; r : out std_logic);
end component;
signal s1,s2 : std_logic;
begin
L1 : not_gate port map (a,s1);
entity decoder is
L2 : not_gate port map (b,s2);
port ( a,b: in std_logic; y: out
L3 : and_gate port map (s1,s2,y(0));
std_logic_vector(0 to 3));
L4 : and_gate port map (s1,b,y(1));
end decoder;
L5 : and_gate port map (a,s2,y(2));
L6 : and_gate port map (a,b,y(3));
end DEC_STR;
VHDL - Structural Model
Multiplexer
architecture MUX_STR of multiplexer is
component not_gate
port(m : in std_logic; n : out std_logic);
end component;
component and_gate
port(p,q,r : in std_logic; s : out std_logic);
end component;
component or_gate
port(e,f,g,h: in std_logic; i out std_logic);
end component;
signal s1,s2,s3,s4,s5,s6: std_logic;
begin entity multiplexer is
L1 : not_gate port map (a,s1); port ( d: in std_logic_vector(0 to 3);
L2 : not_gate port map (b,s2); a,b:in std_logic; y: out std_logic);
L3 : and_gate port map (s1,s2,d(0),s3); end multiplexer;
L4 : and_gate port map (s1,b,d(1),s4);
L5 : and_gate port map (a,s2,d(2),s5);
L6 : and_gate port map (a,b,d(3),s6);
L7 : or_gate port map (s3,s4,s5,s6,y);
end MUX_STR;
VHDL
Dataflow Model
Architecture body of an entity described as Set of concurrent signal assignment
entity half_subtractor is
Architecture body of Half Subtractor without using signal
port (a, b: in std_logic; diff, bor: out std_logic);
architecture HS_DF of half_subtractor is
end half_subtarctor;
begin
diff <= a xor b;
bor <= (not a) and b;
end HS_DF;
VHDL - Dataflow Model
Full Adder
Architecture body of Full Adder using signal
architecture FA_DF of full_adder is
signal s1,s2,s3 : std_logic;
begin
s1 <= a xor b;
sum <= s1 xor cin;
s2<= a and b;
s3<= s1 and cin;
carry <= s3 or s2;
end FA_DF;
entity full_adder is
Architecture body of Full Adder without using signal
port (a, b, cin: in std_logic; sum,carry: out std_logic);
architecture FA_DF of full_adder is
end full_adder;
begin
sum <= (a xor b) xor cin;
carry <= ((a xor b) and cin) or (a and b);
end FA_DF;
VHDL - Dataflow Model
Decoder
Architecture body of Decoder using signal
architecture DEC_DF of decoder is
signal s1,s2 : std_logic;
begin
s1 <= not a;
s2 <= not b;
d(0) <= s1 and s2;
d(1) <= s1 and b;
d(2) <= a and s2;
d(3) <= a and b;
end DEC_DF;
This set of sequential statements, that are specified inside a process statement, do not
explicitly specify the structure of the entity but merely specifies its functionality.
Architecture body of Decoder using Dataflow model Architecture body of Decoder using Behavioral model
architecture DEC_DF of decoder is architecture DEC_BEH of decoder is
signal s1,s2: std_logic; begin
begin process (a,b)
s1 <= not a; variable s1,s2 : std_logic;
s2 <= not b; begin
d(0) <= s1 and s2; s1 := not a;
d(1) <= s1 and b; s2 := not b;
d(2) <= a and s2; d(0) <= s1 and s2;
d(3) <= a and b; d(1) <= s1 and b;
end DEC_DF; d(2) <= a and s2;
d(3) <= a and b;
end process;
end DEC_BEH;
VHDL - Behavioral Model
Full Adder
entity full_adder is
port (a, b, cin: in std_logic; sum,carry: out std_logic);
end full_adder;
sum <= s1 xor cin; port (a, b, cin: in std_logic; sum,carry: out std_logic);
process(a,b,cin)
variable s2,s3 : std_logic;
begin
carry <= s3 or s2;
end process;
end FA_MIX;
VHDL - Mixed Model - Multiplexer
architecture MUX_MIX of multiplexer is
component not_gate
port(m : in std_logic; n : out std_logic);
end component;
signal s1,s2,s3,s4,s5,s6 : std_logic;
begin
L1 : not_gate port map (a,s1);
L2 : not_gate port map (b,s2);
s3 <= s1 and s2 and d(0);
s4 <= s1 and b and d(1); entity multiplexer is
s5 <= a and s2 and d(2); port ( d: in std_logic_vector(0 to 3); a,b: in std_logic;
s6 <= a and b and d(3); y: out std_logic);
process(a,b,d) end multiplexer;
variable s3,s4,s5,s6 : std_logic;
begin
y <= s3 or s4 or s5 or s6;
end process;
end MUX_MIX;
VHDL – Basic Language Elements
File Type
Objects of file type represent files in the host environment.
Syntax :
type file_type_name is file of type_name;
VHDL – Basic Language Elements
Operators
logical operators
• and, or, nand, nor, xor, xnor, not
relational operators
• <, >, =, <=, >=, /= -- /= means not equal to
shift operators
• sll, srl, sla, sra, rol, ror
adding operators
• +, -, & -- & is concatenation
multiplying operators
• *, /, mod, rem
miscellaneous operators
• abs, ** -- ** is exponentiation
VHDL – Structural Model
• An entity is modeled as a set of components connected by signals, that
is,
as a net-list.
• The behavior of the entity is not explicitly apparent from its model.
•The component instantiation statement is the primary mechanism used for
describing such a model of an entity.
• COMPONENT & PORT MAP statements are used to implement structural
modeling.
• The component instantiation statements are concurrent statements, and
their order of appearance in the architecture body is therefore not important.
• A component can be instantiated any number of times.
• Each instantiation must have a unique component label
VHDL – Structural Model – Component Declaration
A component in a structural description must first be declared using a component
declaration. A component declaration declares the name and the interface of a component
(similar to the
entity).
The interface specifies the mode and the type of ports.
The component-name may or may not refer to the name of an entity already existing in a
library. If it does not, it must be explicitly bound to an entity.
The binding information can be specified using a configuration.
The List-Of-Interface-Ports specifies the name, mode, and type for each port of the
component in a manner similar to that specified in an entity declaration.
The names of the ports may also be different from the names of the ports in the entity to
VHDL-Structural Model-Component Instantiation
A component instantiation statement defines a association of formal and actual parameters. It
associates the signals in the entity with the ports of that component.
The Component-Label can be any legal identifier and can be considered as the name of the
instance.
The Component-Name must be the name of a component declared earlier using a component
declaration.
The association-list, associates signals in the entity, called actuals, with the ports of a
component, called formals.
There are two ways to perform the association of formals with actuals:
1. Positional association
2. Named association
VHDL-Structural Model- Component Instantiation
B
VHDL – Model Quiz
3. Which of the following is correct syntax for entity declaration?
a)
ENTITY entity_name IS
PORT( signal_names : signal_modes signal_type;
signal_names : signal_modes signal_type);
END entity_name;
b)
ENTITY entity_name
PORT( signal_names : signal_modes;
signal_names : signal_modes);
END ENTITY;
c)
ENTITY entity_name IS
PORT port_name
( signal_names : signal_modes signal_type;
signal_names : signal_modes signal_type);
END entity_name;
d)
ENTITY entity_name
PORT port_name A
(signal_names : signal_modes;
signal_names : signal_modes);
END ENTITY;
VHDL – Model Quiz
4. Refer to the VHDL code given below, how many input-output pins are there in MUX entity?
ENTITY mux IS
Port ( a,b : IN STD_LOGIC; d : IN STD_LOGIC_VECTOR(0 to 3); Y : OUT STD_LOGIC);
END mux;
a)5
b)7 B
c)6
d)4
5. The entity name ‘xyz’ and ‘XYZ’ will be treated the same.
a)True
b) False
A
6. Which of the following mode of the signal is bidirectional?
a) IN
b) OUT
c) INOUT
d) BUFFER C
7. Which of the following is the correct syntax for architecture declaration and definition?
9. Which of the following is the correct architecture for a simple Nand gate?
a) ARCHITECTURE my_arch OF nand_gate IS
BEGIN
x <= a NAND b;
END my_arch;
b) BEGIN
ARCHITECTURE my_arch OF nand_gate IS
x <= a NAND b;
END behavioral;
c) BEGIN
ARCHITECTURE behavioral OF nand_gate IS
x <= a NAND b;
END my_arch;