Explain bus system and its types in a computer with suitable diagram.
A computer system consists of components like CPU, memory, ALU, registers, and
input/output devices. These components must communicate with each other to execute
instructions and transfer data. This communication is done using a BUS, which is a common
connection linking all components.
The bus structure connects the CPU, memory, and I/O devices and carries data, addresses,
and control signals through wires and circuits. It helps in easy data transfer and improves
system efficiency. Three parts of a Bus System are data bus, address bus & control bus.
1. Data Bus (carries data)
The data bus is a group of wires used to transfer data from one part of the computer to another.
The main objective of data bus is transfer of the data between the CPU, memory, and
input/output devices.
It carries instructions and data to and from the processor.
The data bus is bidirectional because the data can flow in either direction from CPU to memory
(or input/output device) or from memory to the CPU.
The size of the data bus decides how much data can be sent at one time.
2. Address Bus (carries memory/ I/O locations)
The address bus is a group of wires used to identify a specific memory location or I/O device.
It carries the address of the memory or I/O location that CPU wants to read from or write to.
The address bus is unidirectional, meaning it carries signals only from the CPU to memory or
I/O devices.
The size of the address bus determines how many different memory locations can be accessed.
3. Control Bus (carries timing and control signals for synchronization).
The control bus is a set of wires that carry control and timing signals between the CPU and other
parts of the computer.
It sends control signals such as read, write, and interrupt signals.
These signals help in coordinating and synchronizing the operations of all hardware
components.
The control bus is bidirectional, because signals can travel from the CPU to devices and
from devices back to the CPU.
Explain the stack organization and its types (register stack and memory stack) with a neat
diagram.
Stack Organization: A stack is a special type of memory organization in which data is stored and
removed according to the principle LIFO (Last In, First Out). A stack uses a special register called the Stack
Pointer (SP), which always points to the top of the stack.
Basic Stack Operations
PUSH: Insert data into the stack
POP: Remove data from the stack
Stack organization uses a stack for managing execution flow, storing temporary data, and
performing arithmetic or logical operations. The stack is implemented as a portion of memory, with
a stack pointer (SP) that tracks the current top of the stack.
There are two main types of stack organization: 1. Register Stack 2. Memory Stack
1. Register Stack: A register stack is implemented using a set of CPU registers. In a register stack,
memory words or registers are placed on top of each other. The address of the top element is
stored in the stack pointer register. Each time an element is added (pushed), the stack pointer is
incremented. When an element is removed (popped), the pointer is decremented.
Where:
Stack Pointer (SP): Points to the top of the stack.
Data Register (DR): Holds data being transferred.
Full: The stack is at maximum capacity and cannot hold more data (stack overflow).
Empty: The stack contains no data, and no items can be popped (stack underflow).
2. Memory Stack: A memory stack is implemented using main memory (RAM).A memory stack is
created by reserving a portion of memory for the stack. The stack pointer (SP) points to the current
top of the stack in memory. The stack typically grows downwards, with new elements being
pushed at lower memory addresses. The stack pointer register keeps track of the top of the stack,
and elements are inserted or removed using this pointer.
Where,
Program Counter (PC): Holds the address of the next instruction.
Address Register (AR): Stores memory addresses.
Stack Pointer (SP): Points to the top of the stack.
Data Register (DR): Holds data being transferred.
What is addressing? Explain the immediate addressing, Direct addressing, Register
addressing, Register indirect addressing mode with examples and diagrams.
Addressing is the method used by the CPU to find the operand (data) required to execute an
instruction. The addressing mode tells the CPU where the data is located (in instruction, memory or
in a register). Addressing mode specifies how an instruction identifies the operand (data) to
be used during execution.
Types of Addressing Modes:
1. Immediate Addressing Mode: In immediate addressing, the actual data (operand) is given
directly inside the instruction. No memory reference required.
EX: MOV R1, #25
Instruction
Opcode Data
MOV 25
Here, 25 is the data.
2. Direct Addressing Mode: In direct addressing, the instruction contains the memory address of the
data.
EX: LOAD R1, [1000]
Here, 1000 is the memory address where data is stored
Instruction
Opcode Data
LOAD 1000
Memory
address Data
1000 25
3. Register Addressing Mode: In register addressing, the operand is stored in a CPU register..
EX: ADD R1, R2
Instruction
Opcode Register
ADD R2
Register R2
Data
25
4. Register Indirect Addressing Mode: In this mode, a register holds the memory address of the
data.
EX: MOV R1, (R2)
Here, R2 contains the address of the data.
Instruction
Opcode Register
MOV R2
Register R2
address
1000
Memory
address Data
1000 25
Explain the functionalities of a register? Explain the Control and Status Registers and its
types in details.
A register is a small, high-speed storage location inside the CPU used to store data, instructions,
addresses, and intermediate results during program execution.
Main Functions of Registers
1. Data Storage: Registers temporarily store data being processed by the CPU.
2. Instruction Storage: Some registers store instructions fetched from memory before
execution.
3. Address Storage: Registers hold memory addresses required for data access.
4. Intermediate Results: Registers store intermediate results during ALU operations.
5. Control of Program Execution: Registers help in sequencing and controlling instruction
execution.
6. Improving Speed: registers provide the fastest access and improve system performance.
Control and Status Registers (CSR)
Control and Status Registers are special-purpose registers used to control CPU operations
and monitor the current state of the processor.
1. Program Counter (PC):
Holds the address of the next instruction to be executed.
Automatically updated after each instruction.
2. Instruction Register (IR):
Stores the current instruction being executed.
The control unit decodes this instruction.
3. Memory Address Register (MAR):
Holds the address of the memory location to be accessed.
Used for both read and write operations.
4. Memory Buffer Register (MBR):
Stores data read from memory or data to be written into memory.
5. Stack Pointer (SP):
Stores the address of the top of the stack.
6. Flag Register:
Contains status flags that reflect the result of ALU operations.
Ex. of flag : Zero (Z), Carry (C), Sign (S), Overflow (V)
Explain the functions of ALU and CU in a CPU.
Arithmetic Logic Unit (ALU): The ALU is the part of the CPU that performs arithmetic
and logical operations on data.
Functions of ALU
1. Arithmetic Operations: Performs basic mathematical operations such as:
Addition, Subtraction, Multiplication, Division
2. Logical Operations: Performs logical comparisons:
AND, OR, NOT, XOR
3. Comparison Operations: Compares two values. Used in decision-making instructions
Greater than, Less than, Equal to
4. Shift and Rotate Operations: Rotates bits for efficient calculations.
Shifts data left or right.
5. Updating Status Flags: Sets or resets flags such as:
Zero, Carry, Sign, Overflow
Control Unit (CU): The Control Unit directs and coordinates all activities of the CPU.
Functions of Control Unit
1. Instruction Fetching: Fetches instructions from memory using the Program Counter (PC).
2. Instruction Decoding: Decodes the instruction to understand the required operation.
3. Generating Control Signals: Sends control signals to:
ALU, Registers, Memory, Input/output devices
4. Sequencing Operations: Ensures operations occur in the correct order.
5. Data Flow Control: Manages the movement of data between:
Registers, ALU, Memory
Note: The ALU is responsible for processing data. The CU is responsible for controlling and
coordinating CPU operations.
Explain binary addition in ALU with carry generation using an example.
Binary addition in an ALU is performed using full adders. Each full adder adds two input bits and a carry-in,
producing a sum and a carry-out. The carry-out of one bit is passed as carry-in to the next higher bit.
Example: Add two 4-bit binary numbers: A = 1011 and B = 0111
1011
+ 0111
------
10010