Electrical – Where is data coming from a bus stored in a microcontroller

datagpiomemorymicrocontroller

It might sound like a silly question, but somehow I am not able to answer this myself with confidence. Let's say we have a microcontroller (MCU) with a data/address bus and data is moving to and from the bus. "Where" exactly on the MCU is the data arriving on this bus temporarily stored? Is it in some RAM buffer or some IO data register for a particular address?

If it is not a data/address bus (that has addresses) and the data is coming on a random GPIO pin, where is this data temporarily stored in this case?

Thank you.

Best Answer

Here is a block diagram of a 8051 variant. There are probably hundreds of different microcontroller architectures. Most are more complicated than the 8051 (which why I chose it, for its relative simplicity), and may have additional features such as DMA (Direct Memory Access), pipelining, caches, etc., but they all pretty much have to start with the basic components shown here: program memory, data memory (separate in a Harvard architecture, the same in a von Neumann srchitecture), instruction decode, accumulator(s) and/or register file, ALU, interrupt logic, and peripherals. (The 8051 does have a rudimentary instruction cache that can look ahead 6 instructions.)

The 8051 is a accumulator based machine that also has a set of four register files which are actually located in RAM. It is an 8-bit microcontroller, so the data bus is 8 bits wide.

enter image description here

Note that everywhere data must be stored off of the data bus, there are latches. Data can be transferred to and from the accumulator. The ALU (arithmetic logic unit) has two registers for storing its two operands, one of which can come from the accumulator and the other a data bus source (memory or peripheral register, for example), or both from the data bus (in which case the first is held in one of the ALU registers while the second is loaded). The B register is only used for the multiply instruction. Each of the ports has its own latch. The timers implicitly have registers within them.