aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/CacheContent.ui22
-rw-r--r--qtmips_gui/CacheStatistics.ui10
-rw-r--r--qtmips_gui/MainWindow.ui99
-rw-r--r--qtmips_gui/NewDialog.ui344
-rw-r--r--qtmips_gui/cachecontent.cpp10
-rw-r--r--qtmips_gui/cachecontent.h17
-rw-r--r--qtmips_gui/cachestatistics.cpp8
-rw-r--r--qtmips_gui/cachestatistics.h15
-rw-r--r--qtmips_gui/coreview.cpp33
-rw-r--r--qtmips_gui/coreview.h43
-rw-r--r--qtmips_gui/icons.qrc16
-rw-r--r--qtmips_gui/icons/application-exit.pngbin2633 -> 2525 bytes
-rw-r--r--qtmips_gui/main.cpp15
-rw-r--r--qtmips_gui/mainwindow.cpp93
-rw-r--r--qtmips_gui/mainwindow.h44
-rw-r--r--qtmips_gui/newdialog.cpp153
-rw-r--r--qtmips_gui/newdialog.h33
-rw-r--r--qtmips_gui/qtmips_gui.pro23
-rw-r--r--qtmips_gui/registersdock.cpp10
-rw-r--r--qtmips_gui/registersdock.h18
-rw-r--r--qtmips_gui/registersdock.ui18
21 files changed, 885 insertions, 139 deletions
diff --git a/qtmips_gui/CacheContent.ui b/qtmips_gui/CacheContent.ui
index ac2f263..372dee1 100644
--- a/qtmips_gui/CacheContent.ui
+++ b/qtmips_gui/CacheContent.ui
@@ -1,7 +1,7 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>DockWidget</class>
- <widget class="QDockWidget" name="DockWidget">
+ <class>CacheContent</class>
+ <widget class="QDockWidget" name="CacheContent">
<property name="geometry">
<rect>
<x>0</x>
@@ -11,8 +11,20 @@
</rect>
</property>
<property name="windowTitle">
- <string>DockWidget</string>
+ <string>Cache content</string>
</property>
- <widget class="QWidget" name="dockWidgetContents"/>
+ <widget class="QWidget" name="dockWidgetContents">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>TODO</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
+ <resources/>
+ <connections/>
</ui>
diff --git a/qtmips_gui/CacheStatistics.ui b/qtmips_gui/CacheStatistics.ui
index ac2f263..5bb8b72 100644
--- a/qtmips_gui/CacheStatistics.ui
+++ b/qtmips_gui/CacheStatistics.ui
@@ -1,7 +1,7 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>DockWidget</class>
- <widget class="QDockWidget" name="DockWidget">
+ <class>CacheStatistics</class>
+ <widget class="QDockWidget" name="CacheStatistics">
<property name="geometry">
<rect>
<x>0</x>
@@ -11,8 +11,10 @@
</rect>
</property>
<property name="windowTitle">
- <string>DockWidget</string>
+ <string>Cache statistics</string>
</property>
<widget class="QWidget" name="dockWidgetContents"/>
</widget>
+ <resources/>
+ <connections/>
</ui>
diff --git a/qtmips_gui/MainWindow.ui b/qtmips_gui/MainWindow.ui
index 0f69613..56f5319 100644
--- a/qtmips_gui/MainWindow.ui
+++ b/qtmips_gui/MainWindow.ui
@@ -6,20 +6,47 @@
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
- <height>300</height>
+ <width>957</width>
+ <height>651</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
- <widget class="QWidget" name="centralWidget"/>
+ <property name="dockNestingEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="unifiedTitleAndToolBarOnMac">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QWidget" name="widget" native="true"/>
+ </item>
+ </layout>
+ </widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
+ <width>957</width>
<height>20</height>
</rect>
</property>
@@ -27,7 +54,8 @@
<property name="title">
<string>File</string>
</property>
- <addaction name="actionLoad_binary"/>
+ <addaction name="actionNew"/>
+ <addaction name="actionReload"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
@@ -85,16 +113,39 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
+ <addaction name="actionNew"/>
+ <addaction name="actionReload"/>
+ <addaction name="separator"/>
+ <addaction name="actionRun"/>
+ <addaction name="actionPause"/>
+ <addaction name="actionStep"/>
</widget>
- <action name="actionLoad_binary">
+ <action name="actionNew">
+ <property name="icon">
+ <iconset resource="icons.qrc">
+ <normaloff>:/icons/document-import.png</normaloff>:/icons/document-import.png</iconset>
+ </property>
<property name="text">
- <string>Load binary...</string>
+ <string>New simulation...</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+O, Ctrl+N</string>
</property>
</action>
<action name="actionExit">
+ <property name="icon">
+ <iconset resource="icons.qrc">
+ <normaloff>:/icons/application-exit.png</normaloff>:/icons/application-exit.png</iconset>
+ </property>
<property name="text">
<string>Exit</string>
</property>
+ <property name="toolTip">
+ <string>Exit program</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Q</string>
+ </property>
</action>
<action name="actionRestart">
<property name="text">
@@ -102,19 +153,40 @@
</property>
</action>
<action name="actionRun">
+ <property name="icon">
+ <iconset resource="icons.qrc">
+ <normaloff>:/icons/play.png</normaloff>:/icons/play.png</iconset>
+ </property>
<property name="text">
<string>Run</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+R</string>
+ </property>
</action>
<action name="actionStep">
+ <property name="icon">
+ <iconset resource="icons.qrc">
+ <normaloff>:/icons/next.png</normaloff>:/icons/next.png</iconset>
+ </property>
<property name="text">
<string>Step</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+S</string>
+ </property>
</action>
<action name="actionPause">
+ <property name="icon">
+ <iconset resource="icons.qrc">
+ <normaloff>:/icons/pause.png</normaloff>:/icons/pause.png</iconset>
+ </property>
<property name="text">
<string>Pause</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+P</string>
+ </property>
</action>
<action name="action1_ips">
<property name="text">
@@ -184,8 +256,19 @@
<string>Assembler</string>
</property>
</action>
+ <action name="actionReload">
+ <property name="icon">
+ <iconset resource="icons.qrc">
+ <normaloff>:/icons/reload.png</normaloff>:/icons/reload.png</iconset>
+ </property>
+ <property name="text">
+ <string>Reload existing</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
- <resources/>
+ <resources>
+ <include location="icons.qrc"/>
+ </resources>
<connections/>
</ui>
diff --git a/qtmips_gui/NewDialog.ui b/qtmips_gui/NewDialog.ui
index 18d31ab..e39edbf 100644
--- a/qtmips_gui/NewDialog.ui
+++ b/qtmips_gui/NewDialog.ui
@@ -1,71 +1,299 @@
-<ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
- <class>Dialog</class>
- <widget class="QDialog" name="Dialog" >
- <property name="geometry" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NewDialog</class>
+ <widget class="QDialog" name="NewDialog">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
- <height>300</height>
+ <width>558</width>
+ <height>306</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>Dialog</string>
</property>
- <widget class="QDialogButtonBox" name="buttonBox" >
- <property name="geometry" >
- <rect>
- <x>30</x>
- <y>240</y>
- <width>341</width>
- <height>32</height>
- </rect>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="leftMargin">
+ <number>0</number>
</property>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
+ <property name="topMargin">
+ <number>0</number>
</property>
- <property name="standardButtons" >
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ <property name="rightMargin">
+ <number>0</number>
</property>
- </widget>
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>2</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Basic</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Preset</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_6">
+ <item>
+ <widget class="QRadioButton" name="preset_no_pipeline">
+ <property name="text">
+ <string>No pipeline no cache</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="preset_pipelined">
+ <property name="text">
+ <string>Pipelined and cache</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="preset_custom">
+ <property name="text">
+ <string>Custom</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="Line" name="line_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Elf executable: </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="elf_file"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton_browse">
+ <property name="text">
+ <string>Browse</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_core">
+ <attribute name="title">
+ <string>Core</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="pipelined">
+ <property name="text">
+ <string>Pipelined</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="hazard">
+ <property name="text">
+ <string>Hazard unit</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="flush_jump">
+ <property name="text">
+ <string>Flush pipeline on jump</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="prediction">
+ <property name="title">
+ <string>Jump prediction</string>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QRadioButton" name="prediction_static">
+ <property name="text">
+ <string>Static</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="prediction_one_dynamic">
+ <property name="text">
+ <string>One level dynamic</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_memory">
+ <attribute name="title">
+ <string>Memory</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="QCheckBox" name="mem_protec_write">
+ <property name="text">
+ <string>Program memory write protection</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="mem_protec_exec">
+ <property name="text">
+ <string>Data memory executable protection</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="cache">
+ <property name="title">
+ <string>Cache (for both program and data)</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_7">
+ <item>
+ <widget class="QRadioButton" name="cache_associative">
+ <property name="text">
+ <string>Associative</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <property name="leftMargin">
+ <number>9</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>9</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton_load">
+ <property name="text">
+ <string>Load machine</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton_cancel">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
</widget>
- <pixmapfunction></pixmapfunction>
<resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>Dialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>248</x>
- <y>254</y>
- </hint>
- <hint type="destinationlabel" >
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>Dialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>316</x>
- <y>260</y>
- </hint>
- <hint type="destinationlabel" >
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <connections/>
</ui>
diff --git a/qtmips_gui/cachecontent.cpp b/qtmips_gui/cachecontent.cpp
index c651b7b..1dd4693 100644
--- a/qtmips_gui/cachecontent.cpp
+++ b/qtmips_gui/cachecontent.cpp
@@ -1,6 +1,10 @@
-#include "cache_content.h"
+#include "cachecontent.h"
-cache_content::cache_content()
-{
+CacheContentDock::CacheContentDock(QWidget *parent) : QDockWidget(parent) {
+ ui = new Ui::CacheContent();
+ ui->setupUi(this);
+}
+CacheContentDock::~CacheContentDock() {
+ delete ui;
}
diff --git a/qtmips_gui/cachecontent.h b/qtmips_gui/cachecontent.h
index 09b8734..3b028b5 100644
--- a/qtmips_gui/cachecontent.h
+++ b/qtmips_gui/cachecontent.h
@@ -1,11 +1,16 @@
-#ifndef CACHE_CONTENT_H
-#define CACHE_CONTENT_H
+#ifndef CACHECONTENT_H
+#define CACHECONTENT_H
+#include <QDockWidget>
+#include "ui_CacheContent.h"
-class cache_content
-{
+class CacheContentDock : public QDockWidget {
public:
- cache_content();
+ CacheContentDock(QWidget *parent);
+ ~CacheContentDock();
+
+private:
+ Ui::CacheContent *ui;
};
-#endif // CACHE_CONTENT_H \ No newline at end of file
+#endif // CACHECONTENT_H
diff --git a/qtmips_gui/cachestatistics.cpp b/qtmips_gui/cachestatistics.cpp
index ade92c6..dd78a8c 100644
--- a/qtmips_gui/cachestatistics.cpp
+++ b/qtmips_gui/cachestatistics.cpp
@@ -1,6 +1,10 @@
#include "cachestatistics.h"
-CacheStatistics::CacheStatistics()
-{
+CacheStatisticsDock::CacheStatisticsDock(QWidget *parent) : QDockWidget(parent) {
+ ui = new Ui::CacheStatistics();
+ ui->setupUi(this);
+}
+CacheStatisticsDock::~CacheStatisticsDock() {
+ delete ui;
}
diff --git a/qtmips_gui/cachestatistics.h b/qtmips_gui/cachestatistics.h
index 4fa77a6..a92d125 100644
--- a/qtmips_gui/cachestatistics.h
+++ b/qtmips_gui/cachestatistics.h
@@ -1,11 +1,18 @@
#ifndef CACHESTATISTICS_H
#define CACHESTATISTICS_H
+#include <QDockWidget>
+#include "ui_CacheStatistics.h"
-class CacheStatistics
-{
+class CacheStatisticsDock : public QDockWidget {
+ Q_OBJECT
public:
- CacheStatistics();
+ CacheStatisticsDock(QWidget *parent);
+ ~CacheStatisticsDock();
+
+private:
+ Ui::CacheStatistics *ui;
+
};
-#endif // CACHESTATISTICS_H \ No newline at end of file
+#endif // CACHESTATISTICS_H
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp
index de8a637..4d23bd8 100644
--- a/qtmips_gui/coreview.cpp
+++ b/qtmips_gui/coreview.cpp
@@ -1,6 +1,35 @@
#include "coreview.h"
-CoreView::CoreView()
-{
+CoreView::CoreView(QWidget *parent) : QGraphicsView(parent) {
}
+
+/*
+CoreViewBlock::CoreViewBlock() {
+}
+
+CoreViewLine::CoreViewLine() {
+
+}
+
+CoreViewLine::CoreViewLine(struct point start, struct point end, QList<struct point> axis) {
+
+}
+
+CoreViewLine::~CoreViewLine() {
+
+}
+
+void CoreViewLine::set_start(struct point p) {
+
+}
+
+void CoreViewLine::set_end(struct point p) {
+
+}
+
+void CoreViewLine::set_axis(QList<struct point> axs) {
+
+}
+
+*/
diff --git a/qtmips_gui/coreview.h b/qtmips_gui/coreview.h
index 6e7407f..a2772fb 100644
--- a/qtmips_gui/coreview.h
+++ b/qtmips_gui/coreview.h
@@ -1,11 +1,46 @@
#ifndef COREVIEW_H
#define COREVIEW_H
+#include <QGraphicsView>
+#include <QGraphicsItem>
+#include <QList>
+#include "machineconfig.h"
-class CoreView
-{
+class CoreView : public QGraphicsView {
+ Q_OBJECT
public:
- CoreView();
+ CoreView(QWidget *parent);
+
+private:
+
+};
+
+/*
+class CoreViewBlock : public QGraphicsItem {
+ Q_OBJECT
+public:
+ CoreViewBlock();
+};
+
+class CoreViewLine : public QGraphicsItem {
+ Q_OBJECT
+public:
+ struct point {
+ int x1, y1, x2, y2;
+ };
+
+ CoreViewLine();
+ CoreViewLine(struct point start, struct point end, QList<struct point> axis);
+ ~CoreViewLine();
+
+ void set_start(struct point);
+ void set_end(struct point);
+ void set_axis(QList<struct point>);
+
+protected:
+ struct point start, end;
+ QList<struct point> axis;
};
+*/
-#endif // COREVIEW_H \ No newline at end of file
+#endif // COREVIEW_H
diff --git a/qtmips_gui/icons.qrc b/qtmips_gui/icons.qrc
index 90f4a83..08542ee 100644
--- a/qtmips_gui/icons.qrc
+++ b/qtmips_gui/icons.qrc
@@ -1,2 +1,14 @@
-<!DOCTYPE RCC>
-<RCC version="1.0"/>
+<RCC>
+ <qresource prefix="/">
+ <file>icons/application-exit.png</file>
+ <file>icons/reload.png</file>
+ <file>icons/document-import.png</file>
+ <file>icons/finish.png</file>
+ <file>icons/forward.png</file>
+ <file>icons/next.png</file>
+ <file>icons/pause.png</file>
+ <file>icons/refresh.png</file>
+ <file>icons/play.png</file>
+ <file>icons/stop.png</file>
+ </qresource>
+</RCC>
diff --git a/qtmips_gui/icons/application-exit.png b/qtmips_gui/icons/application-exit.png
index 2d0cd61..79ee79c 100644
--- a/qtmips_gui/icons/application-exit.png
+++ b/qtmips_gui/icons/application-exit.png
Binary files differ
diff --git a/qtmips_gui/main.cpp b/qtmips_gui/main.cpp
index b48f94e..1c03f3f 100644
--- a/qtmips_gui/main.cpp
+++ b/qtmips_gui/main.cpp
@@ -1,11 +1,14 @@
-#include "mainwindow.h"
#include <QApplication>
+#include <QCommandLineParser>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[]) {
+ QApplication app(argc, argv);
+ app.setApplicationName("qtmips_gui");
+ app.setApplicationVersion("0.1");
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
MainWindow w;
- w.show();
+ w.start();
- return a.exec();
+ return app.exec();
}
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 49d64fc..ea48736 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -1,14 +1,93 @@
#include "mainwindow.h"
-#include "ui_mainwindow.h"
-MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::MainWindow)
-{
+MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
+ settings = new QSettings("CTU", "QtMips");
+ coreview = nullptr;
+
+ ui = new Ui::MainWindow();
ui->setupUi(this);
+ setWindowTitle("QtMips");
+
+ // Create/prepare other widgets
+ ndialog = new NewDialog(this, settings);
+ cache_content = new CacheContentDock(this);
+ cache_content->hide();
+ cache_statictics = new CacheStatisticsDock(this);
+ cache_statictics->hide();
+ registers = new RegistersDock(this);
+ registers->hide();
+
+ // Connect signals from menu
+ QObject::connect(ui->actionExit, SIGNAL(triggered(bool)), this, SLOT(close()));
+ QObject::connect(ui->actionNew, SIGNAL(triggered(bool)), this, SLOT(new_machine()));
+ QObject::connect(ui->actionCache, SIGNAL(triggered(bool)), this, SLOT(show_cache_content()));
+ QObject::connect(ui->actionCache_statistics, SIGNAL(triggered(bool)), this, SLOT(show_cache_statictics()));
+ QObject::connect(ui->actionRegisters, SIGNAL(triggered(bool)), this, SLOT(show_registers()));
+
+ // Restore application state from settings
+ restoreState(settings->value("windowState").toByteArray());
+ restoreGeometry(settings->value("windowGeometry").toByteArray());
}
-MainWindow::~MainWindow()
-{
+MainWindow::~MainWindow() {
+ settings->sync();
+ delete settings;
+ if (coreview != nullptr)
+ delete coreview;
+ delete ndialog;
+ delete cache_content;
+ delete cache_statictics;
+ delete registers;
delete ui;
}
+
+void MainWindow::start() {
+ this->show();
+ ndialog->show();
+}
+
+void MainWindow::create_core(MachineConfig *config) {
+ // Create machine
+ machine = new QtMipsMachine(config);
+ // Create machine view
+ coreview = new CoreView(this);
+ this->setCentralWidget(coreview);
+ // TODO connect signals
+}
+
+void MainWindow::new_machine() {
+ ndialog->show();
+}
+
+void MainWindow::show_cache_content() {
+ show_dockwidget(cache_content);
+}
+
+void MainWindow::show_cache_statictics() {
+ show_dockwidget(cache_statictics);
+}
+
+void MainWindow::show_registers() {
+ show_dockwidget(registers);
+}
+
+bool MainWindow::configured() {
+ return (machine != nullptr);
+}
+
+void MainWindow::closeEvent(QCloseEvent *event) {
+ settings->setValue("windowGeometry", saveGeometry());
+ settings->setValue("windowState", saveState());
+ settings->sync();
+ QMainWindow::closeEvent(event);
+}
+
+void MainWindow::show_dockwidget(QDockWidget *dw) {
+ if (dw->isHidden()) {
+ dw->show();
+ addDockWidget(Qt::RightDockWidgetArea, dw);
+ } else {
+ dw->raise();
+ dw->setFocus();
+ }
+}
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index a3948a9..bba1cb7 100644
--- a/qtmips_gui/mainwindow.h
+++ b/qtmips_gui/mainwindow.h
@@ -2,21 +2,55 @@
#define MAINWINDOW_H
#include <QMainWindow>
+#include <QSettings>
+#include "ui_MainWindow.h"
+#include "newdialog.h"
+#include "coreview.h"
+#include "cachecontent.h"
+#include "cachestatistics.h"
+#include "registersdock.h"
-namespace Ui {
-class MainWindow;
-}
+#include "qtmipsmachine.h"
+#include "machineconfig.h"
-class MainWindow : public QMainWindow
-{
+class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
+ void start();
+ void create_core(MachineConfig *config);
+
+public slots:
+ void new_machine();
+
+ void show_cache_content();
+ void show_cache_statictics();
+ void show_registers();
+
+ bool configured();
+
+protected:
+ void closeEvent(QCloseEvent *event);
+
private:
Ui::MainWindow *ui;
+
+ NewDialog *ndialog;
+
+ CoreView *coreview;
+
+ CacheContentDock *cache_content;
+ CacheStatisticsDock *cache_statictics;
+ RegistersDock *registers;
+
+ QSettings *settings;
+
+ QtMipsMachine *machine; // Current simulated machine
+
+ void show_dockwidget(QDockWidget *w);
};
#endif // MAINWINDOW_H
diff --git a/qtmips_gui/newdialog.cpp b/qtmips_gui/newdialog.cpp
index b2d24a8..31f4bb8 100644
--- a/qtmips_gui/newdialog.cpp
+++ b/qtmips_gui/newdialog.cpp
@@ -1,6 +1,155 @@
#include "newdialog.h"
+#include "mainwindow.h"
-newdialog::newdialog()
-{
+NewDialog::NewDialog(QWidget *parent, QSettings *settings) : QDialog(parent) {
+ ui = new Ui::NewDialog();
+ ui->setupUi(this);
+ setWindowTitle("New machine");
+ this->settings = settings;
+
+ QObject::connect(ui->pushButton_load, SIGNAL(clicked(bool)), this, SLOT(create()));
+ QObject::connect(ui->pushButton_cancel, SIGNAL(clicked(bool)), this, SLOT(cancel()));
+ // Signals on Base tab
+ QObject::connect(ui->preset_no_pipeline, SIGNAL(toggled(bool)), this, SLOT(preset(bool)));
+ QObject::connect(ui->preset_pipelined, SIGNAL(toggled(bool)), this, SLOT(preset(bool)));
+ QObject::connect(ui->pushButton_browse, SIGNAL(clicked(bool)), this, SLOT(browse_elf()));
+#define CUSTOM_PRESET(UI) QObject::connect(UI, SIGNAL(clicked(bool)), this, SLOT(set_custom_preset()))
+ // Signals on Core tab
+ CUSTOM_PRESET(ui->pipelined);
+ CUSTOM_PRESET(ui->hazard);
+ CUSTOM_PRESET(ui->flush_jump);
+ CUSTOM_PRESET(ui->prediction);
+ CUSTOM_PRESET(ui->prediction_static);
+ CUSTOM_PRESET(ui->prediction_one_dynamic);
+ // Signals on Memory tab
+ CUSTOM_PRESET(ui->mem_protec_write);
+ CUSTOM_PRESET(ui->mem_protec_exec);
+ CUSTOM_PRESET(ui->cache);
+ CUSTOM_PRESET(ui->cache_associative);
+#undef CUSTOM_PRESET
+
+ // Load setting after signals are configured so that we can have correct settings
+ load_settings();
+}
+
+NewDialog::~NewDialog() {
+ delete ui;
+ // Settings is freed by parent
+ delete elf_dialog;
+}
+
+void NewDialog::cancel() {
+ this->close();
+}
+
+void NewDialog::create() {
+ MainWindow *prnt = (MainWindow*)parent();
+
+ MachineConfig *mc = new MachineConfig();
+ mc->set_elf(ui->elf_file->text());
+ mc->set_pipelined(ui->pipelined->isChecked());
+ // TODO other settings
+
+ try {
+ prnt->create_core(mc);
+ } catch (const QtMipsExceptionInput &e) {
+ QMessageBox msg(this);
+ msg.setText(e.msg(false));
+ msg.setIcon(QMessageBox::Critical);
+ msg.setToolTip("Please check that ELF executable realy exists and is in correct format.");
+ msg.setDetailedText(e.msg(true));
+ msg.setWindowTitle("Error while initializing new machine");
+ msg.exec();
+ goto cleanup;
+ }
+
+ store_settings(); // Save to settings
+ this->close();
+
+cleanup:
+ delete mc;
+}
+
+void NewDialog::browse_elf() {
+ QFileDialog elf_dialog(this);
+ elf_dialog.setFileMode(QFileDialog::ExistingFile);
+ if (elf_dialog.exec())
+ ui->elf_file->setText(elf_dialog.selectedFiles()[0]);
+}
+
+void NewDialog::preset(bool value) {
+ if (value) {
+ bool pip = ui->preset_pipelined->isChecked();
+ // Core settings
+ ui->pipelined->setChecked(pip);
+ ui->hazard->setChecked(pip);
+ ui->flush_jump->setChecked(pip);
+ ui->prediction->setChecked(pip);
+ ui->prediction_one_dynamic->setChecked(pip);
+ // Memory settings
+ ui->mem_protec_write->setChecked(true);
+ ui->mem_protec_exec->setChecked(true);
+ ui->cache->setChecked(pip);
+ ui->cache_associative->setChecked(true);
+ } // Else custom so do no changes
+}
+
+void NewDialog::set_custom_preset() {
+ ui->preset_custom->setChecked(true);
+}
+
+void NewDialog::closeEvent(QCloseEvent *) {
+ load_settings(); // Reset from settings
+ // Close main window if not already configured
+ MainWindow *prnt = (MainWindow*)parent();
+ if (!prnt->configured())
+ prnt->close();
+}
+
+#define LOAD_BUTTON(NAME, DEF) ui->NAME->setChecked(settings->value(#NAME, DEF).toBool())
+#define LOAD_LINE(NAME, DEF) ui->NAME->setText(settings->value(#NAME, DEF).toString())
+
+#define STORE_BUTTON(NAME) settings->setValue(#NAME, ui->NAME->isChecked())
+#define STORE_LINE(NAME) settings->setValue(#NAME, ui->NAME->text())
+
+void NewDialog::load_settings() {
+ // Core tab
+ LOAD_BUTTON(pipelined, false);
+ LOAD_BUTTON(hazard, false);
+ LOAD_BUTTON(flush_jump, false);
+ LOAD_BUTTON(prediction, false);
+ LOAD_BUTTON(prediction_static, true);
+ LOAD_BUTTON(prediction_one_dynamic, false);
+ // Memory tab
+ LOAD_BUTTON(mem_protec_write, true);
+ LOAD_BUTTON(mem_protec_exec, true);
+ LOAD_BUTTON(cache, false);
+ LOAD_BUTTON(cache_associative, true);
+ // Base tab
+ // We are doing this last so presets can reset previous configuration to somethin valid
+ LOAD_BUTTON(preset_no_pipeline, true);
+ LOAD_BUTTON(preset_pipelined, false);
+ LOAD_BUTTON(preset_custom, false);
+ LOAD_LINE(elf_file, "");
+}
+
+void NewDialog::store_settings() {
+ // Core tab
+ STORE_BUTTON(pipelined);
+ STORE_BUTTON(hazard);
+ STORE_BUTTON(flush_jump);
+ STORE_BUTTON(prediction);
+ STORE_BUTTON(prediction_static);
+ STORE_BUTTON(prediction_one_dynamic);
+ // Memory tab
+ STORE_BUTTON(mem_protec_write);
+ STORE_BUTTON(mem_protec_exec);
+ STORE_BUTTON(cache);
+ STORE_BUTTON(cache_associative);
+ // Base tab
+ STORE_BUTTON(preset_no_pipeline);
+ STORE_BUTTON(preset_pipelined);
+ STORE_BUTTON(preset_custom);
+ STORE_LINE(elf_file);
}
diff --git a/qtmips_gui/newdialog.h b/qtmips_gui/newdialog.h
index d37c9c0..d9e850e 100644
--- a/qtmips_gui/newdialog.h
+++ b/qtmips_gui/newdialog.h
@@ -1,11 +1,36 @@
#ifndef NEWDIALOG_H
#define NEWDIALOG_H
+#include <QDialog>
+#include <QSettings>
+#include <QFileDialog>
+#include <QMessageBox>
+#include "ui_NewDialog.h"
+#include "qtmipsexception.h"
-class newdialog
-{
+class NewDialog : public QDialog {
+ Q_OBJECT
public:
- newdialog();
+ NewDialog(QWidget *parent, QSettings *settings);
+ ~NewDialog();
+
+public slots:
+ void cancel();
+ void create();
+ void browse_elf();
+ void preset(bool);
+ void set_custom_preset();
+
+protected:
+ void closeEvent(QCloseEvent *);
+
+private:
+ Ui::NewDialog *ui;
+ QSettings *settings;
+ QFileDialog *elf_dialog;
+
+ void load_settings();
+ void store_settings();
};
-#endif // NEWDIALOG_H \ No newline at end of file
+#endif // NEWDIALOG_H
diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro
index 7dfb53c..ee2bd6e 100644
--- a/qtmips_gui/qtmips_gui.pro
+++ b/qtmips_gui/qtmips_gui.pro
@@ -14,10 +14,27 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
- mainwindow.cpp
+ mainwindow.cpp \
+ newdialog.cpp \
+ coreview.cpp \
+ registersdock.cpp \
+ cachestatistics.cpp \
+ cachecontent.cpp
HEADERS += \
- mainwindow.h
+ mainwindow.h \
+ newdialog.h \
+ coreview.h \
+ registersdock.h \
+ cachestatistics.h \
+ cachecontent.h
FORMS += \
- mainwindow.ui
+ NewDialog.ui \
+ MainWindow.ui \
+ CacheContent.ui \
+ registersdock.ui \
+ CacheStatistics.ui
+
+RESOURCES += \
+ icons.qrc
diff --git a/qtmips_gui/registersdock.cpp b/qtmips_gui/registersdock.cpp
index bf82725..e8a5907 100644
--- a/qtmips_gui/registersdock.cpp
+++ b/qtmips_gui/registersdock.cpp
@@ -1,6 +1,10 @@
-#include "registers.h"
+#include "registersdock.h"
-Registers::Registers()
-{
+RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) {
+ ui = new Ui::RegistersDock();
+ ui->setupUi(this);
+}
+RegistersDock::~RegistersDock() {
+ delete ui;
}
diff --git a/qtmips_gui/registersdock.h b/qtmips_gui/registersdock.h
index 0fb60eb..338edc3 100644
--- a/qtmips_gui/registersdock.h
+++ b/qtmips_gui/registersdock.h
@@ -1,11 +1,17 @@
-#ifndef REGISTERS_H
-#define REGISTERS_H
+#ifndef REGISTERSDOCK_H
+#define REGISTERSDOCK_H
+#include <QDockWidget>
+#include "ui_registersdock.h"
-class Registers
-{
+class RegistersDock : public QDockWidget {
public:
- Registers();
+ RegistersDock(QWidget *parent);
+ ~RegistersDock();
+
+private:
+ Ui::RegistersDock *ui;
+
};
-#endif // REGISTERS_H \ No newline at end of file
+#endif // REGISTERSDOCK_H
diff --git a/qtmips_gui/registersdock.ui b/qtmips_gui/registersdock.ui
index ac2f263..9b51505 100644
--- a/qtmips_gui/registersdock.ui
+++ b/qtmips_gui/registersdock.ui
@@ -1,7 +1,7 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>DockWidget</class>
- <widget class="QDockWidget" name="DockWidget">
+ <class>RegistersDock</class>
+ <widget class="QDockWidget" name="RegistersDock">
<property name="geometry">
<rect>
<x>0</x>
@@ -11,8 +11,16 @@
</rect>
</property>
<property name="windowTitle">
- <string>DockWidget</string>
+ <string>Registers</string>
</property>
- <widget class="QWidget" name="dockWidgetContents"/>
+ <widget class="QWidget" name="dockWidgetContents">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTableWidget" name="tableWidget"/>
+ </item>
+ </layout>
+ </widget>
</widget>
+ <resources/>
+ <connections/>
</ui>