forked from tanchou/Verilog
Add ultrasonic sensor model and driver, update testbench and scripts
This commit is contained in:
46
Semaine_6/ULTRASON/scripts/linux/build.sh
Normal file
46
Semaine_6/ULTRASON/scripts/linux/build.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Aller à la racine du projet
|
||||
cd "$(dirname "$0")/../.." || exit 1
|
||||
|
||||
# Config de base
|
||||
DEVICE="GW2AR-LV18QN88C8/I7"
|
||||
BOARD="tangnano20k"
|
||||
TOP="top_uart_ultrason_command"
|
||||
CST_FILE="$TOP.cst"
|
||||
JSON_FILE="runs/$TOP.json"
|
||||
PNR_JSON="runs/pnr_$TOP.json"
|
||||
BITSTREAM="runs/$TOP.fs"
|
||||
|
||||
# Créer le dossier runs si nécessaire
|
||||
mkdir -p runs
|
||||
|
||||
echo "=== Étape 1 : Synthèse avec Yosys ==="
|
||||
yosys -p "read_verilog -sv src/verilog/$TOP.v IP/verilog/ultrasonic_fpga.v IP/verilog/uart_tx_fifo.v IP/verilog/uart_rx_fifo.v IP/verilog/rxuartlite.v IP/verilog/fifo.v IP/verilog/uart_tx.v; synth_gowin -top $TOP -json $JSON_FILE"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "=== Erreur lors de la synthèse ==="
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Étape 2 : Placement & Routage avec nextpnr-himbaechel ==="
|
||||
nextpnr-himbaechel --json "$JSON_FILE" --write "$PNR_JSON" --device "$DEVICE" --vopt cst=constraints/"$CST_FILE" --vopt family=GW2A-18C
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "=== Erreur lors du placement/routage ==="
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Étape 3 : Packing avec gowin_pack ==="
|
||||
gowin_pack -d "$DEVICE" -o "$BITSTREAM" "$PNR_JSON"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "=== Erreur lors du packing ==="
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Étape 4 : Flash avec openFPGALoader ==="
|
||||
openFPGALoader -b "$BOARD" "$BITSTREAM"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "=== Erreur lors du flash ==="
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Compilation et flash réussis ==="
|
4
Semaine_6/ULTRASON/scripts/linux/clean.sh
Normal file
4
Semaine_6/ULTRASON/scripts/linux/clean.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "=== Nettoyage des fichiers générés ==="
|
||||
rm -rf runs/*
|
5
Semaine_6/ULTRASON/scripts/linux/gtkwave.sh
Normal file
5
Semaine_6/ULTRASON/scripts/linux/gtkwave.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "=== Lancement de GTKWave ==="
|
||||
gtkwave runs/ultrason_commands.vcd
|
||||
echo "=== GTKWave terminé ==="
|
17
Semaine_6/ULTRASON/scripts/linux/simulate.sh
Normal file
17
Semaine_6/ULTRASON/scripts/linux/simulate.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "=== Simulation avec Icarus Verilog ==="
|
||||
|
||||
OUT="runs/sim.vvp"
|
||||
TOP="tb_ultrason_commands"
|
||||
DIRS=("src/verilog" "tests/verilog" "IP/verilog")
|
||||
|
||||
FILES=()
|
||||
for dir in "${DIRS[@]}"; do
|
||||
for file in "$dir"/*.v; do
|
||||
FILES+=("$file")
|
||||
done
|
||||
done
|
||||
|
||||
iverilog -g2012 -o "$OUT" -s "$TOP" "${FILES[@]}"
|
||||
vvp "$OUT"
|
45
Semaine_6/ULTRASON/scripts/windows/build.bat
Normal file
45
Semaine_6/ULTRASON/scripts/windows/build.bat
Normal file
@@ -0,0 +1,45 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
rem === Aller à la racine du projet ===
|
||||
cd /d %~dp0\..\..
|
||||
|
||||
rem === Config de base ===
|
||||
set DEVICE=GW2AR-LV18QN88C8/I7
|
||||
set BOARD=tangnano20k
|
||||
set TOP=top_uart_ultrason_command
|
||||
set CST_FILE=%TOP%.cst
|
||||
set JSON_FILE=runs/%TOP%.json
|
||||
set PNR_JSON=runs/pnr_%TOP%.json
|
||||
set BITSTREAM=runs/%TOP%.fs
|
||||
|
||||
rem === Créer le dossier runs si nécessaire ===
|
||||
if not exist runs (
|
||||
mkdir runs
|
||||
)
|
||||
|
||||
echo === Étape 1 : Synthèse avec Yosys ===
|
||||
yosys -p "read_verilog -sv src/verilog/%TOP%.v IP/verilog/ultrasonic_fpga.v IP/verilog/uart_tx_fifo.v IP/verilog/uart_rx_fifo.v IP/verilog/rxuartlite.v IP/verilog/txuartlite.v IP/verilog/fifo.v; synth_gowin -top %TOP% -json %JSON_FILE%"
|
||||
if errorlevel 1 goto error
|
||||
|
||||
echo === Étape 2 : Placement & Routage avec nextpnr-himbaechel ===
|
||||
nextpnr-himbaechel --json %JSON_FILE% --write %PNR_JSON% --device %DEVICE% --vopt cst=constraints/%CST_FILE% --vopt family=GW2A-18C
|
||||
if errorlevel 1 goto error
|
||||
|
||||
echo === Étape 3 : Packing avec gowin_pack ===
|
||||
gowin_pack -d %DEVICE% -o %BITSTREAM% %PNR_JSON%
|
||||
if errorlevel 1 goto error
|
||||
|
||||
echo === Étape 4 : Flash avec openFPGALoader ===
|
||||
openFPGALoader -b %BOARD% %BITSTREAM%
|
||||
if errorlevel 1 goto error
|
||||
|
||||
echo === Compilation et flash réussis ===
|
||||
goto end
|
||||
|
||||
:error
|
||||
echo === Une erreur est survenue ===
|
||||
|
||||
:end
|
||||
endlocal
|
||||
pause
|
4
Semaine_6/ULTRASON/scripts/windows/clean.bat
Normal file
4
Semaine_6/ULTRASON/scripts/windows/clean.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
echo === Nettoyage du dossier runs ===
|
||||
rd /s /q runs
|
||||
mkdir runs
|
3
Semaine_6/ULTRASON/scripts/windows/gtkwave.bat
Normal file
3
Semaine_6/ULTRASON/scripts/windows/gtkwave.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
echo === Lancement de GTKWave ===
|
||||
gtkwave runs/sim.vcd
|
29
Semaine_6/ULTRASON/scripts/windows/simulate.bat
Normal file
29
Semaine_6/ULTRASON/scripts/windows/simulate.bat
Normal file
@@ -0,0 +1,29 @@
|
||||
@echo off
|
||||
echo === Simulation avec Icarus Verilog ===
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: Dossier de sortie
|
||||
set OUT=runs/sim.vvp
|
||||
|
||||
:: Top-level testbench module
|
||||
set TOP=hc_sr04_tb
|
||||
|
||||
:: Répertoires contenant des fichiers .v
|
||||
set DIRS=src/verilog tests/verilog IP/verilog
|
||||
|
||||
:: Variable pour stocker les fichiers
|
||||
set FILES=
|
||||
|
||||
:: Boucle sur chaque dossier
|
||||
for %%D in (%DIRS%) do (
|
||||
for %%F in (%%D\*.v) do (
|
||||
set FILES=!FILES! %%F
|
||||
)
|
||||
)
|
||||
|
||||
:: Compilation avec Icarus Verilog
|
||||
iverilog -g2012 -o %OUT% -s %TOP% %FILES%
|
||||
|
||||
endlocal
|
||||
|
||||
vvp runs/sim.vvp
|
Reference in New Issue
Block a user