SlideShare a Scribd company logo
5.
Write the VHDL code for the state machine.
library ieee;
use ieee.std_logic_1164.all;
entity state_machine5 is
port(clk: in std_logic;
R: in std_logic;
S,T:in std_logic);
end state_machine5;
architecture arc_ state_machine5 of state_machine5 is
type state_type is (A,B,C,D);
signal present_state,next_state:state_type;
begin
process (clk,reset)
if (R=’1’) then
present_state<=A;
elsif (rising_edge(clk) then
present_state<=next_state;
end if;
end process;
process (present_state,S,T)
begin
case present_state is
when A =>
if (S=’1’ or T=’1’)then
next_state<=A;
elsif (S=’0’)then
next_state<=C;
elsif (S=’1’ or T=’0’)
next_state<=B;
else
next_state<=A;
end if;
when B =>
if (R=’0’)then
next_state<=B;
elsif (R=’1’)then
next_state<=C;
else
next_state<=A;
end if;
when C =>
if (R=’0’ and T=’1’ )then
next_state<=D;
elsif (R=’1’ and T=’0’)then
next_state<=A;
elsif((R=’0’andT=’0’)or R=’1’and T=’1’)
next_state<=B;
else
next_state<=A;
end if;
when D =>
next_state<=A;
end case;
end process;
end arc_ state_machine5;
Test bench:
entity test_sm is
end test_sm;
architecture arc_test_sm of test_sm is
component state_machine5
port(clk: in std_logic;
R: in std_logic;
S,T:in std_logic);
end component;
signal clk: std_logic :=’0’;
signal R: std_logic :=’1’;
signal S: std_logic :=’0’;
signal T: std_logic :=’0’;
constant clk_period : time := 5 ns;
begin
test1: state_machine5 port map (
clk,R,S,T);
process
begin
clk<=’0’;
wait for clk_period/2;
clk<=’1’;
wait for clk_period/2;
end process;
process
begin
wait for 5 ns;
R<=’0’;
S<=’0’;T<=’0’;
wait for 5 ns;
S<=’0’;T<=’1’;
wait for 5 ns;
R<=’1’;
wait for 5 ns;
S<=’1’;T<=’0’;
wait for 5 ns;
S<=’1’;T<=’1’;
end process;
end arc_test_sm;
Solution
5.
Write the VHDL code for the state machine.
library ieee;
use ieee.std_logic_1164.all;
entity state_machine5 is
port(clk: in std_logic;
R: in std_logic;
S,T:in std_logic);
end state_machine5;
architecture arc_ state_machine5 of state_machine5 is
type state_type is (A,B,C,D);
signal present_state,next_state:state_type;
begin
process (clk,reset)
if (R=’1’) then
present_state<=A;
elsif (rising_edge(clk) then
present_state<=next_state;
end if;
end process;
process (present_state,S,T)
begin
case present_state is
when A =>
if (S=’1’ or T=’1’)then
next_state<=A;
elsif (S=’0’)then
next_state<=C;
elsif (S=’1’ or T=’0’)
next_state<=B;
else
next_state<=A;
end if;
when B =>
if (R=’0’)then
next_state<=B;
elsif (R=’1’)then
next_state<=C;
else
next_state<=A;
end if;
when C =>
if (R=’0’ and T=’1’ )then
next_state<=D;
elsif (R=’1’ and T=’0’)then
next_state<=A;
elsif((R=’0’andT=’0’)or R=’1’and T=’1’)
next_state<=B;
else
next_state<=A;
end if;
when D =>
next_state<=A;
end case;
end process;
end arc_ state_machine5;
Test bench:
entity test_sm is
end test_sm;
architecture arc_test_sm of test_sm is
component state_machine5
port(clk: in std_logic;
R: in std_logic;
S,T:in std_logic);
end component;
signal clk: std_logic :=’0’;
signal R: std_logic :=’1’;
signal S: std_logic :=’0’;
signal T: std_logic :=’0’;
constant clk_period : time := 5 ns;
begin
test1: state_machine5 port map (
clk,R,S,T);
process
begin
clk<=’0’;
wait for clk_period/2;
clk<=’1’;
wait for clk_period/2;
end process;
process
begin
wait for 5 ns;
R<=’0’;
S<=’0’;T<=’0’;
wait for 5 ns;
S<=’0’;T<=’1’;
wait for 5 ns;
R<=’1’;
wait for 5 ns;
S<=’1’;T<=’0’;
wait for 5 ns;
S<=’1’;T<=’1’;
end process;
end arc_test_sm;

More Related Content

Similar to 5.Write the VHDL code for the state machine.library ieee;use i.pdf

vhdll.docx
vhdll.docxvhdll.docx
vhdll.docx
NguynTinDng35
 
Verilog_Examples (1).pdf
Verilog_Examples (1).pdfVerilog_Examples (1).pdf
Verilog_Examples (1).pdf
DrViswanathKalannaga1
 
Combinational Circuits
Combinational CircuitsCombinational Circuits
Combinational Circuits
Farzan Dehbashi
 
lalr. fo engineering student those who to
lalr. fo engineering student those who tolalr. fo engineering student those who to
lalr. fo engineering student those who to
HjJordTzong
 
Behavioral modelling in VHDL
Behavioral modelling in VHDLBehavioral modelling in VHDL
Behavioral modelling in VHDL
Bhupendra Pratap Singh
 
VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLES
karthik kadava
 
Uart
UartUart
Uart
cs1090211
 
solution of question no.6inputPresent stateNext stateoutput.pdf
solution of question no.6inputPresent stateNext stateoutput.pdfsolution of question no.6inputPresent stateNext stateoutput.pdf
solution of question no.6inputPresent stateNext stateoutput.pdf
aptind
 
solution of question no.6inputPresent stateNext stateoutput.pdf
solution of question no.6inputPresent stateNext stateoutput.pdfsolution of question no.6inputPresent stateNext stateoutput.pdf
solution of question no.6inputPresent stateNext stateoutput.pdf
aptind
 
5 c control statements looping
5  c control statements looping5  c control statements looping
5 c control statements looping
MomenMostafa
 
paraproject_Markov_Chain
paraproject_Markov_Chainparaproject_Markov_Chain
paraproject_Markov_Chain? ?
 
Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Ron Liu
 
Presentation1.pdf
Presentation1.pdfPresentation1.pdf
Presentation1.pdf
BijoyGoswami2
 
Digital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential CircuitsDigital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential Circuits
Indira Priyadarshini
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational Processor
Daniel Roggen
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
sana shaikh
 

Similar to 5.Write the VHDL code for the state machine.library ieee;use i.pdf (18)

vhdll.docx
vhdll.docxvhdll.docx
vhdll.docx
 
Verilog_Examples (1).pdf
Verilog_Examples (1).pdfVerilog_Examples (1).pdf
Verilog_Examples (1).pdf
 
Combinational Circuits
Combinational CircuitsCombinational Circuits
Combinational Circuits
 
lalr. fo engineering student those who to
lalr. fo engineering student those who tolalr. fo engineering student those who to
lalr. fo engineering student those who to
 
Fpga creating counter with internal clock
Fpga   creating counter with internal clockFpga   creating counter with internal clock
Fpga creating counter with internal clock
 
Behavioral modelling in VHDL
Behavioral modelling in VHDLBehavioral modelling in VHDL
Behavioral modelling in VHDL
 
VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLES
 
Uart
UartUart
Uart
 
solution of question no.6inputPresent stateNext stateoutput.pdf
solution of question no.6inputPresent stateNext stateoutput.pdfsolution of question no.6inputPresent stateNext stateoutput.pdf
solution of question no.6inputPresent stateNext stateoutput.pdf
 
solution of question no.6inputPresent stateNext stateoutput.pdf
solution of question no.6inputPresent stateNext stateoutput.pdfsolution of question no.6inputPresent stateNext stateoutput.pdf
solution of question no.6inputPresent stateNext stateoutput.pdf
 
5 c control statements looping
5  c control statements looping5  c control statements looping
5 c control statements looping
 
paraproject_Markov_Chain
paraproject_Markov_Chainparaproject_Markov_Chain
paraproject_Markov_Chain
 
Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現Day4 順序控制的循序邏輯實現
Day4 順序控制的循序邏輯實現
 
Presentation1.pdf
Presentation1.pdfPresentation1.pdf
Presentation1.pdf
 
Digital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential CircuitsDigital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential Circuits
 
Vhdlbputspdas
VhdlbputspdasVhdlbputspdas
Vhdlbputspdas
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational Processor
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 

More from sooryasalini

Polarity is measured on a scale of electronegativ.pdf
                     Polarity is measured on a scale of electronegativ.pdf                     Polarity is measured on a scale of electronegativ.pdf
Polarity is measured on a scale of electronegativ.pdf
sooryasalini
 
Geometric isomers are a subset of stereoisomers. .pdf
                     Geometric isomers are a subset of stereoisomers. .pdf                     Geometric isomers are a subset of stereoisomers. .pdf
Geometric isomers are a subset of stereoisomers. .pdf
sooryasalini
 
Scientists Contributions Stanley Miller Conducted an experiment .pdf
    Scientists Contributions   Stanley Miller Conducted an experiment .pdf    Scientists Contributions   Stanley Miller Conducted an experiment .pdf
Scientists Contributions Stanley Miller Conducted an experiment .pdf
sooryasalini
 
1) Microfinance is the provision of small-scale financial services t.pdf
1) Microfinance is the provision of small-scale financial services t.pdf1) Microfinance is the provision of small-scale financial services t.pdf
1) Microfinance is the provision of small-scale financial services t.pdf
sooryasalini
 
