Computer Architecture: Memory, Machine Language, and Communication, Schemes and Mind Maps of Computer Science

A comprehensive overview of computer architecture, covering key concepts such as memory types, machine language instructions, communication between devices, and bitwise operations. It delves into the functionality of registers, main memory, mass storage, and cache memory, explaining their roles in data storage and retrieval. The document also explores the fetch-decode-execute cycle, program counter, and the distinction between programs and data. It further examines logic operations, shift operations, and their applications in computer programming. The document concludes with a discussion of social issues related to computer architecture, including ownership, planned obsolescence, and the impact of technology on society.

Typology: Schemes and Mind Maps

2024/2025

Available from 01/04/2025

hamza-anjum
hamza-anjum 🇵🇰

8 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
2.1 Computer Architecture
The circuitry in a computer that controls the manipulation of data is called the
Central Processing Unit (CPU)
, or processor.
CPU Basics
A CPU consists of three parts:
Arithmetic/Logic Unit
: contains the circuitry that performs operations on data
(such as addition and subtraction)
Control Unit
: contains the circuitry for coordinating the machine's activities
Register Unit
: contains data storage cells (similar to main memory cells), called
registers
, that are used for temporary storage of information within the CPU
Registers
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.
Bus
A machine's 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 that it is supposed to retrieve the data in the indicated cell.
The Stored-Program Concept
The idea of storing a computer's program in its main memory is called the
stored-program concept
and has become the standard approach used
today.
This concept allows the program that the machine follows to be changed merely by
changing the contents of the computer's memory instead of rewiring the CPU.
Created by Turbolearn AI
Page 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download Computer Architecture: Memory, Machine Language, and Communication and more Schemes and Mind Maps Computer Science in PDF only on Docsity!

2.1 Computer Architecture

The circuitry in a computer that controls the manipulation of data is called the

Central Processing Unit (CPU), or processor.

CPU Basics

A CPU consists of three parts:

Arithmetic/Logic Unit: contains the circuitry that performs operations on data

(such as addition and subtraction)

Control Unit: contains the circuitry for coordinating the machine's activities

Register Unit: contains data storage cells (similar to main memory cells), called

registers, that are used for temporary storage of information within the CPU

Registers

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.

Bus

A machine's 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 that it is supposed to retrieve the data in the indicated cell.

The Stored-Program Concept

The idea of storing a computer's program in its main memory is called the

stored-program concept and has become the standard approach used

today.

This concept allows the program that the machine follows to be changed merely by

changing the contents of the computer's memory instead of rewiring the CPU.

Cache Memory

Cache memory is a portion (perhaps several hundred KB) of high-speed memory

located within the CPU itself. In this special memory area, the machine attempts to

keep a copy of that portion of main memory that is of current interest.

Memory Type Functionality

Registers Hold data immediately applicable to the operation at hand

Main Memory Hold data that will be needed in the near future

Mass Storage Hold data that will likely not be needed in the immediate future

Cache Memory Hold a copy of main memory that is of current interest

2.2 Machine Language

To apply the stored-program concept, CPUs are designed to recognize instructions

encoded as bit patterns. This collection of instructions along with the encoding

system is called the machine language.

The Instruction Repertoire

The list of machine instructions that a typical CPU must be able to decode and

execute is quite short. There are two philosophies of CPU architecture:

Reduced Instruction Set Computer (RISC): a CPU should be designed to

execute a minimal set of machine instructions

Complex Instruction Set Computer (CISC): a CPU should be designed to

execute a large number of complex instructions

CPU

Architecture

Characteristics

RISC Efcient, fast, and less expensive to manufacture

CISC

Can better cope with the ever-increasing complexities of today's

software

Examples of CPU Architectures

Control

Control instructions direct the execution of the program rather than the manipulation

of data. Examples include:

JUMP (or BRANCH) instructions: instructions that direct the CPU to execute an

instruction other than the next one in the list.

Conditional jumps: instructions that result in a change of venue only if a certain

