From 981b84a5ebc4ab4f7a7da38182d486044a9c062e Mon Sep 17 00:00:00 2001 From: mariusmonton Date: Thu, 20 Sep 2018 15:29:22 +0200 Subject: [PATCH] Better register dump --- inc/Registers.h | 1 + src/Registers.cpp | 66 +++++++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/inc/Registers.h b/inc/Registers.h index 1a98349..4467108 100644 --- a/inc/Registers.h +++ b/inc/Registers.h @@ -8,6 +8,7 @@ #define REGISTERS_H #define SC_INCLUDE_DYNAMIC_PROCESSES +#include #include "systemc" #include "tlm.h" diff --git a/src/Registers.cpp b/src/Registers.cpp index 0d53835..90d6f5b 100644 --- a/src/Registers.cpp +++ b/src/Registers.cpp @@ -10,45 +10,49 @@ Registers::Registers() { } void Registers::dump(void) { - cout << "************************************" << endl; cout << "Registers dump" << dec << endl; -#if 0 - cout << "x0 (zero): " << register_bank[0] << "\t"; - cout << "x1 (ra): " << register_bank[1] << "\t"; - cout << "x2 (sp): " << register_bank[2] << "\t"; - cout << "x3 (gp): " << register_bank[3] << "\t" << endl; + cout << "x0 (zero): " << left << setw(8) << register_bank[0]; + cout << "x1 (ra): " << left << setw(8) << register_bank[1]; + cout << "x2 (sp): " << left << setw(8) << register_bank[2]; + cout << "x3 (gp): " << left << setw(8) << register_bank[3] << endl; - cout << "x4 (tp): " << register_bank[4] << "\t"; - cout << "x5 (t0): " << register_bank[5] << "\t"; - cout << "x6 (t1): " << register_bank[6] << "\t"; - cout << "x7 (t2): " << register_bank[7] << "\t" << endl; + cout << "x4 (tp): " << left << setw(8) << register_bank[4]; + cout << "x5 (t0): " << left << setw(8) << register_bank[5]; + cout << "x6 (t1): " << left << setw(8) << register_bank[6]; + cout << "x7 (t2): " << left << setw(8) << register_bank[7] << endl; - cout << "x8 (s0/fp): " << register_bank[8] << "\t"; - cout << "x9 (s1): " << register_bank[9] << "\t"; - cout << "x10 (a0): " << register_bank[10] << "\t"; - cout << "x11 (a1): " << register_bank[11] << "\t" << endl; + cout << "x8 (s0/fp): " << left << setw(8) << register_bank[8]; + cout << "x9 (s1): " << left << setw(8) << register_bank[9]; + cout << "x10 (a0): " << left << setw(8) << register_bank[10]; + cout << "x11 (a1): " << left << setw(8) << register_bank[11] << endl; - cout << "x12 (a2): " << register_bank[12] << "\t"; - cout << "x13 (a3): " << register_bank[13] << "\t"; - cout << "x14 (a4): " << register_bank[14] << "\t"; - cout << "x15 (a5): " << register_bank[15] << "\t" << endl; + cout << "x12 (a2): " << left << setw(8) << register_bank[12]; + cout << "x13 (a3): " << left << setw(8) << register_bank[13]; + cout << "x14 (a4): " << left << setw(8) << register_bank[14]; + cout << "x15 (a5): " << left << setw(8) << register_bank[15] << endl; - cout << "x16 (a6): " << register_bank[16] << "\t"; - cout << "x17 (a7): " << register_bank[17] << "\t"; - cout << "x18 (s2): " << register_bank[18] << "\t"; - cout << "x19 (s3): " << register_bank[19] << "\t" << endl; + cout << "x16 (a6): " << left << setw(8) << register_bank[16]; + cout << "x17 (a7): " << left << setw(8) << register_bank[17]; + cout << "x18 (s2): " << left << setw(8) << register_bank[18]; + cout << "x19 (s3): " << left << setw(8) << register_bank[19] << endl; -#else - for(int i=0;i<32;i++) { - cout << "R" << dec << i << ": " << register_bank[i] << "\t"; - if (i % 4 == 3) { - cout << endl; - } - } -#endif + cout << "x20 (s4): " << left << setw(8) << register_bank[16]; + cout << "x21 (s5): " << left << setw(8) << register_bank[17]; + cout << "x22 (s6): " << left << setw(8) << register_bank[18]; + cout << "x23 (s7): " << left << setw(8) << register_bank[19] << endl; - cout << "PC: 0x" << hex << register_PC << endl; + cout << "x24 (s8): " << left << setw(8) << register_bank[16]; + cout << "x25 (s9): " << left << setw(8) << register_bank[17]; + cout << "x26 (s10): " << left << setw(8) << register_bank[18]; + cout << "x27 (s11): " << left << setw(8) << register_bank[19] << endl; + + cout << "x28 (t3): " << left << setw(8) << register_bank[16]; + cout << "x29 (t4): " << left << setw(8) << register_bank[17]; + cout << "x30 (t5): " << left << setw(8) << register_bank[18]; + cout << "x31 (t6): " << left << setw(8) << register_bank[19] << endl; + + cout << "PC: 0x" << hex << left << setw(8) << register_PC << endl; cout << "************************************" << endl; }