-
Notifications
You must be signed in to change notification settings - Fork 0
/
sq_pipelineSimulatorGUI.py
executable file
·522 lines (436 loc) · 38.4 KB
/
sq_pipelineSimulatorGUI.py
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""CPU Pipeline algorithm GUI simulator.
This script simulates the CPU pipeline algorithm of a emu 8086 processor.
"""
__author__ = "Altin Ukshini"
__copyright__ = "Copyright (c) 2018, Altin Ukshini"
__license__ = "GPL v3.0"
__version__ = "1.0"
__maintainer__ = "Altin Ukshini"
__email__ = "[email protected]"
__status__ = "Development"
__credits__ = "https://github.com/cvanoort/CPUPipelineSimulation"
import os
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_HelpDialog(object):
def setupUi(self, HelpDialog):
HelpDialog.setObjectName("HelpDialog")
HelpDialog.resize(640, 437)
self.helpContent = QtWidgets.QTextBrowser(HelpDialog)
self.helpContent.setGeometry(QtCore.QRect(10, 10, 621, 381))
self.helpContent.setObjectName("helpContent")
self.okButton = QtWidgets.QPushButton(HelpDialog)
self.okButton.setGeometry(QtCore.QRect(540, 400, 92, 30))
self.okButton.setObjectName("okButton")
self.actionOK = QtWidgets.QAction(HelpDialog)
self.actionOK.setObjectName("actionOK")
self.okButton.clicked.connect(HelpDialog.accept)
self.retranslateUi(HelpDialog)
QtCore.QMetaObject.connectSlotsByName(HelpDialog)
def retranslateUi(self, HelpDialog):
_translate = QtCore.QCoreApplication.translate
HelpDialog.setWindowTitle(_translate("HelpDialog", "Dialog"))
self.helpContent.setHtml(_translate("HelpDialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'Open Sans\'; font-size:10pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:11pt; font-weight:600;\">Simulatori merr katër argumente kryesore:</span></p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- <span style=\" font-weight:600;\">Faza e operandit:</span> Faza në të cilën lexohet operandi (p.sh., faza 1 (DI) prej 0-5)</p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- <span style=\" font-weight:600;\">Faza e rezultatit:</span> Faza në të cilën rezultatet janë të gatshme për shkrim (p.sh., Faza 5 (WO) prej 0-5)</p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- <span style=\" font-weight:600;\">Fillimi i instruksionit:</span> Instruksioni fillestarë për grafin e simulimit.</p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- <span style=\" font-weight:600;\">Përfundimi i instruksionit:</span> Instruksioni i fundit në paraqitjen e grafit (0 ose < fillimi i instruksionit, nënkupton që nuk do të ketë paraqitje grafike)</p>\n""<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:11pt; font-weight:600;\">Argumentet tjera:</span></p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- <span style=\" font-weight:600;\">Pipeline:</span> Fazat/ciklet e pipeline. Duhet të jetë më gjatë se 3 faza (p.sh: FI, DI, EI), ose FI,DI,CO,FO,EI,WO. Fazat duhet të ndahen me presje. </p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- <span style=\" font-weight:600;\">Madhësia e regjistrit:</span> Numri i regjistrit (madhësia) </p>\n""<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:11pt; font-weight:600;\">Trace:</span></p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Çdo rresht në trace përmban numra, që reprezentojnë regjistrat për operand 1, operand 2, dhe result. Ne rast të -1 në ndonjërën nga pozitat, nënkuptohet që instruksioni nuk do të marr parasysh atë operand, ose nuk do të paraqesë ndonjë rezultat. Operandët ose rezultatet nuk duhet të jenë më të vogla se -1 ose më të mëdha se madhësia e regjistrit (regjistri - 1)</p>\n""<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:11pt; font-weight:600;\">Rezultatit:</span></p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Dritarja kryesore e rezultatit paraqet grafin dhe analizat e simulimit, përderisa rezultati i dytë paraqet statusin e regjistrit gjatë ekzekutimit.<br/></p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:11pt; font-weight:600;\">Shembull i MIPS pipeline (5 faza):</span></p>\n""<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Ndrysho fazën e rezultatit në \"4\" dhe pipeline në \"IF,ID,EX,ME,WB\"</p>\n""<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.okButton.setText(_translate("HelpDialog", "OK"))
self.actionOK.setText(_translate("HelpDialog", "OK"))
self.actionOK.setToolTip(_translate("HelpDialog", "OK"))
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(850, 569)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 99, 221, 401))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.verticalLayout.setObjectName("verticalLayout")
self.label_9 = QtWidgets.QLabel(self.verticalLayoutWidget)
self.label_9.setObjectName("label_9")
self.verticalLayout.addWidget(self.label_9)
self.traceText = QtWidgets.QPlainTextEdit(self.verticalLayoutWidget)
self.traceText.setObjectName("traceText")
self.verticalLayout.addWidget(self.traceText)
self.gridLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.gridLayoutWidget.setGeometry(QtCore.QRect(490, 90, 351, 61))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setObjectName("gridLayout")
self.label_6 = QtWidgets.QLabel(self.gridLayoutWidget)
self.label_6.setObjectName("label_6")
self.gridLayout.addWidget(self.label_6, 0, 0, 1, 1)
self.registernumbers = QtWidgets.QSpinBox(self.gridLayoutWidget)
self.registernumbers.setMinimum(46)
self.registernumbers.setMaximum(1000)
self.registernumbers.setObjectName("registernumbers")
self.gridLayout.addWidget(self.registernumbers, 1, 1, 1, 1)
self.label_8 = QtWidgets.QLabel(self.gridLayoutWidget)
self.label_8.setObjectName("label_8")
self.gridLayout.addWidget(self.label_8, 0, 1, 1, 1)
self.pipelineStages = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.pipelineStages.setObjectName("pipelineStages")
self.gridLayout.addWidget(self.pipelineStages, 1, 0, 1, 1)
self.verticalLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget_2.setGeometry(QtCore.QRect(10, 10, 831, 61))
self.verticalLayoutWidget_2.setObjectName("verticalLayoutWidget_2")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_2)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.label_5 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
self.label_5.setObjectName("label_5")
self.verticalLayout_2.addWidget(self.label_5)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.operandstage = QtWidgets.QSpinBox(self.verticalLayoutWidget_2)
self.operandstage.setMaximum(5)
self.operandstage.setProperty("value", 1)
self.operandstage.setObjectName("operandstage")
self.horizontalLayout.addWidget(self.operandstage)
self.label = QtWidgets.QLabel(self.verticalLayoutWidget_2)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.resultstage = QtWidgets.QSpinBox(self.verticalLayoutWidget_2)
self.resultstage.setMaximum(5)
self.resultstage.setProperty("value", 4)
self.resultstage.setObjectName("resultstage")
self.horizontalLayout.addWidget(self.resultstage)
self.label_4 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
self.label_4.setObjectName("label_4")
self.horizontalLayout.addWidget(self.label_4)
self.startat = QtWidgets.QSpinBox(self.verticalLayoutWidget_2)
self.startat.setMaximum(1000)
self.startat.setProperty("value", 1)
self.startat.setObjectName("startat")
self.horizontalLayout.addWidget(self.startat)
self.label_2 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
self.label_2.setObjectName("label_2")
self.horizontalLayout.addWidget(self.label_2)
self.endat = QtWidgets.QSpinBox(self.verticalLayoutWidget_2)
self.endat.setMaximum(1000)
self.endat.setProperty("value", 10)
self.endat.setObjectName("endat")
self.horizontalLayout.addWidget(self.endat)
self.label_3 = QtWidgets.QLabel(self.verticalLayoutWidget_2)
self.label_3.setObjectName("label_3")
self.horizontalLayout.addWidget(self.label_3)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.horizontalLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(7, 510, 831, 51))
self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_2)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.simulateButton = QtWidgets.QPushButton(self.horizontalLayoutWidget_2)
self.simulateButton.setObjectName("simulateButton")
self.horizontalLayout_2.addWidget(self.simulateButton)
self.loadTrace = QtWidgets.QPushButton(self.horizontalLayoutWidget_2)
self.loadTrace.setObjectName("loadTrace")
self.horizontalLayout_2.addWidget(self.loadTrace)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.helpButton = QtWidgets.QPushButton(self.horizontalLayoutWidget_2)
self.helpButton.setObjectName("helpButton")
self.horizontalLayout_2.addWidget(self.helpButton)
self.quitButton = QtWidgets.QPushButton(self.horizontalLayoutWidget_2)
self.quitButton.setFlat(False)
self.quitButton.setObjectName("quitButton")
self.horizontalLayout_2.addWidget(self.quitButton)
self.verticalLayoutWidget_3 = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget_3.setGeometry(QtCore.QRect(240, 140, 601, 251))
self.verticalLayoutWidget_3.setObjectName("verticalLayoutWidget_3")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_3)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.label_10 = QtWidgets.QLabel(self.verticalLayoutWidget_3)
self.label_10.setObjectName("label_10")
self.verticalLayout_3.addWidget(self.label_10)
self.textOutput = QtWidgets.QTextBrowser(self.verticalLayoutWidget_3)
font = QtGui.QFont()
font.setFamily("Monospace")
self.textOutput.setFont(font)
self.textOutput.setObjectName("textOutput")
self.textOutput.ensureCursorVisible()
self.verticalLayout_3.addWidget(self.textOutput)
self.gridLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
self.gridLayoutWidget_2.setGeometry(QtCore.QRect(1060, 140, 160, 80))
self.gridLayoutWidget_2.setObjectName("gridLayoutWidget_2")
self.gridLayout_3 = QtWidgets.QGridLayout(self.gridLayoutWidget_2)
self.gridLayout_3.setObjectName("gridLayout_3")
self.verticalLayoutWidget_4 = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget_4.setGeometry(QtCore.QRect(240, 410, 601, 91))
self.verticalLayoutWidget_4.setObjectName("verticalLayoutWidget_4")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_4)
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.textOutput2 = QtWidgets.QTextBrowser(self.verticalLayoutWidget_4)
self.textOutput2.setObjectName("textOutput2")
self.verticalLayout_4.addWidget(self.textOutput2)
MainWindow.setCentralWidget(self.centralwidget)
self.actionQuit = QtWidgets.QAction(MainWindow)
self.actionQuit.setObjectName("actionQuit")
self.actionSimulate = QtWidgets.QAction(MainWindow)
self.actionSimulate.setObjectName("actionSimulate")
self.actionHelp = QtWidgets.QAction(MainWindow)
self.actionHelp.setObjectName("actionHelp")
self.helpButton.clicked.connect(self.openHelp)
self.simulateButton.clicked.connect(self.simulateCPUPipeline)
self.quitButton.clicked.connect(QtCore.QCoreApplication.instance().quit)
self.actionLoadTrace = QtWidgets.QAction(MainWindow)
self.actionLoadTrace.setObjectName("actionLoadTrace")
self.loadTrace.clicked.connect(self.loadTraceLines)
MainWindow.setCentralWidget(self.centralwidget)
self.actionQuit = QtWidgets.QAction(MainWindow)
self.actionQuit.setObjectName("actionQuit")
self.actionSimulate = QtWidgets.QAction(MainWindow)
self.actionSimulate.setObjectName("actionSimulate")
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def openHelp(self):
HelpDialog = QtWidgets.QDialog()
ui2 = Ui_HelpDialog()
ui2.setupUi(HelpDialog)
HelpDialog.exec_()
def loadTraceLines(self):
self.traceText.setProperty("plainText", "-1 -1 13\n" "-1 -1 13\n""-1 5 45\n""45 3 44\n""-1 5 3\n""-1 -1 0\n""-1 -1 0\n""-1 -1 12\n""13 0 13\n""-1 -1 -1\n""-1 3 0\n""0 0 44\n""-1 -1 -1\n""-1 0 7\n""-1 7 44\n""44 -1 0\n""0 -1 44\n""-1 -1 -1\n""-1 -1 6\n""-1 -1 44\n""4 -1 4\n""44 4 -1\n""-1 -1 -1\n""15 4 -1\n""4 -1 4\n""14 4 -1\n""4 -1 4\n""13 4 -1\n""4 -1 4\n""7 -1 13\n""12 4 -1\n""4 -1 4\n""6 -1 12\n""5 4 -1\n""4 -1 4\n""3 4 -1\n""4 -1 4\n""4 -1 4\n""-1 7 44\n""44 -1 0\n""0 -1 44\n""-1 -1 -1\n""-1 7 5\n""5 -1 44\n""-1 -1 -1\n""-1 -1 45\n""-1 45 45\n""5 45 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 2\n""2 2 44\n""-1 -1 -1\n""-1 2 12\n""12 -1 12\n""-1 -1 45\n""-1 45 45\n""5 45 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 2\n""2 2 44\n""-1 -1 -1\n""-1 2 0\n""5 0 44\n""-1 -1 -1\n""-1 -1 45\n""-1 45 45\n""5 45 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 2\n""2 2 44\n""-1 -1 -1\n""-1 2 45\n""45 -1 44\n""44 2 -1\n""5 -1 44\n""12 -1 12\n""-1 -1 -1\n""-1 13 45\n""45 -1 44\n""-1 13 44\n""44 -1 5\n""-1 -1 -1\n""12 -1 3\n""-1 13 2\n""3 3 44\n""-1 -1 -1\n""-1 3 0\n""-1 0 45\n""45 -1 44\n""-1 -1 -1\n""-1 3 3\n""3 3 44\n""-1 -1 -1\n""4 -1 4\n""-1 4 3\n""4 -1 4\n""-1 4 5\n""4 -1 4\n""-1 4 12\n""4 -1 4\n""-1 4 13\n""4 -1 4\n""-1 4 14\n""4 -1 4\n""-1 4 15\n""4 -1 4\n""-1 4 44\n""4 -1 4\n""44 -1 -1\n""-1 -1 -1\n""12 -1 12\n""3 -1 3\n""-1 5 45\n""12 45 44\n""-1 -1 -1\n""-1 5 0\n""-1 0 45\n""45 -1 44\n""-1 -1 -1\n""-1 0 0\n""-1 0 0\n""0 -1 0\n""0 -1 44\n""-1 -1 -1\n""-1 5 11\n""11 11 44\n""-1 -1 -1\n""-1 5 1\n""-1 5 -1\n""1 5 -1\n""-1 -1 -1\n""-1 5 3\n""-1 3 0\n""0 0 44\n""-1 -1 -1\n""-1 0 7\n""-1 7 45\n""45 -1 44\n""-1 -1 -1\n""-1 7 1\n""1 -1 44\n""-1 -1 -1\n""-1 -1 0\n""-1 -1 -1\n""0 1 0\n""1 0 44\n""-1 -1 -1\n""1 -1 13\n""-1 -1 45\n""-1 45 45\n""45 13 44\n""0 5 -1\n""-1 -1 -1\n""-1 -1 44\n""-1 44 2\n""2 2 44\n""-1 -1 -1\n""-1 2 10\n""10 10 44\n""-1 -1 -1\n""13 -1 13\n""-1 5 45\n""45 13 44\n""-1 -1 -1\n""-1 5 45\n""45 -1 44\n""44 5 -1\n""-1 5 45\n""45 -1 44\n""44 5 -1\n""-1 5 0\n""-1 5 45\n""45 0 44\n""-1 -1 -1\n""-1 5 1\n""-1 -1 6\n""-1 -1 -1\n""-1 -1 -1\n""-1 1 45\n""45 -1 44\n""-1 -1 -1\n""-1 1 0\n""0 0 44\n""-1 -1 -1\n""-1 0 45\n""45 -1 44\n""-1 -1 -1\n""6 -1 6\n""1 -1 1\n""-1 5 45\n""6 45 44\n""-1 -1 -1\n""-1 5 1\n""-1 5 -1\n""1 5 -1\n""-1 -1 -1\n""-1 5 2\n""-1 2 0\n""0 0 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 9\n""-1 0 12\n""-1 2 14\n""9 9 44\n""-1 -1 -1\n""-1 12 44\n""44 -1 2\n""2 -1 44\n""-1 -1 -1\n""-1 5 45\n""45 -1 44\n""-1 -1 -1\n""-1 5 1\n""-1 1 6\n""6 6 44\n""-1 -1 -1\n""-1 -1 -1\n""-1 12 44\n""44 -1 0\n""0 -1 44\n""-1 -1 -1\n""0 -1 44\n""-1 -1 -1\n""0 -1 44\n""-1 -1 -1\n""-1 -1 2\n""12 -1 7\n""-1 -1 44\n""4 -1 4\n""44 4 -1\n""-1 -1 -1\n""14 4 -1\n""4 -1 4\n""2 -1 14\n""13 4 -1\n""4 -1 4\n""6 -1 13\n""12 4 -1\n""4 -1 4\n""5 4 -1\n""4 -1 4\n""7 -1 5\n""3 4 -1\n""4 -1 4\n""-1 7 44\n""44 -1 0\n""0 -1 44\n""-1 -1 -1\n""-1 7 3\n""-1 -1 45\n""-1 45 45\n""3 45 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 2\n""2 2 44\n""-1 -1 -1\n""-1 2 45\n""45 3 44\n""-1 -1 -1\n""13 13 44\n""-1 -1 -1\n""-1 13 1\n""1 1 44\n""-1 -1 -1\n""-1 1 2\n""-1 2 45\n""45 -1 44\n""-1 -1 -1\n""-1 1 1\n""1 1 44\n""-1 -1 -1\n""-1 1 2\n""-1 2 45\n""45 -1 44\n""-1 -1 -1\n""-1 2 44\n""44 -1 0\n""-1 5 45\n""0 45 44\n""-1 -1 -1\n""-1 2 5\n""-1 -1 45\n""-1 45 45\n""5 45 44\n""-1 -1 -1\n""5 -1 0\n""0 -1 0\n""0 5 0\n""0 -1 0\n""0 -1 0\n""-1 0 2\n""-1 0 12\n""2 2 44\n""-1 -1 -1\n""-1 2 45\n""45 5 44\n""-1 -1 -1\n""-1 -1 -1\n""-1 2 12\n""-1 -1 44\n""5 44 -1\n""-1 -1 44\n""2 44 -1\n""12 -1 0\n""0 0 14\n""14 -1 14\n""14 -1 13\n""-1 -1 44\n""-1 44 44\n""13 44 13\n""-1 2 45\n""45 5 44\n""-1 -1 -1\n""-1 -1 45\n""-1 45 45\n""3 45 44\n""-1 -1 -1\n""3 -1 0\n""0 -1 0\n""0 3 0\n""0 -1 0\n""0 -1 0\n""-1 0 2\n""-1 0 5\n""2 2 44\n""-1 -1 -1\n""-1 2 45\n""3 45 44\n""-1 -1 -1\n""-1 -1 44\n""3 44 -1\n""-1 -1 44\n""2 44 -1\n""12 2 -1\n""-1 13 2\n""-1 13 7\n""2 -1 44\n""-1 -1 -1\n""3 -1 44\n""-1 -1 -1\n""2 -1 44\n""2 -1 1\n""3 -1 8\n""-1 -1 -1\n""-1 -1 44\n""-1 44 10\n""-1 -1 44\n""-1 44 6\n""8 10 1\n""-1 1 44\n""44 -1 0\n""0 6 9\n""-1 -1 45\n""-1 45 45\n""9 45 44\n""-1 -1 -1\n""-1 1 44\n""44 -1 0\n""0 6 0\n""-1 -1 45\n""-1 45 45\n""0 45 44\n""-1 -1 -1\n""7 -1 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 6\n""7 -1 0\n""0 -1 0\n""-1 -1 -1\n""0 6 2\n""8 6 1\n""-1 2 0\n""0 1 -1\n""-1 2 0\n""0 0 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 0\n""14 0 44\n""3 44 -1\n""-1 -1 -1\n""-1 -1 0\n""3 2 -1\n""7 1 -1\n""-1 -1 -1\n""-1 4 3\n""4 -1 4\n""-1 4 5\n""4 -1 4\n""-1 4 12\n""4 -1 4\n""-1 4 13\n""4 -1 4\n""-1 4 14\n""4 -1 4\n""-1 4 44\n""4 -1 4\n""44 -1 -1\n""0 0 44\n""-1 -1 -1\n""12 -1 7\n""-1 -1 44\n""4 -1 4\n""44 4 -1\n""-1 -1 -1\n""15 4 -1\n""4 -1 4\n""7 -1 15\n""14 4 -1\n""4 -1 4\n""13 4 -1\n""4 -1 4\n""12 4 -1\n""4 -1 4\n""5 4 -1\n""4 -1 4\n""3 4 -1\n""4 -1 4\n""4 -1 4\n""-1 7 45\n""45 -1 44\n""-1 -1 -1\n""-1 15 45\n""45 -1 44\n""-1 -1 -1\n""-1 15 3\n""-1 -1 45\n""-1 45 45\n""3 45 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 2\n""2 2 44\n""-1 -1 -1\n""-1 2 5\n""5 5 44\n""-1 -1 -1\n""4 -1 4\n""-1 4 3\n""4 -1 4\n""-1 4 5\n""4 -1 4\n""-1 4 12\n""4 -1 4\n""-1 4 13\n""4 -1 4\n""-1 4 14\n""4 -1 4\n""-1 4 15\n""4 -1 4\n""-1 4 44\n""4 -1 4\n""44 -1 -1\n""-1 12 45\n""45 -1 44\n""-1 -1 -1\n""-1 12 3\n""3 -1 44\n""-1 -1 -1\n""-1 -1 45\n""-1 45 45\n""3 45 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 2\n""2 2 44\n""-1 -1 -1\n""-1 2 0\n""0 -1 0\n""-1 5 2\n""0 2 -1\n""-1 -1 -1\n""-1 14 45\n""45 -1 44\n""-1 -1 -1\n""-1 5 0\n""-1 12 44\n""44 -1 1\n""12 -1 7\n""-1 0 2\n""-1 0 6\n""-1 -1 44\n""4 -1 4\n""44 4 -1\n""-1 -1 -1\n""15 4 -1\n""4 -1 4\n""2 -1 15\n""14 4 -1\n""4 -1 4\n""6 -1 14\n""13 4 -1\n""4 -1 4\n""12 4 -1\n""4 -1 4\n""5 4 -1\n""4 -1 4\n""7 -1 5\n""3 4 -1\n""4 -1 4\n""4 -1 4\n""-1 7 45\n""45 -1 44\n""1 4 -1\n""-1 -1 -1\n""-1 7 3\n""-1 -1 45\n""-1 45 45\n""3 45 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 2\n""2 2 44\n""-1 -1 -1\n""-1 2 45\n""45 3 44\n""-1 -1 -1\n""-1 5 45\n""45 -1 44\n""-1 -1 -1\n""3 -1 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 13\n""13 13 44\n""-1 -1 -1\n""-1 13 0\n""-1 -1 44\n""0 44 -1\n""5 13 -1\n""-1 13 -1\n""-1 5 44\n""44 -1 0\n""0 -1 44\n""-1 -1 -1\n""-1 -1 0\n""-1 -1 -1\n""0 13 -1\n""5 -1 7\n""-1 -1 44\n""4 -1 4\n""44 4 -1\n""-1 -1 -1\n""12 4 -1\n""4 -1 4\n""5 4 -1\n""4 -1 4\n""-1 -1 5\n""3 4 -1\n""4 -1 4\n""-1 -1 3\n""4 -1 4\n""-1 4 12\n""7 4 -1\n""12 -1 7\n""-1 -1 44\n""4 -1 4\n""44 4 -1\n""-1 -1 -1\n""7 -1 0\n""-1 7 -1\n""-1 7 -1\n""-1 4 44\n""4 -1 4\n""44 -1 -1\n""-1 4 7\n""12 -1 2\n""-1 -1 6\n""-1 -1 44\n""4 -1 4\n""44 4 -1\n""-1 -1 -1\n""15 4 -1\n""4 -1 4\n""6 -1 15\n""2 -1 6\n""14 4 -1\n""4 -1 4\n""2 -1 14\n""13 4 -1\n""4 -1 4\n""12 4 -1\n""4 -1 4\n""5 4 -1\n""4 -1 4\n""3 4 -1\n""4 -1 4\n""4 -1 4\n""7 4 -1\n""-1 -1 44\n""4 -1 4\n""44 4 -1\n""15 -1 -1\n""4 -1 4\n""-1 7 0\n""6 -1 2\n""0 0 44\n""-1 -1 -1\n""-1 0 45\n""45 -1 44\n""-1 -1 -1\n""-1 0 6\n""2 -1 7\n""-1 -1 44\n""4 -1 4\n""44 4 -1\n""-1 -1 -1\n""12 4 -1\n""4 -1 4\n""6 -1 12\n""12 -1 12\n""5 4 -1\n""4 -1 4\n""7 -1 5\n""3 4 -1\n""4 -1 4\n""-1 7 7\n""6 -1 3\n""7 7 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 6\n""6 6 44\n""-1 -1 -1\n""-1 6 0\n""-1 -1 44\n""0 44 -1\n""3 -1 2\n""3 -1 3\n""-1 -1 0\n""2 -1 2\n""3 -1 1\n""-1 6 -1\n""-1 6 -1\n""2 -1 2\n""0 1 0\n""-1 5 45\n""45 -1 44\n""12 6 -1\n""2 6 44\n""0 44 -1\n""-1 -1 -1\n""-1 6 -1\n""-1 6 -1\n""6 5 -1\n""-1 -1 -1\n""6 5 -1\n""12 5 -1\n""-1 4 3\n""4 -1 4\n""-1 4 5\n""4 -1 4\n""-1 4 12\n""4 -1 4\n""-1 4 44\n""4 -1 4\n""44 -1 -1\n""-1 -1 0\n""4 -1 4\n""-1 4 44\n""4 -1 4\n""44 -1 -1\n""0 4 -1\n""0 -1 0\n""-1 -1 -1\n""-1 4 11\n""11 11 44\n""-1 -1 -1\n""-1 4 2\n""-1 2 0\n""0 0 44\n""-1 -1 -1\n""-1 0 44\n""44 -1 0\n""0 -1 1\n""-1 0 44\n""44 -1 0\n""1 4 -1\n""0 0 44\n""-1 -1 -1\n""0 -1 0\n""-1 4 -1\n""0 -1 0\n""0 4 -1\n""-1 4 3\n""-1 4 1\n""-1 4 2\n""1 3 44\n""44 -1 0\n""0 -1 44\n""-1 -1 -1\n""0 -1 44\n""-1 -1 -1\n""0 -1 44\n""-1 -1 -1\n""-1 4 45\n""45 -1 44\n""44 4 -1\n""-1 4 0\n""-1 4 45\n""45 0 44\n""-1 -1 -1\n""-1 4 3\n""-1 4 1\n""-1 4 2\n""1 3 44\n""44 -1 0\n""0 -1 44\n""-1 -1 -1\n""0 -1 44\n""-1 -1 -1\n""0 -1 44\n""-1 -1 -1\n""-1 4 45\n""45 -1 44\n""44 4 -1\n""-1 4 0\n""-1 4 45\n""45 0 44\n""-1 -1 -1\n""-1 -1 -1\n""-1 4 0\n""4 -1 4\n""-1 4 3\n""4 -1 4\n""-1 4 5\n""4 -1 4\n""-1 4 12\n""4 -1 4\n""-1 4 13\n""4 -1 4\n""-1 4 14\n""4 -1 4\n""-1 4 15\n""4 -1 4\n""-1 4 44\n""4 -1 4\n""44 -1 -1\n""-1 4 8\n""8 8 44\n""-1 -1 -1\n""-1 -1 9\n""9 8 6\n""9 -1 10\n""6 6 44\n""-1 -1 -1\n""-1 -1 7\n""-1 -1 11\n""-1 -1 -1\n""7 -1 1\n""11 -1 0\n""0 1 0\n""0 6 44\n""-1 -1 -1\n""0 -1 0\n""6 0 6\n""-1 8 0\n""0 10 0\n""0 -1 0\n""1 0 2\n""2 -1 44\n""-1 -1 -1\n""2 -1 44\n""-1 -1 -1\n""2 -1 44\n""-1 -1 -1\n""2 -1 44\n""-1 -1 -1\n""-1 2 0\n""0 -1 44\n""-1 -1 -1\n""2 -1 44\n""-1 -1 0\n""-1 -1 -1\n""3 0 3\n""6 6 44\n""-1 -1 -1\n""9 -1 9\n""9 -1 44\n""-1 -1 -1\n""9 8 6\n""9 -1 10\n""6 6 44\n""-1 -1 -1\n""9 -1 9\n""9 -1 44\n""-1 -1 -1\n""-1 8 8\n""8 8 44\n""-1 -1 -1\n""12 -1 7\n""-1 -1 44\n""4 -1 4\n""44 4 -1\n""-1 -1 -1\n""-1 7 0\n""0 0 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 1\n""-1 -1 -1\n""-1 0 2\n""1 0 -1\n""2 2 44\n""-1 -1 -1\n""-1 -1 44\n""0 44 -1\n""-1 7 -1\n""-1 7 -1\n""-1 4 44\n""4 -1 4\n""44 -1 -1\n""5 5 44\n""-1 -1 -1\n""4 -1 4\n""3 -1 0\n""-1 4 3\n""4 -1 4\n""-1 4 5\n""4 -1 4\n""-1 4 12\n""4 -1 4\n""-1 4 44\n""4 -1 4\n""44 -1 -1\n""15 -1 2\n""0 13 -1\n""-1 13 -1\n""-1 13 -1\n""2 -1 6\n""-1 13 -1\n""-1 4 0\n""-1 13 -1\n""-1 13 -1\n""6 13 -1\n""0 13 -1\n""-1 5 44\n""44 -1 1\n""-1 1 0\n""0 -1 44\n""-1 -1 -1\n""1 -1 44\n""-1 -1 -1\n""1 -1 44\n""-1 -1 -1\n""1 -1 44\n""-1 -1 -1\n""-1 -1 -1\n""1 -1 44\n""-1 -1 -1\n""-1 -1 -1\n""1 -1 44\n""-1 -1 -1\n""1 -1 44\n""-1 -1 -1\n""-1 5 0\n""0 -1 0\n""0 -1 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 8\n""5 8 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 7\n""5 7 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 11\n""5 11 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 9\n""5 9 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 10\n""5 10 44\n""-1 -1 -1\n""1 -1 44\n""-1 -1 -1\n""1 -1 44\n""-1 -1 1\n""-1 -1 1\n""-1 -1 -1\n""6 6 44\n""1 13 -1\n""-1 -1 -1\n""13 6 -1\n""14 14 44\n""2 -1 44\n""13 44 -1\n""-1 -1 -1\n""-1 14 12\n""-1 13 6\n""-1 13 8\n""-1 12 0\n""-1 12 2\n""0 6 44\n""-1 -1 -1\n""2 8 44\n""-1 -1 -1\n""8 -1 44\n""-1 -1 -1\n""2 -1 44\n""-1 -1 -1\n""0 6 44\n""-1 -1 -1\n""-1 -1 -1\n""2 8 44\n""-1 -1 -1\n""-1 -1 -1\n""8 -1 0\n""0 2 0\n""-1 -1 -1\n""-1 -1 -1\n""0 0 44\n""-1 -1 -1\n""8 -1 44\n""-1 -1 -1\n""6 -1 44\n""-1 -1 -1\n""12 -1 7\n""-1 -1 -1\n""-1 7 1\n""1 1 44\n""-1 -1 -1\n""-1 1 0\n""-1 1 2\n""0 6 44\n""-1 -1 -1\n""8 2 44\n""-1 -1 -1\n""0 6 44\n""-1 -1 -1\n""8 2 44\n""-1 -1 -1\n""-1 -1 -1\n""1 13 -1\n""13 1 -1\n""7 13 -1\n""13 7 -1\n""12 13 -1\n""-1 13 45\n""45 -1 44\n""-1 -1 -1\n""-1 5 45\n""45 -1 44\n""-1 -1 -1\n""-1 5 3\n""-1 -1 45\n""-1 45 45\n""3 45 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 2\n""2 2 44\n""-1 -1 -1\n""-1 2 44\n""44 -1 0\n""-1 -1 44\n""-1 44 2\n""0 0 0\n""0 -1 0\n""2 0 45\n""45 -1 44\n""-1 -1 -1\n""-1 5 45\n""45 -1 44\n""-1 -1 -1\n""-1 5 3\n""-1 -1 45\n""-1 45 45\n""3 45 44\n""-1 -1 -1\n""-1 -1 44\n""-1 44 2\n""2 2 44\n""-1 -1 -1\n""-1 2 44\n""44 -1 0\n""-1 -1 44\n""-1 44 6\n""0 0 0\n""0 -1 0\n""6 0 45\n""45 -1 44\n""-1 -1 -1\n""-1 5 3\n""-1 -1 45\n""-1 45 45\n""3 45 44\n""-1 5 44\n""44 -1 14\n""44 -1 14")
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Simulatori i Pipeline"))
self.pipelineStages.setText(_translate("MainWindow", "IF,ID,EX,ME,WB"))
self.pipelineStages.setPlaceholderText(_translate("MainWindow", "comma separated: (IF,ID,EX,ME,WB)"))
self.label_6.setText(_translate("MainWindow", "Pipeline"))
self.label_9.setText(_translate("MainWindow", "Trace:"))
self.label_8.setText(_translate("MainWindow", "Madhësia e regjistrit"))
self.label_5.setText(_translate("MainWindow", "Pipeline Setup"))
self.label.setText(_translate("MainWindow", "Faza e operandit"))
self.label_4.setText(_translate("MainWindow", "Faza e rezultatit"))
self.label_2.setText(_translate("MainWindow", "Fillimi i instruksionit"))
self.label_3.setText(_translate("MainWindow", "Përfundimi i instruksionit"))
self.simulateButton.setText(_translate("MainWindow", "Fillo simulimin"))
self.helpButton.setText(_translate("MainWindow", "Ndihmë"))
self.quitButton.setText(_translate("MainWindow", "Dil"))
self.label_10.setText(_translate("MainWindow", "Rezultati"))
self.actionQuit.setText(_translate("MainWindow", "Dil"))
self.actionQuit.setToolTip(_translate("MainWindow", "Dil"))
self.actionSimulate.setText(_translate("MainWindow", "Simulo"))
self.actionSimulate.setToolTip(_translate("MainWindow", "Simulo"))
self.actionHelp.setText(_translate("MainWindow", "Ndihmë"))
self.actionHelp.setToolTip(_translate("MainWindow", "Ndihmë"))
self.loadTrace.setText(_translate("MainWindow", "Ngarko trace shembull"))
self.actionLoadTrace.setText(_translate("MainWindow", "LoadTrace"))
self.actionLoadTrace.setToolTip(_translate("MainWindow", "LoadTrace"))
def simulateCPUPipeline(self):
# Typecasting variables as needed
operandStage = int(self.operandstage.property("value"))
resultStage = int(self.resultstage.property("value"))
startChart = int(self.startat.property("value"))
endChart = int(self.endat.property("value"))
traceFile = self.traceText.property("plainText").splitlines()
errors = ""
if not self.pipelineStages.text().split(',') or len(self.pipelineStages.text().split(',')) <= 2:
errors += "ERROR: Fazat e pipeline nuk duhet të jenë të zbrazëta, më pak se 3 faza, dhe duhet të jenë të ndara me presje.\n"
if not traceFile or len(traceFile) < len(self.pipelineStages.text().split(',')):
errors += "ERROR: Trace nuk duhet të jetë e zbrazët ose me më pak rreshta se numri i fazave të pipeline. Shtyp butonin \"Ndihmë\" për më shumë informacion.\n"
if errors != "":
self.textOutput.setProperty("plainText", errors)
return
pipelineStages = self.pipelineStages.text().split(',')
numberRegisters = int(self.registernumbers.property("value"))
textOutput = str("\nFILLIMI I SIMULIMIT: Simulatori i Pipeline\n\n" +
"Faza e operandit: " + str(operandStage) +
"\nFaza e rezultatit: " + str(resultStage) +
"\nFillimi i instruksionit: " + str(startChart) +
"\nPërfimdimi i instruksionit: " + str(endChart)) + "\n\n"
self.textOutput.setProperty("plainText", textOutput)
idNum = 0
stageNum = 0
stallNum = 0
pipe = PipelineStatus(pipelineStages)
regs = RegisterStatus(int(numberRegisters))
textOutput2 = str(regs.printGraph())
for position, line in enumerate(traceFile):
if not line.split() or (len(line.split()) < 3 or len(line.split()) > 3) or \
all(int(i) > -2 for i in line.split()) is not True or \
all(int(i) < numberRegisters for i in line.split()) is not True:
self.textOutput.setProperty("plainText", "ERROR: Rreshtat e trace nuk janë të formatuara në rregull. Shiko në rreshtin " + \
str(position + 1) + ". Shtyp butonin \"Ndihml\" për më shumë informacion.\n")
return
idNum += 1
op1 = int(line.split(" ")[0])
op2 = int(line.split(" ")[1])
result = int(line.split(" ")[2])
if pipe.getStatus(resultStage):
pipe.setInstrEx(pipe.getElement(resultStage).idNum)
pipe.advancePipeline(resultStage)
if pipe.getStatus(resultStage):
regs.writeBack(pipe.getElement(resultStage))
pipe.addInstruction(ProcessInfo(idNum, op1, op2, result, False))
# check and set stalls
pipe.setStall(operandStage, regs.decode(pipe.getElement(operandStage)))
if pipe.printGraph(startChart, endChart):
textOutput += str(pipe.printGraph(startChart, endChart))
stageNum += 1
while pipe.getStall(operandStage):
if pipe.getStatus(resultStage):
pipe.setInstrEx(pipe.getElement(resultStage).idNum)
pipe.advancePipeline(resultStage)
if pipe.getStatus(resultStage):
textOutput2 += str(regs.printGraph())
regs.writeBack(pipe.getElement(resultStage))
# check and set stalls
pipe.setStall(operandStage, regs.decode(pipe.getElement(operandStage)))
if pipe.printGraph(startChart, endChart):
textOutput += str(pipe.printGraph(startChart, endChart))
stageNum += 1
stallNum += 1
while not pipe.isEmpty():
if pipe.getStatus(resultStage):
pipe.setInstrEx(pipe.getElement(resultStage).idNum)
pipe.advancePipeline(resultStage)
if pipe.getStatus(resultStage):
textOutput2 += str(regs.printGraph())
regs.writeBack(pipe.getElement(resultStage))
# check and set stalls
pipe.setStall(operandStage, regs.decode(pipe.getElement(operandStage)))
if pipe.printGraph(startChart, endChart):
textOutput += str(pipe.printGraph(startChart, endChart))
stageNum += 1
# Handle Stalls
if pipe.getStall(operandStage):
stallNum += 1
noPipeline = len(pipelineStages) * idNum
speedup = round(100 * (float(noPipeline) / float(stageNum)), 3)
avgStalls = round(float(stallNum) / float(idNum), 3)
textOutput += str("\nAnaliza e simulimit: " +
"\nNumri i instruksioneve të ekzekutuara: " + str(idNum) +
"\nNumri i fazava të ekzekutuara pa pipeline: " + str(noPipeline) +
"\nNumri i fazave në pritje: " + str(stallNum) +
"\nNumri i fazave në simulim të pipeline: " + str(stageNum) +
"\nMesatarja e fazave në pritje për instruksion: " + str(avgStalls) +
"\nPërmirësimi (shpejtësi): " + str(speedup) + "%" +
"\n\nPËRFUNDIMI I SIMULIMIT\n\n")
self.textOutput.setProperty("plainText", textOutput)
self.textOutput2.setProperty("plainText", textOutput2)
class ProcessInfo:
idNum = 0
operand1 = -1
operand2 = -1
stall = bool(False)
result = -1
def __init__(self, idNum=0, operand1=-1, operand2=-1, result=-1, stall=bool(False)):
self.idNum = idNum
self.operand1 = operand1
self.operand2 = operand2
self.result = result
self.stall = bool(stall)
class PipelineStatus():
size = 0
instructionEx = 0
stageID = []
pipelineStatus = []
def __init__(self, pipelineStages):
self.size = len(pipelineStages)
self.instructionEx = 0
self.stageID = []
self.pipelineStatus = []
for stage in pipelineStages:
self.stageID.append(stage)
for i in range(0, self.size):
self.pipelineStatus.append(ProcessInfo())
def getStatus(self, index):
if index < self.size:
if self.pipelineStatus[index].idNum != 0:
return bool(True)
else:
return bool(False)
else:
sys.exit("ERROR: index out of bounds on pipelineStatus structure!")
def addInstruction(self, p):
if self.pipelineStatus[0].idNum == 0:
self.pipelineStatus[0] = p
else:
sys.exit("ERROR: FI is busy!")
def setInstrEx(self, instructorNum):
self.instructionEx = instructorNum
def setStall(self, index, stall):
if index < self.size:
self.pipelineStatus[index].stall = bool(stall)
def getStall(self, index):
return self.pipelineStatus[index].stall
def getElement(self, index):
if index < self.size:
return self.pipelineStatus[index]
else:
sys.exit("ERROR: Index out of bounds on pipelineStatus structure")
def advancePipeline(self, resultStage):
self.pipelineStatus[resultStage] = ProcessInfo()
for i in range(self.size - 1, 0, -1):
if (not self.pipelineStatus[i - 1].stall) and self.pipelineStatus[i].idNum == 0:
self.pipelineStatus[i] = self.pipelineStatus[i - 1]
self.pipelineStatus[i - 1] = ProcessInfo()
def isEmpty(self):
empty = bool(True)
for i in range(0, self.size - 1):
if self.pipelineStatus[i].idNum != 0:
empty = bool(False)
return empty
def printGraph(self, startChart, stopChart):
output = str()
if self.pipelineStatus[0].idNum >= startChart and self.instructionEx <= stopChart and startChart > 0:
for i in range(0, (self.instructionEx - startChart) + 1):
output += str(" ")
count = self.size
while (count - 1) >= 0:
if self.pipelineStatus[count - 1].idNum != 0:
if self.pipelineStatus[count - 1].idNum >= startChart and self.pipelineStatus[count - 1].idNum <= stopChart:
if self.pipelineStatus[count - 1].stall:
output += str("-- ")
count = 0
else:
output += str(self.stageID[count - 1] + " ")
count -= 1
output += str(os.linesep)
return output
class RegisterInfo:
lastWrite = 0
nextWrite = 0
def __init__(self):
self.lastWrite = 0
self.nextWrite = 0
class RegisterStatus:
size = 0
registerStatus = []
def __init__(self, size):
self.size = size
self.registerStatus = []
for i in range(0, self.size):
self.registerStatus.append(RegisterInfo())
def writeBack(self, p):
if self.registerStatus[int(p.result)].nextWrite == p.idNum:
self.registerStatus[int(p.result)].lastWrite = p.idNum
self.registerStatus[int(p.result)].nextWrite = 0
def decode(self, p):
stall = bool(False)
if p.operand1 != -1:
if self.registerStatus[int(p.operand1)].nextWrite != 0 and self.registerStatus[int(p.operand1)].nextWrite < p.idNum:
stall = bool(True)
if p.operand2 != -1:
if self.registerStatus[int(p.operand2)].nextWrite != 0 and self.registerStatus[int(p.operand2)].nextWrite < p.idNum:
stall = bool(True)
if (not stall) and p.result != -1:
self.registerStatus[int(p.result)].nextWrite = p.idNum
return stall
def printGraph(self):
textOutput = str("Register Status" + os.linesep)
# sys.stdout.write("Register Status" + os.linesep)
for i in range(0, self.size):
if self.registerStatus[i].lastWrite != 0 or self.registerStatus[i].nextWrite != 0:
textOutput += str(" Register " + str(i) + \
": Last Write - " + str(self.registerStatus[i].lastWrite) + \
", Next Write - " + str(self.registerStatus[i].nextWrite) + "\n")
textOutput += os.linesep
return textOutput
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())