public HashSet <DelayGraphVertex> Execute(
            DelayGraph.DelayGraph delayGraph,
            int targetPeriod)
        {
            Graph = delayGraph;
            InitializeDelayMap();
            RegisteredTerminals.Clear();

            Traverse(targetPeriod);
            Traverse(targetPeriod); // helps with feedback paths to call twice but the delay on the second pass is likely inaccurate. Chicken and egg problem
            return(RegisteredTerminals);
        }
Beispiel #2
0
        public HashSet <DelayGraphVertex> Execute(
            DelayGraph.DelayGraph delayGraph,
            int targetPeriod)
        {
            Graph        = delayGraph;
            TargetPeriod = targetPeriod;

            // first, add all vertex to RegisteredTerminals
            var registered = new HashSet <DelayGraphVertex>(Graph.Vertices);

            //initialize all output and input delay maps
            Initialize();

            // next, iteratively remove registered terminals as long as it meets timing
            bool changed;

            do
            {
                changed = false;
                // remove vertex if possible
                var sorted = from vertex in Graph.Vertices
                             where (!vertex.IsRegistered && registered.Contains(vertex))
                             orderby vertex.ThroughputCostIfRegistered descending,
                    vertex.LatencyCostIfRegistered descending,
                    vertex.RegisterCostIfRegistered descending
                select vertex;
                foreach (var vertex in sorted)
                {
                    if (IsSafeToDeRegister(vertex))
                    {
                        changed = true;
                        registered.Remove(vertex);
                    }
                }
            }while (changed);
            bool foundCycle;
            int  maxDelay = SanityCheckGraph(registered, out foundCycle);

            if (foundCycle)
            {
                Console.WriteLine("Detected Cycles");
            }
            if (maxDelay > TargetPeriod)
            {
                Console.WriteLine("Detected Timing Violation");
            }

            return(registered);
        }