PadhaikoAll subjects

Instruction, Machine & T-Cycles; Timing Diagrams

Microprocessors (ENEX 201)

Open in the Padhaiko app

2.8 Instruction cycle, machine cycle and T-cycle

The timing and sequence of operations in the Intel 8085 microprocessor follow a strict hierarchical structure governed by the master system clock. Every internal operation and external bus communication is synchronized in terms of clock periods.

Definition

The Three Levels of Microprocessor Timing

  1. T-State (Clock Period): The fundamental unit of processor timing. One T-state is equal to one complete period T of the internal system clock: T = 1 / f_clock. For example, with a standard internal clock frequency of 3.072 MHz, one T-state has a duration of: T = 1 / (3.072 * 10^6 Hz) = 325.52 nanoseconds.
  2. Machine Cycle: The time required by the microprocessor to complete one external bus transaction with memory or an I/O peripheral device.
    • A standard machine cycle consists of 3 to 6 T-states (labeled T1, T2, T3, T4, T5, T6).
    • The first machine cycle of any instruction is always the Opcode Fetch (OF) cycle, taking 4 T-states (or 6 T-states for 16-bit register instructions). Subsequent machine cycles (Memory Read, Memory Write, I/O Read, I/O Write) take 3 T-states each.
  3. Instruction Cycle: The total elapsed time and sequence of machine cycles necessary to fetch an instruction from memory and completely execute it.
    • An instruction cycle contains between 1 and 5 machine cycles.
    • Total duration ranges from 4 to 18 T-states (e.g., MOV A, B requires 1 machine cycle / 4 T-states; CALL addr16 requires 5 machine cycles / 18 T-states).
Text
+-----------------------------------------------------------------------------+
|                             INSTRUCTION CYCLE                               |
|   (Total time to fetch, decode, and execute the entire instruction)         |
|                                                                             |
|  +--------------------+  +--------------------+  +--------------------+     |
|  |   Machine Cycle 1  |  |   Machine Cycle 2  |  |   Machine Cycle 3  | ... |
|  |   (Opcode Fetch)   |  |   (Memory Read)    |  |   (Memory Write)   |     |
|  +--------------------+  +--------------------+  +--------------------+     |
|  | T1 | T2 | T3 | T4  |  | T1 | T2 | T3       |  | T1 | T2 | T3       |     |
|  +----+----+----+-----+  +----+----+----+     +  +----+----+----+     +     |
+-----------------------------------------------------------------------------+

The Seven Types of 8085 Machine Cycles

The 8085 identifies which machine cycle it is currently executing using three status outputs: IO/M_bar, S1, and S0. The control strobes RD_bar and WR_bar indicate whether data is transferred into or out of the CPU.

8085 Machine Cycle Status and Control Signals
Machine Cycle NameSymbolT-StatesIO/M_barS1S0Active Control StrobeTypical Instruction
Opcode FetchOF4 or 6011RD_bar = 0 (T2–T3)All instructions (first cycle)
Memory ReadMR3010RD_bar = 0 (T2–T3)MVI, LDA, MOV A, M
Memory WriteMW3001WR_bar = 0 (T2–T3)STA, MOV M, A, PUSH
I/O ReadIOR3110RD_bar = 0 (T2–T3)IN port8
I/O WriteIOW3101WR_bar = 0 (T2–T3)OUT port8
Interrupt AcknowledgeINA6 or 12111INTA_bar = 0 (T2–T3)Response to INTR
Bus IdleBI30 / 100None (Floating)DAD, internal operations

2.9 Timing diagrams of bus operations

A timing diagram is a graphical representation of signal transitions on the system buses and control lines plotted against time (T-states). It shows the exact clock edge on which memory addresses, data words, and control strobes become active, stable, and inactive.

1. Opcode Fetch (OF) Machine Cycle (4 T-States)

The Opcode Fetch cycle reads the operation code byte from memory and decodes it inside the CPU:

2. Memory Read (MR) Machine Cycle (3 T-States)

The Memory Read cycle retrieves an 8-bit operand or address byte from memory:

3. Memory Write (MW) Machine Cycle (3 T-States)

The Memory Write cycle stores an 8-bit byte from an internal CPU register into memory:

4. I/O Read (IOR) and I/O Write (IOW) Cycles (3 T-States each)

During I/O machine cycles:


Worked Examples

Example 1

1 (6 marks)

The Intel 8085 instruction MVI M, 32H is stored at memory address 2000H. Assume the HL register pair currently contains 3050H.

  1. Identify all machine cycles required to execute this instruction, specifying the T-states for each.
  2. Calculate the total execution time if the CPU operates with a 3 MHz master clock.
  3. Show the complete timing diagram across all machine cycles with bus address and data values.

