VHDL
VHDL
VHDL 1. ver.8a
In this chapter
Learn the basic structure of a VHDL file, especially
What is an entity? What is entity declaration? What is an architecture body?
VHDL 1. ver.8a
Library declaration
Entity declaration
Architecture body
VHDL 1. ver.8a
Entity declaration
Entity
Architecture body
VHDL 1. ver.8a
a3 a2 a1 a0
b3 b2 b1 b0
equals
5
An example of a comparator
1 entity eqcomp4 is 2 port (a, b: in std_logic_vector(3 downto 0); 3 equals: out std_logic); 4 end eqcomp4; 5 6 architecture dataflow1 of eqcomp4 is 7 begin 8 equals <= '1' when (a = b) else '0; 9-- comment equals is active high 10 end dataflow1;
VHDL 1. ver.8a 6
How to read it
Port defines the I/O pins.
Entity enclosed by the entity name eqcomp4 (entered by the user) A bus, use downto to define it. E.g. in std_logic_vector(3 downto 0);
1 entity eqcomp4 is 2 port (a, b: in std_logic_vector(3 downto 0); 3 equals: out std_logic); Std_logic means it is a digital pin. 4 end eqcomp4; 5 6 architecture dataflow1 of eqcomp4 is Architecture body enclosed by the 7 begin architecture name dataflow1 8 equals <= '1' when (a = b) else '0; 9-- comment equals is active high 10 end dataflow1;
VHDL 1. ver.8a 7
Entity declaration
Define Input/Output (IO) pins
Entity
Library declaration
Entity declaration
Architecture body
VHDL 1. ver.8a
a3 a2 a1 a0
b3 b2 b1 b0
equals
9
1 entity test1 is 2 port (in1,in2: in bit; 3 out1: out bit; 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. (Dont forget the two most important pins) Underline the words that are user defined in the above VHDL code.
VHDL 1. ver.8a 10
entity do_care is port( s: in std_logic_vector(1 downto 0); y: buffer std_logic); end do_care; 4 types of IO pins
in, out, inout (bidirectional) buffer (can be read back by the entity)
VHDL 1. ver.8a 11
VHDL 1. ver.8a
12
Draw the schematics of the four types Based on the following schematic, identify the types of the IO pins.
From VHDL for programmable logic, Skahill, Addison Wesley
VHDL 1. ver.8a
13
Entity
Library declaration
Entity declaration
Architecture body
VHDL 1. ver.8a
14
How to read it
Architecture name -- dataflow1(entered by the user) equals, a,b are I/O signal pins designed by the user in the entity declaration. The operation: equals <= '1' when (a = b) else '0; -- means comment
6 architecture dataflow1 of eqcomp4 is 7 begin 8 equals <= '1' when (a = b) else '0; 9-- comment equals is active high 10 end dataflow1;
VHDL 1. ver.8a 16
VHDL 1. ver.8a
17
18
Summary
Learned entity declaration and architecture body
VHDL 1. ver.8a
19