SlideShare a Scribd company logo
1 of 34
Session 1
omar abdelrhman
What is digital design ?
It is the design of hardware components and creates the circuits that is
necessary for the products function which have outputs 0 or 1.
Types: - fixed design (like: ASIC “Application-specific integrated circuit”)
- programmable design (like: FPGA “Field Programmable Gate Arrays”)
ASIC create a new fixed IC FPGA programmable IC which can
be designed for any circuit you need
omar abdelrhman
What is VHDL ?
VHDL is the shortcut of (very high speed integrated circuit hardware description language)
It’s a hardware description language not programming language……what does it mean?
We know that FPGA consists of many logic gates and logic cells (LUT) so, VHDL provide you to
make wires with logic gates to build your logic circuit that’s simply the main idea……
Like that:
omar abdelrhman
What is FPGA ?
FPGA (Field Programmable Gate Arrays) is simply consists of logic
cells inside each logic cell there are many logic gates.
It consists of: 1- logic cells (LUT, memory element(flip-flop))
2- interconnections resources (muxs that have ability
to make connections with any block)
3- I/O cells (pins)
omar abdelrhman
What is LUT ?
A LUT eht yb dexedni si taht MARS fo kcolb a fo stsisnoc LUT’s ehT .stupni
eht fo tuptuoLUT MARS s'ti ni notiacol dexedni eht ni si eulav revetahw si .
When you describe the function of the circuit LUT in FPGA will be programmed
(use logic gates inside it) and for any input of LUT you will get the output.
omar abdelrhman
How to implement:
U = AB + CD
D C B A U
LUT
Result of synthesizer:
omar abdelrhman
Synthesizer will implement:
B
As following:
BA
omar abdelrhman
I need you imagine that:
1- Your code is converted to addresses to sign to a certain LUT in FPGA.
2- and the connection is converted to wires which connect LUTS to each other.
so, when you burn your code to FPGA each gate you want to use and connections to each gates are known and
simply that’s VHDL do.
omar abdelrhman
RTL (register transfer level):
It is an abstraction layer that describe the connections between blocks.
Ex:
omar abdelrhman
Abstraction layers
Blocks
RTL VHDL / Verilog
C++ / java / python
omar abdelrhman
Design of digital system
Digital design
Structural
implement
Conceptual
implement
Truth table
Blocks
omar abdelrhman
omar abdelrhman
VHDL code structure
libraries
entity
architecture
Make compiler understand the code
and compile it to an effective thing.
Describe the inputs and outputs of
the main block.
Describe operation of the circuit.
omar abdelrhman
Design of half adder
Note that: This design is conceptual ------> truth table.
Steps of coding:
1- define inputs (a,b) and outputs (s,c) of main block.
2- describe how to get outputs from inputs “function of
circuit”.
omar abdelrhman
A
B
S
C
omar abdelrhman
VHDL code for half adder
Library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity half_adder is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
s : out STD_LOGIC;
c : out STD_LOGIC);
end half_adder;
architecture Behavioral of half_adder is
begin
s <= a xor b;
c <= a and b;
end Behavioral;
library
Entity
Architecture
omar abdelrhman
Signals mode
In -------> input
Out ----> output
Inout -------> input and output
circuit
in
inout
out
omar abdelrhman
Common Port types
Std_logic
Std_logic_vector
Bit
Bit_vector
Signed
Unsigned
Integer
Strings
Signed, unsigned, integer --------> are used in code don’t converted to hardware and have all decimal values
bit, bit_vector --------> have only value 0, 1
Strings ---------------> is used only in simulation in report statement
Std_logic, std_logic_vector -----------> are have values as following:
‘x’ forcing unknown
‘0’ forcing low
‘1’ forcing high
‘z’ high impedance
‘w’ weak unknown
‘L’ weak low
‘H’ weak high
‘U’ uninitialized
‘-’ don’t care
Notes:
omar abdelrhman
Differece between std_logic & std_logic_vector
Std_logic: is only one bit
Std_ logic_vector: is more than one bit
How to write stg_logic_vector?
Ex:
X : in std_logic_vector (7 downto 0);
y : in std_logic_vector (7 to 0);
7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7
x
y
LSBMSB
MSB
LSB
omar abdelrhman
Back to the previous code:
Library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity half_adder is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
s : out STD_LOGIC;
c : out STD_LOGIC);
end half_adder;
architecture Behavioral of half_adder is
begin
s <= a xor b;
c <= a and b;
end Behavioral;
Define the library
1-Define (a,b) are inputs of
one bit of std_logic.
2-Define (s,c) are outputs of
one bit of std_logic.
The function of circuit.
omar abdelrhman
Test bench
The testbench is a specification in VHDL that plays the role of a complete
simulation environment for the analyzed system (unit under test, UUT). A
testbench contains both the UUT as well as stimuli for the simulation.
The UUT is instantiated as a component of the testbench and the
architecture of the testbench specifies stimuli for the UUT's ports, usually as
waveforms assigned to all output and bidirectional ports of the UUT.
The entity of a testbench does not have any ports as this serves as an
environment for the UUT. All the simulation results are reported using the
assert and report statements.
omar abdelrhman
Test bench code
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY tb IS
END tb;
ARCHITECTURE behavior OF tb IS
-- Component Declaration for the Unit
Under Test (UUT)
COMPONENT half_adder1
PORT(
a : IN std_logic;
b : IN std_logic;
s : OUT std_logic;
c : OUT std_logic
);
END COMPONENT;
--Inputs
signal a : std_logic := '0';
signal b : std_logic := '0';
--Outputs
signal s : std_logic;
signal c : std_logic;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: half_adder1 PORT MAP (
a => a,
b => b,
s => s,
c => c
);
omar abdelrhman
-- Stimulus process
stim_proc: process
begin
a<='0’;
b<='0’;
wait for 100 ns;
a<='1’;
b<='0’;
wait for 100 ns;
a<='0’;
b<='1’;
wait for 100 ns;
a<='1’;
b<='1’;
wait for 100 ns;
end process;
END;
omar abdelrhman
Design full adder from half adder
Steps for design:
1- define inputs (A,B,Cin) and outputs (S,Cout)
of main block.
2- describe how to get outputs from inputs
“function of circuit”.
Note that: this design is structural.
omar abdelrhman
VHDL code using port map
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity full_adder is
Port ( A: in STD_LOGIC;
B: in STD_LOGIC;
cin : in STD_LOGIC;
S: out STD_LOGIC;
cout : out STD_LOGIC);
end full_adder;
architecture Behavioral of full_adder is
component half_adder is
Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
s : out STD_LOGIC;
c : out STD_LOGIC);
end component;
signal x,y,z :std_logic;
begin
X1:half_adder port map (A,B,x,y);
X2:half_adder port map (x,cin,S,z);
cout <= z or y;
end Behavioral;
omar abdelrhman
objects
1- signals
signal name : std_logic := “initial value”; --initial value can be removed
--signal is like a wire
2-variables
used inside the code and no hardware for it.
variable name : type :=value ;
variable x : integer :=10;
3-constants
-- used in code no hardware for it
constant name : type :=value ;
signal
omar abdelrhman
4-Alias
--not an object it take part of vector, important for instruction format
alias name :type with no. of bits is original vector name which bits ;
ex:
signal word :std_logic_vector (15 downto 0);
alias upper :std_logic_vector (7 downto 0) is word (15 downto 8);
alias lower : std_logic_vector (7 downto 0) is word (7 downto 0);
7 6 5 4 3 2 1 015 14 13 12 11 10 9 8
1 0 1 1 1 1 0 0 1 0 1 0 1 1 0 0
upper lower
word
omar abdelrhman
Steps of port mapping:
1- define the main entity of the digital circuit following name entity.
2- define small entities which you use inside you circuit following name component.
3- describe the architecture or connection between logic cells.
4- if you use any component write this as discussed in the previous example: X1:half_adder port map (A,B,x,y);
Key word
If you write by this
way be careful
about the
arrangement.
Name of component
Name of block
omar abdelrhman
Test bench code
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY half_adder_tb IS
END half_adder_tb;
ARCHITECTURE behavior OF half_adder_tb IS
-- Component Declaration for the Unit Under Test
(UUT)
COMPONENT full_adder
PORT(
A : IN std_logic ;
B : IN std_logic ;
cin : IN std_logic ;
S : OUT std_logic ;
cout : OUT std_logic ;
);
END COMPONENT;
--Inputs
signal A : std_logic := '0';
signal B : std_logic := '0';
signal cin : std_logic := '0';
--Outputs
signal S : std_logic ;
signal cout : std_logic;
BEGIN
uut: full_adder PORT MAP (
A => A,
B => B,
cin => cin,
S => S,
cout => cout
);
omar abdelrhman
-- Stimulus process
stim_proc1: process
begin
A<='0’;
B<=‘0’
cin<='0’;
wait for 100 ns;
A<='1’;
B<='0’;
cin<='0’;
wait for 100 ns;
A<='0’;
B<='1’;
cin<='0’;
wait for 100 ns;
A<=‘1’;
B<='1’;
cin<='0’;
wait for 100 ns;
A<='0';
B<='0';
cin<='1';
wait for 100 ns;
A<='1';
B<='0';
cin<='1';
wait for 100 ns;
A<='0';
B<='1';
cin<='1';
wait for 100 ns;
A<='1';
B<='1';
cin<='1';
wait for 100 ns;
end process;
END;
omar abdelrhman
omar abdelrhman
Important notes
VHDL is case insensitive
VHDL code is non sequential
To deal with combinational logic use “<=” not “=”
For comment, use --
omar abdelrhman
Design a 4-bit adder from full adder
Full
omar abdelrhman
Session1

