tentative fonctionnement boutons
This commit is contained in:
parent
8113bf74d5
commit
e109b98673
@ -242,7 +242,7 @@ class Simulator:
|
|||||||
|
|
||||||
# ----------------- boucle principale -----------------
|
# ----------------- boucle principale -----------------
|
||||||
|
|
||||||
def run(self, max_steps: int = 100000):
|
def run(self, max_steps: int = 1):
|
||||||
steps = 0
|
steps = 0
|
||||||
while self.cpu.running and steps < max_steps:
|
while self.cpu.running and steps < max_steps:
|
||||||
result = self.step()
|
result = self.step()
|
||||||
|
|||||||
@ -61,8 +61,8 @@ buttons_frame.pack(padx=5, pady=5, side=tk.TOP)
|
|||||||
buttonAll = tk.Button(root, text="All In")
|
buttonAll = tk.Button(root, text="All In")
|
||||||
buttonStep = tk.Button(root, text="Step By Step")
|
buttonStep = tk.Button(root, text="Step By Step")
|
||||||
|
|
||||||
buttonAll.pack(in_=buttons_frame, side=tk.LEFT)
|
buttonAll.pack(in_=buttons_frame, side=tk.LEFT, padx=5)
|
||||||
buttonStep.pack(in_=buttons_frame, side=tk.LEFT)
|
buttonStep.pack(in_=buttons_frame, side=tk.LEFT, padx=5)
|
||||||
|
|
||||||
image_frame = tk.Frame(instructions_frame, width=400, height=100, bg="#89B4E1")
|
image_frame = tk.Frame(instructions_frame, width=400, height=100, bg="#89B4E1")
|
||||||
image_frame.pack(padx=5, pady=5, side=tk.TOP)
|
image_frame.pack(padx=5, pady=5, side=tk.TOP)
|
||||||
@ -132,10 +132,7 @@ label_eq = Label(annexe_1_frame, bg="orange")
|
|||||||
label_eq.pack(pady=5)
|
label_eq.pack(pady=5)
|
||||||
|
|
||||||
|
|
||||||
|
#Annexe 2
|
||||||
|
|
||||||
|
|
||||||
#RAnnexe 2
|
|
||||||
annexe_2_frame = tk.Frame(annexes_frames, width=100, height=100, bg="orange")
|
annexe_2_frame = tk.Frame(annexes_frames, width=100, height=100, bg="orange")
|
||||||
annexe_2_frame.pack(padx=10, pady=0, side=tk.LEFT)
|
annexe_2_frame.pack(padx=10, pady=0, side=tk.LEFT)
|
||||||
|
|
||||||
@ -197,11 +194,29 @@ myOutList = tk.Listbox(out_frame, yscrollcommand=scrollbarOut.set, width=50)
|
|||||||
myOutList.pack(side=tk.LEFT, fill=tk.BOTH)
|
myOutList.pack(side=tk.LEFT, fill=tk.BOTH)
|
||||||
scrollbarOut.config(command=myOutList.yview)
|
scrollbarOut.config(command=myOutList.yview)
|
||||||
|
|
||||||
|
def StartCPU(program, callback, registerCallback):
|
||||||
|
print(program)
|
||||||
|
sim = e3.Simulator(program)
|
||||||
|
|
||||||
|
def onClickButtonAll():
|
||||||
|
print("oui")
|
||||||
|
StartCPU(program, None, None)
|
||||||
|
sim.run(100000)
|
||||||
|
update_gui()
|
||||||
|
|
||||||
|
def onClickButtonStep():
|
||||||
|
print("non")
|
||||||
|
StartCPU(program, None, None)
|
||||||
|
sim.run()
|
||||||
|
update_gui()
|
||||||
|
|
||||||
|
|
||||||
#val = subprocess.run(["/usr/bin/python3", "/home/aurelien/Documents/24hducode2026/24H_du_code_2026/Epreuve3.py", "test_bin_epreuve3/call_label.bin"] # transforme bytes en str)
|
buttonAll.config(command=onClickButtonAll)
|
||||||
|
buttonStep.config(command=onClickButtonStep)
|
||||||
|
|
||||||
|
|
||||||
|
#Gestion dynamique affichage valeurs
|
||||||
|
|
||||||
previous_sp = None # Initialisation avant la première itération
|
previous_sp = None # Initialisation avant la première itération
|
||||||
|
|
||||||
def update_gui():
|
def update_gui():
|
||||||
@ -209,7 +224,8 @@ def update_gui():
|
|||||||
try:
|
try:
|
||||||
state = next(sim_iter)
|
state = next(sim_iter)
|
||||||
|
|
||||||
# 👉 mise à jour label instruction
|
#Récupération des valeurs retourné par le fichier Epreuve3.py
|
||||||
|
|
||||||
single_instr.config(
|
single_instr.config(
|
||||||
text=state["instr"] + " Cycle(s): " + str(state["cycles_added"])
|
text=state["instr"] + " Cycle(s): " + str(state["cycles_added"])
|
||||||
)
|
)
|
||||||
@ -239,6 +255,7 @@ def update_gui():
|
|||||||
previous_sp = state['sp']
|
previous_sp = state['sp']
|
||||||
ram = state['ram']
|
ram = state['ram']
|
||||||
|
|
||||||
|
#Gestion affichage RAM
|
||||||
for addr in range(0, 256, 8):
|
for addr in range(0, 256, 8):
|
||||||
chunk = ram[addr:addr+8]
|
chunk = ram[addr:addr+8]
|
||||||
hex_values = " ".join(f"{b:02X}" for b in chunk)
|
hex_values = " ".join(f"{b:02X}" for b in chunk)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user