Professional Documents
Culture Documents
Digital System Design
Digital System Design
Digital System Design
History of VHDL
Why VHDL?
ENTITY
The Entity is used to specify the input and output ports of the circuit. An
Entity usually has one or more ports that can be inputs (in), outputs (out),
input-outputs (inout), or buffer.
An Entity may also include a set of generic values that are used to declare
properties of the circuit.
Entity Declaration
Simplified syntax
1. entity entity_name is
2. ort (
3. port_1_name : mode data_type;
4. ort_2_name : mode data_type;
5. .......
6. Port_n_name : mode data_type
7. );
8. end entity_name;
Using generic
Simplified syntax
1. entity entity_name is
2. generic (
3. generic_1_name : data_type;
4. generic_2_name : data_type;
5. ........
6. generic_n_name : data_type
7. );
8. port (
9. port_1_name : mode data_type;
10. port_2_name : mode data_type;
11. ........
12. Port_n_name : mode data_type
13. );
14. end entity_name;
Modes of Port
in Input port
out Output port
inout Bidirectional port
buffer Buffered output port
Architecture
Architecture Declaration
1. architecture architecture_name of entity_name is
2. begin
3. (concurrent statements )
4. end architecture_name;
configuration
A configuration defines how the design hierarchy is linked together. It is
also used to associate architecture with an entity.
Configuration Declaration
1. configuration configuration_name of entity_name is
2. --configuration declarations
3. for architecture_name
4. for instance_label : component_name
5. use entity library_name.entity_name(architecture_name);
6. end for;
7. --
8. end for;
9. end [configuration] [configuration_name];
VHDL Objects
Example :-
Signal sig1: std_logic;
Sig1 <= '1'
1. Scalar Types
o Integer
Integer data types are the set of positive and negative whole
numbers.
o Floating point
Floating point data types are the set of positive and negative
numbers that contain a decimal point.
o Enumeration
Enumeration data type is used to increase the readability of the
code.
o Physical
Physical data type describes objects in terms of a base unit,
multiples of base unit, and a specified range.
2. Composite Types
o Arrays
Arrays are used to hold multiple values of the same types under a
single identifier
o Record
Records are used to specify one or more elements, and each
element has a different name and different type.
VHDL Operator
VHDL Operators are used for constructing the expressions.There are the
following types of operators in VHDL:
1. Logical Operators
Logical Operators are used to control the program flow. When the logical
operators combined with signals or variables, then it is used to create
combinational logic.
o and
o or
o nand
o nor
o xor
o xnor
o not
2. Relational Operators
o = Equal to
o /= Not Equal to
o < Less than
o > Greater than
o <= Less than or equal to
o >= Greater than or equal to
3. Arithmetic Operators
o + Addition
o - Subtraction
o * Multiplication
o / Division
o & Concatenation
o mod Modulus
o rem Remainder
o abs Absolute Value
o ** Exponentiation
4. Shift Operators
Advantage of VHDL
Disadvantage of VHDL
VHDL Program
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity half_adder is
end half_adder;
begin
sum<= a xor b;
end data;
Waveform:-
Result :- This is a program in VHDL for implementing the half adder and to
verify the functionality.
Experiment – 3
Aim :- To write a program in VHDL for implementing the full adder and to
verify the functionality.
Required Component :- Multisim Softwere.
Theory :- Full Adder is the adder which adds three inputs and
produces two outputs. The first two inputs are A and B and the third
input is an input carry as C-IN. The output carry is designated as C-
OUT and the normal output is designated as S which is SUM
Full Adder is the adder that adds three inputs and produces two outputs.
The first two inputs are A and B and the third input is an input carry as C-
IN. The output carry is designated as C-OUT and the normal output is
designated as S which is SUM. A full adder logic is designed in such a
manner that can take eight inputs together to create a byte-wide adder
and cascade the carry bit from one adder to another. we use a full adder
because when a carry-in bit is available, another 1-bit adder must be
used since a 1-bit half-adder does not take a carry-in bit. A 1-bit full
adder adds three operands and generates 2-bit results.
Truth Table
Input Output
A B CIN Sum COUT
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Diagram
VHDL Program
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
end full_adder;
begin
end data;
Waveform:-
Result :- This is a program in VHDL for implementing the full adder and to
verify the functionality.
Experiment – 4
Aim :- To write a program in VHDL for implementing the half subtractor
and to verify the functionality.
VHDL Program
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
Library ieee;
use ieee.std_logic_1164.all;
entity half_sub is
end half_sub;
begin
dif <= a xor b;
end sub_arch;
Waveform:-
Experiment – 5
Aim :- To write a program in VHDL for implementing the full subtractor
and to verify the functionality.
Required Component :- Multisim Softwere.
Theory :- The Half Subtractor is used to subtract only two numbers.
To overcome this problem, a full subtractor was designed. The full
subtractor is used to subtract three 1-bit numbers A, B, and C,
which are minuend, subtrahend, and borrow, respectively. The full
subtractor has three input states and two output states i.e., diff and
borrow.
A full subtractor is a combinational circuit that performs subtraction of
two bits, one is minuend and other is subtrahend, taking into account
borrow of the previous adjacent lower minuend bit. This circuit has
three inputs and two outputs. The three inputs A, B and Bin, denote the
minuend, subtrahend, and previous borrow, respectively. The two
outputs, D and Bout represent the difference and output borrow,
respectively. Although subtraction is usually achieved by adding the
complement of subtrahend to the minuend, it is of academic interest to
work out the Truth Table and logic realisation of a full subtractor; x is the
minuend; y is the subtrahend; z is the input borrow; D is the difference;
and B denotes the output borrow. The corresponding maps for logic
functions for outputs of the full subtractor namely difference and
borrow.
Truth Table
Input Output
A B BIN Difference BOUT
0 0 0 0 0
0 0 1 1 1
0 1 0 1 1
0 1 1 0 1
1 0 0 1 0
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
Diagram
VHDL Program
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity full_sub is
end full_sub;
begin
end data;
Waveform:-
Result :- This is a program in VHDL for implementing the full adder and to
verify the functionality.
Experiment – 6
Aim :- To write a program in VHDL for implementing the 2 to 4 decoder
and to verify the functionality.
Required Component :- Multisim Softwere.
Theory :- A Decoder is a combinational logic circuit that has ‘n’ input
signal lines and 2n output lines. In the 2:4 decoder, we have 2 input lines
and 4 output lines. In addition, we provide ‘enable‘ to the input to
ensure the decoder is functioning whenever enable is 1 and it is turned
off when enable is 0.
Truth Table:-
Input Output
A/A0 B/A1 En Y3 Y2 Y1 Y0
X X 0 X X X X
0 0 1 0 0 0 1
0 1 1 0 0 1 0
1 0 1 0 1 0 0
1 1 1 1 0 0 0
Diagram :-
VHDL Program :-
1. 2 to 4 decoder using logic gates
entity decoder2 is
port(
a : in STD_LOGIC_VECTOR(1 downto 0);
b : out STD_LOGIC_VECTOR(3 downto 0)
);
end decoder2;
end bhv;
process(a)
begin
if (a=”00″) then
b <= “0001”;
elsif (a=”01″) then
b <= “0010”;
elsif (a=”10″) then
b <= “0100”;
else
b <= “1000”;
end if;
end process;
end bhv;
process(a)
begin
case a is
when “00” => b <= “0001”; when “01” => b <= “0010”; when “10” => b <=
“0100”; when “11” => b <= “1000”;
end case;
end process;
end bhv;
Waveform:-