From da25748edb6997629ffb380683c8c736f24033a8 Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 19 Apr 2025 02:23:03 -0400 Subject: Add custom QWidget to keep track of up to 4 user cache ways --- gui/dynamicwaysentry.cc | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 gui/dynamicwaysentry.cc (limited to 'gui/dynamicwaysentry.cc') diff --git a/gui/dynamicwaysentry.cc b/gui/dynamicwaysentry.cc new file mode 100644 index 0000000..f35c9ef --- /dev/null +++ b/gui/dynamicwaysentry.cc @@ -0,0 +1,80 @@ +#include "dynamicwaysentry.h" +#include +#include +#include +#include +#include +#include + +DynamicWaysEntry::DynamicWaysEntry(QWidget *parent) : QWidget(parent) +{ + this->l = new QVBoxLayout(this); + this->l->setAlignment(Qt::AlignTop); + this->l->setSpacing(6); + this->l->setContentsMargins(0, 0, 0, 0); + this->setLayout(l); + this->add_field(); +} + +QStringList DynamicWaysEntry::get_entries() const { return this->entries; } + +int DynamicWaysEntry::parse_valid_way(QString t) +{ + bool s; + int i; + i = t.toInt(&s); + return (s && i >= 0 && 5 > i) ? i : -1; +} + +void DynamicWaysEntry::on_number_enter(const QString &t) +{ + int i; + QLineEdit *sender_field; + + sender_field = qobject_cast(sender()); + i = fields.indexOf(sender_field); + entries[i] = t; + + if (i == this->fields.size() - 1 && !t.isEmpty() && + (this->parse_valid_way(t) > 0) && fields.size() < 4) + add_field(); + + // TODO, unlink, don't trash everything after + if (t.isEmpty()) { + while (this->fields.size() > i + 1) { + remove_last_field(); + } + while (entries.size() > fields.size()) { + entries.removeLast(); + } + } +} + +void DynamicWaysEntry::add_field() +{ + QLineEdit *f; + + f = new QLineEdit(this); + f->setPlaceholderText("# ways (a power of 2)"); + + this->l->addWidget(f);; + this->fields.append(f); + this->entries.append(QString()); + connect( + f, &QLineEdit::textChanged, this, &DynamicWaysEntry::on_number_enter); +} + +void DynamicWaysEntry::remove_last_field() +{ + QLineEdit *f; + + if (this->fields.isEmpty()) + return; + + f = this->fields.takeLast(); + this->l->removeWidget(f); + f->deleteLater(); + + if (!this->entries.isEmpty()) + entries.removeLast(); +} -- cgit v1.2.3 From 24de6faf71c85e0281b32fb899fcbe4fe82380c4 Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 19 Apr 2025 04:16:00 -0400 Subject: Reinstate rest of worker.cc functions such that programs work again --- gui/dynamicwaysentry.cc | 2 ++ gui/worker.cc | 34 +++++++++++++++++----------------- gui/worker.h | 7 ++++--- 3 files changed, 23 insertions(+), 20 deletions(-) (limited to 'gui/dynamicwaysentry.cc') diff --git a/gui/dynamicwaysentry.cc b/gui/dynamicwaysentry.cc index f35c9ef..4e2cd66 100644 --- a/gui/dynamicwaysentry.cc +++ b/gui/dynamicwaysentry.cc @@ -26,6 +26,8 @@ int DynamicWaysEntry::parse_valid_way(QString t) return (s && i >= 0 && 5 > i) ? i : -1; } +// TODO if you enter something valid and then make it invalid, +// the next box still shows void DynamicWaysEntry::on_number_enter(const QString &t) { int i; diff --git a/gui/worker.cc b/gui/worker.cc index 6ec564e..cd79821 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -16,13 +16,14 @@ void Worker::configure( std::vector program, bool is_pipelined) { - unsigned int size_inc; Dram *d; Storage *s; int i; - if (ways.size() != 0) - size_inc = MEM_LINE_SPEC / ways.size(); + if (ways.size() != 0) { + // will ensure the largest cache is only half of DRAM + this->size_inc = (MEM_LINE_SPEC / ways.size()) / 2; + } d = new Dram(DRAM_DELAY); s = (Storage *)d; @@ -31,7 +32,7 @@ void Worker::configure( for (i = ways.size(); i > 0; --i) { s = (Storage *)new Cache( - s, size_inc * (i), ways.at(i - 1), CACHE_DELAY + i); + s, this->size_inc * (i), ways.at(i - 1), CACHE_DELAY + i); this->s.push_front(s); } @@ -49,16 +50,15 @@ void Worker::configure( void Worker::refreshDram() { qDebug() << "Refreshing Dram"; - // emit dram_storage(this->d->view(0, 255)); + emit dram_storage(this->s.back()->view(0, 255)); } void Worker::refreshCache() { qDebug() << "Refreshing Cache"; - // if(getWays().size() > 0) { - // unsigned int size = this->c.at(getWays().size()-1)->get_size(); - // emit cache_storage(this->c.at(getWays().size()-1)->view(0, 1<s.size() > 0) { + emit cache_storage(this->s.at(0)->view(0, 1 << this->size_inc)); + } } void Worker::refreshRegisters() @@ -71,12 +71,12 @@ void Worker::runSteps(int steps) { qDebug() << "Running for " << steps << "steps"; this->ct->run_for(steps); - // emit dram_storage(this->d->view(0, 255)); - // emit register_storage(this->ct->get_gprs()); - // emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc()); - // emit if_info(this->if_stage->stage_info()); - // emit id_info(this->id_stage->stage_info()); - // emit ex_info(this->ex_stage->stage_info()); - // emit mm_info(this->mm_stage->stage_info()); - // emit wb_info(this->wb_stage->stage_info()); + emit dram_storage(this->s.back()->view(0, 255)); + emit register_storage(this->ct->get_gprs()); + emit clock_cycles(this->ct->get_clock_cycle(), this->ct->get_pc()); + emit if_info(this->if_stage->stage_info()); + emit id_info(this->id_stage->stage_info()); + emit ex_info(this->ex_stage->stage_info()); + emit mm_info(this->mm_stage->stage_info()); + emit wb_info(this->wb_stage->stage_info()); } diff --git a/gui/worker.h b/gui/worker.h index b6332b0..acfffcf 100644 --- a/gui/worker.h +++ b/gui/worker.h @@ -23,15 +23,16 @@ class Worker : public QObject * The storage objects, stored smallest to largest. */ std::deque s; - /** - * The stage objects, starting with fetch. - */ IF *if_stage; ID *id_stage; EX *ex_stage; MM *mm_stage; WB *wb_stage; Controller *ct; + /** + * The size each progressive cache level increases by. + */ + unsigned int size_inc; public: explicit Worker(QObject *parent = nullptr); -- cgit v1.2.3 From dbf5d3986e5fe271b072cd3d32e73e4fa26a5fae Mon Sep 17 00:00:00 2001 From: bd Date: Mon, 21 Apr 2025 11:59:32 -0400 Subject: Add licensing to new files --- gui/digitlabel.cc | 17 +++++++++++++++++ gui/digitlabel.h | 17 +++++++++++++++++ gui/dynamicwaysentry.cc | 17 +++++++++++++++++ gui/dynamicwaysentry.h | 17 +++++++++++++++++ 4 files changed, 68 insertions(+) (limited to 'gui/dynamicwaysentry.cc') diff --git a/gui/digitlabel.cc b/gui/digitlabel.cc index a5c84f1..ffecfff 100644 --- a/gui/digitlabel.cc +++ b/gui/digitlabel.cc @@ -1,3 +1,20 @@ +// Simulator for the RISC-V[ECTOR] mini-ISA +// Copyright (C) 2025 Siddarth Suresh +// Copyright (C) 2025 bdunahu + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + #include "digitlabel.h" DigitLabel::DigitLabel(QWidget *parent) : QLabel(parent) diff --git a/gui/digitlabel.h b/gui/digitlabel.h index 9106cc9..2916426 100644 --- a/gui/digitlabel.h +++ b/gui/digitlabel.h @@ -1,3 +1,20 @@ +// Simulator for the RISC-V[ECTOR] mini-ISA +// Copyright (C) 2025 Siddarth Suresh +// Copyright (C) 2025 bdunahu + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + #ifndef DIGITLABEL_H #define DIGITLABEL_H diff --git a/gui/dynamicwaysentry.cc b/gui/dynamicwaysentry.cc index 4e2cd66..e1f740e 100644 --- a/gui/dynamicwaysentry.cc +++ b/gui/dynamicwaysentry.cc @@ -1,3 +1,20 @@ +// Simulator for the RISC-V[ECTOR] mini-ISA +// Copyright (C) 2025 Siddarth Suresh +// Copyright (C) 2025 bdunahu + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + #include "dynamicwaysentry.h" #include #include diff --git a/gui/dynamicwaysentry.h b/gui/dynamicwaysentry.h index de001ee..26b8b3e 100644 --- a/gui/dynamicwaysentry.h +++ b/gui/dynamicwaysentry.h @@ -1,3 +1,20 @@ +// Simulator for the RISC-V[ECTOR] mini-ISA +// Copyright (C) 2025 Siddarth Suresh +// Copyright (C) 2025 bdunahu + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + #ifndef DYNAMICWAYSENTRY_H #define DYNAMICWAYSENTRY_H -- cgit v1.2.3