Skip to content

Commit ac943ab

Browse files
author
Salvador Santoluctio
committed
added file to get netlist
1 parent 526aacd commit ac943ab

File tree

2 files changed

+43
-19
lines changed

2 files changed

+43
-19
lines changed

labview_fpga_hdl_tools/get_window_netlist.py

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313

1414

1515
def _get_window_netlist(config, test=False):
16-
"""Gets the Window netlist from the Vivado Project as well as other HDL Files.
17-
18-
Args:
19-
config: Configuration settings object
20-
test (bool): If True, skip running Vivado
21-
"""
16+
"""Gets the Window netlist from the Vivado Project as well as other HDL Files."""
2217
get_netlist_tcl_path = os.path.join(os.getcwd(), "TCL/GetWindowNetlist.tcl")
2318
current_dir = os.getcwd()
2419

@@ -40,9 +35,21 @@ def _get_window_netlist(config, test=False):
4035
else: # Linux or other OS
4136
vivado_executable = os.path.join(vivado_path, "bin", "vivado")
4237

38+
source_file = os.path.join(vivado_project_path, "TheWindow.edf")
39+
destination_folder = config.the_window_folder_output
40+
41+
# Create destination directory if it doesn't exist
42+
os.makedirs(destination_folder, exist_ok=True)
43+
4344
# In test mode, skip running Vivado
4445
if test:
4546
print("TEST MODE: Skipping Vivado execution")
47+
48+
# In test mode, create a mock EDF file if it doesn't exist
49+
if not os.path.exists(source_file):
50+
with open(source_file, "w") as f:
51+
f.write("# Mock EDF file created for testing\n")
52+
print(f"Created mock EDF file for testing: {source_file}")
4653
else:
4754
print(f"Current working directory: {os.getcwd()}")
4855
common.run_command(
@@ -51,18 +58,32 @@ def _get_window_netlist(config, test=False):
5158
capture_output=False,
5259
)
5360

54-
# Create a mock EDF file in test mode
55-
source_file = os.path.join(vivado_project_path, "TheWindow.edf")
56-
destination_folder = config.the_window_folder_output
61+
# Check for success marker in vivado.log file
62+
vivado_log_path = os.path.join(os.getcwd(), "vivado.log")
63+
if not os.path.exists(vivado_log_path):
64+
os.chdir(current_dir)
65+
raise RuntimeError("Vivado log file not found. TCL script execution may have failed.")
5766

58-
# Create destination directory if it doesn't exist
59-
os.makedirs(destination_folder, exist_ok=True)
67+
# Read the log file and check for success marker
68+
try:
69+
with open(vivado_log_path, "r", encoding="utf-8", errors="replace") as log_file:
70+
log_content = log_file.read()
71+
# This GET_WINDOW=FAILED constant is set in the GetWindowNetlist.tcl file
72+
# We have not found a better way to surface an error from Vivado executing a
73+
# TCL script up to Python
74+
if "GET_WINDOW=FAILED" in log_content:
75+
os.chdir(current_dir)
76+
raise RuntimeError("Window netlist extraction failed.")
77+
except Exception as e:
78+
os.chdir(current_dir)
79+
raise RuntimeError(f"Errors found in Vivado log file: {str(e)}")
6080

61-
# In test mode, create a mock EDF file if it doesn't exist
62-
if test and not os.path.exists(source_file):
63-
with open(source_file, "w") as f:
64-
f.write("# Mock EDF file created for testing\n")
65-
print(f"Created mock EDF file for testing: {source_file}")
81+
# Check if the expected output file was generated
82+
if not os.path.exists(source_file):
83+
os.chdir(current_dir)
84+
raise RuntimeError(
85+
f"Vivado TCL script execution failed: Expected output file {source_file} was not generated."
86+
)
6687

6788
destination_file = os.path.join(destination_folder, "TheWindow.edf")
6889

@@ -71,9 +92,11 @@ def _get_window_netlist(config, test=False):
7192
shutil.copy(source_file, destination_file)
7293
print(f"Copied {source_file} to {destination_file}")
7394
else:
74-
print(f"Error: Source file {source_file} not found")
95+
os.chdir(current_dir)
96+
raise FileNotFoundError(f"Source file {source_file} not found")
7597
except Exception as e:
76-
print(f"Error copying file: {str(e)}")
98+
os.chdir(current_dir)
99+
raise RuntimeError(f"Error copying file: {str(e)}")
77100

78101
os.chdir(current_dir)
79102

@@ -94,6 +117,7 @@ def _copy_lv_generated_files(config):
94117
"PkgLvFpgaConst.vhd",
95118
"PkgCommIntConfiguration.vhd",
96119
"PkgDmaPortCommIfcRegs.vhd",
120+
"PkgDmaPortDmaFifos.vhd",
97121
]
98122

99123
for file_name in files_to_copy:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "labview-fpga-hdl-tools"
7-
version = "0.0.21"
7+
version = "0.0.22"
88
description = "LabVIEW FPGA HDL Tools"
99
authors = [
1010
"Salvador Santolucito <salvador.santolucito@gmail.com>"

0 commit comments

Comments
 (0)