Login

Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.

ARM Community: RAM in Code memory area - ARM Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

RAM in Code memory area Rate Topic: -----

#1 User is offline   narke 

  • Member
  • Pip
  • Group: Members
  • Posts: 11
  • Joined: 09-June 11

Posted 20 June 2011 - 03:40 AM

Hi,

My board has 32K SRAM in the code memory area (within the first 0.5G), also has the same size of build in SRAM in data area. My question is, what kind of data are suitable to put in CODE area? Particularly, should I set the main stack in CODE SRAM or DATA SRAM?

Thanks in advance.
0

#2 User is offline   Alban Rampon 

  • Regular Contributor
  • PipPipPip
  • View blog
  • Group: Blog Owners
  • Posts: 170
  • Joined: 11-May 09

Posted 21 June 2011 - 01:42 PM

Hello,
Linkers I've used all understand the CODE segments as being READ_ONLY.
Therefore I would not put a stack there... and the stack is not code.
Still, your question being on the vague side, it's not necessarily easy to grasp what you are working on.
Kindly,
Alban.

Edit: spelling
Alban Rampon
Partnership Marketing Specialist, ARM.
ARM Connected Community | Contact the team | Raise a new technical support case
0

#3 User is offline   Joseph Yiu 

  • Regular Contributor
  • PipPipPip
  • Group: Members.
  • Posts: 217
  • Joined: 01-March 10

Posted 21 June 2011 - 04:47 PM

I guess you are using a NXP Cortex-M3 microcontroller? (Please be more specific on device type)

If that is the case, to get the best performance (program execution as well as interrupt latency), the stack should be place in the SRAM in the SRAM region. This allows stack operations and program fetches to take place at the same time.
0

#4 User is offline   narke 

  • Member
  • Pip
  • Group: Members
  • Posts: 11
  • Joined: 09-June 11

Posted 22 June 2011 - 02:42 PM

View PostJoseph, on 21 June 2011 - 04:47 PM, said:

I guess you are using a NXP Cortex-M3 microcontroller? (Please be more specific on device type)

If that is the case, to get the best performance (program execution as well as interrupt latency), the stack should be place in the SRAM in the SRAM region. This allows stack operations and program fetches to take place at the same time.



Yes, your guess is perfectly right! I am using NXP17cxx board. For the board, 50% SRAM are arranged in CODE region, another half are in SRAM region. I also have the same thinking about placing the stack on SRAM rather than CODE. But what kind of data (with r/w accessing) are suitable to be placed in CODE region? It's not affordable of not using the 50% of the total SRAM space.

Looking forward for you answer.

Best Regards,
narke


0

#5 User is offline   Joseph Yiu 

  • Regular Contributor
  • PipPipPip
  • Group: Members.
  • Posts: 217
  • Joined: 01-March 10

Posted 22 June 2011 - 08:18 PM

The reason to have half of the RAM in CODE region is to have high speed program execution from SRAM.
By having two SRAM units, you can have data and instruction accesses at the same time (havard bus architecture).

To use this, you need to copy your program code (or at least some part of it) from flash to this SRAM in CODE region, usually during start up process. (Note: You need to link your program correctly to match the run time memory map).

Although NXP has a flash memory prefetch unt, which avoid wait state in sequential accesses, wait state of the flash memory still affect the performance in branches, or some other non-sequential accesses to flash. By using this SRAM for program execution, you can eliminate the effect of flash wait state.

From my understanding there is nothing to stop you from using this SRAM (in CODE region) for stack or data variables. But this SRAM region is not covered by bit-band feature. And depending on how NXP implement the bus interconnections, you might (Note: I don't know, you need to do your own benchmark) find that performance of the system reduced because stack/data operations and program accesses use the same bus (it became von Neumann bus architecture).

regards,
Joseph
0

#6 User is offline   narke 

  • Member
  • Pip
  • Group: Members
  • Posts: 11
  • Joined: 09-June 11

Posted 23 June 2011 - 09:37 AM

View PostJoseph, on 22 June 2011 - 08:18 PM, said:

The reason to have half of the RAM in CODE region is to have high speed program execution from SRAM.
By having two SRAM units, you can have data and instruction accesses at the same time (havard bus architecture).

To use this, you need to copy your program code (or at least some part of it) from flash to this SRAM in CODE region, usually during start up process. (Note: You need to link your program correctly to match the run time memory map).

Although NXP has a flash memory prefetch unt, which avoid wait state in sequential accesses, wait state of the flash memory still affect the performance in branches, or some other non-sequential accesses to flash. By using this SRAM for program execution, you can eliminate the effect of flash wait state.

From my understanding there is nothing to stop you from using this SRAM (in CODE region) for stack or data variables. But this SRAM region is not covered by bit-band feature. And depending on how NXP implement the bus interconnections, you might (Note: I don't know, you need to do your own benchmark) find that performance of the system reduced because stack/data operations and program accesses use the same bus (it became von Neumann bus architecture).

regards,
Joseph


Joseph,

Thanks for the very clean explanation. For our application, because the 32k RAM is definitely not enough, so we have to use the another 32K RAM in code region to store data other than code. In this case, you must understand, we have to decide to put what kind of data into the CODE region RAM space and keep the performance lost in a minimum level. So, putting stack into the CODE region is a good choice or not?

Thanks again,
narke



0

#7 User is offline   Joseph Yiu 

  • Regular Contributor
  • PipPipPip
  • Group: Members.
  • Posts: 217
  • Joined: 01-March 10

Posted 23 June 2011 - 10:41 AM

Putting the stack in the SRAM in CODE region should be fine.
I don't know if it will affect the performance and interrupt latency, you need to do your own benchmark to test it.
regards,
Joseph
0

#8 User is offline   Zova 

  • Member
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 09-June 11

Posted 28 June 2011 - 01:27 AM

View Postnarke, on 20 June 2011 - 03:40 AM, said:

Hi,

My board has 32K SRAM in the code memory area (within the first 0.5G), also has the same size of build in SRAM in data area. My question is, what kind of data are suitable to put in CODE area? Particularly, should I set the main stack in CODE SRAM or DATA SRAM?

Thanks in advance.


Hi narke, may I ask how you access the I/D SRAM or say I/DTCM ? Have you modified your linker program? Now, I'm facing the same problem as you. I want to put some code in code SRAM (my board is S3C6410, ARM1176JZF-S based), but I've no idea about how to place code in.

Thanks,
Zova
0

#9 User is offline   Joseph Yiu 

  • Regular Contributor
  • PipPipPip
  • Group: Members.
  • Posts: 217
  • Joined: 01-March 10

Posted 28 June 2011 - 09:00 AM

Hi Zova,

A easier way to do this is to enable the TCM during startup code, and program the coprocessor register for TCM configuration, and then copy the required program code into the I-TCM before entering main. However, this might not be possible in some boards with fixed firmware / OS.

Have you look at the TRM?
http://infocenter.ar...h/Chdhbjjb.html

regards,
Joseph
1

#10 User is offline   Zova 

  • Member
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 09-June 11

Posted 22 July 2011 - 03:34 AM

View PostJoseph Yiu, on 28 June 2011 - 09:00 AM, said:

Hi Zova,

A easier way to do this is to enable the TCM during startup code, and program the coprocessor register for TCM configuration, and then copy the required program code into the I-TCM before entering main. However, this might not be possible in some boards with fixed firmware / OS.

Have you look at the TRM?
http://infocenter.ar...h/Chdhbjjb.html

regards,
Joseph


Thanks Joseph, and sorry for my late reply. I've read the link above. And can you see this topic just posted.

Thanks,
Zova
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic