public static string GenerateTestBench(TestBench test, string workingDirectory, string templateFile) { string assemblyFile = PathHelper.Combine(workingDirectory, "test.s"); Logger.Instance.WriteVerbose("Generating Assembly file"); File.WriteAllText(assemblyFile, test.GenerateAssembly()); MemoryStream code = GenerateMachineCode(workingDirectory, assemblyFile); return TestBenchTemplate(code, templateFile); }
public static string GenerateTestBench(TestBench test, string workingDirectory, string templateFile) { string assemblyFile = PathHelper.Combine(workingDirectory, "test.s"); Logger.Instance.WriteVerbose("Generating Assembly file"); File.WriteAllText(assemblyFile, test.GenerateAssembly()); MemoryStream code = GenerateMachineCode(workingDirectory, assemblyFile); return(TestBenchTemplate(code, templateFile)); }
private static void PrintAssertionsState(TestBench test, bool forceFailed) { Console.CursorLeft = Console.WindowWidth - 12; Console.Write(" [ "); if (test.failedAssertions > 0 || test.passedAssertions == 0 || forceFailed) { using (new ConsoleColorScope(ConsoleColor.Red)) { Console.Write("failed"); } } else { using (new ConsoleColorScope(ConsoleColor.Green)) { Console.Write("passed"); } } Console.WriteLine(" ]"); }
private void Setup() { SetupPaths(); // Load test bench bench = TestBench.Load(fileTest); // Generate test bench vhdl File.WriteAllText(fileTemplateBuilt, TestBenchGenerator.GenerateTestBench(bench, workingDirectory, fileTemplate)); // Manually generate the prj file string prjFile = File.ReadAllText(pregenPrjFile); string prjFileGen = PathHelper.Combine(workingDirectory, "prj.prj"); prjFile = prjFile + Environment.NewLine + string.Format("vhdl avr_core_v1_00_a \"{0}\"", fileTemplateBuilt) + Environment.NewLine; File.WriteAllText(prjFileGen, prjFile); Logger.Instance.WriteVerbose("Building Simulation"); // Build the isim exe FuseBuild.BuildResult result = FuseBuild.BuildProject(workingDirectory, prjFileGen, "avr_core_v1_00_a.avr_proc_exec_test"); simulationExe = result.ExecutableFile; }
public override void Execute(TestBench test, ProcessorState state) { Match m = assertionOperation.Match(Parameters); if (m.Success) { string a = m.Groups["a"].Value.Trim(); string b = m.Groups["b"].Value.Trim(); string op = m.Groups["op"].Value.Trim(); bool passed = false; if (string.Compare(op, "==", true) == 0) { if (GetValueForString(a, state) == GetValueForString(b, state)) { passed = true; } } else if (string.Compare(op, "!=", true) == 0) { if (GetValueForString(a, state) != GetValueForString(b, state)) { passed = true; } } if (!passed) { Logger.Instance.WriteError("Assertion failed 0x{0:X4}@{1}, '{2}' <> '{3} {4} {5}'", Address * 2, CyclesAfterEvent, Parameters, GetValueForString(a, state), op, GetValueForString(b, state)); } test.IncrementAssertionResult(passed); return; } Console.WriteLine("Malformed assertion! '{0}'", Parameters); }
public static TestBench Load(string file) { TestBench bench = new TestBench(); using (FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read)) { using (StreamReader reader = new StreamReader(stream)) { while (!reader.EndOfStream) { string line = reader.ReadLine().Trim(); if (!string.IsNullOrEmpty(line)) { if (line.StartsWith("#")) { TestCommand command = ParseCommand(line, bench.instructionsList.Count); if (command != null) { Logger.Instance.WriteDebug("Add {0}::'{1}'", command.GetType().ToString(), command.Parameters); bench.commands.Add(command); } else if (line.StartsWith("##todo", StringComparison.InvariantCultureIgnoreCase)) { Logger.Instance.WriteWarning("{0}: {1}", Path.GetFileName(file), line); } } else { bench.instructionsList.Add(line); } } } } } return bench; }
public static TestBench Load(string file) { TestBench bench = new TestBench(); using (FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read)) { using (StreamReader reader = new StreamReader(stream)) { while (!reader.EndOfStream) { string line = reader.ReadLine().Trim(); if (!string.IsNullOrEmpty(line)) { if (line.StartsWith("#")) { TestCommand command = ParseCommand(line, bench.instructionsList.Count); if (command != null) { Logger.Instance.WriteDebug("Add {0}::'{1}'", command.GetType().ToString(), command.Parameters); bench.commands.Add(command); } else if (line.StartsWith("##todo", StringComparison.InvariantCultureIgnoreCase)) { Logger.Instance.WriteWarning("{0}: {1}", Path.GetFileName(file), line); } } else { bench.instructionsList.Add(line); } } } } } return(bench); }
public virtual void Execute(TestBench test, ProcessorState state) { }
public override void Execute(TestBench test, ProcessorState state) { test.EndTest(); }