SlideShare a Scribd company logo
1 of 16
Download to read offline
solution of question no.6
input
Present state
Next state
output
0
S0
S0
0
1
S0
S1
0
0
S1
S2
0
1
S1
S1
0
0
S2
S3
0
1
S2
S1
0
0
S3
S0
0
1
S3
S4
0
0
S4
S2
1
1
S4
S1
1
library ieee;
use IEEE.std_logic_1164.all;
entity moore is
port (clk : in std_logic;
reset : in std_logic;
input : in std_logic;
output : out std_logic
);
end moore;
architecture behavioral of moore is
type state_type is (s0,s1,s2,s3,s4); --type of state machine.
signal current_s,next_s: state_type; --current and next state declaration.
begin
process (clk,reset)
begin
if (reset='1') then
current_s <= s0; --default state on reset.
elsif (rising_edge(clk)) then
current_s <= next_s; --state change.
end if;
end process;
--state machine process.
process (current_s,input)
begin
case current_s is
when s0 => --when current state is "s0"
if(input ='0') then
output <= '0';
next_s <= s0;
else
output <= '0';
next_s <= s1;
end if;
when s1 =>; --when current state is "s1"
if(input ='0') then
output <= '0';
next_s <= s2;
else
output <= '0';
next_s <= s1;
end if;
when s2 => --when current state is "s2"
if(input ='0') then
output <= '0';
next_s <= s3;
else
output <= '0';
next_s <= s1;
end if;
when s3 => --when current state is "s3"
if(input ='0') then
output <= '1';
next_s <= s0;
else
output <= '0';
next_s <= s4;
end if;
when s4 => --when current state is "s4"
if(input ='0') then
output <= '1';
next_s <= s2;
else
output <= '1';
next_s <= s1;
end if;
end case;
end process;
end behavioral;
solution of question no.7
input
Present state
Next state
output
0
S0
S1
0
1
S0
S0
0
0
S1
S1
0
1
S1
S2
0
0
S2
S3
0
1
S2
S0
0
0
S3
S1
0
1
S3
S2
1
library ieee;
use IEEE.std_logic_1164.all;
entity mealy is
port (clk : in std_logic;
reset : in std_logic;
input : in std_logic;
output : out std_logic
);
end mealy;
architecture behavioral of moore is
type state_type is (s0,s1,s2,s3); --type of state machine.
signal current_s,next_s: state_type; --current and next state declaration.
begin
process (clk,reset)
begin
if (reset='1') then
current_s <= s0; --default state on reset.
elsif (rising_edge(clk)) then
current_s <= next_s; --state change.
end if;
end process;
--state machine process.
process (current_s,input)
begin
case current_s is
when s0 => --when current state is "s0"
if(input ='0') then
output <= '0';
next_s <= s1;
else
output <= '0';
next_s <= s0;
end if;
when s1 =>; --when current state is "s1"
if(input ='0') then
output <= '0';
next_s <= s1;
else
output <= '0';
next_s <= s2;
end if;
when s2 => --when current state is "s2"
if(input ='0') then
output <= '0';
next_s <= s3;
else
output <= '0';
next_s <= s1;
end if;
when s3 => --when current state is "s3"
if(input ='0') then
output <= '0';
next_s <= s1;
else
output <= '1';
next_s <= s2;
end if;
end case;
end process;
end behavioral;
input
Present state
Next state
output
0
S0
S0
0
1
S0
S1
0
0
S1
S2
0
1
S1
S1
0
0
S2
S3
0
1
S2
S1
0
0
S3
S0
0
1
S3
S4
0
0
S4
S2
1
1
S4
S1
1
Solution
solution of question no.6
input
Present state
Next state
output
0
S0
S0
0
1
S0
S1
0
0
S1
S2
0
1
S1
S1
0
0
S2
S3
0
1
S2
S1
0
0
S3
S0
0
1
S3
S4
0
0
S4
S2
1
1
S4
S1
1
library ieee;
use IEEE.std_logic_1164.all;
entity moore is
port (clk : in std_logic;
reset : in std_logic;
input : in std_logic;
output : out std_logic
);
end moore;
architecture behavioral of moore is
type state_type is (s0,s1,s2,s3,s4); --type of state machine.
signal current_s,next_s: state_type; --current and next state declaration.
begin
process (clk,reset)
begin
if (reset='1') then
current_s <= s0; --default state on reset.
elsif (rising_edge(clk)) then
current_s <= next_s; --state change.
end if;
end process;
--state machine process.
process (current_s,input)
begin
case current_s is
when s0 => --when current state is "s0"
if(input ='0') then
output <= '0';
next_s <= s0;
else
output <= '0';
next_s <= s1;
end if;
when s1 =>; --when current state is "s1"
if(input ='0') then
output <= '0';
next_s <= s2;
else
output <= '0';
next_s <= s1;
end if;
when s2 => --when current state is "s2"
if(input ='0') then
output <= '0';
next_s <= s3;
else
output <= '0';
next_s <= s1;
end if;
when s3 => --when current state is "s3"
if(input ='0') then
output <= '1';
next_s <= s0;
else
output <= '0';
next_s <= s4;
end if;
when s4 => --when current state is "s4"
if(input ='0') then
output <= '1';
next_s <= s2;
else
output <= '1';
next_s <= s1;
end if;
end case;
end process;
end behavioral;
solution of question no.7
input
Present state
Next state
output
0
S0
S1
0
1
S0
S0
0
0
S1
S1
0
1
S1
S2
0
0
S2
S3
0
1
S2
S0
0
0
S3
S1
0
1
S3
S2
1
library ieee;
use IEEE.std_logic_1164.all;
entity mealy is
port (clk : in std_logic;
reset : in std_logic;
input : in std_logic;
output : out std_logic
);
end mealy;
architecture behavioral of moore is
type state_type is (s0,s1,s2,s3); --type of state machine.
signal current_s,next_s: state_type; --current and next state declaration.
begin
process (clk,reset)
begin
if (reset='1') then
current_s <= s0; --default state on reset.
elsif (rising_edge(clk)) then
current_s <= next_s; --state change.
end if;
end process;
--state machine process.
process (current_s,input)
begin
case current_s is
when s0 => --when current state is "s0"
if(input ='0') then
output <= '0';
next_s <= s1;
else
output <= '0';
next_s <= s0;
end if;
when s1 =>; --when current state is "s1"
if(input ='0') then
output <= '0';
next_s <= s1;
else
output <= '0';
next_s <= s2;
end if;
when s2 => --when current state is "s2"
if(input ='0') then
output <= '0';
next_s <= s3;
else
output <= '0';
next_s <= s1;
end if;
when s3 => --when current state is "s3"
if(input ='0') then
output <= '0';
next_s <= s1;
else
output <= '1';
next_s <= s2;
end if;
end case;
end process;
end behavioral;
input
Present state
Next state
output
0
S0
S0
0
1
S0
S1
0
0
S1
S2
0
1
S1
S1
0
0
S2
S3
0
1
S2
S1
0
0
S3
S0
0
1
S3
S4
0
0
S4
S2
1
1
S4
S1
1

