Machine Cycle

What is Machine Cycle?

Machine cycle refers to the steps performed by the processor of the computer to execute an instruction after it is received and consists of T states.

Technically, it refers to the time taken by the processor to complete a single operation which involves accessing I/O, memory, or acknowledging a peripheral request.

Understanding Machine Cycle

What is Machine Cycle

Machine cycle is the most fundamental operation performed by a computer system to carry out an instruction.

It is the basic operation of the processor that involves reading or writing a single byte from the I/O port or to the memory, respectively.

Ideally, there are lots of these cycles performed by the processor of the computer to perform tedious tasks such as displaying a single character on the monitor and others.

And these cycles start from the moment you switch on your computer system and carry on till you shut it down.

Typically, modern computer processors can carry out millions of machine cycles per second.

The machine cycle process involves four basic steps such as fetch, decode, execute and store, and accordingly, it is known by different names such as:

Though basic, attempts are made to improve the machine cycle process and one such way is by using pipelining.

With its implementation, modern computers do not have to wait until an instruction completes all four steps to start working on the following instruction, as was the case with the earlier computer systems.

With pipelining, the processor can start fetching the second instruction before the previous machine cycle is completed.

Machine cycle plays a significant role. It basically maintains the flow of instructions and their execution so that they do not give any wrong results.

It helps with the better understanding of the internals of the instruction execution so that any need for further improvements can be figured out.

In short, the machine cycle determines the performance of the computer system on the whole and prevents it from being degraded.

Read Also:  What is CPU Socket? Lifespan, Type, Works & More

It also helps in determining the processing speed of the device based on the number of instructions executed in a given period of time.

Machine Cycle Types

The first machine cycle is the opcode fetch cycle which is followed by memory read and write cycles, I/O read and write cycles, interrupt acknowledge and bus idle.

Different types of operations are performed in these different types of machine cycles, making each of them significant for the entire process. Here they are all explained for you:

Opcode Fetch Cycle:

Here, the nature of the instructions to be carried out is found out. The Program Counter contents are placed on the address bus and the opcode is read.

This cycle has variable lengths ranging from 4 to 6 T states. Depending on the instructions, the states can be as follows:

Memory Read Cycle:

Here, the content of ROM or R/W memory is read and has three states as follows:

Memory Write Cycle:

Here, the data is stored into the stack memory or data memory in three states. These states are similar to the above with the only exception that in the T2 state, WR signal low is sent for writing in the memory location.

When it is high, it disables the memory device and the write operation is concluded.

I/O Read and I/O Write Cycles:

These cycles are similar to the memory read and write machine cycles with the difference that the IO/M signal is high to indicate that it is an I/O operation.

Interrupt Acknowledge Cycle:

In this cycle, instruction from the external devices is read according to the signal and is almost similar to the opcode fetch cycle for RST instruction with a slight difference such as:

Read Also:  Chipset and Processor: 8 Differences

And, for CALL instructions, two bytes of the CALL address are fetched through two extra interrupt acknowledge machine cycles.

Bus Idle Cycle:

Here, the machine cycle is not Read or Write and is akin to memory read cycles but the ALE and RD signals are not set off.

Machine Cycle Examples

An example of a complete machine cycle and its steps can be solving a math problem.

The entire cycle includes:

Machine Cycle Steps

Typically, one machine cycle is completed by performing four steps namely, fetch, decode, execute and store.

The functions performed in these different steps are:

What is Machine Cycle State?

The states in a machine cycle, called T states, refer to the part of the cycle that is completed in one single internal clock pulse. It is actually one time period of frequency of the processor.

There is also a wait state that a processor enters into during a machine cycle.

T states:

In simple words, it is the time taken by the processor to complete the process of accessing the memory or the I/O devices.

These T states are typically measured from the falling edge of a single clock pulse to the following clock pulse. This measure may vary depending on the maximum clock frequency of the processor.

Wait states:

Apart from the T state, there is also the concept of wait states in a few specific processors such as 8085.

This is something that happens in a few specific applications where the timing of the processor does not match the speed of the I/O system or the memory system. This means that it takes a longer time to read or write data.

In such circumstances, the processor will first have to confirm whether or not a peripheral device is ready to move data.

If the pin is READY, in other words, if it is high, data transfer will happen. Otherwise, the processor will enter into a wait state during the machine cycle.

This wait state will keep on being inserted as long as READY is low and during this state all the contents of the data bus, control bus and address bus will be held constant.

Read Also:  What is 6th Generation Processor? Pros, Cons & More

An additional clock cycle time is given to the I/O port or addressed memory by the wait state so that it can yield legitimate data on the data bus.

This characteristic allows using I/O devices and memory that may have extended access times.

How Many States are there in the Machine Cycle?

Every part of the machine cycle may consist of 3 to 6 T states, also referred to as clock cycles or clock periods wherein the fetch cycle has four T states and the execution cycle has three of these states. Along with others, there can be as many as 13 T states in total.

The breakup of these states is as follows:

Machine Cycle Vs Instruction Cycle

Conclusion

The machine cycle is the process of executing an instruction by a computer in four easy steps that involves fetching, decoding, executing, and storing.

The machine cycle of a computer is not only important for it to perform, but it also helps in calculating the performance of the processor and selecting the device.