--- In gbadev@y..., James Daniels <james.daniels@a...> wrote:
> Hi all,
>
> Has anyone here timed 16-bit reads from IWRAM and EWRAM on a
> real GBA? Are reads from odd addresses just as fast as those
> from even addresses?
I interpret "even" to mean "4n" and "odd" as "4n + 2". Reads from
"odd" addresses from IWRAM should not be any different than reads
from "even" addresses because the whole 32-bit quantity gets placed
on the CPU's bus.
Let me rephrase in more precise language how I perceive your
question, according to the scientific method.
Observation: The GBA has a 16-bit bus between the memory controller
and EWRAM and a 32-bit bus between the CPU and the memory controller.
Some memory controller designers are absent-minded and make stupid
mistakes when connecting buses of differing widths.
Hypothesis: The memory controller does not perform the minimal
optimization of checking which half word the CPU wants first; thus,
a 16-bit read from *(4n + 2) inserts several additional wait states.
Alternate hypothesis: The memory controller performs the
optimization of checking which half word the CPU wants first
and fetches the correct half word from EWRAM.
Experiment: Write a subroutine in C, compiled to ARM binary with
GCC, to run from IWRAM. It should read 16-bit values from addresses
0x02001000, 0x02001002, 0x03001000, and 0x03001002 several times,
surrounded by palette modifications. Include it as part of my timing
test suite, designed to run on multiboot. Run it and look at the
height of the resulting color bars. If "odd" address reads take
longer, the corresponding color bars should be taller.
Results: The color bars for even and odd word EWRAM accesses were
equal in height, and they were appropriately taller than the
corresponding IWRAM color bars. For fun, I added in an unaligned
(odd-byte-address) EWRAM read, and its color bar was the same height.
Conclusion: The data do not match the hypothesis, but they do match
the alternate hypothesis.
Independent verification: Mail me at [tepples at spamcop dot net]
if you want a copy of the source and binaries I used.
--
Damian