예제 #1
0
        private bool TraverseSignal(List <Guid> signals, List <Guid> ports, List <Guid> buses, Signal signal, Port target, bool ignoreHold, IScanVisitor visitor)
        {
            if (signal == null || signals.Contains(signal.InstanceId))
            {
                return(true);
            }
            signals.Add(signal.InstanceId);

            if (visitor.EnterSignal(signal, target, false, target == null))
            {
                // LEAF SIGNAL?
                if (!signal.BehavesAsBeingDriven(ignoreHold))
                {
                    if (!visitor.VisitLeaf(signal, false))
                    {
                        return(false); // finished
                    }
                }
                else // HANDLE PORT
                {
                    TraversePort(signals, ports, buses, signal.DrivenByPort, signal, ignoreHold, visitor);
                }
            }
            return(visitor.LeaveSignal(signal, target, false, target == null));
        }
예제 #2
0
 protected override void DoTraverse(Signal rootSignal, IScanVisitor visitor, bool ignoreHold)
 {
     if (rootSignal.BehavesAsBeingDriven(ignoreHold))
     {
         List <Guid> ports = new List <Guid>();
         TraversePort(ports, rootSignal.DrivenByPort, rootSignal, ignoreHold, visitor);
     }
 }
 protected override void DoTraverse(Signal rootSignal, IScanVisitor visitor, bool ignoreHold)
 {
     if(rootSignal.BehavesAsBeingDriven(ignoreHold))
     {
         List<Guid> ports = new List<Guid>();
         TraversePort(ports, rootSignal.DrivenByPort, rootSignal, ignoreHold, visitor);
     }
 }
예제 #4
0
        public static bool CollectFactors(ISignalSet signals)
        {
            bool changed = false;

            for (int i = 0; i < signals.Count; i++)
            {
                Signal s = signals[i];
                if (!s.BehavesAsBeingDriven(false))
                {
                    continue;
                }

                Port p = s.DrivenByPort;
                if (p.Entity.EntityId.Equals(MultiplicationArchitectures.EntityIdentifier))
                {
                    signals.RemoveAt(i);
                    ISignalSet inputs = p.InputSignals;
                    for (int j = 0; j < inputs.Count; j++)
                    {
                        signals.Insert(i + j, inputs[j]);
                    }
                    i--;
                    changed = true;
                    continue;
                }

                if (p.Entity.EntityId.Equals(DivisionArchitectures.EntityIdentifier))
                {
                    ISignalSet inputs = p.InputSignals;
                    signals[i] = inputs[0];
                    i--;
                    for (int j = 1; j < inputs.Count; j++)
                    {
                        signals.Insert(i + j, Std.Invert(inputs[j]));
                    }
                    changed = true;
                    continue;
                }
            }
            return(changed);
        }
예제 #5
0
        public static bool CollectSummands(ISignalSet signals)
        {
            bool changed = false;

            for (int i = 0; i < signals.Count; i++)
            {
                Signal s = signals[i];
                if (!s.BehavesAsBeingDriven(false))
                {
                    continue;
                }

                Port p = s.DrivenByPort;
                if (p.Entity.EntityId.Equals(AdditionArchitectures.EntityIdentifier))
                {
                    signals.RemoveAt(i);
                    ISignalSet inputs = p.InputSignals;
                    for (int j = 0; j < inputs.Count; j++)
                    {
                        signals.Insert(i + j, (i == 0 && j != 0) ? Std.Negate(inputs[j]) : inputs[j]);
                    }
                    i--;
                    changed = true;
                    continue;
                }

                if (p.Entity.EntityId.Equals(SubtractionArchitectures.EntityIdentifier))
                {
                    ISignalSet inputs = p.InputSignals;
                    signals[i] = inputs[0];
                    i--;
                    for (int j = 1; j < inputs.Count; j++)
                    {
                        signals.Insert(i + j, (i == 0) ? inputs[j] : Std.Negate(inputs[j]));
                    }
                    changed = true;
                    continue;
                }
            }
            return(changed);
        }