The components of individual health are as followsThe three compon.pdf
The components of individual health are as followsThe three compon.pdfThe components of individual health are as followsThe three compon.pdf
The components of individual health are as followsThe three compon.pdf
sooryasalini
 
-Lower income households have become more concentrated in U.S. centr.pdf
-Lower income households have become more concentrated in U.S. centr.pdf-Lower income households have become more concentrated in U.S. centr.pdf
-Lower income households have become more concentrated in U.S. centr.pdf
sooryasalini
 
NO+ note O has one more electron then N, thus, .pdf
                     NO+  note O has one more electron then N, thus, .pdf                     NO+  note O has one more electron then N, thus, .pdf
NO+ note O has one more electron then N, thus, .pdf
sooryasalini
 
Yes, we should be very suspicious of the bones authenticity. This .pdf
Yes, we should be very suspicious of the bones authenticity. This .pdfYes, we should be very suspicious of the bones authenticity. This .pdf
Yes, we should be very suspicious of the bones authenticity. This .pdf
sooryasalini
 
WHITE COLLAR CRIMEWhite-collar crime is nonviolent crime commited.pdf
WHITE COLLAR CRIMEWhite-collar crime is nonviolent crime commited.pdfWHITE COLLAR CRIMEWhite-collar crime is nonviolent crime commited.pdf
WHITE COLLAR CRIMEWhite-collar crime is nonviolent crime commited.pdf
sooryasalini
 