condition is satised.

Machine Language Encoding

Machine language instructions consist of two parts:

Op-code (short for operation code): a bit pattern that indicates which

elementary operation is requested by the instruction.

Operand: a bit pattern that provides more detailed information about the

operation specied by the op-code.

Instruction Format

Op-code Operand

4 bits (1 hexadecimal digit) 12 bits (3 hexadecimal digits)

Instruction Examples

Instruction

Op-

code

Operand Translation

STORE 3 5A

STORE the bit pattern found in register 5 in the

memory cell at address A

OR 7 0C

OR the contents of register C with the contents of

register 5 and leave the result in register 0

Instruction Encoding

Instruction

Encoded

Version

LOAD register 5 with the bit pattern found in the memory cell at

address 6C

156C

LOAD register 6 with the bit pattern found in the memory cell at

address 6D

166D

ADD the contents of register 5 and 6 as though they were two's

complement

| GHz | One billion Hz | However, clock speed alone is not a reliable measure of a computer's power > "Benchmarking is a more meaningful way to compare the performance of dif Program execution involves the CPU fetching instructions from memory, deco

Fetch-Decode-Execute Cycle

The fetch-decode-execute cycle is the process by which the CPU executes in

  • Fetch: The CPU retrieves the next instruction from memory.
  • Decode: The CPU decodes the instruction, determining what operation
  • Execute: The CPU executes the instruction, performing the required o

Program Counter

The program counter is a register that keeps track of the current instruct

Programs vs. Data

Programs and data are stored in memory, but the CPU has no way of knowing

Advantages of Shared Memory

Having programs and data share the same memory space has several advantage

  • Programs can manipulate other programs: A program can modify another
  • Programs can write and execute other programs: A program can create

Logic Operations

Logic operations are used to combine two input bits to produce a single ou

AND Operation

The AND operation combines two input bits to produce a single output bit.

  • Masking: Placing 0s in one part of a bit pattern while not disturbin
  • Filtering: Filtering certain colors out of a digital image. > "The AND operation is like a filter that only allows certain bits to pas

OR Operation

The OR operation combines two input bits to produce a single output bit. I

  • Duplicating a part of a string: Duplicating a part of a string while
  • Forcing a 1 in a bit position: Forcing a 1 in a bit position using a > "The OR operation is like a duplicator that copies certain bits and fill

XOR Operation

The XOR operation combines two input bits to produce a single output bit.

  • Forming the complement of a bit string: XORing any byte with a mask
  • Inverting all the bits of an RGB bitmap image: Inverting all the bit > "The XOR operation is like a mirror that reflects the bits of a string."

Rotation and Shift Operations

Rotation and shift operations provide a means for moving bits within a reg

Types of Shift Operations

There are several types of shift operations:

  • Circular shift: A circular shift is a shift operation that moves the
  • Logical shift: A logical shift is a shift operation that discards th
  • Arithmetic shift: An arithmetic shift is a shift operation that pres

Uses of Shift Operations

Shift operations have several uses:

  • Multiplying twos complement representations by two: Shifting binary
  • Dividing by two: Shifting the binary string to the right corresponds

Machine Language Instructions

The machine language described in Appendix C uses opcodes 7, 8, and 9 for

OpcodeOperationDescription 7ORPerforms the OR operation between the contents of two designate 8ANDPerforms the AND operation between the contents of two designa 9XORPerforms the XOR operation between the contents of two designa

Rotation Instructions

  • The machine language described in Appendix C contains only a right circu
  • The first hexadecimal digit in the operand specifies the register to be Example: The instruction A501 means Rotate the contents of register 5 | Original Bit Pattern | Rotated Bit Pattern | | --- | --- | | 0 1 1 0 0 1 0 1 | 1 0 1 1 0 0 1 0 |

Arithmetic Operations

  • Arithmetic operations can be simulated using logical operations.
  • Subtraction can be simulated by means of addition and negation.
  • Multiplication is merely repeated addition and division is repeated subt Definition: > "Arithmetic operations are operations that perform mathematical calculat

