提交 0381ae5a 编写于 作者: Z Zihao Yu

noop,IFU: change reset vector to 0x80000000

* also put mainargs at 0x80001000 to match AM
上级 54453403
......@@ -66,7 +66,7 @@ $(EMU): $(EMU_MK) $(EMU_DEPS) $(EMU_HEADERS) $(REF_SO)
CPPFLAGS=-DREF_SO=\\\"$(REF_SO)\\\" $(MAKE) -C $(dir $(EMU_MK)) -f $(abspath $(EMU_MK))
ifdef mainargs
MAINARGS = -a $(mainargs)
MAINARGS = -m $(mainargs)
endif
emu: $(EMU)
......
......@@ -8,7 +8,7 @@ import utils._
import bus.simplebus._
trait HasResetVector {
val resetVector = 0x80100000L//TODO: set reset vec
val resetVector = 0x80000000L//TODO: set reset vec
}
class IFU extends NOOPModule with HasResetVector {
......
......@@ -34,7 +34,7 @@ void difftest_skip_dut() {
is_skip_dut = true;
}
void init_difftest(uint64_t *reg, const char *mainargs) {
void init_difftest(uint64_t *reg) {
void *handle;
handle = dlopen(REF_SO, RTLD_LAZY | RTLD_DEEPBIND);
assert(handle);
......@@ -63,14 +63,13 @@ void init_difftest(uint64_t *reg, const char *mainargs) {
ref_difftest_init();
void* get_img_start();
long get_img_size();
ref_difftest_memcpy_from_dut(0x100000, get_img_start(), get_img_size());
ref_difftest_memcpy_from_dut(0x0, (void *)mainargs, strlen(mainargs) + 1);
ref_difftest_memcpy_from_dut(0x0, get_img_start(), get_img_size());
ref_difftest_setregs(reg);
}
int difftest_step(uint64_t *reg_scala, uint64_t this_pc, int isMMIO, uint64_t intrNO) {
uint64_t ref_r[33];
static uint64_t nemu_pc = 0x80100000;
static uint64_t nemu_pc = 0x80000000;
if (isMMIO) {
// printf("diff pc: %x\n", this_pc);
// MMIO accessing should not be a branch or jump, just +4 to get the next pc
......
......@@ -9,7 +9,6 @@
#include "common.h"
#include "VNOOPSimTop.h"
class Emulator {
const char *image;
const char *mainargs;
......@@ -37,7 +36,7 @@ class Emulator {
// argv decay to the secondary pointer
Emulator(int argc, const char *argv[]):
image(nullptr),
mainargs(""),
mainargs(NULL),
dut_ptr(new std::remove_reference<decltype(*dut_ptr)>::type),
seed(0), max_cycles(-1), cycles(0)
{
......@@ -60,11 +59,11 @@ class Emulator {
// init core
reset_ncycles(10);
extern void init_difftest(uint64_t *reg, const char *mainargs);
extern void init_difftest(uint64_t *reg);
uint64_t reg[33];
read_emu_regs(reg);
reg[32] = 0x80100000;
init_difftest(reg, mainargs);
reg[32] = 0x80000000;
init_difftest(reg);
}
void reset_ncycles(size_t cycles) {
......
......@@ -20,8 +20,9 @@ const struct option Emulator::long_options[] = {
{ "seed", 1, NULL, 's' },
{ "max-cycles", 1, NULL, 'C' },
{ "image", 1, NULL, 'i' },
{ "mainargs", 1, NULL, 'a' },
{ "help", 0, NULL, 'h' }
{ "mainargs", 1, NULL, 'm' },
{ "help", 0, NULL, 'h' },
{ 0, 0, NULL, 0 }
};
void Emulator::print_help(const char *file) {
......@@ -30,15 +31,15 @@ void Emulator::print_help(const char *file) {
printf(" -s, --seed=NUM use this seed\n");
printf(" -C, --max-cycles=NUM execute at most NUM cycles\n");
printf(" -i, --image=FILE run with this image file\n");
printf(" -m, --mainargs=ARGS run with this mainargs (AM only)\n");
printf(" -h, --help print program help info\n");
printf("\n");
printf("Report bugs to 141242068@smail.nju.edu.cn.\n");
}
std::vector<const char *> Emulator::parse_args(int argc, const char *argv[]) {
std::vector<const char *> args = { argv[0] };
int o;
while ( (o = getopt_long(argc, const_cast<char *const*>(argv), "-s:C:hi:a:", long_options, NULL)) != -1) {
while ( (o = getopt_long(argc, const_cast<char *const*>(argv), "-s:C:hi:m:", long_options, NULL)) != -1) {
switch (o) {
case 's':
if(std::string(optarg) != "NO_SEED")
......@@ -49,8 +50,8 @@ std::vector<const char *> Emulator::parse_args(int argc, const char *argv[]) {
args.push_back("-i");
args.push_back(optarg);
break;
case 'a': mainargs = optarg;
args.push_back("-a");
case 'm': mainargs = optarg;
args.push_back("-m");
args.push_back(optarg);
break;
default:
......
#include "common.h"
#define RAMSIZE (128 * 1024 * 1024)
#define MAINARGS_START 0x1000
static uint64_t ram[RAMSIZE / sizeof(uint64_t)];
static long img_size = 0;
void* get_img_start() { return &ram[0x100000 / sizeof(uint64_t)]; }
void* get_img_start() { return &ram[0]; }
long get_img_size() { return img_size; }
void init_ram(const char *img, const char *mainargs) {
......@@ -21,11 +22,13 @@ void init_ram(const char *img, const char *mainargs) {
img_size = ftell(fp);
fseek(fp, 0, SEEK_SET);
int ret = fread(get_img_start(), img_size, 1, fp);
int ret = fread(ram, img_size, 1, fp);
assert(ret == 1);
fclose(fp);
strcpy((char *)ram, mainargs);
if (mainargs != NULL) {
strcpy((char *)ram + MAINARGS_START, mainargs);
}
}
extern "C" void ram_helper(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册