Professional Documents
Culture Documents
Anish Chatterjee Digital Design & Fundamentals Theory of Computer Architecture Prof. Daniel Tylavsky Arizona State University April 2006
Objective
The purpose of this Capstone Design Project was to develop a synchronous machine that uses the transmitted data as input and then produces an output the negative of the input number by performing the twos complement operation on the incoming data. My project determines the application usage of finite state machines specifically in FSM Logic & Hardware applications, more specifically in any digital circuit, an FSM can be built using a programmable logic device, a programmable logic controller, logic gates and flip flops or relays. In order to implicate output based on a given input and/or a state using actions, two FSM Transducer models are constructed; moore & mealy machine to determine the best possible finite state machine implementation. As such the project is designed to gain experience in building a synchronous state machine model using the classical design techniques like state diagrams, state definition tables and Karnaugh maps. At the end of this project, the following guidelines of digital design fundamentals were achieved. Using classical design techniques (i.e. state diagrams, state transition table, and Karnaugh maps) to devise a synchronous sequential machine starting with a functional specification. Making scientific assumptions to complete an incomplete functional specification. Build and debug a synchronous sequential machine. Develop reasonable engineering criteria for comparing different designs. Apply engineering criteria to select the best design.
Designing Two Synchronous Sequential Finite State Machines (Analogous Digital Circuits)
The design implementation was set in motion by constructing two synchronous sequential machines that can perform the necessary twos complementary function. The circuit should have two 1-bit inputs: Data and Sync; and it should also have one 1-bit output for the twos complement of Data. The circuit also has a Clock signal which synchronizes all the basic functional actions within any particular electronic
Fig 1.1 A typical Clock Cycle medium, including flow of data due to changes in signal which is proportionate to time. Our prototype circuit can also become active at either the rising edge, falling edge, or both edges of this associated clock cycle (Fig 1.1). When Sync is 1, the data entered is recognized as a new potential word and the circuit starts the twos complementary function and Sync is made 0 until a new word is to be entered. The twos complementary function is performed such that starting with the LSB and moving toward the MSB, transcribe all zeroes until we reach the first 1; transcribe that 1 then complement every bit after that. The following table implements a few data input and output values which would give the readers a better understanding of testing which was carried out.
Then we will copy that 1, and complement all bits more significant than it. The following state diagram (Fig. 1.2) describes a finite state machine with one input X and one output Z. The FSM asserts its output Z when it recognizes the following input bit sequence: "1011". The machine will keep checking for the proper bit sequence and does not reset to the initial state after it has recognized the string. The output will assert only when it is in state S4 (after having seen the sequence 1011). The FSM is thus a Moore machine. .
0,0,1 Moore Programmatic Representation 0,1,0 0,1,1 1,0,0 A programmatic representation of Moore machine implementation of the sequence detector module is as follows Module Seqdetect1 Title 'Moore Machine Sequence Detector' Declarations "input and output signals" X, CLOCK, RST PIN; Z PIN istype 'com'; Q2, Q1, Q0 PIN istype 'reg'; "State register declarations
Fig 1.3 Binary State Transition Table actions, i.e. when you transition into the state, the output corresponding to the state is only produced. The first step in building this circuit was making some basic assumptions that are needed to make the problem easier. In order to perform the twos complement we will use a simplified method to make the twos complement. Starting with the least significant bit, copy all bits until we reach the first 1.
SREG = [Q2,Q1,Q0]; S0 = [0,0,0]; S1 = [0,0,1]; S2 = [0,1,0]; S3 = [0,1,1]; S4 = [1,0,0]; "State machine clock signal Equations" [Q2,Q1,Q0].AR = RST; [Q2,Q1,Q0].CLK = CLOCK; "Define state diagram STATE_DIAGRAM SREG STATE S0: Z=0; IF X THEN S1 ELSE S0; STATE S1: Z=0; IF X THEN S1 ELSE S2; STATE S2: Z=0; IF X THEN S3 ELSE S0; STATE S3: Z=0; IF X THEN S4 ELSE S2; STATE S4: Z=1; IF X THEN S1 ELSE S2; end Seqdetect1
Present State S0 S0 S0 S0 S1 S1 S1 S1 S2 S2 S2 S2 S3 S3 S3 S3
Next State S0 S0 S3 S1 S1 S2 S3 S1 S1 S2 S3 S1 S3 S1 S3 S1
QB
QA
QB+
QA+
JB
KB
JA
KA
Output
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
0 0 1 0 0 1 1 0 0 1 1 0 1 0 1 0
0 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1
0 0 1 0 0 1 1 0 X X X X X X X X
X X X X X X X X 1 0 0 1 0 1 0 1
0 0 1 1 X X X 1 0 1 1 X X X X X
X X X X 0 1 0 X X X X 0 0 0 0 0
0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0
QB,QA/S,D 00 01 11 10
00 0 0 X X
01 0 1 X X
11 0 0 X X
10 1 1 X X
QB,QA/S,D 00 01 11 10
00 0 1 0 0
01 0 1 0 0
11 0 1 0 0
10 0 1 0 0
JB = SD+QASD QB,QA/S,D 00 01 11 10 00 X X 0 1 01 X X 1 0 11 X X 1 1 10 X X 0 0
Output= QBQA
KB=SD+QAD+QASD QB,QA/S,D 00 01 11 10 00 0 X X 1 01 0 X X 0 11 1 X X 1 10 1
Clock S
1 0 D 1 0
X X
+5V +5V DEV1 QB Clock J Q C K R Q Res et S S Clock DEV1 QB J Q C QB' K R Q Res et
JA= S+ QBD The matrix groups which are generated are converted to a Boolean expression by locating and thus transcribing the variable formally attributed to the matrix box by various axiom laws of Boolean algebra.
QB' 0 QB'
Fig 1.8 A diagrammatic circuit representation of the Moore machine using LABView & LogicWorks.
C has been split into two Moore states, one (C) with output 0, and one (E) with output 1. and does not reset to the initial state. When the machine is in the state D, the output will go high Fig 2.2 Mealy State Transition Diagram
Given below are the transition sequence numbers which the state remembers
Fig 2.1 Binary State Transition Table The following state diagram describes a finite state machine with one input X and one input Z. The FSM asserts its output Z when it recognizes the following input bit sequence 1011. The machine will keep checking for the bit sequence after the arrival of a "1" at the input. On comparing both the state diagrams it is clearly noticed that state E of the Moore machine is equivalent to state C in the Mealy diagram; Mealy state
"Define state diagram STATE_DIAGRAM SREG STATE S0: IF X THEN S1 ELSE S0; STATE S1: IF X THEN S1 ELSE S2; STATE S2: IF X THEN S3 ELSE S0; STATE S3: IF X THEN S1 WITH Z=1; ELSE S2; end Seqdetect2
S 0 0 1 1 0 D 0 1 0 1 0 1 0 1 0 1 0 1
QB S0 S0 S0 S0 S1 S1 S1 S1 S2 S2 S2 S2 S0 S1 S0 S1 S1 S2 S0 S1 S2 S2 S0 S1 0 0 0 0 0 0 0 0 1 1 1 1
QA 0 0 0 0 1 1 1 1 0 0 0 0
JB 0 0 0 0 0 1 0 0 X X X X
KB X X X X X X X X 1 0 1 1
JA 0 1 0 1 X X X X 1 0 0 1
KA X X X X 0 1 1 0 X X X X 0 1 0 1 1 0 0 1 1 0 0 1
Initially, we're in state 00, with an output of 0. Unlike the Moore machine, a Mealy machine's output doesn't depend on the current state. From the (Fig 2.1) we notice that in state 00, we see an input of a 1. This takes us to state 01, with an output of 1. Reading the second column of numbers, we see 0 and a 1 (which is state 01, q1q0), followed by a 1 (which is the output z).
1 1 0 0 1 1
Next, the state transition table for the mealy machine was obtained to check for the input & output differences based on the state transitions. Fig 2.3 Mealy Timing Sequence
QB,QA/S,D 00 01 11 10
00 0 0 X X
01 0 1 X X
11 0 0 X X
10 0 0 X X
QB,QA/S,D 00 01 11 10
00 0 1 X 1
01 1 0 X 0
11 1 1 X 1
10 0 0 X 0
Output= SD+QASD+QBSD+QBQAD JB= QA+S+D Fig 2.6 A diagrammatic circuit representation of the Moore machine using LABView & LogicWorks.
QB,QA/S,D 00 01 11 10
00 0 X X 1
01 1 X X 0
11 1 X X 1
10 0 X X 0
QB S S D A
+5V
S J Q C K R Q Res et
QB
KB=S+D
D S
QB,QA/S,D 00 01 11 10
00 X X X 1
01 X X X 0
11 X X X 1
10 X X X
QB
1 0 1 0 1 0 1 0
S D S QA
CR Q
1
D
JA=SD+QBSD+QBQAD
Finally, the circuit was physically built (along with the moore machine) in the lab to authenticate test results in the presence of the professor in charge of the project along with a teaching assistant. The following results were obtained for the output which was authenticated by the professor proving that the circuit worked without any glitches. . Sync 1 0 0 0 0 0 0 1 0 0 0 0 0 Data 0 0 0 1 1 0 1 1 1 0 0 1 0 Output 0 0 0 1 0 1 0 1 0 1 1 0 1
quality. While a moore model is often very easy to code, the transition may be often implemented just by constants as initialized tables. The mealy model on the other hand becomes very complex due to the amount of coding required to build the adjoining state machine. Although the Mealy machine results in the reduction of the number of states, my design logic and hypothesized experiments have led me to prefer the moore machine for hardware applications.
Conclusion:
Even though I prefer the mealy machine based on the justifications stated, it is noticeable that both the state machines are arbitrarily equivalent. A mealy state machines output depends on both input and state, so if we ignore the state, we should be able to convert a Moore machine to a Mealy machine. Hence, if both machines are fed the same sequence of inputs, they will both produce the same sequence of outputs. Since Moore machines generate output even if no input has been read in, by ignoring this initial output of the Moore machine we can convert between one machine and the other. On the other hand a Mealy machine can be converted to a Moore machine by increasing the number of states. For e.g. If we have a Mealy machine with N states, and there are k bits of input, we would need up to 2kN states in the equivalent Moore machine.
Acknowledgements
This work and its contents were supported in part by Prof. Daniel Tylavsky, Associate Prof. Basam Matar and several other senior teaching assistants from the department of computer and electrical engineering in the IRA Fulton School of Engineering Studies I am also gratefully thankful to several librarians in the Nobel Science Engineering Library for providing me aid in my research throughout this capstone project.
References
[1] Holdsworth, Bryan & Woods, Clive; Practical Digital Logic Design and Testing, 6th edition Prentice Hall, 2004. [2] Katz, R.H Contemporary Logic Design in Sequential Electronic Circuits & Finite State, 5th edition, The Benjamin/Cummings Publishing Company, 2003. [3] Booth, Taylor L. (1994). Sequential Machines and Automata Theory (10th ed.). New York: John Wiley and Sons, Inc. [8] Roth, Charles H., Jr. (2004). Fundamentals of Logic Design. Thomson-Engineering, 364-367. ISBN 0534378048. [9] Mealy, G.H. (September 1955). "A Method for Synthesizing Sequential Circuits". Bell System Tech. J. 34: 10451079 [10] Hopcroft, John and Ullman, Jeffrey (1979) Intro to Automata Theory, Languages, and Computation, Addison-Wesley Publishing Company, Reading Mass, ISBN 0-20102988-X [11] Sipser, Michael Introduction to the Theory of Computation. PWS, Boston. 1997. Section 1.1: Finite Automata, pp.3147 [12] Hopcroft, John E.; Rajeev Motwani, Jeffrey D. Ullman (2001). Introduction to Automata Theory, Languages, and Computation (2nd ed.). Reading Mass: Addison-Wesley. ISBN 0201441241.
[4] Kohavi, Z., Switching and Finite Automata Theory. McGraw-Hill, 1978 [5] Wagner, F., "Modeling Software with Finite State Machines: A Practical Approach", Auerbach Publications, 2006, ISBN 0-84938086-3. [6] Timothy Kam, Synthesis of Finite State Machines: Functional Optimization. Kluwer Academic Publishers, Boston 1997, ISBN 07923-9842-4 [7] Samek, M., Practical UML Statecharts in C/C++, 1st Edition, Newnes, 2006, ISBN 075068-706-1.