Chapter 2: Hardware, Memory and Number Systems
What to remember
- The CPU has three parts: ALU (calculations and logic), CU (control and timing) and registers (tiny, fastest storage). Memory gets faster, smaller and costlier as it comes closer to the CPU.
- 1 byte = 8 bits; each storage unit is 1024 times the one before it (KB, MB, GB, TB). Computers store everything in binary (base 2).
- To convert numbers: divide repeatedly for decimal to other bases; group bits (3 for octal, 4 for hex) for binary to octal or hex. Basic logic gates are AND, OR, NOT, with NAND and NOR as universal gates.
Basic hardware and the CPU
Hardware means the parts of a computer that you can touch: keyboard, mouse, monitor, CPU, printer. Software means the programs that run on it. Every computer follows the cycle of input, processing, storage and output.
The CPU (Central Processing Unit) is called the brain of the computer. It is a small chip called a microprocessor. It has three main parts.
- ALU (Arithmetic Logic Unit): does addition, subtraction, multiplication, division and logical comparisons such as greater than or equal to.
- CU (Control Unit): directs the flow of data and instructions. It fetches an instruction, decodes it and tells other parts what to do. It does not process data itself.
- Registers: very small, very fast storage inside the CPU. They hold the data and instructions being used right now. Examples are the Program Counter (address of the next instruction), the Instruction Register, the Accumulator and the Memory Address Register.
The CPU works in a repeating cycle: fetch, decode, execute. Clock speed is measured in hertz (Hz), usually GHz today. A higher clock speed means more cycles per second. Modern CPUs have more than one core, such as dual-core or quad-core. Each core can run its own instructions. Cache memory sits on or near the CPU to hold often used data.
The motherboard is the main circuit board that joins the CPU, RAM, storage and other parts. The system bus carries signals. It has the data bus (carries data), the address bus (carries memory addresses) and the control bus (carries control signals). A port is a socket for connecting devices, such as USB and HDMI.
Input devices send data into the computer: keyboard, mouse, scanner, microphone, webcam, light pen, barcode reader, touch screen. Output devices give results: monitor, printer, speaker, plotter, projector. Some devices do both, such as a touch screen and a modem.
Memory and its hierarchy
Memory stores data and instructions. It is of two broad kinds: primary (main) memory and secondary memory.
Primary memory is directly connected to the CPU.
- RAM (Random Access Memory): read and write memory. It is volatile, which means its content is lost when power goes off. It holds the programs and data in use. Two types are SRAM (static, faster, costlier, used for cache) and DRAM (dynamic, needs refreshing, cheaper, used as main memory).
- ROM (Read Only Memory): non-volatile. It keeps its content without power. It stores the start-up (boot) instructions, called firmware or BIOS. Types are PROM (programmed once by the user), EPROM (erased by ultraviolet light and reprogrammed), EEPROM (erased by electric signal) and flash memory.
Secondary memory is permanent and large but slower. Examples are hard disk (HDD), solid state drive (SSD), CD, DVD, pen drive and memory card. HDD uses spinning magnetic platters. SSD has no moving parts, so it is faster and quieter.
Cache memory is a small, very fast memory between the CPU and RAM. It keeps copies of frequently used data. Virtual memory uses part of the hard disk as if it were extra RAM when RAM is full.
The memory hierarchy, from fastest and smallest to slowest and largest, is: registers, cache, RAM, secondary storage (SSD or HDD), and then offline storage such as optical discs. As we move down, speed and cost per byte fall, while capacity rises.
| Feature | RAM | ROM |
|---|---|---|
| Full form | Random Access Memory | Read Only Memory |
| Volatile? | Yes | No |
| Use | Running programs and data | Boot instructions |
| Write access | Read and write | Normally read only |
| Speed | Fast | Slower than RAM |
Storage units
The smallest unit is a bit (binary digit), which is 0 or 1. Four bits make a nibble. Eight bits make a byte, which stores one character. Larger units follow, each 1024 times the previous one.
| Unit | Equals |
|---|---|
| 1 Byte | 8 bits |
| 1 KB (Kilobyte) | 1024 bytes |
| 1 MB (Megabyte) | 1024 KB |
| 1 GB (Gigabyte) | 1024 MB |
| 1 TB (Terabyte) | 1024 GB |
| 1 PB (Petabyte) | 1024 TB |
The order of growth is bit, nibble, byte, KB, MB, GB, TB, PB, EB, ZB, YB. A word is the number of bits the CPU handles at once, such as 32 or 64 bits. Character codes map characters to numbers. ASCII uses 7 bits (128 characters), and extended ASCII uses 8 bits (256 characters). Unicode supports characters of many languages, including Telugu, and can use 8, 16 or 32 bits.
Number systems and conversion
A number system is defined by its base (radix). The base equals the count of digits used.
| System | Base | Digits used |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0 to 7 |
| Decimal | 10 | 0 to 9 |
| Hexadecimal | 16 | 0 to 9 and A to F |
In hexadecimal, A=10, B=11, C=12, D=13, E=14, F=15.
Decimal to binary: divide by 2 again and again and note the remainders. Read the remainders from bottom to top. Example: 13 gives remainders 1, 0, 1, 1 (from top), so 13 = 1101 in binary.
Binary to decimal: multiply each bit by a power of 2 (from the right, 1, 2, 4, 8 and so on) and add. Example: 1011 = 8 + 0 + 2 + 1 = 11.
Binary to octal: group bits in threes from the right. Example: 101 110 = 5 and 6, so 56 in octal.
Binary to hexadecimal: group bits in fours from the right. Example: 1111 0101 = F and 5, so F5 in hexadecimal.
Octal or hex to binary: write each digit as 3 bits (octal) or 4 bits (hex). Example: hex 2B = 0010 1011.
Octal or hex to decimal: multiply each digit by a power of the base and add. Example: octal 17 = 1 x 8 + 7 = 15; hex 1A = 16 + 10 = 26.
Binary addition rules: 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1), 1+1+1=11. Negative numbers are stored using 1's complement (flip all bits) and 2's complement (flip all bits and add 1).
Logic gates basics
A logic gate is a tiny circuit that takes one or more binary inputs and gives one binary output. Gates are the building blocks of the CPU.
| Gate | Rule | Output is 1 when |
|---|---|---|
| AND | Output 1 only if all inputs are 1 | Both inputs are 1 |
| OR | Output 1 if any input is 1 | At least one input is 1 |
| NOT | Reverses the input | Input is 0 |
| NAND | NOT of AND | Not both inputs are 1 |
| NOR | NOT of OR | Both inputs are 0 |
| XOR | Output 1 if inputs differ | Inputs are different |
| XNOR | NOT of XOR | Inputs are same |
NOT has only one input. NAND and NOR are called universal gates, because any other gate can be built from either one. Truth table of AND for inputs (0,0), (0,1), (1,0), (1,1) gives 0, 0, 0, 1. Truth table of OR gives 0, 1, 1, 1.
Exam traps
- RAM is volatile; ROM is non-volatile. Do not swap them.
- The ALU does calculation; the CU only controls and directs. The CU does not do arithmetic.
- Cache is faster than RAM; RAM is faster than the hard disk. Registers are the fastest of all.
- 1 KB is 1024 bytes, not 1000 bytes. A kilobyte is not a "thousand bits".
- A bit is the smallest unit; a nibble (4 bits) is not a byte (8 bits).
- Binary has base 2, octal base 8, hex base 16. Hex digit F equals 15, not 16.
- NAND and NOR are universal gates; XOR is not.
- SRAM is faster and costlier (used for cache); DRAM is slower and cheaper (used as main memory).
- ASCII is 7 bits (128 characters); extended ASCII is 8 bits (256).
One-liners
- 1. The CPU is the brain of the computer and is built on a microprocessor chip.
- 2. ALU stands for Arithmetic Logic Unit.
- 3. Registers are the fastest memory in the computer.
- 4. RAM loses its data when power is switched off.
- 5. BIOS and boot instructions are stored in ROM.
- 6. EPROM is erased by ultraviolet light; EEPROM by electric signal.
- 7. SSD has no moving parts; HDD has spinning platters.
- 8. 1 byte = 8 bits; 1 GB = 1024 MB.
- 9. Hexadecimal uses digits 0 to 9 and letters A to F.
- 10. Decimal 10 is 1010 in binary.
- 11. The NOT gate has a single input and inverts it.
- 12. Clock speed is measured in hertz (GHz for modern CPUs).
Practice questions
Which part of the CPU performs arithmetic and logical operations?
- Cache
- CU
- Register
- ALU
Answer
D. ALU
The Arithmetic Logic Unit does calculations and comparisons.
Which part of the CPU directs the flow of data and instructions?
- ALU
- Monitor
- Control Unit
- Hard disk
Answer
C. Control Unit
The CU fetches, decodes and controls but does not calculate.
Which is the fastest memory in a computer?
- Hard disk
- RAM
- DVD
- Registers
Answer
D. Registers
Registers are inside the CPU and are the fastest.
RAM is called volatile memory because
- its contents stay forever
- it can only be read
- it is used only for booting
- its contents are lost when power is off
Answer
D. its contents are lost when power is off
Volatile means data disappears without power.
Boot-up instructions of a computer are stored in
- RAM
- Registers
- ROM
- Cache
Answer
C. ROM
ROM is non-volatile and holds the start-up firmware.
How many bits make one byte?
- 4
- 8
- 16
- 10
Answer
B. 8
1 byte = 8 bits.
1 Kilobyte (KB) is equal to
- 1000 bytes
- 512 bytes
- 1024 bytes
- 1024 bits
Answer
C. 1024 bytes
Each storage unit is 1024 times the previous unit.
1 Gigabyte (GB) is equal to
- 100 MB
- 1024 TB
- 1000 KB
- 1024 MB
Answer
D. 1024 MB
1 GB = 1024 MB.
The smallest unit of data in a computer is
- nibble
- bit
- byte
- word
Answer
B. bit
A bit is a single binary digit, 0 or 1.
The base of the hexadecimal number system is
- 8
- 16
- 10
- 2
Answer
B. 16
Hexadecimal uses 16 symbols, 0-9 and A-F.
The decimal number 13 in binary is
- 1011
- 1110
- 1101
- 1001
Answer
C. 1101
13 = 8 + 4 + 1, so 1101.
Which gate gives output 1 only when all its inputs are 1?
- AND
- OR
- XOR
- NOR
Answer
A. AND
AND needs every input to be 1.
Which logic gate has only one input?
- AND
- NAND
- XOR
- NOT
Answer
D. NOT
NOT inverts a single input.
A hard disk is an example of
- secondary memory
- register
- cache memory
- primary memory
Answer
A. secondary memory
HDD gives large permanent storage and is secondary memory.
Which storage device has no moving parts?
- HDD
- Floppy disk
- SSD
- CD-ROM
Answer
C. SSD
SSD uses flash chips; HDD has spinning platters.
Which of the following is an input device?
- Printer
- Projector
- Scanner
- Speaker
Answer
C. Scanner
A scanner sends data into the computer.
Which of the following is an output device?
- Light pen
- Plotter
- Microphone
- Mouse
Answer
B. Plotter
A plotter produces printed drawings as output.
A small, very fast memory placed between the CPU and RAM is called
- virtual memory
- flash memory
- ROM
- cache memory
Answer
D. cache memory
Cache holds frequently used data close to the CPU.
Which memory type can be erased by ultraviolet light and reprogrammed?
- EPROM
- PROM
- EEPROM
- DRAM
Answer
A. EPROM
EPROM uses UV light; EEPROM uses an electric signal.
The binary number 1011 equals which decimal number?
- 9
- 11
- 13
- 10
Answer
B. 11
8 + 0 + 2 + 1 = 11.
The binary number 101110 in octal is
- 56
- 46
- 65
- 35
Answer
A. 56
Group in threes: 101 = 5, 110 = 6.
The binary number 11110101 in hexadecimal is
- D5
- 5F
- E5
- F5
Answer
D. F5
1111 = F and 0101 = 5.
The hexadecimal number 1A in decimal is
- 16
- 31
- 26
- 21
Answer
C. 26
1 x 16 + 10 = 26.
The octal number 17 in decimal is
- 8
- 15
- 14
- 17
Answer
B. 15
1 x 8 + 7 = 15.
Which pair of gates are called universal gates?
- NAND and NOR
- XOR and XNOR
- NOT and AND
- AND and OR
Answer
A. NAND and NOR
Any gate can be built using only NAND or only NOR.
The output of a NOR gate is 1 only when
- both inputs are 1
- both inputs are 0
- inputs differ
- any input is 1
Answer
B. both inputs are 0
NOR is NOT of OR, so it is 1 only if all inputs are 0.
The XOR gate gives output 1 when
- the two inputs are same
- both inputs are 1
- the two inputs are different
- both inputs are 0
Answer
C. the two inputs are different
XOR means exclusive OR: inputs must differ.
The bus that carries memory locations from the CPU is the
- control bus
- data bus
- power bus
- address bus
Answer
D. address bus
The address bus carries memory addresses.
Which register holds the address of the next instruction to be run?
- Memory Data Register
- Instruction Register
- Accumulator
- Program Counter
Answer
D. Program Counter
The Program Counter points to the next instruction.
Extended ASCII can represent how many characters?
- 512
- 65536
- 256
- 128
Answer
C. 256
Extended ASCII uses 8 bits, so 2^8 = 256.
Which memory is used as cache because it is faster though costlier?
- SRAM
- EEPROM
- PROM
- DRAM
Answer
A. SRAM
SRAM is faster and costlier than DRAM.
The correct order of memory from fastest to slowest is
- Register, Cache, RAM, Hard disk
- Cache, Register, RAM, Hard disk
- Register, RAM, Cache, Hard disk
- RAM, Cache, Register, Hard disk
Answer
A. Register, Cache, RAM, Hard disk
Speed falls as we move away from the CPU.
Part of the hard disk used as if it were extra RAM is called
- flash memory
- virtual memory
- buffer
- cache memory
Answer
B. virtual memory
Virtual memory extends RAM using disk space.
The complement method that flips all bits and then adds 1 is
- 9's complement
- 10's complement
- 2's complement
- 1's complement
Answer
C. 2's complement
2's complement = invert bits, then add 1.
In binary addition, 1 + 1 + 1 gives
- 10
- 111
- 11
- 3
Answer
C. 11
Sum is 1 with a carry of 1, written 11.
Which Unicode feature is most useful for storing Telugu text?
- Uses only 7 bits
- Supports only English letters
- Has only 128 characters
- Supports characters of many languages
Answer
D. Supports characters of many languages
Unicode covers scripts of many languages including Telugu.
Hexadecimal digit E stands for which decimal value?
- 14
- 16
- 15
- 13
Answer
A. 14
A=10, B=11, C=12, D=13, E=14, F=15.
The truth table output of an OR gate for inputs (0,0), (0,1), (1,0), (1,1) is
- 1, 1, 1, 0
- 0, 0, 0, 1
- 1, 0, 0, 0
- 0, 1, 1, 1
Answer
D. 0, 1, 1, 1
OR is 1 if any input is 1.
Statements: 1. RAM is volatile. 2. ROM is volatile. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
A. 1 only
RAM loses data without power; ROM keeps it.
Statements: 1. The CU performs arithmetic operations. 2. The ALU performs logical comparisons. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
B. 2 only
Arithmetic and logic are done by the ALU; the CU only controls.
Statements: 1. 1 byte = 8 bits. 2. 1 KB = 1024 bytes. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
C. Both 1 and 2
Both are standard storage unit definitions.
Statements: 1. NAND is a universal gate. 2. XOR is a universal gate. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
A. 1 only
Only NAND and NOR are universal gates.
Statements: 1. Octal uses digits 0 to 7. 2. Hexadecimal uses digits 0 to 9 only. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
A. 1 only
Hex also uses the letters A to F.
Statements: 1. SSD has spinning platters. 2. HDD uses magnetic platters. Which is/are correct?
- 1 only
- 2 only
- Both 1 and 2
- Neither 1 nor 2
Answer
B. 2 only
SSD has no moving parts; HDD uses magnetic spinning platters.
Match the pair: which pair is correct?
- PROM - erased by ultraviolet light
- SRAM - needs constant refreshing
- DRAM - used as cache
- EEPROM - erased by electric signal
Answer
D. EEPROM - erased by electric signal
EEPROM is electrically erasable; SRAM does not need refreshing, DRAM does.