1. Machine Cycle Identification: MVI M, 32H is a 2-byte instruction (Opcode: 36H, Data: 32H). Execution requires 3 machine cycles totaling 10 T-states:

  • M1: Opcode Fetch (OF, 4 T-states): Fetches the opcode 36H from memory location 2000H.
  • M2: Memory Read (MR, 3 T-states): Reads the immediate data byte 32H from memory location 2001H into an internal temporary register.
  • M3: Memory Write (MW, 3 T-states): Writes the immediate data byte 32H into the memory location addressed by HL (3050H).

Total T-states = 4 + 3 + 3 = 10 T-states.

2. Execution Time Calculation at 3 MHz: Clock frequency f_clock = 3.0 MHz = 3 * 10^6 Hz. Clock period T = 1 / (3 * 10^6) = 0.3333 microseconds. Total execution time = 10 * 0.3333 microseconds = 3.333 microseconds.

3. Timing Diagram Representation: The bus operations trace:

  • M1 (OF): Address = 2000H, Data = 36H (Opcode).
  • M2 (MR): Address = 2001H, Data = 32H (Immediate operand).
  • M3 (MW): Address = 3050H, Data = 32H (Written into RAM [HL]).
MVI M, 32H CLK A15–A8 AD7–AD0 ALE IO/M̅ S1 S0 RD̅ WR̅ OF T1 T2 T3 T4 20H Unspecified 00H 36H High-Z MR T1 T2 T3 20H 01H 32H MW T1 T2 T3 30H 50H 32H
MVI M, 32H · OF + MR + MW · 10 T-states
Answer:
  1. Machine cycles: OF (4T) + MR (3T) + MW (3T) = 10 T-states.
  2. Execution time at 3 MHz = 3.33 microseconds.
  3. The timing diagram illustrates the three machine cycles with addresses 2000H, 2001H, and 3050H.
Example 2

2 (6 marks)

The 8085 instruction OUT 01H (Opcode: D3H) is located at memory address 2000H. Assume the Accumulator currently contains the data byte 55H.

  1. List the machine cycles executed and state what signals appear on the address bus during the I/O cycle.
  2. Calculate the execution time when running at a clock frequency of 2 MHz.
  3. Render the timing diagram showing the machine cycles.

1. Machine Cycle Breakdown: OUT 01H is a 2-byte instruction (Byte 1: D3H, Byte 2: 01H). It requires 3 machine cycles and 10 T-states:

  • M1 (Opcode Fetch - OF, 4T): Fetches opcode D3H from 2000H.
  • M2 (Memory Read - MR, 3T): Reads port address 01H from 2001H.
  • M3 (I/O Write - IOW, 3T): Writes Accumulator content (55H) to output port 01H.
    • In M3, the 8-bit port address 01H is duplicated on both A15–A8 and AD7–AD0 (0101H).
    • Status lines: IO/M_bar = 1, S1 = 0, S0 = 1.
    • Control strobe: WR_bar = 0 during T2 and T3.

2. Execution Time Calculation at 2 MHz: Total T-states = 4 + 3 + 3 = 10 T-states. Clock period T = 1 / (2 * 10^6 Hz) = 0.5 microseconds. Execution time = 10 * 0.5 microseconds = 5.0 microseconds.

3. Timing Diagram:

OUT 01H CLK A15–A8 AD7–AD0 ALE IO/M̅ S1 S0 RD̅ WR̅ OF T1 T2 T3 T4 20H Unspecified 00H D3H High-Z MR T1 T2 T3 20H 01H 01H IOW T1 T2 T3 01H 01H 55H
OUT 01H · OF + MR + IOW · 10 T-states
Answer:
  1. Machine cycles: OF (4T) + MR (3T) + IOW (3T) = 10 T-states. In M3, port address 01H is duplicated on A8–A15 and AD0–AD7 with IO/M_bar = 1.
  2. Execution time at 2 MHz = 5.00 microseconds.
  3. Timing diagram renders OF, MR, and IOW cycles.
Example 3

3 (6 marks)

(Tribhuvan University Past exam questions Guide) Draw and explain the complete timing diagram for the 8085 instruction STA 2050H. Calculate its total execution time assuming the microprocessor is clocked by a 6.144 MHz quartz crystal.

1. Instruction Structure and Machine Cycles: STA 2050H (Opcode: 32H) is a 3-byte instruction stored as:

  • Address 2000H: 32H (Opcode)
  • Address 2001H: 50H (Low-order address byte)
  • Address 2002H: 20H (High-order address byte)

It requires 4 machine cycles and 13 T-states:

  • M1 (Opcode Fetch - OF, 4 T-states): Reads opcode 32H from 2000H.
  • M2 (Memory Read - MR, 3 T-states): Reads low address 50H from 2001H into register Z.
  • M3 (Memory Read - MR, 3 T-states): Reads high address 20H from 2002H into register W.
  • M4 (Memory Write - MW, 3 T-states): Writes Accumulator content (e.g., 45H) into memory location 2050H (WZ).

