SlideShare a Scribd company logo
VHDL
 V-VHSIC- VERY HIGH SPEED INTERGRATED CIRCUIT
 HDL- HARD WARE DISCRIPTION LANGUAGE
*VHDL AND VERILOG HDL FOR DEVELOPMENT AND
DESIGN
SYSTEM VERILOG FOR VERIFICATION
It can be model a digital system at many level of
abstraction ranging from algorithmic level to gate level
History of VHDL
 IT WAS FIRST GENRATION 1981
 THREE COMPANIES IBM,TEXAS INS. AND INTERMETRICS.
 DEVELOPED VERSION 7.2 OF VHDL – 1985
COMPARSIONOF VHDL AND
VERILOG
VHDL VERILOG HDL
Depends on library function It is independent of library
Body consisted of two parts Entire body defined as module
Case insensitivity ( upper and lower
case)
Case insensitivity
Library need for vhdl Library not need
It is free language Structural language
Different b/w Verilog and vhdl
Fuction Vhdl verilog
AND GATE AND &
OR GATE OR !
NAND NAND ~ &
NOR NOR ~ !
XOR XOR ^
XNOR XNOR ~^
NOT NOT ~
 Vhdl provides 5 different type of primary constructs called design
units.
 Entity declaration
 Configuration declaration
 Architecture body
 Package declaration
 Package body
HARDWARE ABSTRACT DEVICE
DEVICE DEVICE MODELmodel
Digital
systems
External view
Internal view
ENTITY
DECLARATION
ARCHITECTURE A
B
Z
VHDL
PROGRA
M
MODELS IN VHDL
 STRUCTURAL MODEL
 DATAFLOW MODEL
 BEHAVIERAL MODEL
 HYBRID MODEL
 PHYSICAL MODEL
STRUCTURE OF VHDL PROGRAM
 Library declaration
 Entity
 Architecture body
BASIC STRUCTURE OF VHDL PROGRAM
 library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;
 use IEEE.STD_LOGIC_ARITH.ALL;
 use IEEE.STD_LOGIC_UNSIGNED.ALL;
 Entity entity name is
 Port declaration; in type ;( data type)
 port declaration ; out type;
 End entity name;
 Architecture Arc name of entity name is
 Signal declaration;
 variable declaration;
 Constant declaration;
 Package declaration;
 Component declaration;
 Begin
 Statement port
 .
 End Arc name;
Half adder
A B SUM CARRY
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
HALF ADDER:
LOGIC DIAGRAM: TRUTH TABLE:
Dataflow Modeling: for half adder

 library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;
 use IEEE.STD_LOGIC_ARITH.ALL;
 use IEEE.STD_LOGIC_UNSIGNED.ALL;
 entity hadd is
 Port ( a : in std_logic;
 b : in std_logic;
 sum : out std_logic;
 carry : out std_logic);
 end hadd;
 architecture dataflow of hadd is
 begin
 sum <= a xor b;
 carry <= a and b;
 end dataflow;
Behavioral modeling for half adder
Behavioral Modeling:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity haddbehavioral is
Port ( a : in std_logic;
b : in std_logic;
sum : out std_logic;
carry : out std_logic);
end haddbehavioral;
architecture Behavioral of haddbehavioral is
begin
p1:process (a,b)
begin
sum<= a xor b;
carry<= a and b;
end process p1;
end Behavioral;
Structural Modeling:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity haddstructural is
Port ( a : in std_logic;
b : in std_logic;
sum : out std_logic;
carry : out std_logic);
end haddstructural;
architecture structural of haddstructural is
component xor2
port(a,b:in std_logic;
z:out std_logic);
end component;
component and2
port(a,b:in std_logic;
z:out std_logic);
end component;
begin
x1: xor2 port map (a,b,sum);
a1: and2 port map (a,b,carry);
end structural;
and2 component source code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity and2 is
Port ( a : in std_logic;
b : in std_logic;
z : out std_logic);
end and2;
architecture dataflow of and2 is
begin
z<= a and b;
end dataflow;
xor2 component source code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity xor2 is
Port ( a : in std_logic;
b : in std_logic;
z : out std_logic);
end xor2;
architecture dataflow of xor2 is
begin
z<= a xor b;
end dataflow;
Dataflow Modeling:
half adder
Behavioral Modeling:
half adder
Structural Modeling:
half adder
module ha_dataflow(a, b, s, ca);
input a;
input b;
output s;
output ca;
assign#2 s=a^b;
assign#2 ca=a&b;
endmodule
module ha_behv(a, b, s, ca);
input a;
input b;
output s;
output ca;
reg s,ca;
always @ (a or b) begin
s=a^b;
ca=a&b;
end
endmodule
module ha_struct(a, b, s, ca);
input a;
input b;
output s;
output ca;
xor
x1(s,a,b);
and
a1(ca,a,b);
endmodule
VERILOG SOURCE CODE:
Gate code for verilog
 VERILOG SOURCE CODE:

 module logicgates1(a, b, c);
 input a;
 input b;
 OUTPUT: [6:0] c;
 assign c[0]= a & b;
 assign c[1]= a | b;
 assign c[2]= ~(a & b);
 assign c[3]= ~(a | b);
 assign c[4]= a ^ b;
 assign c[5]= ~(a ^ b);
 assign c[6]= ~ a;
 endmodule
