From 2c94ea91b1c5a0d7c0ebb0ab229950f7c849909a Mon Sep 17 00:00:00 2001 From: bd Date: Thu, 17 Apr 2025 15:30:26 -0400 Subject: The pipeline says some things and there are numbers --- src/sim/id.cc | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src/sim/id.cc') diff --git a/src/sim/id.cc b/src/sim/id.cc index 37c6773..de412d4 100644 --- a/src/sim/id.cc +++ b/src/sim/id.cc @@ -86,7 +86,7 @@ void ID::get_instr_fields( break; case 0b10: t = J; - this->decode_J_type(s1, s2, s3); + this->decode_J_type(s1, s2, s3, m); break; case 0b11: t = INV; @@ -159,8 +159,10 @@ void ID::decode_I_type( this->status = r1; } -void ID::decode_J_type(signed int &s1, signed int &s2, signed int &s3) +void ID::decode_J_type( + signed int &s1, signed int &s2, signed int &s3, Mnemonic &m) { + Response r1, r2; unsigned int s0b, s1b; s0b = REG_SIZE; @@ -169,7 +171,35 @@ void ID::decode_J_type(signed int &s1, signed int &s2, signed int &s3) s2 = GET_BITS_SIGN_EXTEND(s1, s0b, s1b); s1 = GET_LS_BITS(s1, s0b); - this->status = this->read_guard(*&s1); + switch (m) { + case PUSH: + s2 = s1; // source + s3 = 2; // stack pointer + s1 = -1; // increment amount + r1 = this->read_guard(s2); + r2 = (this->is_checked_out(s3)) ? STALLED : OK; // we read the stack pointer + if (r1 == OK && r2 == OK) { + this->write_guard(s3); // we write the stack pointer + } + this->status = (r1 == OK && r2 == OK) ? OK : STALLED; + break; + case POP: + s2 = s1; // destination + s3 = 2; // stack pointer + s1 = 1; // increment amount + r1 = (this->is_checked_out(s3)) ? STALLED : OK; // we read the stack pointer + if (r1 == OK) { + this->write_guard(s2); + this->write_guard(s3); // we write the stack pointer + } + this->status = r1; + break; + default: + this->status = this->read_guard(*&s1); + } + + std::cout << m << ":" << this->status << std::endl; + } std::vector ID::stage_info() -- cgit v1.2.3 From f6f2f32b6dbd1b1e60052cb67f40864c3b5bd74b Mon Sep 17 00:00:00 2001 From: bd Date: Thu, 17 Apr 2025 16:28:36 -0400 Subject: Functioning PUSH/POP --- gui/worker.cc | 76 +++++++++++++++++++++++++++++++++++------------------------ src/sim/ex.cc | 2 -- src/sim/id.cc | 2 -- src/sim/wb.cc | 9 +++---- 4 files changed, 50 insertions(+), 39 deletions(-) (limited to 'src/sim/id.cc') diff --git a/gui/worker.cc b/gui/worker.cc index 061e0da..08503c9 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -21,41 +21,55 @@ void Worker::doWork() std::vector p; - p.push_back(0b00000000000000000010100010001101); - p.push_back(0b11111111111101010011000000001101); - p.push_back(0b00000000000000000000000110100010); - p.push_back(0b00000000000000000011000000001110); - p.push_back(0b00000000000000000000000110100110); - p.push_back(0b00000000001000100011000000101001); + p.push_back(0b00000000000000010010100000001101); p.push_back(0b00000000000000000000000101100010); - p.push_back(0b00000000000000000010100010001101); - p.push_back(0b00000000000001000001000010010001); - p.push_back(0b11111111111010010011000000001101); - p.push_back(0b11111111111111000011000101101001); - p.push_back(0b00000000000001000010100111000101); - p.push_back(0b11111111111111000010100110000101); - p.push_back(0b00000000000011000111001100000100); - p.push_back(0b00000000000000000000000110100010); - p.push_back(0b00000000000000001010100000001110); - p.push_back(0b00000000000000000000000110100110); - p.push_back(0b00000000000001000011000101101001); - p.push_back(0b00000000000000000001000101001101); - p.push_back(0b00000000000000000000000101100110); - p.push_back(0b00000000000000000000000000101010); + p.push_back(0b00000000000000010010100101001101); + p.push_back(0b00000000000000000000000101100010); + p.push_back(0b00000000000000010010100101001101); + p.push_back(0b00000000000000000000000101100010); + p.push_back(0b00000000000000010010100101001101); p.push_back(0b00000000000000000000000101100010); - p.push_back(0b00000000000000000010100010001101); - p.push_back(0b00000000000001000001000010010001); - p.push_back(0b00000000010011000011000000001101); - p.push_back(0b11111111111111000011000101101001); - p.push_back(0b00000000000001000010100111000101); - p.push_back(0b11111111111111000010100110000101); - p.push_back(0b00000000000011000111001100000100); - p.push_back(0b00000000000001000011000101101001); - p.push_back(0b00000000000000000001000101001101); p.push_back(0b00000000000000000000000101100110); - p.push_back(0b00000000000000000000000000101010); + p.push_back(0b00000000000000000000000110100110); + p.push_back(0b00000000000000000000000111100110); + p.push_back(0b00000000000000000000001000100110); p.push_back(0b00000000000000000000000000010000); - p.push_back(0b00000000000000000000000000000000); + + // p.push_back(0b00000000000000000010100010001101); + // p.push_back(0b11111111111101010011000000001101); + // p.push_back(0b00000000000000000000000110100010); + // p.push_back(0b00000000000000000011000000001110); + // p.push_back(0b00000000000000000000000110100110); + // p.push_back(0b00000000001000100011000000101001); + // p.push_back(0b00000000000000000000000101100010); + // p.push_back(0b00000000000000000010100010001101); + // p.push_back(0b00000000000000010001000010010001); + // p.push_back(0b11111111111010010011000000001101); + // p.push_back(0b11111111111111000011000101101001); + // p.push_back(0b00000000000001000010100111000101); + // p.push_back(0b11111111111111000010100110000101); + // p.push_back(0b00000000000011000111001100000100); + // p.push_back(0b00000000000000000000000110100010); + // p.push_back(0b00000000000000001010100000001110); + // p.push_back(0b00000000000000000000000110100110); + // p.push_back(0b00000000000001000011000101101001); + // p.push_back(0b00000000000000000001000101001101); + // p.push_back(0b00000000000000000000000101100110); + // p.push_back(0b00000000000000000000000000101010); + // p.push_back(0b00000000000000000000000101100010); + // p.push_back(0b00000000000000000010100010001101); + // p.push_back(0b00000000000000010001000010010001); + // p.push_back(0b00000000010011000011000000001101); + // p.push_back(0b11111111111111000011000101101001); + // p.push_back(0b00000000000001000010100111000101); + // p.push_back(0b11111111111111000010100110000101); + // p.push_back(0b00000000000011000111001100000100); + // p.push_back(0b00000000000001000011000101101001); + // p.push_back(0b00000000000000000001000101001101); + // p.push_back(0b00000000000000000000000101100110); + // p.push_back(0b00000000000000000000000000101010); + // p.push_back(0b00000000000000000000000000010000); + // p.push_back(0b00000000000000000000000000000000); this->d->load(p); } diff --git a/src/sim/ex.cc b/src/sim/ex.cc index c676781..a32105f 100644 --- a/src/sim/ex.cc +++ b/src/sim/ex.cc @@ -340,9 +340,7 @@ EX::EX(Stage *stage) : Stage(stage) INIT_INSTRUCTION( PUSH, { - std::cout << "adding " << s1 << " and " << s3; s1 = s1 + s3; - std::cout << " for " << s1 << std::endl; (void)pc; (void)s2; (void)this; diff --git a/src/sim/id.cc b/src/sim/id.cc index de412d4..d10d695 100644 --- a/src/sim/id.cc +++ b/src/sim/id.cc @@ -198,8 +198,6 @@ void ID::decode_J_type( this->status = this->read_guard(*&s1); } - std::cout << m << ":" << this->status << std::endl; - } std::vector ID::stage_info() diff --git a/src/sim/wb.cc b/src/sim/wb.cc index 08e5ed3..c62468c 100644 --- a/src/sim/wb.cc +++ b/src/sim/wb.cc @@ -28,16 +28,17 @@ void WB::write_handler() throw std::runtime_error("instruction tried to pop a register out of " "an empty queue during writeback."); - this->checked_out.pop_front(); - reg = this->curr_instr->get_checked_out(); - this->store_register(reg, this->curr_instr->get_s1()); - if (this->curr_instr->get_mnemonic() == POP) { // POP performs a second register write reg = this->checked_out.front(); this->checked_out.pop_front(); this->store_register(reg, this->curr_instr->get_s3()); } + + this->checked_out.pop_front(); + reg = this->curr_instr->get_checked_out(); + this->store_register(reg, this->curr_instr->get_s1()); + } void WB::jump_handler() -- cgit v1.2.3