Web 3.0 is just how, why and at what time.Web serviceis a software.pdf
Web 3.0 is just how, why and at what time.Web serviceis a software.pdfWeb 3.0 is just how, why and at what time.Web serviceis a software.pdf
Web 3.0 is just how, why and at what time.Web serviceis a software.pdf
sooryasalini
 
There are a few different reagent could be used to perform this tran.pdf
There are a few different reagent could be used to perform this tran.pdfThere are a few different reagent could be used to perform this tran.pdf
There are a few different reagent could be used to perform this tran.pdf
sooryasalini
 
now a days security is very important to organization and physical s.pdf
now a days security is very important to organization and physical s.pdfnow a days security is very important to organization and physical s.pdf
now a days security is very important to organization and physical s.pdf
sooryasalini
 
pH = pKa + log([A-][HA])(base) HONH2 + H2O (acid) HONH3+ + OH-.pdf
pH = pKa + log([A-][HA])(base) HONH2 + H2O  (acid) HONH3+ + OH-.pdfpH = pKa + log([A-][HA])(base) HONH2 + H2O  (acid) HONH3+ + OH-.pdf
pH = pKa + log([A-][HA])(base) HONH2 + H2O (acid) HONH3+ + OH-.pdf
sooryasalini
 
Solution Relation between carpels and locules Carpels is the p.pdf
Solution Relation between carpels and locules Carpels is the p.pdfSolution Relation between carpels and locules Carpels is the p.pdf
Solution Relation between carpels and locules Carpels is the p.pdf
sooryasalini
 
