1 Structural VHDL
1 Structural VHDL
1 Structural VHDL
Dr DC Hendry
1 Structural VHDL
The designs we have used so far have consisted of a single design entity (except-
ing in the laboratory where a testbench has also been used). Real designs will
contain a number, often a large number, of design entities representing various
components of the design. These components may be at a high level of abstrac-
tion (a USB interface or a microprocessor), or at a lower level (an adder or a
multiplier). These designs must then be connected together to create the com-
plete design. The design work at this stage consists of connecting the various
inputs and outputs between designs. This style of design, where the structure
of the overall design is being represented is sometimes referred to as structural
design.
component example1
port (
a, b, c : in std_logic;
z, y : out std_logic);
end component;
At a practical level, Xemacs is normally used to copy an entity header and than
paste that header as a component declaration. Similarly Xemacs can be used
to paste an entity header as a component instantiation so saving much typing
and possibility of error.
Component instantation statements are then used to insert one or more such
components into the design. Each component instantiation statement is consid-
ered to be a single concurrent statement, and is therefore placed between the
begin and end of the architecture body.
<instantiation_label> : <instantiated_unit>
[<generic_map>]
[<port_map>] ;
for example:
DUT: example1
port map (
a => a,
b => b,
c => c,
z => z,
y => y);
where:
<instantiated unit> This is normally the name of the design representing this
components, e.g. example1 or detector. Other forms are available.
<generic map> Supplies values for any generic parameters required.
<port map> Specifies the connections of input and output signals.
The generic map gives the value of required generic parameters using the fol-
lowing syntax:
where:
<formal parameter> is the parameter name used in the original design entity
header.
<actual parameter> is an expression giving the value to be used for this in-
stantiation.
where:
<formal parameter> is the signal name used in the original design entity header.
<actual parameter> is a signal name defined in the higher level design to con-
nect to this formal signal, or
open if the keyword open is given (only sensible for an output signal, no con-
nection is made.
3 Example Design
In this section well look at the application of the above statements to the
structural design of an adder. You should not construct an adder in this way,
rather allow the synthesis tool to construct such a design. An adder is being
used here due to its familiarity and simplicity to illustrate the concepts above.
The design will be constructed with a single bit adder as the basic building
block. This has three inputs, cin (carry in), a and b and two outputs, the sum
bit sum and the carry out bit called cout. Here is the VHDL for the single bit
adder design:
Title : Single bit adder
Project : EG3560
File : adder1bit.vhd
Author : <d.c.hendry@abdn.ac.uk>
Company : Aberdeen University
Created : 2006-03-19
Last update: 2006-03-19
Platform :
Description: A single bit adder used in course EG3560 to illustrate use of
the for generate and if generate statements.
Copyright (c) 2006 DC Hendry, University of Aberdeen
Revisions :
Date Version Author Description
2006-03-19 1.0 eng186 Created
library ieee;
use ieee.std logic 1164.all;
entity adder1bit is
port (
cin, a, b : in std logic;
sum, cout : out std logic);
end adder1bit;
begin rtl
end rtl;
library ieee;
use ieee.std logic 1164.all;
entity adderNbit is
generic (
N : integer);
port (
a, b : in std logic vector(N 1 downto 0);
cout : out std logic;
sum : out std logic vector(N 1 downto 0));
end adderNbit;
begin rtl
carries(0) <= 0;
topbit: if n = N 1 generate
adder1bit 1: adder1bit
port map (
cin => carries(n),
a => a(n),
b => b(n),
sum => sum(n),
cout => cout);
end generate topbit;
end generate bn;
end rtl;