aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/machineconfig.cpp
blob: e479d6661b1f90dd63cae185fde769878e6855bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "machineconfig.h"

using namespace machine;

MachineConfigCache::MachineConfigCache() {
    // TODO
}

MachineConfigCache::MachineConfigCache(const MachineConfigCache *cc) {
    // TODO
}

bool MachineConfigCache::operator==(const MachineConfigCache &c) const {
    // TODO
    return true;
}

bool MachineConfigCache::operator!=(const MachineConfigCache &c) const {
    return !operator==(c);
}

MachineConfig::MachineConfig() {
    pipeline = false;
    delayslot = true;
    hunit = HU_STALL_FORWARD;
}

MachineConfig::MachineConfig(const MachineConfig *cc) {
    pipeline = cc->pipelined();
    delayslot = cc->delay_slot();
    elf_path = cc->elf();
    cch_program = cc->cache_program();
    cch_data = cc->cache_data();
    hunit = cc->hazard_unit();
}

void MachineConfig::set_pipelined(bool v) {
    pipeline = v;
}

void MachineConfig::set_delay_slot(bool v) {
    delayslot = v;
    if (!delayslot)
        pipeline = false;
}

void MachineConfig::set_elf(QString path) {
    elf_path = path;
}

void MachineConfig::set_cache_program(const MachineConfigCache &c) {
    cch_program = c;
}

void MachineConfig::set_cache_data(const MachineConfigCache &c) {
    cch_data = c;
}

void MachineConfig::set_hazard_unit(enum MachineConfig::HazardUnit hu)  {
    hunit = hu;
}

bool MachineConfig::pipelined() const {
    return pipeline;
}

bool MachineConfig::delay_slot() const {
    return delayslot;
}

QString MachineConfig::elf() const {
    return elf_path;
}

MachineConfigCache MachineConfig::cache_program() const {
    return cch_program;
}

MachineConfigCache MachineConfig::cache_data() const {
    return cch_data;
}

enum MachineConfig::HazardUnit MachineConfig::hazard_unit() const {
    return hunit;
}

bool MachineConfig::operator==(const MachineConfig &c) const {
#define CMP(GETTER) (GETTER)() == (c.GETTER)()
    return CMP(pipelined) && \
            CMP(delay_slot) && \
            CMP(elf) && \
            CMP(cache_program) && \
            CMP(cache_data) && \
            CMP(hazard_unit);
#undef CMP
}

bool MachineConfig::operator!=(const MachineConfig &c) const {
    return !operator==(c);
}