Solution.Providing legal advice to the president of the company co.pdf
Solution.Providing legal advice to the president of the company co.pdfSolution.Providing legal advice to the president of the company co.pdf
Solution.Providing legal advice to the president of the company co.pdf
sooryasalini
 
S and Se are 6th group elementsSize increase the leaving nature in.pdf
S and Se are 6th group elementsSize increase the leaving nature in.pdfS and Se are 6th group elementsSize increase the leaving nature in.pdf
S and Se are 6th group elementsSize increase the leaving nature in.pdf
sooryasalini
 
Please refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdfPlease refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdf
sooryasalini
 
Simple DefinationsIntertidal zone is the area that is above wate.pdf
Simple DefinationsIntertidal zone  is the area that is above wate.pdfSimple DefinationsIntertidal zone  is the area that is above wate.pdf
Simple DefinationsIntertidal zone is the area that is above wate.pdf
sooryasalini
 
Production.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfProduction.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdf
sooryasalini
 
Proteobacteria are major phylum of gram negative bacteria. Major gro.pdf
Proteobacteria are major phylum of gram negative bacteria. Major gro.pdfProteobacteria are major phylum of gram negative bacteria. Major gro.pdf
Proteobacteria are major phylum of gram negative bacteria. Major gro.pdf
sooryasalini
 

More from sooryasalini (20)

Polarity is measured on a scale of electronegativ.pdf
                     Polarity is measured on a scale of electronegativ.pdf                     Polarity is measured on a scale of electronegativ.pdf
Polarity is measured on a scale of electronegativ.pdf
 
Geometric isomers are a subset of stereoisomers. .pdf
                     Geometric isomers are a subset of stereoisomers. .pdf                     Geometric isomers are a subset of stereoisomers. .pdf
Geometric isomers are a subset of stereoisomers. .pdf
 
Scientists Contributions Stanley Miller Conducted an experiment .pdf
    Scientists Contributions   Stanley Miller Conducted an experiment .pdf    Scientists Contributions   Stanley Miller Conducted an experiment .pdf
Scientists Contributions Stanley Miller Conducted an experiment .pdf
 
1) Microfinance is the provision of small-scale financial services t.pdf
1) Microfinance is the provision of small-scale financial services t.pdf1) Microfinance is the provision of small-scale financial services t.pdf
1) Microfinance is the provision of small-scale financial services t.pdf
 
The components of individual health are as followsThe three compon.pdf
The components of individual health are as followsThe three compon.pdfThe components of individual health are as followsThe three compon.pdf
The components of individual health are as followsThe three compon.pdf
 
-Lower income households have become more concentrated in U.S. centr.pdf
-Lower income households have become more concentrated in U.S. centr.pdf-Lower income households have become more concentrated in U.S. centr.pdf
-Lower income households have become more concentrated in U.S. centr.pdf
 
NO+ note O has one more electron then N, thus, .pdf
                     NO+  note O has one more electron then N, thus, .pdf                     NO+  note O has one more electron then N, thus, .pdf
NO+ note O has one more electron then N, thus, .pdf
 
