SlideShare a Scribd company logo
VHDL 360© by: Mohamed Samy         Samer El-Saadany
Copyrights Copyright © 2010 to authors. All rights reserved All content in this presentation, including charts, data, artwork and logos (from here on, "the Content"), is the property of Mohamed Samy and Samer El-Saadany or the corresponding owners, depending on the circumstances of publication, and is protected by national and international copyright laws. Authors are not personally liable for your usage of the Content that entailed casual or indirect destruction of anything or actions entailed to information profit loss or other losses. Users are granted to access, display, download and print portions of this presentation, solely for their own personal non-commercial use, provided that all proprietary notices are kept intact.  Product names and trademarks mentioned in this presentation belong to their respective owners. VHDL 360 © 2
Objective Modeling more complicated logic using sequential statements Skills gained: Model simple sequential logic using loops Control the process execution using wait statements VHDL 360 © 3
Sequential Statements Sequential Statements Case statement  If statement loop statements While Loop For Loop Wait statement Think Hardware VHDL 360 © 4
While-Loop <Loop_Label> While  <condition> loop   -- list of sequential statements end loop; 5 VHDL 360 © Syntax: ,[object Object],<Loop_Label> optional label to identify the loop <condition> Boolean expression that evaluates to  either TRUE or FALSE Example 1: count number of ONES in vector A A: (7DOWNTO0), count: integerrange0to8; PROCESS(A)IS     VARIABLEtempCount, iteration:integerrange0to8; BEGIN iteration :=0;tempCount:=0; my_loop:WHILE (iteration <= 7) LOOP if A(iteration)= '1' then tempCount:=tempCount+1; endif; iteration := iteration +1; ENDLOOP; Count <=tempCount; ENDPROCESS;
Skills Check 6 VHDL 360 © After the loop finishes what will be the value of “count” signal? While count <10loop 	count <= count +1; Endloop;
Skills Check (Soln.) ,[object Object]
To fix this :“count” must be a variable 7 VHDL 360 © While count <10loop 	count := count +1; Endloop; Or the process should be suspended inside the while loop using a wait statement While count <10loop 	count <= count +1; <wait statement>-- more on “Wait” later Endloop; Golden rules of thumb ,[object Object]
Signals are updated after the process suspends,[object Object]
For-Loop <Loop_Label> for  <idenifier> in <range> loop   -- list of sequential statements end loop; 9 VHDL 360 © Syntax: ,[object Object],<Loop_Label> optional label to identify the loop <identifier> loop iterator that can only be read inside the loop and is not available outside it  <Range> loop range and can be one of the following         <integer> to <integer>         <integer> downto <integer> Example 2: Anding A with each bit in the vector B_bus SIGNAL A: std_logic; SIGNALB_bus,C_bus:std_logic_vector(7downto0); … process( A,B_bus) begin foriin7downto0loop C_bus(i)<= A andB_bus(i); endloop; Endprocess;
For-Loop 10 VHDL 360 © Example 3: 8-bit shift register Library ieee; Use ieee.std_logic_1164.all; entityshift_registeris Port(clk, D, enable :inSTD_LOGIC; 	Q :outSTD_LOGIC); endentity; architecture Behavioral ofshift_registeris 	signalreg:std_logic_vector(7downto0);  begin process(clk) begin ifrising_edge(clk)then if enable = '1' then reg(7)<= d; 	foriin7downto1loop reg(i-1)<=reg(i); 	endloop; endif; endif; endprocess; Q <=reg(0); end Behavioral;
Exercise 1  The following diagram and flow chart show a “Serial In Parallel Out” register’s interface and describe how it behaves. 11 VHDL 360 ©
Exercise 1 To complete the “Serial In Parallel Out” we need to do the following: Add necessary assignments to the reset condition Add a for loop to shift each bit of the internal register “reg” to the right Decide the condition by which the 8 queued values goes outside the register 12 VHDL 360 © libraryieee; useieee.std_logic_1164.all; useieee.std_logic_unsigned.all; entityserialinparalleloutis port(clk:instd_logic;        d   :instd_logic; rst:instd_logic;        enable :instd_logic; ready :outstd_logic;        q :outstd_logic_vector(7downto0)); endserialinparallelout;
Exercise 1 architecture behave ofserialinparalleloutis   signal count:std_logic_vector(2downto0); begin   process(clk)     variablereg:std_logic_vector(7downto0);   begin    ifrising_edge(clk)then     ifrst= '1' then       Q <= X"00";-- hexadecimal format 		<Here>      else       Ready <= '0';       if enable = '1' then 		< Add the loop Here>  reg(7):= d;        count <= count+1; 		… VHDL 360 © 13
Exercise 1    …    if count = ?? then     Q <=reg;     count <="000";     Ready <= '1';    endif;   endif; endif; endif; endprocess; end behave; VHDL 360 © 14
Sequential Statements Sequential Statements Case statement  If statement loop statements While Loop  For Loop Wait statement VHDL 360 © 15
Wait Statement wait [ sensitivity clause ] [ condition clause ] [timeout clause] ; 16 VHDL 360 © Syntax: Process’ sensitivity list is only one means for controlling when a process is executed. Process execution can also be controlled with one or more waitstatements The wait statement causes suspension of a process Sensitivity clause, condition clause and timeout clause can optionally coexist in the same wait statement sensitivity_clause: onsignal_name Condition clause: until condition timeout_clause: fortime_expression Example 4: wait;                        -- suspends process forever waiton clock;-- suspends process execution until an event occurs on clock  waitfor10 ns;-- suspends process execution for 10 ns  waituntil A < B andenable = '1';-- suspends process until the condition is true waituntil A = '0' for2 ns;-- after A equals 0 wait 2 ns then resume execution of process
Wait Statement Example 5: Counter generator 1  Architecture waveform oftestbenchis 	signal z :std_logic_vector(2downto0); Begin   process-- no sensitivity list   begin    foriin0to7loop      z <=conv_std_logic_vector(i,3);-- converts integer to std_logic_vector      waitfor20 ns;    endloop;    wait;   Endprocess; Endarchitecture; 17 VHDL 360 ©
Skills Check Architecture waveform oftestbenchis 	signal z :std_logic_vector(2downto0); Begin   process   begin    foriin0to7loop      z <=conv_std_logic_vector(i,3);      waitfor20 ns;    endloop; -- wait; 	   Endprocess; Endarchitecture; 18 VHDL 360 © What will happen if we remove this “wait”?
Skills Check (Soln.) Architecture waveform oftestbenchis 	signal z :std_logic_vector(2downto0); Begin   process   begin    foriin0to7loop      z <=conv_std_logic_vector(i,3);      waitfor20 ns;    endloop; -- wait;   Endprocess; Endarchitecture; 19 VHDL 360 © The waveform will not stop when Z reaches “111”, Z will start over again from “000”
Skills Check 20 VHDL 360 © Catch me If you can! ,[object Object]
After fixing the problems, draw the waveforms
When do you think one of them can’t be used for clock generation?,[object Object]
Architecture “behave2” can’t generate a clock with duty cycle other than 50%,[object Object]
Process 3 differs only at initialization time…afterwards the simulation results will be similar to Process 1 & Process 2,[object Object],[object Object]
Conversion Functions 25 VHDL 360 © Reference page Syntax: conv_integer() Converts a std_logic_vector type to an integer; Requires: library ieee; use ieee.std_logic_unsigned.all; Or use ieee.std_logic_signed.all; conv_integer(std_logic_vector); Example 6: libraryieee; useieee.std_logic_unsigned.all; signal tour:std_logic_vector(3downto0); signal n:integer; n <=conv_integer(tour);
Conversion Functions 26 VHDL 360 © Reference page conv_std_logic_vector() Converts an integer type to a std_logic_vector type  Requires: library ieee; use ieee.std_logic_arith.ALL; Syntax: conv_std_logic_vector(integer, number_of_bits) Example 7: libraryieee; useieee.std_logic_arith.all; signal tour:std_logic_vector(3downto0); signal n:integer; tour <=conv_std_logic_vector(n,4);
Sharpen your Saw
Lab work Write the code for a Fibonacci sequence generator:  Output is the sum of the two previous outputs (0,1,1,2,3,5,8,13,…) Port names & types must be: Clk, rst: std_logic Fib_out : integer Don’t use inoutports rst: synchronous reset 28 VHDL 360 ©
Knight Rider LEDs 29 ,[object Object],The shining led moves from left to right then from right to left…etc Port names & types must be: Clk, rst, enable: std_logic knight: std_logic_vector(7 downto 0) Don’t use inoutports rst: synchronous reset VHDL 360 ©

