Module 6: Basic Computer Organization & Design
1. Instruction codes: Instruction codes In computer architecture are concise groups of bits that
instruct computers to execute a specific task operation. Instruction codes and addresses are
unique to each computer. The operation code (opcode) in computer instructions is like a secret
code that commands the computer what to do such as addition, subtraction, shift, complement,
and control flow instructions.
2. Structure of an Instruction Code
The instruction code is also known as an instruction set. It is a collection of binary codes.
It represents the operations that a computer processor can perform. The structure of an
instruction code can vary. It depends on the architecture of the processor but generally
consists of the following parts:
Opcode: The opcode (Operation code) represents the operation that the processor must
perform. It might indicate that the instruction is an arithmetic operation such as
addition, subtraction, multiplication, or division.
Operand(s): The operand(s) represents the data that the operation must be performed
on. This data can take various forms, depending on the processor's architecture. It might
be a register containing a value, a memory address pointing to a location in memory
where the data is stored, or a constant value embedded within the instruction itself.
Addressing mode: The addressing mode represents how the operand(s) can be
interpreted. It might indicate that the operand is a direct address in memory, an indirect
address (i.e. a memory address stored in a register), or an immediate value (i.e. a
constant embedded within the instruction).
Prefixes or modifiers: Some instruction sets may include additional prefixes or modifiers
that modify the behavior of the instruction. For example, they may specify that the
operation should be performed only if a specific condition is met or that the instruction
should be executed repeatedly until a specific condition is met.
3. Types of Instruction Code
There are various types of instruction codes. They are classified based on the number of
operands, the type of operation performed, and the addressing modes used. The
following are some common types of instruction codes:
One-operand instructions: These instructions have one operand and operate on that
operand. For example, the "neg" instruction in the x86 assembly language negates the
value of a single operand.
Two-operand instructions: These instructions have two operands and perform an
operation involving both. For example, the "add" instruction in x86 assembly language
adds two operands together.
Three-operand instructions: These instructions have three operands and perform an
operation that involves all three operands. For example, the "fma" (fused multiply-add)
instruction in some processors multiplies two operands together, adds a third operand,
and stores the result in a fourth operand.
Data transfer instructions: These instructions move data between memory and
registers or between registers. For example, the "mov" instruction in the x86 assembly
language moves data from one location to another.
Control transfer instructions: These instructions change the flow of program execution
by modifying the program counter. For example, the "jmp" instruction in the x86
assembly language jumps to a different location in the program.
Arithmetic instructions: These instructions perform mathematical operations on
operands. For example, the "add" instruction in x86 assembly language adds two
operands together.
Logical instructions: These instructions perform logical operations on operands. For
example, the "and" instruction in x86 assembly language performs a bitwise AND
operation on two operands.
Comparison instructions: These instructions compare two operands and set a flag based
on the result. For example, the "cmp" instruction in x86 assembly language compares
two operands and sets a flag indicating whether they are equal, greater than, or less
than.
Floating-point instructions: These instructions perform arithmetic and other operations
on floating-point numbers. For example, the "fadd" instruction in the x86 assembly
language adds two floating-point numbers together.
4. computer registers/instructions: Computer registers are high-speed memory storing
units. It is an element of the computer processor. It can carry any type of information including a
bit sequence or single data.
A register should be 32 bits in length for a 32-bit instruction computer. Registers can be numbered relies
upon the processor design and language rules.
The instructions in a computer are saved in memory locations and implemented one after another at a
time. The function of the control unit is to fetch the instruction from the memory and implement it. The
control does the similar for all the instructions in the memory in sequential order.
Register Number of
Register Name Function
Symbol Bits
OUTR 8 Output register It holds output character.
INPR 8 Input register It holds input character.
PC 12 Program Counter It holds the address of the instruction.
AR 12 Address Register It holds an address for memory.
DR 16 Data Register It holds memory operand.
AC 16 Accumulator It’s a processor register.
IR 16 Instruction Register It holds an instruction code.
Temporary
TR 16 It holds temporary data.
Register
5. What is Program Counter?
There is a register in a PC (program counter) processor that contains the address of the next
instruction to be executed from memory. It is a 16 bit register and is also called instruction
counter, instruction pointer, and instruction address register (IAR). PC (program counter) is a
digital counter which is needed to execute tasks quickly and track the current execution point.
All the instructions and data present in memory have a special address. As each instruction is
processed, the program counter is updated to the address of the next instruction to be fetched.
When a byte (machine code) is fetched, the PC is incremented by one. So that it can fetch the next
instruction. If the computer is reset or restarted, the program counter returns to zero value.
For example, suppose the content of PC is 8000H. Which means that the processor wants to
fetch the instruction byte on 8000H. After fetching the byte at 8000H, the PC automatically
increments by one (1). In this way the processor becomes ready to fetch the next byte of the
instruction or to fetch the next opcode.
6. Difference Between Program Counter (PC) and Instruction Register (IR):
Program Counter (PC) Instruction Register (IR)
Instruction register is one of the
A program counter is a register which
registers used in holding the present
stores the address of the next
instruction that is currently being
instruction to be retrieved from the
executed or decoded by the CPU. It
memory. It indicates the place in the
consists of the binary code for the
memory where the next instruction is
instruction that has been fetched from
kept.
memory.
Holds the memory address that will It stores a binary code of the currently
fetch the next instruction. running instruction.
The PC ensures that it keeps on
The instruction is fetched from memory
recording the order in which instructions
and stored in the IR, whose content is
will be performed and always points at
subsequently used by the CPU for
the address where the next instruction
decoding and executing. In many cases,
should continue. The PC typically
information contained in this field is
proceeds with an update after it has
interpreted according to op code stored
fetched an instruction from a specified
in register for instructions.
address.
As the program runs through different During every cycle, new instructions are
steps, the PC gets incremented or fetched from memory and the content of
changed such that it can direct the the IR is updated.
Program Counter (PC) Instruction Register (IR)
computer towards the next instruction
sequentially.
7. Workflow Diagram of Instruction Register
Here is explanation of each component of above diagram:
Memory: This is the location of instructions and data. Information is fetched and stored by the
CPU via its communication with memory.
Memory Control Unit: It controls the flow of information in between the CPU and memory.
Address Register: It is the pointer that points to the next machine which is used for fetching
instructions.
Instruction Fetch Unit: It reads the instruction from the memory location addressed.
Instruction Register (IR): Temporarily holds the fetched instruction. Here, the opcode and
operands can be found.
ALU (Arithmetic Logic Unit): Executes all the arithmetic and logic instructions retrieved from the
internal register.
8. timing and control:
Timing and control are defined as the components of a computer that indicate when some
operations are to be carried out. With timing, the various elements are synchronised so that
they work together at the proper time intervals. Control the data where to go and dictate how
instructions are executed by the different parts of the system. These processes work together
with CPU to ensure that operations are executed in a manner at the correct time.
The timing and control unit (TCU) produces the timing signals that synchronise the various
operations while producing control signals that manage the data flow between the different
components of the system.
9. Functions of the Timing and Control Unit
The Timing and Control Unit (TCU) is a central component of a computer system, orchestrating
the operation of the processor and ensuring various components' concerted efforts and correct
temporal alignment during execution. The TCU organises discrete instances of sequenced
execution of processes and subsystems throughout the entire system. The major components of
TCU include timing signals and control signals. Below, we explore their roles in detail.
10. Role of Timing Signals:
Timing signals ensure that various operations in the computer system happen in a synchronised
manner. They signal when each operation starts and ends to prevent data collisions or conflicting
executions. Usually, operations are regularly triggered using a timing signal, as a timing signal often
occurs at fixed intervals in modern processors.
Timing signals synchronise operations in the Fetch-Decode-Execute cycle:
Instruction Fetch: Instruction fetching is activated by a timing signal from the particular state of
the fetch-execute cycle. This will make sure that the program counter (PC) points to the proper
memory location, fetches the instruction, and places it in the instruction register (IR) for
processing.
Instruction Decode: The next timing signal will synchronize the decoding of the instruction. With
the instruction in the IR, timing signals help direct the control unit to decode the instruction into
specific operations for the ALU, memory, or other components. This timing signal thus ensures
proper instruction interpretation between its opcode and operands.
Execute: Finally, timing signals will determine when during the execute phase, the ALU will
process the instruction (i.e., arithmetic or logic operation) or the movement of data from/to
memory. The signal would determine when the ALU will execute the operation and when the
result is stored in a register or memory.
11. Types of Control Units
There are two main types of control units in a computer's CPU
1. Hardwired Control Unit
2. Microprogrammable control unit
Hardwired Control Unit
Hardwired control units generate control signals using rigid logic circuits. These circuits are designed for
specific operations,using fast-controlled hardwired units. The speed of control signals generation by
hardwired units is incredible because they depend on physical circuits, and these circuits have the
capability of working extremely fast.
The key advantage of this approach is speed because control signals are generated directly through
physical circuits, and they can operate very quickly. However, hardwired control units are less flexible,
making them suitable for small or specialised systems that do not require frequent updates or complex
operations. An example is a basic embedded system or a small CPU for a specific application.
Microprogrammed Control Unit
Microprogrammed control units use a set of instructions (called micro-operations or microprograms) to
generate control signals. Compared to hardwired units, this approach enjoys far more flexibility because
modification of the microprograms is trivial. This makes microprogrammed control units most suitable
for more complex systems, or general-purpose CPUs, in which flexibility and modification are essential.
Microprogrammed control units most commonly used for larger systems like general-purpose
processors (for example, in PCs or smartphones).