상속: IProcessListener
예제 #1
0
        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;
        }
예제 #2
0
        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;
        }
예제 #3
0
        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;
        }
예제 #5
0
        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;
        }