Electronic – SRAM swapped address / data bits

memorymicrocontrollersram

Consider the following wiring from a microcontroller to a sram chip:

uC        SRAM
A0    --> A3
A1    --> A0
A2    --> A1
A3    --> A2
A4    --> A4
..    --> ..
A15   --> A15

As you can see, some of the address bits are swapped.

So when it comes to reading / writing the memory, will there be no errors? For example:

Address Microcontroller    Address Chip        Contents
0000                       0000                H
0001                       1000                e
0010                       0001                l
0011                       1001                l
0100                       0010                o
0101                       1010                
0110                       0011                !
0111                       1011                \0

So… from the microcontroller's side the addresses are all ascending, but as you can see in reality, the uC addresses various memory places in the sram.

Is this a problem? I think with ONE microcontroller using the memory: no, since the microcontroller can nevertheless fetch the data in proper order (even if its not doing this from outside observation). But I think, with two or more microcontrollers this could become a problem IF the address bits are not connected in the same manner.

Conclusion:

As long as each address is distinct from another, there will be no reading / writing problem. (Considering ONE microcontroller using the memory!)

And:
As long as each data bit is distinct from the other data bits, there will be no reading / writing problem. (Considiering ONE microcontroller using the memory!).

So my final question is: is my understanding for this problem correct or am I missing something? I could not find something on the internet concerning this problem!

Best Answer

Your understanding is correct.

An address is just an arbitrary label for a location. All locations are identical (from the PoV of the MCU), and as long as each MCU accessing the locations agree on what the labels mean (are wired the same) then it doesn't matter the slightest how you assign those "labels".

As long as you use the same wiring for putting data in as you use for getting data out, it's just numbers.

Imagine you can't count. Imagine you think the numbers go 0, 3, 2, 5, 4, 1 instead of 0, 1, 2, 3, 4, 5.

Your boss tells you to put this box on shelf 3. So you go and put it on what you think is shelf 3, but it's actually shelf 1.

Later that day the boss tells you to go and get that box back off shelf 3 for him. So you go to what you think is shelf 3 (really shelf 1) and get the correct box.

Now, if the boss were to go to get the box instead he'd find a completely different box, because he didn't go to your shelf 3 but to his shelf 3 (your shelf 5).