public bool CompileToVHDL(string topLevelModule, string filename) { // Execute and gather program data ProtoCore.CompileAndExecutePass.ProgramData programData = null; bool compileAndExecuteSuceeded = CompileAndExecutePass(filename, out programData); Validity.Assert(compileAndExecuteSuceeded == true); Validity.Assert(programData != null); ProtoCore.Options options = new ProtoCore.Options(); options.CompilationTarget = ProtoCore.DSDefinitions.CompileTarget.VHDL; // Generate a new core and pass it the data gathered from the previous pass ProtoCore.Core core = new ProtoCore.Core(options); core.SetProgramData(programData); options.ExecutionMode = ProtoCore.ExecutionMode.Serial; core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core)); core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core)); core.Executives.Add(ProtoCore.Language.kVHDL, new ProtoVHDL.Executive(core)); core.Options.DumpByteCode = true; core.Options.Verbose = true; core.VhdlCore = new ProtoCore.VHDL.VHDLCore(topLevelModule); System.IO.StreamReader reader = null; try { reader = new System.IO.StreamReader(filename, Encoding.UTF8, true); } catch (System.IO.IOException) { throw new Exception("Cannot open file " + filename); } string strSource = reader.ReadToEnd(); reader.Dispose(); core.Options.RootModulePathName = ProtoCore.Utils.FileUtils.GetFullPathName(filename); core.CurrentDSFileName = core.Options.RootModulePathName; core.ExecMode = ProtoCore.DSASM.InterpreterMode.kNormal; bool buildSucceeded = false; try { //defining the global Assoc block that wraps the entire .ds source file ProtoCore.LanguageCodeBlock globalBlock = new ProtoCore.LanguageCodeBlock(); globalBlock.language = ProtoCore.Language.kVHDL; globalBlock.body = strSource; //the wrapper block can be given a unique id to identify it as the global scope globalBlock.id = ProtoCore.LanguageCodeBlock.OUTERMOST_BLOCK_ID; //passing the global Assoc wrapper block to the compiler ProtoCore.CompileTime.Context context = new ProtoCore.CompileTime.Context(); ProtoCore.Language id = globalBlock.language; int blockID = 0; core.Executives[id].Compile(out blockID, null, globalBlock, context); core.BuildStatus.ReportBuildResult(); buildSucceeded = core.BuildStatus.BuildSucceeded; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(buildSucceeded); }