VHDL Lecture 1 Intro To Code Parts
VHDL Lecture 1 Intro To Code Parts
VHDL Lecture 1 Intro To Code Parts
THESE ARE THE TWO DESIGN UNITS THAT YOU HAVE TO HAVE IN
YOUR VHDL DESIGN DESCRIPTION.
THAT SAID THERE ARE ANOTHER THREE POSSIBLE DESIGN UNITS
THAT COULD BE INCLUDED. (THAT SAID THEY ARE NOT REQUIRED
RIGHT NOW)
PACKAGES, PACKAGE BODIES AND CONFIGURATIONS.
Entity
The entity basically describes the ‘black box’ without describing the function (or process) – ie: it
defines the inputs and outputs.
This is a statement (indicated by the entity key-word) that defines the external circuit (or sub-
circuit).
When writing an entity you need to provide a name (unique to your design) as well as a port list
which defines all the input and output ports of your circuit.
Each Port has to have a name, direction and type.
Entity
Example:
X
Entity fulladder is
port (X: in bit; Y
Y: in bit;
Cin: in bit;
Cout: out bit;
Sum: out bit);
end fulladder;
Architecture:
The architecture describes the function (or process) and/or structure of the ‘black box’.
This is a statement (indicated by the architecture key-word) that describes the function and/or
structure of the circuit.
Each architecture must be coupled (by name) with one entity in your design.
VHDL allows one to have more than one architecture for each entity which is useful for
simulation and for projects team when wanting to experiment with different description
methods.
Architecture:
All architectures consist of zero or more declarations. Declarations define what the circuit actually does.
This declaration is followed by a begin statement, a series of concurrent statements, and an end
statement.
X
Example:
Y
architecture concurrent of fulladder is
begin
Sum <= X xor Y xor Cin;
Cout <= (X and Y) or (X and Cin) or (Y and Cin);
end concurrent;
Other parts that are to be included in your
code.
Apart from the entity and the architecture you will also require the sections mentioned below
to be included in your code:
◦ A Header
◦ A Library Declaration
◦ Comments
◦ Plus more that we may look into at a later date.
For this Module:
For the purpose of this course and module you will need the following sections to appear in you design
code:
1. Header
2. Library declaration
3. Entity declaration
4. Architecture body
library ieee;
use ieee.std_logic_1164.all;
Note that “library”, “use” and “all” are reserved words, hence why they are in bold type.
The Entity:
The entity defines the inputs to and outputs from the circuit.
“entity”, “is port”, “in”, “out” and “end” are all reserved words.
“Assignment1” is the name that has been chosen for this design.
“a”,“b” and “c” are chosen as the labels for inputs – these are defined as inputs and of the type “std_logic”
as defined in the library declaration.
“x” and “y” have been chosen as the labels for two outputs and are also of the type “std_logic”.
Note that semicolons are used to mark the end of statements.
The Port Declaration:
An entity may define ports in various modes (directions):
An entity may define ports in various modes (directions):
in simple dedicated input pin
out simple dedicated output pin
inout bi-directional pin
buffer output that allows for internal feedback
In addition to the port modes the port types must also be specified. In the example above the type is
“std_logic” – this is used to specify individual bits.
Structural
Structural descriptions involve describing a set of interconnected components. This type of modelling is dealt
with later on in the course.
Reserved Words:
abs downto library postponed srl
access else linkage procedure subtype
after elsif literal process then
Operators:
alias end loop pure to
all entity map range transport Logical Operators and, or, nand, nor, xor, xnor, not
and exit mod record type Adding Operators +, -, &
architecture file nand register unaffected Multiplying Operators *, /, mod, rem
Miscellaneous Operators abs, **
array for new reject units Assignment Operators <=, :=
assert function next rem until Association Operator =>
attribute generate nor report use Shift Operators sll, srl, sla, sra, rol, ror
begin generic not return variable
block group null rol wait
body guarded of ror when Data Types:
Quartus II supports (along with others) the following pre-
buffer if on select while defined VHDL types:
bus impure open severity with
case in or signal xnor integer character std_logic
component inertial others shared xor boolean string std_logic_vector
bit bit_vector
configuration inout out sla
constant is package sll
disconnect label port sra