Example: Binary Adder We want to construct a finite state machine that will add two numbers. The input is two binary numbers, (xn…x1x0)2 and (yn…y1y0)2.

Slides:



Advertisements
Similar presentations
Adders Used to perform addition, subtraction, multiplication, and division (sometimes) Half-adder adds rightmost (least significant) bit Full-adder.
Advertisements

Regular Expression Manipulation FSM Model
Discrete Math by R.S. Chang, Dept. CSIE, NDHU1 Languages: Finite State Machines Chapter 6 problemsstrings (languages) machines answers.
Modeling Computation Chapter 13.
Lab 08: SR Flip Flop Fundamentals:
Logic Gates Flip-Flops Registers Adders
Chapter #8: Finite State Machine Design 8
ADDER, HALF ADDER & FULL ADDER
Finite-State Machines with No Output Ying Lu
Finite State Machine Continued
Finite State Machines Finite state machines with output
CMPS 3223 Theory of Computation
CS1Q Computer Systems Lecture 12 Simon Gay. Lecture 12CS1Q Computer Systems - Simon Gay 2 Design of Sequential Circuits The systematic design of sequential.
Combinational Circuits. Analysis Diagram Designing Combinational Circuits In general we have to do following steps: 1. Problem description 2. Input/output.
Finite Automata with Output
Finite Automata Section 1.1 CSC 4170 Theory of Computation.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture13: Mapping Reductions Prof. Amos Israeli.
ECE 331 – Digital System Design
1 Lecture 16 FSA’s –Defining FSA’s –Computing with FSA’s Defining L(M) –Defining language class LFSA –Comparing LFSA to set of solvable languages (REC)
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs.
Copyright © Cengage Learning. All rights reserved. CHAPTER 2 THE LOGIC OF COMPOUND STATEMENTS THE LOGIC OF COMPOUND STATEMENTS.
Rosen 5th ed., ch. 11 Ref: Wikipedia
Finite-State Machines with Output
Lecture 23: Finite State Machines with no Outputs Acceptors & Recognizers.
REGULAR LANGUAGES.
Digital Electronics and Computer Interfacing
Decidable Questions About Regular languages 1)Membership problem: “Given a specification of known type and a string w, is w in the language specified?”
Introduction to State Machine
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
Finite State Machines Prof. Sirer COMP 303 Koç University.
CSCI 115 Chapter 8 Topics in Graph Theory. CSCI 115 §8.1 Graphs.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Computer Science 101 More Devices: Arithmetic. From 1-Bit Equality to N-Bit Equality = A B A = B Two bit strings.
Fundamentals of Informatics Lecture 3 Turing Machines Bas Luttik.
TM Design Macro Language D and SD MA/CSSE 474 Theory of Computation.
Finite State Machines 1.Finite state machines with output 2.Finite state machines with no output 3.DFA 4.NDFA.
Computing Machinery Chapter 4: Finite State Machines.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 10 Automata, Grammars and Languages.
Lecture # 15. Mealy machine A Mealy machine consists of the following 1. A finite set of states q 0, q 1, q 2, … where q 0 is the initial state. 2. An.
1 Languages: Finite State Machines Chapter 6 problemsstrings (languages) machines answers.
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
LECTURE 4 Logic Design. LOGIC DESIGN We already know that the language of the machine is binary – that is, sequences of 1’s and 0’s. But why is this?
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
CS151 Introduction to Digital Design Chapter 5: Sequential Circuits 5-1 : Sequential Circuit Definition 5-2: Latches 1Created by: Ms.Amany AlSaleh.
Lecture 22: Finite State Machines with Output. Moore Machine - A Moore machine is a 6-tuple (Q, , , , q 0,  ) where, (1) Q is a finite set of states.
LOGIC CIRCUITLOGIC CIRCUIT. Goal To understand how digital a computer can work, at the lowest level. To understand what is possible and the limitations.
Lecture 14: Theory of Automata:2014 Finite Automata with Output.
Mealy Machines Finite State Machines with Outputs given on the transitions.
Finite Automata (FA) with Output FA discussed so far, is just associated with R.Es or language. Is there exist an FA which generates an output string corresponding.
Finite-State Machines (FSM) Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth Rosen.
Discrete Mathematics and its Applications
Lab. on Finite State Machine
Nondeterministic Finite Automata
Discrete Mathematics and its Applications
§11.2 – Finite State Machines with Output
Logic Gates.
Discrete Mathematics and its Applications
ECE 352 Digital System Fundamentals
Discrete Mathematics and its Applications
Recap lecture 19 NFA corresponding to Closure of FA, Examples, Memory required to recognize a language, Example, Distinguishing one string from another,
Recap lecture 20 Recap Theorem, Example, Finite Automaton with output, Moore machine, Examples.
CSC 4170 Theory of Computation Finite Automata Section 1.1.
Adder and Subtractors Discussion D4.1. Adder and Subtractor Circuits Objective: (i) To construct half and full adder circuit and verify its working (ii)
Finite Automaton with output
Discrete Mathematics and its Applications
Presentation transcript:

