Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Memory Architecture of 32 bit controllers

Status
Not open for further replies.

beenuseren

New Member
I have a question. When do we call a controller as 32 bit controller?

From what I know if the data bus of the controller is of 32 bit, then the controller is a 32 bit controller.

That is it is capable of writing or reading 32 bits at a time. Then why is it, Flash and SRAM memory of a 32 bit controller are byte addressed. That is each byte in both the memories is given an address. Instead of 8 bits they can address 32 bits.

Especially in Flash whats the use of addressing each byte?

Thanks
beenuseren
 
Good Question.

I have a question. When do we call a controller as 32 bit controller?
The internal register size and data paths are what determine the processor size. You can have a 16 bit processor with an external 8 bit data bus.

Then why is it, Flash and SRAM memory of a 32 bit controller are byte addressed.
It is useful when handling 8 bit data such as 8 bit numbers and characters.

Think about the problems in stepping through an array of bytes in a processor that can not address its memory as bytes.

The easy way is to store one byte in each word regardless of the word size. With a 16 bit word size the storage required for the array will be twice as large as on a byte addressable machine. 4x for a 32 bit, 8x for a 64 bit.

A more memory efficient method is to pack each word with bytes. To read any given byte you calculate which word it is in, fetch the word, and then extract the byte. More then a bit of processor overhead.

Neither method is as simple as byte addressing.

EDIT:
In the mid 70's the size of computer memory was limited by how fast we could decode an address. Large address spaces took so long to decode that it made sense to use fewer addresses and larger addressable chunks. That problem has been solved, so most computers are now able to do byte addressing.

Memory access has come a long way since then.
 
Last edited:
Thanks for the reply.

Here I am talking about internal data bus and internal memory of a 32 bit controller.

If a byte has to be written to the internal SRAM, the 32 bit data bus would actually write 32 bits to it. But the byte is only 8 bits what will the rest of 24 bits constitute? Do they constitute zeros?
 
The question is how are the characters written on a 32 bit controllers SRAM?
I feel each character would occupy 32bits in the SRAM.
 
beenuseren said:
The question is how are the characters written on a 32 bit controllers SRAM?
I feel each character would occupy 32bits in the SRAM.

Only if it's really badly designed, you can usually treat each 32 bit location as either 4 bytes, 2 words, or 1 long word, depending what instructions you use.

The 68000 is a good example, and was even available with different external bus sizes (the 68008 only had 8 bit memory, but was 32 bit's internally).
 
beenuseren said:
Thanks for the reply.

Here I am talking about internal data bus and internal memory of a 32 bit controller.

If a byte has to be written to the internal SRAM, the 32 bit data bus would actually write 32 bits to it. But the byte is only 8 bits what will the rest of 24 bits constitute? Do they constitute zeros?

Memory is always accessed via the memory bus. It does not matter if it is internal or external memory. (there are rare exceptions)

As I said earlier "The internal register size and data paths are what determine the processor size. You can have a 16 bit processor with an external 8 bit data bus." Perhaps the choice of the word external was unfortunate. I was thinking microprocessor and we were talking about micro controllers.

Most modern processors include instructions that operate on data that is smaller then the word size. As Nigel pointed out this allows them to access memory a byte at a time.

If we wanted to store the null terminated string "Frog" in your 32 bit uC the memory might look like this.

0x0100 'F'
0x0101 'r'
0x0102 'o'
0x0103 'g'
0x0105 0x00
...

The 4 characters are stored in one word at 0x0100 and the letter 'c' is located at address 0x0102. The null is stored in the next word at location 0x0105. No bytes are wasted.

Think of it this way. There are enough 8 bit instructions in your 32 bit processor to allow it to act as an 8 bit processor when needed.
 
Last edited:
Here you mentioned string of characters, "frog". But if I want to write single character to SRAM ?

For example, I am executing a program

main()
{
char c;
c = 'A';
}

During execution of the above program, C will be given a byte space in the memory.
Then I am assigning a value 'A' to that location.

My databus is made up of 32 copper lines. 8 lines would be carrying the 'A' value which has to be written to SRAM.
What data would be carried by the rest of the 24 lines.? ? ?

According to my program I just have to write 'A' in the location of variable C.

Thanks,
 
Why do you still think that a 32 bit read/write are the only possible way to read/write memory on a 32 bit controller. It is not. Most modern controllers are able to read and write 8 and 16 byte data.

beenuseren said:
Here you mentioned string of characters, "frog". But if I want to write single character to SRAM ?

For example, I am executing a program

main()
{
char c;
c = 'A';
}

During execution of the above program, C will be given a byte space in the memory.
Then I am assigning a value 'A' to that location.
Yes​

My data bus is made up of 32 copper lines. 8 lines would be carrying the 'A' value which has to be written to SRAM.
What data would be carried by the rest of the 24 lines.? ? ?
If the processor can do an eight bit write to memory then the other 24 lines are unused. The memory will ignore them. They may be one, zero, or floating/tristate, it does not matter.

If the processor can only do a 32 bit write then it would first read the word containing the desired byte, modify the byte in that word, and then write it back to memory.​

According to my program I just have to write 'A' in the location of variable C.

And that is what it does.
Thanks,
 
beenuseren said:
Here you mentioned string of characters, "frog". But if I want to write single character to SRAM ?

For example, I am executing a program

main()
{
char c;
c = 'A';
}

During execution of the above program, C will be given a byte space in the memory.
Then I am assigning a value 'A' to that location.

My databus is made up of 32 copper lines. 8 lines would be carrying the 'A' value which has to be written to SRAM.
What data would be carried by the rest of the 24 lines.? ? ?

According to my program I just have to write 'A' in the location of variable C.

Your question isn't to do with the processor, it's to do with your C compiler - and how are we to know what code your compiler produces?.

We've already explained that the processor should be able to access bytes, words, and long words - use assembler instead of C!.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top