More Related Content

Similar to solution of question no.6inputPresent stateNext stateoutput.pdf

05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt
RAMAKOTESH1
 
05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt
RAMAKOTESH1
 

Similar to solution of question no.6inputPresent stateNext stateoutput.pdf (20)

Digital Electronics Unit_3.pptx
Digital Electronics Unit_3.pptxDigital Electronics Unit_3.pptx
Digital Electronics Unit_3.pptx
 
Digital Electronics Unit_3.pptx
Digital Electronics Unit_3.pptxDigital Electronics Unit_3.pptx
Digital Electronics Unit_3.pptx
 
vhdll.docx
vhdll.docxvhdll.docx
vhdll.docx
 
vhdll.docx
vhdll.docxvhdll.docx
vhdll.docx
 
Hd5
Hd5Hd5
Hd5
 
Hd5
Hd5Hd5
Hd5
 
J - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPSJ - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPS
 
J - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPSJ - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPS
 
Flip flops
Flip flopsFlip flops
Flip flops
 
Flip flops
Flip flopsFlip flops
Flip flops
 
Latches and flip flops
Latches and flip flopsLatches and flip flops
Latches and flip flops
 
Latches and flip flops
Latches and flip flopsLatches and flip flops
Latches and flip flops
 
07 seq logicii-ix2
07 seq logicii-ix207 seq logicii-ix2
07 seq logicii-ix2
 
07 seq logicii-ix2
07 seq logicii-ix207 seq logicii-ix2
07 seq logicii-ix2
 
Sequential circuits
Sequential circuitsSequential circuits
Sequential circuits
 
Sequential circuits
Sequential circuitsSequential circuits
Sequential circuits
 
05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt
 
05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt
 
05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt
 
05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt05_Chapter 6,7,8 - Sequential-design.ppt
05_Chapter 6,7,8 - Sequential-design.ppt
 

More from aptind

               CLOUD COMPUTING -----------------------------------.pdf
               CLOUD COMPUTING -----------------------------------.pdf               CLOUD COMPUTING -----------------------------------.pdf
               CLOUD COMPUTING -----------------------------------.pdf