TEST BENCH(VHDL):
 LIBRARY ieee;
 USE ieee.std_logic_1164.ALL;
 USE ieee.std_logic_unsigned.all;
 USE ieee.numeric_std.ALL;
 ENTITY test_bench_vhd IS
 END test_bench_vhd;
 ARCHITECTURE behavior OF test_bench_vhd IS
 COMPONENT hadd
 PORT(
 a : IN std_logic;
 b : IN std_logic;
 sum : OUT std_logic;
 carry : OUT std_logic
 );
 END COMPONENT;

 --Inputs
 SIGNAL a : std_logic := '0';
 SIGNAL b : std_logic := '0';

 --Outputs
 SIGNAL sum : std_logic;
 SIGNAL carry : std_logic;

 BEGIN
 -- Instantiate the Unit Under Test (UUT)
 uut: hadd PORT MAP(
 a => a,
 b => b,
 sum => sum,
 carry => carry
 );

 tb : PROCESS
 BEGIN
 a<='0'; b<='0'; wait for 100 ps;
 a<='0'; b<='1'; wait for 100 ps;
 a<='1'; b<='0'; wait for 100 ps;
 a<='1'; b<='1'; wait for 100 ps;

 END PROCESS;
 END;
FULL ADDER:
A B C SUM CARRY
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
LOGIC DIAGRAM: TRUTH TABLE:
 Dataflow Modeling:
 library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;
 use IEEE.STD_LOGIC_ARITH.ALL;
 use IEEE.STD_LOGIC_UNSIGNED.ALL;
 entity fadd_dataflow is
 Port ( a : in std_logic;
 b : in std_logic;
 c : in std_logic;
 sum : out std_logic;
 carry : out std_logic);
 end fadd_dataflow;
 architecture dataflow of fadd_dataflow is
 signal p,q,r,s:std_logic;
 begin
 p<= a xor b;
 q<= a and b;
 r<= b and c;
 s<= c and a;
 sum<= p xor c;
 carry<= q or r or s;
 end dataflow;
 Behavioral Modeling:
 library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;
 use IEEE.STD_LOGIC_ARITH.ALL;
 use IEEE.STD_LOGIC_UNSIGNED.ALL;
 entity fadd_behv is
 Port ( a : in std_logic;
 b : in std_logic;
 c : in std_logic;
 sum : out std_logic;
 carry : out std_logic);
 end fadd_behv;
 architecture Behavioral of fadd_behv is
 begin
 p1:process(a,b,c)
 variable r,s,t:std_logic;
 begin
 r:= a and b;
 s:= b and c;
 t:= c and a;
 sum<= a xor b xor c;
 carry<= r or s or t;
 end process p1;
 end Behavioral;
Structural Modeling:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity fadd_structural is
Port ( a : in std_logic;
b : in std_logic;
c : in std_logic;
sum : out std_logic;
carry : out std_logic);
end fadd_structural;
architecture structural of fadd_structural is
component xor2
port(a,b:in std_logic;
z:out std_logic);
end component;
component and2
port(a,b:in std_logic;
z:out std_logic);
end component;
component or3
port(a,b,c:in std_logic;
z:out std_logic);
end component;
signal p,q,r,s:std_logic;
begin
x1: xor2 port map (a,b,p);
x2: xor2 port map (p,c,sum);
a1: and2 port map (a,b,q);
a2: and2 port map (b,c,r);
a3: and2 port map (c,a,s);
o1: or3 port map (q,r,s,carry);
end structural;
and2 component source code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity and2 is
Port ( a : in std_logic;
b : in std_logic;
z : out std_logic);
end and2;
architecture dataflow of and2 is
begin
z<= a and b;
end dataflow;
or3 component source code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use
IEEE.STD_LOGIC_UNSIGNED.ALL;
entity or3 is
Port ( a : in std_logic;
b : in std_logic;
c : in std_logic;
z : out std_logic);
end or3;
architecture dataflow of or3 is
begin
z<= a or b or c;
end dataflow;
xor2 component source code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity xor2 is
Port ( a : in std_logic;
b : in std_logic;
z : out std_logic);
end xor2;
architecture dataflow of xor2 is
begin
z<= a xor b;
end dataflow;

