private void test(Func <AifFile> getFile, params Dictionary <string, string>[] testCases)
        {
            TestLogger.Setup();

            var log  = LogManager.GetLogger(nameof(DataPathGeneratorTests));
            var file = getFile();

            var schedule = new IlpScheduler(file, file.MinCycles.Values.Max());

            schedule.BuildSchedule();

            var dataPathGenerator = new DataPathGenerator(new MultiplexerGenerator(new RegisterAllocator(new FunctionalUnitAllocator(schedule))));

            using (var stream = new MemoryStream())
                using (var writeStream = new StreamWriter(stream))
                {
                    if (testCases.Length > 0)
                    {
                        Debug.WriteLine(nameof(dataPathGenerator.SaveTestBench));
                        dataPathGenerator.SaveTestBench(writeStream, testCases);
                    }

                    Debug.WriteLine(nameof(dataPathGenerator.SaveController));
                    dataPathGenerator.SaveController(writeStream);

                    Debug.WriteLine(nameof(dataPathGenerator.SaveDataPath));
                    dataPathGenerator.SaveDataPath(writeStream, true);

                    Debug.WriteLine(nameof(dataPathGenerator.SaveDesign));
                    dataPathGenerator.SaveDesign(writeStream);

                    writeStream.Flush();
                    log.Info(Encoding.UTF8.GetString(stream.ToArray()));
                }
        }
        private void test(Func <AifFile> getFile)
        {
            TestLogger.Setup();

            var file = getFile();

            var schedule = new IlpScheduler(file, file.MinCycles.Values.Max());

            schedule.BuildSchedule();

            var funcUnitAllocator = new FunctionalUnitAllocator(schedule);

            Assert.IsNotNull(funcUnitAllocator.Units);

            //The IP scheduler has determined the optimal resources needed.
            //Compare the results of functional allocator to the resources results from the IP scheduler.
            foreach (var resource in schedule.Resources)
            {
                Assert.AreEqual(funcUnitAllocator.Units.Count(unit => unit.Op == resource.Key), resource.Value, $"The unit count for {resource.Key} is wrong.");
            }

            foreach (var unit in funcUnitAllocator.Units)
            {
                //operations that share the same functional unit cannot share the same cycle index
                Assert.AreEqual(unit.Operations.Length, unit.Operations.Select(op => op.CycleIndex).Distinct().Count(),
                                "Two operations with the same cycle index are sharing the same function unit.");
            }
        }
Exemplo n.º 3
0
        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));
        }
        private void test(Func <AifFile> getFile)
        {
            TestLogger.Setup();

            var file = getFile();

            var schedule = new IlpScheduler(file, file.MinCycles.Values.Max());

            schedule.BuildSchedule();

            var registerAllocator = new RegisterAllocator(new FunctionalUnitAllocator(schedule));

            Assert.IsNotNull(registerAllocator.Units);

            var registers = registerAllocator.Units.SelectMany(unit => unit.Registers).ToArray();

            Assert.AreEqual(registers.Length, schedule.AifFile.Registers.Count);
            Assert.IsTrue(registers.All(reg => schedule.AifFile.Registers.ContainsValue(reg)));

            Assert.IsTrue(registerAllocator.Units
                          .All(unit => unit.Registers
                               .All(reg1 => unit.Registers
                                    .Where(reg2 => reg1 != reg2)
                                    .All(reg1.IsCompatible))));
        }
Exemplo n.º 5
0
        private void test(Func <AifFile> getFile)
        {
            TestLogger.Setup();

            var file = getFile();

            var schedule = new IlpScheduler(file, file.MinCycles.Values.Max());

            Assert.IsNotNull(schedule);

            schedule.BuildSchedule();

            //make sure all the operations are included in the schedule
            var operations = schedule.Cycles.SelectMany(cycle => cycle).ToArray();

            Assert.AreEqual(operations.Length, schedule.AifFile.Operations.Count);
            Assert.IsTrue(operations.All(operation => schedule.AifFile.Operations.ContainsValue(operation)));

            Assert.AreEqual(schedule.Cycles.Length, schedule.AifFile.MinCycles.Values.Max(), "The schedule does not have the min number of cycles.");

            //check the order of operations
            for (var index = 1; index < schedule.Cycles.Length; index++)
            {
                var cycle1 = schedule.Cycles[index - 1];
                var cycle2 = schedule.Cycles[index];

                Assert.IsTrue(cycle1.All(op1 => cycle2.All(op2 => !op1.IsDependantOn(op2))), "The order of operations are invalid.");
            }
        }