diff options
-rw-r--r-- | qtmips_gui/coreview.cpp | 27 | ||||
-rw-r--r-- | qtmips_gui/coreview/value.cpp | 9 | ||||
-rw-r--r-- | qtmips_gui/coreview/value.h | 8 | ||||
-rw-r--r-- | qtmips_machine/core.cpp | 7 | ||||
-rw-r--r-- | qtmips_machine/core.h | 5 |
5 files changed, 41 insertions, 15 deletions
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp index 061a3ec..b45f7ca 100644 --- a/qtmips_gui/coreview.cpp +++ b/qtmips_gui/coreview.cpp @@ -190,7 +190,7 @@ CoreViewScene::CoreViewScene(machine::QtMipsMachine *machine) : QGraphicsScene() NEW_V(200, 200, decode_instruction_value); // Instruction NEW_V(360, 250, decode_reg1_value); // Register output 1 NEW_V(360, 270, decode_reg2_value); // Register output 2 - NEW_V(335, 415, decode_immediate_value); // Sign extended immediate value + NEW_V(335, 413, decode_immediate_value); // Sign extended immediate value NEW_V(370, 99, decode_regd31_value, false, 1); NEW_V(370, 113, decode_memtoreg_value, false, 1); NEW_V(360, 120, decode_memwrite_value, false, 1); @@ -219,15 +219,20 @@ CoreViewScene::CoreViewScene(machine::QtMipsMachine *machine) : QGraphicsScene() NEW_V(710, 330, writeback_value, true); // Write back value new_label("RsD", 215, 241); - NEW_V(205, 250, decode_rs_num_value, false, 2, 0, 10); + NEW_V(205, 250, decode_rs_num_value, false, 2, 0, 10, ' '); new_label("RtD", 215, 261); - NEW_V(205, 270, decode_rt_num_value, false, 2, 0, 10); + NEW_V(205, 270, decode_rt_num_value, false, 2, 0, 10, ' '); new_label("RtD", 297, 372); - NEW_V(320, 380, decode_rt_num_value, false, 2, 0, 10); + NEW_V(320, 380, decode_rt_num_value, false, 2, 0, 10, ' '); new_label("RdD", 297, 380); - NEW_V(320, 390, decode_rd_num_value, false, 2, 0, 10); - NEW_V(320, 500, writeback_regw_num_value, false, 2, 0, 10); + NEW_V(320, 390, decode_rd_num_value, false, 2, 0, 10, ' '); + NEW_V(320, 500, writeback_regw_num_value, false, 2, 0, 10, ' '); + + new_label("Cycles", 440, SC_HEIGHT - 14); + NEW_V(500, SC_HEIGHT - 9, cycle_c_value, false, 10, 0, 10, ' ', false); + new_label("Stalls", 570, SC_HEIGHT - 14); + NEW_V(630, SC_HEIGHT - 9, stall_c_value, false, 10, 0, 10, ' ', false); connect(regs, SIGNAL(open_registers()), this, SIGNAL(request_registers())); connect(mem_program, SIGNAL(open_mem()), this, SIGNAL(request_program_memory())); @@ -491,11 +496,11 @@ CoreViewScenePipelined::CoreViewScenePipelined(machine::QtMipsMachine *machine) NEW_V(560, 105, memory_regw_value, false, 1); new_label("RtE", 427, 372); - NEW_V(450, 380, execute_rt_num_value, false, 2, 0, 10); + NEW_V(450, 380, execute_rt_num_value, false, 2, 0, 10, ' '); new_label("RdE", 427, 380); - NEW_V(450, 390, execute_rd_num_value, false, 2, 0, 10); - NEW_V(510, 385, execute_regw_num_value, false, 2, 0, 10); - NEW_V(610, 385, memory_regw_num_value, false, 2, 0, 10); + NEW_V(450, 390, execute_rd_num_value, false, 2, 0, 10, ' '); + NEW_V(510, 385, execute_regw_num_value, false, 2, 0, 10, ' '); + NEW_V(610, 385, memory_regw_num_value, false, 2, 0, 10, ' '); if (machine->config().hazard_unit() == machine::MachineConfig::HU_STALL_FORWARD) { NEW_MUX(hu.mux_alu_reg_a, 430, 232, execute_reg1_ff_value, 3, false); @@ -532,7 +537,7 @@ CoreViewScenePipelined::CoreViewScenePipelined(machine::QtMipsMachine *machine) struct coreview::Latch::ConnectorPair regdest_dc_rs = latch_id_ex->new_connector(ex.mux_regdest->connector_in(0)->point().y() - latch_id_ex->y() - 8); new_bus(dc.instr_bus->new_connector(0, ex.mux_regdest->connector_in(0)->y() - 8), regdest_dc_rs.in, 2); new_label("RsE", 427, 364); - NEW_V(450, 370, execute_rs_num_value, false, 2, 0, 10); + NEW_V(450, 370, execute_rs_num_value, false, 2, 0, 10, ' '); NEW(Junction, ex.j_rs_num, 442, 372); new_bus(regdest_dc_rs.out, ex.j_rs_num->new_connector(coreview::Connector::AX_X), 2); diff --git a/qtmips_gui/coreview/value.cpp b/qtmips_gui/coreview/value.cpp index 1250fb1..9dbe2e0 100644 --- a/qtmips_gui/coreview/value.cpp +++ b/qtmips_gui/coreview/value.cpp @@ -43,11 +43,13 @@ using namespace coreview; // TODO orientation Value::Value(bool vertical, unsigned width, std::uint32_t init_val, - unsigned a_base) : QGraphicsObject(nullptr) { + unsigned a_base, QChar fillchr, bool frame) : QGraphicsObject(nullptr) { wid = width; val = init_val; base = a_base; this->vertical = vertical; + this->fillchr = fillchr; + this->frame = frame; } QRectF Value::boundingRect() const { @@ -69,9 +71,12 @@ void Value::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __at rect = QRectF(-(LETWIDTH*(int)wid)/2 - 0.5, -HEIGHT/2 - 0.5, LETWIDTH*wid + 1, HEIGHT + 1); painter->setBrush(QBrush(QColor(Qt::white))); painter->setBackgroundMode(Qt::OpaqueMode); + if (!frame) + painter->setPen(QColor(Qt::white)); painter->drawRect(rect); + painter->setPen(QColor(Qt::black)); painter->setBackgroundMode(Qt::TransparentMode); - QString str = QString("%1").arg(val, wid, base, QChar('0')); + QString str = QString("%1").arg(val, wid, base, fillchr); if (vertical) { rect.setHeight(HEIGHT + 1); for (unsigned i = 0; i < wid; i++) { diff --git a/qtmips_gui/coreview/value.h b/qtmips_gui/coreview/value.h index 755a9b2..a8c1e76 100644 --- a/qtmips_gui/coreview/value.h +++ b/qtmips_gui/coreview/value.h @@ -38,14 +38,16 @@ #include <QGraphicsObject> #include <QPainter> +#include <QChar> namespace coreview { class Value : public QGraphicsObject { Q_OBJECT public: - Value(bool vertical = false, unsigned width = 8, - unsigned init_val = 0, unsigned base = 16); // width is for number of character to be shown from number + Value(bool vertical = false, unsigned width = 8, // width is for number of character to be shown from number + unsigned init_val = 0, unsigned base = 16, + QChar fillchr = '0', bool frame = true); QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); @@ -60,6 +62,8 @@ private: unsigned wid; unsigned base; bool vertical; + QChar fillchr; + bool frame; }; } diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp index 9e285a4..88b2fe2 100644 --- a/qtmips_machine/core.cpp +++ b/qtmips_machine/core.cpp @@ -43,6 +43,7 @@ Core::Core(Registers *regs, MemoryAccess *mem_program, MemoryAccess *mem_data, unsigned int min_cache_row_size, Cop0State *cop0state) : ex_handlers(), hw_breaks() { cycle_c = 0; + stall_c = 0; this->regs = regs; this->cop0state = cop0state; this->mem_program = mem_program; @@ -61,11 +62,13 @@ Core::Core(Registers *regs, MemoryAccess *mem_program, MemoryAccess *mem_data, void Core::step(bool skip_break) { cycle_c++; + emit cycle_c_value(cycle_c); do_step(skip_break); } void Core::reset() { cycle_c = 0; + stall_c = 0; do_reset(); } @@ -903,6 +906,10 @@ void CorePipelined::do_step(bool skip_break) { } // emit instruction_decoded(dt_d.inst, dt_d.inst_addr, dt_d.excause, dt_d.is_valid); } + if (stall || dt_d.stop_if) { + stall_c++; + emit stall_c_value(stall_c); + } } void CorePipelined::do_reset() { diff --git a/qtmips_machine/core.h b/qtmips_machine/core.h index 8672850..ff589c5 100644 --- a/qtmips_machine/core.h +++ b/qtmips_machine/core.h @@ -165,6 +165,9 @@ signals: void hu_stall_value(std::uint32_t); void branch_forward_value(std::uint32_t); + void cycle_c_value(std::uint32_t); + void stall_c_value(std::uint32_t); + void stop_on_exception_reached(); protected: @@ -273,6 +276,8 @@ protected: void dtExecuteInit(struct dtExecute &dt); void dtMemoryInit(struct dtMemory &dt); +protected: + unsigned int stall_c; private: struct hwBreak{ hwBreak(std::uint32_t addr); |