예제 #6
0
 private bool TraverseSignal(List <Guid> signals, Signal signal, Port target, bool ignoreHold, IScanVisitor visitor)
 {
     if (signal == null || signals.Contains(signal.InstanceId))
     {
         return(true);
     }
     signals.Add(signal.InstanceId);
     if (visitor.EnterSignal(signal, target, false, target == null))
     {
         if (signal.BehavesAsBeingDriven(ignoreHold))
         {
             Port port = signal.DrivenByPort;
             foreach (Signal input in port.InputSignals)
             {
                 if (!TraverseSignal(signals, input, port, ignoreHold, visitor))
                 {
                     return(false); // finished
                 }
             }
         }
     }
     return(visitor.LeaveSignal(signal, target, false, target == null));
 }
        private bool TraverseSignal(Stack <Guid> signals, Signal signal, Port target, bool ignoreHold, IScanVisitor visitor)
        {
            if (signal == null)
            {
                return(true);
            }

            if (visitor.EnterSignal(signal, target, false, target == null))
            {
                signals.Push(signal.InstanceId);

                // HANDLE PORT
                if (signal.BehavesAsBeingDriven(ignoreHold))
                {
                    Port port = signal.DrivenByPort;

                    if (visitor.EnterPort(port, signal, false, false))
                    {
                        // LEAF PORT?
                        if (port.InputSignalCount == 0 && port.BusCount == 0)
                        {
                            if (!visitor.VisitLeaf(port, false))
                            {
                                return(false); // finished
                            }
                        }
                        // HANDLE BUSES
                        foreach (Bus b in port.Buses)
                        {
                            if (!visitor.VisitLeaf(b, false))
                            {
                                return(false); // finished
                            }
                        }
                        // HANDLE INPUT SIGNALS
                        foreach (Signal s in port.InputSignals)
                        {
                            if (signals.Contains(s.InstanceId))
                            {
                                if (!visitor.VisitCycle(port, signal, s))
                                {
                                    return(false); //finished
                                }
                            }
                            else if (!TraverseSignal(signals, s, port, ignoreHold, visitor))
                            {
                                return(false); // finished
                            }
                        }
                    }
                    if (!visitor.LeavePort(port, signal, false, false))
                    {
                        return(false); // finished
                    }
                }
                else if (!visitor.VisitLeaf(signal, false))
                {
                    return(false); // finished
                }
                signals.Pop();
            }
            return(visitor.LeaveSignal(signal, target, false, target == null));
        }
예제 #8
0
        private bool TraverseSignal(List<Guid> signals, List<Guid> ports, List<Guid> buses, Signal signal, Port target, bool ignoreHold, IScanVisitor visitor)
        {
            if(signal == null)
                return true;

            bool again = true;
            if(!signals.Contains(signal.InstanceId))
            {
                again = false;
                signals.Add(signal.InstanceId);
            }

            if(visitor.EnterSignal(signal, target, again, target == null))
            {
                // LEAF SIGNAL?
                if(!signal.BehavesAsBeingDriven(ignoreHold))
                {
                    if(!visitor.VisitLeaf(signal, again))
                        return false; // finished
                }
                else // HANDLE PORT
                {
                    TraversePort(signals, ports, buses, signal.DrivenByPort, signal, ignoreHold, visitor);
                }
            }
            return visitor.LeaveSignal(signal, target, again, target == null);
        }
        private bool TraverseSignal(Stack<Guid> signals, Signal signal, Port target, bool ignoreHold, IScanVisitor visitor)
        {
            if(signal == null)
                return true;

            if(visitor.EnterSignal(signal, target, false, target == null))
            {
                signals.Push(signal.InstanceId);

                // HANDLE PORT
                if(signal.BehavesAsBeingDriven(ignoreHold))
                {
                    Port port = signal.DrivenByPort;

                    if(visitor.EnterPort(port, signal, false, false))
                    {
                        // LEAF PORT?
                        if(port.InputSignalCount == 0 && port.BusCount == 0)
                            if(!visitor.VisitLeaf(port, false))
                                return false; // finished

                        // HANDLE BUSES
                        foreach(Bus b in port.Buses)
                            if(!visitor.VisitLeaf(b, false))
                                return false; // finished

                        // HANDLE INPUT SIGNALS
                        foreach(Signal s in port.InputSignals)
                        {
                            if(signals.Contains(s.InstanceId))
                            {
                                if(!visitor.VisitCycle(port, signal, s))
                                    return false; //finished
                            }
                            else if(!TraverseSignal(signals, s, port, ignoreHold, visitor))
                                return false; // finished
                        }
                    }
                    if(!visitor.LeavePort(port, signal, false, false))
                        return false; // finished
                }
                else if(!visitor.VisitLeaf(signal, false))
                    return false; // finished

                signals.Pop();
            }
            return visitor.LeaveSignal(signal, target, false, target == null);
        }
 private bool TraverseSignal(List<Guid> signals, Signal signal, Port target, bool ignoreHold, IScanVisitor visitor)
 {
     if(signal == null || signals.Contains(signal.InstanceId))
         return true;
     signals.Add(signal.InstanceId);
     if(visitor.EnterSignal(signal, target, false, target == null))
     {
         if(signal.BehavesAsBeingDriven(ignoreHold))
         {
             Port port = signal.DrivenByPort;
             foreach(Signal input in port.InputSignals)
                 if(!TraverseSignal(signals, input, port, ignoreHold, visitor))
                     return false; // finished
         }
     }
     return visitor.LeaveSignal(signal, target, false, target == null);
 }