예제 #1
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="original">original object</param>
 private SignalOutput(SignalOutput original)
 {
     if (!String.IsNullOrEmpty(original.m_Name))
     {
         Name = (string)original.Name.Clone();
     }
     m_LastState       = m_Inputs[0].State;
     m_Inputs[0].Delay = new NoDelay();
 }
예제 #2
0
 private void GenerateSignals()
 {
     m_SignalList.Clear();
     //add a signal for all clocks
     foreach (BaseElement element in m_Circuit)
     {
         Clock clock = element as Clock;
         if (clock != null)
         {
             Signal clkSignal = new Signal();
             clkSignal.IsReadOnly = true;
             clkSignal.Name       = element.Name;
             m_SignalList.Add(clkSignal);
         }
     }
     //add the stimuli
     foreach (Signal signal in m_EditorSignals)
     {
         //Signal clone = signal.Clone() as Signal;
         //clone.IsReadOnly = true;
         //m_SignalList.Add(clone);
         Signal inSignal = new Signal();
         inSignal.IsReadOnly = true;
         inSignal.Name       = signal.Name;
         m_SignalList.Add(inSignal);
     }
     //add a signal for all outputs
     foreach (BaseElement element in m_Circuit)
     {
         SignalOutput output = element as SignalOutput;
         if (output != null)
         {
             Signal outSignal = new Signal();
             outSignal.IsReadOnly = true;
             outSignal.Name       = output.SignalName;
             if (string.IsNullOrEmpty(outSignal.Name))
             {
                 outSignal.Name = element.Name;
             }
             m_SignalList.Add(outSignal);
         }
     }
     if (m_SignalList.IsConsistent == false)
     {
         m_SignalList.ForceConsistency();
     }
 }
예제 #3
0
 private void ProcessSimulationStep()
 {
     //set the inputs appropriate
     foreach (BaseElement element in m_Circuit)
     {
         SignalInput input = element as SignalInput;
         if (input != null)
         {
             State state = input.Signal.GetStateAtStep(m_CurrentStep);
             if (state == null)
             {
                 if (m_LoopSimulation || m_CurrentStep < m_EditorSignals.MaxSignalLength)
                 {
                     throw new SimulationException(
                               String.Format("Missing State for Signal {0} at step {1}.",
                                             input.SignalName, m_CurrentStep));
                 }
                 //else don't change the signal
             }
             else
             {
                 input.State = state;
             }
         }
     }
     //perform an update
     m_Circuit.Update();
     foreach (BaseElement element in m_Circuit)
     {
         //get data from clocks
         Clock clock = element as Clock;
         if (clock != null)
         {
             AddStateToSignal(clock.Name, clock.State);
         }
         //get data from inputs
         SignalInput input = element as SignalInput;
         if (input != null)
         {
             AddStateToSignal(input.SignalName, input.State);
         }
         //get data from outputs
         SignalOutput output = element as SignalOutput;
         if (output != null)
         {
             string name = output.SignalName;
             if (string.IsNullOrEmpty(name))
             {
                 name = output.Name;
             }
             AddStateToSignal(name, output.State);
         }
     }
     m_CurrentStep++;
     if (m_LoopSimulation && m_CurrentStep >= m_EditorSignals.MaxSignalLength)
     {
         m_CurrentStep = 0;
         foreach (Signal signal in m_SignalList)
         {
             signal.Clear();
         }
     }
 }