2. Execution Time at 6.144 MHz Crystal: Internal clock frequency: f_internal = f_crystal / 2 = 6.144 MHz / 2 = 3.072 MHz. Clock period T = 1 / 3.072 MHz = 0.3255 microseconds. Total Execution Time = 13 * 0.3255 microseconds = 4.232 microseconds.

3. Timing Diagram:

STA 2050H CLK A15–A8 AD7–AD0 ALE IO/M̅ S1 S0 RD̅ WR̅ OF T1 T2 T3 T4 20H Unspecified 00H 32H High-Z MR T1 T2 T3 20H 01H 50H MR T1 T2 T3 20H 02H 20H MW T1 T2 T3 20H 50H 45H
STA 2050H · OF + MR + MR + MW · 13 T-states
Answer:

STA 2050H executes in 4 machine cycles (OF, MR, MR, MW) totaling 13 T-states, taking 4.23 microseconds at 3.072 MHz.


Exercises

Exercises

Question 1

Define an instruction cycle, machine cycle, and T-state. List the seven machine cycles of the Intel 8085 microprocessor along with their identifying status signals (IO/M_bar, S1, S0).

Definitions:

  • T-State: One individual clock period of the master CPU clock (T = 1 / f_clock).
  • Machine Cycle: The basic time unit required by the CPU to complete one external bus access (memory or I/O). Consists of 3 to 6 T-states.
  • Instruction Cycle: The total time and sequence of machine cycles required to fetch, decode, and completely execute an instruction (1 to 5 machine cycles, 4 to 18 T-states).

The Seven Machine Cycles and Status Signals:

  1. Opcode Fetch (OF, 4T/6T): IO/M_bar = 0, S1 = 1, S0 = 1.
  2. Memory Read (MR, 3T): IO/M_bar = 0, S1 = 1, S0 = 0.
  3. Memory Write (MW, 3T): IO/M_bar = 0, S1 = 0, S0 = 1.
  4. I/O Read (IOR, 3T): IO/M_bar = 1, S1 = 1, S0 = 0.
  5. I/O Write (IOW, 3T): IO/M_bar = 1, S1 = 0, S0 = 1.
  6. Interrupt Acknowledge (INA, 6T/12T): IO/M_bar = 1, S1 = 1, S0 = 1.
  7. Bus Idle (BI, 3T): IO/M_bar = 0/1, S1 = 0, S0 = 0.
Answer:

An instruction cycle consists of multiple machine cycles (bus operations), each comprising 3 to 6 T-states (clock periods). The seven 8085 machine cycles are OF (0,1,1), MR (0,1,0), MW (0,0,1), IOR (1,1,0), IOW (1,0,1), INA (1,1,1), and Bus Idle (X,0,0).

Question 2

Draw and explain the step-by-step signal transitions of the Opcode Fetch (OF) machine cycle in the Intel 8085 microprocessor across states T1, T2, T3, and T4.

Opcode Fetch Signal Transitions:

  • State T1 (Address Setup):
    • High address A8–A15 emits upper byte of Program Counter (PCH).
    • Low address/data lines AD0–AD7 emit lower byte of Program Counter (PCL).
    • Status lines output IO/M_bar = 0, S1 = 1, S0 = 1.
    • ALE pulses high during the first half of T1 and transitions low, causing the external latch to freeze PCL.
  • State T2 (Read Strobe Asserted):
    • AD0–AD7 is floated into the high-impedance input state.
    • RD_bar is asserted low. Memory enables its output buffers and drives the opcode byte onto AD0–AD7.
    • The Program Counter is incremented: PC <- PC + 1.
  • State T3 (Data Transfer):
    • The CPU latches the opcode byte from AD0–AD7 into the Instruction Register (IR).
    • RD_bar transitions high, disabling memory outputs.
  • State T4 (Instruction Decode):
    • The Instruction Decoder decodes the opcode in the IR.
    • External system buses remain idle/floating.

Timing Diagram:

Opcode Fetch Machine Cycle CLK A15–A8 AD7–AD0 ALE IO/M̅ S1 S0 RD̅ WR̅ OF T1 T2 T3 T4 20H Unspecified 00H 78H High-Z
Opcode Fetch Machine Cycle · OF · 4 T-states
Answer:

During T1, PC is driven onto A8–A15 and AD0–AD7 while ALE latches low address. In T2, RD_bar goes low and PC increments. In T3, opcode is read into IR and RD_bar returns high. In T4, the internal decoder decodes the opcode.

Question 3