Yes, we should be very suspicious of the bones authenticity. This .pdf
Yes, we should be very suspicious of the bones authenticity. This .pdfYes, we should be very suspicious of the bones authenticity. This .pdf
Yes, we should be very suspicious of the bones authenticity. This .pdf
 
WHITE COLLAR CRIMEWhite-collar crime is nonviolent crime commited.pdf
WHITE COLLAR CRIMEWhite-collar crime is nonviolent crime commited.pdfWHITE COLLAR CRIMEWhite-collar crime is nonviolent crime commited.pdf
WHITE COLLAR CRIMEWhite-collar crime is nonviolent crime commited.pdf
 
Web 3.0 is just how, why and at what time.Web serviceis a software.pdf
Web 3.0 is just how, why and at what time.Web serviceis a software.pdfWeb 3.0 is just how, why and at what time.Web serviceis a software.pdf
Web 3.0 is just how, why and at what time.Web serviceis a software.pdf
 
There are a few different reagent could be used to perform this tran.pdf
There are a few different reagent could be used to perform this tran.pdfThere are a few different reagent could be used to perform this tran.pdf
There are a few different reagent could be used to perform this tran.pdf
 
now a days security is very important to organization and physical s.pdf
now a days security is very important to organization and physical s.pdfnow a days security is very important to organization and physical s.pdf
now a days security is very important to organization and physical s.pdf
 
pH = pKa + log([A-][HA])(base) HONH2 + H2O (acid) HONH3+ + OH-.pdf
pH = pKa + log([A-][HA])(base) HONH2 + H2O  (acid) HONH3+ + OH-.pdfpH = pKa + log([A-][HA])(base) HONH2 + H2O  (acid) HONH3+ + OH-.pdf
pH = pKa + log([A-][HA])(base) HONH2 + H2O (acid) HONH3+ + OH-.pdf
 
Solution Relation between carpels and locules Carpels is the p.pdf
Solution Relation between carpels and locules Carpels is the p.pdfSolution Relation between carpels and locules Carpels is the p.pdf
Solution Relation between carpels and locules Carpels is the p.pdf
 
Solution.Providing legal advice to the president of the company co.pdf
Solution.Providing legal advice to the president of the company co.pdfSolution.Providing legal advice to the president of the company co.pdf
Solution.Providing legal advice to the president of the company co.pdf
 
S and Se are 6th group elementsSize increase the leaving nature in.pdf
S and Se are 6th group elementsSize increase the leaving nature in.pdfS and Se are 6th group elementsSize increase the leaving nature in.pdf
S and Se are 6th group elementsSize increase the leaving nature in.pdf
 
Please refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdfPlease refer this solution. This is working file for IntegersHeade.pdf
Please refer this solution. This is working file for IntegersHeade.pdf
 
Simple DefinationsIntertidal zone is the area that is above wate.pdf
Simple DefinationsIntertidal zone  is the area that is above wate.pdfSimple DefinationsIntertidal zone  is the area that is above wate.pdf
Simple DefinationsIntertidal zone is the area that is above wate.pdf
 
