如何制作ARM9自定义设备模拟器?

发布于 2024-08-05 12:01:49 字数 247 浏览 12 评论 0原文

我正在使用 266 Mhz、支持 fpu 和 32 MB RAM 的 ARM 9 处理器,我在上面运行 linux。我想在 pc 上模拟它(我在 pc 上同时有 linux 和 windows 可用)。我想分析我的周期计数,直接在模拟器中运行交叉编译的可执行文件。是否有任何开源项目可用于轻松创建模拟器,我需要编写多少更改/代码/工作才能用它制作自定义模拟器?如果您为我提供教程或其他参考资料以帮助我入门,那就太好了。

谢谢&问候,

桑尼。

I am working on ARM 9 processor with 266 Mhz with fpu support and 32 MB RAM, I run linux on it.I want to emulate it on pc ( I have both linux and windows availabe on pc ). I want to profile my cycle counts, run my cross-compiled executables directly in emulator. Is there any opensource project available to create emulator easily, How much change/code/effort does I need to write to make custom emulator with it ? It would be great if you provide me tutorials ot other reference to get kick-start.

Thanks & Regards,

Sunny.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

似狗非友 2024-08-12 12:01:49

您想仅模拟处理器还是整个​​机器?

模拟 CPU 非常简单,只需定义一个包含所有 CPU 寄存器的结构,创建一个数组来模拟 RAM,然后像这样进行模拟:

    cpu_ticks = 0;  // counter for cpu cycles 

    while (true) {

      opcode = RAM[CPU.PC++]; // Fetch opcode and increment program counter

      switch (opcode) {

        case 0x12: // invented opcode for "MOV A,B"
          CPU.A = CPU.B;
          cpu_ticks += 4; // imagine you need 4 ticks for this operation
          set_cpu_flags_mov();
          break;

        case 0x23: // invented opcode for "ADD A, #"
          CPU.A += RAM[CPU. PC++]; // get operand from memory
          cpu_ticks += 8;
          set_cpu_flags_add();
          break;

        case 0x45: // invented opcode for "JP Z, #"
          if (CPU.FLAGS.Z) CPU.PC=RAM[CPU.PC++]; // jump
          else CPU.PC++; // continue
          cpu_ticks += 12;
          set_cpu_flags_jump();
          break;
        ...
      }

      handle_interrupts();

    }

模拟整个机器要困难得多...您需要模拟 LCD 控制器、内存映射寄存器、内存条控制器、DMA、输入设备、声音、I/O 东西...也许你还需要 BIOS 和操作系统的转储...我不知道 ARM 处理器,但它是否有管道、缓存和这样的事情,时间安排变得更加复杂。

如果您完整记录了所有硬件部件,那么没有问题,但如果您需要进行逆向工程或猜测模拟机器的工作原理......您将遇到困难。

从这里开始:http://infocenter.arm.com/help/index.jsp并下载适用于您的处理器的“技术参考手册”。

对于一般仿真问题:http://www.google。 es/search?q=how+to+write+an+模拟器

Do you want to emulate just the processor or an entire machine?

Emulate a CPU is very easy, just define a structure containing all CPU registers, create an array to simulate RAM and then just emulate like this:

    cpu_ticks = 0;  // counter for cpu cycles 

    while (true) {

      opcode = RAM[CPU.PC++]; // Fetch opcode and increment program counter

      switch (opcode) {

        case 0x12: // invented opcode for "MOV A,B"
          CPU.A = CPU.B;
          cpu_ticks += 4; // imagine you need 4 ticks for this operation
          set_cpu_flags_mov();
          break;

        case 0x23: // invented opcode for "ADD A, #"
          CPU.A += RAM[CPU. PC++]; // get operand from memory
          cpu_ticks += 8;
          set_cpu_flags_add();
          break;

        case 0x45: // invented opcode for "JP Z, #"
          if (CPU.FLAGS.Z) CPU.PC=RAM[CPU.PC++]; // jump
          else CPU.PC++; // continue
          cpu_ticks += 12;
          set_cpu_flags_jump();
          break;
        ...
      }

      handle_interrupts();

    }

Emulate an entire machine is much much harder... you need to emulate LCD controllers, memory mapped registers, memory banks controllers, DMAs, input devices, sound, I/O stuff... also probably you need a dump from the bios and operative system... I don't know the ARM processor but if it has pipelines, caches and such things, things get more complicated for timing.

If you have all hardware parts fully documented, there's no problem but if you need to reverse engineer or guess how the emulated machine works... you will have a hard time.

Start here: http://infocenter.arm.com/help/index.jsp and download the "Technical Reference Manual" for your processor.

And for general emulation questions: http://www.google.es/search?q=how+to+write+an+emulator

葬心 2024-08-12 12:01:49

您应该查看 QEMU
但是我不明白,为什么需要一个完整的模拟器?

您已经可以在没有模拟器的情况下进行大量分析。您期望通过系统模拟器获得什么收益?

You should give a look at QEMU.
I don't understand however, why do you need a complete emulator ?

You can already a lot of profiling without emulator. What are the gains you expect from having a system emulator ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文