This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RAM in Code memory area

Note: This was originally posted on 20th June 2011 at http://forums.arm.com

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.
Parents
  • Note: This was originally posted on 23rd June 2011 at http://forums.arm.com


    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


Reply
  • Note: This was originally posted on 23rd June 2011 at http://forums.arm.com


    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


Children
No data