This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

An Embarrassingly Simple SRAM/EMIF Question

On a 6418, with all L2 RAM turned off (100 percent user SRAM), and all MARs at their power-up default state of 0 (disabled), does the CPU automatically handle EDMA transfers from L1D cache to external SDRAM for a simple initialization loop like this:

void InitSDRAM(void)
{
  uint32_t n;
  uint8_t* p;

  p =   (uint8_t*)0x80000000;
  for (n = 0; n < 0x04000000; n++)
  {
    *(p + n) = 0x00;
  }
}

?

I'm asking because I'm getting wrong results if I try to initialize more than 1 MB. The routine is run last after all other initialization, including EMIF, has been performed.

--Randy

  • I'm a little confused by the question.   Maybe I should clarify on a few things:

    • Cache requests to external memory are submitted by the L2 cache controller to the EDMA
    • In the case of a "long distance access" (i.e. non-cacheable data in external memory) this will also get submitted to the EDMA and the CPU will stall until it completes

    What results do you see?  I suspect this could be a compiler issue (maybe related to small/large memory model, etc).  Have you tried adjusting your syntax a bit.  Maybe like this:

    void InitSDRAM(void)
    {
      uint32_t n;
      uint8_t* p;

      p =   (uint8_t*)0x80000000;
      for (n = 0; n < 0x04000000; n++)
      {
        *p++ = 0x00;
      }

    // optionally re-initialize p back to the initial value if you need it some more


    }

  • Thanks for that, Brad. I think my situation falls into the second bullet you listed above but I'm not sure I understand you. 

    As I stated, there is no L2 cache - I've turned it all off. So obviously the L2 cache controller is not involved here.

    When you say "non-cacheable data in external memory", what do you mean? Since there is L1 data and code cache, it seems that any piece of data anywhere is R/W  "cacheable".

    When you say "this will also get submitted to the EDMA", what would the EDMA source address be? The L1 cache? I.e., is the CPU going to write the data, one cache line at a time, into the L1 data cache, and then the CPU will generate an EDMA to write the data from the cache out to SDRAM?

    I guess my confusion is this: where exactly does the CPU "write" to when it tries to write to SDRAM? As I understand it, there is no direct path from the CPU to external memory in the 6418. The previous paragraph is my best guess: it writes to the L1 cache. Is this correct or not?

    --Randy

  • Randy,

    There are a couple documents that are relevant here that I want to be sure you're aware of:

    Cache User's Guide
    Two Level Internal Memory Reference Guide

    That second guide in particular would be easy to overlook, but it has a lot of great information including the details on the "long distance access".

    Randy Yates said:
    As I stated, there is no L2 cache - I've turned it all off. So obviously the L2 cache controller is not involved here.

    Although you have disabled caching, the cache controller never goes away.  It simply stops keeping a local copy.  So regardless of whether cache is enabled or disabled (and regardless of MAR bits) the L2 cache controller still submits requests to the EDMA.

    Randy Yates said:
    When you say "non-cacheable data in external memory", what do you mean? Since there is L1 data and code cache, it seems that any piece of data anywhere is R/W  "cacheable".

    For external memory the user controls whether or not it is cacheable or not.  That's the whole purpose of the MAR bits.

    Randy Yates said:
    When you say "this will also get submitted to the EDMA", what would the EDMA source address be? The L1 cache? I.e., is the CPU going to write the data, one cache line at a time, into the L1 data cache, and then the CPU will generate an EDMA to write the data from the cache out to SDRAM?

    Important distinction:  the CPU does not submit EDMA events.  The CPU will simply attempt to access an external memory location.  Consider the cache as a black box between the CPU and the external memory.  There are a handful of knobs on that box, but from the CPU perspective it simply asks for an address and receives the corresponding data.  If the knobs are turned such that data is NOT cacheable then the CPU will receive data very slowly.  If the knobs are turned such that cache is enabled then the CPU will get data much faster.  It's important to note that in these 2 scenarios nothing changes from the CPU perspective (i.e. it requests data and receives it).  The difference is in the speed in which the cache subsystem gives that data to the CPU.

    Randy Yates said:
    I guess my confusion is this: where exactly does the CPU "write" to when it tries to write to SDRAM? As I understand it, there is no direct path from the CPU to external memory in the 6418. The previous paragraph is my best guess: it writes to the L1 cache. Is this correct or not?

    From the CPU perspective it is doing a write directly to SDRAM.  It doesn't know anything about the underlying cache.  From the cache subsystem perspective, the L1D memory controller will first take the request.  If that line exists in L1D cache it will make the update and that will be the end.  If that line does NOT exist in L1D cache then note that in the case of a write it will NOT be allocated since L1D is a read allocate cache (i.e. only a read miss will cause the line to be allocated).  So the data the CPU is writing will miss L1D and go into a write buffer to L2.  Since L2 cache is disabled it will be submitted to the EDMA which will then write it to the EMIF where it ultimately lands in SDRAM.

    Hopefully these details are helping you and not confusing you more!

     

  • Brad, thanks very much for your detailed and satisfying answers. You're right, I had skipped over the two-level memory document. That document, along with a detailed reading of your response, is now on my short list of things to do.

    --Randy