aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview.h
blob: 4852e2563571d16fd0c39112cbba03272c756653 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// SPDX-License-Identifier: GPL-2.0+
/*******************************************************************************
 * QtMips - MIPS 32-bit Architecture Subset Simulator
 *
 * Implemented to support following courses:
 *
 *   B35APO - Computer Architectures
 *   https://cw.fel.cvut.cz/wiki/courses/b35apo
 *
 *   B4M35PAP - Advanced Computer Architectures
 *   https://cw.fel.cvut.cz/wiki/courses/b4m35pap/start
 *
 * Copyright (c) 2017-2019 Karel Koci<cynerd@email.cz>
 * Copyright (c) 2019      Pavel Pisa <pisa@cmp.felk.cvut.cz>
 *
 * Faculty of Electrical Engineering (http://www.fel.cvut.cz)
 * Czech Technical University        (http://www.cvut.cz/)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 ******************************************************************************/

#ifndef COREVIEW_H
#define COREVIEW_H

#include <QGraphicsView>
#include <QGraphicsScene>
#include "qtmipsmachine.h"
#include "graphicsview.h"
#include "coreview/connection.h"
#include "coreview/programcounter.h"
#include "coreview/multiplexer.h"
#include "coreview/latch.h"
#include "coreview/alu.h"
#include "coreview/adder.h"
#include "coreview/memory.h"
#include "coreview/registers.h"
#include "coreview/instructionview.h"
#include "coreview/junction.h"
#include "coreview/constant.h"
#include "coreview/logicblock.h"
#include "coreview/and.h"
#include "coreview/value.h"

class CoreViewScene : public QGraphicsScene {
    Q_OBJECT
public:
    CoreViewScene(machine::QtMipsMachine *machine);
    ~CoreViewScene();

signals:
    void request_registers();
    void request_data_memory();
    void request_program_memory();
    void request_jump_to_program_counter(std::uint32_t addr);
    void request_cache_program();
    void request_cache_data();
    void request_peripherals();
    void request_terminal();

protected:
    coreview::ProgramMemory *mem_program;
    coreview::DataMemory *mem_data;
    coreview::Registers *regs;
    coreview::Alu *alu;
    coreview::LogicBlock *peripherals;
    coreview::LogicBlock *terminal;
    struct {
        coreview::ProgramCounter *pc;
        coreview::Latch *latch;
        coreview::Adder *adder;
        coreview::Constant *adder_4;
        coreview::Junction *junc_pc, *junc_pc_4;
        coreview::Multiplexer *multiplex;
    } ft;
    struct {
        coreview::LogicBlock *ctl_block, *sign_ext, *shift2, *cmp;
        coreview::Adder *add;
        coreview::Junction *j_sign_ext;
        coreview::And *and_branch;
        coreview::Junction *j_inst_up, *j_inst_down;
        coreview::Bus *instr_bus;
    } dc;
    struct {
        coreview::Junction *j_mux;
        coreview::Multiplexer *mux_imm, *mux_regdest;
    } ex;
    struct {
        coreview::Junction *j_addr;
    } mm;
    struct {
        coreview::Multiplexer *mem_or_reg;
        coreview::Junction *j_reg_write_val;
    } wb;
    struct {
        coreview::Multiplexer *mux_alu_reg_a;
        coreview::Multiplexer *mux_alu_reg_b;
        coreview::Junction *j_alu_out;
    } hu;

    coreview::Connection *new_connection(const coreview::Connector*, const coreview::Connector*);
    coreview::Bus *new_bus(const coreview::Connector*, const coreview::Connector*, unsigned width = 4);
    coreview::Signal *new_signal(const coreview::Connector*, const coreview::Connector*);
    QGraphicsSimpleTextItem *new_label(const QString &str, qreal x, qreal y);
    coreview::Connection *pc2pc_latch;
    coreview::Connection *pc_latch2pc_joint, *pc_joint2pc_adder, *pc_joint2mem;
    coreview::Connection *pc_multiplexer2pc;
};

class CoreViewSceneSimple : public CoreViewScene {
public:
    CoreViewSceneSimple(machine::QtMipsMachine *machine);

private:
    coreview::InstructionView *instr_prim, *instr_delay;
    coreview::Latch *delay_slot_latch;
};

class CoreViewScenePipelined : public CoreViewScene {
public:
    CoreViewScenePipelined(machine::QtMipsMachine *machine);

private:
    coreview::Latch *latch_if_id, *latch_id_ex, *latch_ex_mem, *latch_mem_wb;
    coreview::InstructionView *inst_fetch, *inst_dec, *inst_exec, *inst_mem, *inst_wrb;
    coreview::LogicBlock *hazard_unit;
};

#else

class CoreViewScene;
class CoreViewSceneSimple;
class CoreViewScenePipelined;

#endif // COREVIEW_H