Production.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdfProduction.javapublic class Production {    Declaring instance.pdf
Production.javapublic class Production {    Declaring instance.pdf
 
Proteobacteria are major phylum of gram negative bacteria. Major gro.pdf
Proteobacteria are major phylum of gram negative bacteria. Major gro.pdfProteobacteria are major phylum of gram negative bacteria. Major gro.pdf
Proteobacteria are major phylum of gram negative bacteria. Major gro.pdf
 

Recently uploaded

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
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
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
 
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
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
"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
 
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
 
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
 
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
 
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
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
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
 
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
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 

Recently uploaded (20)

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
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
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
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
"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...
 
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
 
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
 
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
 
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
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
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 Á...
 
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
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 

5.Write the VHDL code for the state machine.library ieee;use i.pdf

  • 1. 5. Write the VHDL code for the state machine. library ieee; use ieee.std_logic_1164.all; entity state_machine5 is port(clk: in std_logic; R: in std_logic; S,T:in std_logic); end state_machine5; architecture arc_ state_machine5 of state_machine5 is type state_type is (A,B,C,D); signal present_state,next_state:state_type; begin process (clk,reset) if (R=’1’) then present_state<=A; elsif (rising_edge(clk) then present_state<=next_state; end if; end process; process (present_state,S,T) begin case present_state is when A => if (S=’1’ or T=’1’)then next_state<=A; elsif (S=’0’)then next_state<=C; elsif (S=’1’ or T=’0’) next_state<=B; else next_state<=A; end if; when B => if (R=’0’)then
  • 2. next_state<=B; elsif (R=’1’)then next_state<=C; else next_state<=A; end if; when C => if (R=’0’ and T=’1’ )then next_state<=D; elsif (R=’1’ and T=’0’)then next_state<=A; elsif((R=’0’andT=’0’)or R=’1’and T=’1’) next_state<=B; else next_state<=A; end if; when D => next_state<=A; end case; end process; end arc_ state_machine5; Test bench: entity test_sm is end test_sm; architecture arc_test_sm of test_sm is component state_machine5 port(clk: in std_logic; R: in std_logic; S,T:in std_logic); end component; signal clk: std_logic :=’0’; signal R: std_logic :=’1’; signal S: std_logic :=’0’; signal T: std_logic :=’0’; constant clk_period : time := 5 ns; begin
  • 3. test1: state_machine5 port map ( clk,R,S,T); process begin clk<=’0’; wait for clk_period/2; clk<=’1’; wait for clk_period/2; end process; process begin wait for 5 ns; R<=’0’; S<=’0’;T<=’0’; wait for 5 ns; S<=’0’;T<=’1’; wait for 5 ns; R<=’1’; wait for 5 ns; S<=’1’;T<=’0’; wait for 5 ns; S<=’1’;T<=’1’; end process; end arc_test_sm; Solution 5. Write the VHDL code for the state machine. library ieee; use ieee.std_logic_1164.all; entity state_machine5 is port(clk: in std_logic; R: in std_logic; S,T:in std_logic); end state_machine5;
  • 4. architecture arc_ state_machine5 of state_machine5 is type state_type is (A,B,C,D); signal present_state,next_state:state_type; begin process (clk,reset) if (R=’1’) then present_state<=A; elsif (rising_edge(clk) then present_state<=next_state; end if; end process; process (present_state,S,T) begin case present_state is when A => if (S=’1’ or T=’1’)then next_state<=A; elsif (S=’0’)then next_state<=C; elsif (S=’1’ or T=’0’) next_state<=B; else next_state<=A; end if; when B => if (R=’0’)then next_state<=B; elsif (R=’1’)then next_state<=C; else next_state<=A; end if; when C => if (R=’0’ and T=’1’ )then next_state<=D; elsif (R=’1’ and T=’0’)then
  • 5. next_state<=A; elsif((R=’0’andT=’0’)or R=’1’and T=’1’) next_state<=B; else next_state<=A; end if; when D => next_state<=A; end case; end process; end arc_ state_machine5; Test bench: entity test_sm is end test_sm; architecture arc_test_sm of test_sm is component state_machine5 port(clk: in std_logic; R: in std_logic; S,T:in std_logic); end component; signal clk: std_logic :=’0’; signal R: std_logic :=’1’; signal S: std_logic :=’0’; signal T: std_logic :=’0’; constant clk_period : time := 5 ns; begin test1: state_machine5 port map ( clk,R,S,T); process begin clk<=’0’; wait for clk_period/2; clk<=’1’; wait for clk_period/2; end process; process
  • 6. begin wait for 5 ns; R<=’0’; S<=’0’;T<=’0’; wait for 5 ns; S<=’0’;T<=’1’; wait for 5 ns; R<=’1’; wait for 5 ns; S<=’1’;T<=’0’; wait for 5 ns; S<=’1’;T<=’1’; end process; end arc_test_sm;