public override string ToString() { XDocument document = new XDocument(new XDeclaration("1.0", "utf-8", "no")); XElement root = new XElement(xm + "project"); document.Add(root); // Setup the namespaces root.Add(new XAttribute(XNamespace.Xmlns + xilinxNamespacePrefix, xm)); // namespace prefix root.Add(new XAttribute("xmlns", xm)); // default namespace // Populate the document root.Add(new XElement(xm + "header")); // empty header root.Add(new XElement(xm + "version", new XAttribute(xm + "ise_version", defaultVersion), new XAttribute(xm + "schema_version", defaultSchemaVersion))); //root.Add(new XElement(xm + "bindings")); // empty //root.Add(new XElement(xm + "partitions")); // empty // Files and Libraries XElement files; XElement libraries; HashSet <string> librariesSet = new HashSet <string>(); root.Add(files = new XElement(xm + "files")); root.Add(libraries = new XElement(xm + "libraries")); foreach (IModule module in ReferenceHelper.GetAllModules(Modules)) { if (!librariesSet.Contains(module.Parent.Name)) { librariesSet.Add(module.Parent.Name); libraries.Add(new XElement(xm + "library", new XAttribute(xm + "name", module.Parent.Name))); } files.Add(IModuleToElement(module)); } // Add the constraints file if (!string.IsNullOrEmpty(UserConstraintsFile)) { files.Add(CreateFileElement(Path.GetFullPath(UserConstraintsFile), XilinxFileType_Constraints, null, ExecutionType.SynthesisOnly)); } // Properties XElement properties; root.Add(properties = new XElement(xm + "properties", new XElement(xm + "property", new XAttribute(xm + "name", "Preferred Language"), new XAttribute(xm + "value", "VHDL"), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Property Specification in Project File"), new XAttribute(xm + "value", "Store non-default values only"), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Working Directory"), new XAttribute(xm + "value", "."), new XAttribute(xm + "valueState", "non-default")))); if (Device != null) { properties.Add( new XElement(xm + "property", new XAttribute(xm + "name", "Device Family"), new XAttribute(xm + "value", Device.Part.Parent.Family.Name), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Device"), new XAttribute(xm + "value", Device.Part.Parent.Name), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Package"), new XAttribute(xm + "value", Device.Part.Package.Name), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Speed Grade"), new XAttribute(xm + "value", Device.Speed.Name), new XAttribute(xm + "valueState", "non-default"))); } else { properties.Add( new XElement(xm + "property", new XAttribute(xm + "name", "Device Family"), new XAttribute(xm + "value", "Spartan6"), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Device"), new XAttribute(xm + "value", "xc6slx9"), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Package"), new XAttribute(xm + "value", "csg225"), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Speed Grade"), new XAttribute(xm + "value", "-3"), new XAttribute(xm + "valueState", "non-default"))); } StringWriter writer = new StringHelpers.Utf8StringWriter(); document.Save(writer); return(writer.ToString()); }
public override string ToString() { XDocument document = new XDocument(new XDeclaration("1.0", "utf-8", "no")); XElement root = new XElement(xm + "project"); document.Add(root); // Setup the namespaces root.Add(new XAttribute(XNamespace.Xmlns + xilinxNamespacePrefix, xm)); // namespace prefix root.Add(new XAttribute("xmlns", xm)); // default namespace // Populate the document root.Add(new XElement(xm + "header")); // empty header // Project Version details if (Version != null) { Logger.Instance.WriteVerbose("Generating Project File with Xilinx Version = '{0}'", Version.Version); root.Add(new XElement(xm + "version", new XAttribute(xm + "ise_version", Version.Version.ToString()), new XAttribute(xm + "schema_version", defaultSchemaVersion))); } else { Logger.Instance.WriteVerbose("Generating Project File without Xilinx Version"); } //root.Add(new XElement(xm + "bindings")); // empty //root.Add(new XElement(xm + "partitions")); // empty // Files and Libraries XElement files; XElement libraries; HashSet<string> librariesSet = new HashSet<string>(); root.Add(files = new XElement(xm + "files")); root.Add(libraries = new XElement(xm + "libraries")); foreach (IModule module in ReferenceHelper.GetAllModules(Modules)) { if (!librariesSet.Contains(module.Parent.Name)) { librariesSet.Add(module.Parent.Name); libraries.Add(new XElement(xm + "library", new XAttribute(xm + "name", module.Parent.Name))); } files.Add(IModuleToElement(module)); } // Add the constraints file if (!string.IsNullOrEmpty(UserConstraintsFile)) { files.Add(CreateFileElement(Path.GetFullPath(UserConstraintsFile), XilinxFileType_Constraints, null, ExecutionType.SynthesisOnly)); } // Properties XElement properties; root.Add(properties = new XElement(xm + "properties", new XElement(xm + "property", new XAttribute(xm + "name", "Preferred Language"), new XAttribute(xm + "value", "VHDL"), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Property Specification in Project File"), new XAttribute(xm + "value", "Store non-default values only"), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Working Directory"), new XAttribute(xm + "value", "."), new XAttribute(xm + "valueState", "non-default")))); if (Device != null) { properties.Add( new XElement(xm + "property", new XAttribute(xm + "name", "Device Family"), new XAttribute(xm + "value", Device.Part.Parent.Family.Name), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Device"), new XAttribute(xm + "value", Device.Part.Parent.Name), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Package"), new XAttribute(xm + "value", Device.Part.Package.Name), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Speed Grade"), new XAttribute(xm + "value", Device.Speed.Name), new XAttribute(xm + "valueState", "non-default"))); } else { properties.Add( new XElement(xm + "property", new XAttribute(xm + "name", "Device Family"), new XAttribute(xm + "value", "Spartan6"), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Device"), new XAttribute(xm + "value", "xc6slx9"), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Package"), new XAttribute(xm + "value", "csg225"), new XAttribute(xm + "valueState", "non-default")), new XElement(xm + "property", new XAttribute(xm + "name", "Speed Grade"), new XAttribute(xm + "value", "-3"), new XAttribute(xm + "valueState", "non-default"))); } StringWriter writer = new StringHelpers.Utf8StringWriter(); document.Save(writer); return writer.ToString(); }