Hardware description language (HDL) is a specialized computer language used to program electronic
and digital logic circuits. The structure, operation and design of the circuits are programmable using
HDL. HDL includes a textual description consisting of operators, expressions, statements, inputs and
outputs. Instead of generating a computer executable file, the HDL compilers provide a gate map.
The gate map obtained is then downloaded to the programming device to check the operations of
the desired circuit. The language helps to describe any digital circuit in the form of structural,
behavioural and gate level.
The three common HDLs are Verilog, VHDL, and SystemC. The HDLs allow fast design and better
verification. In most of the industries, Verilog and VHDL are common. Verilog, one of the main
Hardware Description Language is used for designing all types of circuits. It consists of modules and
the language allows Behavioural, Dataflow and Structural Description. VHDL (Very High Speed
Integrated Circuit Hardware Description Language) is standardized by IEEE1164. The design is
composed of entities consisting of multiple architectures. SystemC is a language that consist a set of
C++classes and macros. It allows electronic system level and transaction modelling.
All the goals like power, throughput, latency (delay), test coverage, functionality and area
consumption required for a design can be known by using HDL. As a result, the designer can make
the necessary engineering tradeoffs and can develop the design in a better and efficient way.
HDLs for digital circuit design: Other than Verilog, VHDL and SystemC many HDLs are available for
digital circuits. Among them, `Advanced Boolean Expression Language (ABEL) is better for
programming PLDs (Programmable Logic Devices). Bluespec, a high level functional programming
HDL language is developed to handle chip design and automation systems. Bluespec System
Verilog(BSV) uses syntax similar to Verilog HDL. C-to-Verilog is generally a converter which helps to
convert C to Verilog language. Constructing Hardware in a Scala Embedded Language
(Chisel), MyHDL and HHDL are HDLs used to support advanced hardware design.
Compiler for Universal Programming Language (CUPL) is generally used for logic device
programming. Handel-C is used for programming FPGA’s. Hardware Join Java (HJJ) helps in
reconfigurable computing applications. Impulse C, subset of C supports parallel programming. Just-
Another Hardware Description Language (JHDL) uses an object oriented programming
approach. LavaHDL helps in specifying layout of circuits mainly. Lola HDL is basically used for
synchronous digital circuits. M, is another HDL from Mentor Graphics. PALASM is used as a HDL for
Programmable Array Logic (PAL) devices. Finally System Verilog is an extension to Verilog.
HDLs for analog circuit design: The HDLs used for analog circuits include Analog Hardware
Description Language (AHDL), Spectre High Level Description Language (SpectreHDL), Verilog for
Analog and Mixed Signal (Verilog – AMS), VHDL with analog and mixed signal extension (VHDL –
AMS) and finally HDL-A. AHDL is most commonly used as a HDL language for analog circuits.
SpectreHDL is a high level description language that uses functional description text files to model
the behaviour of the systems. Verilog-AMS is an industry standard modelling language that contains
continuous an event driven simulators for analog, digital and analog/digital circuits. VHDL-AMS is
good for verifying complex analog, mixed signal and RF (radio frequency) circuits. HDL-A is a
proprietary HDL for mixed and analog circuits.
HDL for Printed Circuit Design: PHDL (Printed Circuit Board HDL) is generally used for modeling text
based schematics for PCBs. It allows generating massive buses and re-uses device definitions easily.
Benefits of HDL
The major benefit of the language is fast design and better verification. The Top-down design and
hierarchical design method allows the design time; design cost and design errors to be reduced.
Another major advantage is related to complex designs, which can be managed and verified easily.
HDL provides the timing information and allows the design to be described in gate level and register
transfer level. Reusability of resources is one of the other advantages.
And Gate :
entity aand1_gate is
Port ( a,b : in STD_LOGIC;
c : out STD_LOGIC);
end aand1_gate;
begin
c <= a and b;
end Behavioral;
OR GATE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity oor2_gate is
Port ( a,b : in STD_LOGIC;
c : out STD_LOGIC);
end oor2_gate;
end Behavioral;
NOT GATE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity nnot3_gate is
Port ( a : in STD_LOGIC;
b : out STD_LOGIC);
end nnot3_gate;
architecture Behavioral of nnot3_gate is
begin
b <= not a ;
end Behavioral;
NAND GATE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity nnand3_gate is
Port ( a,b : in STD_LOGIC;
c : out STD_LOGIC);
end nnand3_gate;
begin
c <= a nand b;
end Behavioral;
NOR GATE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity nnor1_gate is
Port ( a ,b : in STD_LOGIC;
c : out STD_LOGIC);
end nnor1_gate;
architecture Behavioral of nnor1_gate is
begin
c <= a nor b;
end Behavioral;
.
Xor Gate :
entity xxor1_gate is
Port ( a,b : in STD_LOGIC;
c : out STD_LOGIC);
end xxor1_gate;
begin
c <= a xor b;
end Behavioral;
3.Write a program to implement Half adder using VHDL.
entity h_add is
Port ( a,b : in STD_LOGIC;
c,s : out STD_LOGIC);
end h_add;
begin
s <= a xor b;
c <= a and b;
end Behavioral;
2. Write a program to implement Full Adder using VHDL
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity wwxfa is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
s : out STD_LOGIC;
car : out STD_LOGIC);
end wwxfa;
begin
s<=a xor b xor c;
car<= (a and b) or (b and c) or (c and a);
end Behavioral;
5.Implement Full Adder by using two half adders
entity full_adder1 is
Port ( x,y,z : in STD_LOGIC;
t,u : out STD_LOGIC);
end full_adder1;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity hs_hs1 is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
d : out STD_LOGIC;
bor : out STD_LOGIC);
end hs_hs1;
begin
d<= a xor b;
bor<= a and not b;
end Behavioral;
FULL SUBTRACTOR
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity de is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
c : in STD_LOGIC;
d : out STD_LOGIC;
bor : out STD_LOGIC);
end de;
architecture Behavioral of de is
begin
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity RCA is
Port ( a : in STD_LOGIC_vector(3 downto 0);
b : in STD_LOGIC_vector(3 downto 0);
ci : in STD_LOGIC;
sum : out STD_LOGIC_vector(3 downto 0);
carry : out STD_LOGIC);
end RCA;
begin
FA1: full_add port map( A(0), B(0), ci, sum(0), s1);
FA2: full_add port map( A(1), B(1), s1, sum(1), s2);
FA3: full_add port map( A(2), B(2), s2, sum(2), s3);
FA4: full_add port map( A(3), B(3), s3, sum(3), carry);
end Behavioral;
8. Write a program to implement 2x4 and 3x8 Decoder using VHDL(
Structural,Behavioral and Dataflow modelling)
2x4 Decoder
Structural
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dec2x4 is
Port ( p : in STD_LOGIC;
q : in STD_LOGIC;
w : out STD_LOGIC;
x : out STD_LOGIC;
y : out STD_LOGIC;
z : out STD_LOGIC);
end dec2x4;
end Behavioral;
Behavioral
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity decoder1 is
port(
a : in STD_LOGIC_VECTOR(1 downto 0);
b : out STD_LOGIC_VECTOR(3 downto 0) );
end decoder1;
architecture bhv of decoder1 is
begin
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 behavioral;
Dataflow
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dec1 is
Port ( a : in STD_LOGIC_VECTOR (1 downto 0);
b: out STD_LOGIC_VECTOR (3 downto 0));
end dec1;
end Behavioral;
3x8 DECODER
Structural
entity dec3x8 is
Port ( p : in STD_LOGIC;
q : in STD_LOGIC;
r : in STD_logic;
s: out STD_LOGIC;
t: out STD_LOGIC;
u: out STD_LOGIC;
v: out STD_LOGIC;
w : out STD_LOGIC;
x : out STD_LOGIC;
y : out STD_LOGIC;
z : out STD_LOGIC);
end dec3x8;
Behavioral
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity decoder2 is
port(
a : in STD_LOGIC_VECTOR(2 downto 0);
b : out STD_LOGIC_VECTOR(7 downto 0) );
end decoder2;
architecture behavioral of decoder2 is
begin
process(a)
begin
if (a="000") then
b <= "00000001";
elsif (a="001") then
b <= "00000010";
elsif (a="010") then
b <= "00000100";
elsif (a="011") then
b <= "00001000";
elsif (a="100") then
b <= "00010000";
elsif (a="101") then
b <= "00100000";
elsif (a="110") then
b <= "01000000";
elsif (a="111") then
b <= "10000000";
end if;
end process;
end behvioral;
DATAFLOW
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity dec2 is
Port ( a : in STD_LOGIC_VECTOR (2 downto 0);
b: out STD_LOGIC_VECTOR (7 downto 0));
end dec2;
Behavioural
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity encoder8to3 is
port (din : in STD_LOGIC_VECTOR(7 downto 0);
dout : out STD_LOGIC_VECTOR(2 downto 0)
);
end encoder8to3;
begin
dout <= "000" when (din="10000000") else
"001" when (din="01000000") else
"010" when (din="00100000") else
"011" when (din="00010000") else
"100" when (din="00001000") else
"101" when (din="00000100") else
"110" when (din="00000010") else
"111";
end Behavioral;
DATAFLOW
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity encoder8to3 is
port(
a : in.STD_LOGIC_VECTOR(7 downto 0)
b : out.STD_LOGIC_VECTOR(2 downto 0)
);
end encoder8to3;
architecture behavior of encoder8to3 is
begin
b(0) <= d(4) or d(5) or d(6) or d(7);
b(1) <= d(2) or d(3) or d(6) or d(7);
b(2) <= d(1) or d(3) or d(5) or d(7);
end behavioral;
STRUCTURAL
entity enc8x3 is
Port ( p : out STD_LOGIC;
q : out STD_LOGIC;
r : out STD_logic;
s: in STD_LOGIC;
t: in STD_LOGIC;
u: in STD_LOGIC;
v: in STD_LOGIC;
w : in STD_LOGIC;
x : in STD_LOGIC;
y : in STD_LOGIC;
z : in STD_LOGIC);
end enc8x3;
STRUCTURAL
entity mux4x1 is
Port ( i0,i1,i2,i3 : in std logic;
s1 : in STD_LOGIC;
s0: in STD_LOGIC;
o: out std_logic);
end mux4x1;
BEHAVIORAL
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mx41 is
Port ( o : in std_logic_vector(3 downto 0);
u : out std_logic;
b : in std_logic_vector(1 downto 0));
end mx41;
architecture mx of mx41 is
begin
process(o,b)
begin
case b is
when "00"=>
u<=o(0);
when "01"=>
u<=o(1);
when "10"=>
u<=o(2);
when others=>
u<=o(3);
end case;
end process;
DATAFLOW
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mux41 is
Port ( s : in STD_LOGIC_VECTOR (1 downto 0);
i : in STD_LOGIC_VECTOR (3 downto 0);
y : out STD_LOGIC);
end mux41;
y<= (not s(1) and not s(0) and i(0)) or (not s(1) and s(0) and i(1)) or (s(1) and not s(0) and i(2)) or (s(1)
and s(0) and i(3));
end Behavioral;
11. Program to implement 4x2 Priority Encoder in VHDL.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity prenc is
Port ( a : in STD_LOGIC_vector(3 downto 0);
b : out STD_LOGIC_vector(1 downto 0);
en : in STD_LOGIC);
end prenc;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity btg is
Port ( b : in STD_LOGIC_vector(3 downto 0);
g : out STD_LOGIC_vector(3 downto 0));
end gtb;
begin
g(3)<= b(3);
g(2)<= b(3) xor b(2);
g(1)<= g(2) xor g(1);
g(0)<= g(1) xor g(0);
end Behavioral;
B)Gray code to Binary code coverter
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity gtb is
Port ( g : in STD_LOGIC_vector(3 downto 0);
b : out STD_LOGIC_vector(3 downto 0));
end gtb;
begin
b(3)<= g(3);
b(2)<= g(3) xor g(2);
b(1)<= g(3) xor g(2)xor g(1);
b(0)<= g(3) xor g(2)xor g(1) xor g(0);
end Behavioral;
C) BCD to 7segment code converter
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity seven is
Port ( bcd : in STD_LOGIC_vector(3 downto 0);
seg7 : out STD_LOGIC_vector(6 downto 0));
end seven;
begin
process(bcd)
begin
if(bcd="0000") then
seg7<="1111110";
elsif(bcd="0001") then
seg7<="0000110";
elsif(bcd="0010") then
seg7<="1011011";
elsif(bcd="0011") then
seg7<="1001111";
elsif(bcd="0100") then
seg7<="0100111";
elsif(bcd="0101") then
seg7<="1101101";
elsif(bcd="0110") then
seg7<="1111101";
elsif(bcd="0111") then
seg7<="1000110";
elsif(bcd="1000") then
seg7<="1111111";
elsif(bcd="1001") then
seg7<="1101111";
else seg7<="0000000";
end if;
end process;
end Behavioral;
D) BCD to Excess-3 code converter
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity xs3 is
Port ( bcd : in STD_LOGIC_vector(3 downto 0);
exst : out STD_LOGIC_vector(3 downto 0));
end xs3;
begin
process(bcd)
begin
if(bcd="0000") then
exst<="0011";
elsif(bcd="0001") then
exst<="0100";
elsif(bcd="0010") then
exst<="0101";
elsif(bcd="0011") then
exst<="0110";
elsif(bcd="0100") then
exst<="0111";
elsif(bcd="0101") then
exst<="1000";
elsif(bcd="0110") then
exst<="1001";
elsif(bcd="0111") then
exst<="1010";
elsif(bcd="1000") then
exst<="1011";
elsif(bcd="1001") then
exst<="1100";
end if;
end process;
end Behavioral;