-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcpupane.h
126 lines (90 loc) · 3.63 KB
/
cpupane.h
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
// File: cpupane.h
/*
Pep8-1 is a virtual machine for writing machine language and assembly
language programs.
Copyright (C) 2009 J. Stanley Warford, Pepperdine University
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef CPUPANE_H
#define CPUPANE_H
#include <QWidget>
#include "enu.h"
namespace Ui {
class CpuPane;
}
class CpuPane : public QWidget {
Q_OBJECT
Q_DISABLE_COPY(CpuPane)
public:
explicit CpuPane(QWidget *parent = 0);
virtual ~CpuPane();
void updateCpu();
// Post: Updates CPU pane labels
void clearCpu();
// Post: The CPU pane labels are blanked and the CPU registers are cleared
void runClicked();
// Post: All of the debug checkboxes are unclicked
void setDebugState(bool b);
// Post: if b is true, checkboxes are set to disabled, and vice versa
void traceTraps(bool b);
// Post: Trace traps checkbox is checked if b, unchecked else
void setButtonsEnabled(bool b);
// Post: if b is true, buttons are enabled, and vice versa
void runWithBatch();
// Runs the simulator through with batch input
void runWithTerminal();
// Runs the simulator through with terminal i/o
void resumeWithBatch();
// Resumes the simulator with batch input
void resumeWithTerminal();
// Resumes the simulator with terminal input
void singleStepWithBatch();
// Single steps the simulator with batch input
void singleStepWithTerminal();
// Single steps the simulator with terminal input
void trapLookahead();
// Looks ahead to the next instruction to determine if we are trapping
void interruptExecution();
// Post: interruptExecutionFlag is set to true
void highlightOnFocus();
// Post: Highlights the label based on the label window color saved in the UI file
Enu::EWaiting waitingState();
// Post: Returns the waiting state of the simulation (for terminal io)
bool singleStepHasFocus();
// Post: returns if the single step is enabled
bool hasFocus();
// Post: Returns if the single step button has focus
bool isSimulating();
// Returns if the CPU is currently simulating - this can happen when the enter key is
// held down to single step quickly, causing multiple enter events to fire per single step
// This is used to avoid that.
void giveSingleStepFocus();
// Gives the single step button focus - this is used when we press 'enter' in other panes
// and we want to give the cpu pane focus for ease of navigation
private:
Ui::CpuPane *ui;
bool interruptExecutionFlag; // Used to interrupt execution by the user
Enu::EWaiting waiting; // Used to store terminal IO waiting for input state
void mousePressEvent(QMouseEvent *);
bool isCurrentlySimulating;
private slots:
void singleStepButton();
signals:
void resumeButtonClicked();
void singleStepButtonClicked();
void updateSimulationView();
void executionComplete();
void appendOutput(QString);
void vonNeumannStepped();
void waitingForInput();
};
#endif // CPUPANE_H