You know what a simulator is it simulates things like planes and cars, giving you the feeling that your operating that object.
An emulator is something that makes something else act like something its not. There for allowing you to use something as if it was something its not.
Most talk of emulation is for computer and computer based items. You would install an emulator to emulate (act as) a example : game system.
Confused yet??? lol
Read on......
Emulator
An emulator reproducing a console game's playable atmosphere on a Windows computer.
Enlarge
An emulator reproducing a console game's playable atmosphere on a Windows computer.
A software emulator allows computer programs to run on a platform (computer architecture and/or operating system) other than the one for which they were originally written. Unlike simulation, which only attempts to reproduce a program's behavior, emulation attempts to model to various degrees the state of the device being emulated. High-level emulation uses a combination of the two approaches in an attempt to retain as much accuracy as possible while having the advantages of simplicity and speed provided by simulation.
A hardware emulator is an emulator which takes the form of a hardware device. Examples include printer emulators inside the ROM of the printer, and FPGA-based emulators.
A popular use of emulators is to mimic the experience of running arcade games or console games on personal computers. Emulating these on modern desktop computers is usually less cumbersome and more reliable than relying on the original machines, which are often old and hard to find, let alone repair. Emulation of arcade and console systems on home PCs usually includes the practice of illegally downloading software from various electronic distribution sources.
In a theoretical sense, the Church-Turing thesis implies that any operating environment can be emulated within any other. In practice, it can be quite difficult, particularly when the exact behavior of the system to be emulated is not documented and has to be deduced through reverse engineering. It also says nothing about timing constraints; if the emulator does not perform as quickly as the original hardware, the emulated software may run much more slowly than it would have on the original hardware.
-------------------------------------------------------------------------------------
* 1 Structure
o 1.1 Memory subsystem
o 1.2 CPU simulator
o 1.3 I/O
* 2 See also
* 3 External links
Structure
Most emulators just emulate a hardware architecture — if operating system firmware or software is required for the desired software, it must be provided as well (and may itself be emulated). Both the OS and the software will then be interpreted by the emulator, rather than being run by native hardware. Apart from this interpreter for the emulated machine's language, some other hardware (such as input or output devices) must be provided in virtual form as well; if writing to a specific memory location should influence the screen, for example, this will have to be emulated.
Sufficient emulation of some hardware platforms requires extreme accuracy, down to the level of individual clock cycles, undocumented features and implementation bugs. This is particularly the case with classic home computers such as the Commodore 64, whose software often depends on highly sophisticated low-level programming tricks invented by game programmers and the demoscene.
In contrast, some other platforms have had very little use of direct hardware addressing. In these cases, a simple compatibility layer may suffice. This translates system calls for the emulated system into system calls for the host system.
Developers of software for embedded systems or video game consoles often design their software on especially accurate emulators called simulators before trying it on the real hardware. This is so that software can be produced and tested before the final hardware exists in large quantities, so that it can be tested without taking the time to copy the program to the hardware, or so that it can be debugged at a low level without introducing the side effects of a debugger. In many cases, the simulator is actually produced by the company providing the hardware, which theoretically increases its accuracy.
Typically, an emulator is divided into modules that correspond roughly to the emulated computer's subsystems. Most often, an emulator will be composed of the following modules:
* a CPU emulator or CPU simulator (the two terms are mostly interchangeable)
* a memory subsystem module
* various I/O devices emulators
Buses are often not emulated, either for reasons of performance or simplicity, and virtual peripherals communicate directly with the CPU or the memory subsystem.
A detailed description of the internals of a specific emulator can be found in the ElectrEm article.
Technical details follow
The following subsections contain technical details and assumes the reader has knowledge on computer architecture and computer programming. Readers not interested in those details may skip these parts.
[edit]
Memory subsystem
It is possible for the memory subsystem emulation to be reduced to simply an array of elements each sized like an emulated word; however, this model falls very quickly as soon as any location in the computer's logical memory does not match physical memory.
This clearly is the case whenever the emulated hardware allows for advanced memory management (in which case, the MMU logic can be embedded in the memory emulator, made a module of its own, or sometimes integrated into the CPU simulator).
Even if the emulated computer does not feature an MMU, though, there are usually other factors that break the equivalence between logical and physical memory: many (if not most) architecture offer memory-mapped I/O; even those that do not almost invariably have a block of logical memory mapped to ROM, which means that the memory-array module must be discarded if the read-only nature of ROM is to be emulated. Features such as bank switching or segmentation may also complicate memory emulation.
As a result, most emulators implement at least two procedures for writing to and reading from logical memory, and it is these procedures' duty to map every access to the correct location of the correct object.
On a base-limit addressing system where memory from address 0 to address ROMSIZE is read-only memory, while the rest is RAM, something along the line of the following procedures would be typical:
void WriteMemory(word Address, word Value) {
word RealAddress;
RealAddress=Address+BaseRegister;
if(RealAddress
if(RealAddress>ROMSIZE) Memory[RealAddress]=Value;
} else {
RaiseInterrupt(INT_SEGFAULT);
}
}
word ReadMemory(word Address) {
word RealAddress;
RealAddress=Address+BaseRegister;
if(RealAddress
return Memory[RealAddress];
} else {
RaiseInterrupt(INT_SEGFAULT);
return NULL;
}
}
[edit]
CPU simulator
The CPU simulator is often the most complicated part of an emulator. Many emulators are written using "pre-packaged" CPU simulators, in order to concentrate on good and efficient emulation of a specific machine.
The simplest form of a CPU simulator is an interpreter, which follows the execution flow of the emulated program code and, for every machine code instruction encountered, executes operations on the host processor that are semantically equivalent to the original instructions.
This is made possible by assigning a variable to each register and flag of the simulated CPU. The logic of the simulated CPU can then more or less be directly translated into software algorithms, creating a software re-implementation that basically mirrors the original hardware implementation.
The following example illustrates how CPU simulation is accomplished by an interpreter. In this case, interrupts are checked-for before every instruction executed, though this behavior is rare in real emulators for performance reasons.
void Execute(void) {
if(Interrupt!=INT_NONE) {
SuperUser=TRUE;
WriteMemory(++StackPointer, ProgramCounter);
ProgramCounter=InterruptPointer;
}
switch(ReadMemory(ProgramCounter++)) {
/*
* Handling of every valid instruction
* goes here...
*/
default:
Interrupt=INT_ILLEGAL;
}
}
Interpreters are very popular as CPU simulators, as they are much simpler to implement than more time-efficient alternative solutions, and their speed is more than adequate for emulating computers of more than roughly a decade ago on modern machines.
However, the speed penalty inherent in interpretation can be a problem when emulating computers whose processor speed is on the same order of magnitude as the host machine. Until not many years ago, emulation in such situations was considered completely impractical by many.
What allowed breaking through this restriction were the advances in dynamic recompilation techniques. Simple a priori translation of emulated program code into code runnable on the host architecture is usually impossible because of several reasons:
* code may be modified while in RAM, even if it is modified only by the emulated operating system when loading the code (for example from disk)
* there may not be a way to reliably distinguish data (which should not be translated) from executable code.
Various forms of dynamic recompilation, including the popular Just In Time compiler (JIT) technique, try to circumvent these problems by waiting until the processor control flow jumps into a location containing untranslated code, and only then ("just in time") translates a block of the code into host code that can be executed. The translated code is kept in a code cache, and the original code is not lost or affected; this way, even data segments can be (meaninglessly) translated by the recompiler, resulting in no more than a waste of translation time.
[edit]
I/O
Most emulators do not, as mentioned earlier, emulate the main system bus; each I/O device is thus often treated as a special case, and no consistent interface for virtual peripherals is provided.
This can result in a performance advantage, since each I/O module can be tailored to the characteristics of the emulated device; designs based on a standard, unified I/O API can however rival such simpler models, if well thought-out, and they have the additional advantage of "automatically" providing a plug-in service through which third-party virtual devices can be used within the emulator.
A unified I/O API may not necessarily mirror the structure of the real hardware bus: bus design is limited by several electric constraints and a need for hardware concurrency management that can mostly be ignored in a software implementation.
Even emulators that treat each device as a special case, there is usually a common basic infrastructure for
* managing interrupts, by means of a procedure that sets flags readable by the CPU simulator whenever an interrupt is raised, allowing the virtual CPU to "poll for (virtual) interrupts"
* writing to and reading from physical memory, by means of two procedures similar to the ones dealing with logical memory (although, contrary to the latter, the former can often be left out, and direct references to the memory array be employed instead)
2006-09-18 13:31:23
·
answer #1
·
answered by tc_an_american 7
·
0⤊
0⤋