Beruflich Dokumente
Kultur Dokumente
VHDL
By
Prof. Anand N. Gharu
(Assistant Professor)
PVGCOE Computer Dept.
10/14/2017 2
Introduction
What is VHDL?
VHDL is a Hardware Description Language used for
modeling digital systems made of interconnection of
components.
It is used for describing hardware from the abstract to
concrete level.
Entity
Architecture
Architecture Architecture
A E
1. Reserved Keywords
names
Port ); or Note the absence
in: Inputof semicolon ;
at the end
of theOutput
out: last signal and the
END
Signal names
my_ckt; presence at the end of the closing
bracket inout: Bidirectional
Fall 08, Oct 29 ELEC2200-002 Lecture 7 (updated) 17
Entity
Entity Declaration for AND gate:
ENTITY and2 IS
PORT(A, B: IN BIT;
Q: OUT BIT);
END and2;
ENTITY or2 IS
PORT(A, B: IN BIT;
Q: OUT BIT);
END or2;
ENTITY not2 IS
PORT(A: IN BIT;
Q: OUT BIT);
END not2;
ENTITY xor2 IS
PORT(A, B: IN BIT;
Y: OUT BIT);
END xor2;
ENTITY ckt_fig IS
PORT(A, B: IN BIT;
Y: OUT BIT);
END ckt_fig;
ENTITY rsff IS
END rsff;
entity name
ARCHITECTUER XOR_STRUCTURE OF xor2 IS
COMPONENT and2
PORT(X, Y: IN BIT, Z:OUT BIT);
For each type of
END COMPONENT;
component, component
COMPONENT or2 declaration is required
PORT(P, Q: IN BIT, R:OUT BIT);
END COMPONENT;
COMPONENT not2
10/14/2017 Mrs. Sunita M Dol, CSE Dept. 30
Local signals or buried nodes
declaration which are neither
inputs nor outputs of the entity
of architecture
entity name
ARCHITECTUER RSFF_STRUCTURE OF rsff IS
component
declaration
COMPONENT nand2
PORT(A, B: IN BIT, Y:OUT BIT);
END COMPONENT; Component
instantiation statements
BEGIN
N1: nand2 PORT MAP(SET,
10/14/2017 QB,M Dol,
Mrs. Sunita Q);CSE Dept. 32
Architecture
Data Flow Modeling
In this modeling, the flow of data through the entity
is expressed using concurrent signal assignment
statements.
ENTITY and2 IS
PORT(A, B: IN BIT;
Q: OUT BIT);
END and2;
ENTITY or2 IS
PORT(A, B: IN BIT;
Q: OUT BIT);
END or2;
ENTITY not2 IS
PORT(A: IN BIT;
Q: OUT BIT);
END not2;
ENTITY xor2 IS
PORT(A, B: IN BIT;
Q: OUT BIT);
END xor2;
ENTITY rsff IS
PORT(SET, RESET: IN BIT;
Q, QB: INOUT BIT);
END rsff;
ENTITY mux2 IS A
PORT(A, B, S: IN STD_LOGIC; 2:1 MUX Y
Y: OUT STD_LOGIC); B
END mux2;
S
10/14/2017 Mrs. Sunita M Dol, CSE Dept. 42
ARCHITECTURE df_mux2 OF mux2 IS
Architecture
Data Flow Modeling
Selected Signal Assignment allows a signal to be
assigned one of several values based on selection
criterion.
ENTITY mux2 IS A
PORT(A, B, S: IN STD_LOGIC; 2:1 MUX Y
B
Y: OUT STD_LOGIC);
END mux2;
S
10/14/2017 Mrs. Sunita M Dol, CSE Dept. 44
Architecture
Behavioural Modeling
The behaviour of the entity is expressed using
statement which are executed sequentially.
10/14/2017
Any assignment made to the signal
Mrs. Sunita M Dol, CSE Dept.
inside the process
45
are not visible outside the process until all of the
Architecture
Behavioural Modeling
The process statement consist of three parts
Sensitivity list
Declarative part and
Statement part.
Sensitivity list:
A process statement is always active and executes at all times
if not suspended.
Following the PROCESS keyword, the sensitivity list in
parentheses is specifies.
It includes all input signals that are used inside the PROCESS.
10/14/2017 Mrs. Sunita M Dol, CSE Dept. 46
Architecture
Behavioural Modeling
Sensitivity list:
When the program flow reaches the last sequential statement,
the process becomes suspended until another event occurs on
the signal that it is sensitive to.
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY AND_EXAMPLE IS
PORT(A,B: IN STD_LOGIC;
BEGIN
YA <= A AND B;
PROCESS(A,B)
BEGIN
10/14/2017 Mrs. Sunita M Dol, CSE Dept. 54
YC <= 0;
Chapter 6: Introduction to
VHDL
Introduction
Entity
Architecture
Package
Data Objects
CASE Statement
Examples of VHDL Codes
10/14/2017 Mrs. Sunita M Dol, CSE Dept. 61
Data Objects
Declaration of Data Objects
Signal Type
STD_LOGIC: This type of data object was added to VHDL
standard in IEEE standard 1164. For using this type, the
following two statements are to be included
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
Examples
CASE expression IS
WHEN constant_value => statement;
WHEN constant_value => statement;
WHEN OTHERS => statement;
END CASE;
0 0 0 0 0
1 0 0 1 1
2 0 1 0 1
3 0 1 1 0
4 1 0 0 1
5 1 0 1 0
6 1 1 0 0
7 1 1 1 1
10/14/2017 Mrs. Sunita M Dol, CSE Dept. 72
Row Inputs
no
ENTITY table1 IS A B C
END table1; 1 0 0 1 1
2 0 1 0 1
3 0 1 1 0
4 1 0 0 1
ARCHITECTUR truth_table of table1 IS 5 1 0 1 0
6 1 1 0 0
SIGNAL comb_cir : BIT_VECTOR (2 DOWN TO 0);
7 1 1 1 1
BEGIN
comb_cir <= A&B&C;
& is used to connect
Y <= 0 WHEN 000,
the bit variables to
1 WHEN 001, form a bit vector
1 WHEN 010,
0 WHEN 011,
1 WHEN 100,
0 WHEN 101,
10/14/2017 Mrs. Sunita M Dol, CSE Dept. 73
0 WHEN 110,
Examples of VHDL Code
Arithmetic Circuits in VHDL:
Consider the half adder circuit
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY H_A IS
PORT (A, B: IN STD_LOGIC; S, C: OUT STD_LOGIC);
END H_A;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY H_A IS
PORT (A, B: IN STD_LOGIC; S, C: OUT STD_LOGIC);
END H_A;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY H_A IS
PORT (A, B: IN STD_LOGIC; S, C: OUT STD_LOGIC);
END H_A;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY H_S IS
PORT (A, B: IN STD_LOGIC; DIFF, BORROW: OUT STD_LOGIC);
END H_S;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY H_S IS
PORT (A, B: IN STD_LOGIC; DIFF, BORROW: OUT STD_LOGIC);
END H_S;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY H_S IS
PORT (A, B: IN STD_LOGIC; DIFF, BORROW: OUT STD_LOGIC);
END H_S;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY DECODER24 IS
PORT( A, B, EN:IN STD_LOGIC;
Z:OUT STD_LOGIC_VECTOR(0 TO 3));
END DECODER24;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY DECODER24 IS
PORT( A, B, EN:IN STD_LOGIC;
Z:OUT STD_LOGIC_VECTOR(0 to 3));
END DECODER24;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY DECODER24 IS
PORT( A, B, EN:IN STD_LOGIC;
Z:OUT STD_LOGIC_VECTOR(0 TO 3));
END DECODER24;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY PRIORITY_ENCODER IS
PORT( I : IN STD_LOGIC_VECTOR(9 DOWN TO 0);
Y : OUT STD_LOGIC_VECTOR(3 DOWN TO 0) );
END PRIORITY_ENCODER;
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY PRIORITY_ENCODER IS
PORT( I : IN STD_LOGIC_VECTOR(9 DOWN TO 0);
Y : OUT STD_LOGIC_VECTOR(3 DOWN TO 0) );
END PRIORITY_ENCODER;
ENTITY COMPARATOR IS
PORT( A, B : IN STD_LOGIC_VECTOR(1 DOWN TO 0);
AGTB, AEQB, ALTBY : OUT STD_LOGIC);
END COMPARATOR;
D Q
Data IN
Output
Clock
_
Q
ENTITY DFF IS
PORT(DATA_IN:IN STD_LOGIC;
CLOCK:IN STD_LOGIC;
DATA_OUT:OUT STD_LOGIC);
END DFF;
D Q
Data IN
Output
Clock
_
Q
ENTITY DFF IS
PORT(DATA_IN:IN STD_LOGIC;
CLOCK:IN STD_LOGIC;
DATA_OUT:OUT STD_LOGIC);
END DFF;
D Q
Data IN
Output
Clock
_
Q
ENTITY DFF IS
PORT(DATA_IN:IN STD_LOGIC;
CLOCK:IN STD_LOGIC;
DATA_OUT:OUT STD_LOGIC);
END DFF;
10/14/2017 108
ENTITY SHIFT4 IS
PORT(DIN:IN STD_LOGIC;
CLOCK, CLEAR:IN STD_LOGIC;
Q:OUT STD_LOGIC(3 DOWN TO 0));
END SHIFT4;
10/14/2017 110