Unit 1: Introduction to Computers

📚 What is a Computer?

A computer is an electronic device that accepts input, processes it according to a set of instructions (program), and produces output. It can also store data for future use.

Input → Processing → Output → Storage

Characteristics of a Computer:

Feature Explanation
Speed Performs billions of operations per second (measured in GHz)
Accuracy Near-perfect accuracy — errors are from human input, not computer
Storage Can store massive amounts of data (terabytes and beyond)
Diligence Never gets tired or bored — can work 24/7 without errors
Versatility Can perform many different tasks (gaming, calculations, design, etc.)
No Intelligence Cannot think on its own — strictly follows instructions given by humans

Generations of Computers:

Gen Period Technology Example Key Features
1st 1940-56 Vacuum Tubes ENIAC, UNIVAC Room-sized, very hot, unreliable, machine language only
2nd 1956-63 Transistors IBM 1401 Smaller, faster, assembly language, magnetic storage
3rd 1964-71 ICs (Integrated Circuits) IBM 360 Even smaller, high-level languages (FORTRAN, COBOL)
4th 1971-present Microprocessors (VLSI) Intel, Apple Personal computers, GUI, internet, very cheap
5th Present+ AI, Quantum Computing IBM Watson Artificial intelligence, natural language processing

Types of Computers:

📚 Hardware Components

Input Devices (data enters the computer):

Device Function
Keyboard Type text, numbers, commands
Mouse Point, click, select, drag
Scanner Converts physical documents to digital images
Microphone Audio input for voice recording/commands
Webcam Captures video input
Barcode Reader Reads barcodes on products (supermarkets)
OCR (Optical Character Recognition) Reads printed text from images/scanned documents

Output Devices (results come out):

Device Function
Monitor Displays text, images, video (soft copy)
Printer Produces paper output (hard copy). Types: Inkjet, Laser, Dot Matrix
Speaker Audio output
Projector Projects display on large screen/wall
Plotter Prints large engineering/architectural drawings

CPU (Central Processing Unit) — "The Brain":

The CPU has 3 main parts:

  1. ALU (Arithmetic Logic Unit): Performs all arithmetic (+, −, ×, ÷) and logical (AND, OR, NOT, comparisons) operations
  2. CU (Control Unit): Directs and coordinates all computer operations. Fetches instructions, decodes them, sends signals to other components. Like a traffic policeman.
  3. Registers: Tiny, extremely fast memory locations INSIDE the CPU. Used to hold data being processed right now.
    • Accumulator (AC): Stores intermediate calculation results
    • Program Counter (PC): Holds address of NEXT instruction to execute
    • Instruction Register (IR): Holds the CURRENT instruction being executed
    • MAR (Memory Address Register): Holds the address of memory to read/write
    • MDR (Memory Data Register): Holds data being read from or written to memory

Instruction Cycle (Machine Cycle):

Fetch → Decode → Execute → Store (repeats for every instruction)
  1. Fetch: CU gets the next instruction from memory (using PC)
  2. Decode: CU interprets what the instruction means
  3. Execute: ALU performs the operation
  4. Store: Result is written back to memory or register

📚 Memory Hierarchy

Computer memory is organized in a pyramid — faster memory is smaller and more expensive.

Level Type Speed Size Persistent? Examples
1 (Fastest) Registers < 1 ns Bytes No Inside CPU
2 Cache (L1, L2, L3) 1-10 ns KB-MB No On/near CPU chip
3 RAM (Primary) 10-100 ns 4-64 GB No (volatile) DDR4, DDR5
4 SSD/HDD (Secondary) µs-ms 256GB-10TB Yes (non-volatile) Hard disk, SSD
5 (Slowest) Optical/Tape (Tertiary) seconds TB+ Yes CD, DVD, tape backup

RAM vs ROM:

