CS 151: Computer Organization and Architecture I Lecture Notes PDF
Document Details
Uploaded by ResoluteDune857
University of Dar es Salaam
Tags
Related
Summary
These lecture notes cover computer organization and architecture, focusing on the memory system. Topics discussed include memory locations, addressing, byte ordering, different memory technologies like RAM and ROM, memory characteristics, memory hierarchy, and CPU registers. The notes also present examples and diagrams.
Full Transcript
25-Nov-24 CS 151: Computer Organization and Architecture I Lecture 3a - The Memory System 1 The memory system – Unit 1 coverage Unit 1: The memory system i. Memory locations and addressing ii. Byte ordering in me...
25-Nov-24 CS 151: Computer Organization and Architecture I Lecture 3a - The Memory System 1 The memory system – Unit 1 coverage Unit 1: The memory system i. Memory locations and addressing ii. Byte ordering in memory – little and big endian iii. Memory technologies: RAM (SRAM and DRAM), and ROM iv. Memory characteristics v. Memory hierarchy —Principle of locality (temporal locality and spatial locality —Four Questions about Levels of Memory Hierarchy iv. Main Memory organization v. CPU Registers vi. Secondary Memory 25-Nov-24 Computer System Memory Unit Most computers are built using the Von Neumann model, which is centered on memory Memory is the section where information is stored. The information could be: - —Programs —Data to be processed —Results of computation A program (data & Instructions) should be stored in memory in order to get executed. The memory is equivalent to thousands of locations (multi-dimentional array of location), each storing a binary word —Each memory location has its unique identification called “Memory address” 4 25-Nov-24 Memory Unit The total number of uniquely identifiable locations in memory is called address space. — Total amount of memory that can be accessed by a computer With “k” address bits and “n” bits per location “n” is typically 8 (byte), 16 (word), 32 (long word) A word is grouped into eight bits (a byte). “n” is a word length Memory Unit Example: A 32-bit computer can address 232 = 22 × 230 = 4GB of physical memory (GB = Giga Byte) 25-Nov-24 Memory Unit Memory Unit Memory locations and addresses determine how the computer’s memory is organized so that the user can efficiently store or retrieve information from the computer. The computer’s memory is made of a silicon chip which has millions of storage cell, where each storage cell is capable to store a bit of information which value is either 0 or 1. For a computer to hold instructions and data, and a single bit is very small to hold this information so bits are rarely used individually. —As a solution to this, the bits are grouped in fixed sizes of n bits (8, 16, 32, or 64 bits, termed a “word”) 25-Nov-24 Memory Unit Data are written into memory and read out of memory, based on their address. To store any instruction or data may it be of a byte or a word, CPU have to access a memory location. Memory Unit Address starts from 0 to last addressable word in address space. To address 64 KB (26×210 = 216) of memory, need to use 16 bits for addressing. Example: 1. How many address inputs are required to access: i. 256 bytes memory? ii. 16KB of memory size? iii. 4KB of memory size? 25-Nov-24 Bytes Ordering in Memory Consider the Hexadecimal (Base 16) value (052916 = 0529H = 0000 0101 0011 10012) which requires two bytes or one word of memory. It consist of high order (most significant) byte 05 and a low order (least significant) byte 29. The processor store the data in memory in reverse byte sequence i.e. —The low order byte in the low memory address and —The high order byte in the high memory address. Bytes Ordering in Memory Most Significant Byte Least Significant Byte 05 29 In the above example the content of address 04A26H is 29, and the content of address 04A27H is = 05. 25-Nov-24 Little versus Big Endian Byte Order The term endian refers to the way the computer stores the bytes of a multiple-byte data element. Virtually all computer architectures today are byte- addressable and must, therefore, have a standard for storing information requiring more than a single byte. Little versus Big Endian Byte Order NOTE: A memory system is said to be byte-addressable if the addresses that are used correspond to individual byte locations. A word-addressable system, on the other hand, interprets the addresses as indices that indicate which multi-byte word is to be addressed: Little Endian: Store the least significant byte first (at the lower address) followed by the most significant byte. Therefore, a byte at a lower address has lower significance. 25-Nov-24 Little versus Big Endian Byte Order Big Endian: Store the most significant byte first at lower addresses, followed by its least significant byte at the most significant byte. Example: Represent the byte ordering of a Hex value 12345678H in both Big and Little Endian MSB LSB 12 34 56 78 Memory Unit Most computers are built using the Von Neumann model, which is centered on memory Memory is the section where information is stored. The information could be: - —Programs —Data to be processed —Results of computation Two types of memories 1. Main memory (or sometimes called Primary Memory). communicate directly to the CPU. 2. Auxiliary or external memory (sometimes called secondary memory). Provide backup storage. – Hard disks, Magnetic tapes/disks, Compact disks (CDs) 16 25-Nov-24 Memory Technologies In order to understand what memory technologies to apply to which processor operation, we need to understand a little bit more about the memory technologies themselves. The two memory technologies include: —Random Access Memory (RAM), and —Read Only Memory (ROM) The term Random Access Memory (RAM) is typically applied to memory that is easily read from and written to by the microprocessor, hence also called read-write memory. Random Access Memory In general, RAM is the main memory of a computer. Its purpose is to store data and applications that are currently in use. RAM is the memory to which computer specifications refer. When buying a computer with say 128MB, 128MB is being referred to RAM For a memory to be random access means that any address can be accessed at any time. The operating system controls the use of this memory dictating: —when items are to be loaded into RAM, —where they are to be located in RAM, and —when they need to be removed from RAM. RAM: —Is meant to be very fast both for reading and writing data. —Also tends to be volatile in that, as soon as power is removed, all of the data is lost. 25-Nov-24 Static RAM versus Dynamic RAM Scientists and engineers have tried to modify the technologies in order to make RAM faster and to cram more of it into a smaller space. Main classifications of RAM are: 1. Static RAM (SRAM) and 2. Dynamic RAM (DRAM). 1. SRAM: — Is made from an array of latches such as the D-latch (Flip Flop). — Each latch can maintain a single bit of data within a single memory address or location. For example, — if a memory stores eight bits per memory address, then there are eight latches for a single address. — If this same memory has an address space of 256 K, then there are 218 × 8 = 221 = 2,097,152 latches in the device. Static RAM versus Dynamic RAM generally, SRAMs: —store data in transistor circuits similar to D-latches; —are used for very fast applications such as RAM caches (where speed is more critical) —tend to store less data allowing for very fast access due to the simpler decoding logic, —static RAMs have much shorter cycle times —are volatile meaning that the data remains stored only as long as power is available. 2. DRAM — A bit in a DRAM is stored in a DRAM using a device called a capacitor. — Since a capacitor can be made very small, DRAM technology is better adapted to high density memories, 25-Nov-24 Static RAM versus Dynamic RAM In general, DRAMs: —A dynamic RAM cell is simpler and hence smaller than a static memory cell. Thus, a dynamic RAM is more dense (more cells per unit area) and less expensive than a corresponding static RAM. —will "leak" current due to the nature of capacitors and will eventually lose the data they have stored unless it is refreshed periodically; —are volatile meaning that the data is fixed and remains stored only as long as power is available. —DRAMs have longer cycle times than SRAMs. —Consequently DRAMs tend to be favored for large memory requirements, DRAMs are mainly used in computer main memory Static RAM versus Dynamic RAM 25-Nov-24 RAM Structures Static RAM Structure Dynamic RAM Structure Read Only Memory (ROM) In every computer system, there must be a portion of memory that is stable and resistant to power loss. This kind of memory is called Read Only Memory or ROM. If it was not possible to write to this type of memory, we could not store the code or data that is to be contained in it. It simply means that without special mechanisms in place, a processor cannot write to this type of memory. 25-Nov-24 Read Only Memory (ROM) The most common application of ROM is to store the computer's BIOS (Basic Input Output System). —A computer's microprocessor uses to start the computer system after it is powered on —BIOS is the code that tells the processor how to access its resources upon powering up, it must be present even when the computer is powered down. Another application is the code for embedded systems (a special-purpose system designed to perform a dedicated function). ROM ROM is a Read-Only-Memory Programs and data are permanently stored and can only be read Nonvolatile: information cannot be lost with the absent of power Information cannot be erased, changed or altered through regular program instruction Information and data can only be changed or altered by changing the circuitry Programs are written at the factory 26 25-Nov-24 ROM Generally, ROM is used to store the binary codes for the sequence of instructions you want the computer to carry out and data such as look up tables. —This is because this type of information does not change. It is important to note that although we give the name RAM to static and dynamic read/write memory devices, ROMs are also accessed randomly with unique addresses. 27 Types of ROM Masked ROM Programmable ROM, PROM Erasable Programmable ROM (EPROM) –Erased by UV Electrically Erasable ROM (EEPROM) –Takes much longer to write than read –Not used for storage of data –Used for calibration 25-Nov-24 RAM vs. ROM Memory Characteristics Memory system can be characterized based on: —Location [CPU, Internal, External], —Capacity [Word size, Number of words (or Bytes)], —Unit of transfer —Access method —Performance [Access time, Memory Cycle time, Transfer Rate], —Physical type [Semiconductor e.g. RAM, Magnetic e.g. Disk & Tape, —Physical characteristics [Volatility, Erasable], —Organisation [Physical arrangement of bits into words, interleaved. 25-Nov-24 MEMORY Characteristics 1. Location: —CPU- It is in the form of CPU registers and its internal cache memory —Internal- It is the main memory of the system which CPU can access directly —External- It is in the form of secondary storage devices magnetic disk, tapes, etc. The CPU accesses this with the help of I/O controllers 2. Capacity: —Word size (expressed in Bytes-8 bit), 8,16,32 bits —Number of words –in a specific memory device the capacity is 4K x 8 meaning word size=8, no of words=4K=4096 MEMORY Characteristics 3. Unit of transfer: — Max. no of bits that can be read/written into memory at a time — Internal; (Usually governed by data bus width-word size) — External; (Usually a block which is much larger than a word) 4. Access method: — Sequential (e.g. tape) – Start at the beginning and read through in order – Access time depends on location of data and previous location, e.g. tape — Direct (e.g. disc) – Individual blocks have unique address – Access is by jumping to vicinity plus sequential search – Access time depends on location and previous location — Random [Individual addresses identify locations exactly] — Associative [Data is located by a comparison; content of data requested with contents of a portion of the store] 25-Nov-24 MEMORY Characteristics 5. Performance —Access time – Time between presenting the address and getting the valid data —Memory Cycle time – Time may be required for the memory to “recover” before next access – Cycle time = access time + recovery time before a 2nd access can commence —Transfer Rate – Rate at which data can be moved in and out of memory 6. Physical Types —Semiconductor memory (RAM) —Magnetic memory (Disk & Tape) —Optical memory (CD & DVD) MEMORY Characteristics 7. Physical Characteristics —Volatile/Nonvolatile : If memory can hold data even if power is turned off, it is called as nonvolatile memory; otherwise volatile memory. —Erasable/Non erasable :The memories in which data is once programmed cannot be erased are called as non erasable memories. 8. Organization —Physical arrangement of bits into words (Little- Endian and Big-Endian) —Memory addressability (Byte- and word- addressable) —Interleaved 25-Nov-24 Memory Hierarchy Considering the differences of SRAM and DRAM: —DRAM is less costly than SRAM, —Though DRAM is substantially slower than SRAM, DRAM uses significant less area per bit of memory (because it uses capacitor), thus have longer capacity for the same amount of silicon Because of these differences of cost and speed (access time) in technology, —It provides the advantageous of building a memory in a hierarchy of levels. —With the faster memory close to the CPU (Processor) and the slower, less expensive memory below that. Memory Hierarchy Again: — Computer pioneers correctly predicted that programmers would want unlimited amounts of fast memory. — An economical solution to that desire is a memory hierarchy, which takes advantage of locality principle and cost/performance of memory technologies. The principle of locality says that: — Most programs do not access all code or data uniformly. “i.e. Programs access a relatively small portion of their address space at any instant of time” — This principle, plus the guideline that smaller hardware is faster, led to hierarchies based on memories of different speeds and sizes. The hierarchical memory system include: —registers, —cache, —main memory, and —secondary memory 25-Nov-24 Memory Hierarchy Increasing size Memory Hierarchy Computers have a small amount of very high-speed memory, called a cache, where data from frequently used memory locations may be temporarily stored. This cache is connected to a much larger main memory, which is typically a medium-speed memory. This memory (main memory) is complemented by a very large secondary memory, composed of a hard disk and various removable media. Note that: —A memory hierarchy can consist of multiple levels, but data is copied between adjacent levels at a time 25-Nov-24 Memory Hierarchy HOW with key terminologies: —If the data requested by the processor appears in some block in the upper level, this is called a hit —If the data requested by the processor is not found in the upper level, this is called a miss —The lower level in the hierarchy is then accessed to retrieve the block containing the requested data – The hit rate, or hit ratio, is a fraction of memory accesses found in the upper level – It is often used as a measure of the performance of the memory hierarchy – The miss rate (1-hit rate) is the fraction (percentage) of memory accesses not found in the upper level General Definitions and Principles of Memory Hierarchy The minimum unit of information that can be present or not present Processor in the two level hierarch is called a block If the data requested by the processor appears in some block in the upper level, this is called a hit Data are transferred If data is not found in the upper level, the request is called a miss The lower level in the hierarchy is then accessed to retrieve the block containing the requested data 25-Nov-24 General Definitions and Principles of Memory Hierarchy The Hit rate or sometimes called the hit ratio is the fraction of memory accesses to the the upper level. —(i.e. the number of hits divided by the total number of references in the same program-execution period). —It is used as a measure of performance of the memory hierarchy Similarly, the miss ratio refers to misses per memory reference and miss rate refers to misses per unit time i.e. it is the fraction of memory accesses not found in the upper level Miss rate = 1-Hit rate General Definitions and Principles of Memory Hierarchy Performance is the major reason for having memory hierarchy, the speed of hits and misses is important Hit time: the time taken to access a block in the upper level of the memory hierarchy, which includes the time needed to determine whether the access is a hit or a miss The miss penalty: The time taken to replace a block in the upper level with the corresponding block from the lower level, plus the time to deliver this block to the processor. 25-Nov-24 General Definitions and Principles of Memory Hierarchy Because the upper level is smaller and built using fast memory parts, the hit time will be much smaller than the time to access the next level in the hierarchy, which is the major component of the miss penalty. Thus: Hit time