π Lecture 33 β State Assignment
π Overview: This lecture explores the process of assigning binary codes to states in sequential circuits to minimize the complexity of combinational logic. It demonstrates with detailed examples that different state assignments yield different Boolean expressions, and provides guidelines for selecting optimal assignments. The lecture also presents Moore and Mealy machine implementations for the same state diagram.
ποΈ Topics Covered
The lecture covers state assignment concepts and guidelines for sequential circuits, including three different state assignments for a six-state machine and their resulting flip-flop input tables and Karnaugh maps. It then presents a complete Moore Machine design from state diagram through J-K flip-flop implementation with timing diagrams, followed by a parallel Mealy Machine design showing the differences in state diagram, next-state tables, and output implementation.
π Lecture Summary
State Assignment
Each state in a sequential circuit is identified by a unique combination of binary bits. Unless the output is directly taken from flip-flop outputs (as in counters), states can be selected to allow minimum bit changes when changing from one state to another. Keeping bit changes to a minimum results in simpler combinational circuits that determine the next state.
π Definition β State Assignment: The process of assigning unique binary codes to each state in a sequential circuit to minimize the complexity of the next-state and output logic.
Three possible state assignments for states a, b, c, d and f are shown:
| State | Assignment 1 | Assignment 2 | Assignment 3 |
|---|---|---|---|
| a | 000 | 001 | 000 |
| b | 001 | 010 | 001 |
| c | 010 | 011 | 011 |
| d | 011 | 100 | 010 |
| f | 100 | 110 | 110 |
Table 33.1 Three possible state assignments
For State Assignment 1, the D flip-flop input table (Table 33.2a) and Karnaugh maps (Table 33.2b) yield:
- Dβ = QβQβQβx + QβQβX
- Dβ = Qβ + QβX + QβQβ
- Dβ = QβQβX + QβQβX + QβQβX + QβQβQβX
For State Assignment 2, (Table 33.3a, 33.3b):
- Dβ = QβQβx + QβQβX + QβQβX + QβQβX
- Dβ = QβQβ + QβQβ + QβX + QβX
- Dβ = QβQβX + QβQβX + QβQβX
For State Assignment 3, (Table 33.4a, 33.4b):
- Dβ = QβQβx + QβQβX
- Dβ = Qβx + QβX + QβQβ
- Dβ = QβQβQβx + QβX + QβQβ + QβX
The third State Assignment is shown to have simpler input Boolean expressions leading to a simpler combinational circuit.
Guidelines for State Assignment:
- Choose an initial coded state into which the state machine can easily be forced to reset (000 or 111)
- Minimize the State Variables that change on each transition
- Maximize the number of state variables that don't change in a group of related states
- If there are unused states, choose the best state variable combinations to achieve the first three goals
Moore Machine State Diagram
The state diagram of a Moore Machine is shown (Figure 33.1). The Clocked Synchronous Sequential Circuit has six states. On each clock transition the machine sequences through the states 011, 111, 001, 010, 100 and 110. The outputs of the flip-flops represent the sequential circuit output.
Next-State Table (Moore Machine)
The Next-State table (Table 33.5) is derived from the State diagram:
| Present State | Next State |
|---|---|
| 011 | 111 |
| 111 | 001 |
| 001 | 010 |
| 010 | 100 |
| 100 | 110 |
| 110 | 011 |
Karnaugh Maps (Moore Machine)
The J-K flip-flop input table (Table 33.6) uses the J-K flip-flop transition table to determine inputs. The Karnaugh maps (Table 33.7a-c) yield:
- Jβ = Qβ, Kβ = Qβ
- Jβ = 1, Kβ = QβQβ + QβQβ
- Jβ = QβQβ, Kβ = Qβ
Implementation (Moore Machine)
The circuit and timing diagram (Figure 33.2) shows the State Machine. The sequential circuit is assumed to be reset to state 011. At interval tβ, J-K input of the first flip-flop is set at 0 and 0 respectively; therefore at the clock transition the output of the first flip-flop remains unchanged. The J input of the second flip-flop is permanently connected to logic 1, the K input is set at logic 0, therefore the output of the second flip-flop is set to logic 1 at the clock transition tβ. The J-K input of the third flip-flop is set to logic 1, at clock transition tβ the output of the flip-flop changes to logic 1.
π‘ Why this matters: The Moore Machine outputs depend only on the present state (flip-flop outputs), making them stable between clock transitions but requiring more states for sequential problems.
Mealy Machine State Diagram
The sequential circuit represented earlier as a Moore Machine is described as a Mealy Machine (Figure 33.3). The output of a Mealy machine depends upon the present state at the inputs. The state diagram shows six states. When the input is 1, the machine switches from its present state to the next. If the input is 0, the machine remains in its present state.
Next-State Table (Mealy Machine)
The Next-State table (Table 33.8) shows present state, next state for X=0 and X=1, and outputs for each input condition:
| Present State | Next State (X=0) | Next State (X=1) | Output (X=0) | Output (X=1) |
|---|---|---|---|---|
| a | a | b | 011 | 111 |
| b | b | c | 111 | 001 |
| c | c | d | 001 | 010 |
| d | d | e | 010 | 100 |
| e | e | f | 100 | 110 |
| f | f | a | 110 | 011 |
State Assignments (Mealy Machine)
Based on guidelines, states are assigned keeping bit changes to minimum (Table 33.9):
| Present State | Next State (X=0) | Next State (X=1) |
|---|---|---|
| 000 | 000 | 001 |
| 001 | 001 | 011 |
| 011 | 011 | 010 |
| 010 | 010 | 110 |
| 110 | 110 | 100 |
| 100 | 100 | 000 |
Karnaugh Maps (Mealy Machine)
The J-K flip-flop input tables (Table 33.10a-b) and Karnaugh maps (Table 33.11a-d) yield:
- Jβ = QβQβX, Kβ = QβX
- Jβ = QβX, Kβ = QβX
- Jβ = QβQβX, Kβ = QβX
- Oβ = QβX + QβQβ + QβQβX + QβQβX
- Oβ = QβQβX + QβQβX + QβX + QβQβ + QβX
- Oβ = QβX + QβQβ + QβX
Implementation (Mealy Machine)
The machine is assumed to be reset to state 'a' 000. At interval tβ, J-K inputs of the first flip-flop are set at logic 1 and 0 respectively, therefore at the clock transition the output of the first flip-flop switches from 0 to 1. The J-K inputs of the second flip-flop are set at logic 0 and 0 respectively, thus the output state of the second flip-flop remains unchanged. The J-K inputs of the third flip-flop are set to logic 0 and 1 respectively, thus at clock transition tβ the flip-flop is reset to logic 0.
At interval tβ, before the clock transition, Qβ, Qβ and Qβ outputs are set at logic 0, 0 and 0 respectively. When the X input is logic 0, the output of Boolean expressions for Oβ, Oβ and Oβ is 0, 1 and 1 respectively. At the clock transition tβ when the X input is set to 1, the outputs Oβ, Oβ and Oβ are set to 1, 1 and 1.
π‘ Why this matters: The Mealy Machine outputs depend on both present state AND inputs, often requiring fewer states than a Moore machine for the same task, but outputs can change asynchronously with input changes.
β Key Takeaways
State assignment is a critical design step that directly impacts the complexity of combinational logic in sequential circuits, with different assignments producing drastically different Boolean expressions. The third state assignment demonstrated simpler logic than the other two, following guidelines of minimizing bit changes between states and maximizing unchanged state variables. Both Moore and Mealy machines can implement the same state diagram, but Moore outputs depend only on the present state while Mealy outputs depend on both present state and inputs, making Mealy potentially more compact but with timing differences. J-K flip-flop implementations for both machines were fully derived from state diagrams through next-state tables and Karnaugh maps, showing the complete design process from specification to circuit implementation.
π§ Quick Revision Questions
- What are the four guidelines for selecting an optimal state assignment in sequential circuits?
- How does the third state assignment produce simpler Boolean expressions compared to the first two?
- What is the key difference between Moore and Mealy machine outputs in terms of what they depend on?
- In the Moore machine example, what is the sequence of states (starting from 011) and what are the J-K input expressions for each flip-flop?
- For the Mealy machine, why does the output change when input X changes even before the clock transition occurs?
π Lecture 34 β SHIFT REGISTERS
π Overview: This lecture covers the storage and shifting of binary data using shift registers built from multiple flip-flops. It explains different shift operations and register configurations, including serial and parallel data movement, bidirectional shifting, and specialized counter circuits like the Johnson and Ring counters, which are fundamental in digital systems for data manipulation and timing.
ποΈ Topics Covered
This lecture covers seven shift operations (Serial In/Shift Right/Serial Out, Serial In/Shift Left/Serial Out, Serial In/Parallel Out, Parallel In/Serial Out, and Parallel In/Parallel Out), bidirectional shift registers, rotate operations (right and left), and shift register counters including the Johnson Counter and Ring Counter with their specific circuit configurations and state sequences.
π Lecture Summary
Lesson No. 34 - SHIFT REGISTERS
A flip-flop stores a single binary bit. Multiple bits are stored using multiple flip-flops with their clock inputs connected together. A register performs two basic functions: it stores data and it moves or shifts data. The shifting of data involves moving bits from one flip-flop to another within the register or moving data in and out. The shift operation is carried out by applying clock signals.
1. Serial In/Shift Right/Serial Out Operation
Data is shifted in the right-hand direction one bit at a time with each transition of the clock signal. Data enters the shift register serially from the left-hand side. After four clock transitions, the 4-bit register has 4 bits of data. Data is shifted out serially one bit at a time from the right-hand side if clock signals are continuously applied. Thus, after 8 clock signals, the 4-bit data is completely shifted out.
π Definition β Serial In/Shift Right/Serial Out: A shift register operation where data enters one bit at a time from the left and exits one bit at a time from the right.
2. Serial In/Shift Left/Serial Out Operation
Data is shifted in the left-hand direction one bit at a time with each transition of the clock signal. Data enters the shift register serially from the right-hand side. After four clock transitions, the 4-bit register has 4 bits of data. Data is shifted out serially one bit at a time from the left-hand side. Thus, after 8 clock signals, the 4-bit data is completely shifted out.
A Serial Shift register can be implemented using any type of flip-flops, such as D flip-flops. At each clock transition, 1 bit of serial data is shifted in and 1 bit of serial data is shifted out. As data is shifted out, a logic 0 value is usually shifted in to fill the vacant bits.
Bidirectional Shift Registers allow data to be shifted left or right. This is configured by setting the RIGHT / LEFT signal to logic high or low. When configured to shift right, AND gates marked 1 are enabled, connecting the input of the first flip-flop to the Serial Input, and the inputs of the next three flip-flops to the Q outputs of the previous flip-flops. Serial data is shifted out through output Qβ. When configured to shift left, AND gates marked 2 are enabled, connecting Q outputs of the right-hand flip-flop to the D input of the left-hand flip-flop. Serial data out is available through the Qβ output.
π Definition β Bidirectional Shift Register: A shift register that can be configured to shift data either left or right based on a control signal.
3. Serial In/Parallel Out Operation
Data is shifted in one bit at a time with each clock transition. After four clock transitions, the 4-bit register has 4 bits of data. The data is shifted out in parallel by the application of a single clock signal. The shift register has 4 parallel outputs.
The 74HC164 is an MSI 8-bit Serial In/Parallel Out Shift Register. It has 8 parallel outputs, an Asynchronous Active-low CLR input, and is triggered on the positive clock transition. Serial data is applied through inputs A and B, which are internally connected through an internal NAND gate. Setting one input to logic high enables the shift operation. The register is cleared asynchronously by activating the active-low CLR input.
π Definition β Serial In/Parallel Out: A shift register operation where data enters one bit at a time and is available simultaneously on all outputs after the register is full.
4. Parallel In/Serial Out Operation
The register has parallel inputs. Data bits are loaded into the register in parallel by activating a load signal. Data is shifted out serially by application of clock signals. In a 4-bit shift register, after 4 clock signals, the 4-bit data is completely shifted out.
Data is initially loaded in Parallel by setting the SHIFT / LOAD input to logic low, enabling AND gates marked 2 to apply data to the D inputs of the flip-flops. On a positive clock transition, the data is latched. To shift, SHIFT / LOAD is set to logic high, enabling AND gates marked 1, which connect the Q output of each flip-flop to the D input of the next flip-flop.
The 74HC165 is an 8-bit Parallel In/Serial Out register that can also work as a Serial In/Serial Out register. Parallel data is loaded asynchronously using the Asynchronous Set/Clear Inputs. The clock signal is enabled by setting the CLK INH signal to logic low.
π Definition β Parallel In/Serial Out: A shift register operation where all data bits are loaded simultaneously and then shifted out one bit at a time.
5. Parallel In/Parallel Out Operation
The register has parallel inputs and parallel outputs. Data is entered in parallel by applying a single clock pulse. Data is latched by the flip-flops on the clock transition and is available in parallel form at the flip-flop outputs. This register stores parallel data and usually does not allow any shift operations.
The 74HC195 is a 4-bit Parallel In/Parallel Out Register. It also has a Serial In input, allowing it to be used as a Serial In/Parallel Out or Serial In/Serial Out register. The J and K inputs are used to input data serially. The SH/ LD pin is used to load parallel data and allow shift operations.
The 74HC194 is a 4-bit Bidirectional Shift register that shifts data left and right and has both Parallel and Serial input/output capability. The Sβ and Sβ inputs control the operation. When both are at logic high, the register loads parallel data. When Sβ is high, shift right operation is carried out with serial data through the SR SER input. When Sβ is high, shift left operation is carried out with serial data through the SL SER input. When both are logic low, the register is inhibited.
π Definition β Universal Shift Register: A shift register that can perform multiple operations including parallel load, shift left, shift right, and hold, controlled by mode select inputs.
6. Rotate Right Operation
The serial output of the register is connected to the serial input of the register. By applying clock pulses, data is shifted right. The data shifted out of the serial out pin at the right-hand side is re-circulated back into the shift register input at the left-hand side. Thus, the data is rotated right within the register.
7. Rotate Left Operation
The serial output of the register is connected to the serial input of the register. By applying clock pulses, data is shifted left. The data shifted out of the serial out pin at the left-hand side is re-circulated back into the shift register input at the right-hand side. Thus, the data is rotated left within the register.
Shift Register Counters
Shift register counters are shift registers connected to perform rotate left and rotate right operations. When data is rotated through a register counter, a specific sequence of states is repeated. Two commonly used register counters are the Johnson Counter and the Ring Counter.
1. Johnson Counter
In a Johnson counter, the Q output of the last flip-flop of the shift register is connected to the data input of the first flip-flop. The sequence of states implemented by an n-bit Johnson counter is 2n. A 4-bit Johnson counter sequences through 8 states.
π Formula: Number of states = 2n for an n-bit Johnson counter
π Example: For a 4-bit Johnson counter, the sequence is: 0000 β 1000 β 1100 β 1110 β 1111 β 0111 β 0011 β 0001
| Clock Pulse | Qβ | Qβ | Qβ | Qβ |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 |
| 2 | 1 | 1 | 0 | 0 |
| 3 | 1 | 1 | 1 | 0 |
| 4 | 1 | 1 | 1 | 1 |
| 5 | 0 | 1 | 1 | 1 |
| 6 | 0 | 0 | 1 | 1 |
| 7 | 0 | 0 | 0 | 1 |
2. Ring Counter
The Ring Counter is similar to the Johnson counter, except that the Q output of the last flip-flop is connected to the data input of the first flip-flop. All flip-flops are cleared to logic low except for the first flip-flop, which is preset to logic high. After initialization, the logic high is shifted right at each clock transition. With a Ring Counter, no decoding gates are required because each state has a unique output.
π Example: For a 4-bit Ring Counter, the sequence is: 1000 β 0100 β 0010 β 0001
| Clock Pulse | Qβ | Qβ | Qβ | Qβ |
|---|---|---|---|---|
| 0 | 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 |
| 2 | 0 | 0 | 1 | 0 |
| 3 | 0 | 0 | 0 | 1 |
β Key Takeaways
A shift register is a fundamental digital circuit that stores and moves binary data, with operations classified by how data enters (serial or parallel) and exits (serial or parallel). Bidirectional shift registers like the 74HC194 allow data movement in both directions using control signals, while universal shift registers can perform multiple operations including parallel load, shift left, shift right, and hold. Rotate operations recirculate data by connecting output back to input, forming the basis for shift register counters. The Johnson counter produces 2n states and the Ring counter produces n states, each following a distinct state sequence that is critical for understanding timing and sequencing in digital systems.
π§ Quick Revision Questions
- How many clock transitions are required to completely shift in and shift out a 4-bit word using a Serial In/Serial Out shift register?
- What is the difference between a Johnson counter and a Ring counter in terms of how the output of the last flip-flop is connected to the input of the first flip-flop?
- In the 74HC164 8-bit Serial In/Parallel Out shift register, what is the function of the two inputs A and B?
- How does the SHIFT/LOAD signal control the operation of a Parallel In/Serial Out shift register?
- What is the state sequence for a 4-bit Johnson counter and how many states does it have?
π Lecture 35 β Applications of Shift Registers
π Overview: This lecture examines practical applications of shift registers, including serial-to-parallel conversion for asynchronous data transmission and keyboard encoding. It also introduces programmable sequential logic using PLD devices, specifically how to configure GAL22V10 devices for registered modes to implement shift registers and registers in hardware description languages like ABEL.
ποΈ Topics Covered
The lecture covers serial-to-parallel converters using shift registers for asynchronous serial data transmission with start and stop bits, keyboard encoder circuits using ring counters for row-column scanning, programmable sequential logic using PLD devices in registered mode, software mode specification using ISTYPE statements and dot extensions in ABEL, and three detailed examples: an 8-bit parallel I/O register with inverted outputs, an 8-bit serial in/parallel out shift register, and a 4-bit parallel in/serial out shift register.
π Lecture Summary
1. Serial-to-Parallel Converter
In Asynchronous Serial data transmission, an 8-bit character is transmitted with additional start and stop bits. A start bit (logic low) precedes the character to indicate data is coming, and stop bits (two logic high bits) follow to mark the end and return the line to idle. A total of 11 bits are transmitted per character: 1 start bit, 8 data bits, and 2 stop bits. The serial-to-parallel converter uses a J-K flip-flop triggered by the start bit, which enables a clock generator. The clock drives a Serial In/Parallel Out shift register and an 8-bit counter. When the counter reaches terminal count 111, it triggers a One-Shot that loads parallel data into a Parallel In/Parallel Out register and resets the system.
π Definition β Asynchronous Serial Data Transmission: A method where data is sent one bit at a time without a shared clock, using start and stop bits to frame each character.
π Example: Transmitting character "A" (binary 01000001) requires the sequence: 0 (start), 01000001 (data), 1, 1 (stop) = 11 bits total.
π‘ Why this matters: The start/stop bit framing allows receivers to synchronize with incoming data without needing a separate clock line, which is essential for UART communication in computers and microcontrollers.
2. Keyboard Encoder
A keyboard encoder regularly scans keys organized in rows and columns using a shift register based ring counter. The ring counter sequences through a bit pattern with all 1's and a single 0, selecting one row at a time by setting it to logic 0. When a key is pressed, the corresponding column also becomes logic 0. Row and column encoders encode the position. A NAND gate detects the column going low and triggers two One-Shots: the first inhibits the clock to the ring counter, and the second sends a pulse to the Key Code Register to store the 3-bit row and 3-bit column key ID.
π Definition β Ring Counter: A shift register configured to circulate a single 0 (or 1) pattern, used for sequential selection in scanning applications.
π‘ Why this matters: This scanning method reduces the number of connections needed for keyboards with many keys compared to direct encoding, making it practical for full-size computer keyboards.
Programmable Sequential Logic
PLD devices can implement sequential circuits by using the AND-OR array for excitation inputs and a flip-flop in each OLMC (Output Logic Macro Cell) module as the memory element. The present state output feeds back to the AND array. The output is obtained from a tri-state buffer connected to the PLD output pin.
The Registered Mode
In the Registered Mode, the OLMC is configured by setting MUX select inputs S1 and S0 to 01 or 00. With S1=0 and S0=1, the Q output of the D flip-flop is routed through the MUX to the tri-state buffer. Feedback to the AND gate array comes from the Q output, not the tri-state buffer output. Setting S1=0 and S0=0 connects the Q output (inverted) to the output while feedback remains from Q.
Software Mode Specification
The ISTYPE statement in ABEL declares whether an output is 'Registered' or 'Combinational'. The dot extension .CLK indicates a clocked flip-flop. Assignment operators := and :> indicate registered outputs, while = indicates combinational outputs.
π Definition β ISTYPE: An ABEL declaration statement specifying the output mode of a PLD pin as 'reg' (registered), 'com' (combinational), 'reg.buffer' (active-high registered), or 'reg.invert' (active-low registered).
π Formula: X := D; β "X gets the value of D on the clock transition"
π Formula: X.CLK = Clock; β "X is clocked by the signal named Clock"
Example1: Parallel Input/Parallel Output 8-bit Register with inverted outputs
An 8-bit D flip-flop based register with inverted outputs using GAL22V10:
Clock, D0..D7 PIN 1, 2, 3, 4, 5, 6, 7, 8, 9;
Q0..Q7 PIN 22, 21, 20, 19, 18, 17, 16, 15 ISTYPE 'reg.invert';
[Q0..Q7] := [D0..D7];
[Q0..Q7].CLK = Clock;
Example2: 8-bit Serial In/Parallel Out Shift Register
ABEL implementation using GAL22V10 with Clear (asynchronous reset) and Enable controls:
Q0 := Data & Enable;
[Q1..Q7] := [Q0..Q6];
[Q0..Q7].CLK = Clock;
[Q0..Q7].AR = !Clear;
The test vectors verify shifting behavior: with Enable=0, no shift occurs; with Enable=1, data shifts in one bit per clock cycle.
π Definition β Asynchronous Reset (AR): A control input that immediately clears a flip-flop regardless of the clock signal, specified in ABEL using the .AR dot extension.
π Example: The test vector [.c., 1, 1, 1] -> [1, 0, 0, 0, 0, 0, 0, 0] shows shifting in a '1' when Clock transitions, Clear=1, Data=1, Enable=1.
Example3: 4-bit Parallel In/Serial Out Shift Register
ABEL implementation with SHLD (Shift/Load) control:
Q0 := D0;
Q1 := Q0 & SHLD # D1 & !SHLD;
Q2 := Q1 & SHLD # D2 & !SHLD;
Q3 := Q2 & SHLD # D3 & !SHLD;
[Q0..Q3].CLK = Clock;
[Q0..Q3].AR = !Clear;
When SHLD=0, parallel data D0-D3 is loaded. When SHLD=1, data shifts right.
π Example: With SHLD=0 (load), D0=0, D1=1, D2=0, D3=1 β Q3 becomes 1 (the MSB loaded). With SHLD=1 (shift), the register shifts right on each clock.
β Key Takeaways
The shift register's primary application is converting between parallel and serial data formats, essential for efficient data transmission. Asynchronous serial communication uses start and stop bits (11 bits total per character) for framing, and shift register based converters replace the more complex multiplexer/demultiplexer combinations. Keyboard encoders use ring counters and row-column scanning to detect key presses, encoding position as row and column codes. PLD devices in registered mode can implement sequential circuits like registers and shift registers, configured using ABEL with ISTYPE statements, dot extensions (.CLK, .AR), and assignment operators (:= for registered, = for combinational). The SHLD (Shift/Load) control distinguishes between parallel load and serial shift operations in shift register implementations.
π§ Quick Revision Questions
- In asynchronous serial transmission, how many total bits are transmitted per 8-bit character, and what are their functions?
- How does the keyboard encoder circuit detect a key press using the ring counter and column NAND gate?
- What is the difference between the Registered Mode and Combinational Mode in a PLD's OLMC?
- In ABEL, what do the assignment operators
:=and=indicate, and what does the dot extension.CLKspecify? - For the 4-bit parallel in/serial out shift register example, explain how the SHLD signal controls whether data is loaded in parallel or shifted serially.
π Lecture 36 β EXAMPLE 4: 3-BIT UP/DOWN COUNTER
π Overview: This lecture demonstrates the complete design process of a 3-bit Up/Down counter using D flip-flops, including Karnaugh map simplification, ABEL Hardware Description Language implementations using equations, truth tables, and state diagrams. It concludes with a comprehensive elevator control system design example that applies sequential state machine principles to a real-world application.
ποΈ Topics Covered
The lecture covers the D flip-flop input table and Karnaugh map simplification for a 3-bit Up/Down counter, ABEL implementation using Boolean equations with clock and clear definitions, test vector verification, alternative ABEL specifications using truth tables and state diagrams with IF-THEN-ELSE and GOTO statements, and a detailed elevator control system design including state definition, state diagram, state tables, and input latch requirements.
π Lecture Summary
Example 4: 3-BIT UP/DOWN COUNTER
The 3-bit Up/Down Counter previously implemented using J-K flip-flops is now implemented using D flip-flops by mapping present state and next state information into a D Input table. The simplified Boolean expressions derived from Karnaugh maps are used to implement the circuit.
For X=0 (up counting), the present state transitions follow: 000β001β010β011β100β101β110β111β000. For X=1 (down counting), the sequence reverses: 000β111β110β101β100β011β010β001β000.
Table 36.1a shows the D flip-flop input table for X=0, where Dβ, Dβ, Dβ represent the required D inputs to achieve the next state. Table 36.1b shows the corresponding table for X=1.
From the Karnaugh maps, the simplified Boolean expressions are derived:
Dβ = Qβ'Qβ'Qβ'X + Qβ'QβQβX' + QβQβ'X' + QβQβX + QβQβ'Qβ (Table 36.2a)
Dβ = Qβ'Qβ'X + Qβ'QβX' + QβQβ'X' + QβQβX which simplifies to Dβ = Qβ β Qβ β X (Table 36.2b)
Dβ = Qβ' (Table 36.2c) β The least significant bit toggles on every clock pulse.
π Definition β D flip-flop input table: A table listing the required D input values for each flip-flop to transition from present state to next state. π Formula: Dβ = Qβ β Qβ β X β The Dβ input equals the XOR of the three variables Qβ, Qβ, and X. π Example: When present state QβQβQβ=010 and X=0, the next state is 011. Dβ=0, Dβ=1, Dβ=1 as shown in Table 36.1a, row 3.
The circuit diagram (Figure 36.1) shows three D flip-flops with their D inputs connected according to these Boolean expressions.
ABEL Implementation β Equation Definition
The ABEL input file defines pin assignments: pins 1,2,3 are CLOCK, CLEAR, X; pins 21,22,23 are Qβ, Qβ, Qβ. The outputs are declared as ISTYPE 'reg,buffer' since they are sequential outputs from flip-flops.
Table 36.3a shows the pin definitions. The state variables Qβ, Qβ, Qβ define the different counter states.
The ABEL equations (Table 36.3b) define next state outputs:
Q0 := !Q0;
Q1 := Q0 $ Q1 $ X;
Q2 := !Q2 & !Q1 & !Q0 & X # !Q2 & Q1 & Q0 & !X # Q2 & !Q0 & !X
# Q2 & Q1 & X # Q2 & !Q1 & Q0;
The statements [Q0, Q1, Q2].CLK = clock and [Q0, Q1, Q2].AR = !clear declare state changes occur on clock transitions, and the Asynchronous Reset (AR) clears all flip-flops when clear is active low.
The Test Vectors (Table 36.3c) verify the counter operation. The first vector with Clear=0 resets outputs to 000 regardless of X input. When Clear=1 and X=0, the counter increments: 000β001β010β011β100β101β110β111β000. When X=1, it decrements: 111β110β101β100β011β010β001β000.
π‘ Why this matters: Test vectors are essential for verifying sequential circuit functionality before hardware implementation.
Using a Truth-Table to specify Sequential Circuit
The ABEL Input file can use a truth table instead of equations to specify the Boolean expressions. The Equation definition reduces to two statements defining clock transition and asynchronous reset (Table 36.4a).
The Truth Table (Table 36.4b) has inputs [Clear, X, Qβ, Qβ, Qβ] and outputs [Qβ, Qβ, Qβ]. The first statement shows that when Clear=0, the output resets to 000 regardless of other inputs. The next 16 statements define the 8 input combinations for up counting (X=0) and 8 for down counting (X=1).
π Definition β Truth table specification: An alternative to Boolean equations where the complete circuit behavior is defined by listing all input combinations and their corresponding next state outputs.
π Example: When Clear=1, X=0, QβQβQβ=011, the next state is 100 (incrementing from 3 to 4).
Using a State Diagram to specify Sequential Circuit
The ABEL Input file can also use a State Diagram to specify the sequential circuit. First, states must be defined. Table 36.5a defines eight states A through H corresponding to QβQβQβ values 000 through 111.
The QSTATE variable groups the three state bits as [Q2, Q1, Q0].
Using IF-THEN-ELSE statements (Table 36.5b): For State A, "if X then H else B" means if X=1 (count down) go to state H (111), else go to state B (001, count up). Similar statements define transitions for all eight states.
Using GOTO statements (Table 36.5c): For a simple up counter, unconditional transitions are specified: State A goes to B, B to C, C to D, D to E, E to F, F to G, G to H, H to A.
π Definition β State Diagram: A graphical representation showing states as nodes and transitions as directed edges with input conditions. π Formula: State A: if X then H else B β If X=1, next state is H; if X=0, next state is B. π Example: In the up counter GOTO specification, from State D (011, value 3), the next state is E (100, value 4).
Design Example: Elevator Control System
An elevator system in a building moves between floors. Users press request buttons, floor selection buttons, and an open door button. The elevator has a 7-segment display showing the current floor and direction.
Input and Output Signals:
- Inputs: REQ1, REQ2 (call elevator), FLOOR1, FLOOR2 (floor selection), OPEN (door open button), CLOCK, ARRIVE (floor sensor)
- Outputs: DOOR (0=open, 1=closed), DIR (0=up, 1=down), MOTION (0=waiting, 1=moving)
π‘ Why this matters: This illustrates how sequential state machines control real-world systems with multiple inputs and outputs.
Elevator State Diagram
The state diagram (Figure 36.2) has six states requiring three state variables:
Wait 1 State (W1) β State 000: Elevator waiting on floor 1, door open. Outputs: DOOR=0, MOTION=0, DIR=0. Transitions to C1 if no request, or to UP if REQ2 or FLOOR2 is pressed.
Close 1 State (C1) β State 100: Elevator on floor 1, doors closed. Outputs: DOOR=1, MOTION=0, DIR=0. Returns to W1 if OPEN or REQ1 is pressed.
Up State (U) β State 110: Elevator moving up. Outputs: DOOR=1, MOTION=1, DIR=0. Transitions to W2 when ARRIVE signal received.
Wait 2 State (W2) β State 001: Elevator waiting on floor 2, door open. Outputs: DOOR=0, MOTION=0, DIR=1. Transitions to C2 if no request, or to D if REQ1 or FLOOR1 pressed.
Close 2 State (C2) β State 101: Elevator on floor 2, doors closed. Outputs: DOOR=1, MOTION=0, DIR=1. Returns to W2 if OPEN or REQ2 pressed.
Down State (D) β State 111: Elevator moving down. Outputs: DOOR=1, MOTION=1, DIR=1. Transitions to W1 when ARRIVE signal received.
State Table
Table 36.6a shows next states for REQ1, FLOOR1, and OPEN inputs. Table 36.6b shows next states for REQ2, FLOOR2, and OPEN inputs.
For example, from W1 state: if REQ2=0, next state is C1; if REQ2=1, next state is UP. From C1 state: if REQ2=0, stay in C1; if REQ2=1, go to UP.
π Definition β State Table: A tabular representation showing present states, input conditions, and corresponding next states. π Example: From W1 (000), if FLOOR2=1, the next state is UP (110) β elevator starts moving to floor 2.
Input Latches
Request buttons (REQ1, REQ2), floor buttons (F1, F2), and OPEN button can be pressed at any time. If a button is pressed and released between clock transitions, the sequential circuit might miss the input. Therefore, all input buttons must be connected through latches not controlled by a clock signal (Figure 36.3).
A total of 5 latches are required to store inputs from REQ1, REQ2, F1, F2, and OPEN. These latches capture and hold the button states until the state machine processes them.
π Definition β Input Latch: An asynchronous storage element that captures and holds an input signal until it is read by the sequential circuit. π Example: A person presses REQ1 momentarily between clock cycles; the latch stores this request so the state machine detects it at the next clock edge.
β Key Takeaways
The 3-bit Up/Down counter demonstrates three equivalent ABEL specification methods β equations, truth tables, and state diagrams β each useful for different design scenarios. The D flip-flop implementation simplifies to Dβ=QββQββX and Dβ=Qβ', with Dβ requiring a more complex expression. The elevator control system exemplifies a practical Mealy/Moore state machine with six states, five button inputs, an ARRIVE sensor, and three output signals controlling doors, direction, and motion. Input latches are essential to capture asynchronous button presses that may occur between clock cycles, ensuring no requests are missed.
π§ Quick Revision Questions
- What are the three methods of specifying a sequential circuit in ABEL, and what are the advantages of each?
- Why must asynchronous input buttons like REQ1 and OPEN be connected through latches in the elevator control system?
- What is the simplified Boolean expression for Dβ in the 3-bit Up/Down counter, and how is it derived from the Karnaugh map?
- How does the state diagram for the elevator switch from Wait 1 State to Up State, and what input conditions trigger this transition?
- In the 3-bit Up/Down counter test vectors, what happens when Clear=0 and why is this behavior important for circuit initialization?
π Lecture 37 β Reduced Number of Input Latches
π Overview: This lecture focuses on reducing the number of input latches in the elevator control system from five to two (SR1 and SR2), simplifying the Boolean expressions and circuit design. It also introduces a new design example of a Traffic Signal Control System, covering its inputs, outputs, and state machine implementation using ABEL.
ποΈ Topics Covered
This lecture covers the simplification of the elevator control system by using two SR latches (SR1 and SR2) to store external inputs like REQ1, FLOOR1, OPEN, REQ2, FLOOR2, and OPEN. It presents the simplified next state tables for both latches and the overall next state table based on SR1, SR2, and ARRIVAL inputs. The lecture then details the complete ABEL input file for the elevator state machine, including pin declarations, state definitions, and state diagrams. Finally, it introduces a new design example: a Traffic Signal Control System, outlining its sensors, timing inputs, outputs, and state machine design.
π Lecture Summary
Reduced Number of Input Latches
The number of latches used to store external inputs in the elevator control system can be reduced to two. The REQ1, FLOOR1, and OPEN button outputs (pressed when the elevator is on the first floor) are stored on one latch, and the REQ2, FLOOR2, and OPEN button outputs (pressed when the elevator is on the second floor) are stored on a second latch. This reduces the complexity of the Boolean expressions for the next state excitation inputs.
The Boolean expressions that set the latch SR1 is: REQ1 + FLOOR1.DIR + OPEN.DIR. The DIR variable indicates the current floor: if DIR=0, the elevator is on the first floor; if DIR=1, it is on the second floor. The circuit diagram for the SR1 latch shows the set and reset inputs derived from these signals.
π Definition β DIR variable: indicates the current floor. DIR=0 means the elevator is on the first floor, DIR=1 means it is on the second floor.
The simplified next state table for inputs REQ1, FLOOR1, and OPEN in terms of the SR1 latch is shown in Table 37.1. For example, when the present state is C1(100) and SR1=0, the next state is C1; when SR1=1, the next state is W1.
The state of inputs REQ2, FLOOR2, and OPEN is similarly represented by the second latch SR2. The circuit diagram and Boolean expression follow the same logic, as shown in Figure 37.2 and Table 37.2.
In the modified block diagram (Figure 37.3), the Next State Combinational Circuit block is replaced by latches SR1 and SR2, which handle the external inputs. The external input ARRIVE is connected directly to the Next State Combinational circuit along with the Present State inputs to determine the excitation inputs for the memory element.
The overall Next State Table (Table 37.3) for the Elevator State Machine is based on the SR1, SR2, and ARRIVAL inputs. It determines the next state for each combination of present state and these input conditions.
The ABEL Input file for Elevator State Machine
The ABEL input file for the Elevator State Machine defines the pin declarations, state definitions, state diagram, and equations for the latches.
The SR1, SR1_, SR2, and SR2_ variables are the Q and QΜ (NOT Q) outputs for latches SR1 and SR2. These outputs are generated by combinational circuits and are defined as ISTYPE 'com.buffer'. These outputs are fed back to the AND gate array. The outputs from the three D flip-flops (DOOR, MOTION, and DIR) are declared as ISTYPE 'reg.buffer' as they are sequential circuit outputs.
The pin declarations (Table 36.4a) map the CLK, !OLE, REQ1, REQ2, FLOOR1, FLOOR2, OPEN, ARRIVE inputs to specific pins and the SR1, SR1_, SR2, SR2_, DOOR, MOTION, and DIR signals to output pins.
The states are defined using statements like WAIT1 = ^B000;, CLOSE1 = ^B100;, etc. (Table 37.4b).
The state diagram (Table 37.4c) defines the operation of the sequential state machine using State_diagram CONSTATE and statements for each state (e.g., State WAIT1: if (SR2) then UP else CLOSE1;).
The equations for the latches SR1 and SR2 are defined in the Equation Definition part (Table 37.4d). For example:
SR1 = REQ1 # !DIR.FB & OPEN # DIR.FB & FLOOR1 # !SR1_;SR1_ = (!DOOR.FB & !MOTION.FB & !DIR.FB) # !SR1;
The 'FB' indicates that the DOOR, MOTION, and DIR output signals are fed back to the AND gate array.
Design Example: Traffic Signal Control System
This lecture introduces a new design example: a Traffic Signal Control System at a road intersection. On each road section, two sensors determine the presence and arrival of vehicles:
- Sensor 1: activated if a car is waiting.
- Sensor 2: activated when an arriving vehicle passes over it.
Sensors on the North-South section are connected together, determining the presence of vehicles on that road. Similarly, sensors on East-West are connected together.
During the day, the traffic light is cycled every 5 minutes: Green for 5 minutes, then Red for 5 minutes for each section. During the night, it stops a car for a maximum of 1 minute, unless a car approaches on the cross road, in which case the signal turns red for the approaching car and allows the waiting car to proceed.
Traffic Signal Controller Inputs and Outputs:
- NSSR: activated when a car is over any of the four sensors on the North-South section.
- EWSR: activated when a car is over any of the four sensors on the East-West section.
- LTIME: activated if 5 minutes have elapsed.
- STIME: activated if 1 minute has elapsed.
- NSGrn, NSYel, NSRed: Green, Yellow, and Red signals for North-South traffic.
- EWGrn, EWYel, EWRed: Green, Yellow, and Red signals for East-West traffic.
- TMRST: Resets the timer after a time interval is reached.
The transition from the NSG (North-South Green) state to the NSY (North-South Yellow) state is determined by a flowchart (Figure 37.5) based on inputs like LTIME, STIME, EWSR, and NSSR.
The state machine can be implemented using a GAL16V8 device. The pin declarations (Table 37.5a) define pins for CLOCK, NSSR, EWSR, LTIME, STIME, state variable outputs Q0, Q1, Q2 (defined as ISTYPE 'reg.invert'), and TMRST (defined as ISTYPE 'com.invert').
The states (Table 37.5b) are defined using three state variables (e.g., NSG = [0, 0, 0]; NSY = [0, 0, 1];).
The ABEL State Diagram statements (Table 37.5c) define each state and transitions. For example:
State NSG: if (!STIME) then NSG
else if (LTIME) then NSY
else if (EWSR & !NSSR) then NSG
else if (EWSR & NSSR) then NSY
else if (!NSSR) then NSG
else NSY;
π‘ Why this matters: This design example demonstrates a practical application of state machines in real-world control systems, showing how to handle multiple conditions and timing constraints.
β Key Takeaways
The key takeaway is that reducing the number of input latches in a state machine simplifies both the hardware design and the Boolean expressions, as demonstrated by the elevator controller. The ABEL input file is crucial for implementing state machines in PLDs, using pin declarations, state definitions, and state diagrams. The Traffic Signal Control System example illustrates a complex real-world application involving multiple sensors, timers, and state transitions based on various conditions (day/night mode, car presence on different roads). Understanding how to define states, derive transition conditions from flowcharts, and implement them in ABEL is essential for designing control systems.
π§ Quick Revision Questions
- What is the benefit of reducing the number of latches in the elevator control system, and which two latches are used instead of five?
- What is the Boolean expression for setting the SR1 latch, and what does the DIR variable represent in that expression?
- In the ABEL file for the elevator controller, what are the ISTYPE declarations for SR1/SR2 and DOOR/MOTION/DIR, and why are they different?
- In the Traffic Signal Control System, what is the function of the LTIME and STIME inputs, and during which operation mode (day or night) does each apply?
- Describe the state transition conditions from the NSG state to the NSY state in the Traffic Light Controller, based on the given flowchart.