RAM (Random Access Memory) ROM (Read-Only Memory)
Volatile — data lost when power off Non-volatile — data stays when power off
Read AND write Read only (mostly)
Stores currently running programs & data Stores BIOS/firmware (boot instructions)
Larger (4GB-64GB) Smaller (few MB)
Types: SRAM (cache), DRAM (main memory) Types: PROM, EPROM, EEPROM

Storage Units:

1 Bit = 0 or 1 (smallest unit)
1 Nibble = 4 bits
1 Byte = 8 bits (can represent one character)
1 KB = 1024 Bytes
1 MB = 1024 KB
1 GB = 1024 MB
1 TB = 1024 GB

📚 Software

Software is a set of instructions (programs) that tells the hardware what to do. Without software, hardware is useless.

System Software Application Software
Manages/controls the computer itself Performs specific tasks for users
Runs in the background Runs on top of system software
OS (Windows, Linux, macOS), Device Drivers, Compilers MS Word, Chrome, Photoshop, Games, Excel

Operating System Functions:

Programming Language Levels:

Level Language Example Features
Low-level Machine Language 10110111 01001000 Binary only, fastest, hardware-specific
Low-level Assembly Language MOV AX, 5 Uses mnemonics, needs assembler
High-level C, Java, Python printf("Hello"); Human-readable, needs compiler/interpreter

Compiler vs Interpreter:

Compiler Interpreter
Translates ENTIRE program at once Translates line by line
Creates executable file (.exe) No separate file created
Faster execution (already compiled) Slower execution (translates each time)
Shows all errors after compilation Stops at first error
C, C++, Java Python, JavaScript, Ruby
Unit 2: Number Systems & Conversions

📚 Number Systems — How Computers Think in Numbers

Humans use decimal (base 10) because we have 10 fingers. Computers use binary (base 2) because electronics have two states: ON (1) and OFF (0). We also use hexadecimal and octal as shorthand for binary.