More Related Content

What's hot

Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
Abhiraj Bohra
 

What's hot (20)

Vhdl programming
Vhdl programmingVhdl programming
Vhdl programming
 
Verilog presentation final
Verilog presentation finalVerilog presentation final
Verilog presentation final
 
System Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLSystem Verilog Tutorial - VHDL
System Verilog Tutorial - VHDL
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學
 
VHDL
VHDLVHDL
VHDL
 
Digital Circuit Verification Hardware Descriptive Language Verilog
Digital Circuit Verification Hardware Descriptive Language VerilogDigital Circuit Verification Hardware Descriptive Language Verilog
Digital Circuit Verification Hardware Descriptive Language Verilog
 
Programs of VHDL
Programs of VHDLPrograms of VHDL
Programs of VHDL
 
Verilog
VerilogVerilog
Verilog
 
Dsd lab Practical File
Dsd lab Practical FileDsd lab Practical File
Dsd lab Practical File
 
VHDL CODES
VHDL CODES VHDL CODES
VHDL CODES
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
Vhdl
VhdlVhdl
Vhdl
 
Hardware Description Language
Hardware Description Language Hardware Description Language
Hardware Description Language
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
Verilog Tutorial - Verilog HDL Tutorial with Examples
Verilog Tutorial - Verilog HDL Tutorial with ExamplesVerilog Tutorial - Verilog HDL Tutorial with Examples
Verilog Tutorial - Verilog HDL Tutorial with Examples
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical file
 
VLSI & E-CAD Lab Manual
VLSI & E-CAD Lab ManualVLSI & E-CAD Lab Manual
VLSI & E-CAD Lab Manual
 
Fpga creating counter with external clock
Fpga   creating counter with external clockFpga   creating counter with external clock
Fpga creating counter with external clock
 
Verilogspk1
Verilogspk1Verilogspk1
Verilogspk1
 

Similar to Session1

EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
PRADEEP
 
L6_Slides_vhdl coures temporary hair dye for dark hair
L6_Slides_vhdl coures temporary hair dye for dark hairL6_Slides_vhdl coures temporary hair dye for dark hair
L6_Slides_vhdl coures temporary hair dye for dark hair
loyad20119
 
8. Kevin Stanton-report PSUBOT
8. Kevin Stanton-report PSUBOT8. Kevin Stanton-report PSUBOT
8. Kevin Stanton-report PSUBOT
Karl Radestam
 
vlsi introduction to hdl and its typesunit-1.pptx
vlsi introduction to hdl and its typesunit-1.pptxvlsi introduction to hdl and its typesunit-1.pptx
vlsi introduction to hdl and its typesunit-1.pptx
iconicyt2
 
Pipeline stalling in vhdl
Pipeline stalling in vhdlPipeline stalling in vhdl
Pipeline stalling in vhdl
Sai Malleswar
 
