diff options
author | Karel Kočí <cynerd@email.cz> | 2017-11-19 21:16:46 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-11-19 21:16:46 +0100 |
commit | 2c6562fa78e884d66b8c2a306f020101e8803f2e (patch) | |
tree | 7e9a940cb73fcdf3424ff5443163ba51da0ef82c /qtmips_machine | |
parent | 04ea2670be26291a17808bd704ce3549795953a0 (diff) | |
download | qtmips-2c6562fa78e884d66b8c2a306f020101e8803f2e.tar.gz qtmips-2c6562fa78e884d66b8c2a306f020101e8803f2e.tar.bz2 qtmips-2c6562fa78e884d66b8c2a306f020101e8803f2e.zip |
Just something I had stagged
Diffstat (limited to 'qtmips_machine')
-rw-r--r-- | qtmips_machine/alu.cpp | 6 | ||||
-rw-r--r-- | qtmips_machine/alu.h | 11 | ||||
-rw-r--r-- | qtmips_machine/machineconfig.cpp | 6 | ||||
-rw-r--r-- | qtmips_machine/machineconfig.h | 11 | ||||
-rw-r--r-- | qtmips_machine/tests/testalu.cpp | 0 | ||||
-rw-r--r-- | qtmips_machine/tests/testcore.cpp | 0 | ||||
-rw-r--r-- | qtmips_machine/tests/testinstruction.cpp | 76 | ||||
-rw-r--r-- | qtmips_machine/tests/testprogramloader.cpp | 0 |
8 files changed, 34 insertions, 76 deletions
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 --- /dev/null +++ b/qtmips_machine/tests/testalu.cpp diff --git a/qtmips_machine/tests/testcore.cpp b/qtmips_machine/tests/testcore.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/qtmips_machine/tests/testcore.cpp 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 <iostream> - -void MachineTests::instruction_arithmetic_data() { - QTest::addColumn<size_t>("type"); - QTest::addColumn<std::uint32_t>("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<size_t>("type"); - QTest::addColumn<std::uint32_t>("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 --- /dev/null +++ b/qtmips_machine/tests/testprogramloader.cpp |