[Add] software simulator add

This commit is contained in:
bLueriVerLHR
2023-05-11 17:55:41 +08:00
parent 4e39007d17
commit 0bf1c68d94
16 changed files with 535 additions and 10 deletions

View File

@@ -1,11 +1,38 @@
#include <sysbus.hh>
#include <iostream>
int main() {
fetch();
#ifdef DEBUG_MODE
std::cout << "Hello" << std::endl;
#endif
#include <sysbus.hh>
#include <memory.hh>
#include <serial.hh>
#include <la32r.hh>
#include <common.h>
#include <devaddr.h>
int main(int argc, char *argv[]) {
if (argc < 2) {
std::cout << "Usage: sim <bin>";
return 0;
}
SystemBus bus;
Memory ram(2 * 1024 * 1024);
Memory stk(256 * 1024);
Memory flash(1024 * 1024);
flash.load(argv[1]);
ram.load(&flash, IMG_ADDR, flash.size());
bus.regdev(&ram, RAM_ADDR);
bus.regdev(&stk, STK_ADDR);
Serial bios(1);
bus.regdev(&bios, SERIAL_PORT);
auto cpu = new LA32R(&bus);
while (true) {
cpu->Step(1);
}
delete cpu;
return 0;
}