Skip to content

Commit 934558e

Browse files
author
Salvador Santoluctio
committed
only gen window VHDL during create project
1 parent 2e7bf64 commit 934558e

File tree

2 files changed

+100
-62
lines changed

2 files changed

+100
-62
lines changed

labview_fpga_hdl_tools/create_vivado_project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,10 +661,10 @@ def create_project(overwrite=False, update=False, test=False):
661661
return 1
662662

663663
if len(config.window_vhdl_templates) > 0:
664-
# Run (or rerun) generate LV target support - this is needed to generate TheWindow.vhd that goes
664+
# Run (or rerun) generate LV Window VHDL - this is needed to generate TheWindow.vhd that goes
665665
# into the objects directory and which gets used in the Vivado project
666666
try:
667-
gen_labview_target_plugin.gen_lv_target_support()
667+
gen_labview_target_plugin.gen_window_vhdl()
668668
except Exception as e:
669669
print(f"Error: {e}")
670670
return 1

labview_fpga_hdl_tools/gen_labview_target_plugin.py

Lines changed: 98 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -663,96 +663,101 @@ def _copy_targetinfo_ini(plugin_folder, targetinfo_path):
663663
print("Warning: Could not resolve path to TargetInfo.ini")
664664

665665

666-
def _validate_ini(config):
667-
"""Validate that all required configuration settings are present.
666+
def _validate_ini(config, gen_window_only=False):
667+
"""Validate that required configuration settings are present.
668668
669-
This function checks that all settings required for target plugin generation
670-
are present in the configuration object and validates that all specified paths exist.
669+
This function checks configuration settings and validates that all specified paths exist.
670+
When gen_window_only is True, only validates settings needed for Window VHDL generation.
671671
672672
Args:
673673
config: Configuration object containing settings from INI file
674+
gen_window_only: If True, only validate settings for Window VHDL generation
674675
675676
Raises:
676677
ValueError: If any required settings are missing or paths are invalid
677678
"""
678679
missing_settings = []
679680
invalid_paths = []
680681

681-
# Required general settings
682-
if not config.target_family:
683-
missing_settings.append("GeneralSettings.TargetFamily")
684-
685-
if not config.base_target:
686-
missing_settings.append("GeneralSettings.BaseTarget")
687-
688-
# Required plugin settings
689-
if not config.lv_target_plugin_folder:
690-
missing_settings.append("LVFPGATargetSettings.LVTargetPluginFolder")
691-
692-
if not config.lv_target_name:
693-
missing_settings.append("LVFPGATargetSettings.LVTargetName")
694-
695-
if not config.lv_target_guid:
696-
missing_settings.append("LVFPGATargetSettings.LVTargetGUID")
697-
698-
# Validate input files and folders
682+
# Validate input CSV if custom IO is included (required for both modes)
699683
if config.include_custom_io and not config.custom_signals_csv:
700684
missing_settings.append("LVFPGATargetSettings.LVTargetBoardIO")
701685

702-
if not config.boardio_output:
703-
missing_settings.append("LVFPGATargetSettings.BoardIOXML")
704-
705-
if not config.clock_output:
706-
missing_settings.append("LVFPGATargetSettings.ClockXML")
707-
686+
# Validate Window VHDL template paths (required for both modes)
708687
if not config.window_vhdl_templates:
709688
missing_settings.append("LVFPGATargetSettings.WindowVhdlTemplates")
710689
else:
711-
# Validate each template file path
712690
for i, template_path in enumerate(config.window_vhdl_templates):
713691
invalid_path = common.validate_path(
714692
template_path, f"LVFPGATargetSettings.WindowVhdlTemplates[{i}]", "file"
715693
)
716694
if invalid_path:
717695
invalid_paths.append(invalid_path)
718696

697+
# Validate output folder setting (required for both modes)
719698
if not config.window_vhdl_output_folder:
720699
missing_settings.append("LVFPGATargetSettings.WindowVhdlOutputFolder")
721700

722-
if not config.board_io_signal_assignments_example:
723-
missing_settings.append("LVFPGATargetSettings.BoardIOSignalAssignmentsExample")
701+
# Only validate additional settings if generating full target support
702+
if not gen_window_only:
703+
# Required general settings
704+
if not config.target_family:
705+
missing_settings.append("GeneralSettings.TargetFamily")
724706

725-
# Check list settings
726-
if not config.hdl_file_lists:
727-
missing_settings.append("VivadoProjectSettings.VivadoProjectFilesLists")
728-
else:
729-
# Validate each file list path
730-
for i, file_list_path in enumerate(config.hdl_file_lists):
731-
invalid_path = common.validate_path(
732-
file_list_path, f"VivadoProjectSettings.VivadoProjectFilesLists[{i}]", "file"
733-
)
734-
if invalid_path:
735-
invalid_paths.append(invalid_path)
707+
if not config.base_target:
708+
missing_settings.append("GeneralSettings.BaseTarget")
736709

737-
if not config.target_xml_templates:
738-
missing_settings.append("LVFPGATargetSettings.TargetXMLTemplates")
739-
else:
740-
# Validate each template file path
741-
for i, template_path in enumerate(config.target_xml_templates):
742-
invalid_path = common.validate_path(
743-
template_path, f"LVFPGATargetSettings.TargetXMLTemplates[{i}]", "file"
744-
)
745-
if invalid_path:
746-
invalid_paths.append(invalid_path)
710+
# Required plugin settings
711+
if not config.lv_target_plugin_folder:
712+
missing_settings.append("LVFPGATargetSettings.LVTargetPluginFolder")
747713

748-
# Validate any constraint files if specified
749-
if config.lv_target_constraints_files:
750-
for i, constraint_path in enumerate(config.lv_target_constraints_files):
751-
invalid_path = common.validate_path(
752-
constraint_path, f"LVFPGATargetSettings.LVTargetConstraintsFiles[{i}]", "file"
753-
)
754-
if invalid_path:
755-
invalid_paths.append(invalid_path)
714+
if not config.lv_target_name:
715+
missing_settings.append("LVFPGATargetSettings.LVTargetName")
716+
717+
if not config.lv_target_guid:
718+
missing_settings.append("LVFPGATargetSettings.LVTargetGUID")
719+
720+
# Validate input files and folders
721+
if not config.boardio_output:
722+
missing_settings.append("LVFPGATargetSettings.BoardIOXML")
723+
724+
if not config.clock_output:
725+
missing_settings.append("LVFPGATargetSettings.ClockXML")
726+
727+
if not config.board_io_signal_assignments_example:
728+
missing_settings.append("LVFPGATargetSettings.BoardIOSignalAssignmentsExample")
729+
730+
# Check list settings
731+
if not config.hdl_file_lists:
732+
missing_settings.append("VivadoProjectSettings.VivadoProjectFilesLists")
733+
else:
734+
# Validate each file list path
735+
for i, file_list_path in enumerate(config.hdl_file_lists):
736+
invalid_path = common.validate_path(
737+
file_list_path, f"VivadoProjectSettings.VivadoProjectFilesLists[{i}]", "file"
738+
)
739+
if invalid_path:
740+
invalid_paths.append(invalid_path)
741+
742+
if not config.target_xml_templates:
743+
missing_settings.append("LVFPGATargetSettings.TargetXMLTemplates")
744+
else:
745+
# Validate each template file path
746+
for i, template_path in enumerate(config.target_xml_templates):
747+
invalid_path = common.validate_path(
748+
template_path, f"LVFPGATargetSettings.TargetXMLTemplates[{i}]", "file"
749+
)
750+
if invalid_path:
751+
invalid_paths.append(invalid_path)
752+
753+
# Validate any constraint files if specified
754+
if config.lv_target_constraints_files:
755+
for i, constraint_path in enumerate(config.lv_target_constraints_files):
756+
invalid_path = common.validate_path(
757+
constraint_path, f"LVFPGATargetSettings.LVTargetConstraintsFiles[{i}]", "file"
758+
)
759+
if invalid_path:
760+
invalid_paths.append(invalid_path)
756761

757762
# Construct error message
758763
error_msg = common.get_missing_settings_error(missing_settings)
@@ -764,6 +769,39 @@ def _validate_ini(config):
764769
raise ValueError(error_msg)
765770

766771

772+
def gen_window_vhdl():
773+
"""Generate Window VHDL files only.
774+
775+
Standalone entry point for generating Window VHDL files from CSV and templates.
776+
This is useful when you only need to regenerate VHDL interface files without
777+
rebuilding the entire target plugin.
778+
779+
Returns:
780+
int: 0 if successful, 1 if errors occurred
781+
"""
782+
# Load configuration
783+
config = common.load_config()
784+
785+
# Validate that required settings for Window VHDL generation are present
786+
try:
787+
_validate_ini(config, gen_window_only=True)
788+
except Exception as e:
789+
print(f"Error: {e}")
790+
return 1
791+
792+
# Generate Window VHDL files
793+
_generate_window_vhdl_from_csv(
794+
config.custom_signals_csv,
795+
config.window_vhdl_templates,
796+
config.window_vhdl_output_folder,
797+
config.include_clip_socket_ports,
798+
config.include_custom_io,
799+
)
800+
801+
print("Window VHDL generation complete.")
802+
return 0
803+
804+
767805
def gen_lv_target_support():
768806
"""Generate target support files."""
769807
# Load configuration

0 commit comments

Comments
 (0)