System Base Digits Used Example Use
Binary 2 0, 1 1010₂ = 10₁₀ Inside computer circuits
Octal 8 0-7 12₈ = 10₁₀ Unix file permissions
Decimal 10 0-9 255₁₀ Daily human use
Hexadecimal 16 0-9, A-F FF₁₆ = 255₁₀ Memory addresses, colors (#FF0000)

Decimal to Binary Conversion:

Convert 25₁₀ to binary:
Repeatedly divide by 2 and note remainders (read bottom to top):
25 ÷ 2 = 12 remainder 1
12 ÷ 2 = 6 remainder 0
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Read bottom → top: 25₁₀ = 11001₂

Binary to Decimal Conversion:

Convert 11001₂ to decimal:
Multiply each digit by 2 raised to its position (right to left, starting from 0):
1×2⁴ + 1×2³ + 0×2² + 0×2¹ + 1×2⁰
= 16 + 8 + 0 + 0 + 1 = 25₁₀

Decimal to Hexadecimal:

Convert 255₁₀ to hex:
255 ÷ 16 = 15 remainder 15 (F)
15 ÷ 16 = 0 remainder 15 (F)
Read bottom → top: 255₁₀ = FF₁₆

Binary Arithmetic:

Binary Addition:
0+0=0, 0+1=1, 1+0=1, 1+1=10 (0 carry 1)

  1011 (11)
+ 0110 (6)
————
10001 (17) ✔

1's and 2's Complement (for representing negative numbers):

1's Complement: Flip all bits (0→1, 1→0)
1010 → 0101

2's Complement: 1's complement + 1
1010 → 0101 + 1 = 0110

This is how computers represent negative numbers!
To find −5 in 8-bit: +5 = 00000101 → 1's = 11111010 → +1 = 11111011 = −5
Unit 3: Boolean Algebra & Logic Gates

📚 Boolean Algebra

Boolean algebra works with only two values: 0 (false) and 1 (true). Named after George Boole. It's the mathematical foundation of digital circuits.

Basic Operations:

Operation Symbol Meaning Truth Table
AND A · B or A ∧ B Output 1 ONLY if BOTH inputs are 1 0·0=0, 0·1=0, 1·0=0, 1·1=1
OR A + B or A ∨ B Output 1 if ANY input is 1 0+0=0, 0+1=1, 1+0=1, 1+1=1
NOT A' or ¬A Flips the value 0'=1, 1'=0

Derived Operations:

Gate Expression Output
NAND (A · B)' Opposite of AND: 1,1,1,0
NOR (A + B)' Opposite of OR: 1,0,0,0
XOR A ⊕ B Output 1 if inputs are DIFFERENT: 0,1,1,0
XNOR (A ⊕ B)' Output 1 if inputs are SAME: 1,0,0,1
NAND and NOR are called Universal Gates because ANY other gate can be built using only NAND gates (or only NOR gates).

Boolean Laws (memorize these!):

Law AND Form OR Form
Identity A · 1 = A A + 0 = A
Null/Domination A · 0 = 0 A + 1 = 1
Idempotent A · A = A A + A = A
Complement A · A' = 0 A + A' = 1
Double Negation (A')' = A
Commutative A · B = B · A A + B = B + A
Associative (AB)C = A(BC) (A+B)+C = A+(B+C)
Distributive A(B+C) = AB + AC A + BC = (A+B)(A+C)
Absorption A(A+B) = A A + AB = A
De Morgan's (AB)' = A' + B' (A+B)' = A' · B'
Simplification Example:
Simplify: F = AB + AB'
= A(B + B') ← Factor out A (distributive law)
= A · 1 ← B + B' = 1 (complement law)
= A ← A · 1 = A (identity law)

📚 Combinational Circuits

Half Adder: Adds two single bits. Outputs: Sum (XOR) and Carry (AND).

A B Sum (A⊕B) Carry (A·B)
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

Full Adder: Adds three bits (A, B, and Carry-in from previous position). Needed for multi-bit addition.

Sum = A ⊕ B ⊕ Cᵢₙ
Carry-out = AB + Cᵢₙ(A ⊕ B)

Other Important Circuits:

📚 Sequential Circuits & Flip-Flops

Sequential circuits have memory — output depends on current input AND previous state. This is unlike combinational circuits where output depends only on current input.

Flip-Flops (1-bit memory elements):

Type Inputs Behavior Use
SR Flip-Flop Set, Reset S=1: output becomes 1. R=1: output becomes 0. Both 1: invalid! Basic memory cell
D Flip-Flop Data Output follows input on clock edge. Simplest type. Registers, data storage
JK Flip-Flop J, K Like SR but J=K=1 toggles output (no invalid state) Counters, most versatile
T Flip-Flop Toggle T=1: output toggles (flips). T=0: no change. Counters

Registers: Group of flip-flops that store multiple bits. An 8-bit register stores one byte.

Counters: Circuits that count in sequence (0,1,2,3... or 3,2,1,0...). Made from flip-flops.

Unit 4-5: System Organization & I/O

📚 Bus Architecture & I/O Systems

A bus is a set of wires that carry data between computer components. Like a highway connecting different parts of a city.

Types of Buses:

Bus Carries Direction Width Example
Data Bus Actual data being processed Bidirectional (both ways) 32-bit, 64-bit
Address Bus Memory addresses (WHERE to read/write) Unidirectional (CPU → memory) 32-bit = 4GB addressable
Control Bus Control signals (read/write, clock, interrupt) Bidirectional Various signals

I/O Data Transfer Methods:

Method How It Works CPU Involvement Speed
Programmed I/O CPU continuously checks if device is ready (polling) 100% — CPU waiting the whole time Slowest
Interrupt-Driven I/O Device sends interrupt signal when ready. CPU does other work while waiting. Moderate — CPU works until interrupted Medium
DMA (Direct Memory Access) DMA controller transfers data directly between device and memory WITHOUT CPU Minimal — CPU free for other tasks Fastest

Interrupts: Signals that temporarily halt the CPU's current work to handle a higher-priority task.