🧠 Main Memory

Understanding RAM & ROM: The Foundation of Computer Memory

📚 Memory Unit Overview

The memory unit is a collection of storage cells organized with associated circuits for information transfer. Information is stored in groups of bits called words.

What is a Memory Word?

A memory word is an entity of n bits. Common configurations include:

  • 📦 16 bits - Two bytes (2 × 8 bits)
  • 📦 32 bits - Four bytes (4 × 8 bits)

Types of Main Memory

Main memory utilizes two major types:

🚀 Random-Access Memory (RAM)
▼

Key Characteristic: Access time is the same regardless of physical location - hence "random access"

Operations: Both Read and Write

Volatility: Data is lost when power is turned off

💾 Read-Only Memory (ROM)
▼

Key Characteristic: Performs read operations only

Operations: Read only - no write capability

Permanence: Information is determined during hardware production and cannot be altered

⚖️ RAM vs ROM Comparison

Feature RAM ROM
Full Form Random-Access Memory Read-Only Memory
Access Type Random access to any location Read-only access
Write Capability ✅ Yes - Read & Write ❌ No - Read only
Volatility Volatile (data lost when power off) Non-volatile (permanent storage)
Access Speed Uniform - same for all locations Fast - but read-only
Primary Use Temporary data storage, active programs Fixed programs, constant tables, firmware
Programming Continuously reprogrammable Programmed during manufacture or once

ROM Types

Mask ROM
▼

Programmed by the manufacturer during fabrication. Cannot be changed after production.

PROM (Programmable ROM)
▼

Uses fusible links that can be "blown" once by the user. Programming is permanent and irreversible.

EPROM/EEPROM (Erasable Programmable ROM)
▼

Can be erased and reprogrammed. EPROM uses UV light for erasing; EEPROM uses electrical signals.

⚙️RAM Chip

RAM Chip
📝 Memory Write Operation

When the chip is selected and the Write signal is active, the data from the Data Bus is transferred into the memory location addressed by AD.

CS1 CS2 RD WR: M[AD] ← Data Bus

Transfer content of data bus to memory location specified by AD

📖 Memory Read Operation

When the chip is selected and the Read signal is active, the data stored at the memory location addressed by AD is transferred onto the Data Bus.

CS1 CS2 RD: M[AD] ← Data Bus

Transfer content from memory location specified by AD to data bus

The Inhibit State

High-Impedance State
IF (CS1 = 0) or (CS2 = 1): Data bus ← Hi-Z

If the selection conditions are not met, the Data Bus is logically disconnected. In RTL, this is often represented as the bus entering a Hi-Z (floating) state.

⚙️ROM Chip

ROM Chip
📖 Memory Read Operation

When the chip select conditions are met, the content of the ROM (M) at the 9-bit address (AD) is placed onto the data bus.

CS1 CS2: Data Bus ← M[AD]

The Inhibit State

IF (CS1 = 0) or (CS2 = 1): Data bus ← Hi-Z

When the chip is not enabled, the bus is forced into high impedance.

🧮 Memory Address Map

The address mapping operation for the configuration consisting of 512 bytes each of RAM and ROM is performed as follows:

  1. Identify Component Requirements
    • RAM Capacity: The system uses four RAM chips (RAM1, RAM2, RAM3 and RAM4), each containing 128 bytes. Each chip requires 7 address lines (lines 1 through 7) because 27 = 128.
    • ROM Capacity: The system uses one ROM chip containing 512 bytes. This chip requires 9 address lines (lines 1 through 9) because 29 = 512.
  2. Define the Address Bus Structure
    • Total Bus Lines: While the system has a 16-line address bus, this mapping example utilizes only the first 10 lines; the remaining 6 are assumed to be zero.
    • Internal Addressing (x): Small 'x's in the address map designate lines connected directly to the address inputs of each chip to select specific bytes within that chip.
  3. Establish Chip Selection Logic: To distinguish between the different physical chips, higher-order bus lines are assigned as selection bits:
    • RAM vs. ROM Selection: Bus line 10 is used to distinguish between RAM and ROM. When line 10 is 0, a RAM chip is selected. When line 10 is 1, the ROM chip is selected.
    • Individual RAM Chip Selection: Bus lines 8 and 9 are used to distinguish between the four distinct RAM chips.
  4. Map the Address Space: The resulting hexadecimal address ranges for each component are determined by these bit assignments:
    Component Line 10 (Type) Line 9-8 (Chip ID) Address Range (in Hex)
    RAM1 0 00 0000 - 007F
    RAM2 0 01 0080 - 00FF
    RAM3 0 10 0100 - 017F
    RAM4 0 11 0180 - 01FF
    ROM 1 XX 0200 - 03FF

    By using this map, the designer ensures that the processor can uniquely communicate with each memory component without address overlap.

🔗 Memory-CPU Connection

Interconnection and Operation of a Integrated RAM/ROM Memory System in a CPU Architecture

MEMORY CPU CONNECTION

Key Connection

🛣️ Address Bus Connections
  • Internal Byte Selection: The low-order lines of the address bus are used to select a specific byte within a chip. For each 128 X 8 RAM, address lines 1 through 7 are connected to the AD7 inputs. For the 512 X 8 ROM, address lines 1 through 9 are connected to the AD9 inputs.
  • RAM Chip Decoding: Address lines 8 and 9 are fed into a 2 X 4 decoder. The four outputs of this decoder are connected to the CS1 (Chip Select 1) inputs of the four RAM chips to select one individual chip at a time.
  • RAM vs. ROM Selection: Address line 10 is the primary selector between memory types. It is directly connected to the CS2 inputs of all RAM chips and connected through an inverter to CS2 input of the ROM chip.
  • Memory Mapping: This configuration assigns hexadecimal addresses 0000H to 01FFH to the RAM block and addresses 0200H to 03FFH to the ROM.
🔧 Control Signal Connections
  • Read/Write Operations: The CPU's RD (Read) and WR (Write) outputs are connected to the corresponding RD and WR inputs on all four RAM chips.
  • ROM Enable Logic: For the ROM, the CS1 input is directly connected to the CPU's RD control line. This ensures the ROM is only enabled during a read operation.

🔄 Data Bus Connections
  • Bidirectional RAM Bus:: The data bus connected to the RAM chips is bidirectional, allowing the transfer of information in both directions (reading from and writing to memory).
  • Unidirectional ROM Bus: The data bus for the ROM has only an output capability, as it can only provide data to the CPU.

Selection Logic

Connection Summary
  • RAM Selection: Occurs when address line 10 is 0.
  • ROM Selection: Occurs when address line 10 is 1.
  • Inhibit State: If a chip is not enabled by the select inputs or control signals, the memory is inhibited and its data bus remains in a high-impedance state to avoid bus contention.

🎮 Interactive Memory Demo

Click on memory cells to simulate read/write operations!

Memory Array (64 words)

Output: Ready to perform operations...
💡 How to Use
  • Click any cell to view its address and current value
  • Enter an address (0-63) and data value to write to memory
  • Click "Write" to store data at the specified address
  • Click "Read" to retrieve data from the specified address
  • Active cells glow green when accessed
Associative Memory