More Related Content

What's hot (20)

PPT
Lecture2 vhdl refresher
Nima Shafiee
 
PPT
Short.course.introduction.to.vhdl for beginners
Ravi Sony
 
PPTX
Introduction to VHDL
Mohamed Samy
 
PPTX
Basics of Vhdl
Atchyuth Sonti
 
PPT
VHDL Part 4
Abhilash Nair
 
ODP
VHDL Packages, Coding Styles for Arithmetic Operations and VHDL-200x Additions
Amal Khailtash
 
PDF
VHDL-Behavioral-Programs-Structure of VHDL
Revathi Subramaniam
 
PDF
VHDL course
Ibrahim Mezzah
 
PPT
VHDL - Part 2
Abhilash Nair
 
PPT
VHDL Entity
Ramasubbu .P
 
PDF
Verilog HDL Training Course
Paul Laskowski
 
DOCX
VHDL CODES
OmkarDarekar6
 
PPTX
Vhdl programming
Yogesh Mashalkar
 
PPTX
Vhdl
vandanamalode
 
PDF
INTRODUCTION TO VHDL
karthikpunuru
 
PPT
Lecture3 combinational blocks
Nima Shafiee
 
PPT
VHDL - Enumerated Types (Part 3)
Abhilash Nair
 
PDF
Introduction to VHDL
Farzan Dehbashi
 
Lecture2 vhdl refresher
Nima Shafiee
 
Short.course.introduction.to.vhdl for beginners
Ravi Sony
 
Introduction to VHDL
Mohamed Samy
 
Basics of Vhdl
Atchyuth Sonti
 
VHDL Part 4
Abhilash Nair
 
VHDL Packages, Coding Styles for Arithmetic Operations and VHDL-200x Additions
Amal Khailtash
 
VHDL-Behavioral-Programs-Structure of VHDL
Revathi Subramaniam
 
VHDL course
Ibrahim Mezzah
 
VHDL - Part 2
Abhilash Nair
 
VHDL Entity
Ramasubbu .P
 
Verilog HDL Training Course
Paul Laskowski
 
VHDL CODES
OmkarDarekar6
 
Vhdl programming
Yogesh Mashalkar
 
INTRODUCTION TO VHDL
karthikpunuru
 
Lecture3 combinational blocks
Nima Shafiee
 
VHDL - Enumerated Types (Part 3)
Abhilash Nair
 
Introduction to VHDL
Farzan Dehbashi
 

Viewers also liked (20)

PDF
4Sem VTU-HDL Programming Notes-Unit3-Behavioral Descriptions
Dr. Shivananda Koteshwar
 
PPTX
Behavioral modelling in VHDL
Bhupendra Pratap Singh
 
DOCX
Unit i
gopi5953
 
PPSX
Vhd lhigh2003
gkumawat
 
PDF
VHDL Reference
Eslam Mohammed
 
PDF
Digital system design practical file
Archita Misra
 
PDF
Dataflow Analysis
Eelco Visser
 
PPT
Encoder decoder
dennis gookyi
 
PDF
4Sem VTU-HDL Programming Notes-Unit2-Data Flow Descriptions
Dr. Shivananda Koteshwar
 
PDF
Verilog tutorial
Abhiraj Bohra
 
PDF
4Sem VTU-HDL Programming Notes-Unit1-Introduction
Dr. Shivananda Koteshwar
 
PPT
Behavioral modeling
dennis gookyi
 
DOC
All VLSI programs
Gouthaman V
 
DOCX
VERILOG CODE
Dhaval Kaneria
 
PDF
Programs of VHDL
Rkrishna Mishra
 
PPTX
Introduction to CAD/CAM
DINBANDHU SINGH
 
