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.

Configuring Cache in DSP BIOS v6

Other Parts Discussed in Thread: SYSBIOS

Hello all,

 

Did anybody find a good example / tutorial for how to configure the cache in a DSP BIOS version 6 project?

Of course I did find the cache module ( ti.sysbios.hal.Cache ). But I'm a bit at loss in how to use it. I would like to enable  the L1P, L1D, LL2 and SL2 caches and the MAR on a C6472 DSP. Is there an example somewhere, I couldn't find one.

 

Many thanks in advance!

Tom

  • Hi Tom,

    If you take a look at (ti.sysbios.family.c64p.Cache), which can be used as the cache file for the C6472 DSP, it has more detailed explanation on enabling the cache. 

    Depending on the size of memory you want to be cached,  you can set the mask bits of MAR accordingly.

    In BIOS6, you need a .cfg file to configure/specify the DSP/BIOS parameters. For example, you can use the following in the .cfg file in order to configure MAR224,225,226,227 address spaces of DDR2 as cacheable. 

    var Cache       =   xdc.useModule('ti.sysbios.family.c64p.Cache');

    Cache.MAR224_255 = 0x0000000f;

    If you want to take a look at a demo project for C6472 based on BIOS 6, you can go to https://gforge.ti.com/gf/project/6472evm_oobdemo and download the project. 

    Regards,

    Arun

  • Hi Arun,

    Thank you for your reply. That is indeed an interesting and relevant example. In the mean while we've enabled the cache without use of the module using:

    #include <cslr_cache.h>

    init_cache()

    {

    int i;

    CSL_CacheRegs *CacheRegs;

    CacheRegs = (CSL_CacheRegs*)0x01840000;

    /* Invalidate L1I and L1D */

    CacheRegs->L2CFG = CacheRegs->L2CFG | 0x300;

     

        /* Clean L2 */

        CacheRegs->L2WBINV = 0x1;

    /* Enable Maximal L1P/D cache */

    CacheRegs->L1PCFG = 0x7;

    CacheRegs->L1DCFG = 0x7;

    /* Enable 256k L2 cache */

    CacheRegs->L2CFG = CacheRegs->L2CFG | 0x4;

    for(i=224;i<239;i++)

    CacheRegs->MAR[i] = 0x1;

    }

    But I will try the module way as well using the demo project.
    Kind regards,
    Tom

  • Hi Tom,

    If you have the CSL, thats an easier way to do it too. Good luck with your project :)

    Regards,

    Arun

  • Auppu,

     

    In the demo project you mention the cfg file indeed contains:

    var Cache       =   xdc.useModule('ti.sysbios.family.c64p.Cache');

    Cache.MAR224_255 = 0x0000000f;

    Is that sufficient to enable the caches? How do I know that my caches are enabled now, and that the L2 cache size is e.g., 256k?

     

    Kind regards

  • Tom,

    - the MAR registers enable only cacheability for the external memory (DDR2). If L2 cache or L1 cache are turned off, the performance will still be slow when running out of DDR2


    - to have the MAR range really cached, you will need to have L2 cache / L1 cache active. You found a way to enable it with CSL, and there was a suggestion on how to configure this in BIOS.

    note that after reset L2 is all SRAM (see datasheet page 96) so this needs to be changed as desired


    - the L1 cache configurations will have also default (reset) values which might be changed by the ROM bootloader - you can check in the bootloader user guide what the status will be, see table 21

    Again, the application code will need to modify them as desired after the bootloader stage


    - pay attention that the linker command file for your application will need to be coherent with the final configuration, i.e. it is forbidden to allocate code / data in memory sections (like in L2) that are successively reconfigured as cache. If you do this the program would likely behave in an unpredictable way and crash immediately

    - the megamodule (C64x+) cache user guide has information on what to take care of in terms of cache / buffer management in relation to different scenarios, when having L2 cache active with DDR buffers and concurrent DMA transfers

    This applies mainly to external memory ranges since internal cache coherency between L2 Ram and L1P/L1D is quite completely maintained by the megamodule itself in hw by snooping the cache activity (please check the user guide for the details and the exceptions, mainly for L1P)


    - also make sure to read carefully the bootloader user guide as at reset some parts of the L2 internal ram for core zero need to be reserved to the bootloader internal use.  If I recall well you can also "reuse" this apparently "lost" memory after boot by declaring it as a union, and putting there an uninitialized section, if desired, or some other data which you page / copy in with the application - see the assembly language tools user guide for the details, there should be an example of doing this (sorry I don't remember the exact section, it's about the linker command file setup)

     

    Hope this helps clarifying.