Skip to content

Commit

Permalink
add vhdp template and update
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Mar 15, 2024
1 parent cbff9ff commit 8fc5a33
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 8 deletions.
21 changes: 21 additions & 0 deletions oneware-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@
"url": "https://github.com/ProtopSolutions/OneWare.Vhdp/releases/download/0.3/OneWare.VhdpExtension_0.3_osx-arm64.zip"
}
]
},
{
"version": "0.4",
"targets": [
{
"target": "win-x64",
"url": "https://github.com/ProtopSolutions/OneWare.Vhdp/releases/download/0.4/OneWare.VhdpExtension_0.4_win-x64.zip"
},
{
"target": "linux-x64",
"url": "https://github.com/ProtopSolutions/OneWare.Vhdp/releases/download/0.4/OneWare.VhdpExtension_0.4_linux-x64.zip"
},
{
"target": "osx-x64",
"url": "https://github.com/ProtopSolutions/OneWare.Vhdp/releases/download/0.4/OneWare.VhdpExtension_0.4_osx-x64.zip"
},
{
"target": "osx-arm64",
"url": "https://github.com/ProtopSolutions/OneWare.Vhdp/releases/download/0.4/OneWare.VhdpExtension_0.4_osx-arm64.zip"
}
]
}
]
}
16 changes: 16 additions & 0 deletions src/OneWare.Vhdp/Assets/Templates/VhdpBlink/%PROJECTNAME%.vhdp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Main
(
led: OUT STD_LOGIC := '0';
)
{
Process()
{
Thread
{
led <= '0';
Wait(250ms);
led <= '1';
Wait(250ms);
}
}
}
5 changes: 3 additions & 2 deletions src/OneWare.Vhdp/HdpProjectContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public void Deactivate()

public void ProcessChanges(string fullPath, Container<TextDocumentContentChangeEvent> changes)
{
_documents[fullPath] = ApplyChanges(_documents[fullPath], changes);
if (_documents.TryGetValue(fullPath, out string? value))
_documents[fullPath] = ApplyChanges(value, changes);
}

private static string ApplyChanges(string document, IEnumerable<TextDocumentContentChangeEvent> changes)
Expand Down Expand Up @@ -164,7 +165,7 @@ public void AddPath(string fullPath)

public void RemovePath(string fullPath)
{
if (_projectRoot?.Search(fullPath) is { } entry)
if (_projectRoot?.SearchFullPath(fullPath) is { } entry)
{
_analyzerContexts.Remove(fullPath);
}
Expand Down
11 changes: 7 additions & 4 deletions src/OneWare.Vhdp/OneWare.Vhdp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>0.3</Version>
<Version>0.4</Version>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand All @@ -12,12 +12,15 @@

<ItemGroup>
<Content Include="oneware.json" CopyToOutputDirectory="PreserveNewest"/>
<AvaloniaResource Include="Assets\**\*.*" />
<AvaloniaResource Include="Assets\*.*" />
<Content Include="Assets\Templates\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="OneWare.Essentials" Version="0.1" Private="false" ExcludeAssets="runtime;Native"/>
<PackageReference Include="OneWare.UniversalFpgaProjectSystem" Version="0.14" Private="false" ExcludeAssets="runtime;Native"/>
<PackageReference Include="OneWare.Essentials" Version="0.4.3" Private="false" ExcludeAssets="runtime;Native" />
<PackageReference Include="OneWare.UniversalFpgaProjectSystem" Version="0.16.4" Private="false" ExcludeAssets="runtime;Native" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/OneWare.Vhdp/OneWareVhdpModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using OneWare.Essentials.Models;
using OneWare.Essentials.Services;
using OneWare.Essentials.ViewModels;
using OneWare.UniversalFpgaProjectSystem.Services;
using OneWare.Vhdp.Templates;
using Prism.Ioc;
using Prism.Modularity;

Expand All @@ -18,5 +20,7 @@ public void OnInitialized(IContainerProvider containerProvider)
containerProvider.Resolve<IErrorService>().RegisterErrorSource("VHDP");

containerProvider.Resolve<ILanguageManager>().RegisterService(typeof(LanguageServiceVhdp),true, ".vhdp");

containerProvider.Resolve<FpgaService>().RegisterTemplate<VhdpBlinkTemplate>();
}
}
36 changes: 36 additions & 0 deletions src/OneWare.Vhdp/Templates/VhdpBlinkTemplate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Text.Json.Nodes;
using OneWare.Essentials.Services;
using OneWare.UniversalFpgaProjectSystem.Helpers;
using OneWare.UniversalFpgaProjectSystem.Models;
using OneWare.UniversalFpgaProjectSystem.Services;

namespace OneWare.Vhdp.Templates;

public class VhdpBlinkTemplate(ILogger logger, IDockService dockService) : IFpgaProjectTemplate
{
public string Name => "VHDP Blink";

public void FillTemplate(UniversalFpgaProjectRoot root)
{
var codeBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new NullReferenceException(Assembly.GetExecutingAssembly().Location);

var path = Path.Combine(codeBase, "Assets", "Templates", "VhdpBlink");

try
{
var name = root.Header.Replace(" ", "");
TemplateHelper.CopyDirectoryAndReplaceString(path, root.FullPath, ("%PROJECTNAME%", name));
var file = root.AddFile(name + ".vhdp");
root.TopEntity = file;

root.IncludePath("*.vhdp");

_ = dockService.OpenFileAsync(file);
}
catch (Exception e)
{
logger.Error(e.Message, e);
}
}
}
9 changes: 7 additions & 2 deletions src/OneWare.Vhdp/oneware.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
"Dependencies": [
{
"Name": "OneWare.Essentials",
"MinVersion": "0.1.0.0",
"MaxVersion": "0.1.0.0"
"MinVersion": "0.4.3.0",
"MaxVersion": "0.4.3.0"
},
{
"Name": "OneWare.UniversalFpgaProjectSystem",
"MinVersion": "0.16.4.0",
"MaxVersion": "0.16.4.0"
}
]
}

0 comments on commit 8fc5a33

Please sign in to comment.