1
0
forked from tanchou/Verilog

Refactor UART testbench and top-level modules; remove old testbench files, enhance UART communication in top_ultrason_uart, and implement LED control via UART in top_led_uart. Add Python scripts for UART communication and data reading.

This commit is contained in:
Gamenight77
2025-04-17 18:00:54 +02:00
parent 897f829e40
commit 65cf0e8232
13 changed files with 142 additions and 39776 deletions

View File

@@ -0,0 +1,30 @@
import serial
import time
# Ouvre le port série (à adapter si nécessaire)
ser = serial.Serial('COM6', 115200, timeout=0.5) # timeout non bloquant
print("Entrez un chiffre entre 0 et 5 pour toggler une LED.")
try:
while True:
user_input = input("> ")
if user_input.isdigit() and 0 <= int(user_input) <= 64:
value = int(user_input)
ser.write(bytes([value])) # envoie en binaire brut
print(f"Envoyé : {value} -> {value:08b}")
# Lecture de la réponse UART (1 octet)
response = ser.read(1)
if response:
led_state = response[0]
print(f"État reçu du FPGA : {led_state:08b}")
else:
print("⚠️ Aucune réponse reçue.")
else:
print("Veuillez entrer un chiffre entre 0 et 63.")
except KeyboardInterrupt:
print("\nFermeture.")
finally:
ser.close()

View File

@@ -0,0 +1,15 @@
import serial
import time
ser = serial.Serial('COM6', 115200)
ser.timeout = 1
# Boucle pour lire les données du port série
while True:
if ser.in_waiting > 0:
data = ser.read(1)
distance = int.from_bytes(data, byteorder='little')
print(f'Distance reçue : {distance} cm')
ser.close()