# What to call the cells of memory in a computer or a microcontroller?

I don't know if this is the right forum to post this question, but I thought so because this forum is for educators and I'm a trainer and my question is related to education.

I want to do an introduction for a technical manual about basics of microcontroller, and got to the memory chapter.

I started with a definition for the three main memory types in a microcontroller, which are:

1. Program memory (ROM): Which is basically a flash memory for storing the program HEX file for execution.
2. Data memory (RAM): Which is for processing data during operation of the microcontroller, but the data is lost after resetting the microcontroller.
3. EEPROM: Which has the advantage of reading and writing data during the operation of the microcontroller and also keep the data after resetting the device.

Then, I posted a picture of microcontroller's block diagram and how it's connected to the internal units as a subtitle of the memory chapter.

The next subtitle is the term "registers" as they are the building block of any type of MEMORY in computer, whether it's ROM, RAM or EEPROM. Because I found this information in a website, and want to be sure.

This is the link to the website:

Section 5.1: Registers. As the previous section is 4. Program Memory.

Then in section 5. Data memory, the author explain the sub-parts of Data memory which are:

• 5.1 Registers
• 5.2 Bits and bytes

So, my question here, is: Registers are memory cells to every memory type, and the difference is that ROM memory are non-volatile registers, RAM are volatile registers and EEPROM is also non-volatile registers? So they all are basically register.

=====================================================

Add1: I want to add this picture I found in an eBook:

So, the only memory called registers is the CPU registers other memories called just memory. But how about the arrangement in microcontroller sector?

# =====================================================

My updated question is how registers differ from other memory cells in other types of memories? Like, Flash and EEPROM memories.

• This is probably better addressed to ComputerScience.StackExchange rather than here. It is really a more technical and less of an education question. But welcome to this site. – Buffy Jul 4 '18 at 23:22
• @buffy We got the migration on the Electrical Engineering SE. Thanks! It's probably a better question here because Perch is asking about something hardware related. We'll take it from here. – user103380 Jul 5 '18 at 0:19
• I find the term "registers" in this context quite misleading. In CPU and µC contexts, a register is quite different from a storage location in RAM, ROM or on disk. Hence I would strongly advise to come up with another term for the concept of storage locations for data. - Unless you want to talk in abstract about theories of computing machines (Turing,...), but then you won't differentiate RAM, ROM, disks and tapes. – JimmyB Jul 5 '18 at 14:27

In my mind, a register is a storage location that is within the CPU, or directly addressable by the CPU - things like the Accumulator, index registers, and similar things. I would not say that EPROM, FLASH and RAM have registers.

If you look at the assembly-language instruction set for a microprocessor or microcontroller, you will see that some instructions deal with registers, while others deal with RAM, EPROM or FLASH memory access, so the processor sees a register as something different than a memory location.

• That's very logical and makes a lot of sense. I really like your answer, absolutely agree with you, but the link I provided in that specific section actually described the register as a building unit for every memory location. That's what I wanted to be sure about. – R1S8K Jul 5 '18 at 0:07
• Registers are small, fast memory directly accessible to the CPU, and are often considered a part of the CPU. RAM, which holds data and program instructions and is more properly called main memory, is addressed differently, and often uses different technology. – Bob Brown Jul 5 '18 at 2:07
• Yes, that's pretty much what I think it's, so registers are the same in microprocessor and microcontroller configurations. They're for power-on operations, where non-volatile memories are built of memories cells and they're not registers, they are memory addresses or locations. How about my conclusion? – R1S8K Jul 5 '18 at 2:52
• To add a little confusion, in microcontrollers the memory "things" used by peripherals like timers, counters, serial ports, etc. are often called registers, but are accessed using the same instructions as for RAM memory, unlike the "internal" CPU registers. – Peter Bennett Jul 5 '18 at 3:23
• And then there are peripheral registers which are accessed via special instructions (in, out) unlike CPU registers or memory :) – JimmyB Jul 5 '18 at 14:20

I think you will find that the terminology is not set in stone and that different authors will use different terms. The important thing, of course, is to be clear that there are different terms for the same thing and similar terms for different things.

If the book is about engineering then the differences have more relevance since they are implemented in different ways. How important that will be depends on the purpose and the audience for your book. "Memory" can refer to lots of things. "Register" is often used for the few directly addressable memory cells defined in the architecture (machine language). Don't forget that disk space is sometimes called "memory" as is cache when available.

There is a whole range of things that vary in volatility, Some are stable only when there is electricity present, others are stable when shut off. Eprom is actually volatile, but via a different pathway.

But, in general, I'd avoid trying to give a solid definition to students, as they will hear different definitions later and may be confused if you seem to definitive.

• I have to provide a solid and also flexible definition. But as you mentioned; for example, disk space, can I can each cell in this type of memory a "register"? I just want to know the base of the term "register" is it related to every memory cell, or just for cache and RAM cells? – R1S8K Jul 5 '18 at 0:04

No, registers are generally RAM cells dedicated to a single purpose. In current µC designs, the only special registers are the program counter, the (return) stack pointer and various status and control registers.

