示例#1
0
        private void appendFiles(List <string> filePathList, List <string> includePathList, pluginVerilog.Verilog.Module module, codeEditor.Data.Project project)
        {
            string fileId = module.FileId;

            pluginVerilog.Data.VerilogFile file = module.File as pluginVerilog.Data.VerilogFile;
            if (file == null)
            {
                return;
            }
            string absolutePath = project.GetAbsolutePath(file.RelativePath);

            if (!filePathList.Contains(absolutePath))
            {
                filePathList.Add(absolutePath);
            }

            if (file.VerilogParsedDocument == null)
            {
                return;
            }

            // includes
            foreach (var include in file.VerilogParsedDocument.IncludeFiles.Values)
            {
                string includePath = project.GetAbsolutePath(include.RelativePath);
                includePath = includePath.Substring(0, includePath.LastIndexOf('\\'));
                if (!includePathList.Contains(includePath))
                {
                    includePathList.Add(includePath);
                }
            }

            foreach (pluginVerilog.Verilog.ModuleItems.ModuleInstantiation instance in module.ModuleInstantiations.Values)
            {
                pluginVerilog.Verilog.Module subModule = (project.GetProjectProperty(pluginVerilog.Plugin.StaticID) as pluginVerilog.ProjectProperty).GetModule(instance.ModuleName);
                if (subModule != null)
                {
                    appendFiles(filePathList, includePathList, subModule, project);
                }
            }
        }
示例#2
0
        private void run()
        {
            codeEditor.NavigatePanel.NavigatePanelNode node;
            codeEditor.Controller.NavigatePanel.GetSelectedNode(out node);
            pluginVerilog.NavigatePanel.VerilogFileNode verilogFileNode = node as pluginVerilog.NavigatePanel.VerilogFileNode;
            if (node == null)
            {
                return;
            }

            pluginVerilog.Data.VerilogFile topFile = verilogFileNode.VerilogFile;
            codeEditor.Data.Project        project = topFile.Project;

            if (topFile == null)
            {
                return;
            }
            pluginVerilog.Verilog.ParsedDocument topParsedDocument = topFile.ParsedDocument as pluginVerilog.Verilog.ParsedDocument;
            if (topParsedDocument == null)
            {
                return;
            }
            if (topParsedDocument.Modules.Count == 0)
            {
                return;
            }

            string simName = topFile.Name.Substring(0, topFile.Name.LastIndexOf('.'));


            string simulationPath = Setup.SimulationPath + "\\" + simName;

            if (!System.IO.Directory.Exists(simulationPath))
            {
                System.IO.Directory.CreateDirectory(simulationPath);
            }

            List <string> filePathList = new List <string>();
            {
                string absolutePath = project.GetAbsolutePath(topFile.RelativePath);
                filePathList.Add(absolutePath);
            }

            List <string> includeFileList = new List <string>();

            foreach (pluginVerilog.Verilog.Module module in topParsedDocument.Modules.Values)
            {
                appendFiles(filePathList, includeFileList, module, project);
            }

            pluginVerilog.Verilog.Module topModule = topParsedDocument.Modules.FirstOrDefault().Value;
            if (topModule == null)
            {
                return;
            }

            // create project file
            // verilog<work_library> < file_names > ... [-d<macro>]...[-i<include_path>]...
            // vhdl<work_library> <file_name>
            // sv<work_library> <file_name>
            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(simulationPath + "\\" + simName + ".prj"))
            {
                foreach (string absolutePath in filePathList)
                {
                    sw.Write("verilog " + simName + " \"" + absolutePath + "\"");
                    if (includeFileList.Count != 0)
                    {
                        foreach (string includePath in includeFileList)
                        {
                            sw.Write(" -i \"" + getShortPath(includePath) + "\""); // path with space is not accepted
                        }
                    }
                    sw.Write("\r\n");
                }
            }

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(simulationPath + "\\command.bat"))
            {
                sw.Write("echo #compile\r\n");

                //foreach (string absolutePath in filePathList)
                //{
                //    sw.Write("call "+Setup.BinPath + "xvlog ^\r\n");
                //    if (includeFileList.Count != 0)
                //    {
                //        foreach (string includePath in includeFileList)
                //        {
                //            sw.Write("-i \"" + includePath + "\" ^\r\n"); // path with space is not accepted
                //        }
                //    }
                //    sw.Write("\""+absolutePath + "\"");
                //    sw.Write("\r\n");
                //}

                sw.Write("call " + Setup.BinPath + "xvlog -prj " + simName + ".prj" + " ^\r\n");
                //if (includeFileList.Count != 0)
                //{
                //    foreach (string includePath in includeFileList)
                //    {
                //        sw.Write("-i \"" + includePath + "\" ^"); // path with space is not accepted
                //    }
                //}
                //foreach (string absolutePath in filePathList)
                //{
                //    sw.Write(" ^\r\n \"" + absolutePath + "\"");
                //}
                sw.Write("\r\n");
                sw.Write("\r\n");
                sw.Write("echo #elaboration\r\n");
                sw.Write("call " + Setup.BinPath + "xelab ^\r\n");
                sw.Write("--debug all ^\r\n");
                sw.Write("--notimingchecks ^\r\n");
                sw.Write(topModule.Name + "\r\n");
                sw.Write("\r\n");
                sw.Write("\r\n");

                sw.Write("echo #simulation\r\n");
                sw.Write("call " + Setup.BinPath + "xsim " + topModule.Name + " -t xsim_run.tcl\r\n");
            }

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(simulationPath + "\\xsim_run.tcl"))
            {
                sw.Write("run all\r\n");
            }


            if (abort)
            {
                return;
            }
            shell = new ajkControls.CommandShell(new List <string> {
                "prompt xSimVerilogShell$G$_",
                "cd " + simulationPath
            });
            shell.LineReceived += receiveLineString;
            shell.Start();

            while (shell.GetLastLine() != "xSimVerilogShell>")
            {
                if (abort)
                {
                    return;
                }
                System.Threading.Thread.Sleep(10);
            }
            shell.ClearLogs();
            shell.StartLogging();
            shell.Execute("command.bat");
            while (shell.GetLastLine() != "%xsim")
            {
                if (abort)
                {
                    return;
                }
                System.Threading.Thread.Sleep(10);
            }
            RequestTabIconChange(codeEditor.Global.IconImages.Wave0, ajkControls.IconImage.ColorStyle.Green);
            List <string> logs = shell.GetLogs();

            if (logs.Count != 3 || logs[1] != "")
            {
                return;
            }
            shell.EndLogging();
        }