1
\$\begingroup\$

This question already has an answer here:

I am new to the field of embedded systems. Recently I was learning about the differences between different bit size (8, 16, 32) microcontrollers. What I found was that the size of bit indicates the memory addressing capacity, data bus and address bus size etc. Every other website has almost the same explanation. But still I could not find answer to some of the questions. To list them:

  1. Is it really necessary for the address and data bus to be the same size as the bit size of the micro.

  2. What is it that will become fixed for sure for a given bit sized microcontroller?

  3. Do a microcontroller have have same address bus for all the memories (RAM, flash, EEPROM) and if so, is it the choice of manufacturer to allot any size to any type of memory out of the available addresses?

  4. Say there's an 8 bit microcontroller. So it can adress 2^8 memory locations (that's what I figured out, I am not sure). If each register is 8 bit it means a total of (2^8)*8 =2048 bits of memory. That's not even close to the 32kb of flash inside most of them. What blunder am I making?

\$\endgroup\$

marked as duplicate by Elliot Alderson, Chris Stratton, Oleg Mazurov, Umar, RoyC Sep 1 at 14:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4
\$\begingroup\$

The "bit size" of a CPU typically refers to the size of its general-purpose registers (or its primary register, in parts with nonuniform registers). For example, the MC68000 is generally considered a 32-bit architecture as its registers are all 32 bits wide -- even though it has a 16-bit data bus and a 20-bit address bus. (This means that it must make two memory accesses to write a single register to memory. The top 4 bits of an address register are simply ignored, which is a bit of an oddity.)

The sizes of the address and/or data busses connecting the processor to its various memories are often different, either from the size of registers or even from each other. In more complex architectures, it is not uncommon for the same memory to even be accessible over multiple data busses of different widths.

\$\endgroup\$
  • \$\begingroup\$ Incorrect, it is the ALU not the registers, and no, they do not always match. \$\endgroup\$ – Chris Stratton Aug 30 at 13:08
  • 2
    \$\begingroup\$ @ChrisStratton I suppose there's always an exception: PDP-8S had a 1-bit ALU, but is regarded as a (s-l-o-w) 12-bit machine. Perhaps the logic wrapper around the 1-bit ALU that collected 12 bits counts as part of the ALU? \$\endgroup\$ – glen_geek Aug 30 at 13:22
  • \$\begingroup\$ @glen_geek typically the ALU width in the instruction set / programming model. Ie, Z80 is regarded as an 8-bit machine as it implements a superset of the 8-bit 8080 instruction set. Not 4-bit (the actual ALU), not 16-bit (registers in pretty much the same pairing scheme used in the clearly 16-bit 8086) \$\endgroup\$ – Chris Stratton Aug 30 at 13:24
3
\$\begingroup\$

It is not necessary that data bus and address bus widths are same in a micro-controller. For eg, in the good old 8051, data bus is of 8 bits and address bus is of 16 bits. '8-bit' in the naming convention of a micro-controller is quite abstract. Mostly it refers to the size of registers inside 8. All general purpose registers inside 8051 are 8-bit registers except PC and DPTR. You have to go thru the data sheet. So you are wrong in your assumptions about 4th question, because '8-bit micro-controller' doesn't always mean that it has an address/data bus of 8-bit. Need more info to clarify it.

2,3 are purely architectural based. Yea, you can have different buses inside. Big topic.

\$\endgroup\$
  • 1
    \$\begingroup\$ Please spell out your words instead of using slang like "cz". This will make it easier for users who are not native English speakers to learn from the site, and it makes you sound more like a professional. \$\endgroup\$ – Elliot Alderson Aug 30 at 12:46
  • \$\begingroup\$ It is called an 8-bit controller though because it can address a byte per every address location." - no, because the vast majority of computers including the likely 64bit machine you are sitting in front of can do that. Further, you are wrong about the registers inside, as 8 bit systems typically had joinable16 bit pairs and 16 bit systems typically had pairs decomposable to 8 bit halves... In actuality the "bitness" of a processor traditional refers to the ALU width, not physically, but in the programming model - ie, the Z80 is an 8 bit processor even through it has a 4 bit ALU. \$\endgroup\$ – Chris Stratton Aug 30 at 13:05
  • \$\begingroup\$ All general purpose registers inside 8051 are 8-bit registers except PC and DPTR. The reason why it should have been always called an 8-bit controller. There might be exceptions as you stated. That's why I said it is 'abstract' nomenclature followed by 'mostly' which means 'typically' in my non-native English dictionary. \$\endgroup\$ – Mitu Raj Aug 30 at 13:54
2
\$\begingroup\$

Well that's a lot of learning books. You should get one in the library.

  1. No, usually the address bus is wider than data bus. This is very basic knowledge on processors.

  2. Depends on architecture of the processor. Newer ARM RISC processors have many address buses. Learn: von Neuman VS. Harvard architecture. For example the MCU can have separate internal RAM and FEPROM bus and yet 3rd external address and data bus

  3. As stated in 2. it can have more internal buses, depends on architecture.

  4. You're wrong. For 32kB space you would need an address bus at least (or exactly) 15 bit wide.

enter image description here source of the image

\$\endgroup\$
  • \$\begingroup\$ Thanks Marko. Did you mean the point '4' is wrong instead of '3'? \$\endgroup\$ – Bhuvnesh Aug 30 at 7:53
  • \$\begingroup\$ @Bhuvnesh Indeed, I wrote 4. but the automatic numbering shows 3. I did correct that \$\endgroup\$ – Marko Buršič Aug 30 at 8:46
0
\$\begingroup\$

(3) Do a microcontroller have have same address bus for all the memories...?

Not necessarily. Unlike a larger computer system where an operating system can load and execute different programs on-the-fly, the application code in a microcontroller typically is burned into the flash memory at the factory, and then is seldom or never changed after that. There is no need, therefore, for one microcontroller program to be able to treat the instructions of another program like data.

A system which, like some of the world's earliest stored-program computers, has separate data paths for fetching instructions and, for accessing data, can be simpler (cost less/use less power) than a so-called Von Neumann machine that stores instructions and data in the same memory space.

\$\endgroup\$
  • \$\begingroup\$ In practice pretty much all current MCUs can treat program code as data, as self-flashing either via a bootloader or for field updates delivered by a communication channel is too much a customer demanded feature for an ordinary MCU to be made without support for that. And of course almost any practical system needs to be able to retrieve constants and other initialized data stored with reasonable efficiency in program memory, unless it is going to have a unique ROM for that. \$\endgroup\$ – Chris Stratton Aug 30 at 18:46
  • \$\begingroup\$ Further most modern large systems do not truly have the same address but coming out of the execution core for all memories, since distinct code and data caches are the norm. With the exception of DSPs and other unique systems, and a few older MCU designs, most modern systems have a Von Neumann programming model but Harvard-style data path optimizations used for the majority of operations. \$\endgroup\$ – Chris Stratton Aug 30 at 18:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.