PPTX
Hsc project management 2015
greg robertson
 
PDF
Introduction to cad cam
parabajinkya0070
 
PPT
HSC Context and data flow diagrams ( DFD )
greg robertson
 
PPT
Multiplexers & Demultiplexers
Jayanshu Gundaniya
 
4Sem VTU-HDL Programming Notes-Unit3-Behavioral Descriptions
Dr. Shivananda Koteshwar
 
Behavioral modelling in VHDL
Bhupendra Pratap Singh
 
Unit i
gopi5953
 
Vhd lhigh2003
gkumawat
 
VHDL Reference
Eslam Mohammed
 
Digital system design practical file
Archita Misra
 
Dataflow Analysis
Eelco Visser
 
Encoder decoder
dennis gookyi
 
4Sem VTU-HDL Programming Notes-Unit2-Data Flow Descriptions
Dr. Shivananda Koteshwar
 
Verilog tutorial
Abhiraj Bohra
 
4Sem VTU-HDL Programming Notes-Unit1-Introduction
Dr. Shivananda Koteshwar
 
Behavioral modeling
dennis gookyi
 
All VLSI programs
Gouthaman V
 
VERILOG CODE
Dhaval Kaneria
 
Programs of VHDL
Rkrishna Mishra
 
Introduction to CAD/CAM
DINBANDHU SINGH
 
Hsc project management 2015
greg robertson
 
Introduction to cad cam
parabajinkya0070
 
HSC Context and data flow diagrams ( DFD )
greg robertson
 
Multiplexers & Demultiplexers
Jayanshu Gundaniya
 
Ad

Similar to Vhdl basic unit-2 (20)

PDF
Presentation1.pdf
BijoyGoswami2
 
PDF
Digital system design lab manual
Santhosh Poralu
 
PPTX
Digital Electronics .
inian2
 
PDF
Dsdlab 120528004329-phpapp01
Shilpa Sharma
 
PPTX
Very high speed HDL Presentation FOR KIET.pptx
ssuser7e8b8f
 
DOCX
Q 1
rahulbarde420
 
PPTX
vlsi introduction to hdl and its typesunit-1.pptx
iconicyt2
 
PPTX
vhdl
NAGASAI547
 
PDF
Session1pdf
GamalSaied2
 
PPT
VHDL-PRESENTATION.ppt
Dr.YNM
 
PDF
VHDL CODE
Veer Singh shakya
 
PDF
Dsd lab Practical File
Soumya Behera
 
PDF
Digital System Design Lab Report - VHDL ECE
Ramesh Naik Bhukya
 
PPTX
VHDL summer training (ppt)
HoneyKumar34
 
PDF
VHDL Programs
Dr. A. B. Shinde
 
PPTX
the-vhsic-.pptx
jpradha86
 
PDF
Session 02 _rtl_design_with_vhdl 101
Mahmoud Abdellatif
 
PPTX
Basic Coding In VHDL COding
anna university
 
Presentation1.pdf
BijoyGoswami2
 
Digital system design lab manual
Santhosh Poralu
 
Digital Electronics .
inian2
 
Dsdlab 120528004329-phpapp01
Shilpa Sharma
 
Very high speed HDL Presentation FOR KIET.pptx
ssuser7e8b8f
 
vlsi introduction to hdl and its typesunit-1.pptx
iconicyt2
 
Session1pdf
GamalSaied2
 
VHDL-PRESENTATION.ppt
Dr.YNM
 
VHDL CODE
Veer Singh shakya
 
Dsd lab Practical File
Soumya Behera
 
Digital System Design Lab Report - VHDL ECE
Ramesh Naik Bhukya
 
VHDL summer training (ppt)
HoneyKumar34
 
VHDL Programs
Dr. A. B. Shinde
 
the-vhsic-.pptx
jpradha86
 
Session 02 _rtl_design_with_vhdl 101
Mahmoud Abdellatif
 
Basic Coding In VHDL COding
anna university
 
Ad

Recently uploaded (20)

PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 

