2
$\begingroup$

I recall hearing briefly about this back in one of my CS courses on hardware, but I can't recall many of the details, nor can I find anything online that talks about it. A search on Google only yields a bunch of pages about Android emulators and people complaining that PCSX2 is slow. I'd like to know, in general, why software emulation of hardware is inefficient.

Can anybody point me to a good resource or explain briefly here?

$\endgroup$
  • 3
    $\begingroup$ My impression is that it can be quite efficient. To emulate one processor architecture on another architecture, you would use techniques similar to those found in high-level language VMs, such as some Java runtimes. Java bytecode can achieve about the same speed as natively compiled Java code (stackoverflow.com/q/51276/507803). $\endgroup$ – Heatsink Jul 6 '13 at 0:32
  • $\begingroup$ Can you be more specific about the situation you are concerned about? As @Heatsink points out there are lots of software emulators that are quite quick. qemu and Virtual Box emulate supervisor mode using user-mode code. VMs like VMWare, Xen, HyperV emulate multiple machines on one machine with very little overhead. On the other hand if you are trying to simulate a large Verilog or VHDL hardware specification in software then it's going to be really slow. Emulating Floating Point with Integer is relatively slow too. $\endgroup$ – Wandering Logic Jul 6 '13 at 2:55
  • $\begingroup$ I suppose there might be areas where it is efficient - but I was thinking in the context of emulating old console systems. My professor talked as a fan of the original playstation and briefly talked about the speed of hardware circuits vs software - in that software can do everything hardware can do, but not necessarily as fast. When you have a CPU that is highly specialized like that in the PSX, emulating it via software is very hard. $\endgroup$ – agent154 Jul 6 '13 at 5:39
  • 1
    $\begingroup$ I don't think this is exactly ontopic here as the fundamental assumption is flawed: there does not seem to be a principle preventing simulation speed. The observed issues may be caused by poor coding. $\endgroup$ – Raphael Jul 6 '13 at 13:38
  • $\begingroup$ See Retrocomputing's question What makes accurate emulation of old systems a difficult task?. $\endgroup$ – Paul A. Clayton May 1 at 13:17
2
$\begingroup$

If the underlying machine is similar to the simulated one, you can run most code natively (no speed loss unless there are hard to handle instructions or other characteristics, this is the "virtualization" business). If it is very different, you have to really simulate each instruction (for a cost of half a dozen or so native instructions for a typical machine). If it is important enough, you can use tricks like JIT compilation to native code to speed it up.

$\endgroup$
  • 1
    $\begingroup$ Also it can be hard to run code from MIPS III with 32 registers on ARMv7 which has only 16 GP registers. So, even with similar instruction set, every instruction of original system will be converted into several instructions of target system, with additional pressure on memory (more loads/stores) $\endgroup$ – osgx Mar 14 '14 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.