-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
530d067
commit 784a3de
Showing
30 changed files
with
580 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using OneWare.UniversalFpgaProjectSystem.Fpga; | ||
using OneWare.UniversalFpgaProjectSystem.Models; | ||
|
||
namespace OneWare.IceBreaker; | ||
|
||
public class IceBreakerFpga : FpgaBase | ||
{ | ||
public IceBreakerFpga() | ||
{ | ||
LoadFromJson("avares://OneWare.IceBreaker/Assets/IceBreakerV1.0e.json"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/OneWare.IceBreaker/ViewModels/IceBreakerFpgaViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using OneWare.UniversalFpgaProjectSystem.Models; | ||
|
||
namespace OneWare.IceBreaker.ViewModels; | ||
|
||
public class IceBreakerFpgaViewModel : FpgaModel | ||
{ | ||
public IceBreakerFpgaViewModel(IceBreakerFpga fpga) : base(fpga) | ||
{ | ||
|
||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
src/OneWare.IceBreaker/ViewModels/IceBreakerV10EViewModel.cs
This file was deleted.
Oops, something went wrong.
112 changes: 56 additions & 56 deletions
112
...IceBreaker/Views/IceBreakerV10EView.axaml → ...IceBreaker/Views/IceBreakerFpgaView.axaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 78 additions & 5 deletions
83
src/OneWare.OssCadSuiteIntegration/Yosys/YosysToolchain.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,97 @@ | ||
using OneWare.UniversalFpgaProjectSystem.Models; | ||
using OneWare.Shared.Services; | ||
using OneWare.UniversalFpgaProjectSystem.Models; | ||
using OneWare.UniversalFpgaProjectSystem.Services; | ||
using Prism.Ioc; | ||
|
||
namespace OneWare.OssCadSuiteIntegration.Yosys; | ||
|
||
public class YosysToolchain : IFpgaToolchain | ||
{ | ||
public string Name => "Yosys"; | ||
|
||
public void LoadConnections() | ||
public void LoadConnections(UniversalFpgaProjectRoot project, FpgaModel fpga) | ||
{ | ||
|
||
try | ||
{ | ||
var files = Directory.GetFiles(project.RootFolderPath); | ||
var pcfPath = files.FirstOrDefault(x => Path.GetExtension(x) == ".pcf"); | ||
if (pcfPath != null) | ||
{ | ||
var pcf = File.ReadAllText(pcfPath); | ||
var lines = pcf.Split('\n'); | ||
foreach (var line in lines) | ||
{ | ||
var trimmedLine = line.Trim(); | ||
if (trimmedLine.StartsWith("set_io")) | ||
{ | ||
var parts = trimmedLine.Split(' '); | ||
if (parts.Length != 3) | ||
{ | ||
ContainerLocator.Container.Resolve<ILogger>().Warning("PCF Line invalid: " + trimmedLine); | ||
continue; | ||
} | ||
|
||
var signal = parts[1]; | ||
var pin = parts[2]; | ||
|
||
if (fpga.PinModels.TryGetValue(pin, out var pinModel) && fpga.NodeModels.TryGetValue(signal, out var signalModel)) | ||
{ | ||
fpga.Connect(pinModel, signalModel); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
ContainerLocator.Container.Resolve<ILogger>().Error(e.Message, e); | ||
} | ||
} | ||
|
||
public void SaveConnections() | ||
public void SaveConnections(UniversalFpgaProjectRoot project, FpgaModel fpga) | ||
{ | ||
|
||
var pcfPath = Path.Combine(project.FullPath, "project.pcf"); | ||
|
||
try | ||
{ | ||
var pcf = ""; | ||
if (File.Exists(pcfPath)) | ||
{ | ||
var existingPcf = File.ReadAllText(pcfPath); | ||
existingPcf = RemoveLine(existingPcf, "set_io"); | ||
pcf = existingPcf.Trim(); | ||
} | ||
|
||
foreach (var conn in fpga.PinModels.Where(x => x.Value.Connection is not null)) | ||
{ | ||
pcf += $"\nset_io {conn.Value.Connection!.FpgaNode.Name} {conn.Value.Pin.Name}"; | ||
} | ||
pcf = pcf.Trim() + '\n'; | ||
|
||
File.WriteAllText(pcfPath, pcf); | ||
} | ||
catch (Exception e) | ||
{ | ||
ContainerLocator.Container.Resolve<ILogger>().Error(e.Message, e); | ||
} | ||
} | ||
|
||
public void StartCompile() | ||
{ | ||
|
||
} | ||
|
||
private string RemoveLine(string file, string find) | ||
{ | ||
var startIndex = file.IndexOf(find, StringComparison.Ordinal); | ||
while (startIndex > -1) | ||
{ | ||
var endIndex = file.IndexOf('\n', startIndex); | ||
if (endIndex == -1) endIndex = file.Length - 1; | ||
file = file.Remove(startIndex, endIndex - startIndex + 1); | ||
startIndex = file.IndexOf(find, startIndex, StringComparison.Ordinal); | ||
} | ||
|
||
return file; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Nodes; | ||
using System.Text.Json.Serialization; | ||
using Avalonia.Platform; | ||
|
||
namespace OneWare.UniversalFpgaProjectSystem.Fpga; | ||
|
||
public abstract class FpgaBase : IFpga | ||
{ | ||
private static readonly JsonSerializerOptions SerializerOptions = new() | ||
{ | ||
WriteIndented = true, | ||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, | ||
AllowTrailingCommas = true | ||
}; | ||
|
||
public string Name { get; private set; } = "Unknown"; | ||
|
||
public IList<FpgaPin> Pins { get; } = new List<FpgaPin>(); | ||
|
||
protected void LoadFromJson(string path) | ||
{ | ||
var stream = AssetLoader.Open(new Uri(path)); | ||
|
||
var properties = JsonSerializer.Deserialize<JsonObject>(stream, SerializerOptions); | ||
|
||
Name = properties?["Name"]?.ToString() ?? "Unknown"; | ||
|
||
foreach (var jsonNode in properties["Pins"].AsArray()) | ||
{ | ||
var description = jsonNode["Description"].ToString(); | ||
var name = jsonNode["Name"].ToString(); | ||
|
||
Pins.Add(new FpgaPin(name, description)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace OneWare.UniversalFpgaProjectSystem.Fpga; | ||
|
||
public class FpgaNode | ||
{ | ||
public string Name { get; } | ||
|
||
public string Direction { get; } | ||
|
||
public FpgaNode(string name, string direction) | ||
{ | ||
Name = name; | ||
Direction = direction; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace OneWare.UniversalFpgaProjectSystem.Fpga; | ||
|
||
public class FpgaPin | ||
{ | ||
public string Name { get; } | ||
|
||
public string? Description { get; } | ||
|
||
public FpgaPin(string name, string? description) | ||
{ | ||
Name = name; | ||
Description = description; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace OneWare.UniversalFpgaProjectSystem.Fpga; | ||
|
||
public interface IFpga | ||
{ | ||
public string Name { get; } | ||
|
||
public IList<FpgaPin> Pins { get; } | ||
} |
13 changes: 13 additions & 0 deletions
13
src/OneWare.UniversalFpgaProjectSystem/Helpers/FpgaHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Nodes; | ||
using System.Text.Json.Serialization; | ||
using Avalonia.Platform; | ||
using NodeEditor.Controls; | ||
using OneWare.UniversalFpgaProjectSystem.Models; | ||
|
||
namespace OneWare.UniversalFpgaProjectSystem.Helpers; | ||
|
||
public class FpgaHelper | ||
{ | ||
|
||
} |
Oops, something went wrong.