aptind
 
ViVi is universally available on Unix systems. It has been around.pdf
ViVi is universally available on Unix systems. It has been around.pdfViVi is universally available on Unix systems. It has been around.pdf
ViVi is universally available on Unix systems. It has been around.pdf
aptind
 
Waterfall methodThe model consists of various phases based on the.pdf
Waterfall methodThe model consists of various phases based on the.pdfWaterfall methodThe model consists of various phases based on the.pdf
Waterfall methodThe model consists of various phases based on the.pdf
aptind
 
The main function of cerebellum is to control the motor movements. H.pdf
The main function of cerebellum is to control the motor movements. H.pdfThe main function of cerebellum is to control the motor movements. H.pdf
The main function of cerebellum is to control the motor movements. H.pdf
aptind
 
Starting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdfStarting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdf
aptind
 
Sexual reproduction has played the most crucial role in evolution of.pdf
Sexual reproduction has played the most crucial role in evolution of.pdfSexual reproduction has played the most crucial role in evolution of.pdf
Sexual reproduction has played the most crucial role in evolution of.pdf
aptind
 
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdfpackage com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
aptind
 
Hi please find my code.import java.util.HashMap;import java.util.pdf
Hi please find my code.import java.util.HashMap;import java.util.pdfHi please find my code.import java.util.HashMap;import java.util.pdf
Hi please find my code.import java.util.HashMap;import java.util.pdf
aptind
 
