Data Representation and Computer Structure Study Guide
Introduction to Data Representation and Computer Structure
Inside modern computers, all information is encoded in the form of 0s and 1s, which are called bits (short for binary digits). These bits are the fundamental building blocks of computing, similar to how letters are the building blocks of words. Patterns of bits are combined to represent various types of information, including text, numbers, images, and sound. At a mechanical level, computers are machines that manipulate digital signals that are either 'on' (1) or 'off' (0). This principle is primary to all fields of computer science, including programming, machine learning, and robotics.
Key definitions and concepts include:
- Bit: The smallest unit of data in computing.
- Byte: A collection of 8 bits ().
- Encoding/Decoding: Raw binary data must be encoded into patterns to represent information and decoded according to its type to be useful to human users.
- Boolean Logic: A type of algebra where results are calculated as either True or False.
- Buses: Communication channels used to connect computer components, allowing data and signals to pass between them. The system bus, consisting of the address, data, and control buses, is essential for the machine cycle.
Binary Representation of Data
A bit can exist in one of two binary states: 0 or 1. Historically, the word 'binary' comes from the Latin 'bini', meaning 'two together'. In practical applications, 0 often symbolizes 'Off' or 'False', while 1 symbolizes 'On' or 'True'. Complex data is represented through sequences of these bits known as bit patterns.
Integer Representation
Encoding numbers in binary involves shifting from base-10 (decimal) to base-2 (binary). In base-2, place values increase by powers of 2 from right to left (, etc.).
Decimal to Binary Conversion
To convert a decimal number to binary, one must divide the number repeatedly by 2 until the quotient is 0, then read the remainders in reverse order.
Example Case: Converting 13 to binary
- (Remainder 1)
- (Remainder 0)
- (Remainder 1)
- (Remainder 1) Result in reverse order:
Example Case: Converting 25 to binary
- (Remainder 1)
- (Remainder 0)
- (Remainder 0)
- (Remainder 1)
- (Remainder 1) Result in reverse order:
Leading zeros can be added to these patterns to fill a full 8-bit byte. For instance, the decimal number 5 is represented as in an 8-bit format.
Binary to Decimal Conversion
Conversion uses the positional notation system where each bit represents a power of 2 based on its position, starting at position 0 on the right.
Example: Converting to decimal
Example: Converting to decimal
Text Representation
Characters are mapped to binary values using specific standards:
- Standard ASCII: A 7-bit code representing 128 characters (95 printable characters like A-Z, 0-9, and symbols, plus 33 non-printable control characters).
- Extended ASCII: An 8-bit code representing 256 characters ( additional symbols).
- Unicode: A 16-bit standard that overcomes ASCII limitations, aiming to provide a unique number for every character across all languages and platforms. Extended ASCII is a subset of Unicode (the first 256 characters).
Examples of ASCII codes:
- 'A' = 65 (Decimal) = (Binary)
- 'a' = 97 (Decimal) = (Binary)
Image, Audio, and Video Representation
Images: Digital images are composed of pixels, the smallest unit of a display. A bitmap is a grid of binary data representing pixel color values. If 1 bit is used per pixel, only 2 colors (e.g., black and white) are possible. If 2 bits are used (), four colors are possible (00, 01, 10, 11).
Audio: Represented as digital audio, sound is recorded as a sequence of samples. Each sample encodes the amplitude of a sound wave at a specific time.
- 8-bit audio: levels of resolution.
- 16-bit audio: levels (CD-quality standard).
- 24-bit audio: levels (professional high-fidelity).
Video: A series of image frames played in rapid succession, where each frame is encoded using bit patterns.
Data Transmission: When data is sent over networks, binary representations are broken into fixed-size pieces called packets and reassembled at the destination.
Boolean Logic and Operations
Boolean logic, developed by George Boole, uses algebra where values are True (1) or False (0). It is the basis for digital circuit design and decision-making in programming.
Standard Logical Operations
- AND Operation: Output is 1 (True) only if both inputs (A and B) are 1. Otherwise, the output is 0.
- OR Operation: Output is 1 (True) if at least one input is 1. If both are 0, the output is 0.
- NOT Operation: A unary operator that flips the input value (if 0, output is 1; if 1, output is 0).
Computer Memory and Structure
Memory Units
Memory is measured using the following hierarchy:
- Bit (b): Smallest unit.
- Byte (B): 8 bits.
- Kilobyte (KB): 1024 bytes.
- Megabyte (MB): or .
- Gigabyte (GB): or .
Components of a Computer System
A computer comprises a CPU, memory, input devices (keyboard, mouse), output devices (screens, printers), and storage devices. Bits are stored in memory using electronic circuits called flip-flops, which can hold exactly one bit of data.
Types of Memory
- Random Access Memory (RAM): Volatile working memory directly accessible by the CPU. It holds data currently being processed. When power is lost, data is lost.
- Read-Only Memory (ROM): Non-volatile memory that retains data without power. It stores instructions for housekeeping functions and booting the operating system.
- Secondary Memory: Non-volatile, permanent external storage (HDDs, SSDs, Flash drives). It has higher capacity but slower access speeds than RAM.
- Cache Memory: Small, high-speed memory on or near the CPU that acts as a buffer for frequently used data to prevent the CPU from waiting on RAM.
- Registers: Found within the CPU, these are the smallest and fastest storage units for immediate data processing.
Memory Hierarchy
The hierarchy is organized by speed, cost, and capacity. From top (fastest/smallest) to bottom (slowest/largest):
- CPU Registers
- Cache
- Main Memory (RAM)
- Secondary Storage (SSD/HDD)
- Optical Drives (CD/DVD)
The Central Processing Unit (CPU)
The CPU is the 'brain' of the computer, responsible for processing data into information. It consists of three primary internal parts:
- Control Unit (CU): Manages operations, controls the execution of instructions, fetches and decodes data, and manages other components via internal buses.
- Arithmetic and Logic Unit (ALU): Performs arithmetic () and logical operations () and comparisons ().
- Registers: Temporary storage for instructions and addresses being processed. Key registers include:
- Memory Address Register (MAR): Stores memory addresses being read from or written to.
- Program Counter (PC): Stores the address of the next instruction.
- Memory Data Register (MDR): Holds data being transferred to and from the processor.
Supporting CPU Components
- Clock: Sends regular electrical pulses to keep components in step. Speed is measured in Gigahertz (GHz). One cycle represents one unit of work (fetching, decoding, etc.). Higher clock speed improves performance.
- System Bus: A collection of lines connecting the CPU to memory and other hardware. It consists of:
- Address Bus: Sends memory addresses to components.
- Data Bus: Transfers actual data between components.
- Control Bus: Sends control signals.
The Machine Cycle
The CPU follows a sequence known as the Fetch-Decode-Execute-Store (FDES) cycle:
- Fetch: The CPU retrieves an instruction from memory. The address bus provides the RAM location from the Program Counter, and the data bus carries the instruction to a CPU register. The Program Counter is then incremented.
- Decode: The CU interprets the instruction, identifying the required operation and operands into a format understand by the CPU.
- Execute: The CPU performs the specified task (math, data movement, or logic).
- Store: Results are written back to memory or registers for future use.
All tasks performed by a computer are translated into the CPU's Instruction Set Architecture (ISA), which is the specific sequence of simple commands the processor understands.
Embedded Systems
An embedded system is a special-purpose computer encapsulated within the device it controls. Examples include fitness trackers, digital watches, GPS systems, and domestic appliances like washing machines.
Characteristics and Advantages:
- Pre-defined tasks: They have specific requirements and are generally not programmable by the user.
- Real-time operation: They respond quickly to environment changes.
- ROM-based software: Often stored in Flash ROM for speed and reliability.
- Limited hardware: Usually lack disk drives and use small keypads or touch screens for interfaces.
- High efficiency: Specialized for specific jobs to ensure minimal errors.
Questions & Discussion
Activity 1.20: Real Life Processing Examples
- Input: Dirty clothes -> Processor: Washing machine -> Output: Clean clothes.
- Input: Broken car -> Processor: Garage -> Output: Fixed car.
- Input: Raw chicken -> Processor: Fire -> Output: Roast chicken.
- Input: Person with long hair -> Processor: Hairdressers -> Output: Person with short hair.
Discussion on Browser Caching Browser cache is hardware/software storage for web pages. Clearing it can solve run-time errors or issues where the browser attempts to load an old version of a updated website. Instructions for Chrome:
- Click the three dots (top right).
- Hover over 'History' and click 'History'.
- Select 'Clear browsing data' on the left.
Review Questions Highlights
- 1 KB equals 1024 bytes. Thus, 7 KB equals .
- Speed calculation: If a CPU processes 10,000 instructions per second, in one minute (), it processes .
- ROM is non-volatile because it retains data without power.
- The CPU is analogous to the human brain.