Private RAM vs SDRAM

Ask anything your want about the 32X Mushroom programming.

Moderator: BigEvilCorporation

Post Reply
ob1
Very interested
Posts: 463
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Private RAM vs SDRAM

Post by ob1 » Tue May 25, 2021 2:34 pm

I've done some testing regarding private RAM (cache used as RAM), and how it compares to cache-through SDRAM.

My code is something like this :

Code: Select all

main:
	ADD	#2,R2	; R2 = counter
	AND	R3,R1	; R3 = Address Mask. M: $3FFFF ; S: $C00007FF. Not needed for 16-bit tests

	BRA	main
	MOV.W	@R1+,R0	; R1 = Read Address. M: $26000000 ; S: $C0000000
			; Feel free to use MOV.L instead, for testing 32-bits accesses




V_INT_M:
	STS.L	PR,@-R15
	MOV.L	R0,@-R15

	MOV.W	R0,@($16,GBR)	; ACK H_INT

	MOV	R2,R0
	MOV.L	R0,@($20,GBR)

	MOV	#0,R2

	MOV.L	@R15+,R0
	LDS.L	@R15+,PR
	RTE
	NOP


V_INT_S:
	STS.L	PR,@-R15
	MOV.L	R0,@-R15

	MOV.W	R0,@($16,GBR)	; ACK H_INT

	MOV	R2,R0
	MOV.L	R0,@($24,GBR)

	MOV	#0,R2

	MOV.L	@R15+,R0
	LDS.L	@R15+,PR
	RTE
	NOP

With this code, the private RAM is 61% faster than the cache-through SDRAM for 16-bit access,
and more than twice faster for 32-bit access.

Img_2752.jpeg
16-bit access. CommPort0 = Cache Through SDRAM, CommPort4 = Private RAM
Img_2752.jpeg (141.67 KiB) Viewed 63609 times
Img_2753.jpeg
16-bit access. CommPort0 = Cache Through SDRAM, CommPort4 = Private RAM
Img_2753.jpeg (156.31 KiB) Viewed 63609 times
NB : the gap between 16-bit and 32-bit cache-through is the "AND R3,R1" instruction.

As you know, once you've read a data from SDRAM, as long as there is room to hold it in cache, this data stays in cache and benefits from the same bandwidth as private RAM. So, for a small array, my advice is to not worry about its location.


But if you want to access a medium size array (let's say, more than 64B, but less than 2kB), and you know you're going to access it a lot, and each access will be fully random, and you want to store 32-bits long integers - eg, a sine table ; then I definitely would recommend to use the private RAM.

Hope it helps.

Post Reply