Instruction, Machine & T-Cycles; Timing Diagrams
Open in the Padhaiko app2.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.
The Three Levels of Microprocessor Timing
- T-State (Clock Period): The fundamental unit of processor timing. One T-state is equal to one complete period
Tof the internal system clock:T = 1 / f_clock. For example, with a standard internal clock frequency of3.072 MHz, one T-state has a duration of:T = 1 / (3.072 * 10^6 Hz) = 325.52 nanoseconds. - 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.
- A standard machine cycle consists of 3 to 6 T-states (labeled
- 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, Brequires 1 machine cycle / 4 T-states;CALL addr16requires 5 machine cycles / 18 T-states).
+-----------------------------------------------------------------------------+
| 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.
| Machine Cycle Name | Symbol | T-States | IO/M_bar | S1 | S0 | Active Control Strobe | Typical Instruction |
|---|---|---|---|---|---|---|---|
| Opcode Fetch | OF | 4 or 6 | 0 | 1 | 1 | RD_bar = 0 (T2–T3) | All instructions (first cycle) |
| Memory Read | MR | 3 | 0 | 1 | 0 | RD_bar = 0 (T2–T3) | MVI, LDA, MOV A, M |
| Memory Write | MW | 3 | 0 | 0 | 1 | WR_bar = 0 (T2–T3) | STA, MOV M, A, PUSH |
| I/O Read | IOR | 3 | 1 | 1 | 0 | RD_bar = 0 (T2–T3) | IN port8 |
| I/O Write | IOW | 3 | 1 | 0 | 1 | WR_bar = 0 (T2–T3) | OUT port8 |
| Interrupt Acknowledge | INA | 6 or 12 | 1 | 1 | 1 | INTA_bar = 0 (T2–T3) | Response to INTR |
| Bus Idle | BI | 3 | 0 / 1 | 0 | 0 | None (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:
- T1 State:
- The CPU places the higher-order 8 bits of the Program Counter (
PCH) onA8–A15. - The CPU places the lower-order 8 bits of the Program Counter (
PCL) onAD0–AD7. - The status lines indicate an Opcode Fetch:
IO/M_bar = 0,S1 = 1,S0 = 1. - The CPU emits an Address Latch Enable (ALE) pulse high, then low, latching
PCLinto the external 74LS373 latch.
- The CPU places the higher-order 8 bits of the Program Counter (
- T2 State:
- The CPU floats lines
AD0–AD7to prepare for data input. - The CPU asserts
RD_barlow, enabling the addressed memory chip to drive its data ontoAD0–AD7. - The Program Counter is incremented:
PC <- PC + 1.
- The CPU floats lines
- T3 State:
- The CPU reads the opcode byte from
AD0–AD7into the internal Instruction Register (IR). - The CPU de-asserts
RD_barhigh. Memory output buffers return to high-impedance.
- The CPU reads the opcode byte from
- T4 State:
- The Instruction Decoder decodes the opcode in the IR to determine the required micro-operations.
- The external buses (
A8–A15,AD0–AD7) remain inactive / floating.
2. Memory Read (MR) Machine Cycle (3 T-States)
The Memory Read cycle retrieves an 8-bit operand or address byte from memory:
- T1 State: The CPU places the target memory address on
A8–A15andAD0–AD7. Status lines set toIO/M_bar = 0,S1 = 1,S0 = 0. ALE pulses high then low. - T2 State:
AD0–AD7floats. The CPU assertsRD_barlow. Memory drives the requested data byte ontoAD0–AD7. - T3 State: The CPU reads the data byte into the designated internal register.
RD_barreturns high.
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:
- T1 State: The target memory address is placed on
A8–A15andAD0–AD7. Status lines set toIO/M_bar = 0,S1 = 0,S0 = 1. ALE pulses high then low. - T2 State: The CPU places the data byte to be stored directly onto
AD0–AD7. The CPU assertsWR_barlow. - T3 State: The memory chip latches the data byte into the addressed cell. The CPU de-asserts
WR_barhigh.
4. I/O Read (IOR) and I/O Write (IOW) Cycles (3 T-States each)
During I/O machine cycles:
- The 8-bit port address is duplicated on both the upper address lines
A8–A15and the lower linesAD0–AD7. IO/M_baris driven high (1) to indicate an I/O peripheral transaction.RD_baris asserted low forIOR(IN port8);WR_baris asserted low forIOW(OUT port8).
Worked Examples
1
The Intel 8085 instruction MVI M, 32H is stored at memory address 2000H. Assume the HL register pair currently contains 3050H.
- Identify all machine cycles required to execute this instruction, specifying the T-states for each.
- Calculate the total execution time if the CPU operates with a 3 MHz master clock.
- 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
36Hfrom memory location2000H. - M2: Memory Read (MR, 3 T-states): Reads the immediate data byte
32Hfrom memory location2001Hinto an internal temporary register. - M3: Memory Write (MW, 3 T-states): Writes the immediate data byte
32Hinto 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]).
- Machine cycles: OF (4T) + MR (3T) + MW (3T) = 10 T-states.
- Execution time at 3 MHz = 3.33 microseconds.
- The timing diagram illustrates the three machine cycles with addresses
2000H,2001H, and3050H.
2
The 8085 instruction OUT 01H (Opcode: D3H) is located at memory address 2000H. Assume the Accumulator currently contains the data byte 55H.
- List the machine cycles executed and state what signals appear on the address bus during the I/O cycle.
- Calculate the execution time when running at a clock frequency of 2 MHz.
- 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
D3Hfrom2000H. - M2 (Memory Read - MR, 3T): Reads port address
01Hfrom2001H. - M3 (I/O Write - IOW, 3T): Writes Accumulator content (
55H) to output port01H.- In M3, the 8-bit port address
01His duplicated on bothA15–A8andAD7–AD0(0101H). - Status lines:
IO/M_bar = 1,S1 = 0,S0 = 1. - Control strobe:
WR_bar = 0during T2 and T3.
- In M3, the 8-bit port address
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:
- Machine cycles: OF (4T) + MR (3T) + IOW (3T) = 10 T-states. In M3, port address
01His duplicated on A8–A15 and AD0–AD7 withIO/M_bar = 1. - Execution time at 2 MHz = 5.00 microseconds.
- Timing diagram renders OF, MR, and IOW cycles.
3
(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
32Hfrom2000H. - M2 (Memory Read - MR, 3 T-states): Reads low address
50Hfrom2001Hinto register Z. - M3 (Memory Read - MR, 3 T-states): Reads high address
20Hfrom2002Hinto register W. - M4 (Memory Write - MW, 3 T-states): Writes Accumulator content (e.g.,
45H) into memory location2050H(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 executes in 4 machine cycles (OF, MR, MR, MW) totaling 13 T-states, taking 4.23 microseconds at 3.072 MHz.
Exercises
Exercises
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:
- Opcode Fetch (OF, 4T/6T):
IO/M_bar = 0,S1 = 1,S0 = 1. - Memory Read (MR, 3T):
IO/M_bar = 0,S1 = 1,S0 = 0. - Memory Write (MW, 3T):
IO/M_bar = 0,S1 = 0,S0 = 1. - I/O Read (IOR, 3T):
IO/M_bar = 1,S1 = 1,S0 = 0. - I/O Write (IOW, 3T):
IO/M_bar = 1,S1 = 0,S0 = 1. - Interrupt Acknowledge (INA, 6T/12T):
IO/M_bar = 1,S1 = 1,S0 = 1. - Bus Idle (BI, 3T):
IO/M_bar = 0/1,S1 = 0,S0 = 0.
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).
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–A15emits upper byte of Program Counter (PCH). - Low address/data lines
AD0–AD7emit lower byte of Program Counter (PCL). - Status lines output
IO/M_bar = 0,S1 = 1,S0 = 1. ALEpulses high during the first half of T1 and transitions low, causing the external latch to freezePCL.
- High address
- State T2 (Read Strobe Asserted):
AD0–AD7is floated into the high-impedance input state.RD_baris asserted low. Memory enables its output buffers and drives the opcode byte ontoAD0–AD7.- The Program Counter is incremented:
PC <- PC + 1.
- State T3 (Data Transfer):
- The CPU latches the opcode byte from
AD0–AD7into the Instruction Register (IR). RD_bartransitions high, disabling memory outputs.
- The CPU latches the opcode byte from
- State T4 (Instruction Decode):
- The Instruction Decoder decodes the opcode in the IR.
- External system buses remain idle/floating.
Timing Diagram:
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.
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.
- Memory Read:
- Control Strobe:
- Memory Read:
RD_bargoes active low during T2 and T3.WR_barremains high. - Memory Write:
WR_bargoes active low during T2 and T3.RD_barremains high.
- Memory Read:
- Data Bus (
AD0–AD7) Behavior:- Memory Read: During T1, emits low address
A0–A7. During T2, CPU floatsAD0–AD7into 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 ontoAD0–AD7. In T3, memory latches the data.
- Memory Read: During T1, emits low address
- Total Duration: Both cycles take exactly 3 T-states (T1, T2, T3).
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.
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:
- M1 (Opcode Fetch - OF, 4T): Fetches opcode
3AHfrom instruction address (e.g.,2000H). - M2 (Memory Read - MR, 3T): Reads low-order address byte
50Hfrom2001H. - M3 (Memory Read - MR, 3T): Reads high-order address byte
30Hfrom2002H. - M4 (Memory Read - MR, 3T): Reads the actual data operand from memory address
3050Hinto 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 executes in 4 machine cycles (OF, MR, MR, MR) totaling 13 T-states, taking 4.33 microseconds at 3 MHz.
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:
- The 8085 monitors the state of the active-high
READYpin (Pin 35) during clock state T2 of every machine cycle. - If
READYis logic 1 (high), memory is fast enough; the processor proceeds normally to state T3. - If
READYis 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. - 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. - The CPU continues to test
READYon each successive clock cycle. It can insert multipleTwstates (Tw1,Tw2, ...) indefinitely until the peripheral device pullsREADYhigh. - Once
READYgoes high, the CPU transitions into state T3 and completes the bus transfer cleanly.
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.