Computer Architecture
Computer Architecture
Computer Architecture:
Foundations and Structure
digital logic,
computer block structure,
I/O communication,
and interrupts.
Computer Architecture decides the instruction set, data types, memory addressing
—it’s what the programmer sees.
“In short:
Architecture = What the computer does.
Organization = How the computer does it.”
Basics of Digital Logic
Basic components:
Sequential Circuits: Output depends on current and past inputs (memory involved)
NOT Gate
In a NOT gate, the output of a NOT gate attains state 1 if and only if the input does not attain state 1
The Boolean expression is Y=A’
.
A NOT A
0 1
1 0
OR Gate
In an OR gate, the output of an OR gate attains state 1 if one or more inputs attain state 1
.The Boolean expression of the OR gate is Y = A + B
A B A OR B
0 0 0
0 1 1
1 0 1
1 1 1
AND Gate
In the AND gate, the output of an AND gate attains state 1 if and only if all the inputs are in state 1.
The Boolean expression of AND gate is Y = A.B
A B A AND B
0 0 0
0 1 0
1 0 0
1 1 1
NOR Gate
This gate is the combination of OR and NOT gates.
The Boolean expression of the NOR gate is
A B A NOR B
0 0 1
0 1 0
1 0 0
1 1 0
NAND Gate
This basic logic gate is the combination of AND and NOT gates.
The Boolean expression of the NAND gate is
A B A NAND B
0 0 1
0 1 1
1 0 1
1 1 0
🔧 Universal Gates: Why They Are
Called "Universal"
A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0
A B A XNOR B
0 0 1
0 1 0
1 0 0
1 1 1
Combinational and Sequential Circuits
Before diving into circuit types, let's understand how we got here:
🔹 From Logic Gates to Digital Circuits
Basic logic gates (AND, OR, NOT) are the building blocks of all digital systems.
Just like alphabets form words, gates are combined to form logic expressions.
By combining gates in different ways, we build circuits that can make decisions
or store information.
🔸 Combinational Circuits:
Output depends only on current inputs
No memory element
Examples:
Adders, Subtractors,
Multiplexers, Demultiplexers,
Encoders, Decoders
🔸 Sequential Circuits:
Output depends on current input + previous states
(i.e., they have memory)
Use flip-flops as storage elements
Examples:
Latches, Flip-Flops,
Counters,
Shift Registers,
Finite State Machines
🔍 Comparison Table: Combinational vs Sequential Circuits
Feature Combinational Circuits Sequential Circuits
Memory No Yes
The flip flop is a circuit that maintains a state until directed by input to change the state.
A basic flip-flop can be constructed using 4 NAND or 4 NOR gates, popularly known as-
basic digital memory circuit.
TYPE OF FLIP-FLOPs
SR flip-flop
JK flip-flop
D flip flop
T flip-flop
🔸 Encoder, Decoder, Multiplexer, Demultiplexer
These are key combinational circuits used in digital systems:
✅ Definitions:
Encoder: Converts 2ⁿ input lines into n-bit output.
Decoder: Converts n-bit input to 2ⁿ output lines.
Multiplexer (MUX): Selects one of many inputs and forwards it to a single output line.
Demultiplexer (DEMUX): Takes a single input and routes it to one of many outputs.
🔍 Comparison Table:
Feature Encoder Decoder Multiplexer (MUX) Demultiplexer (DEMUX)
Binary input → single high Select 1 input among Send input to selected
Purpose Input → binary output
output many output
Example Keyboard Encoder 7-segment Display Decode 8-to-1 Multiplexer 1-to-8 Demultiplexer
Multiplexer & Demultiplexer
.
Block Structure of a Computer
Main Components:
Input Unit – Devices that send data to the computer (keyboard, mouse)
Communication Methods:
Programmed I/O
CPU controls and checks I/O device status
Slows down CPU (polling)
Interrupt-Driven I/O
I/O device interrupts CPU only when needed
CPU can do other tasks in the meantime
DMA (Direct Memory Access)
Device transfers data directly to memory
CPU is not involved in data transfer
What is an Interrupt?
An interrupt is a signal that temporarily stops CPU's current activity
CPU saves current state, handles the interrupt (e.g., keyboard press), then resumes
Like raising your hand in class – temporarily getting attention
Types of Interrupts
Hardware Interrupts
Caused by external devices (keyboard, mouse, timer)
Maskable
Can be disabled (masked) by software (e.g., INTR in 8086)
Non-maskable
Cannot be disabled;
used for critical tasks like power failure
Software Interrupts
Generated by programs (errors, system calls)
Normal
Exception
Interrupt Vector Table:
List of memory addresses of interrupt service routines
For example let us take a task that involves two activities :
Method #1 : The COMPUTE routine passes N lines to the PRINT routine and the PRINT routine then
prints the N lines one by one on a printer. All this time the COMPUTE routine keeps on waiting and
does not do anything useful.
Method #2 : • The COMPUTE routine passes N lines to the PRINT routine. The PRINT routine then sends
one line to the printer and instead of printing that line it execute itself and passes the control to the
COMPUTE routine . The COMPUTE routine continuous it activity, once the line has been printed the
printers sends an interrupt to the processor of the computer. At this point the COMPUTE routine is
suspended and the PRINT routine is activated and the PRINT routine send second line to the printer so
that the printer can keep on printing the lines and the process continues.
INTERRUPT SERVICE ROUTINE AND IT’S WORKING
The routine that gets executed when an interrupt request is made is called as interrupt service routine.
NMI Actions:
Completes current instruction
Pushes flags, CS, and IP onto stack
Loads new IP from address 000AH, resets IF and TF
INTR Actions:
Completes current instruction
Activates INTA and receives interrupt type
Pushes flags, CS, IP
Loads IP from Type × 4, CS from next word
Resets IF and TF
📌 Note:
If IF = 0 → No INTR interrupt is served
If IF = 1 → CPU ready to respond
After handling an INTR, IF is reset
To serve future INTRs, IF must be re-enabled
🔹 Software Interrupts in 8086
Generated by executing INT instruction in program (e.g., INT 21H)
256 software interrupts: INT 00H to INT FFH
2-byte instruction
ISR addresses are stored from 0000H to 03FFH
Type Purpose
0 Division by zero
1 Single-step debug
2 NMI – power failure
3 Breakpoint
4 Overflow interrupt
5-31 Reserved for advanced use
Feature Meaning
Cascading (up to 64) Can be connected with other PICs to manage 64 devices
Doesn’t run the ISR Just sends the signal to CPU — CPU handles the rest
🔹 Definitions (8085/8086)
Vectored Interrupt: ISR address is fixed and known to processor
Non-Vectored Interrupt: ISR address is given by the device
🔹 8085/8086 Interrupts
8085 has 5 interrupts: TRAP, RST7.5, RST6.5, RST5.5, INTR
TRAP is non-maskable, others are maskable
INTR is non-vectored (ISR address given by device)
Others are vectored (ISR address known to processor)
16-bit Program Counter (PC) Keeps track of the address of the next instruction to execute
16-bit Stack Pointer (SP) Points to the top of the stack in memory (used for temporary storage)
Accumulator (A) An 8-bit register used in math, logic, and I/O operations
Flag Register Holds results of operations — like carry, zero, negative, etc.
Instruction Register & Decoder Loads instructions from memory and figures out what to do
✅ 8086 Microprocessor – At a Glance
Developed by Intel in 1978
It’s a 16-bit microprocessor – can process 16 bits of data at a time
Made using HMOS technology
Comes in a 40-pin DIP package
Contains 29,000+ transistors
Maximum clock speed: 5 MHz
3 ports: A, B, C (8-bit each) You get 3 input/output ports, each 8 bits wide
Programmable You can set which ports are used for input or output
Works in different I/O modes - Simple input/output- Interrupt-driven I/O for faster response
Instruction Cycle Overview
1. Fetch instruction from memory
2. Decode the instruction
3. Execute the instruction using ALU or
control unit
4. Store the result (if needed)
8051 Microcontroller 8-bit MCU with built-in timers, serial port, I/O ports, and interrupts
8156 Timer + I/O Has a timer and 2 I/O ports
8251 Serial Communication USART — for serial data transmission
8253 Timer/Counter 3 independent counters
8255 I/O Interface Connects CPU with keyboard, LEDs, LCD, etc. (24 I/O pins)
8257 DMA Controller Direct Memory Access: memory ↔ I/O transfer
8259 Interrupt Controller Handles multiple interrupts
8279 Keyboard/Display Control Manages keyboard matrix and 7-segment display
LBS MCA CRASH COURSE 2025
Thank You! 😊