Logical Operations

  • Logical operations combine two bits in a specific way.

Request a controller to read a sector of a disk and place the data in a

STORE A3, 5 LOAD A3, 5

### Standard Signals Devices connected to a controller convert their internal signals to a stan ### USB and FireWire * **USB (Universal Serial Bus)**: a standard interface **for** connecting devi * **FireWire**: a high-speed interface **for** connecting devices to a compute | | USB | FireWire | | --- | --- | --- | | Transfer Rate | Up to 480 Mbps (USB 2.0) | Up to 800 Mbps (FireWire 800 ) | Distance | Up to 3 meters | Up to 4.5 meters | | Devices | Mice, keyboards, printers, scanners, digital cameras, smartpho ### Handshaking The transfer of data between two computer components **is** a two-way process, > "Handshaking is a process that allows devices to communicate with each o ### Status Word A status word is a bit pattern generated by a peripheral device and sent t ### Communication Media Communication between devices can occur over two types of paths: parallel * **Parallel Communication**: multiple signals are transferred at the same * **Serial Communication**: signals are transferred one after the other ov | | Parallel Communication | Serial Communication | | --- | --- | --- | | Speed | Faster | Slower | | Complexity | More complex | Less complex | | Examples | Computer internal bus, USB, FireWire | Ethernet connections, ### Communication Rates The rate at which bits are transferred **from** one device to another **is** measu * **bps (bits per second)**: the rate at which bits are transferred * **Kbps (kilobits per second)**: 1 , 000 bps * **Mbps (megabits per second)**: 1 , 000 , 000 bps * **Gbps (gigabits per second)**: 1 , 000 , 000 , 000 bps ### Programming Data Manipulation High-level programming languages, such **as** Python, shield users **from** the de #### Logic and Shift Operations Logic **and** shift operations can be executed on numerical data. ```python x = 0b mask = 0b print(0b00000101 ^ 0b00000100) # Prints 5 XOR 4, which is 1 print(0b00000101 | 0b00000100) # Prints 5 OR 4, which is 5 print(0b00000101 & 0b00000100) # Prints 5 AND 4, which is 4 ```## Bitwise Operations Bitwise operations are used to manipulate the individual bits of a binary ### Bitwise AND (&) The bitwise AND operation compares each bit of the first operand to the co ```python print(0b10011010 & 0b11001001) # Output: 10001000 Bitwise OR (|) ## The bitwise OR operation compares each bit of the rst operand to the corresponding ## bit of the second operand. If either bit is 1, the corresponding result bit is set to 1. ## Otherwise, the corresponding result bit is set to 0. print(0b10011010 | 0b11001001) # Output: 11011011 Bitwise XOR (^) ## The bitwise XOR operation compares each bit of the rst operand to the ## corresponding bit of the second operand. If the bits are not the same, the ## corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. print(0b10011010 ^ 0b11001001) # Output: 01010011 ## Conditional statements are used to execute a block of code if a certain condition is ## true. **if** water_temp > 140 : print('Bath water too hot!') ## Loops ## Loops are used to execute a block of code repeatedly. n = 0 **while** n < 10 : print(n) n = n + 1 ## Functions ## Functions are blocks of code that can be called multiple times from different parts of ## a program. ## Built-in Functions ## Python has several built-in functions that can be used to perform various tasks. ## print(): prints the output to the screen ## bin(): converts an integer to its binary representation ## int(): converts a string to an integer ## User-dened Functions ## Users can dene their own functions to perform specic tasks. ## Function Calls ## Function calls are used to invoke a function and execute its code. x = 1034 y = 1056 z = 2078 biggest = max(x, y, z) print(biggest) # Output: 2078 ## Input and Output ## Input and output are used to interact with the user and display the results of a ## program. ## Input ## The input() function is used to get input from the user. echo = input('Please enter a string to echo: ') print(echo * 3 ) ## Output ## The print() function is used to display the output to the screen. print('Hello, World!') ## Error Handling ## Error handling is used to handle errors that may occur during the execution of a ## program. ## Type Errors ## A function is a block of code that can be called multiple times from different ## parts of a program. ## Functions can take arguments, which are values passed to the function when it ## is called. ## Functions can return values, which are values passed back to the caller when ## the function nishes executing. ## A function is like a recipe. You put in the ingredients (arguments), follow ## the instructions (the function body), and get out a result (the return value). User-Dened Functions ## User-dened functions are functions that are dened by the programmer, as ## opposed to built-in functions like input() and int(). ## User-dened functions are dened using the def keyword, followed by the ## name of the function and a list of arguments in parentheses. ## The body of the function is indented under the function denition. Example: Hypotenuse Calculator **import** math sideA = int(input('Length of side A? ')) sideB = int(input('Length of side B? ')) hypotenuse = math.sqrt(sideA** 2 + sideB** 2 ) print(hypotenuse) Example: Marathon Training Assistant **import** math **def total_seconds** (min, sec): **return** min * 60 + sec **def speed** (time): **return** 3600 / time pace_minutes = int(input('Minutes per mile? ')) pace_seconds = int(input('Seconds per mile? ')) miles = int(input('Total miles? ')) mph = speed(total_seconds(pace_minutes, pace_seconds)) print('Your speed is') print(mph) total = miles * total_seconds(pace_minutes, pace_seconds) elapsed_minutes = total // 60 elapsed_seconds = total % 60 print('Your total elapsed time is') print(elapsed_minutes) print(elapsed_seconds) Pipelining ## Pipelining is a technique used to improve the throughput of a computer by ## allowing the steps in the machine cycle to overlap. ## Pipelining can increase the number of instructions that can be executed per ## second, even if the execution speed of individual instructions remains the same. Multi-Core CPUs ## A multi-core CPU is a CPU that contains multiple processing units on a single ## chip. ## Multi-core CPUs can execute multiple instructions simultaneously, improving ## the overall performance of the computer. Multiprocessor Machines ## Example: Pipelining Conict ## Suppose two processors are attached to the same memory and executing different ## programs. One processor needs to add one to the contents of a memory cell, while ## the other needs to subtract one from the same cell. If the processors execute their ## instructions concurrently, the result may be incorrect. ## Resolving Conicts ## To resolve conicts, the system must ensure that the instructions are executed in a ## way that maintains the correct result. This can be done by: ## Using locks or semaphores to synchronize access to shared memory locations ## Implementing a cache coherence protocol to ensure that each processor has a ## consistent view of the memory ## Machine Language and Instruction Execution ## Machine language is the binary code that a computer's processor understands. It ## consists of a series of instructions, each of which species an operation to be ## performed by the processor. ## Instruction Format ## An instruction typically consists of an opcode (operation code) and an operand (data). ## The opcode species the operation to be performed, while the operand species the ## data to be used in the operation. ## Example: Instruction Format ### Opcode Operand ## LOAD 77 ## STORE 42 ## Instruction Execution ## When an instruction is executed, the processor performs the following steps: ## 1. Fetch the instruction from memory ## 2. Decode the instruction (determine the operation and operand) ## 3. Execute the instruction (perform the operation) ## 4. Store the result (if applicable) ## Program Counter and Instruction Register ## The program counter (PC) is a register that stores the address of the next instruction ## to be executed. The instruction register (IR) is a register that stores the current ## instruction being executed. ## Example: Program Counter and Instruction Register ### PC IR ## 00 LOAD 77 ## 01 STORE 42 ## Memory Organization ## Memory is organized into a series of cells, each of which can store a binary value. The ## cells are addressed using a unique address. ## Example: Memory Organization ### Address Contents ## Floating-Point Representation ## Floating-point numbers are represented using a binary format that consists of a sign ## bit, exponent, and mantissa.