π Lecture 30 β Data Compression: Compressing Audio and Videos
π Overview: This lecture extends the discussion of data compression from images to audio and video formats. It covers the MPEG and MP3 standards, explaining how they achieve compression by exploiting properties of human perception and using relative encoding. The lecture also introduces the CPU's basic structure, moving into data manipulation by hardware.
ποΈ Topics Covered
The lecture begins with a brief note on TIFF compression for facsimile images, then focuses on MPEG standards for video and audio compression, including I-frames and relative encoding. It explains MP3's use of temporal and frequency masking, and discusses compression goals for transmission. Finally, it introduces the CPU's three main parts: arithmetic/logic unit, control unit, and register unit.
π Lecture Summary
The TIFF collection of standards...
The TIFF collection of standards includes data compression techniques, most of which are designed for compressing images of text documents in facsimile applications. These use variations of run-length encoding to take advantage of the fact that text documents consist of long strings of white pixels. The color image compression option included in TIFF is based on techniques similar to those used by GIF and are therefore not widely used in the photography community.
31. Data Compression: Compressing Audio and Videos
The most commonly used standards for encoding and compressing audio and video were developed by the Motion Picture Experts Group (MPEG) under ISO leadership. These standards are themselves called MPEG. MPEG encompasses a variety of standards for different applications, such as high definition television (HDTV) broadcast and video conferencing, which have distinct demands for bandwidth and interactivity.
Video compression techniques are based on video being constructed as a sequence of pictures. To compress such sequences, only some pictures, called I-frames, are encoded in their entirety. The pictures between the I-frames are encoded using relative encoding techniques, meaning only the distinctions from the prior image are recorded. The I-frames themselves are usually compressed with techniques similar to JPEG.
The best-known system for compressing audio is MP3, which is short for MPEG layer 3. MP3 takes advantage of the properties of the human ear, removing details the human ear cannot perceive. One such property is temporal masking: for a short period after a loud sound, the human ear cannot detect softer sounds. Another is frequency masking: a sound at one frequency tends to mask softer sounds at nearby frequencies. By taking advantage of such characteristics, MP3 achieves significant compression while maintaining near CD quality sound.
Using MPEG and MP3 compression, video cameras can record an hour of video within 128MB of storage, and portable music players can store as many as 400 popular songs in a single GB. The goal of compressing audio and video is not necessarily to save storage space; just as important is obtaining encodings that allow information to be transmitted over communication systems fast enough for timely presentation. Audio and video compression systems are often judged by the transmission speeds required for timely data communication. These speeds are measured in bits per second (bps), with common units including Kbps (kilo-bps), Mbps (mega-bps), and Gbps (giga-bps). Using MPEG, video presentations can be relayed over paths providing transfer rates of 40 Mbps, while MP3 recordings generally require transfer rates of no more than 64 Kbps.
π Definition β I-frame: A complete video frame that is encoded in its entirety, used as a reference for compressing other frames. π Definition β Temporal masking: The property where for a short period after a loud sound, the human ear cannot detect softer sounds that would otherwise be audible. π Definition β Frequency masking: The property where a sound at one frequency tends to mask softer sounds at nearby frequencies. π Formula: bit rate units β 1 Kbps = 1,000 bps; 1 Mbps = 1,000,000 bps; 1 Gbps = 1,000,000,000 bps π Example: MPEG allows video to be transmitted at 40 Mbps; MP3 audio requires at most 64 Kbps. This difference means video requires about 625 times more bandwidth than audio for streaming.
32. Data Manipulation: CPU Basic
A CPU consists of three parts: the arithmetic/logic unit, which contains the circuitry that performs operations on data (such as addition and subtraction); the control unit, which contains the circuitry for coordinating the machine's activities; and the register unit, which contains data storage cells called registers used for temporary storage of information within the CPU. Some registers are general-purpose registers, while others are special-purpose registers.
π Definition β Registers: Data storage cells within the CPU, similar to main memory cells but faster, used for temporary storage of information during processing. π‘ Why this matters: Understanding the three CPU components is foundational to grasping how computers execute instructions at the hardware level.
β Key Takeaways
MPEG video compression relies on a mix of complete I-frames (compressed like JPEG) and relative encoding for intermediate frames, dramatically reducing storage and transmission needs. MP3 audio compression exploits human hearing limitations β temporal and frequency masking β to remove imperceptible sounds. The goal of audio/video compression is not just storage savings but enabling real-time transmission over limited-bandwidth networks, measured in bps. Finally, the CPU is built from three core units: the arithmetic/logic unit for operations, the control unit for coordination, and the register unit for fast temporary data storage.
π§ Quick Revision Questions
- What are I-frames and how are they used in MPEG video compression?
- Explain the difference between temporal masking and frequency masking in MP3 compression.
- Why might compressing audio and video for transmission be more important than saving storage space?
- What are the three main parts of a CPU and what does each do?
- What is the approximate transmission speed required for MPEG video and for MP3 audio?
π Lecture 31 β Data Manipulation: Stored Program
π Overview: This lecture explains how the CPU interacts with main memory to execute operations, detailing the role of general-purpose registers and the bus system. It then introduces the stored program concept, a foundational breakthrough that allowed computers to be reprogrammed by changing memory contents instead of rewiring the CPU.
ποΈ Topics Covered
The lecture covers the CPU and main memory connection via a bus system, the function of general-purpose registers as temporary data storage for the arithmetic/logic unit, the read and write operations between CPU and memory, the step-by-step process of adding two values stored in memory, and the stored program concept that enabled flexible computing by storing programs in memory.
π Lecture Summary
CPU and main memory connected via a bus
The CPU and main memory are connected by a collection of wires called a bus. Through this bus, the CPU extracts (reads) data from main memory by supplying the address of the pertinent memory cell along with an electronic signal telling the memory circuitry to retrieve the data in the indicated cell. Similarly, the CPU places (writes) data in memory by providing the address of the destination cell and the data to be stored together with the appropriate electronic signal telling main memory to store the data.
General-purpose registers serve as temporary holding places for data being manipulated by the CPU. These registers hold the inputs to the arithmetic/logic unit's circuitry and provide storage space for results produced by that unit. To perform an operation on data stored in main memory, the control unit transfers the data from memory into the general purpose registers, informs the arithmetic/logic unit which registers hold the data, activates the appropriate circuitry within the arithmetic/logic unit, and tells the arithmetic/logic unit which register should receive the result.
Adding values stored in memory
Based on this design, the task of adding two values stored in main memory involves more than the mere execution of the addition operation. The data must be transferred from main memory to registers within the CPU, the values must be added with the result being placed in a register, and the result must then be stored in a memory cell. The entire process is summarized by the five steps listed in Figure 42:
- Load the first value from memory into a register
- Load the second value from memory into another register
- Add the values in the two registers, placing the result in a register
- Store the result from the register back into a memory cell
Stored Program
Early computers were not known for their flexibilityβthe steps that each device executed were built into the control unit as a part of the machine. To gain more flexibility, some of the early electronic computers were designed so that the CPU could be conveniently rewired. This flexibility was accomplished by means of a pegboard arrangement similar to old telephone switchboards in which the ends of jumper wires were plugged into holes.
A breakthrough (credited, apparently incorrectly, to John von Neumann) came with the realization that a program, just like data, can be encoded and stored in main memory. If the control unit is designed to extract the program from memory, decode the instructions, and execute them, the program that the machine follows can be changed merely by changing the contents of the computerβs memory instead of rewiring the CPU.
π‘ Why this matters: The stored program concept is the foundation of all modern computingβit means computers are general-purpose machines that can run any program simply by loading different software into memory, without any hardware changes.
β Key Takeaways
The bus is the physical connection through which the CPU and main memory communicate for both read and write operations. General-purpose registers inside the CPU act as temporary storage for data that the arithmetic/logic unit processes. Adding two values in memory requires a multi-step process: loading both values into registers, performing the addition, and storing the result back to memory. The stored program concept revolutionized computing by allowing programs to be stored in memory like data, making computers reprogrammable without hardware changes. This breakthrough, associated with von Neumann, enables modern software-based computing where changing a program requires only changing memory contents.
π§ Quick Revision Questions
- What is the role of a bus in connecting the CPU and main memory?
- How do general-purpose registers support the arithmetic/logic unit's operations?
- List the steps required to add two values stored in main memory.
- How were early computers reprogrammed before the stored program concept?
- What is the stored program concept and why is it considered a breakthrough in computing?
π Lecture 32 β Data Manipulation: CPU Architecture Philosophies & Machine Instruction Categories
π Overview: This lecture explores the fundamental concept that computers store both programs and data in memory, known as the stored-program concept. It then examines two competing CPU architecture philosophiesβRISC and CISCβbefore categorizing machine instructions into three functional groups. Understanding these concepts is critical for grasping how modern CPUs process instructions and why different processors are suited for different applications.
ποΈ Topics Covered
The lecture begins with the stored-program concept, explaining its revolutionary nature. It then introduces RISC vs. CISC CPU architecture philosophies, discussing their design trade-offs and commercial examples like Intel (CISC) and ARM (RISC). Finally, it categorizes all machine instructions into three groups: Data Transfer, Arithmetic/Logic, and Control, providing examples like LOAD, STORE, and I/O instructions.
π Lecture Summary
The Stored-Program Concept
The stored-program concept is the idea that a computerβs program is stored in its main memory alongside data. This was revolutionary because previously, people believed programs and data were fundamentally separateβdata belonged in memory, while programs were part of the CPU. This insight, once considered non-obvious, is now the standard approach in all modern computers. It exemplifies how new perspectives can open doors to new theories and applications in computer science.
34. Data Manipulation: CPU Architecture Philosophies
To implement the stored-program concept, CPUs are designed to recognize instructions encoded as bit patterns. The complete collection of instructions, along with their encoding system, is called machine language. An instruction expressed in this language is a machine-level instruction (or machine instruction).
The list of machine instructions a typical CPU must decode and execute is surprisingly short. Beyond a certain point, adding more features increases convenience but does not increase a machine's theoretical capabilities. This observation has led to two competing CPU architecture philosophies:
Reduced Instruction Set Computer (RISC): This philosophy argues for a CPU that executes a minimal set of machine instructions. The argument is that such a machine is efficient, fast, and less expensive to manufacture.
Complex Instruction Set Computer (CISC): This philosophy argues for CPUs that can execute a large number of complex instructions, even if many are technically redundant. The argument is that a more complex CPU can better cope with increasingly complex software, allowing programs to exploit a powerful, rich set of instructions that would require multiple instructions in a RISC design.
In the 1990s and beyond, CISC and RISC processors competed for desktop dominance. Intel processors (used in PCs) are examples of CISC architecture, while PowerPC processors (Apple, IBM, Motorola alliance) were examples of RISC architecture. Over time, the manufacturing cost of CISC dropped, so Intel processors (or AMD equivalents) now dominate virtually all desktop and laptop computers (even Apple adopted Intel).
However, CISC has an insatiable thirst for electrical power. In contrast, Advanced RISC Machine (ARM) designed a RISC architecture specifically for low power consumption. ARM-based processors (manufactured by Qualcomm, Texas Instruments, etc.) are found in game controllers, digital TVs, navigation systems, smartphones, and other consumer electronics.
π‘ Why this matters: The choice between RISC and CISC directly impacts everything from a device's battery life to its processing speed, explaining why your laptop might use an Intel chip while your phone uses an ARM chip.
π Definition β Machine Language: The collection of instructions (encoded as bit patterns) that a CPU is designed to recognize, along with the encoding system. π Definition β RISC (Reduced Instruction Set Computer): A CPU architecture designed to execute a minimal set of machine instructions, prioritizing efficiency, speed, and low manufacturing cost. π Definition β CISC (Complex Instruction Set Computer): A CPU architecture designed to execute a large number of complex instructions, prioritizing the ability to handle increasingly complex software with fewer instructions. π Example: RISC vs. CISC in the real worldβIntel processors used in PCs are CISC; ARM processors (used in smartphones) are RISC. Intel dominates desktop/laptop computing, while ARM dominates low-power consumer electronics due to its power efficiency.
35. Data Manipulation: Machine Instruction Categories
Regardless of the RISC vs. CISC choice, all machine instructions can be categorized into three groups: (1) the data transfer group, (2) the arithmetic/logic group, and (3) the control group.
35.1. Data Transfer Group
The data transfer group consists of instructions that request the movement of data from one location to another. Note that the term "transfer" or "move" is a misnomer; the original data is rarely erasedβthe process is more like copying data.
Special terms are used for data transfer between the CPU and main memory:
- A LOAD instruction requests to fill a general-purpose register with the contents of a memory cell.
- A STORE instruction requests to transfer the contents of a register to a memory cell.
An important subgroup within this category is the I/O instructions, which handle input/output activities (communication with devices like printers, keyboards, displays, disk drives). These are sometimes considered a separate category.
π Definition β LOAD instruction: A machine instruction that requests filling a general-purpose register with the contents of a memory cell. π Definition β STORE instruction: A machine instruction that requests transferring the contents of a register to a memory cell.
35.2. Arithmetic/Logic Group
The arithmetic/logic group consists of instructions that tell the control unit to request an activity within the arithmetic/logic unit (ALU). As the name suggests, the ALU can perform operations beyond basic arithmeticβit also handles logical operations.
35.3. Control Group
(Note: The provided text does not contain the full content of section 35.3, but based on the lecture structure, the control group consists of instructions that alter the sequence of instruction execution, such as jumps, branches, and subroutine calls.)
β Key Takeaways
The stored-program conceptβstoring both programs and data in main memoryβis the fundamental insight that made modern computing possible, overcoming the earlier mental barrier of treating programs and data as separate entities. CPU architecture follows two competing philosophies: RISC (minimal instruction set for efficiency and low power consumption, exemplified by ARM chips in phones) and CISC (large, complex instruction set for richer software capabilities, exemplified by Intel chips in PCs). The choice impacts not just performance but also power consumption and manufacturing cost. All machine instructions, regardless of the architecture, fall into three categories: Data Transfer (LOAD/STORE and I/O), Arithmetic/Logic, and Control, with the first two being directly discussed in this lecture.
π§ Quick Revision Questions
- What is the stored-program concept, and why was it considered non-obvious at first?
- What is the fundamental difference between RISC and CISC architecture philosophies?
- Name a commercial example of a CISC processor and a RISC processor, and state one key application area for each.
- Why is the term "transfer" or "move" considered a misnomer for data transfer group instructions?
- What is the difference between a LOAD instruction and a STORE instruction?
π Lecture 33 β Module 36: Data Manipulation: Program Execution & Module 37: Data Manipulation: Program Execution Example
π Overview: This lecture explains how the CPU executes machine instructions through a structured cycle. It introduces the control group of instructions and the special registers that manage program flow. A practical example demonstrates the step-by-step execution of a simple addition program, from fetching instructions to storing the result.
ποΈ Topics Covered
The lecture begins by defining the control group of instructions that direct program execution rather than data manipulation. It then explains the machine instruction cycle: fetch from main memory to CPU, decode, and obey. Special purpose registers are introduced, including the Instruction Register and Program Counter. The machine cycle is illustrated, and a step-by-step execution example shows how two numbers are read from memory, added, and the result stored.
π Lecture Summary
Module 36: Data Manipulation: Program Execution
The control group consists of those instructions that direct the execution of the program rather than the manipulation of data. Step 5 in Figure 42 falls into this category.
β Machine Instruction is fetched from main memory to CPU as illustrated in Figure 43. β Each instruction is decoded and obeyed. β The order is as the instructions are stored in memory otherwise specified by a JUMP.
Figure 43: CPU and Main memory linkage using Bus
Special Purpose Registers β Instruction Register: Holding instruction being executed now. Program Counter: contains the address of next instruction to be executed.
Machine cycle is shown in Figure 44.
Figure 44: Machine Cycle
π‘ Why this matters: The machine cycle (fetch-decode-execute) is the fundamental heartbeat of every computer. Understanding how the Program Counter and Instruction Register work together is essential for grasping how programs run sequentially and how jumps alter this flow.
Module 37: Data Manipulation: Program Execution Example
In your book an example of machine instructions with their meanings are available in Appendix C at page 581. Letβs discuss it.
Letβs execute a program that reads two numbers from memory, adds them, and stores in the memory. The instructions for such an activity can be seen in Figure 45.
β Key Takeaways
The control group of instructions manages program flow rather than manipulating data. The CPU fetches each machine instruction from memory, decodes it, and executes it in order, unless a JUMP instruction changes the sequence. The Instruction Register holds the current instruction, while the Program Counter holds the address of the next instruction. The machine cycle is the repeating process of fetch, decode, and execute. A concrete example of reading two numbers, adding them, and storing the result demonstrates how these concepts work together in a real program.
π§ Quick Revision Questions
- What is the difference between the Instruction Register and the Program Counter?
- What three steps occur in the machine cycle?
- What determines the order of instruction execution if no JUMP is encountered?
- In the example program, what happens after the two numbers are added?
- What category of instructions does Step 5 in Figure 42 belong to?
π Lecture 34 β Machine Instructions for Adding Two Numbers
π Overview: This lecture demonstrates how machine instructions are loaded into main memory and executed by the CPU. It explains the step-by-step process of fetching an instruction, decoding it, and executing the load operation during the machine cycle. Understanding this process is fundamental to grasping how computers execute programs at the hardware level.
ποΈ Topics Covered
The lecture shows a snapshot of main memory with machine instructions loaded, explains how the CPU analyzes an instruction in the instruction register, describes the load activity during the execution step of the machine cycle, and illustrates how the program counter and instruction register values change after fetching the next instruction.
π Lecture Summary
Machine Instructions for Adding Two Numbers
Figure 45 presents the machine instruction format for adding two numbers. When this instruction is loaded into memory, the snapshot of the main memory is shown in Figure 46. The CPU then analyzes the instruction in its instruction register and concludes that it is to load register 5 with the contents of the memory cell at address 6C. This load activity is performed during the execution step of the machine cycle, and the CPU then begins the next cycle.
π‘ Why this matters: This demonstrates the fundamental fetch-decode-execute cycle that every CPU performs to run programs.
Machine Instructions Loaded in the Main Memory
The next cycle begins by fetching the instruction 166D from the two memory cells starting at address A2. The CPU places this instruction in the instruction register and increments the program counter to A4. The values in the program counter and instruction register therefore become the following:
Program Counter: A4
Instruction Register: 166D
π Definition β Program Counter: A register in the CPU that holds the address of the next instruction to be fetched from memory. π Formula: New Program Counter value = Old Program Counter value + 2 (since each instruction occupies two memory cells) π Example: If the program counter initially contained A2, after fetching the instruction at A2-A3, the program counter is incremented to A4, pointing to the next instruction.
π Definition β Instruction Register: A register in the CPU that holds the current instruction being executed. π Example: The instruction 166D is loaded into the instruction register from memory cells A2 and A3.
β Key Takeaways
The machine cycle consists of fetching an instruction from memory, placing it in the instruction register, then decoding and executing it. During the execution step, the CPU performs the operation specified by the instruction, such as loading register 5 with data from memory address 6C. After execution, the program counter is automatically incremented to point to the next instruction. The instruction register temporarily holds the current instruction (like 166D) while it is being processed. This cycle repeats continuously until the program ends.
π§ Quick Revision Questions
- What is the purpose of the instruction register during the machine cycle?
- After fetching an instruction from address A2, why is the program counter incremented to A4?
- What operation does the instruction tell the CPU to perform when the instruction register contains a load instruction for address 6C?
- During which step of the machine cycle does the load activity actually occur?
- What are the final values of the program counter and instruction register after fetching the instruction 166D from address A2?
π Lecture 35 β Data Manipulation: Logic Operators
π Overview: This lecture completes the machine cycle example from the previous lecture and introduces logical data manipulation operations. Understanding how the CPU executes instructions step-by-step and how logic operators manipulate individual bits is fundamental to computer architecture and low-level programming.
ποΈ Topics Covered
The lecture covers the final execution steps of a machine program showing instruction fetch, decode, execute cycle completion with a halt instruction. It then introduces data manipulation through logic operators, specifically covering AND, OR, and XOR bitwise operations, and explains the concept of masking with practical applications in image processing and bit map manipulation.
π Lecture Summary
Machine Cycle Completion
The CPU continues the machine cycle by decoding instruction 166D, which it determines means to load register 6 with the contents of memory address 6D. It executes this instruction and register 6 is actually loaded.
The program counter now contains A4, so the CPU extracts the next instruction starting at this address. The result 5056 is placed in the instruction register, and the program counter is incremented to A6. The CPU decodes this instruction and executes it by activating the two's complement addition circuitry with inputs being registers 5 and 6.
During this execution step, the arithmetic/logic unit performs the requested addition, leaves the result in register 0 (as requested by the control unit), and reports to the control unit that it has finished. The CPU begins another machine cycle, fetches the next instruction 306E from memory location A6, increments the program counter to A8, decodes and executes this instruction to place the sum in memory location 6E.
The next instruction is fetched from memory location A8, and the program counter is incremented to AA. The contents of the instruction register (C000) are decoded as the halt instruction. Consequently, the machine stops during the execute step of the machine cycle, and the program is completed.
π‘ Why this matters: This step-by-step walkthrough demonstrates how a stored program executes sequentially, with each machine cycle (fetch-decode-execute) precisely following the program counter's direction.
Data Manipulation: Logic Operators
Bitwise operations combine two strings of bits to produce a single output string by applying the basic operation to individual columns. For example, ANDing the patterns 10011010 and 11001001 results in:
10011010
11001001
--------
10001000
ORing and XORing these same patterns would produce:
OR: 10011010 XOR: 10011010
11001001 11001001
-------- --------
11011011 01010011
One major use of the AND operation is for placing 0s in one part of a bit pattern while not disturbing the other part. There are many applications, such as filtering certain colors out of a digital image represented in RGB format. If the byte 00001111 is the first operand of an AND operation, the four most significant bits of the result will be 0s, and the four least significant bits will be a copy of that part of the second operand.
This use of AND is an example of masking β one operand called a mask determines which part of the other operand will affect the result. Masking produces a result that is a partial replica of one of the operands, with 0s occupying the nonduplicated positions. This can mask off all bits associated with the red component of pixels, leaving only blue and green components.
AND operations are useful when manipulating other types of bit maps besides images β whenever a string of bits represents the presence or absence of a particular object. For example, a string of 52 bits can represent a poker hand (five 1s, rest 0s), a bridge hand (thirteen 1s), or 32 bits can represent which ice cream flavors are available.
π Definition β Bit map: A string of bits in which each bit represents the presence or absence of a particular object. π Example: To check if the third bit from the high-order end of an 8-bit bit map is 1, AND the byte with mask 00100000 β this produces all 0s if and only if that bit is 0. To change that bit from 1 to 0 without disturbing other bits, AND the bit map with mask 11011111.
Where AND duplicates a part of a bit string while placing 0s in the nonduplicated part, the OR operation can duplicate a part of a string while putting 1s in the nonduplicated part. For OR masking, indicate bit positions to be duplicated with 0s and use 1s to indicate non-duplicated positions.
β Key Takeaways
The machine cycle (fetch-decode-execute) continues sequentially with the program counter pointing to each instruction β logic operations work bit-by-bit on binary strings, producing predictable results for AND, OR, and XOR. AND masking forces certain bits to 0 while preserving others, making it useful for filtering or testing individual bits in bit maps. OR masking forces certain bits to 1 while preserving others. Bit maps represent the presence or absence of objects and are widely used in image processing, card games, and inventory systems. Masking operations are fundamental to low-level data manipulation in computing.
π§ Quick Revision Questions
- What happens during the execution step when the CPU decodes instruction 5056?
- What instruction does C000 represent, and what happens when it is executed?
- What is the result of ANDing 10011010 with 11001001?
- What is masking, and what role does the mask play in an AND operation?
- How would you change the third bit from the high-order end of an 8-bit bit map from 1 to 0 without disturbing other bits?
π Lecture 36 β Data Manipulation: Rotation and Shift
π Overview: This lecture explores how computers manipulate data at the bit level through operations like rotation, shift, and arithmetic. Understanding these operations is essential for grasping how computers perform tasks such as multiplication, division, and image processing efficiently.
ποΈ Topics Covered
The lecture covers data manipulation operations including rotation and shift (circular, logical, and arithmetic shifts) and arithmetic operators such as addition, subtraction, and multiplication. It also discusses the use of masks with AND, OR, and XOR operations for bit manipulation.
π Lecture Summary
Data Manipulation: Rotation and Shift
The operations in the class of rotation and shift operations provide a means for moving bits within a register and are often used in solving alignment problems. These operations are classified by the direction of motion (right or left) and whether the process is circular. Consider a register containing a byte of bits. If we shift its contents one bit to the right, we imagine the rightmost bit falling off the edge and a hole appearing at the leftmost end. What happens with this extra bit and the hole is the distinguishing feature among the various shift operations.
One technique is to place the bit that fell off the right end in the hole at the left end. The result is a circular shift, also called a rotation. Thus, if we perform a right circular shift on a byte size bit pattern eight times, we obtain the same bit pattern we started with.
Another technique is to discard the bit that falls off the edge and always fill the hole with a 0. The term logical shift is often used to refer to these operations. Such shifts to the left can be used for multiplying two's complement representations by two. After all, shifting binary digits to the left corresponds to multiplication by two, just as a similar shift of decimal digits corresponds to multiplication by ten. Moreover, division by two can be accomplished by shifting the binary string to the right.
In either shift, care must be taken to preserve the sign bit when using certain notational systems. Thus, we often find right shifts that always fill the hole (which occurs at the sign bit position) with its original value. Shifts that leave the sign bit unchanged are sometimes called arithmetic shifts.
π Definition β Rotation (Circular Shift): A shift operation where the bit that falls off one end is placed into the hole at the other end. π Definition β Logical Shift: A shift operation where the bit that falls off the edge is discarded and the hole is always filled with a 0. π Definition β Arithmetic Shift: A shift operation that preserves the sign bit by filling the hole at the sign bit position with its original value.
π‘ Why this matters: These shift operations are fundamental to how computers perform multiplication and division by powers of two without using complex arithmetic circuits.
Data Manipulation: Arithmetic Operators
Subtraction can be simulated by addition and negation like in two's complement notation. For example, 7 - 5 would be 7 + (-5), which means the binary of 7 will be added to the binary of -5.
Multiplication is repetitive addition.
π Formula: Subtraction in two's complement: A - B = A + (-B) π Example: 7 - 5 = 7 + (-5)
- Binary of 7: 0111
- Binary of -5 (using two's complement): 1011
- 0111 + 1011 = 1 0010 (discard overflow) = 0010 = 2 β
π Example: The lecture mentions 7 - 5 would be 7 + (-5) which means the binary of 7 will be added to binary of -5 as demonstrated in Figure 47, showing arithmetic operations examples.
π‘ Why this matters: By using two's complement representation, computers can perform subtraction using the same addition hardware, simplifying processor design.
β Key Takeaways
Students must remember that rotation (circular shift) moves bits in a loop, logical shifts fill vacancies with zeros making them useful for multiplication/division by powers of two, and arithmetic shifts preserve the sign bit for signed numbers. Subtraction in computers is performed using addition of the two's complement negative. Multiplication is implemented as repetitive addition. Understanding how masks work with AND, OR, and XOR operations is crucial for bit manipulation tasks like setting, clearing, and inverting specific bits.
π§ Quick Revision Questions
- What is the difference between a circular shift (rotation) and a logical shift?
- How does shifting a binary number left by one bit relate to multiplication?
- What distinguishes an arithmetic shift from a logical shift?
- How is subtraction performed in a computer using two's complement notation?
- What operation results when you XOR any byte with a mask of all 1s?
π Lecture 37 β Data Manipulation: Role of Controller
π Overview: This lecture explains how computers communicate with peripheral devices through controllers, which act as intermediaries translating data between the computer and external devices. It covers controller functions, bus communication, direct memory access (DMA), and handshaking protocols, which are fundamental to understanding how input/output operations work in modern computing systems.
ποΈ Topics Covered
The lecture covers controllers as intermediary apparatus for device communication, controller types including motherboard-integrated and plug-in circuit boards, standards such as USB and FireWire for device interface, how controllers connect to and communicate via the computer's bus, direct memory access (DMA) for efficient data transfer, and handshaking protocols for data flow coordination.
π Lecture Summary
Communication between a computer and other devices is normally handled through an intermediary apparatus known as a controller.
In the case of a personal computer, a controller may consist of circuitry permanently mounted on the computer's motherboard or, for flexibility, it may take the form of a circuit board that plugs into a slot on the motherboard. In either case, the controller connects via cables to peripheral devices within the computer case or perhaps to a connector, called a port, on the back of the computer where external devices can be attached. These controllers are sometimes small computers themselves, each with its own memory circuitry and simple CPU that performs a program directing the activities of the controller.
A controller translates messages and data back and forth between forms compatible with the internal characteristics of the computer and those of the peripheral device to which it is attached. Originally, each controller was designed for a particular type of device; thus, purchasing a new peripheral device often required the purchase of a new controller as well. Recently, steps have been taken within the personal computer arena to develop standards, such as the universal serial bus (USB) and FireWire, by which a single controller is able to handle a variety of devices.
π Definition β Controller: An intermediary apparatus that handles communication between a computer and other devices, translating messages between forms compatible with the computer's internal characteristics and those of the peripheral device.
π Example: A single USB controller can be used as the interface between a computer and any collection of USB-compatible devices. The list of devices on the market today that can communicate with a USB controller includes mice, printers, scanners, mass storage devices, digital cameras, and smartphones.
Each controller communicates with the computer itself by means of connections to the same bus that connects the computer's CPU and main memory (Figure 48). From this position it is able to monitor the signals being sent between the CPU and main memory as well as to inject its own signals onto the bus.
![Figure 48: Controllers attached to a machine's bus]
With this arrangement, the CPU is able to communicate with the controllers attached to the bus in the same manner that it communicates with main memory. To send a bit pattern to a controller, the bit pattern is first constructed in one of the CPU's general-purpose registers. Then an instruction similar to a STORE instruction is executed by the CPU to "store" the bit pattern in the controller. Likewise, to receive a bit pattern from a controller, an instruction similar to a LOAD instruction is used.
π Definition β Bus: The communication pathway that connects the computer's CPU and main memory, to which controllers also attach to monitor and inject signals.
Direct Memory Access and Handshaking
Since a controller is attached to a computer's bus, it can carry on its own communication with main memory during those nanoseconds in which the CPU is not using the bus. This ability of a controller to access main memory is known as direct memory access (DMA), and it is a significant asset to a computer's performance.
For instance, to retrieve data from a mass storage device, the CPU notifies the controller of the location of the desired data on the device and tells it where to put the data in main memory. The controller then performs the retrieval by placing the data directly in main memory without further CPU involvement. Thus, while the controller is retrieving the data from the mass storage device, the CPU is free to perform other activities.
π Definition β Direct Memory Access (DMA): The ability of a controller to access main memory directly during nanoseconds when the CPU is not using the bus, allowing data transfers without CPU involvement.
π Example: To retrieve data from a mass storage device, the CPU notifies the controller of the desired data's location on the device and where to put it in main memory. The controller then performs the retrieval by placing the data directly in main memory without further CPU involvement, freeing the CPU to perform other activities.
π‘ Why this matters: DMA significantly improves system performance by allowing the CPU to handle other tasks while data transfers occur in the background.
Of course, before sending data to a controller, the CPU must know whether the controller is ready to receive it. Similarly, a controller sending data to main memory via DMA must know whether the main memory is ready to receive it. This coordination can be achieved by requiring the CPU and controller to follow a protocol known as handshaking.
As an example of handshaking, consider a controller that sends data to main memory via DMA. The controller first places data on the bus and then asserts a signal known as a "data ready" signal. Meanwhile, the main memory unit asserts a signal indicating that it is ready to receive data. When the controller senses the main memory's "ready" signal while it is asserting its "data ready" signal, data transfer occurs. At this point, the controller removes its "data ready" signal from the bus, and the process can be repeated.
π Definition β Handshaking: A protocol for coordination between CPU and controller to ensure data is only sent when the receiving component is ready to accept it.
π Example: A controller sends data to main memory via DMA by first placing data on the bus and asserting a "data ready" signal. The main memory unit asserts a signal indicating it is ready to receive data. When both signals are asserted simultaneously, data transfer occurs. The controller then removes its "data ready" signal, and the process can be repeated.
β Key Takeaways
Controllers are essential intermediary devices that translate data between computers and peripherals, connecting through the computer's bus and communicating like main memory via STORE and LOAD instructions. Modern standards like USB and FireWire allow a single controller to handle multiple device types. Direct Memory Access (DMA) dramatically improves performance by enabling controllers to transfer data directly to main memory without CPU involvement, freeing the CPU for other tasks. Handshaking protocols coordinate data transfer by ensuring the sender and receiver are both ready before transmission occurs. Understanding these mechanisms is critical for grasping how input/output operations work in computer systems.
π§ Quick Revision Questions
- What are the two physical forms a controller can take in a personal computer?
- How does a controller communicate with the CPU, and what instructions are analogous to data transfer between them?
- What is Direct Memory Access (DMA), and why is it beneficial for computer performance?
- What is the purpose of handshaking in data transfer between a controller and main memory?
- Give two examples of standards that allow a single controller to handle multiple device types.