private void test(Func <AifFile> getFile) { TestLogger.Setup(); var file = getFile(); var schedule = new IlpScheduler(file, file.MinCycles.Values.Max()); schedule.BuildSchedule(); var multiplexorGenerator = new MultiplexerGenerator(new RegisterAllocator(new FunctionalUnitAllocator(schedule))); Assert.IsNotNull(multiplexorGenerator.FunctionalUnitMultiplexers); Assert.IsNotNull(multiplexorGenerator.RegisterUnitMultiplexers); Assert.IsTrue(multiplexorGenerator.FunctionalUnitMultiplexers.Length == 0 || multiplexorGenerator.FunctionalUnitMultiplexers.All(unit => unit?.SelectionBitSize > 0 && unit.Op?.Length > 1 && unit.Unit != null)); Assert.IsTrue(multiplexorGenerator.RegisterUnitMultiplexers.Length == 0 || multiplexorGenerator.RegisterUnitMultiplexers.All(unit => unit?.SelectionBitSize > 0 && unit.Registers?.Length > 1 && unit.Unit != null)); }
public DataPathGenerator(MultiplexerGenerator multiplexors) { Multiplexers = multiplexors; RegisterAllocator = Multiplexers.RegisterAllocator; Functional = RegisterAllocator.Functional; Scheduler = Functional.Scheduler; AifFile = Scheduler.AifFile; }
public static void Main(string[] args) { StreamWriter controller = null, dataPath = null, design = null, testBench = null; try { string fileName; var file = GetAifFile(out fileName); if (file == null) { return; } //1. Operation Scheduling: var schedule = GetSchedule(file); if (schedule == null) { return; } //2. Functional Unit Allocation and Binding: var functionalUnits = new FunctionalUnitAllocator(schedule); //3. Register Allocation and Binding var registers = new RegisterAllocator(functionalUnits); //4. Multiplexer Generation: var multiplexorGenerator = new MultiplexerGenerator(registers); //5. Datapath Generation in VHDL: var dataPathGenerator = new DataPathGenerator(multiplexorGenerator); //6. Get test cases Console.ForegroundColor = ConsoleColor.Green; foreach (var expression in file.AsExpressions) { Console.WriteLine(expression); } var testCases = GetTestCases(dataPathGenerator).ToArray(); var saveFolder = GetSaveTo(); if (saveFolder == null) { return; } //save generation dataPath = GetSaveStream(Path.Combine(saveFolder, fileName + "_dp.vhd")); if (dataPath == null) { return; } controller = GetSaveStream(Path.Combine(saveFolder, fileName + "_con.vhd")); if (controller == null) { return; } design = GetSaveStream(Path.Combine(saveFolder, fileName + "_des.vhd")); if (design == null) { return; } if (testCases.Length > 0) { testBench = GetSaveStream(Path.Combine(saveFolder, fileName + "_tb.vhd")); if (testBench == null) { return; } } using (controller) { dataPathGenerator.SaveController(controller); } foreach (var codeFile in functionalUnits.Units .Select(unit => unit.VhdlCodeFile) .Concat(new [] { "c_multiplexer", "c_register" }) .Distinct(StringComparer.OrdinalIgnoreCase)) { var savePath = Path.Combine(saveFolder, codeFile + ".vhd"); if (!File.Exists(savePath)) { using (var stream = File.CreateText(savePath)) { stream.WriteVhdlFile(codeFile); } } } using (dataPath) { dataPathGenerator.SaveDataPath(dataPath); } using (design) { dataPathGenerator.SaveDesign(design); } if (testCases.Length > 0) { using (testBench) { dataPathGenerator.SaveTestBench(testBench, testCases); } } Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Press enter to exit."); Console.ReadLine(); } catch (Exception error) { Log.Error(error); dataPath?.Dispose(); design?.Dispose(); controller?.Dispose(); testBench?.Dispose(); } }