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.

TMS570LC4357: L1 cache memory usable as scratchpad memory if cache disabled?

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Assuming that I disable the L1 caches, can I use the cache memory as fast software-controlled scratchpad memory?

According to the technical reference manual, the cache memory is mapped at addresses 0x3000_0000 and 0x3100_0000 (32 KiB each).

With the hardware caching logic disabled, can the software execute regular load and store instructions to these memory locations and expect them to behave normally?

  • Hi Manuel,

    I don't know how to use cache memory as regular RAM. I tried to read/write data from/to cache memory range after enabling AXI-S, but I got abort.

  • I tried to read/write data from/to cache memory range after enabling AXI-S, but I got abort.

    Which addresses were you trying to access?

    The TMS570LC43x TRM contains the following:

    With the "Actual Size" of the Cache Memories specified as 32kB my initial thought that was that the lowest 32kB of each frame would access the Cache Memory.

    From an initial poke around the memory map using:

    a. The CCS debugger Memory Browser.

    b. A TM570LC4357 program halted in _c_int00() before the caches and MPU had been enabled.

    c. Using a modified tms570lc43xx.gel in which all of the address from 0x30000000..0x31FFFFFF were marked as RAM, to prevent the CCS debugger from filtering out accesses to parts of the Level 1 Cache Memories frames.

    d. In the CCS Registers view manually setting the AXISCEN "Enable AXI Slave Cache RAM Access" bit in the CP15_AUXILLARY_CONTROL register.

    From just manually scrolling through the memory map the following addresses are accessible:

    • 0x30008000..0x3000BFFF
    • 0x30010000..0x30013FFF
    • 0x30020000..0x30023FFF
    • 0x30040000..0x30043FFF
    • 0x30088000..0x3008BFFF
    • 0x30090000..0x30093FFF
    • 0x300A0000..0x300A3FFF
    • 0x300C0000..0x300C3FFF
    • 0x30108000..0x3010BFFF
    • 0x30110000..0x30113FFF
    • 0x30118000..0x3011BFFF
    • 0x30120000..0x30123FFF
    • 0x30128000..0x3012BFFF
    • 0x30130000..0x30133FFF
    • 0x30138000..0x3013BFFF
    • 0x30140000..0x30143FFF
    • 0x30148000..0x3014BFFF
    • 0x30150000..0x30153FFF
    • 0x30158000..0x3015BFFF
    • 0x30160000..0x30163FFF
    • 0x30168000..0x3016BFFF
    • 0x30170000..0x30173FFF
    • 0x30178000..0x3017BFFF

    The above was a simplistic test which didn't actually confirm which of the above address regions which are accessible are aliases of each other.

    Cache RAM access is the ARM Cortex-R5 documentation for how the address bits to cache RAMs are mapped, and will try and create a program to demonstrate using the cache RAMs as "scratchpad memory".

  • Thanks Chester. Please let us know after you done it. 

  • Hi Chester,

    thanks for your investigation and the link to the technical reference manual.  I'd be very interested in your findings if you continue with your tests.

  • Cache RAM access is the ARM Cortex-R5 documentation for how the address bits to cache RAMs are mapped, and will try and create a program to demonstrate using the cache RAMs as "scratchpad memory".

    I created a program which read/writes the cache RAMs from a program. To give access to the cache RAMs directly:

    a. In the HalCoGen configuration under R5-MPU-PMU -> Cortex-R5 -> General Configuration left the cache as disabled.

    b. In the HalGoGen configuration under R5-MPU-PMU -> MPU enabled a region to access the cache RAMs:

    c. Used the following function to enable AXI Slave access to the cache RAMs:

    static void enable_axi_slave_cache_access (void)
    {
        uint32_t ACTLR;
        const uint32_t AXISCEN = 1 << 24; /* AXI slave cache RAM access enable */
        const uint32_t AXISCUEN = 1 << 23;  /* AXI slave cache RAM non-privileged access enable */
    
        ACTLR = __MRC (15, 0, 1, 0, 1);
        ACTLR |= AXISCEN | AXISCUEN;
        __MCR (15, 0, ACTLR, 1, 0, 1);
    }

    A test was made on performing 32-bit write/reads to the following which is a total of 32 KB for the D_cache data RAMs:

    • 0x30008000..0x30008fff
    • 0x3000a000..0x3000afff
    • 0x30010000..0x30010fff
    • 0x30012000..0x30012fff
    • 0x30020000..0x30020fff
    • 0x30022000..0x30022fff
    • 0x30040000..0x30040fff
    • 0x30042000..0x30042fff

    When the test program was used to write a test pattern to the above addresses and readback the contents, then with the compiler optimisation level set to off the read back was successful. However, when the compiler optimisation was 2 then the readback failed on some addresses. In the debugger looking in the Memory Browser it looks like some writes to odd words didn't update the data RAM. If single step the optimised program in the debugger, then write in the debugger then data RAM was updated correctly.

    I think the there is something which means the cache RAM accessed over the AXI Slave don't support back-to-back accesses, as the interface is supposed to only be used to functionally test the cache RAMs.

    Also, the AXI Slave interface to the cache RAMs gives independent access to the ECC so direct access to the data RAM may not update the ECC.

    The above is a bit vague, but I don't believe ARM designed the Cortex-R5 caches to be accessed as fast access "scratchpad memory" when the caches are disabled.

  • A test was made on performing 32-bit write/reads to the following which is a total of 32 KB for the D_cache data RAMs

    For reference, the test project is attached. The test_data_rams_uint32 function in source/HL_sys_main.c performs a simple test of the 32KB for the D_cache data RAMs by writing a test pattern using 32-bit accesses, and then checks can read back the pattern.

    When the Debug configuration, with optimisation level Off, is run the read back is successful:

    Num data RAM readback failures as 32-bit inc accesses = 0 (out of 8192 tested)
    Num data RAM readback failures as 32-bit dec accesses = 0 (out of 8192 tested)

    When the Release configuration, with optimisation level 2 - global optimisations, is run then some locations in the D_cache data RAMs fail to read back the expected values:

    Num data RAM readback failures as 32-bit inc accesses = 4095 (out of 8192 tested)
    Num data RAM readback failures as 32-bit dec accesses = 1025 (out of 8192 tested)

    Looking in the debugger at the memory shows that for Release the cache RAM doesn't get updated correctly.

    Single stepping in the debugger for the loop in test_data_rams_uint32() which writes to the data cache RAM reduces the number of readback failures.

    I.e. don't believe the compiler optimizer has generated incorrect code, but rather the change in timing to the data RAM causes accesses to be 'lost'.

    Cache RAM access contains:

    Writes to the RAM-Access space update TRANSFER with the write data, then use this register, and possibly AUX, to write to the selected RAM.
    Reads from the RAM-Access space read the RAM contents into TRANSFER, and possibly AUX, and provide the requested portion of the read data from TRANSFER on the AXI interface.

    To perform accesses outside these restrictions, you must perform a read-modify-write sequence.

    Think that quick back-to-back writes to the RAM-Access space, when the optimisations are used, prevents the RAM being updated correctly.

    8468.TMS570LC4357_cache_rams_scratchpad.zip

  • Thanks Chester

  • Hi Hi Manuel,

    Please try the project developed by Chester. I tested on my bench. It works as described in Chester's post. 

  • Hi,

    thanks so much for the great and in-depth investigation, Chester!  That answers all of my questions.  It's a pity that the cache memory cannot be used as a scratchpad in a straightforward way, but now at least I know how it behaves and why :)

    Thanks,

    Manuel