Commit df54f928 authored by Alexander Shabarshin's avatar Alexander Shabarshin

DEBUG print modifications

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