Digital VLSI Design and FPGA Implementation
Digital VLSI Design and FPGA ImplementationDigital VLSI Design and FPGA Implementation
Digital VLSI Design and FPGA Implementation
Amber Bhaumik
 
Dsdlab 120528004329-phpapp01
Dsdlab 120528004329-phpapp01Dsdlab 120528004329-phpapp01
Dsdlab 120528004329-phpapp01
Shilpa Sharma
 

Similar to Session1 (20)

Session 02 _rtl_design_with_vhdl 101
Session 02 _rtl_design_with_vhdl 101Session 02 _rtl_design_with_vhdl 101
Session 02 _rtl_design_with_vhdl 101
 
Practical file
Practical filePractical file
Practical file
 
Spdas2 vlsibput
Spdas2 vlsibputSpdas2 vlsibput
Spdas2 vlsibput
 
Verilog_ppt.pdf
Verilog_ppt.pdfVerilog_ppt.pdf
Verilog_ppt.pdf
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
L6_Slides_vhdl coures temporary hair dye for dark hair
L6_Slides_vhdl coures temporary hair dye for dark hairL6_Slides_vhdl coures temporary hair dye for dark hair
L6_Slides_vhdl coures temporary hair dye for dark hair
 
8. Kevin Stanton-report PSUBOT
8. Kevin Stanton-report PSUBOT8. Kevin Stanton-report PSUBOT
8. Kevin Stanton-report PSUBOT
 
Vhdl new
Vhdl newVhdl new
Vhdl new
 
Fpga 1
Fpga 1Fpga 1
Fpga 1
 
slide8.ppt
slide8.pptslide8.ppt
slide8.ppt
 
vhdl
vhdlvhdl
vhdl
 
Fpga creating counter with internal clock
Fpga   creating counter with internal clockFpga   creating counter with internal clock
Fpga creating counter with internal clock
 
vlsi introduction to hdl and its typesunit-1.pptx
vlsi introduction to hdl and its typesunit-1.pptxvlsi introduction to hdl and its typesunit-1.pptx
vlsi introduction to hdl and its typesunit-1.pptx
 
Pipeline stalling in vhdl
Pipeline stalling in vhdlPipeline stalling in vhdl
Pipeline stalling in vhdl
 
Digital VLSI Design and FPGA Implementation
Digital VLSI Design and FPGA ImplementationDigital VLSI Design and FPGA Implementation
Digital VLSI Design and FPGA Implementation
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
Vhdl introduction
Vhdl introductionVhdl introduction
Vhdl introduction
 
Dsdlab 120528004329-phpapp01
Dsdlab 120528004329-phpapp01Dsdlab 120528004329-phpapp01
Dsdlab 120528004329-phpapp01
 
e CAD lab manual
e CAD lab manuale CAD lab manual
e CAD lab manual
 
Create your first model for a simple logic circuit
Create your first model for a simple logic circuitCreate your first model for a simple logic circuit
Create your first model for a simple logic circuit
 

Recently uploaded

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 

