One way to get "perfect" emulation is to completely reverse-engineer the system down to the transistor level, wherein the timing relationships between all the components are revealed. I believe this has been done only for a very small number of game consoles, of which I'm aware of are the Atari VCS/2600[1] and NES[2]. Even a GameBoy hasn't been analysed to this level, much less a GBA or DS.
Also, this: https://trixter.oldskool.org/2015/04/07/8088-mph-we-break-al...
[1] http://blog.visual6502.org/2014/10/atari-2600-simulation.htm...