-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.py
More file actions
141 lines (106 loc) · 5.49 KB
/
Interface.py
File metadata and controls
141 lines (106 loc) · 5.49 KB
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
from tkinter import *
from tkinter import filedialog
import MIPS_X_interface
import asmtohex as assbly
import time
class Interface(Frame):
def __init__(self, fenetre, **kwargs):
Frame.__init__(self, fenetre, width=700, height=700, **kwargs)
fenetre.resizable(width=False,height=False)
fenetre.title('Assembleur et ISS')
self.pack(fill=BOTH)
self.nb_clic = 0
self.posAssembly = 2
self.posISS = 5
#creation des boutons
self.bouton_quitter = Button(self, text="Quitter", bg = "green", command=self.quit)
self.bouton_quitter.grid(row=0,column=2)
self.bouton_startAssembly = Button(self, text="Assembly", command=self.startAssembly)
self.bouton_startAssembly.grid(row=self.posAssembly,column=3)
self.bouton_getfiles_ass = Button(self, text="Fichier à compiler", command=self.getfiles_ass)
self.bouton_getfiles_ass.grid(row=self.posAssembly,column=0)
self.bouton_getfiles_hex = Button(self, text="Load Fichier Hexadecimal", command=self.getFiles_hex)
self.bouton_getfiles_hex.grid(row=self.posISS, column = 0)
self.bouton_startISS = Button(self, text="Run",command=self.startISS)
self.bouton_startISS.grid(row=self.posISS,column=4)
self.bouton_pasapas = Button(self, text="Pas à Pas", command=self.pasapas)
self.bouton_pasapas.grid(row=self.posISS,column=3)
self.bouton_loadData = Button(self, text="Load Fichier Data Hexadecimal", command=self.loadData)
self.bouton_loadData.grid(row=self.posISS,column=2)
self.registre = Label(self, text= 'Registres')
self.registre.grid(row = self.posISS+2, column = 3)
self.instr = Label(self, text= 'Instructions')
self.instr.grid(row = self.posISS+2, column = 0)
self.memoire = Label(self, text= 'Memoire')
self.memoire.grid(row = self.posISS+2, column = 2)
Label(self, text = ' ').grid(row = 0, column = 6)
Label(self, text = ' ').grid(row = self.posAssembly+1, column = 6)
Label(self, text = ' ').grid(row = self.posISS+1 , column = 6)
Label(self, text = ' ').grid(row = 1 , column = 6)
def affichageMemoire(self,message):
self.affmemoire = Label(self, text= message)
self.affmemoire.grid(row = self.posISS+5, column = 2)
def affichageReg(self, message ):
self.affReg = Label(self, text= str(message))
self.affReg.grid(row = self.posISS + 5, column = 3)
def affichageInstr(self,message):
self.affInstr = Label(self, text = message)
self.affInstr.grid(row = self.posISS + 5, column = 0)
def affichageProgrammeCounter(self):
self.affPC = Label(self, text = "pc = {}".format(self.simulation.pc))
self.affPC.grid(row = self.posISS + 6, column = 3)
def getFiles_hex(self):
filename = filedialog.askopenfilename()
self.simulation = MIPS_X_interface.VM(filename)
path = Label(self, text= filename)
path.grid(row=self.posISS +1, column=0)
print (filename)
def getfiles_ass(self):
self.filename_assembleur = filedialog.askopenfilename()
path = Label(self, text= self.filename_assembleur)
path.grid(row=self.posAssembly +1, column=0)
def loadData(self):
filename = filedialog.askopenfilename()
self.simulation.getdata(filename)
self.affichageMemoire(self.simulation.outTextMem())
path = Label(self, text= filename)
path.grid(row=self.posISS + 1, column=2)
def startISS(self):
while(self.simulation.running != 0):
self.simulation.unTour()
# time.sleep(0.0001)
self.affichageReg(self.simulation.outTextRegs())
self.showStatus()
def showStatus(self):
self.simulation.get_information_temps()
nombre_de_cycle = self.simulation.c_cycle
temps_execution = self.simulation.t_dps_init
txt = "Fin d'execution : \n Nombre de cycle : {} \n temps execution : {} s".format(nombre_de_cycle, temps_execution)
self.status = Label(self, text = txt)
self.status.grid(row = self.posISS + 5, column = 0)
def pasapas(self):
self.simulation.unTour()
self.affichageReg(self.simulation.outTextRegs())
self.affichageInstr(self.simulation.instruction)
self.affichageMemoire(self.simulation.outTextMem())
self.affichageProgrammeCounter()
if self.simulation.running == 0:
self.showStatus()
def startAssembly(self):
inputFileName = self.filename_assembleur
outputFileName = self.filename_assembleur[0:len(self.filename_assembleur)-4]+"HEX.txt"
asmInstructions = assbly.load_ASM(inputFileName)
numInstructions = assbly.analyze_instructions(asmInstructions)
hexInstructions = assbly.compute_hex_instructions(numInstructions)
assbly.output_hex_instructions(hexInstructions, outputFileName)
path = Label(self, text= outputFileName)
path.grid(row=self.posAssembly + 1, column=3)
self.simulation = MIPS_X_interface.VM(outputFileName)
path = Label(self, text= outputFileName)
path.grid(row=self.posISS +1, column=0)
if __name__ == "__main__":
fenetre = Tk()
interface = Interface(fenetre)
interface.mainloop()
interface.destroy()
fenetre.destroy()