Session1

  • 2. What is digital design ? It is the design of hardware components and creates the circuits that is necessary for the products function which have outputs 0 or 1. Types: - fixed design (like: ASIC “Application-specific integrated circuit”) - programmable design (like: FPGA “Field Programmable Gate Arrays”) ASIC create a new fixed IC FPGA programmable IC which can be designed for any circuit you need omar abdelrhman
  • 3. What is VHDL ? VHDL is the shortcut of (very high speed integrated circuit hardware description language) It’s a hardware description language not programming language……what does it mean? We know that FPGA consists of many logic gates and logic cells (LUT) so, VHDL provide you to make wires with logic gates to build your logic circuit that’s simply the main idea…… Like that: omar abdelrhman
  • 4. What is FPGA ? FPGA (Field Programmable Gate Arrays) is simply consists of logic cells inside each logic cell there are many logic gates. It consists of: 1- logic cells (LUT, memory element(flip-flop)) 2- interconnections resources (muxs that have ability to make connections with any block) 3- I/O cells (pins) omar abdelrhman
  • 5. What is LUT ? A LUT eht yb dexedni si taht MARS fo kcolb a fo stsisnoc LUT’s ehT .stupni eht fo tuptuoLUT MARS s'ti ni notiacol dexedni eht ni si eulav revetahw si . When you describe the function of the circuit LUT in FPGA will be programmed (use logic gates inside it) and for any input of LUT you will get the output. omar abdelrhman
  • 6. How to implement: U = AB + CD D C B A U LUT Result of synthesizer: omar abdelrhman
  • 7. Synthesizer will implement: B As following: BA omar abdelrhman
  • 8. I need you imagine that: 1- Your code is converted to addresses to sign to a certain LUT in FPGA. 2- and the connection is converted to wires which connect LUTS to each other. so, when you burn your code to FPGA each gate you want to use and connections to each gates are known and simply that’s VHDL do. omar abdelrhman
  • 9. RTL (register transfer level): It is an abstraction layer that describe the connections between blocks. Ex: omar abdelrhman
  • 10. Abstraction layers Blocks RTL VHDL / Verilog C++ / java / python omar abdelrhman
  • 11. Design of digital system Digital design Structural implement Conceptual implement Truth table Blocks omar abdelrhman
  • 13. VHDL code structure libraries entity architecture Make compiler understand the code and compile it to an effective thing. Describe the inputs and outputs of the main block. Describe operation of the circuit. omar abdelrhman
  • 14. Design of half adder Note that: This design is conceptual ------> truth table. Steps of coding: 1- define inputs (a,b) and outputs (s,c) of main block. 2- describe how to get outputs from inputs “function of circuit”. omar abdelrhman
  • 16. VHDL code for half adder Library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity half_adder is Port ( a : in STD_LOGIC; b : in STD_LOGIC; s : out STD_LOGIC; c : out STD_LOGIC); end half_adder; architecture Behavioral of half_adder is begin s <= a xor b; c <= a and b; end Behavioral; library Entity Architecture omar abdelrhman
  • 17. Signals mode In -------> input Out ----> output Inout -------> input and output circuit in inout out omar abdelrhman
  • 18. Common Port types Std_logic Std_logic_vector Bit Bit_vector Signed Unsigned Integer Strings Signed, unsigned, integer --------> are used in code don’t converted to hardware and have all decimal values bit, bit_vector --------> have only value 0, 1 Strings ---------------> is used only in simulation in report statement Std_logic, std_logic_vector -----------> are have values as following: ‘x’ forcing unknown ‘0’ forcing low ‘1’ forcing high ‘z’ high impedance ‘w’ weak unknown ‘L’ weak low ‘H’ weak high ‘U’ uninitialized ‘-’ don’t care Notes: omar abdelrhman
  • 19. Differece between std_logic & std_logic_vector Std_logic: is only one bit Std_ logic_vector: is more than one bit How to write stg_logic_vector? Ex: X : in std_logic_vector (7 downto 0); y : in std_logic_vector (7 to 0); 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 x y LSBMSB MSB LSB omar abdelrhman
  • 20. Back to the previous code: Library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity half_adder is Port ( a : in STD_LOGIC; b : in STD_LOGIC; s : out STD_LOGIC; c : out STD_LOGIC); end half_adder; architecture Behavioral of half_adder is begin s <= a xor b; c <= a and b; end Behavioral; Define the library 1-Define (a,b) are inputs of one bit of std_logic. 2-Define (s,c) are outputs of one bit of std_logic. The function of circuit. omar abdelrhman
  • 21. Test bench The testbench is a specification in VHDL that plays the role of a complete simulation environment for the analyzed system (unit under test, UUT). A testbench contains both the UUT as well as stimuli for the simulation. The UUT is instantiated as a component of the testbench and the architecture of the testbench specifies stimuli for the UUT's ports, usually as waveforms assigned to all output and bidirectional ports of the UUT. The entity of a testbench does not have any ports as this serves as an environment for the UUT. All the simulation results are reported using the assert and report statements. omar abdelrhman
  • 22. Test bench code LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.numeric_std.ALL; ENTITY tb IS END tb; ARCHITECTURE behavior OF tb IS -- Component Declaration for the Unit Under Test (UUT) COMPONENT half_adder1 PORT( a : IN std_logic; b : IN std_logic; s : OUT std_logic; c : OUT std_logic ); END COMPONENT; --Inputs signal a : std_logic := '0'; signal b : std_logic := '0'; --Outputs signal s : std_logic; signal c : std_logic; BEGIN -- Instantiate the Unit Under Test (UUT) uut: half_adder1 PORT MAP ( a => a, b => b, s => s, c => c ); omar abdelrhman
  • 23. -- Stimulus process stim_proc: process begin a<='0’; b<='0’; wait for 100 ns; a<='1’; b<='0’; wait for 100 ns; a<='0’; b<='1’; wait for 100 ns; a<='1’; b<='1’; wait for 100 ns; end process; END; omar abdelrhman
  • 24. Design full adder from half adder Steps for design: 1- define inputs (A,B,Cin) and outputs (S,Cout) of main block. 2- describe how to get outputs from inputs “function of circuit”. Note that: this design is structural. omar abdelrhman
  • 25. VHDL code using port map library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity full_adder is Port ( A: in STD_LOGIC; B: in STD_LOGIC; cin : in STD_LOGIC; S: out STD_LOGIC; cout : out STD_LOGIC); end full_adder; architecture Behavioral of full_adder is component half_adder is Port ( a : in STD_LOGIC; b : in STD_LOGIC; s : out STD_LOGIC; c : out STD_LOGIC); end component; signal x,y,z :std_logic; begin X1:half_adder port map (A,B,x,y); X2:half_adder port map (x,cin,S,z); cout <= z or y; end Behavioral; omar abdelrhman
  • 26. objects 1- signals signal name : std_logic := “initial value”; --initial value can be removed --signal is like a wire 2-variables used inside the code and no hardware for it. variable name : type :=value ; variable x : integer :=10; 3-constants -- used in code no hardware for it constant name : type :=value ; signal omar abdelrhman
  • 27. 4-Alias --not an object it take part of vector, important for instruction format alias name :type with no. of bits is original vector name which bits ; ex: signal word :std_logic_vector (15 downto 0); alias upper :std_logic_vector (7 downto 0) is word (15 downto 8); alias lower : std_logic_vector (7 downto 0) is word (7 downto 0); 7 6 5 4 3 2 1 015 14 13 12 11 10 9 8 1 0 1 1 1 1 0 0 1 0 1 0 1 1 0 0 upper lower word omar abdelrhman
  • 28. Steps of port mapping: 1- define the main entity of the digital circuit following name entity. 2- define small entities which you use inside you circuit following name component. 3- describe the architecture or connection between logic cells. 4- if you use any component write this as discussed in the previous example: X1:half_adder port map (A,B,x,y); Key word If you write by this way be careful about the arrangement. Name of component Name of block omar abdelrhman
  • 29. Test bench code LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.numeric_std.ALL; ENTITY half_adder_tb IS END half_adder_tb; ARCHITECTURE behavior OF half_adder_tb IS -- Component Declaration for the Unit Under Test (UUT) COMPONENT full_adder PORT( A : IN std_logic ; B : IN std_logic ; cin : IN std_logic ; S : OUT std_logic ; cout : OUT std_logic ; ); END COMPONENT; --Inputs signal A : std_logic := '0'; signal B : std_logic := '0'; signal cin : std_logic := '0'; --Outputs signal S : std_logic ; signal cout : std_logic; BEGIN uut: full_adder PORT MAP ( A => A, B => B, cin => cin, S => S, cout => cout ); omar abdelrhman
  • 30. -- Stimulus process stim_proc1: process begin A<='0’; B<=‘0’ cin<='0’; wait for 100 ns; A<='1’; B<='0’; cin<='0’; wait for 100 ns; A<='0’; B<='1’; cin<='0’; wait for 100 ns; A<=‘1’; B<='1’; cin<='0’; wait for 100 ns; A<='0'; B<='0'; cin<='1'; wait for 100 ns; A<='1'; B<='0'; cin<='1'; wait for 100 ns; A<='0'; B<='1'; cin<='1'; wait for 100 ns; A<='1'; B<='1'; cin<='1'; wait for 100 ns; end process; END; omar abdelrhman
  • 32. Important notes VHDL is case insensitive VHDL code is non sequential To deal with combinational logic use “<=” not “=” For comment, use -- omar abdelrhman
  • 33. Design a 4-bit adder from full adder Full omar abdelrhman