Refactors Xilinx ISE tool execution and report handling
Replaces repetitive tool execution logic with a reusable `run_tool` function to streamline code and reduce duplication. Introduces a shared `copy_report_file` utility for consistent report copying and error handling. Simplifies individual tool scripts (XST, NGDBuild, MAP, PAR, BitGen) by delegating core logic to common utilities. Improves maintainability and consistency across the codebase.
This commit is contained in:
@@ -4,45 +4,20 @@ import shutil
|
||||
from typing import Optional
|
||||
from models.project import ProjectConfig
|
||||
from models.config import DIRECTORIES
|
||||
from tools.xilinx_ise.common import run_tool
|
||||
|
||||
def run_bitgen(project: ProjectConfig, working_dir: Optional[str] = None):
|
||||
"""
|
||||
Führt Xilinx BitGen aus, um den finalen Bitstream zu erzeugen.
|
||||
|
||||
Args:
|
||||
project (ProjectConfig): Geladene Projektkonfiguration.
|
||||
working_dir (str, optional): Arbeitsverzeichnis; Standard: build-Verzeichnis.
|
||||
"""
|
||||
if working_dir is None:
|
||||
working_dir = DIRECTORIES.build
|
||||
def run_bitgen(project: ProjectConfig):
|
||||
run_tool(
|
||||
project=project,
|
||||
tool_executable_name="bitgen",
|
||||
tool_option_attr="bitgen",
|
||||
mandatory_arguments=[
|
||||
"-w",
|
||||
f"{project.name}.ncd",
|
||||
f"{project.name}.bit"
|
||||
]
|
||||
)
|
||||
|
||||
xilinx_bin_dir = os.path.join(project.xilinx_path, "bin", "lin64") # oder "nt64" für Windows
|
||||
bitgen_executable = os.path.join(xilinx_bin_dir, "bitgen")
|
||||
|
||||
if not os.path.exists(bitgen_executable):
|
||||
raise FileNotFoundError(f"BitGen-Executable nicht gefunden unter: {bitgen_executable}")
|
||||
|
||||
print(f"[hdlbuild] Starte BitGen über {bitgen_executable}")
|
||||
print(f"[hdlbuild] Arbeitsverzeichnis: {working_dir}")
|
||||
|
||||
cmd = [bitgen_executable]
|
||||
|
||||
# Füge zuerst die "common" Optionen ein (falls vorhanden)
|
||||
if project.tool_options and project.tool_options.common:
|
||||
cmd.extend(project.tool_options.common)
|
||||
|
||||
# Dann die BitGen-spezifischen Optionen
|
||||
if project.tool_options and project.tool_options.bitgen:
|
||||
cmd.extend(project.tool_options.bitgen)
|
||||
|
||||
# Dann die Pflicht-Argumente
|
||||
cmd.extend([
|
||||
"-w",
|
||||
f"{project.name}.ncd",
|
||||
f"{project.name}.bit"
|
||||
])
|
||||
|
||||
subprocess.run(cmd, cwd=working_dir, check=True)
|
||||
|
||||
def copy_bitstream_file(project: ProjectConfig):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user