public async Task <bool> UpdateFromFiles(IReadOnlyList <IBrowserFile> files, bool isVerilogVCD) { Clear(); var firFiles = files.Where(x => x.Name.EndsWith(".fir")).ToList(); if (firFiles.Count == 0) { return(false); } IBrowserFile hiFirrtlFile = null; IBrowserFile loFirrtlFile = null; IBrowserFile vcdFile = null; if (firFiles.Count(x => !x.Name.Contains(".lo.")) == 1) { hiFirrtlFile = firFiles.Single(x => !x.Name.Contains(".lo.fir")); } else { hiFirrtlFile = firFiles.OrderByDescending(x => x.Name.Split('.').Length).Last(); } if (firFiles.Count > 1) { loFirrtlFile = firFiles.Where(x => x != hiFirrtlFile).OrderByDescending(x => x.Name.Split('.').Length).First(); } vcdFile = files.FirstOrDefault(x => x.Name.EndsWith(".vcd")); var hiFirrtlPath = CopyBrowserFileToMemory(hiFirrtlFile); var loFirrtlPath = CopyBrowserFileToMemory(loFirrtlFile); var vcdPath = CopyBrowserFileToMemory(vcdFile); await Task.WhenAll(hiFirrtlPath, loFirrtlPath, vcdPath); HiFirrtlStream = hiFirrtlPath.Result; LoFirrtlStream = loFirrtlPath.Result; VCDStream = vcdPath.Result; IsVerilogVCD = isVerilogVCD; Ready = true; OnViewCircuit?.Invoke(); return(true); }
public void UpdateFromPath(string hiFirrtlPath, string loFirrtlPath, string vcdPath, bool isVerilogVCD) { Clear(); if (File.Exists(hiFirrtlPath)) { HiFirrtlStream = File.OpenRead(hiFirrtlPath); } if (File.Exists(loFirrtlPath)) { LoFirrtlStream = File.OpenRead(loFirrtlPath); } if (File.Exists(vcdPath)) { VCDStream = File.OpenRead(vcdPath); } IsVerilogVCD = isVerilogVCD; Ready = true; OnViewCircuit?.Invoke(); }