Professional Documents
Culture Documents
• Elements of VHDL
• Data objects - store values of a given type
• Literals - represent constant values
• Operators - operate on data objects.
• Every data object belongs to a specific type.
• Identifiers -a sequence of one or more characters
• The first character in an identifier must be a letter and
the last character may not be an underscore.
Continued..
• Lower-case and upper-case letters are considered to be identical
when used in an identifier; as an example. Count, COUNT, and
CouNT, all refer to the same identifier.
• There are two other types of objects that are implicitly declared.
These are the indices of a for. . . loop statement and the generate
statement
Continued..
• The values belonging to this type are ordered, that is, relational
operators can be used on these values
• E.g – BIT
• There are four different kinds of scalar types. These types are
• 1. enumeration,
• 2. integer,
• 3. physical,
• 4. floating point.
• Enumeration Types
• Suitable for abstract modelling.
• Values of this type are user defined.
Continued..
• One can represent only the values required for specific operation.
• Values can be identifiers or literals.
• Integer Types
• type INDEX is range 0 to 15;
• type WORD_LENGTH is range 31 downto 0;
• Some object declarations using these types are
• constant MUX_ADDRESS: INDEX := 5;
• Concatenation
• In hardware terms, merging of buses to form a large bus.
• Allows an array to be built up out of smaller arrays & elements.
• Ex-
• Signal a ,b :std_logic_vector(15 downto 0);
• Signal z: std_logic_vector(31 downto 0);
• ….
• Z<= a&b;
• Here both sides of vector assignment symbol must be of equal
length.
Concatenation
• begin
Z_BUS <= A_BIT & B_BIT & C_BIT & D_BIT;
end EXAMPLE;
• Ex –record declaration
• This example declares three fields: opcode of type optype, and src and
dst of type INTEGER.
• Each field can be referenced by using the name of the record, followed by a
period and the field name.
• PROCESS(X)
• VARIABLE inst : instruction;
• VARIABLE source, dest : INTEGER;
• VARIABLE operator : optype;
• BEGIN
• source := inst.src; --Ok line 1
• dest := inst.src; --Ok line 2
• source := inst.opcode; --error line 3
• operator := inst.opcode; --Ok line 4
• inst.src := dest; --Ok line 5
• inst.dst := dest; --Ok line 6
• inst := (add, dest, 2); --Ok line 7
• inst := (source); --error line 8
• END PROCESS;
Comparison operators for signed nos
• Maximum of two signed values
• Library ieee;
• Use ieee.std_logic_1164.all;
• Use ieee.std_logic_arith.all;
• Entity max is
• Port (a,b: in signed( 7 downto 0);
• z: out signed (7 downto 0));
• End max;
• Architecture arch of max is
• Begin
• Z<= a when (a>b) else b;
• End arch;
• Packages STD_LOGIC_1164, NUMERIC_BIT, and NUMERIC_STD are
defined by IEEE standards and included in the IEEE Library.
• Although packages STD_LOGIC_UNSIGNED, STD_LOGIC_SIGNED,
and STD_ LOGIC_ARITH are usually included by tool vendors in their
IEEE libraries, they are not actually IEEE standards. However, because of
their widespread use, they are de facto standards.
The NUMERIC_STD Package