From 2c6562fa78e884d66b8c2a306f020101e8803f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 19 Nov 2017 21:16:46 +0100 Subject: Just something I had stagged --- qtmips_cli/machineapp.cpp | 11 -- qtmips_cli/machineapp.h | 16 --- qtmips_cli/tracer.cpp | 6 + qtmips_cli/tracer.h | 12 ++ qtmips_gui/CacheContent.ui | 18 +++ qtmips_gui/CacheStatistics.ui | 18 +++ qtmips_gui/MainWindow.ui | 191 +++++++++++++++++++++++++++++ qtmips_gui/NewDialog.ui | 71 +++++++++++ qtmips_gui/cachecontent.cpp | 6 + qtmips_gui/cachecontent.h | 11 ++ qtmips_gui/cachestatistics.cpp | 6 + qtmips_gui/cachestatistics.h | 11 ++ qtmips_gui/coreview.cpp | 6 + qtmips_gui/coreview.h | 11 ++ qtmips_gui/icons.qrc | 2 + qtmips_gui/icons/application-exit.png | Bin 0 -> 2633 bytes qtmips_gui/icons/document-import.png | Bin 0 -> 1447 bytes qtmips_gui/icons/finish.png | Bin 0 -> 1364 bytes qtmips_gui/icons/forward.png | Bin 0 -> 1276 bytes qtmips_gui/icons/next.png | Bin 0 -> 3639 bytes qtmips_gui/icons/pause.png | Bin 0 -> 3337 bytes qtmips_gui/icons/play.png | Bin 0 -> 3492 bytes qtmips_gui/icons/refresh.png | Bin 0 -> 1966 bytes qtmips_gui/icons/reload.png | Bin 0 -> 1966 bytes qtmips_gui/icons/stop.png | Bin 0 -> 3131 bytes qtmips_gui/mainwindow.ui | 191 ----------------------------- qtmips_gui/newdialog.cpp | 6 + qtmips_gui/newdialog.h | 11 ++ qtmips_gui/registersdock.cpp | 6 + qtmips_gui/registersdock.h | 11 ++ qtmips_gui/registersdock.ui | 18 +++ qtmips_machine/alu.cpp | 6 + qtmips_machine/alu.h | 11 ++ qtmips_machine/machineconfig.cpp | 6 + qtmips_machine/machineconfig.h | 11 ++ qtmips_machine/tests/testalu.cpp | 0 qtmips_machine/tests/testcore.cpp | 0 qtmips_machine/tests/testinstruction.cpp | 76 ------------ qtmips_machine/tests/testprogramloader.cpp | 0 tests/machine-unit-tests/test.sh | 2 + 40 files changed, 457 insertions(+), 294 deletions(-) delete mode 100644 qtmips_cli/machineapp.cpp delete mode 100644 qtmips_cli/machineapp.h create mode 100644 qtmips_cli/tracer.cpp create mode 100644 qtmips_cli/tracer.h create mode 100644 qtmips_gui/CacheContent.ui create mode 100644 qtmips_gui/CacheStatistics.ui create mode 100644 qtmips_gui/MainWindow.ui create mode 100644 qtmips_gui/NewDialog.ui create mode 100644 qtmips_gui/cachecontent.cpp create mode 100644 qtmips_gui/cachecontent.h create mode 100644 qtmips_gui/cachestatistics.cpp create mode 100644 qtmips_gui/cachestatistics.h create mode 100644 qtmips_gui/coreview.cpp create mode 100644 qtmips_gui/coreview.h create mode 100644 qtmips_gui/icons.qrc create mode 100644 qtmips_gui/icons/application-exit.png create mode 100644 qtmips_gui/icons/document-import.png create mode 100644 qtmips_gui/icons/finish.png create mode 100644 qtmips_gui/icons/forward.png create mode 100644 qtmips_gui/icons/next.png create mode 100644 qtmips_gui/icons/pause.png create mode 100644 qtmips_gui/icons/play.png create mode 100644 qtmips_gui/icons/refresh.png create mode 100644 qtmips_gui/icons/reload.png create mode 100644 qtmips_gui/icons/stop.png delete mode 100644 qtmips_gui/mainwindow.ui create mode 100644 qtmips_gui/newdialog.cpp create mode 100644 qtmips_gui/newdialog.h create mode 100644 qtmips_gui/registersdock.cpp create mode 100644 qtmips_gui/registersdock.h create mode 100644 qtmips_gui/registersdock.ui create mode 100644 qtmips_machine/alu.cpp create mode 100644 qtmips_machine/alu.h create mode 100644 qtmips_machine/machineconfig.cpp create mode 100644 qtmips_machine/machineconfig.h create mode 100644 qtmips_machine/tests/testalu.cpp create mode 100644 qtmips_machine/tests/testcore.cpp create mode 100644 qtmips_machine/tests/testprogramloader.cpp diff --git a/qtmips_cli/machineapp.cpp b/qtmips_cli/machineapp.cpp deleted file mode 100644 index 09fcd3e..0000000 --- a/qtmips_cli/machineapp.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "machineapp.h" -#include - -MachineApp::MachineApp(int argc, char **argv) : QCoreApplication(argc, argv) { - connect(this, SIGNAL(aboutToQuit()), this, SLOT(quit())); - // TODO drop hello - std::cout << "Hello\n"; - std::cout.flush(); - // TODO check argc - this->machine = new QtMipsMachine(argv[1]); -} diff --git a/qtmips_cli/machineapp.h b/qtmips_cli/machineapp.h deleted file mode 100644 index 6587154..0000000 --- a/qtmips_cli/machineapp.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef MACHINEAPP_H -#define MACHINEAPP_H - -#include - -#include "qtmipsmachine.h" -#include "programloader.h" - -class MachineApp : public QCoreApplication { -public: - MachineApp(int argc, char **argv); -private: - QtMipsMachine *machine; -}; - -#endif // MACHINEAPP_H diff --git a/qtmips_cli/tracer.cpp b/qtmips_cli/tracer.cpp new file mode 100644 index 0000000..63d00d1 --- /dev/null +++ b/qtmips_cli/tracer.cpp @@ -0,0 +1,6 @@ +#include "tracer.h" + +Tracer::Tracer() +{ + +} diff --git a/qtmips_cli/tracer.h b/qtmips_cli/tracer.h new file mode 100644 index 0000000..5c99970 --- /dev/null +++ b/qtmips_cli/tracer.h @@ -0,0 +1,12 @@ +#ifndef TRACER_H +#define TRACER_H + +#include + +class Tracer +{ +public: + Tracer(); +}; + +#endif // TRACER_H \ No newline at end of file diff --git a/qtmips_gui/CacheContent.ui b/qtmips_gui/CacheContent.ui new file mode 100644 index 0000000..ac2f263 --- /dev/null +++ b/qtmips_gui/CacheContent.ui @@ -0,0 +1,18 @@ + + + DockWidget + + + + 0 + 0 + 400 + 300 + + + + DockWidget + + + + diff --git a/qtmips_gui/CacheStatistics.ui b/qtmips_gui/CacheStatistics.ui new file mode 100644 index 0000000..ac2f263 --- /dev/null +++ b/qtmips_gui/CacheStatistics.ui @@ -0,0 +1,18 @@ + + + DockWidget + + + + 0 + 0 + 400 + 300 + + + + DockWidget + + + + diff --git a/qtmips_gui/MainWindow.ui b/qtmips_gui/MainWindow.ui new file mode 100644 index 0000000..0f69613 --- /dev/null +++ b/qtmips_gui/MainWindow.ui @@ -0,0 +1,191 @@ + + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + 0 + 0 + 400 + 20 + + + + + File + + + + + + + + Windows + + + + + + + + + + Machine + + + + Simulation speed + + + + + + + + + + + + + + + + + + + + + + + + toolBar + + + false + + + Qt::TopToolBarArea + + + TopToolBarArea + + + false + + + + + Load binary... + + + + + Exit + + + + + Restart + + + + + Run + + + + + Step + + + + + Pause + + + + + 1 instruction per second + + + + + 2 instructions per second + + + + + 5 instructions per second + + + + + 10 instructions per second + + + + + Unlimited + + + + + false + + + Custom... + + + + + Machine control + + + + + Data Memory + + + + + Program memory + + + + + Cache content + + + + + Cache statistics + + + + + Registers + + + + + Assembler + + + + + + + diff --git a/qtmips_gui/NewDialog.ui b/qtmips_gui/NewDialog.ui new file mode 100644 index 0000000..18d31ab --- /dev/null +++ b/qtmips_gui/NewDialog.ui @@ -0,0 +1,71 @@ + + + + + Dialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + 30 + 240 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/qtmips_gui/cachecontent.cpp b/qtmips_gui/cachecontent.cpp new file mode 100644 index 0000000..c651b7b --- /dev/null +++ b/qtmips_gui/cachecontent.cpp @@ -0,0 +1,6 @@ +#include "cache_content.h" + +cache_content::cache_content() +{ + +} diff --git a/qtmips_gui/cachecontent.h b/qtmips_gui/cachecontent.h new file mode 100644 index 0000000..09b8734 --- /dev/null +++ b/qtmips_gui/cachecontent.h @@ -0,0 +1,11 @@ +#ifndef CACHE_CONTENT_H +#define CACHE_CONTENT_H + + +class cache_content +{ +public: + cache_content(); +}; + +#endif // CACHE_CONTENT_H \ No newline at end of file diff --git a/qtmips_gui/cachestatistics.cpp b/qtmips_gui/cachestatistics.cpp new file mode 100644 index 0000000..ade92c6 --- /dev/null +++ b/qtmips_gui/cachestatistics.cpp @@ -0,0 +1,6 @@ +#include "cachestatistics.h" + +CacheStatistics::CacheStatistics() +{ + +} diff --git a/qtmips_gui/cachestatistics.h b/qtmips_gui/cachestatistics.h new file mode 100644 index 0000000..4fa77a6 --- /dev/null +++ b/qtmips_gui/cachestatistics.h @@ -0,0 +1,11 @@ +#ifndef CACHESTATISTICS_H +#define CACHESTATISTICS_H + + +class CacheStatistics +{ +public: + CacheStatistics(); +}; + +#endif // CACHESTATISTICS_H \ No newline at end of file diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp new file mode 100644 index 0000000..de8a637 --- /dev/null +++ b/qtmips_gui/coreview.cpp @@ -0,0 +1,6 @@ +#include "coreview.h" + +CoreView::CoreView() +{ + +} diff --git a/qtmips_gui/coreview.h b/qtmips_gui/coreview.h new file mode 100644 index 0000000..6e7407f --- /dev/null +++ b/qtmips_gui/coreview.h @@ -0,0 +1,11 @@ +#ifndef COREVIEW_H +#define COREVIEW_H + + +class CoreView +{ +public: + CoreView(); +}; + +#endif // COREVIEW_H \ No newline at end of file diff --git a/qtmips_gui/icons.qrc b/qtmips_gui/icons.qrc new file mode 100644 index 0000000..90f4a83 --- /dev/null +++ b/qtmips_gui/icons.qrc @@ -0,0 +1,2 @@ + + diff --git a/qtmips_gui/icons/application-exit.png b/qtmips_gui/icons/application-exit.png new file mode 100644 index 0000000..2d0cd61 Binary files /dev/null and b/qtmips_gui/icons/application-exit.png differ diff --git a/qtmips_gui/icons/document-import.png b/qtmips_gui/icons/document-import.png new file mode 100644 index 0000000..e5d7931 Binary files /dev/null and b/qtmips_gui/icons/document-import.png differ diff --git a/qtmips_gui/icons/finish.png b/qtmips_gui/icons/finish.png new file mode 100644 index 0000000..26ef8e3 Binary files /dev/null and b/qtmips_gui/icons/finish.png differ diff --git a/qtmips_gui/icons/forward.png b/qtmips_gui/icons/forward.png new file mode 100644 index 0000000..8fa42a1 Binary files /dev/null and b/qtmips_gui/icons/forward.png differ diff --git a/qtmips_gui/icons/next.png b/qtmips_gui/icons/next.png new file mode 100644 index 0000000..1eca765 Binary files /dev/null and b/qtmips_gui/icons/next.png differ diff --git a/qtmips_gui/icons/pause.png b/qtmips_gui/icons/pause.png new file mode 100644 index 0000000..36e8803 Binary files /dev/null and b/qtmips_gui/icons/pause.png differ diff --git a/qtmips_gui/icons/play.png b/qtmips_gui/icons/play.png new file mode 100644 index 0000000..746508d Binary files /dev/null and b/qtmips_gui/icons/play.png differ diff --git a/qtmips_gui/icons/refresh.png b/qtmips_gui/icons/refresh.png new file mode 100644 index 0000000..129fcd6 Binary files /dev/null and b/qtmips_gui/icons/refresh.png differ diff --git a/qtmips_gui/icons/reload.png b/qtmips_gui/icons/reload.png new file mode 100644 index 0000000..129fcd6 Binary files /dev/null and b/qtmips_gui/icons/reload.png differ diff --git a/qtmips_gui/icons/stop.png b/qtmips_gui/icons/stop.png new file mode 100644 index 0000000..f83e86c Binary files /dev/null and b/qtmips_gui/icons/stop.png differ diff --git a/qtmips_gui/mainwindow.ui b/qtmips_gui/mainwindow.ui deleted file mode 100644 index 0f69613..0000000 --- a/qtmips_gui/mainwindow.ui +++ /dev/null @@ -1,191 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 400 - 300 - - - - MainWindow - - - - - - 0 - 0 - 400 - 20 - - - - - File - - - - - - - - Windows - - - - - - - - - - Machine - - - - Simulation speed - - - - - - - - - - - - - - - - - - - - - - - - toolBar - - - false - - - Qt::TopToolBarArea - - - TopToolBarArea - - - false - - - - - Load binary... - - - - - Exit - - - - - Restart - - - - - Run - - - - - Step - - - - - Pause - - - - - 1 instruction per second - - - - - 2 instructions per second - - - - - 5 instructions per second - - - - - 10 instructions per second - - - - - Unlimited - - - - - false - - - Custom... - - - - - Machine control - - - - - Data Memory - - - - - Program memory - - - - - Cache content - - - - - Cache statistics - - - - - Registers - - - - - Assembler - - - - - - - diff --git a/qtmips_gui/newdialog.cpp b/qtmips_gui/newdialog.cpp new file mode 100644 index 0000000..b2d24a8 --- /dev/null +++ b/qtmips_gui/newdialog.cpp @@ -0,0 +1,6 @@ +#include "newdialog.h" + +newdialog::newdialog() +{ + +} diff --git a/qtmips_gui/newdialog.h b/qtmips_gui/newdialog.h new file mode 100644 index 0000000..d37c9c0 --- /dev/null +++ b/qtmips_gui/newdialog.h @@ -0,0 +1,11 @@ +#ifndef NEWDIALOG_H +#define NEWDIALOG_H + + +class newdialog +{ +public: + newdialog(); +}; + +#endif // NEWDIALOG_H \ No newline at end of file diff --git a/qtmips_gui/registersdock.cpp b/qtmips_gui/registersdock.cpp new file mode 100644 index 0000000..bf82725 --- /dev/null +++ b/qtmips_gui/registersdock.cpp @@ -0,0 +1,6 @@ +#include "registers.h" + +Registers::Registers() +{ + +} diff --git a/qtmips_gui/registersdock.h b/qtmips_gui/registersdock.h new file mode 100644 index 0000000..0fb60eb --- /dev/null +++ b/qtmips_gui/registersdock.h @@ -0,0 +1,11 @@ +#ifndef REGISTERS_H +#define REGISTERS_H + + +class Registers +{ +public: + Registers(); +}; + +#endif // REGISTERS_H \ No newline at end of file diff --git a/qtmips_gui/registersdock.ui b/qtmips_gui/registersdock.ui new file mode 100644 index 0000000..ac2f263 --- /dev/null +++ b/qtmips_gui/registersdock.ui @@ -0,0 +1,18 @@ + + + DockWidget + + + + 0 + 0 + 400 + 300 + + + + DockWidget + + + + diff --git a/qtmips_machine/alu.cpp b/qtmips_machine/alu.cpp new file mode 100644 index 0000000..5c74a5d --- /dev/null +++ b/qtmips_machine/alu.cpp @@ -0,0 +1,6 @@ +#include "alu.h" + +Alu::Alu() +{ + +} diff --git a/qtmips_machine/alu.h b/qtmips_machine/alu.h new file mode 100644 index 0000000..e913b0c --- /dev/null +++ b/qtmips_machine/alu.h @@ -0,0 +1,11 @@ +#ifndef ALU_H +#define ALU_H + + +class Alu +{ +public: + Alu(); +}; + +#endif // ALU_H \ No newline at end of file diff --git a/qtmips_machine/machineconfig.cpp b/qtmips_machine/machineconfig.cpp new file mode 100644 index 0000000..8562ab9 --- /dev/null +++ b/qtmips_machine/machineconfig.cpp @@ -0,0 +1,6 @@ +#include "machineconfig.h" + +MachineConfig::MachineConfig() +{ + +} diff --git a/qtmips_machine/machineconfig.h b/qtmips_machine/machineconfig.h new file mode 100644 index 0000000..58c2fc2 --- /dev/null +++ b/qtmips_machine/machineconfig.h @@ -0,0 +1,11 @@ +#ifndef MACHINECONFIG_H +#define MACHINECONFIG_H + + +class MachineConfig +{ +public: + MachineConfig(); +}; + +#endif // MACHINECONFIG_H \ No newline at end of file diff --git a/qtmips_machine/tests/testalu.cpp b/qtmips_machine/tests/testalu.cpp new file mode 100644 index 0000000..e69de29 diff --git a/qtmips_machine/tests/testcore.cpp b/qtmips_machine/tests/testcore.cpp new file mode 100644 index 0000000..e69de29 diff --git a/qtmips_machine/tests/testinstruction.cpp b/qtmips_machine/tests/testinstruction.cpp index a299bcf..e69de29 100644 --- a/qtmips_machine/tests/testinstruction.cpp +++ b/qtmips_machine/tests/testinstruction.cpp @@ -1,76 +0,0 @@ -#include "tst_machine.h" -#include "instructions/arithmetic.h" -#include "instructions/jumpbranch.h" -#include "instructions/loadstore.h" -#include "instructions/nop.h" -#include "instructions/shift.h" -#include - -void MachineTests::instruction_arithmetic_data() { - QTest::addColumn("type"); - QTest::addColumn("res"); - - QTest::newRow("ADD") << (size_t)IAT_ADD << (unsigned)749; - QTest::newRow("ADDU") << (size_t)IAT_ADDU << (unsigned)749; - QTest::newRow("SUB") << (size_t)IAT_SUB << (unsigned)-665; - QTest::newRow("SUBU") << (size_t)IAT_SUBU << (unsigned)-665; - QTest::newRow("AND") << (size_t)IAT_AND << (unsigned)2; - QTest::newRow("OR") << (size_t)IAT_OR << (unsigned)747; - QTest::newRow("XOR") << (size_t)IAT_XOR << (unsigned)745; - // TODO others -} - -void MachineTests::instruction_arithmetic() { - Registers regs; - - QFETCH(size_t, type); - QFETCH(std::uint32_t, res); - - // TODO meaby one more dataset? - - regs.write_gp(12, 42); - regs.write_gp(8, 707); - regs.write_gp(5, 0); - - Instruction *i = new InstructionArithmetic((enum InstructionArithmeticT)type, 12, 8, 5); - - i->decode(®s); - i->execute(); - i->memory(nullptr); // We should not work with memory so segfault here is basically a test - i->write_back(®s); - - QCOMPARE(regs.read_gp(5), (std::uint32_t)res); -} - -void MachineTests::instruction_arithmetic_immediate_data() { - QTest::addColumn("type"); - QTest::addColumn("res"); - - QTest::newRow("ADDI") << (size_t)IAT_ADDI << (unsigned)749; - QTest::newRow("ADDIU") << (size_t)IAT_ADDIU << (unsigned)749; - QTest::newRow("ANDI") << (size_t)IAT_ANDI << (unsigned)-665; - QTest::newRow("ORI") << (size_t)IAT_ORI << (unsigned)-665; - QTest::newRow("XORI") << (size_t)IAT_XORI << (unsigned)2; - // TODO others -} - -void MachineTests::instruction_arithmetic_immediate() { - Registers regs; - - QFETCH(size_t, type); - QFETCH(std::uint32_t, res); - - // TODO meaby one more dataset? - - regs.write_gp(9, 42); - regs.write_gp(3, 0); - - Instruction *i = new InstructionArithmeticImmediate((enum InstructionArithmeticImmediateT)type, 9, 3, 707); - - i->decode(®s); - i->execute(); - i->memory(nullptr); // We should not work with memory so segfault here is basically a test - i->write_back(®s); - - QCOMPARE(regs.read_gp(3), (std::uint32_t)res); -} diff --git a/qtmips_machine/tests/testprogramloader.cpp b/qtmips_machine/tests/testprogramloader.cpp new file mode 100644 index 0000000..e69de29 diff --git a/tests/machine-unit-tests/test.sh b/tests/machine-unit-tests/test.sh index c916f74..2f06965 100755 --- a/tests/machine-unit-tests/test.sh +++ b/tests/machine-unit-tests/test.sh @@ -6,6 +6,8 @@ TEST_NAME="machine-unit-test" # Build tests binary qtmips_make sub-qtmips_machine-tests +# Build test data +mips_make_test # Run unit tests qtmips_run qtmips_machine/tests/tst_machine || echo_fail "Test $TEST_NAME failed!" -- cgit v1.2.3