Given below is the code for the question. Since the test files (ment.pdf
Given below is the code for the question. Since the test files (ment.pdfGiven below is the code for the question. Since the test files (ment.pdf
Given below is the code for the question. Since the test files (ment.pdf
aptind
 
Cisco Systems, Inc Acquisition Integration for manufacturing at.pdf
Cisco Systems, Inc Acquisition Integration for manufacturing at.pdfCisco Systems, Inc Acquisition Integration for manufacturing at.pdf
Cisco Systems, Inc Acquisition Integration for manufacturing at.pdf
aptind
 
As we understand, when soil particles binds to each other more stron.pdf
As we understand, when soil particles binds to each other more stron.pdfAs we understand, when soil particles binds to each other more stron.pdf
As we understand, when soil particles binds to each other more stron.pdf
aptind
 
24. Accomodation - n. Ability of lens to chhange shape diminishes as.pdf
24. Accomodation - n. Ability of lens to chhange shape diminishes as.pdf24. Accomodation - n. Ability of lens to chhange shape diminishes as.pdf
24. Accomodation - n. Ability of lens to chhange shape diminishes as.pdf
aptind
 

More from aptind (20)

ssian chemist, Dmitri Mendeleev is often consider.pdf
                     ssian chemist, Dmitri Mendeleev is often consider.pdf                     ssian chemist, Dmitri Mendeleev is often consider.pdf
ssian chemist, Dmitri Mendeleev is often consider.pdf
 
moles of HCl = 0.1106 x 10 millimoles = 1.106 mil.pdf
                     moles of HCl = 0.1106 x 10 millimoles = 1.106 mil.pdf                     moles of HCl = 0.1106 x 10 millimoles = 1.106 mil.pdf
moles of HCl = 0.1106 x 10 millimoles = 1.106 mil.pdf
 
               CLOUD COMPUTING -----------------------------------.pdf
               CLOUD COMPUTING -----------------------------------.pdf               CLOUD COMPUTING -----------------------------------.pdf
               CLOUD COMPUTING -----------------------------------.pdf
 
You cannot.SolutionYou cannot..pdf
You cannot.SolutionYou cannot..pdfYou cannot.SolutionYou cannot..pdf
You cannot.SolutionYou cannot..pdf
 
ViVi is universally available on Unix systems. It has been around.pdf
ViVi is universally available on Unix systems. It has been around.pdfViVi is universally available on Unix systems. It has been around.pdf
ViVi is universally available on Unix systems. It has been around.pdf
 
Waterfall methodThe model consists of various phases based on the.pdf
Waterfall methodThe model consists of various phases based on the.pdfWaterfall methodThe model consists of various phases based on the.pdf
Waterfall methodThe model consists of various phases based on the.pdf
 
Hi, I am unable to understand the terminology in .pdf
                     Hi, I am unable to understand the terminology in .pdf                     Hi, I am unable to understand the terminology in .pdf
Hi, I am unable to understand the terminology in .pdf
 
The main function of cerebellum is to control the motor movements. H.pdf
The main function of cerebellum is to control the motor movements. H.pdfThe main function of cerebellum is to control the motor movements. H.pdf
The main function of cerebellum is to control the motor movements. H.pdf
 
Starting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdfStarting with Main.java, where I tested everythingimport College..pdf
Starting with Main.java, where I tested everythingimport College..pdf
 
Sexual reproduction has played the most crucial role in evolution of.pdf
Sexual reproduction has played the most crucial role in evolution of.pdfSexual reproduction has played the most crucial role in evolution of.pdf
Sexual reproduction has played the most crucial role in evolution of.pdf
 
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdfpackage com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
 
And is option DIf variable interest rate decrease , asset value wi.pdf
And is option DIf variable interest rate decrease , asset value wi.pdfAnd is option DIf variable interest rate decrease , asset value wi.pdf
And is option DIf variable interest rate decrease , asset value wi.pdf
 
import java.util.Scanner;public class Factorial { method usi.pdf
import java.util.Scanner;public class Factorial { method usi.pdfimport java.util.Scanner;public class Factorial { method usi.pdf
import java.util.Scanner;public class Factorial { method usi.pdf
 
Hi please find my code.import java.util.HashMap;import java.util.pdf
Hi please find my code.import java.util.HashMap;import java.util.pdfHi please find my code.import java.util.HashMap;import java.util.pdf
Hi please find my code.import java.util.HashMap;import java.util.pdf
 
Given below is the code for the question. Since the test files (ment.pdf
Given below is the code for the question. Since the test files (ment.pdfGiven below is the code for the question. Since the test files (ment.pdf
Given below is the code for the question. Since the test files (ment.pdf
 
Cisco Systems, Inc Acquisition Integration for manufacturing at.pdf
Cisco Systems, Inc Acquisition Integration for manufacturing at.pdfCisco Systems, Inc Acquisition Integration for manufacturing at.pdf
Cisco Systems, Inc Acquisition Integration for manufacturing at.pdf
 
As we understand, when soil particles binds to each other more stron.pdf
As we understand, when soil particles binds to each other more stron.pdfAs we understand, when soil particles binds to each other more stron.pdf
As we understand, when soil particles binds to each other more stron.pdf
 
Amount deposited (base amount) = 2000Rate of interest = 5Amount.pdf
Amount deposited (base amount) = 2000Rate of interest = 5Amount.pdfAmount deposited (base amount) = 2000Rate of interest = 5Amount.pdf
Amount deposited (base amount) = 2000Rate of interest = 5Amount.pdf
 
24. Accomodation - n. Ability of lens to chhange shape diminishes as.pdf
24. Accomodation - n. Ability of lens to chhange shape diminishes as.pdf24. Accomodation - n. Ability of lens to chhange shape diminishes as.pdf
24. Accomodation - n. Ability of lens to chhange shape diminishes as.pdf
 
1.They trade away higher fecundity for future reproduction.2.Resou.pdf
1.They trade away higher fecundity for future reproduction.2.Resou.pdf1.They trade away higher fecundity for future reproduction.2.Resou.pdf
1.They trade away higher fecundity for future reproduction.2.Resou.pdf
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Recently uploaded (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 

solution of question no.6inputPresent stateNext stateoutput.pdf

  • 1. solution of question no.6 input Present state Next state output 0 S0 S0 0 1 S0 S1 0 0 S1 S2 0 1 S1 S1 0 0 S2 S3 0 1 S2 S1 0 0 S3 S0 0 1 S3
  • 2. S4 0 0 S4 S2 1 1 S4 S1 1 library ieee; use IEEE.std_logic_1164.all; entity moore is port (clk : in std_logic; reset : in std_logic; input : in std_logic; output : out std_logic ); end moore; architecture behavioral of moore is type state_type is (s0,s1,s2,s3,s4); --type of state machine. signal current_s,next_s: state_type; --current and next state declaration. begin process (clk,reset) begin if (reset='1') then current_s <= s0; --default state on reset. elsif (rising_edge(clk)) then current_s <= next_s; --state change. end if; end process;
  • 3. --state machine process. process (current_s,input) begin case current_s is when s0 => --when current state is "s0" if(input ='0') then output <= '0'; next_s <= s0; else output <= '0'; next_s <= s1; end if; when s1 =>; --when current state is "s1" if(input ='0') then output <= '0'; next_s <= s2; else output <= '0'; next_s <= s1; end if; when s2 => --when current state is "s2" if(input ='0') then output <= '0'; next_s <= s3; else output <= '0'; next_s <= s1; end if; when s3 => --when current state is "s3" if(input ='0') then output <= '1';
  • 4. next_s <= s0; else output <= '0'; next_s <= s4; end if; when s4 => --when current state is "s4" if(input ='0') then output <= '1'; next_s <= s2; else output <= '1'; next_s <= s1; end if; end case; end process; end behavioral; solution of question no.7 input Present state Next state output 0 S0 S1 0 1 S0 S0 0 0 S1 S1 0 1
  • 5. S1 S2 0 0 S2 S3 0 1 S2 S0 0 0 S3 S1 0 1 S3 S2 1 library ieee; use IEEE.std_logic_1164.all; entity mealy is port (clk : in std_logic; reset : in std_logic; input : in std_logic; output : out std_logic ); end mealy; architecture behavioral of moore is type state_type is (s0,s1,s2,s3); --type of state machine. signal current_s,next_s: state_type; --current and next state declaration. begin
  • 6. process (clk,reset) begin if (reset='1') then current_s <= s0; --default state on reset. elsif (rising_edge(clk)) then current_s <= next_s; --state change. end if; end process; --state machine process. process (current_s,input) begin case current_s is when s0 => --when current state is "s0" if(input ='0') then output <= '0'; next_s <= s1; else output <= '0'; next_s <= s0; end if; when s1 =>; --when current state is "s1" if(input ='0') then output <= '0'; next_s <= s1; else output <= '0'; next_s <= s2; end if; when s2 => --when current state is "s2" if(input ='0') then output <= '0'; next_s <= s3;
  • 7. else output <= '0'; next_s <= s1; end if; when s3 => --when current state is "s3" if(input ='0') then output <= '0'; next_s <= s1; else output <= '1'; next_s <= s2; end if; end case; end process; end behavioral; input Present state Next state output 0 S0 S0 0 1 S0 S1 0 0 S1 S2 0
  • 10. 1 S4 S1 1 library ieee; use IEEE.std_logic_1164.all; entity moore is port (clk : in std_logic; reset : in std_logic; input : in std_logic; output : out std_logic ); end moore; architecture behavioral of moore is type state_type is (s0,s1,s2,s3,s4); --type of state machine. signal current_s,next_s: state_type; --current and next state declaration. begin process (clk,reset) begin if (reset='1') then current_s <= s0; --default state on reset. elsif (rising_edge(clk)) then current_s <= next_s; --state change. end if; end process; --state machine process. process (current_s,input) begin case current_s is when s0 => --when current state is "s0"
  • 11. if(input ='0') then output <= '0'; next_s <= s0; else output <= '0'; next_s <= s1; end if; when s1 =>; --when current state is "s1" if(input ='0') then output <= '0'; next_s <= s2; else output <= '0'; next_s <= s1; end if; when s2 => --when current state is "s2" if(input ='0') then output <= '0'; next_s <= s3; else output <= '0'; next_s <= s1; end if; when s3 => --when current state is "s3" if(input ='0') then output <= '1'; next_s <= s0; else output <= '0'; next_s <= s4; end if; when s4 => --when current state is "s4"
  • 12. if(input ='0') then output <= '1'; next_s <= s2; else output <= '1'; next_s <= s1; end if; end case; end process; end behavioral; solution of question no.7 input Present state Next state output 0 S0 S1 0 1 S0 S0 0 0 S1 S1 0 1 S1 S2 0 0 S2 S3
  • 13. 0 1 S2 S0 0 0 S3 S1 0 1 S3 S2 1 library ieee; use IEEE.std_logic_1164.all; entity mealy is port (clk : in std_logic; reset : in std_logic; input : in std_logic; output : out std_logic ); end mealy; architecture behavioral of moore is type state_type is (s0,s1,s2,s3); --type of state machine. signal current_s,next_s: state_type; --current and next state declaration. begin process (clk,reset) begin if (reset='1') then current_s <= s0; --default state on reset. elsif (rising_edge(clk)) then
  • 14. current_s <= next_s; --state change. end if; end process; --state machine process. process (current_s,input) begin case current_s is when s0 => --when current state is "s0" if(input ='0') then output <= '0'; next_s <= s1; else output <= '0'; next_s <= s0; end if; when s1 =>; --when current state is "s1" if(input ='0') then output <= '0'; next_s <= s1; else output <= '0'; next_s <= s2; end if; when s2 => --when current state is "s2" if(input ='0') then output <= '0'; next_s <= s3; else output <= '0'; next_s <= s1; end if;
  • 15. when s3 => --when current state is "s3" if(input ='0') then output <= '0'; next_s <= s1; else output <= '1'; next_s <= s2; end if; end case; end process; end behavioral; input Present state Next state output 0 S0 S0 0 1 S0 S1 0 0 S1 S2 0 1 S1 S1 0 0 S2