Vhdl basic unit-2

  • 1. VHDL  V-VHSIC- VERY HIGH SPEED INTERGRATED CIRCUIT  HDL- HARD WARE DISCRIPTION LANGUAGE *VHDL AND VERILOG HDL FOR DEVELOPMENT AND DESIGN SYSTEM VERILOG FOR VERIFICATION It can be model a digital system at many level of abstraction ranging from algorithmic level to gate level
  • 2. History of VHDL  IT WAS FIRST GENRATION 1981  THREE COMPANIES IBM,TEXAS INS. AND INTERMETRICS.  DEVELOPED VERSION 7.2 OF VHDL – 1985
  • 3. COMPARSIONOF VHDL AND VERILOG VHDL VERILOG HDL Depends on library function It is independent of library Body consisted of two parts Entire body defined as module Case insensitivity ( upper and lower case) Case insensitivity Library need for vhdl Library not need It is free language Structural language
  • 4. Different b/w Verilog and vhdl Fuction Vhdl verilog AND GATE AND & OR GATE OR ! NAND NAND ~ & NOR NOR ~ ! XOR XOR ^ XNOR XNOR ~^ NOT NOT ~
  • 5.  Vhdl provides 5 different type of primary constructs called design units.  Entity declaration  Configuration declaration  Architecture body  Package declaration  Package body
  • 6. HARDWARE ABSTRACT DEVICE DEVICE DEVICE MODELmodel Digital systems External view Internal view
  • 8. MODELS IN VHDL  STRUCTURAL MODEL  DATAFLOW MODEL  BEHAVIERAL MODEL  HYBRID MODEL  PHYSICAL MODEL
  • 9. STRUCTURE OF VHDL PROGRAM  Library declaration  Entity  Architecture body
  • 10. BASIC STRUCTURE OF VHDL PROGRAM  library IEEE;  use IEEE.STD_LOGIC_1164.ALL;  use IEEE.STD_LOGIC_ARITH.ALL;  use IEEE.STD_LOGIC_UNSIGNED.ALL;  Entity entity name is  Port declaration; in type ;( data type)  port declaration ; out type;  End entity name;  Architecture Arc name of entity name is  Signal declaration;  variable declaration;  Constant declaration;  Package declaration;  Component declaration;  Begin  Statement port  .  End Arc name;
  • 11. Half adder A B SUM CARRY 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 HALF ADDER: LOGIC DIAGRAM: TRUTH TABLE:
  • 12. Dataflow Modeling: for half adder   library IEEE;  use IEEE.STD_LOGIC_1164.ALL;  use IEEE.STD_LOGIC_ARITH.ALL;  use IEEE.STD_LOGIC_UNSIGNED.ALL;  entity hadd is  Port ( a : in std_logic;  b : in std_logic;  sum : out std_logic;  carry : out std_logic);  end hadd;  architecture dataflow of hadd is  begin  sum <= a xor b;  carry <= a and b;  end dataflow;
  • 13. Behavioral modeling for half adder Behavioral Modeling: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity haddbehavioral is Port ( a : in std_logic; b : in std_logic; sum : out std_logic; carry : out std_logic); end haddbehavioral; architecture Behavioral of haddbehavioral is begin p1:process (a,b) begin sum<= a xor b; carry<= a and b; end process p1; end Behavioral;
  • 14. Structural Modeling: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity haddstructural is Port ( a : in std_logic; b : in std_logic; sum : out std_logic; carry : out std_logic); end haddstructural; architecture structural of haddstructural is component xor2 port(a,b:in std_logic; z:out std_logic); end component; component and2 port(a,b:in std_logic; z:out std_logic); end component; begin x1: xor2 port map (a,b,sum); a1: and2 port map (a,b,carry); end structural; and2 component source code: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity and2 is Port ( a : in std_logic; b : in std_logic; z : out std_logic); end and2; architecture dataflow of and2 is begin z<= a and b; end dataflow; xor2 component source code: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity xor2 is Port ( a : in std_logic; b : in std_logic; z : out std_logic); end xor2; architecture dataflow of xor2 is begin z<= a xor b; end dataflow;
  • 15. Dataflow Modeling: half adder Behavioral Modeling: half adder Structural Modeling: half adder module ha_dataflow(a, b, s, ca); input a; input b; output s; output ca; assign#2 s=a^b; assign#2 ca=a&b; endmodule module ha_behv(a, b, s, ca); input a; input b; output s; output ca; reg s,ca; always @ (a or b) begin s=a^b; ca=a&b; end endmodule module ha_struct(a, b, s, ca); input a; input b; output s; output ca; xor x1(s,a,b); and a1(ca,a,b); endmodule VERILOG SOURCE CODE:
  • 16. Gate code for verilog  VERILOG SOURCE CODE:   module logicgates1(a, b, c);  input a;  input b;  OUTPUT: [6:0] c;  assign c[0]= a & b;  assign c[1]= a | b;  assign c[2]= ~(a & b);  assign c[3]= ~(a | b);  assign c[4]= a ^ b;  assign c[5]= ~(a ^ b);  assign c[6]= ~ a;  endmodule
  • 17. TEST BENCH(VHDL):  LIBRARY ieee;  USE ieee.std_logic_1164.ALL;  USE ieee.std_logic_unsigned.all;  USE ieee.numeric_std.ALL;  ENTITY test_bench_vhd IS  END test_bench_vhd;  ARCHITECTURE behavior OF test_bench_vhd IS
  • 18.  COMPONENT hadd  PORT(  a : IN std_logic;  b : IN std_logic;  sum : OUT std_logic;  carry : OUT std_logic  );  END COMPONENT;   --Inputs  SIGNAL a : std_logic := '0';  SIGNAL b : std_logic := '0';   --Outputs  SIGNAL sum : std_logic;  SIGNAL carry : std_logic; 
  • 19.  BEGIN  -- Instantiate the Unit Under Test (UUT)  uut: hadd PORT MAP(  a => a,  b => b,  sum => sum,  carry => carry  );   tb : PROCESS  BEGIN  a<='0'; b<='0'; wait for 100 ps;  a<='0'; b<='1'; wait for 100 ps;  a<='1'; b<='0'; wait for 100 ps;  a<='1'; b<='1'; wait for 100 ps;   END PROCESS;  END;
  • 20. FULL ADDER: A B C SUM CARRY 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 LOGIC DIAGRAM: TRUTH TABLE:
  • 21.  Dataflow Modeling:  library IEEE;  use IEEE.STD_LOGIC_1164.ALL;  use IEEE.STD_LOGIC_ARITH.ALL;  use IEEE.STD_LOGIC_UNSIGNED.ALL;  entity fadd_dataflow is  Port ( a : in std_logic;  b : in std_logic;  c : in std_logic;  sum : out std_logic;  carry : out std_logic);  end fadd_dataflow;  architecture dataflow of fadd_dataflow is  signal p,q,r,s:std_logic;  begin  p<= a xor b;  q<= a and b;  r<= b and c;  s<= c and a;  sum<= p xor c;  carry<= q or r or s;  end dataflow;
  • 22.  Behavioral Modeling:  library IEEE;  use IEEE.STD_LOGIC_1164.ALL;  use IEEE.STD_LOGIC_ARITH.ALL;  use IEEE.STD_LOGIC_UNSIGNED.ALL;  entity fadd_behv is  Port ( a : in std_logic;  b : in std_logic;  c : in std_logic;  sum : out std_logic;  carry : out std_logic);  end fadd_behv;  architecture Behavioral of fadd_behv is  begin  p1:process(a,b,c)  variable r,s,t:std_logic;  begin  r:= a and b;  s:= b and c;  t:= c and a;  sum<= a xor b xor c;  carry<= r or s or t;  end process p1;  end Behavioral;
  • 23. Structural Modeling: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity fadd_structural is Port ( a : in std_logic; b : in std_logic; c : in std_logic; sum : out std_logic; carry : out std_logic); end fadd_structural; architecture structural of fadd_structural is component xor2 port(a,b:in std_logic; z:out std_logic); end component; component and2 port(a,b:in std_logic; z:out std_logic); end component; component or3 port(a,b,c:in std_logic; z:out std_logic); end component; signal p,q,r,s:std_logic; begin x1: xor2 port map (a,b,p); x2: xor2 port map (p,c,sum); a1: and2 port map (a,b,q); a2: and2 port map (b,c,r); a3: and2 port map (c,a,s); o1: or3 port map (q,r,s,carry); end structural;
  • 24. and2 component source code: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity and2 is Port ( a : in std_logic; b : in std_logic; z : out std_logic); end and2; architecture dataflow of and2 is begin z<= a and b; end dataflow; or3 component source code: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity or3 is Port ( a : in std_logic; b : in std_logic; c : in std_logic; z : out std_logic); end or3; architecture dataflow of or3 is begin z<= a or b or c; end dataflow; xor2 component source code: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity xor2 is Port ( a : in std_logic; b : in std_logic; z : out std_logic); end xor2; architecture dataflow of xor2 is begin z<= a xor b; end dataflow;