Compare Memory Read (MR) and Memory Write (MW) machine cycles with respect to status signals, control strobes, data bus directionality, and timing during states T1, T2, and T3.

Detailed Comparison:

  • Status Signals (IO/M_bar, S1, S0):
    • Memory Read: IO/M_bar = 0, S1 = 1, S0 = 0.
    • Memory Write: IO/M_bar = 0, S1 = 0, S0 = 1.
  • Control Strobe:
    • Memory Read: RD_bar goes active low during T2 and T3. WR_bar remains high.
    • Memory Write: WR_bar goes active low during T2 and T3. RD_bar remains high.
  • Data Bus (AD0–AD7) Behavior:
    • Memory Read: During T1, emits low address A0–A7. During T2, CPU floats AD0–AD7 into input mode; external memory drives the data byte onto the bus. In T3, CPU latches the byte.
    • Memory Write: During T1, emits low address A0–A7. During T2, CPU drives the data byte from its internal register directly onto AD0–AD7. In T3, memory latches the data.
  • Total Duration: Both cycles take exactly 3 T-states (T1, T2, T3).
Answer:

MR sets IO/M=0, S1=1, S0=0, asserts RD_bar, and reads data from memory onto floated AD0–AD7. MW sets IO/M=0, S1=0, S0=1, asserts WR_bar, and actively drives data from the CPU onto AD0–AD7 for memory storage.

Question 4

Draw the timing diagram for the instruction LDA 3050H. Calculate its total execution time when running on an 8085 processor with an operating clock frequency of 3 MHz.

Machine Cycle Decomposition of LDA 3050H: LDA 3050H (Opcode: 3AH) is a 3-byte instruction that loads the Accumulator directly from memory address 3050H. It requires 4 machine cycles and 13 T-states:

  1. M1 (Opcode Fetch - OF, 4T): Fetches opcode 3AH from instruction address (e.g., 2000H).
  2. M2 (Memory Read - MR, 3T): Reads low-order address byte 50H from 2001H.
  3. M3 (Memory Read - MR, 3T): Reads high-order address byte 30H from 2002H.
  4. M4 (Memory Read - MR, 3T): Reads the actual data operand from memory address 3050H into Accumulator.

Total T-states = 4 + 3 + 3 + 3 = 13 T-states.

Execution Time Calculation at 3 MHz: Clock frequency f_clock = 3 MHz = 3 * 10^6 Hz. Period T = 1 / 3.0 MHz = 0.3333 microseconds. Execution time = 13 * 0.3333 microseconds = 4.333 microseconds.

Timing Diagram:

LDA 3050H CLK A15–A8 AD7–AD0 ALE IO/M̅ S1 S0 RD̅ WR̅ OF T1 T2 T3 T4 20H Unspecified 00H 3AH High-Z MR T1 T2 T3 20H 01H 50H MR T1 T2 T3 20H 02H 30H MR T1 T2 T3 30H 50H 88H
LDA 3050H · OF + MR + MR + MR · 13 T-states
Answer:

LDA 3050H executes in 4 machine cycles (OF, MR, MR, MR) totaling 13 T-states, taking 4.33 microseconds at 3 MHz.

Question 5

Explain how slow memory and I/O devices interface with the Intel 8085 microprocessor using the READY pin. What is a Wait State (Tw) and how is it inserted into a machine cycle?

The Need for Wait States: Fast microprocessors can read or write data in 3 T-states (~1 microsecond or less). However, slower memory chips (such as slow EPROMs or peripheral chips) require longer access times to decode addresses and output valid data. If the CPU attempted to latch data in state T3 without waiting, it would read garbled or incomplete data.

Operation of the READY Pin and Insertion of Tw:

  1. The 8085 monitors the state of the active-high READY pin (Pin 35) during clock state T2 of every machine cycle.
  2. If READY is logic 1 (high), memory is fast enough; the processor proceeds normally to state T3.
  3. If READY is logic 0 (low) during T2, the CPU pauses its internal operations and inserts an extra clock state called a Wait State (Tw) between T2 and T3.
  4. During Tw, all signals on the address bus, data bus, RD_bar, WR_bar, and status lines remain frozen and active in their current states.
  5. The CPU continues to test READY on each successive clock cycle. It can insert multiple Tw states (Tw1, Tw2, ...) indefinitely until the peripheral device pulls READY high.
  6. Once READY goes high, the CPU transitions into state T3 and completes the bus transfer cleanly.
Answer:

The READY pin (tested during T2) allows slow devices to pause the CPU by holding READY low. The CPU inserts Wait states (Tw) between T2 and T3, holding address, data, and control strobes active until READY goes high, ensuring error-free data transfer.

Past exam questions for Microprocessors

← 8085 Programs: Arithmetic, Loops, Arrays, BCD, Multiply/Divide8086 Features & Architecture (BIU and EU) →