# Electronics/RAM and ROM

RAM: Random Access Memory ROM: Read Only Memory

## Basics
### Capacitors as memory

* Capacitors can be charged, and when they are charged they can be discharged.
* When charged they act like a source of voltage but only for a limited time unless they are "refreshed".
* If charged they can be "refreshed" by charging them again and again to keep their voltage above a specified minimum. This procedure can be quite automatic at regular intervals and applies ONLY to capacitors that already have a voltage that is above that set minimum.
* "Writing" into a capacitor-memory means either charging that capacitor or discharging it as required. We say that a memory is "a zero" if its voltage is below a specified value, and it is "a one" if above. Putting a 1 into the memory means charging the capacitor, while putting a 0 into the memory means discharging the capacitor.
* "Reading" a capacitor-memory is equivalent to putting a voltmeter across its terminals to see whether its voltage is or is not above a given minimum.
NOTE: Modern memories use transistors, gates, diodes, etc.

#### Examples

Reference 1: Programmer's Reference Guide for the Commodore 64 Personal Computer, published in 1988 by Commodore Business Machines, Inc.
* part of the microprocessor 6510's characteristics:
* For a 0 the minimum is minus 0.3 Volt, and the maximum is plus 0.3 Volt.
* For a 1 the minimum is plus 2.0 Volt, and the maximum is 1 Volt above the supply voltage which usually is about 5 Volt, but whose absolute maximum is 7.0 Volt. Note that static electricity (by friction on the carpet for example) can cause a lot of damage and must be guarded against.
Reference 2: The Semiconductor Memory Data Book for Design Engineers, published in 1975 by Texas Instruments Inc.

### Bits

* Think of "one bit" as one memory unit, such as one capacitor-memory. It can have a 0 or a 1 "in it", as required; a "High" (H) usually is a 1, and a "Low" (L) usually is a 0. Bit is a shortened version of binary digit.

### Bytes

* A byte is a group of bits. One bit can only represent "a count" of zero or one, two bits grouped together into a byte can represent a count of zero to 3, 3 bits into a byte can count up to 7 and n bits in a byte can count up to 2$^n$ minus 1. A byte with 8 bits in it can count from 0 to 255. "Words" are bytes; they each have a stated number of bits in them.
* Bytes can also be combined; 2 bytes, each with 8 bits in it, can count up to 256 times 256 minus 1, that is 0 to 65535.

### Words

* Words are a concept that dates back to early computer architectures, where a single "unit" of memory was different from 8 bits. Common early word sizes were often 10 bits, but sometimes six or 20 bits.
* Generally a word was defined as the size of the memory bus for internal storage (i.e. RAM or ROM), as well as the minimum independently addressable unit of memory.
* Most modern CPU architectures use independently addressable byte architecture, but some modern CPUs (like the Pentium and other x86 CPUs) perform memory and instruction tasks more efficiently if the memory is "aligned" on word boundaries.
* Terms like word and longword date back to 16-bit and 32-bit CPU architectures respectively, and to give a common framework for backward compatible software tools. More recently, the term quadword is used to denote a 64-bit piece of memory, although the term octaword is sometimes used (because it is 8-bytes being accessed at once).
* Endian architecture defines how the memory is encoded within the RAM of the computer and its relationship with the byte addresses. Generally this is not an issue for most software except when you write data files meant for consumption on multiple platforms that have multi-byte components.

### Address Bus connection

Just as the mail delivery person needs to have an address on each item to be delivered/collected, so also access to a particular byte of memory is "delivered" to a particular address, or "collected" from a particular address.
* For example a memory can have 16 address connections, labelled 0 to 15. That means that data can be fed into, or taken out of, a specific memory cell, whose address is between 0 and (2$^{16}$ minus one), which is between 0 and 65535.

### Data Bus connection

After the specific address has been fed into the memory, a specific given number is fed ("written") into the data bus connection, or the content of that address is "read".
* For example a memory can have 8 data connections, labelled 0 to 7. That means that the number fed into the selected byte must be between 0 and (2$^8$ minus one), which is between 0 and 255.

### Read/Write connection

There is also an input terminal connection that indicates the operation required. A 0 into that connection may indicate that the next operation will be a "write", while a 1 may indicate that it will be a "read".

### Clock connection

A memory may require one or more clock signals, possibly "phase 1" and "phase 2", etc., which are inputs into the memory from oscillators, meaning they alternate very fast between 0 and 1 continuously. While the clock is, maybe, 0 various changes can be made, such as an address change and/or a change of data, but the actual reading or writing takes place only while the clock is, maybe, 1. Some memories include clock oscillators, possibly requiring external crystals.

## RAM (Random Access Memory)

A RAM is a "Random Access Memory" - Sizes and their architecture vary considerably, users can put into any of their addressed bytes any number up to a given maximum, and that number can be replaced by another number as required, when required. Some memories supply the complements of what was put into them.
* For example a memory with 1024 bits can require only a 0 or 1 to be put into any of the 1024 cells, while another memory can require 4 bits (0 to 15) per word, but only 16 words can be retained at a time, etc.
Dynamic Read/Write Memories
    Requires frequent refreshing.
Static Read/Write Memories
    Retains the data even if control signals are absent, however such memories may use dynamic addressing

## ROM (Read Only Memory)

A ROM is a "Read Only Memory". It is factory-produced, and usually its contents are fixed. A ROM can be read, but it usually cannot be written. Usually a ROM contains very important fixed information required for the equipment for the operation.
Mask-Programmed Read-Only Memories
    Uses a mask during manufacture, contents cannot be altered.
Programmable Read-Only Memories
    Permits a change of each cell after manufacture, but once only.
Reprogrammable Read-Only Memories
    Permits changes to each cell after manufacture, more than once.