Vhdl1 Introduction To VHDL: (W2 Begins)
Vhdl1 Introduction To VHDL: (W2 Begins)
Vhdl1 Introduction To VHDL: (W2 Begins)
7a 1
VHDL1
INTRODUCTION TO VHDL
(VERY-HIGH-SPEED-INTEGRATED-CIRCUITSHARDWARE DESCRIPTION LANGUAGE)
What is an entity?
Overall structure of a VHDL file
Entity
Entity
Library Architecture
declaration
declaration body
VHDL 1. ver.7a 6
Entity
Entity declaration
Architecture
Body: defines
Architecture body the processing
VHDL 1. ver.7a 7
An example
a comparator in VHDL
•
a=[a3,a2,a1,a0]
b=[b3,b2,b1,b0]
equals
a b Output : Y
a
0 0 1
b
0 1 0
1 0 0
1 1 1
An example of a comparator
1) --the code starts here , “a comment”
Library
2) library IEEE;
declaration
3) use IEEE.std_logic_1164.all;
Entity 4) entity eqcomp4 is
declaration Entity declaration: defines IOs
5) port (a, b: in std_logic_vector(3 downto 0 );
6) equals: out std_logic);
7) end eqcomp4;
8) architecture dataflow1 of eqcomp4 is
Architecture 9) begin
body 10) equals <= '1' when (a = b) else '0’;
Architecture
11) -- “comment” equals is active high Body: defines
12) end dataflow1; the processing
VHDL 1. ver.7a 9
VHDL 1. ver.7a 10
Entity enclosed by the entity name –
How to read it? eqcomp4 (entered by the user)
•Port defines the I/O pins.
Architecture 9) begin
body 10) equals <= '1' when (a = b) else '0’;
11) -- “comment” equals is active high
12) end dataflow1;
VHDL 1. ver.7a 11
Student ID: __________________
Name: ______________________
Date:_______________ Exercise 1.1
(Submit this at the end of the lecture.)
• In the eqcomp4 VHDL • 1 entity eqcomp4 is
code: • 2 port (a, b: in std_logic_vector(3 downto 0
);
• How many Input / Output
pins? • 3 equals: out std_logic);
• Answer: _______ • 4 end eqcomp4;
• 5
• What are their names and
their types? • 6 architecture dataflow1 of eqcomp4 is
• Answer: ___________ • 7 begin
• ___________________ • 8 equals <= '1' when (a = b) else '0’;
• What is the difference • 9-- “comment” equals is active high
between std_logic and • 10 end dataflow1;
std_logic_vector?
• Answer: __________
• __________________
VHDL 1. ver.7a 12
Entity declaration:
define the IO pins of the chip
• entity eqcomp4 is
• port (a, b:in std_logic_vector(3 downto 0 );
• equals: out std_logic);
• end eqcomp4;
Two input buses (a3,a2,a1,a0) (b3,b2,b1,b0) and one output ‘equals’
a3
a2
a1 b3 The comparator
a0 chip: eqcomp4 equals
b2
b1
b0
VHDL 1. ver.7a 13
Concept of signals
• A signal is used to carry logic information.
• In hardware it is a wire.
• A signal can be “in” or “out” ..etc.
• There are many logic types of signals (wires)
• Bit (can only have logic 1 or 0)
• Std_logic can be 1, 0 , Z ..etc. ( Z=float.)
• Std_logic_vector is a group of wires (called bus).
• a, b: in std_logic_vector(3 downto 0); in VHDL
• means a(0), a(1), a(2), a(3) are std_logic signals
(meaning• Same for b.
Standard logic,
an IEEE standard)
VHDL 1. ver.7a 14
Exercise 1.2
• 1 entity test1 is
• 2 port (in1,in2: in std_logic;
• 3 out1: out std_logic) ;
• 4 end test1;
• 5
• 6 architecture test1arch of test1 is
• 7 begin
• 8 out1<= in1 or in2;
• 9 end test1_arch;
• Give line numbers of (i) entity declaration, and (ii) architecture?
Also find an error in the code.
• _____________________________________________
• What are the functions of (i) entity declaration and (ii) architecture?
• _____________________________________________
• Draw the chip and names the pins. (Don’t forget the two most
important pins)
• __________________________________________________
• Underline (or list) the words that are user defined in the above
VHDL code.
• _________________________________________________
VHDL 1. ver.7a 15
Exercise 1.3
Answer:
• Rewrite code in example
1.2, with
• Entity name is not test1 but
test1x
• Inputs are not in1 and in2 but
a,b, resp.
• Output is not out1 but out1x
• Logic type is not std_logic but
bit
• Architecture name is not
test1arch but x_arch.
VHDL 1. ver.7a 16
ENTITY DECLARATION
Define Input/Output (IO) pins
Entity
Entity
Library Architecture
declaration
declaration body
IN port declaration
declare modes(
In out, inout, buffer)
VHDL 1. ver.7a 17
IO Signal
Modes in port
Exercise 1.4 :
On IO signal modes: IN, OUT, INOUT, BUFFER
• State the difference between out and buffer.
• Answer:_______________________________________
___
• Based on the following schematic, identify the modes of
the IO pins.
A D
From
VHDL for
E programmable
logic,
B F Skahill, Addison Wesley
C
G
VHDL 1. ver.7a 21
Entity
Entity
Library Architecture
declaration
declaration Body
THE ARCHITECTURE
BODY
0 0
1 0
1 1
0 1
1 entity test16 is
2 port (in1 , in2: in std_logic;
3 out00,out01,out10,out11 : out std_logic);
4 end test16;
5 architecture test16_arch of test16 is
6 begin
7 out00<=not (_______________________);
8 out10<=not (_______________________);
9 out11<=not (_______________________);
10 out01<=not (_______________________);VHDL 1. ver.7a
11 end test16_arch ;
VHDL 1. ver.7a 27
Exercise 1.7:
• Write a VHDL program that implement the formula
• F= (/a+b)./c
VHDL 1. ver.7a 28
Summary
• learned
• Entity
• Entity declaration
• Use of port()
• Modes of IO signals
• Structure of the Architecture body of a simple VHDL program