More Related Content

What's hot

Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical file
Archita Misra
 
Synthesis Examples
Synthesis ExamplesSynthesis Examples
Synthesis Examples
Mohamed Samy
 
Programs of VHDL
Programs of VHDLPrograms of VHDL
Programs of VHDL
Rkrishna Mishra
 
Behavioral modeling
Behavioral modelingBehavioral modeling
Behavioral modeling
dennis gookyi
 
Vhdl lab manual
Vhdl lab manualVhdl lab manual
Vhdl lab manual
Mukul Mohal
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab report
Jinesh Kb
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014
Béo Tú
 
Dsd lab Practical File
Dsd lab Practical FileDsd lab Practical File
Dsd lab Practical File
Soumya Behera
 
Exceptions and Exception Handling in C++
Exceptions and Exception Handling in C++Exceptions and Exception Handling in C++
Exceptions and Exception Handling in C++
IRJET Journal
 
VERILOG CODE
VERILOG CODEVERILOG CODE
VERILOG CODE
Dhaval Kaneria
 
VHDL CODE
VHDL CODE VHDL CODE
VHDL CODE
Veer Singh shakya
 
PVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 projectPVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學
艾鍗科技
 
Checking the code of Valgrind dynamic analyzer by a static analyzer
Checking the code of Valgrind dynamic analyzer by a static analyzerChecking the code of Valgrind dynamic analyzer by a static analyzer
Checking the code of Valgrind dynamic analyzer by a static analyzer
PVS-Studio
 
Reporte vhdl9
Reporte vhdl9Reporte vhdl9
Reporte vhdl9
Miguel Angel Peña
 
radix_4 fft dif with mdc and mdf
radix_4 fft dif with mdc and mdfradix_4 fft dif with mdc and mdf
radix_4 fft dif with mdc and mdf
sakthi1986
 
06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT
06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT
06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT
Anne Lee
 
Vhdl
VhdlVhdl
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS Basics
Shijin Raj P
 
Lecture 2 verilog
Lecture 2   verilogLecture 2   verilog
Lecture 2 verilogvenravi10
 

What's hot (20)

Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical file
 
Synthesis Examples
Synthesis ExamplesSynthesis Examples
Synthesis Examples
 
Programs of VHDL
Programs of VHDLPrograms of VHDL
Programs of VHDL
 
Behavioral modeling
Behavioral modelingBehavioral modeling
Behavioral modeling
 
Vhdl lab manual
Vhdl lab manualVhdl lab manual
Vhdl lab manual
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab report
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014
 
Dsd lab Practical File
Dsd lab Practical FileDsd lab Practical File
Dsd lab Practical File
 
Exceptions and Exception Handling in C++
Exceptions and Exception Handling in C++Exceptions and Exception Handling in C++
Exceptions and Exception Handling in C++
 
VERILOG CODE
VERILOG CODEVERILOG CODE
VERILOG CODE
 
VHDL CODE
VHDL CODE VHDL CODE
VHDL CODE
 
PVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 projectPVS-Studio is there to help CERN: analysis of Geant4 project
PVS-Studio is there to help CERN: analysis of Geant4 project
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學
 
Checking the code of Valgrind dynamic analyzer by a static analyzer
Checking the code of Valgrind dynamic analyzer by a static analyzerChecking the code of Valgrind dynamic analyzer by a static analyzer
Checking the code of Valgrind dynamic analyzer by a static analyzer
 
Reporte vhdl9
Reporte vhdl9Reporte vhdl9
Reporte vhdl9
 
radix_4 fft dif with mdc and mdf
radix_4 fft dif with mdc and mdfradix_4 fft dif with mdc and mdf
radix_4 fft dif with mdc and mdf
 
06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT
06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT
06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT
 
Vhdl
VhdlVhdl
Vhdl
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS Basics
 
Lecture 2 verilog
Lecture 2   verilogLecture 2   verilog
Lecture 2 verilog
 

Viewers also liked

design of FPGA based traffic light controller system
design of FPGA based traffic light controller systemdesign of FPGA based traffic light controller system
design of FPGA based traffic light controller system
Vinny Chweety
 
Introduction to VHDL
Introduction to VHDLIntroduction to VHDL
Introduction to VHDL
Mohamed Samy
 
Four way traffic light conrol using Verilog
Four way traffic light conrol using VerilogFour way traffic light conrol using Verilog
Four way traffic light conrol using Verilog
Utkarsh De
 
Traffic signal-project-
Traffic signal-project-Traffic signal-project-
Traffic signal-project-Rajeev Verma
 
Smart Traffic Light Controller
Smart Traffic Light ControllerSmart Traffic Light Controller
Smart Traffic Light Controller
Himanshi_Sharma
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
Rkrishna Mishra
 

Viewers also liked (6)

design of FPGA based traffic light controller system
design of FPGA based traffic light controller systemdesign of FPGA based traffic light controller system
design of FPGA based traffic light controller system
 
Introduction to VHDL
Introduction to VHDLIntroduction to VHDL
Introduction to VHDL
 
Four way traffic light conrol using Verilog
Four way traffic light conrol using VerilogFour way traffic light conrol using Verilog
Four way traffic light conrol using Verilog
 
Traffic signal-project-
Traffic signal-project-Traffic signal-project-
Traffic signal-project-
 
Smart Traffic Light Controller
Smart Traffic Light ControllerSmart Traffic Light Controller
Smart Traffic Light Controller
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
 

Similar to Writing more complex models (continued)

How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?
Sameh El-Ashry
 
Introduction to-vhdl
Introduction to-vhdlIntroduction to-vhdl
Introduction to-vhdl
Neeraj Gupta
 
Coding style for good synthesis
Coding style for good synthesisCoding style for good synthesis
Coding style for good synthesis
Vinchipsytm Vlsitraining
 
Verilog overview
Verilog overviewVerilog overview
Verilog overview
posdege
 
chapter4.pptx
chapter4.pptxchapter4.pptx
chapter4.pptx
alisou77666
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"
Ra'Fat Al-Msie'deen
 
Kernel Recipes 2019 - Formal modeling made easy
Kernel Recipes 2019 - Formal modeling made easyKernel Recipes 2019 - Formal modeling made easy
Kernel Recipes 2019 - Formal modeling made easy
Anne Nicolas
 
리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3
Sangho Park
 
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
The Linux Foundation
 
CH05.pdf
CH05.pdfCH05.pdf
CH05.pdf
ImranKhan880955
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisition
azhar557
 
A Post About Analyzing PHP
A Post About Analyzing PHPA Post About Analyzing PHP
A Post About Analyzing PHP
Andrey Karpov
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
MaxJoker2
 
Uart
UartUart
Uart
cs1090211
 
Verifikation - Metoder og Libraries
Verifikation - Metoder og LibrariesVerifikation - Metoder og Libraries
Verifikation - Metoder og Libraries
InfinIT - Innovationsnetværket for it
 
Intro to Arduino Programming.pdf
Intro to Arduino Programming.pdfIntro to Arduino Programming.pdf
Intro to Arduino Programming.pdf
HimanshuDon1
 
Errors detected in the Visual C++ 2012 libraries
Errors detected in the Visual C++ 2012 librariesErrors detected in the Visual C++ 2012 libraries
Errors detected in the Visual C++ 2012 libraries
PVS-Studio
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
Ahmad Alarbeed
 
process synchronisation operating system
process synchronisation operating systemprocess synchronisation operating system
process synchronisation operating system
codefast
 

Similar to Writing more complex models (continued) (20)

How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?
 
Introduction to-vhdl
Introduction to-vhdlIntroduction to-vhdl
Introduction to-vhdl
 
Fpga creating counter with internal clock
Fpga   creating counter with internal clockFpga   creating counter with internal clock
Fpga creating counter with internal clock
 
