Commit df54f928 authored by Alexander Shabarshin's avatar Alexander Shabarshin

DEBUG print modifications

parent b958c728
......@@ -84,6 +84,9 @@ original copyright:
#if 0
#define DEBUG_OUTPUT
#endif
#if 0
#define DEBUG_EXTRA
#endif
/* added by Shaos: */
#define FALSE (0)
......@@ -429,11 +432,9 @@ int csr_read(uint32_t *pval, uint32_t csr,
int csr_write(uint32_t csr, uint32_t val)
{
uint32_t mask;
#if defined(DUMP_CSR)
printf("csr_write: csr=0x%03x val=0x", csr);
print_uint32_t(val);
printf("\n");
#ifdef DEBUG_EXTRA
printf("csr_write: csr=0x%03x val=0x%08x", csr, val);
/* print_uint32_t(val); */
#endif
switch(csr) {
case 0x100: /* sstatus */
......@@ -834,8 +835,10 @@ static uint32_t mulhu32(uint32_t a, uint32_t b)
return ((int64_t)a * (int64_t)b) >> 32;
}
#ifdef DEBUG_EXTRA
/* dumps all registers, useful for in-depth debugging */
#if 0
static void dump_regs()
{
printf("x0 zero: %08x\n", reg[0]);
......@@ -871,6 +874,7 @@ static void dump_regs()
printf("x30 t5: %08x\n", reg[30]);
printf("x31 t6: %08x\n", reg[31]);
}
#endif
void execute_instruction()
......@@ -1422,11 +1426,12 @@ void riscv_cpu_interp_x32()
{
/* we use a single execution loop to keep a simple control flow for emscripten */
while (machine_running) {
#if 1
/* update timer, assuming 10 MHz clock (100 ns period) for the mtime counter */
mtime = get_clock() / 100ll;
/* for reproducible debug runs, you can use a fixed fixed increment per instruction */
#if 0
#else
mtime += 10;
#endif
/* default value for next PC is next instruction, can be changed by branches or exceptions */
......@@ -1444,7 +1449,7 @@ void riscv_cpu_interp_x32()
insn_counter++;
#ifdef DEBUG_OUTPUT
printf("%08x, mtime: %08x, mtimecmp: %08x\n", pc, mtime, mtimecmp);
printf("[%08x]=%08x, mtime: %lx, mtimecmp: %lx\n", pc, insn, mtime, mtimecmp);
#endif
execute_instruction();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment