Skip to content

Commit

Permalink
Merge pull request #36 from FEntwumS/feature/projectVHDLStandard
Browse files Browse the repository at this point in the history
Adding a project-specific VHDL standard
  • Loading branch information
HendrikMennen authored Jan 16, 2025
2 parents 2da36d5 + 3b20f1b commit ce81309
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class UniversalFpgaProjectSettingsEditorViewModel : FlexibleWindowViewMod

private ComboBoxSetting _toolchain;
private ComboBoxSetting _loader;
private ComboBoxSetting? _vhdlStandard;

private ListBoxSetting _includesSettings;
private ListBoxSetting _excludesSettings;
Expand All @@ -41,6 +42,13 @@ public UniversalFpgaProjectSettingsEditorViewModel(UniversalFpgaProjectRoot root
_projectExplorerService = projectExplorerService;
_fpgaService = fpgaService;
Title = $"{_root.Name} Settings";

if (root.TopEntity != null && (root.TopEntity.Name.Contains("vhd") || root.TopEntity.Name.Contains("vhdl")))
{
var standard = _root.Properties["VHDL_Standard"];
var value = standard == null ? "" : standard.ToString();
_vhdlStandard = new ComboBoxSetting("VHDL Standard", value, ["87", "93", "93c", "00", "02", "08", "19"]);
}

var includes = _root.Properties["Include"]!.AsArray().Select(node => node!.ToString()).ToArray();
var exclude = _root.Properties["Exclude"]!.AsArray().Select(node => node!.ToString()).ToArray();
Expand All @@ -52,14 +60,21 @@ public UniversalFpgaProjectSettingsEditorViewModel(UniversalFpgaProjectRoot root
var loader = ContainerLocator.Container.Resolve<FpgaService>().Loaders.Select(loader => loader.Name);
var currentLoader = _root.Properties["Loader"]!.ToString();
_loader = new ComboBoxSetting("Loader", currentLoader, loader);

_includesSettings = new ListBoxSetting("Files to Include", includes);
_excludesSettings = new ListBoxSetting("Files to Exclude", exclude);


SettingsCollection.SettingModels.Add(_toolchain);
SettingsCollection.SettingModels.Add(_loader);

if (_vhdlStandard != null) {
SettingsCollection.SettingModels.Add(_vhdlStandard);
}

SettingsCollection.SettingModels.Add(_includesSettings);
SettingsCollection.SettingModels.Add(_excludesSettings);

}

private async Task SaveAsync()
Expand All @@ -75,6 +90,9 @@ private async Task SaveAsync()
_root.SetProjectPropertyArray("Include", _includesSettings.Items.Select(item => item.ToString()).ToArray());
_root.SetProjectPropertyArray("Exclude", _excludesSettings.Items.Select(item => item.ToString()).ToArray());

if (_vhdlStandard.Value.ToString() != null)
_root.SetProjectProperty("VHDL_Standard", _vhdlStandard.Value.ToString()!);

await _projectExplorerService.SaveProjectAsync(_root);
await _projectExplorerService.ReloadAsync(_root);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
x:Class="OneWare.UniversalFpgaProjectSystem.Views.UniversalFpgaProjectSettingsEditorView"
x:DataType="viewModels:UniversalFpgaProjectSettingsEditorViewModel"
Name="UniversalFpgaProjectCompileViewView">
<DockPanel>
<ScrollViewer DockPanel.Dock="Top">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<ScrollViewer Grid.Row="0">
<ContentControl Padding="4" Content="{Binding SettingsCollection}" />
</ScrollViewer>

<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Margin="8" Classes="WindowButtons"
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="8" Classes="WindowButtons"
HorizontalAlignment="Right"
VerticalAlignment="Bottom">
<Button Command="{Binding SaveAndCloseAsync}"
Expand All @@ -27,5 +32,5 @@
<TextBlock Text="Save and Close" Margin="5 0" />
</Button>
</StackPanel>
</DockPanel>
</Grid>
</controls:FlexibleWindow>

0 comments on commit ce81309

Please sign in to comment.