There may be more registers but for a µC with built-in RAM, they are different from ordinary RAM cells only by the adressing modes available. Usually, indirect and/or indexed addressing is only available if one or both parts of the address are taken from such a register RAM cell. This is due to limitations in the size of the opcode usually (e.g. only 4 bits to select a RAM cell holding the indirect address.) Also, operations requiring two operands, e.g. adding, may also require one operand be in a register RAM cell for the very same reason.

For education purposes, I would put a program counter, a stack pointer and a status register aside and draw the general purpose registers as part of the RAM block.

• This is a quotation from the post I read: Registers All information in the microcontroller, from the program memory, the timer information, to the state on any of input or output pins, is stored in registers. but I think I mislead the syntax because the section is about the data memory which is RAM. – R1S8K Jul 5 '18 at 0:09
• That's inaccurate. As the text you linked to is about the AVR family, please see e.g. the ATtiny85 datasheet. ww1.microchip.com/downloads/en/DeviceDoc/… There are 3 kinds of registers (program counter/stack pointer/status register; General purpose register file; I/O registers) plus internal RAM. – Janka Jul 5 '18 at 12:49

I would summarise the distinction between registers and memories as follows:

1. A "register" is a logic block with main function to latch and remember some data at the moment of some clock edge coming. Data can be flowing along many register elements, but only the selected one set got the data to remember when they are "selected", and the clock toggles. So a register usually have several more functions embedded, like "Reset" to initial state, "Set" to opposite state, and "enable/select" these functions. Without the "Select" the register cell ignores data change.

2. A memory is usually a set of registers of different organisation in terms of parallel size (number of bits per memory word/register) and the number of addressable columns, with usually simplified access functions. For example, bulk memory doesn't have "Reset" or "Set" function, it usually has some address decoder that allows to enable one row of bits (word), which allows the data to be snatched at a clock edge, while other "memory words", being connected to the same data bus ignore the data and continue to "remember" the last write operation. This kind of memory is called "static". Minimal hardware implementation requires six transitors per one bit, the classic 6T-architecture.

1. The main function of memory is to remember a bit of data. With substantial reduction of random-access functionality, the memory function can be accomplished by just one capacitor with low leakage, and one transistor. With some additional circuitry around and special page organisation one can have "dynamic memory cell"

Functionality of one-cap cell needs some sequence of row/column gate opening, for the charge to get into proper memory location, and a periodic "refresh" function to maintain charge levels in high or low states. It is called DRAM - dynamic random access memory, which is used in all modern computers as main system memory.

1. ROM - Read-Only-Memory, could be any of the above, with protected write function. There are re-programmable ROMs, like electrically erasable memories, or could be so-called "mask-programmed" memories where the content can't be altered.
• This is incorrect, as almost any MCU violates the definition of register you propose. – Chris Stratton Jul 5 '18 at 0:51
• @ChrisStratton, how so? Could your elaborate please? – Ale..chenski Jul 5 '18 at 0:53
• Your answer is very nice. Thank you so much for the information. – R1S8K Jul 5 '18 at 0:55
• CPU core registers fit your definition of memory, and relative few registers (at most a subset of those in peripheral blocks) fit your register definition. Hence the distinction you are drawing confuses more than it clarifies. – Chris Stratton Jul 5 '18 at 1:04
• @ChrisStratton, I was trying to draw a line of reasoning that the memory hierarchy is differentiated by the available access granularity and set/reset functionality, and other possible integrated logic. Of course there could be finer classification along these lines, like caches->register files-> reservation stations, etc. But thanks for civilized response. – Ale..chenski Jul 5 '18 at 1:21

My updated question is how registers differ from other memory cells in other types of memories? Like, Flash and EEPROM memories.

Well, Flash and EEPROM are non-volatile. That's the biggest difference.

As for the difference to RAM...

There are CPUs out there where registers are just the first few bytes of ram. The difference there is how you address them in opcodes. Registers can be addressed with just a few bit because there are only a select few. RAM on the other hand is large and you usually use a register to address them. Or the opcode has additional bytes attached to it for the address (only in CISC).

In modern computers RAM is also build differently, so called dynamic memory. The memory cells are basically capacitors that drain over time and you have to constantly recharge them. RAM is also addressed in a matrix. Some bits specify a row and others a column. Accessing data in the same row is faster than switching rows. Reading RAM is destructive and you need to write the data back after a read to preserve it. All this is handled by the memory controller. So there is something between the core CPU and memory (There are also caches and the MMU there).

The registers on the other hand are (afaik) always static ram or straight up flip flops. You store a value in them and they just keep at that stat as long as they have power. On modern desktop/server CPUs the registers that you use in assembler don't exist in the CPU at all. Instead the CPU has a larger register file and registers in the opcode are dynamically remapped onto the larger register file. This solves the problem of opcodes reading and writing the same register or later opcodes overwriting a register of an earlier opcode when the CPU is superscalar.

If you ignore all the specifics of their implementation then registers and ram are totally the same. It's just how they are used, their speed and their cost that differs. Registers are the post-it stickers you keep on your desk while ram are the notebooks you keep in a shelf for when you write the next big american novel. It's all just paper, except not.