public L_Xnor(int id, XNOR v_Xnor) : base(2, 2, id) //Output[0] = Normal [1] = Negiert { this.v_Xnor = v_Xnor; output[0] = !output[1]; //output[0] = Q output[1] = !Q for (int i = 0; i < 2; i++) { this.input[i] = false; } }
private void createGateDueToType(PaintEventArgs e) { //switch can be replaced by a one line of code using runtime Creation ((gotta GOOGLE it)) Gate g; switch (gateType) { case "OR": g = new OR(); break; case "NOT": g = new NOT(); break; case "AND": g = new AND(); break; case "NAND": g = new NAND(); break; case "NOR": g = new NOR(); break; case "XOR": g = new XOR(); break; case "XNOR": g = new XNOR(); break; default: g = null; break; } g.Draw(e); }
public void XNOR_InputChanged_OutputUpdatesCorrectly() { //When both inputs are off output should be on XNOR xnorGate = new XNOR(); Assert.IsTrue(xnorGate.Output.value); //When InputA only is on output should be off xnorGate.InputA.value = true; Assert.IsFalse(xnorGate.Output.value); //When both inputs are on output should be on xnorGate.InputB.value = true; Assert.IsTrue(xnorGate.Output.value); //When InputB only is on output should be off xnorGate.InputA.value = false; Assert.IsFalse(xnorGate.Output.value); //When both inputs are off again output should be on xnorGate.InputB.value = false; Assert.IsTrue(xnorGate.Output.value); }
public List <StandardComponent> parcourir_copier() { UIElement[] tableau = new UIElement[1000]; List <StandardComponent> liste = new List <StandardComponent>(); int length = canvas.Children.Count; canvas.Children.CopyTo(tableau, 0); for (int i = 0; i < length; i++) { StandardComponent newChild = null; if (!(typeof(Line) == tableau[i].GetType()) && ((tableau[i] as StandardComponent).IsSelect)) { if (typeof(AND) == tableau[i].GetType()) { newChild = new AND((tableau[i] as AND).nbrInputs()); for (int j = 0; j < (tableau[i] as AND).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as AND).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as AND).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(OR) == tableau[i].GetType()) { newChild = new OR((tableau[i] as OR).nbrInputs()); for (int j = 0; j < (tableau[i] as OR).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as OR).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as OR).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(NAND) == tableau[i].GetType()) { newChild = new NAND((tableau[i] as NAND).nbrInputs()); for (int j = 0; j < (tableau[i] as NAND).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as NAND).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as NAND).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(NOR) == tableau[i].GetType()) { newChild = new NOR((tableau[i] as NOR).nbrInputs()); for (int j = 0; j < (tableau[i] as NOR).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as NOR).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as NOR).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(Not) == tableau[i].GetType()) { newChild = new Not(); Terminal terminal_1 = (Terminal)((tableau[i] as Not).inputStack.Children[0]); Terminal terminal_2 = (Terminal)((newChild as Not).inputStack.Children[0]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } else if (typeof(Output) == tableau[i].GetType()) { newChild = new Output(); } else if (typeof(Input) == tableau[i].GetType()) { newChild = new Input(); (newChild as Input).state = (tableau[i] as Input).state; } else if (typeof(XNOR) == tableau[i].GetType()) { newChild = new XNOR((tableau[i] as XNOR).nbrInputs()); for (int j = 0; j < (tableau[i] as XNOR).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as XNOR).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as XNOR).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(XOR) == tableau[i].GetType()) { newChild = new XOR((tableau[i] as XOR).nbrInputs()); for (int j = 0; j < (tableau[i] as XOR).nbrInputs(); j++) { Terminal terminal_1 = (Terminal)((tableau[i] as XOR).inputStack.Children[j]); Terminal terminal_2 = (Terminal)((newChild as XOR).inputStack.Children[j]); if (terminal_1.IsInversed) { terminal_2.IsInversed = true; terminal_2.input_inversed(); } } } else if (typeof(Comparateur) == tableau[i].GetType()) { newChild = new Comparateur((tableau[i] as Comparateur).nbrInputs(), (tableau[i] as Comparateur).nbrOutputs()); } else if (typeof(Decodeur) == tableau[i].GetType()) { newChild = new Decodeur((tableau[i] as Decodeur).nbrInputs(), (tableau[i] as Decodeur).nbrOutputs()); } else if (typeof(Demultiplexer) == tableau[i].GetType()) { newChild = new Demultiplexer((tableau[i] as Demultiplexer).nbrInputs(), (tableau[i] as Demultiplexer).nbrOutputs(), (tableau[i] as Demultiplexer).nbrSelections()); } else if (typeof(Encodeur) == tableau[i].GetType()) { newChild = new Encodeur((tableau[i] as Encodeur).nbrInputs(), (tableau[i] as Encodeur).nbrOutputs()); } else if (typeof(FullAdder) == tableau[i].GetType()) { newChild = new FullAdder((tableau[i] as FullAdder).nbrInputs(), (tableau[i] as FullAdder).nbrOutputs()); } else if (typeof(FullSub) == tableau[i].GetType()) { newChild = new FullSub((tableau[i] as FullSub).nbrInputs(), (tableau[i] as FullSub).nbrOutputs()); } else if (typeof(HalfAdder) == tableau[i].GetType()) { newChild = new HalfAdder((tableau[i] as HalfAdder).nbrInputs(), (tableau[i] as HalfAdder).nbrOutputs()); } else if (typeof(HalfSub) == tableau[i].GetType()) { newChild = new HalfSub((tableau[i] as HalfSub).nbrInputs(), (tableau[i] as HalfSub).nbrOutputs()); } else if (typeof(Multiplexer) == tableau[i].GetType()) { newChild = new Multiplexer((tableau[i] as Multiplexer).nbrInputs(), (tableau[i] as Multiplexer).nbrOutputs(), (tableau[i] as Multiplexer).nbrSelections()); } else if (typeof(SequentialComponent.Clock) == tableau[i].GetType()) { newChild = new SequentialComponent.Clock((tableau[i] as SequentialComponent.Clock).LowLevelms, (tableau[i] as SequentialComponent.Clock).HighLevelms, MainWindow.Delay); } liste.Add(newChild); newChild.AllowDrop = true; newChild.PreviewMouseLeftButtonDown += fenetre.MouseLeftButtonDown; newChild.PreviewMouseMove += fenetre.MouseMove; newChild.PreviewMouseLeftButtonUp += fenetre.PreviewMouseLeftButtonUp; newChild.SetValue(Canvas.LeftProperty, tableau[i].GetValue(Canvas.LeftProperty)); newChild.SetValue(Canvas.TopProperty, tableau[i].GetValue(Canvas.TopProperty)); (newChild as StandardComponent).PosX = (tableau[i] as StandardComponent).PosX; (newChild as StandardComponent).PosY = (tableau[i] as StandardComponent).PosY; try { StandardComponent component = newChild as StandardComponent; component.recalculer_pos(); } catch { }; } } return(liste); }