Ajout du OUT
This commit is contained in:
parent
20ed1e558e
commit
f76307ecc1
23
Epreuve3.py
23
Epreuve3.py
@ -24,6 +24,7 @@ class CPU:
|
|||||||
cycles: int = 0
|
cycles: int = 0
|
||||||
running: bool = True
|
running: bool = True
|
||||||
after_ret: bool = False
|
after_ret: bool = False
|
||||||
|
last_out = None
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
if not self.regs:
|
if not self.regs:
|
||||||
@ -189,6 +190,7 @@ class Simulator:
|
|||||||
r = b & 0b11
|
r = b & 0b11
|
||||||
instr = f"OUT R{r}"
|
instr = f"OUT R{r}"
|
||||||
print(f"[OUT] R{r} = {c.regs[r]}")
|
print(f"[OUT] R{r} = {c.regs[r]}")
|
||||||
|
self.cpu.last_out = c.regs[r]
|
||||||
|
|
||||||
# --- TIM valeur ---
|
# --- TIM valeur ---
|
||||||
elif b == 0xF8: # TIM
|
elif b == 0xF8: # TIM
|
||||||
@ -228,16 +230,19 @@ class Simulator:
|
|||||||
print(f" {regs_str} LT={c.lt} EQ={c.eq} SP={c.sp}")
|
print(f" {regs_str} LT={c.lt} EQ={c.eq} SP={c.sp}")
|
||||||
print("-" * 60)
|
print("-" * 60)
|
||||||
ram = self.dump_ram()
|
ram = self.dump_ram()
|
||||||
|
out = self.cpu.last_out
|
||||||
|
self.cpu.last_out = None
|
||||||
return {
|
return {
|
||||||
"pc": pc_before,
|
"pc": pc_before,
|
||||||
"instr": instr,
|
"instr": instr,
|
||||||
"cycles_added": cycles_added,
|
"cycles_added": cycles_added,
|
||||||
"regs": c.regs.copy(),
|
"regs": c.regs.copy(),
|
||||||
"lt": c.lt,
|
"lt": c.lt,
|
||||||
"eq": c.eq,
|
"eq": c.eq,
|
||||||
"sp": c.sp,
|
"sp": c.sp,
|
||||||
"ram": ram
|
"ram": ram,
|
||||||
}
|
"out": out
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# ----------------- boucle principale -----------------
|
# ----------------- boucle principale -----------------
|
||||||
|
|||||||
43
Path.asm
43
Path.asm
@ -12,26 +12,57 @@ _main:
|
|||||||
|
|
||||||
MOV R0 51
|
MOV R0 51
|
||||||
OUT R0
|
OUT R0
|
||||||
TIM 165 ; Ligne droite OK
|
TIM 164 ; Ligne droite OK
|
||||||
|
|
||||||
MOV R0 49 ; 0b 0011 0001
|
MOV R0 49 ; 0b 0011 0001
|
||||||
OUT R0
|
OUT R0
|
||||||
TIM 130 ; Rotation droite OK
|
TIM 131 ; Rotation droite OK
|
||||||
|
|
||||||
MOV R0 51
|
MOV R0 51
|
||||||
OUT R0
|
OUT R0
|
||||||
TIM 152 ; Ligne droite
|
TIM 147 ; Ligne droite
|
||||||
|
|
||||||
MOV R0 19 ; 0b 0001 0011
|
MOV R0 19 ; 0b 0001 0011
|
||||||
OUT R0
|
OUT R0
|
||||||
TIM 130 ; Rotation gauche
|
TIM 131 ; Rotation gauche
|
||||||
;TIM 50
|
;TIM 50
|
||||||
|
|
||||||
MOV R0 51
|
MOV R0 51
|
||||||
OUT R0
|
OUT R0
|
||||||
TIM 136 ; Ligne droite
|
TIM 138 ; Ligne droite
|
||||||
|
|
||||||
|
MOV R0 0
|
||||||
|
OUT R0 ; STOP
|
||||||
|
TIM 160
|
||||||
|
|
||||||
|
MOV R0 162
|
||||||
|
OUT R0
|
||||||
|
TIM 135 ; Rotation gauche
|
||||||
|
|
||||||
|
MOV R0 0
|
||||||
|
OUT R0 ; STOP
|
||||||
|
TIM 140
|
||||||
|
|
||||||
|
MOV R0 42
|
||||||
|
OUT R0
|
||||||
|
TIM 135 ; Rotation droite
|
||||||
|
|
||||||
|
MOV R0 0
|
||||||
|
OUT R0 ; STOP
|
||||||
|
TIM 160
|
||||||
|
|
||||||
|
MOV R0 247
|
||||||
|
OUT R0
|
||||||
|
TIM 130 ; Rotation gauche
|
||||||
|
|
||||||
|
MOV R0 127
|
||||||
|
OUT R0
|
||||||
|
TIM 130 ; Rotation droite
|
||||||
|
|
||||||
|
MOV R0 247
|
||||||
|
OUT R0
|
||||||
|
TIM 180 ; Rotation gauche
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MOV R0 0
|
MOV R0 0
|
||||||
OUT R0 ; STOP
|
OUT R0 ; STOP
|
||||||
|
|||||||
Binary file not shown.
@ -177,6 +177,8 @@ Demi tour + fuite
|
|||||||
|
|
||||||
Parcours
|
Parcours
|
||||||
{"type": "msg", "format": "base64", "string": "4BHw+ILgIvD4guAz8Pil4DHw+ILgM/D4mOAT8PiC4DPw+IjgAPCA4ADw+GSA"}
|
{"type": "msg", "format": "base64", "string": "4BHw+ILgIvD4guAz8Pil4DHw+ILgM/D4mOAT8PiC4DPw+IjgAPCA4ADw+GSA"}
|
||||||
|
{"type": "msg", "format": "base64", "string": "4BHw+ILgIvD4guAz8Pik4DHw+IPgM/D4k+AT8PiD4DPw+IrgAPD4oOCi8PiH4ADw+IzgKvD4h+AA8Pig4Pfw+ILgf/D4guD38Pi04ADwgOAA8PhkgA=="}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -54,6 +54,16 @@ Label(single_inst_frame, text=f"Instruction").pack(pady=5, side=LEFT)
|
|||||||
single_instr = Label(single_inst_frame, text=f"instruction+cycle", width=30, bg="white")
|
single_instr = Label(single_inst_frame, text=f"instruction+cycle", width=30, bg="white")
|
||||||
single_instr.pack(pady=5, side=tk.LEFT)
|
single_instr.pack(pady=5, side=tk.LEFT)
|
||||||
|
|
||||||
|
# Boutons
|
||||||
|
buttons_frame = tk.Frame(instructions_frame, width=400, height=100, bg="#89B4E1")
|
||||||
|
buttons_frame.pack(padx=5, pady=5, side=tk.TOP)
|
||||||
|
|
||||||
|
buttonAll = tk.Button(root, text="All In")
|
||||||
|
buttonStep = tk.Button(root, text="Step By Step")
|
||||||
|
|
||||||
|
buttonAll.pack(in_=buttons_frame, side=tk.LEFT)
|
||||||
|
buttonStep.pack(in_=buttons_frame, side=tk.LEFT)
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
@ -195,7 +205,7 @@ scrollbarOut.config(command=myOutList.yview)
|
|||||||
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():
|
||||||
global previous_sp # Accéder à la variable globale previous_sp
|
global previous_sp, sim_iter # Accéder à la variable globale previous_sp
|
||||||
try:
|
try:
|
||||||
state = next(sim_iter)
|
state = next(sim_iter)
|
||||||
|
|
||||||
@ -234,6 +244,9 @@ def update_gui():
|
|||||||
hex_values = " ".join(f"{b:02X}" for b in chunk)
|
hex_values = " ".join(f"{b:02X}" for b in chunk)
|
||||||
myRamList.insert(tk.END, f"{addr:02X}: {hex_values}")
|
myRamList.insert(tk.END, f"{addr:02X}: {hex_values}")
|
||||||
|
|
||||||
|
if (state["out"] != None):
|
||||||
|
myOutList.insert(tk.END, state["out"])
|
||||||
|
|
||||||
# relance automatique
|
# relance automatique
|
||||||
root.after(200, update_gui)
|
root.after(200, update_gui)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user