With the rapid development of computer technology,hardware manufacturers are constantly updating the hardware architecture of the processor.While promoting the improvement of computer performance,they also have increasingly serious software compatibility problems.The reason for software compatibility problems is that binary executable files compiled for one architecture cannot run on hardware with different architectures.For game consoles and various embedded platforms,the software compatibility problem is more serious than traditional PC platforms,because these platforms not only have different processor architectures,but also there is no unified standard for other internal hardware,which also leads to Embedded developers must purchase the corresponding hardware platform to complete the software development and debugging.The simulator is a type of software that simulates hardware functions through software.The core task of the simulator is to simulate the underlying hardware such as the CPU,image processor,and audio processor of the target platform.Through the simulation of the underlying hardware,it realizes that the software of another platform runs on the host platform,and solves the software compatibility problem to a certain extent.FC(Family Computer)is the first generation of home game console released by Nintendo.It's hardware architecture is very different from the current PC platform,so the software on this platform cannot run directly on the traditional PC.Most existing simulators are interpreted simulators.This kind of simulator will cause very serious performance loss.In order to improve the operating efficiency of the simulator,this article will implement an FC simulator based on the interpreted kernel and dynamic recompilation kernel.The main work of this article can be divided into the following parts: The first part briefly introduces and analyzes the hardware composition and working principle of FC platform.The second part,according to the hardware structure of the original platform,divides the simulator into three modules: kernel module,network module and user interface module,and then designs the overall architecture of the software according to the module division.In the third part,the simulation of instruction set,interrupt and memory bus are realized based on the interpreted kernel.In the fourth part,the dynamic recompilation kernel is implemented based on LLVM.The realization process of functions such as instruction translation,interrupt handling,memory access,and compile-time optimization are introduced in detail.The fifth part introduces the implementation of other components in the kernel,including image processing unit,audio processing unit,NES file parser,memory mapper and input device.The sixth part introduces the realization of the peripheral functions of the simulator,including network connection,instant archiving,event loop and user interface.Finally,this article has carried out a complete test of the implemented simulator,and verified the correctness and reliability of the simulator implementation.Then,the interpreted kernel and the compiled kernel are tested in different environments respectively.According to the test results,it is concluded that the compiled kernel performs faster than the interpreted kernel in most cases.At the same time,according to the test results of the simulator,this article also points out the deficiencies in the implementation of the FC simulator and proposes corresponding improvements. |