Adds progress tracking and new trace tool integration

Introduces step tracking for Xilinx toolchain stages with step number and total steps added to tool execution calls. Enhances user feedback during execution.

Refactors `run_tool` to improve progress display and integrates `ConsoleTask` for better command handling. Simplifies code comments and improves readability.

Implements the `trace` tool support, including execution and report generation for timing analysis.

Adds minor enhancements like file copy feedback with icons.
This commit is contained in:
2025-04-26 14:41:43 +00:00
parent 5c52c0cf59
commit decc18ac83
7 changed files with 46 additions and 26 deletions

View File

@@ -15,7 +15,7 @@ def run_bitgen(project: ProjectConfig):
"-w",
f"{project.name}.ncd",
f"{project.name}.bit"
]
], step_number=5, total_steps=6
)

View File

@@ -1,58 +1,51 @@
import shutil
import subprocess
import os
import threading
import time
import sys
from typing import Optional, List
from models.project import ProjectConfig
from models.config import DIRECTORIES
from utils.console_utils import ConsoleTask
def run_tool(
project: ProjectConfig,
tool_executable_name: str,
mandatory_arguments: List[str],
tool_option_attr: Optional[str] = None,
working_dir: Optional[str] = None
working_dir: Optional[str] = None,
silent: bool = False,
step_number: Optional[int] = None,
total_steps: Optional[int] = None
):
"""
Führt ein beliebiges Xilinx ISE Tool aus (XST, NGDBuild, MAP, PAR, BitGen),
mit Common- und ggf. Toolspezifischen Optionen + festen Pflichtargumenten.
Args:
project (ProjectConfig): Das Projekt-Objekt
tool_executable_name (str): z.B. "xst", "map", "par", "bitgen"
mandatory_arguments (List[str]): Liste mit Pflicht-Argumenten
tool_option_attr (Optional[str]): Attribut-Name in tool_options, z.B. "xst", "map"
working_dir (Optional[str]): Arbeitsverzeichnis
"""
if working_dir is None:
working_dir = DIRECTORIES.build
xilinx_bin_dir = os.path.join(project.xilinx_path, "bin", "lin64") # oder "nt64"
xilinx_bin_dir = os.path.join(project.xilinx_path, "bin", "lin64")
tool_executable = os.path.join(xilinx_bin_dir, tool_executable_name)
if not os.path.exists(tool_executable):
raise FileNotFoundError(f"Executable nicht gefunden: {tool_executable}")
print(f"[hdlbuild] Starte {tool_executable_name.upper()} über {tool_executable}")
print(f"[hdlbuild] Arbeitsverzeichnis: {working_dir}")
step_info = f"[{step_number}/{total_steps}] " if step_number and total_steps else ""
progress_line = f"{step_info}[hdlbuild] Starte {tool_executable_name.upper()}..."
cmd = [tool_executable]
# Füge zuerst "common" Optionen ein
if project.tool_options and project.tool_options.common:
cmd.extend(project.tool_options.common)
# Füge dann Toolspezifische Optionen ein (nur wenn angegeben)
if tool_option_attr and project.tool_options:
tool_opts = getattr(project.tool_options, tool_option_attr, [])
if tool_opts:
cmd.extend(tool_opts)
# Füge die Pflicht-Argumente an
cmd.extend(mandatory_arguments)
print(f"[hdlbuild] Befehl: {' '.join(cmd)}")
task = ConsoleTask(progress_line)
task.run_command(cmd, cwd=working_dir, silent=silent)
subprocess.run(cmd, cwd=working_dir, check=True)
def copy_report_file(
project: ProjectConfig,
@@ -78,4 +71,4 @@ def copy_report_file(
os.makedirs(DIRECTORIES.report, exist_ok=True)
shutil.copyfile(src_path, dst_path)
print(f"[hdlbuild] {description} kopiert nach {dst_path}")
print(f"[hdlbuild] {description} kopiert nach {dst_path} 🗎")

View File

@@ -17,7 +17,7 @@ def run_map(project: ProjectConfig):
f"{project.name}.ngd",
"-o", f"{project.name}.map.ncd",
f"{project.name}.pcf"
]
], step_number=3, total_steps=6
)
def copy_map_report(project: ProjectConfig):

View File

@@ -15,5 +15,5 @@ def run_ngdbuild(project: ProjectConfig):
"-uc", f"{DIRECTORIES.get_relative_prefix()}{project.constraints}",
f"{project.name}.ngc",
f"{project.name}.ngd"
]
], step_number=2, total_steps=6
)

View File

@@ -16,7 +16,7 @@ def run_par(project: ProjectConfig):
f"{project.name}.map.ncd",
f"{project.name}.ncd",
f"{project.name}.pcf"
]
], step_number=4, total_steps=6
)
def copy_par_report(project: ProjectConfig):

View File

@@ -0,0 +1,26 @@
import subprocess
import os
import shutil
from typing import Optional
from models.project import ProjectConfig
from models.config import DIRECTORIES
from tools.xilinx_ise.common import copy_report_file, run_tool
def run_trace(project: ProjectConfig):
run_tool(
project=project,
tool_executable_name="trce",
tool_option_attr="trace",
mandatory_arguments=[
f"{project.name}.ncd",
f"{project.name}.pcf",
], step_number=6, total_steps=6
)
def copy_trace_report(project: ProjectConfig):
copy_report_file(
project=project,
source_filename=f"{project.name}.twr",
destination_filename=f"{project.name}.TimingReport",
description="Timing Report"
)

View File

@@ -49,7 +49,8 @@ def run_xst(project: ProjectConfig):
run_tool(
project=project,
tool_executable_name="xst",
mandatory_arguments=["-ifn", f"{project.name}.scr"]
mandatory_arguments=["-ifn", f"{project.name}.scr",
], step_number=1, total_steps=6
)
def copy_synthesis_report(project: ProjectConfig):