public static BuildResult BuildProject(string workingDirectory, string projectFilePath, string topModule) { string fusePath = XilinxHelper.GetXilinxToolPath("fuse.exe"); if (string.IsNullOrEmpty(fusePath)) { fusePath = XilinxHelper.GetXilinxToolPath("fuse"); if (string.IsNullOrEmpty(fusePath)) { throw new Exception("Unable to find the fuse Executable"); } } // Create prj file on disk string projectExecutablePath = PathHelper.Combine(workingDirectory, "x.exe"); List <string> arguments = new List <string>(); arguments.Add(string.Format("--prj \"{0}\"", projectFilePath)); //arguments.Add(string.Format("-o \"{0}\"", projectExecutablePath)); arguments.Add(topModule); ProcessHelper.ProcessExecutionResult result = XilinxProcess.ExecuteProcess(workingDirectory, fusePath, arguments); BuildResult buildResult = new BuildResult(); buildResult.BuildLog = result.StandardOutput + "\n\n\n" + result.StandardError; buildResult.WorkingDirectory = workingDirectory; buildResult.ExecutableFile = projectExecutablePath; buildResult.Built = true; return(buildResult); }
public static List <string> LoadFamilyList() { List <string> families = new List <string>(); ProcessHelper.ProcessExecutionResult result = XilinxProcess.ExecuteProcess(Environment.CurrentDirectory, "partgen", null); bool startedList = false; using (StringReader reader = new StringReader(result.StandardOutput)) { string line; while ((line = reader.ReadLine()) != null) { if (!startedList) { if (line.EndsWith("Valid architectures are:", StringComparison.InvariantCultureIgnoreCase)) { startedList = true; } } else { // Successive lines are now device families string cleanup = line.Trim(); if (!string.IsNullOrEmpty(cleanup)) { families.Add(cleanup); } } } } return(families); }
public bool Build() { string projectName = Path.GetFileNameWithoutExtension(NCDFile); string projectNcdFilePath = PathHelper.Combine(OutputLocation.TemporaryDirectory, string.Format("{0}.ncd", projectName)); string projectParFilePath = PathHelper.Combine(OutputLocation.TemporaryDirectory, string.Format("{0}.par", projectName)); string projectGrfFilePath = PathHelper.Combine(OutputLocation.TemporaryDirectory, string.Format("{0}.grf", projectName)); // Setup Arguments List<string> arguments = new List<string>(); // Default configuration arguments.Add("-w"); // Overwrite existing files arguments.Add("-ol high"); // Effort Level arguments.Add("-mt off"); // Multi-Thread execution not avaliable on all parts // The Input NCD if (string.IsNullOrEmpty(NCDFile) || !File.Exists(NCDFile)) { throw new FileNotFoundException("NCD File does not exist."); } arguments.Add(string.Format("\"{0}\"", NCDFile)); // Output NCD File arguments.Add(string.Format("\"{0}\"", projectNcdFilePath)); // The Input PCF if (string.IsNullOrEmpty(PCFFile) || !File.Exists(PCFFile)) { throw new FileNotFoundException("PCF File does not exist."); } arguments.Add(string.Format("\"{0}\"", PCFFile)); // Prepare Process XilinxProcess process = new XilinxProcess(Toolchain, "par", arguments); DefaultMessageParser parser = new DefaultMessageParser(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.WorkingDirectory = OutputLocation.TemporaryDirectory; process.Start(); process.WaitForExit(); // Copy logs to the log directory OutputLocation.CopyLogFile(projectParFilePath); OutputLocation.CopyLogFile(projectGrfFilePath); // Copy Artifacts to output directory OutputLocation.CopyOutputFile(projectNcdFilePath); // Check if the process completed correctly if (process.CurrentProcess.ExitCode != 0 || !File.Exists(projectNcdFilePath)) { return false; } return true; }
public static BuildResult BuildProject(string workingDirectory, PrjFile projectFile, IModule topModule) { // Create prj file on disk string toplevelComponentName = string.Format("{0}.{1}", topModule.Parent.Name, topModule.Name); string projectFilePath = PathHelper.Combine(workingDirectory, "projectfile.prj"); File.WriteAllText(projectFilePath, projectFile.ToString(ExecutionType.SynthesisOnly)); string projectXstFilePath = PathHelper.Combine(workingDirectory, "projectfile.xst"); string projectSyrFilePath = PathHelper.Combine(workingDirectory, "projectfile.syr"); string projectXstPath = PathHelper.Combine(workingDirectory, "xst"); string projectTmpPath = PathHelper.Combine(projectXstPath, ".tmp"); File.WriteAllText(projectXstFilePath, GenerateScript(workingDirectory, projectFilePath, topModule.Name)); Directory.CreateDirectory(projectXstPath); Directory.CreateDirectory(projectTmpPath); Logger.Instance.WriteDebug("Top Level component name: {0}", toplevelComponentName); Logger.Instance.WriteDebug("Xst path: {0}", projectXstFilePath); List <string> arguments = new List <string>(); arguments.Add(string.Format("-ifn \"{0}\"", projectXstFilePath)); arguments.Add(string.Format("-ofn \"{0}\"", projectSyrFilePath)); XilinxProcess process = new XilinxProcess("xst", arguments); DefaultMessageParser parser = new DefaultMessageParser(); StringProcessListener stringParser = new StringProcessListener(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.Listeners.Add(stringParser); process.WorkingDirectory = workingDirectory; process.Start(); process.WaitForExit(); BuildResult buildResult = new BuildResult(); buildResult.BuildLog = stringParser.Output + "\n\n\n" + stringParser.ErrorOutput; buildResult.WorkingDirectory = workingDirectory; File.Delete(projectFilePath); File.Delete(projectXstFilePath); Directory.Delete(PathHelper.Combine(workingDirectory, "xst"), true); return(buildResult); }
public static BuildResult BuildProject(string workingDirectory, PrjFile projectFile, IModule topModule) { // Create prj file on disk string toplevelComponentName = string.Format("{0}.{1}", topModule.Parent.Name, topModule.Name); string projectFilePath = PathHelper.Combine(workingDirectory, "projectfile.prj"); File.WriteAllText(projectFilePath, projectFile.ToString(ExecutionType.SynthesisOnly)); string projectXstFilePath = PathHelper.Combine(workingDirectory, "projectfile.xst"); string projectSyrFilePath = PathHelper.Combine(workingDirectory, "projectfile.syr"); string projectXstPath = PathHelper.Combine(workingDirectory, "xst"); string projectTmpPath = PathHelper.Combine(projectXstPath, ".tmp"); File.WriteAllText(projectXstFilePath, GenerateScript(workingDirectory, projectFilePath, topModule.Name)); Directory.CreateDirectory(projectXstPath); Directory.CreateDirectory(projectTmpPath); Logger.Instance.WriteDebug("Top Level component name: {0}", toplevelComponentName); Logger.Instance.WriteDebug("Xst path: {0}", projectXstFilePath); List<string> arguments = new List<string>(); arguments.Add(string.Format("-ifn \"{0}\"", projectXstFilePath)); arguments.Add(string.Format("-ofn \"{0}\"", projectSyrFilePath)); XilinxProcess process = new XilinxProcess("xst", arguments); DefaultMessageParser parser = new DefaultMessageParser(); StringProcessListener stringParser = new StringProcessListener(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.Listeners.Add(stringParser); process.WorkingDirectory = workingDirectory; process.Start(); process.WaitForExit(); BuildResult buildResult = new BuildResult(); buildResult.BuildLog = stringParser.Output + "\n\n\n" + stringParser.ErrorOutput; buildResult.WorkingDirectory = workingDirectory; File.Delete(projectFilePath); File.Delete(projectXstFilePath); Directory.Delete(PathHelper.Combine(workingDirectory, "xst"), true); return buildResult; }
public bool Build() { string bitFile = PathHelper.Combine(OutputLocation.TemporaryDirectory, string.Format("{0}.bit", Path.GetFileNameWithoutExtension(NCDFile))); // Setup Arguments List<string> arguments = new List<string>(); // Default configuration arguments.Add("-w"); // Overwrite existing files // The Input NCD if (string.IsNullOrEmpty(NCDFile) || !File.Exists(NCDFile)) { throw new FileNotFoundException("NCD File does not exist."); } arguments.Add(string.Format("\"{0}\"", NCDFile)); // Prepare Process XilinxProcess process = new XilinxProcess(Toolchain, "bitgen", arguments); DefaultMessageParser parser = new DefaultMessageParser(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.WorkingDirectory = OutputLocation.TemporaryDirectory; process.Start(); process.WaitForExit(); // Copy Artifacts to output directory OutputLocation.CopyOutputFile(bitFile); // Check if the process completed correctly if (process.CurrentProcess.ExitCode != 0 || !File.Exists(bitFile)) { return false; } return true; }
private bool TranslateNCDFile(string ncdFile, string xdlFile) { // Setup Arguments List<string> arguments = new List<string>(); // Default configuration arguments.Add("-ncd2xdl"); // NCD to XDL // The source NCD arguments.Add(string.Format("\"{0}\"", ncdFile)); // The output XDL arguments.Add(string.Format("\"{0}\"", xdlFile)); // Prepare Process XilinxProcess process = new XilinxProcess("xdl", arguments); DefaultMessageParser parser = new DefaultMessageParser(); StringProcessListener stdout = new StringProcessListener(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.Listeners.Add(stdout); process.WorkingDirectory = OutputLocation.TemporaryDirectory; process.Start(); process.WaitForExit(); Logger.Instance.WriteDebug(stdout.Output); // Check if the process completed correctly if (process.CurrentProcess.ExitCode != 0 || !File.Exists(xdlFile)) { return false; } return true; }
public bool Build() { string projectName = Path.GetFileNameWithoutExtension(NetList); string projectNgoPath = PathHelper.Combine(OutputLocation.TemporaryDirectory, "ngo"); string projectNgdFilePath = PathHelper.Combine(OutputLocation.TemporaryDirectory, string.Format("{0}.ngd", projectName)); string projectBldFilePath = PathHelper.Combine(OutputLocation.TemporaryDirectory, string.Format("{0}.bld", projectName)); // Target Device string targetDeviceName = TargetDevice.AlternateName; Logger.Instance.WriteDebug("Target Device Name: {0}", targetDeviceName); // Setup Arguments List<string> arguments = new List<string>(); // Specify the output path arguments.Add(string.Format("-dd \"{0}\"", projectNgoPath)); // Specify the constraints file if (string.IsNullOrEmpty(ConstraintsFile)) { // Ignore the constraints file arguments.Add("-i"); } else if (File.Exists(ConstraintsFile)) { arguments.Add(string.Format("-uc \"{0}\"", ConstraintsFile)); } else { throw new FileNotFoundException("Constraints File does not exist."); } // Ignore timestamps, always run arguments.Add("-nt on"); // Target Device arguments.Add(string.Format("-p {0}", targetDeviceName)); arguments.Add("-verbose"); // The source netlist if (string.IsNullOrEmpty(NetList) || !File.Exists(NetList)) { throw new FileNotFoundException("NetList File does not exist."); } arguments.Add(string.Format("\"{0}\"", NetList)); // The output NGD arguments.Add(string.Format("\"{0}\"", projectNgdFilePath)); // Create Temporary Directories Directory.CreateDirectory(projectNgoPath); Logger.Instance.WriteDebug("Created Temporary Directory (ngo): {0}", projectNgoPath); // Prepare Process XilinxProcess process = new XilinxProcess(Toolchain, "ngdbuild", arguments); DefaultMessageParser parser = new DefaultMessageParser(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.WorkingDirectory = OutputLocation.TemporaryDirectory; process.Start(); process.WaitForExit(); // Copy logs to the log directory OutputLocation.CopyLogFile(projectBldFilePath); // Copy Artifacts to output directory OutputLocation.CopyOutputFile(projectNgdFilePath); // Check if the process completed correctly if (process.CurrentProcess.ExitCode != 0 || !File.Exists(projectNgdFilePath)) { return false; } return true; }
public bool Build() { string projectName = Path.GetFileNameWithoutExtension(Bitstream); string projectMemFilePath = PathHelper.Combine(OutputLocation.TemporaryDirectory, string.Format("{0}.mem", projectName)); string projectBitFilePath = PathHelper.Combine(OutputLocation.TemporaryDirectory, string.Format("{0}_mem.bit", projectName)); // Check bitstream file exists if (string.IsNullOrEmpty(Bitstream) || !File.Exists(Bitstream)) { throw new FileNotFoundException("Bitstream File does not exist."); } // Check bmm file exists if (string.IsNullOrEmpty(BMMDescription) || !File.Exists(BMMDescription)) { throw new FileNotFoundException("BMM File does not exist."); } // Check binary file exists if (string.IsNullOrEmpty(BinaryFile) || !File.Exists(BinaryFile)) { throw new FileNotFoundException("Binary File does not exist."); } // Generate the mem file from binary data string data = MemFormatHelper.ConvertBinaryToMem(File.ReadAllBytes(BinaryFile)); File.WriteAllText(projectMemFilePath, data); // Setup Arguments List<string> arguments = new List<string>(); // The BMM arguments.Add(string.Format("-bm \"{0}\"", BMMDescription)); // The memory contents arguments.Add(string.Format("-bd \"{0}\"", projectMemFilePath)); // The source bitstream arguments.Add(string.Format("-bt \"{0}\"", Bitstream)); // The output bitstream arguments.Add(string.Format("-o b \"{0}\"", projectBitFilePath)); // Prepare Process XilinxProcess process = new XilinxProcess("data2mem", arguments); DefaultMessageParser parser = new DefaultMessageParser(); StringProcessListener stdout = new StringProcessListener(); parser.MessageOccured += ((obj) => obj.WriteToLogger()); process.Listeners.Add(parser); process.Listeners.Add(stdout); process.WorkingDirectory = OutputLocation.TemporaryDirectory; process.Start(); process.WaitForExit(); Logger.Instance.WriteDebug(stdout.Output); // Copy results to output OutputLocation.CopyOutputFile(projectBitFilePath); // Check if the process completed correctly if (process.CurrentProcess.ExitCode != 0 || !File.Exists(projectBitFilePath)) { return false; } return true; }
public static DeviceFamily LoadFamily(DeviceManufacture manufacture, string familyName) { DeviceFamily family = null; List <string> arguments = new List <string>(); arguments.Add("-intstyle silent"); arguments.Add("-arch " + familyName); ProcessHelper.ProcessExecutionResult result = XilinxProcess.ExecuteProcess(Environment.CurrentDirectory, "partgen", arguments); bool startedList = false; string realFamilyName = familyName; string defaultSpeeds = null; Device currentDevice = null; using (StringReader reader = new StringReader(result.StandardOutput)) { string line; while ((line = reader.ReadLine()) != null) { if (!startedList) { startedList = true; realFamilyName = line.Trim(); // Picked up name family = new DeviceFamily(manufacture, realFamilyName, familyName); } else if (family != null) { // The first line i the part + speeds, lines afterwards are packages string cleanup = line.Trim(); if (line.StartsWith(" ")) { if (currentDevice != null) { // Device string[] splitUp = cleanup.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); if (splitUp.Length >= 1 && !string.IsNullOrEmpty(splitUp[0])) { // Package specifier Logger.Instance.WriteDebug("Create/Find Package '{0}'", splitUp[0]); DevicePackage partPackage = family.CreatePackage(splitUp[0]); Logger.Instance.WriteDebug("Create/Find part with package '{0}'", partPackage.Name); DevicePart part = currentDevice.CreatePart(partPackage); // Can have an exclusive set of speeds ParseSpeedDetails(family, part, (splitUp.Length > 1) ? splitUp[1] : defaultSpeeds); } } } else { string[] splitUp = cleanup.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); if (splitUp.Length >= 3 && !string.IsNullOrEmpty(splitUp[0])) { Logger.Instance.WriteDebug("Create/Find Device '{0}'", splitUp[0]); currentDevice = family.CreateDevice(splitUp[0]); defaultSpeeds = splitUp[2]; // Set default speed for devices } } } } } return(family); }