aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-12-17 13:31:25 +0100
committerKarel Kočí <cynerd@email.cz>2017-12-17 13:31:25 +0100
commite0c757926743ee21f1a60b4b6948ca3eb895c373 (patch)
treed2acad9475849d5abed15cdd4b6bf3b8d9030f06
parent7fa050ddefca5373b09bdbcbb3aa0902eacd5d2f (diff)
downloadqtmips-e0c757926743ee21f1a60b4b6948ca3eb895c373.tar.gz
qtmips-e0c757926743ee21f1a60b4b6948ca3eb895c373.tar.bz2
qtmips-e0c757926743ee21f1a60b4b6948ca3eb895c373.zip
Put qtmips_machine to machine namespace
-rw-r--r--qtmips_cli/main.cpp2
-rw-r--r--qtmips_cli/tracer.cpp1
-rw-r--r--qtmips_cli/tracer.h4
-rw-r--r--qtmips_gui/coreview.cpp2
-rw-r--r--qtmips_gui/coreview.h4
-rw-r--r--qtmips_gui/coreview/latch.cpp2
-rw-r--r--qtmips_gui/coreview/latch.h2
-rw-r--r--qtmips_gui/coreview/programcounter.cpp2
-rw-r--r--qtmips_gui/coreview/programcounter.h2
-rw-r--r--qtmips_gui/mainwindow.cpp4
-rw-r--r--qtmips_gui/mainwindow.h4
-rw-r--r--qtmips_gui/newdialog.cpp4
-rw-r--r--qtmips_gui/registersdock.cpp2
-rw-r--r--qtmips_gui/registersdock.h4
-rw-r--r--qtmips_machine/alu.cpp6
-rw-r--r--qtmips_machine/alu.h6
-rw-r--r--qtmips_machine/cache.cpp2
-rw-r--r--qtmips_machine/cache.h4
-rw-r--r--qtmips_machine/core.cpp2
-rw-r--r--qtmips_machine/core.h4
-rw-r--r--qtmips_machine/instruction.cpp2
-rw-r--r--qtmips_machine/instruction.h6
-rw-r--r--qtmips_machine/machineconfig.cpp2
-rw-r--r--qtmips_machine/machineconfig.h4
-rw-r--r--qtmips_machine/memory.cpp4
-rw-r--r--qtmips_machine/memory.h9
-rw-r--r--qtmips_machine/programloader.cpp2
-rw-r--r--qtmips_machine/programloader.h3
-rw-r--r--qtmips_machine/qtmipsexception.cpp2
-rw-r--r--qtmips_machine/qtmipsexception.h6
-rw-r--r--qtmips_machine/qtmipsmachine.cpp2
-rw-r--r--qtmips_machine/qtmipsmachine.h4
-rw-r--r--qtmips_machine/registers.cpp2
-rw-r--r--qtmips_machine/registers.h6
-rw-r--r--qtmips_machine/tests/testalu.cpp2
-rw-r--r--qtmips_machine/tests/testcore.cpp2
-rw-r--r--qtmips_machine/tests/testinstruction.cpp2
-rw-r--r--qtmips_machine/tests/testmemory.cpp2
-rw-r--r--qtmips_machine/tests/testprogramloader.cpp2
-rw-r--r--qtmips_machine/tests/testregisters.cpp2
40 files changed, 102 insertions, 27 deletions
diff --git a/qtmips_cli/main.cpp b/qtmips_cli/main.cpp
index 6240414..4c4652b 100644
--- a/qtmips_cli/main.cpp
+++ b/qtmips_cli/main.cpp
@@ -3,6 +3,8 @@
#include <iostream>
#include "tracer.h"
+using namespace machine;
+
void create_parser(QCommandLineParser &p) {
p.setApplicationDescription("QtMips CLI machine simulator");
p.addHelpOption();
diff --git a/qtmips_cli/tracer.cpp b/qtmips_cli/tracer.cpp
index 5cbf339..2969112 100644
--- a/qtmips_cli/tracer.cpp
+++ b/qtmips_cli/tracer.cpp
@@ -2,6 +2,7 @@
#include <iostream>
using namespace std;
+using namespace machine;
Tracer::Tracer(QtMipsMachine *machine) {
this->machine = machine;
diff --git a/qtmips_cli/tracer.h b/qtmips_cli/tracer.h
index 7055cd8..d5a476b 100644
--- a/qtmips_cli/tracer.h
+++ b/qtmips_cli/tracer.h
@@ -7,7 +7,7 @@
class Tracer : public QObject {
Q_OBJECT
public:
- Tracer(QtMipsMachine *machine);
+ Tracer(machine::QtMipsMachine *machine);
// Trace registers
void reg_pc();
@@ -16,7 +16,7 @@ private slots:
void regs_pc_update(std::uint32_t val);
private:
- QtMipsMachine *machine;
+ machine::QtMipsMachine *machine;
};
#endif // TRACER_H
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp
index 660f78d..6630ad1 100644
--- a/qtmips_gui/coreview.cpp
+++ b/qtmips_gui/coreview.cpp
@@ -1,6 +1,6 @@
#include "coreview.h"
-CoreView::CoreView(QWidget *parent, QtMipsMachine *machine) : QGraphicsView(parent) {
+CoreView::CoreView(QWidget *parent, machine::QtMipsMachine *machine) : QGraphicsView(parent) {
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
diff --git a/qtmips_gui/coreview.h b/qtmips_gui/coreview.h
index fc69861..7e9081a 100644
--- a/qtmips_gui/coreview.h
+++ b/qtmips_gui/coreview.h
@@ -12,13 +12,13 @@
class CoreView : public QGraphicsView {
Q_OBJECT
public:
- CoreView(QWidget *parent, QtMipsMachine *machine);
+ CoreView(QWidget *parent, machine::QtMipsMachine *machine);
private:
void resizeEvent(QResizeEvent *event);
QGraphicsScene scene;
- QtMipsMachine *machine;
+ machine::QtMipsMachine *machine;
coreview::ProgramCounter *pc;
coreview::Multiplexer *pc_multiplexer;
diff --git a/qtmips_gui/coreview/latch.cpp b/qtmips_gui/coreview/latch.cpp
index 77bb317..52f6eb3 100644
--- a/qtmips_gui/coreview/latch.cpp
+++ b/qtmips_gui/coreview/latch.cpp
@@ -7,7 +7,7 @@ using namespace coreview;
#define PENW 1
//////////////////////
-Latch::Latch(QtMipsMachine *machine, qreal height) {
+Latch::Latch(machine::QtMipsMachine *machine, qreal height) {
this->height = height;
connect(machine, SIGNAL(tick()), this, SLOT(tick()));
}
diff --git a/qtmips_gui/coreview/latch.h b/qtmips_gui/coreview/latch.h
index a8738b3..0148b67 100644
--- a/qtmips_gui/coreview/latch.h
+++ b/qtmips_gui/coreview/latch.h
@@ -13,7 +13,7 @@ namespace coreview {
class Latch : public QGraphicsObject {
Q_OBJECT
public:
- Latch(QtMipsMachine *machine, qreal height);
+ Latch(machine::QtMipsMachine *machine, qreal height);
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
diff --git a/qtmips_gui/coreview/programcounter.cpp b/qtmips_gui/coreview/programcounter.cpp
index 32c907c..b25cbbe 100644
--- a/qtmips_gui/coreview/programcounter.cpp
+++ b/qtmips_gui/coreview/programcounter.cpp
@@ -8,7 +8,7 @@ using namespace coreview;
#define PENW 1
//////////////////////
-ProgramCounter::ProgramCounter(QtMipsMachine *machine) : QGraphicsObject(nullptr), value(this), name(this) {
+ProgramCounter::ProgramCounter(machine::QtMipsMachine *machine) : QGraphicsObject(nullptr), value(this), name(this) {
value.setText(QString("0x") + QString::number(machine->registers()->read_pc(), 16));
value.setPos(0, HEIGHT/2 - value.boundingRect().height()/2);
name.setText(QString("PC"));
diff --git a/qtmips_gui/coreview/programcounter.h b/qtmips_gui/coreview/programcounter.h
index 98b161d..91d1da3 100644
--- a/qtmips_gui/coreview/programcounter.h
+++ b/qtmips_gui/coreview/programcounter.h
@@ -12,7 +12,7 @@ namespace coreview {
class ProgramCounter : public QGraphicsObject {
Q_OBJECT
public:
- ProgramCounter(QtMipsMachine *machine);
+ ProgramCounter(machine::QtMipsMachine *machine);
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 157baf4..6a507fa 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -48,9 +48,9 @@ void MainWindow::start() {
ndialog->show();
}
-void MainWindow::create_core(MachineConfig *config) {
+void MainWindow::create_core(machine::MachineConfig *config) {
// Create machine
- machine = new QtMipsMachine(config);
+ machine = new machine::QtMipsMachine(config);
// Create machine view
coreview = new CoreView(this, machine);
this->setCentralWidget(coreview);
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index bba1cb7..8b9e3e7 100644
--- a/qtmips_gui/mainwindow.h
+++ b/qtmips_gui/mainwindow.h
@@ -21,7 +21,7 @@ public:
~MainWindow();
void start();
- void create_core(MachineConfig *config);
+ void create_core(machine::MachineConfig *config);
public slots:
void new_machine();
@@ -48,7 +48,7 @@ private:
QSettings *settings;
- QtMipsMachine *machine; // Current simulated machine
+ machine::QtMipsMachine *machine; // Current simulated machine
void show_dockwidget(QDockWidget *w);
};
diff --git a/qtmips_gui/newdialog.cpp b/qtmips_gui/newdialog.cpp
index 31f4bb8..bbaa73a 100644
--- a/qtmips_gui/newdialog.cpp
+++ b/qtmips_gui/newdialog.cpp
@@ -46,14 +46,14 @@ void NewDialog::cancel() {
void NewDialog::create() {
MainWindow *prnt = (MainWindow*)parent();
- MachineConfig *mc = new MachineConfig();
+ machine::MachineConfig *mc = new machine::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) {
+ } catch (const machine::QtMipsExceptionInput &e) {
QMessageBox msg(this);
msg.setText(e.msg(false));
msg.setIcon(QMessageBox::Critical);
diff --git a/qtmips_gui/registersdock.cpp b/qtmips_gui/registersdock.cpp
index d038462..20eb9e4 100644
--- a/qtmips_gui/registersdock.cpp
+++ b/qtmips_gui/registersdock.cpp
@@ -30,7 +30,7 @@ RegistersDock::~RegistersDock() {
delete gp[i];
}
-void RegistersDock::setup(QtMipsMachine *machine) {
+void RegistersDock::setup(machine::QtMipsMachine *machine) {
regs = machine->registers();
connect(regs, SIGNAL(pc_update(std::uint32_t)), this, SLOT(pc_changed(std::uint32_t)));
connect(regs, SIGNAL(gp_update(std::uint8_t,std::uint32_t)), this, SLOT(gp_changed(std::uint8_t,std::uint32_t)));
diff --git a/qtmips_gui/registersdock.h b/qtmips_gui/registersdock.h
index 90be659..654983e 100644
--- a/qtmips_gui/registersdock.h
+++ b/qtmips_gui/registersdock.h
@@ -14,7 +14,7 @@ public:
RegistersDock(QWidget *parent);
~RegistersDock();
- void setup(QtMipsMachine *machine);
+ void setup(machine::QtMipsMachine *machine);
private slots:
void pc_changed(std::uint32_t val);
@@ -22,7 +22,7 @@ private slots:
void hi_lo_changed(bool hi, std::uint32_t val);
private:
- const Registers *regs;
+ const machine::Registers *regs;
QScrollArea *widg;
QFormLayout *layout;
diff --git a/qtmips_machine/alu.cpp b/qtmips_machine/alu.cpp
index d6e7254..f8b919b 100644
--- a/qtmips_machine/alu.cpp
+++ b/qtmips_machine/alu.cpp
@@ -1,7 +1,9 @@
#include "alu.h"
#include "qtmipsexception.h"
-std::uint32_t alu_operate(enum AluOp operation, std::uint32_t s, std::uint32_t t, std::uint8_t sa, Registers *regs) {
+using namespace machine;
+
+std::uint32_t machine::alu_operate(enum AluOp operation, std::uint32_t s, std::uint32_t t, std::uint8_t sa, Registers *regs) {
switch(operation) {
case ALU_OP_SLL:
return t << sa;
@@ -67,7 +69,7 @@ std::uint32_t alu_operate(enum AluOp operation, std::uint32_t s, std::uint32_t t
}
}
-QString alu_str(enum AluOp operation, std::uint32_t s, std::uint32_t t, std::uint8_t sa) {
+QString machine::alu_str(enum AluOp operation, std::uint32_t s, std::uint32_t t, std::uint8_t sa) {
// TODO
return QString("");
}
diff --git a/qtmips_machine/alu.h b/qtmips_machine/alu.h
index 4d09013..1f89acf 100644
--- a/qtmips_machine/alu.h
+++ b/qtmips_machine/alu.h
@@ -6,6 +6,8 @@
#include <QObject>
#include <registers.h>
+namespace machine {
+
// TODO Any other operations? We seems to be missing a lot of them.
enum AluOp : std::uint8_t {
ALU_OP_SLL = 0,
@@ -47,6 +49,8 @@ std::uint32_t alu_operate(enum AluOp operation, std::uint32_t s, std::uint32_t t
// Returns string representation of ALU instruction (internally used by Instruction::to_str)
QString alu_str(enum AluOp operation, std::uint32_t s, std::uint32_t t, std::uint8_t sa);
-Q_DECLARE_METATYPE(AluOp)
+}
+
+Q_DECLARE_METATYPE(machine::AluOp)
#endif // ALU_H
diff --git a/qtmips_machine/cache.cpp b/qtmips_machine/cache.cpp
index 05b26b0..152b1c7 100644
--- a/qtmips_machine/cache.cpp
+++ b/qtmips_machine/cache.cpp
@@ -1 +1,3 @@
#include "cache.h"
+
+using namespace machine;
diff --git a/qtmips_machine/cache.h b/qtmips_machine/cache.h
index 280ac05..4b91858 100644
--- a/qtmips_machine/cache.h
+++ b/qtmips_machine/cache.h
@@ -3,6 +3,8 @@
#include "memory.h"
+namespace machine {
+
class Cache : public MemoryAccess {
public:
Cache(Memory *m);
@@ -15,4 +17,6 @@ public:
// TODO other chaches
+}
+
#endif // CACHE_H
diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp
index eba423f..000d76d 100644
--- a/qtmips_machine/core.cpp
+++ b/qtmips_machine/core.cpp
@@ -1,6 +1,8 @@
#include "core.h"
#include "programloader.h"
+using namespace machine;
+
#define DM_SUPPORTED (1L<<0)
#define DM_MEMWRITE (1L<<1)
#define DM_MEMREAD (1L<<2)
diff --git a/qtmips_machine/core.h b/qtmips_machine/core.h
index 07933ab..5c61ddb 100644
--- a/qtmips_machine/core.h
+++ b/qtmips_machine/core.h
@@ -8,6 +8,8 @@
#include "instruction.h"
#include "alu.h"
+namespace machine {
+
class Core : public QObject {
Q_OBJECT
public:
@@ -88,4 +90,6 @@ private:
struct Core::dtMemory dt_m;
};
+}
+
#endif // CORE_H
diff --git a/qtmips_machine/instruction.cpp b/qtmips_machine/instruction.cpp
index b6abebc..a90fd5a 100644
--- a/qtmips_machine/instruction.cpp
+++ b/qtmips_machine/instruction.cpp
@@ -1,6 +1,8 @@
#include "instruction.h"
#include "qtmipsexception.h"
+using namespace machine;
+
struct InstructionMap {
const char *name;
};
diff --git a/qtmips_machine/instruction.h b/qtmips_machine/instruction.h
index 0a87826..fc8dbf5 100644
--- a/qtmips_machine/instruction.h
+++ b/qtmips_machine/instruction.h
@@ -4,6 +4,8 @@
#include <QObject>
#include <qstring.h>
+namespace machine {
+
class Instruction : public QObject {
Q_OBJECT
public:
@@ -34,6 +36,8 @@ private:
std::uint32_t dt;
};
-Q_DECLARE_METATYPE(Instruction)
+}
+
+Q_DECLARE_METATYPE(machine::Instruction)
#endif // INSTRUCTION_H
diff --git a/qtmips_machine/machineconfig.cpp b/qtmips_machine/machineconfig.cpp
index 05624cc..2b4da34 100644
--- a/qtmips_machine/machineconfig.cpp
+++ b/qtmips_machine/machineconfig.cpp
@@ -1,5 +1,7 @@
#include "machineconfig.h"
+using namespace machine;
+
MachineConfig::MachineConfig() {
pipeline = false;
jumppred = false;
diff --git a/qtmips_machine/machineconfig.h b/qtmips_machine/machineconfig.h
index 352e62b..8e58d12 100644
--- a/qtmips_machine/machineconfig.h
+++ b/qtmips_machine/machineconfig.h
@@ -3,6 +3,8 @@
#include <QString>
+namespace machine {
+
class MachineConfig {
public:
MachineConfig();
@@ -37,4 +39,6 @@ private:
QString elf_path;
};
+}
+
#endif // MACHINECONFIG_H
diff --git a/qtmips_machine/memory.cpp b/qtmips_machine/memory.cpp
index 3d711cc..23743d5 100644
--- a/qtmips_machine/memory.cpp
+++ b/qtmips_machine/memory.cpp
@@ -1,5 +1,7 @@
#include "memory.h"
+using namespace machine;
+
// Note about endianness: Current memory implementation is expected to be a big endian.
// But we can be running on little endian so we should do conversion from bytes to word according that.
@@ -157,10 +159,12 @@ bool MemorySection::operator!=(const MemorySection &ms) const {
#error Memory tree have to be higher or in limit equal to two
#endif
+namespace machine {
union MemoryTree {
union MemoryTree *mt;
MemorySection *sec;
};
+}
Memory::Memory() {
this->mt_root = allocate_section_tree();
diff --git a/qtmips_machine/memory.h b/qtmips_machine/memory.h
index 7b14855..73ee534 100644
--- a/qtmips_machine/memory.h
+++ b/qtmips_machine/memory.h
@@ -6,6 +6,8 @@
#include <cstdint>
#include "qtmipsexception.h"
+namespace machine {
+
// Virtual class for common memory access
class MemoryAccess : public QObject {
Q_OBJECT
@@ -34,8 +36,6 @@ signals:
void byte_change(std::uint32_t address, std::uint32_t value);
};
-Q_DECLARE_METATYPE(MemoryAccess::AccessControl)
-
class MemorySection : public MemoryAccess {
public:
MemorySection(std::uint32_t length);
@@ -91,6 +91,9 @@ private:
static union MemoryTree *copy_section_tree(const union MemoryTree*, size_t depth);
};
-Q_DECLARE_METATYPE(Memory)
+}
+
+Q_DECLARE_METATYPE(machine::MemoryAccess::AccessControl)
+Q_DECLARE_METATYPE(machine::Memory)
#endif // MEMORY_H
diff --git a/qtmips_machine/programloader.cpp b/qtmips_machine/programloader.cpp
index bad0a82..4a10540 100644
--- a/qtmips_machine/programloader.cpp
+++ b/qtmips_machine/programloader.cpp
@@ -6,6 +6,8 @@
#include <cstring>
#include "qtmipsexception.h"
+using namespace machine;
+
ProgramLoader::ProgramLoader(const char *file) {
// Initialize elf library
if (elf_version(EV_CURRENT) == EV_NONE)
diff --git a/qtmips_machine/programloader.h b/qtmips_machine/programloader.h
index 7da241c..6c13d18 100644
--- a/qtmips_machine/programloader.h
+++ b/qtmips_machine/programloader.h
@@ -9,6 +9,7 @@
#include <qstring.h>
#include "memory.h"
+namespace machine {
class ProgramLoader {
public:
@@ -27,4 +28,6 @@ private:
QVector<size_t> map; // external index to phdrs index
};
+}
+
#endif // PROGRAM_H
diff --git a/qtmips_machine/qtmipsexception.cpp b/qtmips_machine/qtmipsexception.cpp
index bb852a8..76d0cc6 100644
--- a/qtmips_machine/qtmipsexception.cpp
+++ b/qtmips_machine/qtmipsexception.cpp
@@ -2,6 +2,8 @@
#include <iostream>
#include <cstring>
+using namespace machine;
+
QtMipsException::QtMipsException(QTMIPS_ARGS_COMMON) {
this->reason = reason;
this->ext = ext;
diff --git a/qtmips_machine/qtmipsexception.h b/qtmips_machine/qtmipsexception.h
index cfab81a..3f742ad 100644
--- a/qtmips_machine/qtmipsexception.h
+++ b/qtmips_machine/qtmipsexception.h
@@ -4,7 +4,9 @@
#include <exception>
#include <qstring.h>
-#define QTMIPS_EXCEPTION(TYPE, REASON, EXT) (QtMipsException ## TYPE (QString(REASON), QString(EXT), QString(__FILE__), __LINE__))
+namespace machine {
+
+#define QTMIPS_EXCEPTION(TYPE, REASON, EXT) (machine::QtMipsException ## TYPE (QString(REASON), QString(EXT), QString(__FILE__), __LINE__))
#define QTMIPS_ARGS_COMMON QString reason, QString ext, QString file, int line
// Base exception for all machine ones
@@ -82,4 +84,6 @@ public:
#define SANITY_ASSERT(COND, MSG) do { if (!(COND)) throw QTMIPS_EXCEPTION(Sanity, "Sanity check failed (" #COND ")", MSG); } while (false)
+}
+
#endif // QTMIPSEXCEPTION_H
diff --git a/qtmips_machine/qtmipsmachine.cpp b/qtmips_machine/qtmipsmachine.cpp
index 191a7c7..8d1a46a 100644
--- a/qtmips_machine/qtmipsmachine.cpp
+++ b/qtmips_machine/qtmipsmachine.cpp
@@ -1,6 +1,8 @@
#include "qtmipsmachine.h"
#include "programloader.h"
+using namespace machine;
+
QtMipsMachine::QtMipsMachine(const MachineConfig &cc) {
ProgramLoader program(cc.elf());
diff --git a/qtmips_machine/qtmipsmachine.h b/qtmips_machine/qtmipsmachine.h
index c185f28..15d62e9 100644
--- a/qtmips_machine/qtmipsmachine.h
+++ b/qtmips_machine/qtmipsmachine.h
@@ -11,6 +11,8 @@
#include "core.h"
#include "cache.h"
+namespace machine {
+
class QtMipsMachine : public QObject {
Q_OBJECT
public:
@@ -47,4 +49,6 @@ private:
bool program_ended;
};
+}
+
#endif // QTMIPSMACHINE_H
diff --git a/qtmips_machine/registers.cpp b/qtmips_machine/registers.cpp
index b77b1b7..f8961e1 100644
--- a/qtmips_machine/registers.cpp
+++ b/qtmips_machine/registers.cpp
@@ -1,6 +1,8 @@
#include "registers.h"
#include "qtmipsexception.h"
+using namespace machine;
+
// TODO should this be configurable?
//////////////////////////////////////////////////////////////////////////////
/// Program counter initial value
diff --git a/qtmips_machine/registers.h b/qtmips_machine/registers.h
index 4a693db..fa3e304 100644
--- a/qtmips_machine/registers.h
+++ b/qtmips_machine/registers.h
@@ -4,6 +4,8 @@
#include <QObject>
#include <cstdint>
+namespace machine {
+
class Registers : public QObject {
Q_OBJECT
public:
@@ -35,6 +37,8 @@ private:
std::uint32_t pc; // program counter
};
-Q_DECLARE_METATYPE(Registers)
+}
+
+Q_DECLARE_METATYPE(machine::Registers)
#endif // REGISTERS_H
diff --git a/qtmips_machine/tests/testalu.cpp b/qtmips_machine/tests/testalu.cpp
index 603a610..7668679 100644
--- a/qtmips_machine/tests/testalu.cpp
+++ b/qtmips_machine/tests/testalu.cpp
@@ -2,6 +2,8 @@
#include "alu.h"
#include "qtmipsexception.h"
+using namespace machine;
+
void MachineTests::alu_data() {
QTest::addColumn<AluOp>("op");
QTest::addColumn<std::uint32_t>("s");
diff --git a/qtmips_machine/tests/testcore.cpp b/qtmips_machine/tests/testcore.cpp
index efc06da..0bd18ba 100644
--- a/qtmips_machine/tests/testcore.cpp
+++ b/qtmips_machine/tests/testcore.cpp
@@ -1,6 +1,8 @@
#include "tst_machine.h"
#include "core.h"
+using namespace machine;
+
static void core_regs_data() {
QTest::addColumn<Instruction>("i");
QTest::addColumn<Registers>("init");
diff --git a/qtmips_machine/tests/testinstruction.cpp b/qtmips_machine/tests/testinstruction.cpp
index 4efedac..2cdf119 100644
--- a/qtmips_machine/tests/testinstruction.cpp
+++ b/qtmips_machine/tests/testinstruction.cpp
@@ -1,6 +1,8 @@
#include "tst_machine.h"
#include "instruction.h"
+using namespace machine;
+
// Test that we are correctly encoding instructions in constructor
void MachineTests::instruction() {
QCOMPARE(Instruction(0x00), Instruction(0,0));
diff --git a/qtmips_machine/tests/testmemory.cpp b/qtmips_machine/tests/testmemory.cpp
index f1c6b80..bef1a59 100644
--- a/qtmips_machine/tests/testmemory.cpp
+++ b/qtmips_machine/tests/testmemory.cpp
@@ -1,6 +1,8 @@
#include "tst_machine.h"
#include "memory.h"
+using namespace machine;
+
void MachineTests::memory_data() {
QTest::addColumn<std::uint32_t>("address");
diff --git a/qtmips_machine/tests/testprogramloader.cpp b/qtmips_machine/tests/testprogramloader.cpp
index 7ff1c54..057bf3f 100644
--- a/qtmips_machine/tests/testprogramloader.cpp
+++ b/qtmips_machine/tests/testprogramloader.cpp
@@ -3,6 +3,8 @@
#include "programloader.h"
#include "instruction.h"
+using namespace machine;
+
// This is common program start (initial value of program counter)
#define PC_INIT 0x80020000
diff --git a/qtmips_machine/tests/testregisters.cpp b/qtmips_machine/tests/testregisters.cpp
index b498c11..57a6479 100644
--- a/qtmips_machine/tests/testregisters.cpp
+++ b/qtmips_machine/tests/testregisters.cpp
@@ -2,6 +2,8 @@
#include <qtmipsexception.h>
#include <registers.h>
+using namespace machine;
+
void MachineTests::registers_gp0() {
Registers r;
QCOMPARE(r.read_gp(0), (unsigned)0);