Example: Binary Adder We want to construct a finite state machine that will add two numbers. The input is two binary numbers, (xn…x1x0)2 and (yn…y1y0)2 At each step, we can compute (xi+yi) starting with (x0+y0). If (xi+yi)=0, we output 0. If (xi+yi)=1, we output 1. If (xi+yi)=2, we have a problem. The problem is we need a carry bit. In fact, our computation needs to know the carry bit at each step (so we compute xi+yi+ci at each step), and be able to give it to the next step. We can take care of this by using states to represent the carry bit.

Binary Adder States We will use the following states State S0 occurs if the carry bit is 0 State S1 occurs if the carry bit is 1 Since when we begin the computation, there is no carry, we can use S0 as the start state, So, how does which state we are in affect the output? If we are in state S0 (we have a carry of 0) If (xi+yi)=0, we output 0, and stay in state S0 If (xi+yi)=1, we output 1, and stay in state S0 If (xi+yi)=2, we output 0, and go to state S1 If we are in state S1 (we have a carry of 1) If (xi+yi +1)=1, we output 1, and go to state S0 If (xi+yi +1)=2, we output 0, and stay in state S1 If (xi+yi +1)=3, we output 1, and stay in state S1

Binary Adder State Table/Diagram From the previous observations, we can construct the state table and state diagrams for the binary adder Next State Output Input State 00 01 10 11 S0 S1 1

Construct a state table for the finite-state machine in Fig. 3. Input, output Find the output string for the input 101011 Answer: 001000 001000 Output of 101011?

Example: Unit Delay In some electronic devices, it is necessary to use a unit-delay machine. That is, whatever is input into the machine should be output from the machine, but delayed by a specific amount of time. For instance, given a string of binary numbers x1, x2, ……, xn, the machine should produce the string 0, x1, x2, …, xn-1. We want to use a finite state machine to model the behavior of a unit-delay machine. What should a state in this machine represent? One possibility is that a state represents the last input bit. Thus we need a state for “1” and a state for “0”. We also need start state.

Unit Delay States We will use the following states (that memorize last bit; except S0) State S0 is the start state State S1 occurs if the previous input was 1 State S2 occurs if the previous input was 0 We can easily construct the state table for the unit delay machine by realizing that When the input is 0, we always transition to state S2 When the input is 1, we always transition to state S1 When we are in state S1 we always output 1 (since the previous input was 1) When we are in state S2 we always output 0 (since the previous input was 0) When we are in state S0 we always output 0 (since we always output 0 first)

Unit Delay State Table/Diagram Here is the state table and state diagram based on our previous observations. Next State Output Input State 1 S0 S2 S1 What’s output of 101011?

Language Recognizer We want to construct an FSM that outputs 1 iff the string read so far has 111. S0 – this state remembers that the previous input value (if it exists) was not a 1 S1 – this state remembers that the previous input value was a 1, but the input before (if it exists) was not a 1 S2 – this state remembers that the previous two input values were 1

Language Recognizer S0 S1 S2 0,0 1,1 1,0 S0 – this state remembers that the previous input value (if it exists) was not a 1 S1 – this state remembers that the previous input value was a 1, but the input before (if it exists) was not a 1 S2 – this state remembers that the previous two input values were 1 This finite-state machine recognizes the set of bit strings that end in 111.

FSM as a Language Recognizer Definition: Let M=(S, I, O, f, g, S0) be a FSM and L  I*. We say that M recognizes (or accepts) L, iff for any input string x that belongs to L, M produces a 1 as an output

In-Class Exercise 1. Construct a finite-state machine that changes every other bit, starting with the second bit, of an input string, and leaves the other bits unchanged. 2. Construct a finite-state machine that gives an output of 1 if the number of bits read so far is divisible by 3 and an output of 0 otherwise. 3. Construct a finite-state machine that determines whether the input string has a 0 in the third to the last position read so far. (For instance, the output for the input string 00001011 is: 00111101)