Skip to main content

Microcontrollers

Section 2.2 Instruction Register and Decoder

The instruction register (refer to Section 2.4 for a discussion on registers) contains the binary numbers corresponding to the machine instruction (introduced in Subsection 1.3.1) of the piece of software code currently being executed. The size of the instruction register is equal to the word size of each instruction. It’s possible that the word size of an instruction may be larger than the defined bit-size of a microcontroller. (For example, the ATmega328P is an 8-bit microcontroller that has an instruction word size of 16 bits.) In addition, it’s possible that some instructions may require multiple words to express.
The instruction decoder takes the value stored in the instruction register and translates it into appropriate control and address signals. As an example, an addition instruction typically requires two distinct input signals (which could be routed from data memory or a register). The instruction decoder will determine where and how to send the two input signals into the adder hardware in the ALU, then route the solution back to the intended destination. The source of the input signals and destination of the output signal will be defined in the machine instruction, which can be directly programmed using assembly language.
The hardware used to build an instruction decoder is beyond the scope of this textbook.