Coding style for good synthesis
Coding style for good synthesisCoding style for good synthesis
Coding style for good synthesis
 
Verilog overview
Verilog overviewVerilog overview
Verilog overview
 
chapter4.pptx
chapter4.pptxchapter4.pptx
chapter4.pptx
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"
 
Kernel Recipes 2019 - Formal modeling made easy
Kernel Recipes 2019 - Formal modeling made easyKernel Recipes 2019 - Formal modeling made easy
Kernel Recipes 2019 - Formal modeling made easy
 
리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3리눅스 드라이버 실습 #3
리눅스 드라이버 실습 #3
 
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
 
CH05.pdf
CH05.pdfCH05.pdf
CH05.pdf
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisition
 
A Post About Analyzing PHP
A Post About Analyzing PHPA Post About Analyzing PHP
A Post About Analyzing PHP
 
ch6.ppt
ch6.pptch6.ppt
ch6.ppt
 
Uart
UartUart
Uart
 
Verifikation - Metoder og Libraries
Verifikation - Metoder og LibrariesVerifikation - Metoder og Libraries
Verifikation - Metoder og Libraries
 
Intro to Arduino Programming.pdf
Intro to Arduino Programming.pdfIntro to Arduino Programming.pdf
Intro to Arduino Programming.pdf
 
Errors detected in the Visual C++ 2012 libraries
Errors detected in the Visual C++ 2012 librariesErrors detected in the Visual C++ 2012 libraries
Errors detected in the Visual C++ 2012 libraries
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
process synchronisation operating system
process synchronisation operating systemprocess synchronisation operating system
process synchronisation operating system
 

Recently uploaded

Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 

Recently uploaded (20)

Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 

