VHDL ENTITY 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
What is an entity? Overall structure of a VHDL file VHDL 1. ver.8a Entity Library  declaration Entity declaration Architecture body
What are they? VHDL 1. ver.8a Entity declaration Architecture body A VHDL file Library declaration, e.g. IEEE library Defines Input/Output pins The processing Entity
An example  a comparator in VHDL VHDL 1. ver.8a The comparator chip: eqcomp4 a3 a2 a1 a0 equals b3 b2 b1 b0 equals VHDL for programmable logic , Skahill, Addison Wesley A=[a3,a2,a1,a0] B=[b3,b2,b1,b0]
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 Entity declaration: define IOs Architecuture  body: functional definition
How to read it 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 Port defines the I/O pins.  Entity enclosed by the entity name –  eqcomp4  (entered by the user) Architecture body enclosed by the architecture name  dataflow1   Std_logic means it is a digital pin. A bus, use downto to define it.  E.g. in std_logic_vector( 3  downto  0 );
Entity declaration Define Input/Output (IO) pins VHDL 1. ver.8a Entity Library  declaration Entity declaration Architecture body
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 ; VHDL 1. ver.8a The comparator chip: eqcomp4 a3 a2 a1 a0 equals b3 b2 b1 b0 Two input buses (a3,a2,a1,a0) (b3,b2,b1,b0) and one output ‘equals’
Work example 1.1 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. (Don’t forget the two most important pins) Underline the words that are user defined in the above VHDL code. VHDL 1. ver.8a
More on Entity Declaration 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 **User defined variables are in Italic.
IN, OUT, INOUT, BUFFER IN:  data flows in, like an input pin OUT:  data flows out, just like an output.  The output cannot be read back by the entity INOUT:  bi-directional, used for data lines of a CPU etc. BUFFER:  similar to OUT  but it can be read back by the entity . Used for control/address pins of a CPU etc. VHDL 1. ver.8a
Worksheet 1.2  Example/Exercise: IN, OUT, INOUT, BUFFER Draw the schematics of the four types Based on the following schematic, identify the types of the IO pins. VHDL 1. ver.8a From  VHDL for  programmable  logic ,  Skahill, Addison Wesley
The architecture body Define the internal architecture/operation VHDL 1. ver.8a Entity Library  declaration Entity declaration Architecture body
Architecture body: define the operation of the chip Begin … tells you the internal operation….. …… .. end 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 Architecuture  body
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 VHDL 1. ver.8a 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 ;
Worksheet 1.3:  Write the entity of this device Describe the function of the device using plan English/truth table. VHDL 1. ver.8a Worksheet VHDL1.3
Worksheet 1.4:  Draw the schematic circuit 1  entity test is 2  port (in1 : in std_logic_vector (2 downto 0); 3  out1 : out std_logic_vector (3 downto 0)); 4 end test; 5 architecture test_arch of test is 6 begin 7  out1(0)<=in1(1); 8  out1(1)<=in1(2); 9  out1(2)<=in1(0) and in1(1); 10  out1(3)<=‘1’; 11 end test_arch ; VHDL 1. ver.8a Worksheet VHDL1.4
Summary Learned entity declaration and architecture body VHDL 1. ver.8a

VHDL Entity

  • 1.
  • 2.
    In this chapterLearn 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
  • 3.
    What is anentity? Overall structure of a VHDL file VHDL 1. ver.8a Entity Library declaration Entity declaration Architecture body
  • 4.
    What are they?VHDL 1. ver.8a Entity declaration Architecture body A VHDL file Library declaration, e.g. IEEE library Defines Input/Output pins The processing Entity
  • 5.
    An example a comparator in VHDL VHDL 1. ver.8a The comparator chip: eqcomp4 a3 a2 a1 a0 equals b3 b2 b1 b0 equals VHDL for programmable logic , Skahill, Addison Wesley A=[a3,a2,a1,a0] B=[b3,b2,b1,b0]
  • 6.
    An example ofa 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 Entity declaration: define IOs Architecuture body: functional definition
  • 7.
    How to readit 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 Port defines the I/O pins. Entity enclosed by the entity name – eqcomp4 (entered by the user) Architecture body enclosed by the architecture name dataflow1 Std_logic means it is a digital pin. A bus, use downto to define it. E.g. in std_logic_vector( 3 downto 0 );
  • 8.
    Entity declaration DefineInput/Output (IO) pins VHDL 1. ver.8a Entity Library declaration Entity declaration Architecture body
  • 9.
    Entity declaration: definethe IO pins of the chip entity eqcomp4 is port ( a, b: in std_logic_vector( 3 downto 0 ); equals: out std_logic); end eqcomp4 ; VHDL 1. ver.8a The comparator chip: eqcomp4 a3 a2 a1 a0 equals b3 b2 b1 b0 Two input buses (a3,a2,a1,a0) (b3,b2,b1,b0) and one output ‘equals’
  • 10.
    Work example 1.11 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. (Don’t forget the two most important pins) Underline the words that are user defined in the above VHDL code. VHDL 1. ver.8a
  • 11.
    More on EntityDeclaration 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 **User defined variables are in Italic.
  • 12.
    IN, OUT, INOUT,BUFFER IN: data flows in, like an input pin OUT: data flows out, just like an output. The output cannot be read back by the entity INOUT: bi-directional, used for data lines of a CPU etc. BUFFER: similar to OUT but it can be read back by the entity . Used for control/address pins of a CPU etc. VHDL 1. ver.8a
  • 13.
    Worksheet 1.2 Example/Exercise: IN, OUT, INOUT, BUFFER Draw the schematics of the four types Based on the following schematic, identify the types of the IO pins. VHDL 1. ver.8a From VHDL for programmable logic , Skahill, Addison Wesley
  • 14.
    The architecture bodyDefine the internal architecture/operation VHDL 1. ver.8a Entity Library declaration Entity declaration Architecture body
  • 15.
    Architecture body: definethe operation of the chip Begin … tells you the internal operation….. …… .. end 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 Architecuture body
  • 16.
    How to readit 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 VHDL 1. ver.8a 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 ;
  • 17.
    Worksheet 1.3: Write the entity of this device Describe the function of the device using plan English/truth table. VHDL 1. ver.8a Worksheet VHDL1.3
  • 18.
    Worksheet 1.4: Draw the schematic circuit 1 entity test is 2 port (in1 : in std_logic_vector (2 downto 0); 3 out1 : out std_logic_vector (3 downto 0)); 4 end test; 5 architecture test_arch of test is 6 begin 7 out1(0)<=in1(1); 8 out1(1)<=in1(2); 9 out1(2)<=in1(0) and in1(1); 10 out1(3)<=‘1’; 11 end test_arch ; VHDL 1. ver.8a Worksheet VHDL1.4
  • 19.
    Summary Learned entitydeclaration and architecture body VHDL 1. ver.8a