public static void VHDLSample() { Console.WriteLine("Hello World!"); // TODO: Implement Functionality Here string appBase = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); VHDL.parser.Logger loggercompile = VHDL.parser.Logger.CreateLogger(appBase, "compiler"); VHDL_Library_Manager libraryManager = new VHDL_Library_Manager("", @"Libraries\LibraryRepository.xml", loggercompile); libraryManager.Logger.OnWriteEvent += new VHDL.parser.Logger.OnWriteDeleagte(Logger_OnWriteEvent); libraryManager.LoadData(@"Libraries"); VhdlParserSettings settings = VhdlParserWrapper.DEFAULT_SETTINGS; RootDeclarativeRegion rootScope = new RootDeclarativeRegion(); LibraryDeclarativeRegion currentLibrary = new LibraryDeclarativeRegion("work"); rootScope.Libraries.Add(currentLibrary); rootScope.Libraries.Add(libraryManager.GetLibrary("STD")); bool success = true; try { Console.WriteLine("Parsing code"); VhdlFile file = VhdlParserWrapper.parseFile("sample.vhdl", settings, rootScope, currentLibrary, libraryManager); } catch (vhdlParseException ex) { Console.WriteLine(string.Format("{0} {1}:{2} {3} {4} {5}", ex.FilePath, ex.Line, ex.CharPositionInLine, ex.OffendingSymbol.Text, ex.Message, ex.InnerException)); Console.WriteLine("Parsing failed"); success = false; } catch (vhdlSemanticException ex) { Console.WriteLine(ex.GetConsoleMessageTest()); Console.WriteLine("Parsing failed"); success = false; } catch (Exception ex) { Console.WriteLine(string.Format("{0} {1} {2} \n {3}", ex.Message, ex.InnerException, ex.Source, ex.StackTrace)); Console.WriteLine("Parsing failed"); success = false; } if (success) { Console.WriteLine("Parsing complete"); } Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }
public VHDLCompiler(string ProgramPath) { string appBase = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); VHDL.parser.Logger loggercompile = VHDL.parser.Logger.CreateLogger(appBase, "compiler"); libraryManager = new VHDL_Library_Manager("", @"Libraries\LibraryRepository.xml", loggercompile); libraryManager.Logger.OnWriteEvent += new VHDL.parser.Logger.OnWriteDeleagte(Logger_OnWriteEvent); libraryManager.LoadData(@"Libraries"); settings = VhdlParserWrapper.DEFAULT_SETTINGS; settings.AddPositionInformation = true; rootScope = new RootDeclarativeRegion(); currentLibrary = new LibraryDeclarativeRegion("work"); rootScope.Libraries.Add(currentLibrary); rootScope.Libraries.Add(libraryManager.GetLibrary("STD")); }
static void Main(string[] args) { try { string appBase = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); VHDL.parser.Logger loggercompile = VHDL.parser.Logger.CreateLogger(appBase, "compiler"); VHDLRuntime.Logger loggerrun = VHDLRuntime.Logger.CreateLogger(appBase, "run"); VHDL_Library_Manager libraryManager = new VHDL_Library_Manager("", @"Libraries\LibraryRepository.xml", loggercompile); libraryManager.Logger.OnWriteEvent += new VHDL.parser.Logger.OnWriteDeleagte(Logger_OnWriteEvent); libraryManager.LoadData(@"Libraries"); VhdlParserSettings settings = VhdlParserWrapper.DEFAULT_SETTINGS; RootDeclarativeRegion rootScope = new RootDeclarativeRegion(); LibraryDeclarativeRegion currentLibrary = new LibraryDeclarativeRegion("work"); rootScope.Libraries.Add(currentLibrary); //rootScope.getLibraries().Add(VHDL_Library_Manager.GetLibrary("STD")); Console.WriteLine("Parsing code"); VhdlFile file = VhdlParserWrapper.parseFile("vhdl_tests\\simple_simulation.vhd", settings, rootScope, currentLibrary, libraryManager); Console.WriteLine("Parsing complete"); foreach (LibraryUnit unit in file.Elements) { if (unit is Architecture) { Architecture arch = unit as Architecture; if (arch.Identifier.Equals("some_test_bench")) { string fileName = string.Format("{0}\\{1}.dll", appBase, arch.Identifier); string vcdFile = string.Format("{0}\\dump.vcd", appBase, arch.Identifier); VHDLCompilerInterface compiler = new VHDLCompilerInterface(arch, loggercompile); compiler.Compile(appBase); TestRunner.LoadMyAssemblyAndRun(fileName, arch.Identifier, arch.Identifier, loggerrun, vcdFile); Process proc = new Process(); proc.StartInfo.Arguments = "run.log"; proc.StartInfo.FileName = "notepad.exe"; proc.StartInfo.WorkingDirectory = Process.GetCurrentProcess().StartInfo.WorkingDirectory; proc.Start(); } } } } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); } catch { } Console.ReadKey(); }