Writing more complex models (continued)

  • 1. VHDL 360© by: Mohamed Samy Samer El-Saadany
  • 2. Copyrights Copyright © 2010 to authors. All rights reserved All content in this presentation, including charts, data, artwork and logos (from here on, "the Content"), is the property of Mohamed Samy and Samer El-Saadany or the corresponding owners, depending on the circumstances of publication, and is protected by national and international copyright laws. Authors are not personally liable for your usage of the Content that entailed casual or indirect destruction of anything or actions entailed to information profit loss or other losses. Users are granted to access, display, download and print portions of this presentation, solely for their own personal non-commercial use, provided that all proprietary notices are kept intact. Product names and trademarks mentioned in this presentation belong to their respective owners. VHDL 360 © 2
  • 3. Objective Modeling more complicated logic using sequential statements Skills gained: Model simple sequential logic using loops Control the process execution using wait statements VHDL 360 © 3
  • 4. Sequential Statements Sequential Statements Case statement If statement loop statements While Loop For Loop Wait statement Think Hardware VHDL 360 © 4
  • 5.
  • 6. Skills Check 6 VHDL 360 © After the loop finishes what will be the value of “count” signal? While count <10loop count <= count +1; Endloop;
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. For-Loop 10 VHDL 360 © Example 3: 8-bit shift register Library ieee; Use ieee.std_logic_1164.all; entityshift_registeris Port(clk, D, enable :inSTD_LOGIC; Q :outSTD_LOGIC); endentity; architecture Behavioral ofshift_registeris signalreg:std_logic_vector(7downto0); begin process(clk) begin ifrising_edge(clk)then if enable = '1' then reg(7)<= d; foriin7downto1loop reg(i-1)<=reg(i); endloop; endif; endif; endprocess; Q <=reg(0); end Behavioral;
  • 12. Exercise 1 The following diagram and flow chart show a “Serial In Parallel Out” register’s interface and describe how it behaves. 11 VHDL 360 ©
  • 13. Exercise 1 To complete the “Serial In Parallel Out” we need to do the following: Add necessary assignments to the reset condition Add a for loop to shift each bit of the internal register “reg” to the right Decide the condition by which the 8 queued values goes outside the register 12 VHDL 360 © libraryieee; useieee.std_logic_1164.all; useieee.std_logic_unsigned.all; entityserialinparalleloutis port(clk:instd_logic; d :instd_logic; rst:instd_logic; enable :instd_logic; ready :outstd_logic; q :outstd_logic_vector(7downto0)); endserialinparallelout;
  • 14. Exercise 1 architecture behave ofserialinparalleloutis signal count:std_logic_vector(2downto0); begin process(clk) variablereg:std_logic_vector(7downto0); begin ifrising_edge(clk)then ifrst= '1' then Q <= X"00";-- hexadecimal format <Here> else Ready <= '0'; if enable = '1' then < Add the loop Here> reg(7):= d; count <= count+1; … VHDL 360 © 13
  • 15. Exercise 1 … if count = ?? then Q <=reg; count <="000"; Ready <= '1'; endif; endif; endif; endif; endprocess; end behave; VHDL 360 © 14
  • 16. Sequential Statements Sequential Statements Case statement If statement loop statements While Loop For Loop Wait statement VHDL 360 © 15
  • 17. Wait Statement wait [ sensitivity clause ] [ condition clause ] [timeout clause] ; 16 VHDL 360 © Syntax: Process’ sensitivity list is only one means for controlling when a process is executed. Process execution can also be controlled with one or more waitstatements The wait statement causes suspension of a process Sensitivity clause, condition clause and timeout clause can optionally coexist in the same wait statement sensitivity_clause: onsignal_name Condition clause: until condition timeout_clause: fortime_expression Example 4: wait; -- suspends process forever waiton clock;-- suspends process execution until an event occurs on clock waitfor10 ns;-- suspends process execution for 10 ns waituntil A < B andenable = '1';-- suspends process until the condition is true waituntil A = '0' for2 ns;-- after A equals 0 wait 2 ns then resume execution of process
  • 18. Wait Statement Example 5: Counter generator 1 Architecture waveform oftestbenchis signal z :std_logic_vector(2downto0); Begin process-- no sensitivity list begin foriin0to7loop z <=conv_std_logic_vector(i,3);-- converts integer to std_logic_vector waitfor20 ns; endloop; wait; Endprocess; Endarchitecture; 17 VHDL 360 ©
  • 19. Skills Check Architecture waveform oftestbenchis signal z :std_logic_vector(2downto0); Begin process begin foriin0to7loop z <=conv_std_logic_vector(i,3); waitfor20 ns; endloop; -- wait; Endprocess; Endarchitecture; 18 VHDL 360 © What will happen if we remove this “wait”?
  • 20. Skills Check (Soln.) Architecture waveform oftestbenchis signal z :std_logic_vector(2downto0); Begin process begin foriin0to7loop z <=conv_std_logic_vector(i,3); waitfor20 ns; endloop; -- wait; Endprocess; Endarchitecture; 19 VHDL 360 © The waveform will not stop when Z reaches “111”, Z will start over again from “000”
  • 21.
  • 22. After fixing the problems, draw the waveforms
  • 23.
  • 24.
  • 25.
  • 26. Conversion Functions 25 VHDL 360 © Reference page Syntax: conv_integer() Converts a std_logic_vector type to an integer; Requires: library ieee; use ieee.std_logic_unsigned.all; Or use ieee.std_logic_signed.all; conv_integer(std_logic_vector); Example 6: libraryieee; useieee.std_logic_unsigned.all; signal tour:std_logic_vector(3downto0); signal n:integer; n <=conv_integer(tour);
  • 27. Conversion Functions 26 VHDL 360 © Reference page conv_std_logic_vector() Converts an integer type to a std_logic_vector type Requires: library ieee; use ieee.std_logic_arith.ALL; Syntax: conv_std_logic_vector(integer, number_of_bits) Example 7: libraryieee; useieee.std_logic_arith.all; signal tour:std_logic_vector(3downto0); signal n:integer; tour <=conv_std_logic_vector(n,4);
  • 29. Lab work Write the code for a Fibonacci sequence generator: Output is the sum of the two previous outputs (0,1,1,2,3,5,8,13,…) Port names & types must be: Clk, rst: std_logic Fib_out : integer Don’t use inoutports rst: synchronous reset 28 VHDL 360 ©
  • 30.
  • 31. Contacts You can contact us at: http://www.embedded-tips.blogspot.com/ VHDL 360 © 30