gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Hardware > Which ROM WS is standard?

#11547 - poslundc - Fri Oct 10, 2003 4:12 pm

Does anyone know what the standard waitstate for ROM access on a GBA cartridge is?

I'm trying to make some strategic decisions about ROM versus EWRAM, but the effect of the different waitstates is too huge for me to make an informed decision.

On that note, does anyone know what the EZ-Flash ROM uses?

Thanks,

Dan.

#11550 - DekuTree64 - Fri Oct 10, 2003 5:22 pm

The GBA starts up in 4/2, so unless you change it yourself, that's what you'll get. I've heard that most commercial games use 3/1. I'm not sure what's the fastest a flash cart can handle, but you could try 3/1 and if it starts to do unpredictable things, switch to 3/2 or 4/2.
http://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm#REG_WS_CR
tells all the settings for the WSCNT register.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#11551 - torne - Fri Oct 10, 2003 5:30 pm

All recent (in the last year or 18 months) flashcarts should be able to deal with 3/1. Old Visoly carts couldn't; that is why the 'flash speed patches' for commercial roms existed; they found the wait state setting in the ROM and switched it back to 4/2 - this usually made the game jerky (but at least it didn't crash). No commercial cart that I'm aware of uses faster speeds than 3/1.

#11552 - Burton Radons - Fri Oct 10, 2003 6:48 pm

Does anyone know of a consistent assertion test that can be performed? GBATEK only says it's "unstable" to overclock it.

You can check what waitstate a ROM assigns by running it in VBA and opening the Memory Viewer when in window mode. Here's what I get for a couple of games in waitstate 0:

Legend of Zelda, The: A Link to the Past: 3,1.
Pokemon Sapphire: 4,1.
Tactics Ogre: The Knights of Lodis: 2,1.

So it looks like there's a lot of variance.

#11554 - DekuTree64 - Fri Oct 10, 2003 7:17 pm

I don't think there is any certain way to tell. It's just like overclocking a processor, most of the time it will run fine, but sometimes it will overheat or something and mess up. I guess if you DMA a whole bunch of data from the cart to EWram or something, loop through and add it all up and see if you come out with the same number on each waitstate setting it would probably be pretty likely to cause problems if there were any, since DMA will do the most accesses in a short time as possible.

Also, there's an interesing register at 0x4000800 that can set the EWram waitstates. According to http://www.work.de/nocash/gbatek.htm it's not a good thing to mess with. Wouldn't want to hurt my GBA's EWram chip, but it's still tempting to do some tests on it...
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#11555 - poslundc - Fri Oct 10, 2003 7:36 pm

I'm afraid I've only made myself more confused than I was before...

Between the three mirror ROM images and their different wait settings, and the listed access times for different memory areas, I'm having trouble figuring out whether (on standard hardware) it would be faster to access the ROM or EWRAM.

For example, according to gbatek an EWRAM access takes 3/6 for 16/32 bit accesses by default, and ROM takes 5/8 for 16/32 accesses by default. But which of the three ROM banks does this refer to? (For that matter, which ROM bank are all of my variables being read out of?) And does that only apply for the default 3/1 N/S waitstate settings?

Furthermore, DMA timings on the Cowbite spec seem to fly in the face of those numbers. There the EWRAM takes as long or longer than any of the three ROM areas. (Which ROM area is the one I'm actually using again?)

I guess what it all comes down to is that I'm looking to figure out which is faster: EWRAM or ROM. If someone could spell it out for me it would be much appreciated. :)

Thanks,

Dan.

#11557 - tepples - Fri Oct 10, 2003 8:03 pm

poslundc wrote:
I'm having trouble figuring out whether (on standard hardware) it would be faster to access the ROM or EWRAM.

Depends if you're DMAing (mostly sequential access), running Thumb code (a mix), or using a lookup table (lots of random access). EWRAM is slightly faster than ROM for 8-bit or 16-bit random access, but ROM is slightly faster than EWRAM for sequential access. EWRAM also drains the battery less than ROM.

Quote:
For example, according to gbatek an EWRAM access takes 3/6 for 16/32 bit accesses by default, and ROM takes 5/8 for 16/32 accesses by default. But which of the three ROM banks does this refer to? (For that matter, which ROM bank are all of my variables being read out of?)

Anything you compile with DevKit Advance will access the first ROM bank (0x08000000-0x09ffffff). The other two ROM banks are supposed to be used for mapping slower I/O devices into cart space.

Quote:
And does that only apply for the default 3/1 N/S waitstate settings?

The gbatek cycle figures look correct for a random access to memory with 2/2 (EWRAM) and 4/2 (default ROM) wait states. By default, the GBA sets up 4/2 wait states for ROM to account for future memories that may be denser but not as fast as the mask and OTP memories currently used in GBA replication. However, most commercial carts set ROM to 3/1; a random access to ROM at these settings takes 4 cycles (16-bit) or 6 cycles (32-bit).

Quote:
Furthermore, DMA timings on the Cowbite spec seem to fly in the face of those numbers. There the EWRAM takes as long or longer than any of the three ROM areas.

DMA is sequential access, so only the second quoted wait state number counts. EWRAM has 2 wait states for a sequential access, and so does ROM's default settings. However, most commercial carts set ROM to 3/1, and DMA from this sort of ROM is faster than DMA from EWRAM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#11558 - DekuTree64 - Fri Oct 10, 2003 8:33 pm

Well, Tepples pretty much answered your question about which is faster, but to clarify about ROM banks, there's really no difference in them at all, they're just mirrors of the same data. The only difference is that the GBA can see if you're accessing the first, second or third mirror by the upper byte of the address (0x8000000, 0xA000000 or 0xC000000) and use whatever waitstates are set for that mirror in WSCNT. That just gives you a way of setting up 3 waitstate sets, so you can pick between them by changing your address and not have to change WSCNT every time you want to access something from a different speed chip. But yes, for a regular game you'll only use the first mirror, so you only have to worry about the first waitstate setting in WSCNT.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku