public XorGate() { //init the gates Wire wire1 = new Wire(); //for A, first side Wire wire2 = new Wire(); //for B, second side m_gNot1 = new NotGate(); //for B, first side m_gNot2 = new NotGate(); //for A, second side m_gAnd1 = new AndGate(); //first side m_gAnd2 = new AndGate(); //second side m_gOr = new OrGate(); //connect the gates m_gOr.ConnectInput1(m_gAnd1.Output); m_gOr.ConnectInput2(m_gAnd2.Output); m_gAnd1.ConnectInput1(wire1); m_gNot1.ConnectInput(wire2); m_gAnd1.ConnectInput2(m_gNot1.Output); m_gNot2.ConnectInput(wire1); m_gAnd2.ConnectInput1(m_gNot2.Output); m_gAnd2.ConnectInput2(wire2); //set the inputs and the output of the or gate Output = m_gOr.Output; Input1 = wire1; Input2 = wire2; }
public MuxGate() {//init ControlInput = new Wire(); Wire a = new Wire(); Wire b = new Wire(); and1 = new AndGate(); and2 = new AndGate(); or = new OrGate(); not = new NotGate(); //connect or.ConnectInput1(and1.Output); or.ConnectInput2(and2.Output); and1.ConnectInput1(ControlInput); and1.ConnectInput2(b); and2.ConnectInput1(not.Output); not.ConnectInput(ControlInput); and2.ConnectInput2(a); /* or.ConnectInput1(and1.Output); * or.ConnectInput2(and2.Output); * and1.ConnectInput1(ControlInput); * and1.ConnectInput1(b); * not.ConnectInput(ControlInput); * and2.ConnectInput1(not.Output); * and2.ConnectInput2(a); */ //input\output Input1 = a; Input2 = b; Output = or.Output; }
// full addr operation is accomplished by using 2 half addrs and or gate for the output carrier public FullAdder() { // initilaize the gates CarryInput = new Wire(); CarryOutput = new Wire(); first_half_addr = new HalfAdder(); second_half_addr = new HalfAdder(); or_op = new OrGate(); //connecting the first addr first_half_addr.ConnectInput1(Input1); first_half_addr.ConnectInput2(Input2); //connecting the second addr second_half_addr.ConnectInput1(first_half_addr.Output); second_half_addr.ConnectInput2(CarryInput); //or_op for the carry output or_op.ConnectInput1(second_half_addr.CarryOutput); or_op.ConnectInput2(first_half_addr.CarryOutput); //connecting the outputs Output.ConnectInput(second_half_addr.Output); CarryOutput.ConnectInput(or_op.Output); }
//iterates each bit of the 2 inputs and making or operation using "OR" gate - saves the output in Output public BitwiseOrGate(int iSize) : base(iSize) { for (int bit = 0; bit < iSize; bit++) { or_gate_per_bit = new OrGate(); or_gate_per_bit.ConnectInput1(Input1[bit]); or_gate_per_bit.ConnectInput2(Input2[bit]); Output[bit].ConnectInput(or_gate_per_bit.Output); } }
//your code here public BitwiseOrGate(int iSize) : base(iSize) { OrGate[] or = new OrGate[iSize]; for (int i = 0; i < iSize; i++) { or[i] = new OrGate(); or[i].ConnectInput1(Input1[i]); or[i].ConnectInput2(Input2[i]); Output[i].ConnectInput(or[i].Output); } }
private Wire calc(Wire input1, Wire input2, int wireNum) { orGate = new OrGate(); orGate.ConnectInput1(input1); orGate.ConnectInput2(input2); if (wireNum < 0) { return(orGate.Output); } return(calc(orGate.Output, this.m_wsInput[wireNum], wireNum - 1)); }
public XorGate() { //your code here m_gAAndNotB = new AAndNotBGate(); m_gNotAAndB = new AAndNotBGate(); m_gOr = new OrGate(); m_gAAndNotB.ConnectInput1(Input1); m_gAAndNotB.ConnectInput2(Input2); m_gNotAAndB.ConnectInput1(Input2); m_gNotAAndB.ConnectInput2(Input1); m_gOr.ConnectInput1(m_gAAndNotB.Output); m_gOr.ConnectInput2(m_gNotAAndB.Output); Output = m_gOr.Output; }
//making or operation for 2 consecutive bits(wires) until the last bit. first bit is constant - 0 public MultiBitOrGate(int iInputCount) : base(iInputCount) { size_of_wire = iInputCount; result = new Wire(); result.Value = 0; for (int bit = 0; bit < iInputCount; bit++) { or_operator = new OrGate(); or_operator.ConnectInput1(result); or_operator.ConnectInput2(m_wsInput[bit]); result = or_operator.Output; } Output = result; }
public XorGate() { m_gNand = new NAndGate(); m_gOr = new OrGate(); m_gAnd = new AndGate(); m_gOr.ConnectInput1(Input1); m_gOr.ConnectInput2(Input2); m_gNand.ConnectInput1(Input1); m_gNand.ConnectInput2(Input2); m_gAnd.ConnectInput1(m_gOr.Output); m_gAnd.ConnectInput2(m_gNand.Output); Output = m_gAnd.Output; }
public FullAdder() { CarryInput = new Wire(); //your code here CarryOutput = new Wire(); ha1 = new HalfAdder(); ha2 = new HalfAdder(); or = new OrGate(); ha2.ConnectInput1(ha1.Output); ha2.ConnectInput2(CarryInput); or.ConnectInput1(ha1.CarryOutput); or.ConnectInput2(ha2.CarryOutput); Input1 = ha1.Input1; Input2 = ha1.Input2; CarryOutput = or.Output; Output = ha2.Output; }
//your code here public FullAdder() { CarryInput = new Wire(); //your code here HalfAdder ha1 = new HalfAdder(); HalfAdder ha2 = new HalfAdder(); OrGate or = new OrGate(); ha1.ConnectInput1(Input1); ha1.ConnectInput2(Input2); ha2.ConnectInput2(CarryInput); ha2.ConnectInput1(ha1.Output); or.ConnectInput2(ha1.CarryOutput); or.ConnectInput1(ha2.CarryOutput); Output = ha2.Output; CarryOutput = or.Output; }
public MuxGate() { ControlInput = new Wire(); m_gNot = new NotGate(); m_gAnd1 = new AndGate(); m_gAnd2 = new AndGate(); m_gOr = new OrGate(); m_gAnd1.ConnectInput1(m_gNot.Output); m_gOr.ConnectInput1(m_gAnd1.Output); m_gOr.ConnectInput2(m_gAnd2.Output); m_gNot.ConnectInput(ControlInput); m_gAnd2.ConnectInput1(ControlInput); Input1 = m_gAnd1.Input2; Input2 = m_gAnd2.Input2; Output = m_gOr.Output; }
public XorGate() { or = new OrGate(); NAnd = new NAndGate(); and = new AndGate(); Input1 = or.Input1; Input2 = or.Input2; NAnd.ConnectInput1(Input1); NAnd.ConnectInput2(Input2); and.ConnectInput1(or.Output); and.ConnectInput2(NAnd.Output); Output = and.Output; }
public AndGate() { //init the gates m_gOR = new OrGate(); m_gNotInput1 = new NotGate(); m_gNotInput2 = new NotGate(); m_gNotOutput = new NotGate(); //wire the inputs to the not gates m_gNotInput1.ConnectInput(Input1); m_gNotInput2.ConnectInput(Input2); //connect the or gate m_gOR.ConnectInput1(m_gNotInput1.Output); m_gOR.ConnectInput2(m_gNotInput2.Output); //connect the not on the output m_gNotOutput.ConnectInput(m_gOR.Output); //set the output of the and gate Output = m_gNotOutput.Output; }
//Xor gate is possible to get by combining with and gate the results of the nand and or gates. public XorGate() { nand_input = new NAndGate(); or_input = new OrGate(); and_output = new AndGate(); nand_input.ConnectInput1(Input1); nand_input.ConnectInput2(Input2); or_input.ConnectInput1(Input1); or_input.ConnectInput2(Input2); and_output.ConnectInput1(nand_input.Output); and_output.ConnectInput2(or_input.Output); Output = and_output.Output; }
public BitwiseOrGate(int iSize) : base(iSize) { //your code here m_gOrGate = new OrGate[iSize]; WireSet ws_resault = new WireSet(iSize); //your code here for (int i = 0; i < iSize; i++) { m_gOrGate[i] = new OrGate(); m_gOrGate[i].ConnectInput1(Input1[i]); m_gOrGate[i].ConnectInput2(Input2[i]); ws_resault[i].ConnectInput(m_gOrGate[i].Output); } Output.ConnectInput(ws_resault); }
public MultiBitOrGate(int iInputCount) : base(iInputCount) { m_OrGates = new OrGate[iInputCount - 1]; for (int i = 0; i < m_OrGates.Length; i++) { m_OrGates[i] = new OrGate(); } m_OrGates[0].ConnectInput1(m_wsInput[0]); m_OrGates[0].ConnectInput2(m_wsInput[1]); for (int i = 1; i < (iInputCount - 1); i++) { m_OrGates[i].ConnectInput1(m_OrGates[i - 1].Output); m_OrGates[i].ConnectInput2(m_wsInput[i + 1]); } Output = m_OrGates[iInputCount - 2].Output; }
public MuxGate() { ControlInput = new Wire(); m_gAndX = new AndGate(); m_gAndY = new AndGate(); m_gOr = new OrGate(); m_gNotC = new NotGate(); m_gAndY.ConnectInput1(ControlInput); m_gAndY.ConnectInput2(Input2); m_gNotC.ConnectInput(ControlInput); m_gAndX.ConnectInput2(m_gNotC.Output); m_gAndX.ConnectInput1(Input1); m_gOr.ConnectInput1(m_gAndX.Output); m_gOr.ConnectInput2(m_gAndY.Output); Output = m_gOr.Output; }
public XorGate() { //your code here m_gAnd = new AndGate(); m_gNand = new NAndGate(); m_gOr = new OrGate(); m_gAnd.ConnectInput1(m_gNand.Output); m_gAnd.ConnectInput2(m_gOr.Output); Input1 = m_gOr.Input1; Input2 = m_gOr.Input2; m_gNand.ConnectInput1(Input1); m_gNand.ConnectInput2(Input2); Output = m_gAnd.Output; }
public FullAdder() { CarryInput = new Wire(); //your code here ha = new HalfAdder(); ha2 = new HalfAdder(); og = new OrGate(); ha.ConnectInput1(Input1); ha.ConnectInput2(Input2); ha2.ConnectInput1(ha.Output); ha2.ConnectInput2(CarryInput); og.ConnectInput1(ha2.CarryOutput); og.ConnectInput2(ha.CarryOutput); Output = ha2.Output; CarryOutput = og.Output; }
public MultiBitOrGate(int iInputCount) : base(iInputCount) { or = new OrGate(); or.ConnectInput1(m_wsInput[0]); or.ConnectInput2(m_wsInput[1]); Wire temp = or.Output; for (int i = 2; i < iInputCount; i++) { or = new OrGate(); or.ConnectInput1(temp); or.ConnectInput2(m_wsInput[i]); temp = or.Output; } Output = temp; }
public FullAdder() { CarryInput = new Wire(); CarryOutput = new Wire(); var halfAdd1 = new HalfAdder(); var halfAdd2 = new HalfAdder(); var gOr = new OrGate(); halfAdd2.ConnectInput2(CarryInput); halfAdd2.ConnectInput1(halfAdd1.Output); gOr.ConnectInput1(halfAdd1.CarryOutput); gOr.ConnectInput2(halfAdd2.CarryOutput); Input1 = halfAdd1.Input1; Input2 = halfAdd1.Input2; CarryOutput = gOr.Output; Output = halfAdd2.Output; }
public MuxGate() { var mGAnd1 = new AndGate(); var mGAnd2 = new AndGate(); var mGNot1 = new NotGate(); var mGOr = new OrGate(); ControlInput = new Wire(); mGNot1.ConnectInput(ControlInput); mGAnd2.ConnectInput1(Input2); mGAnd2.ConnectInput2(ControlInput); mGAnd1.ConnectInput1(Input1); mGAnd1.ConnectInput2(mGNot1.Output); mGOr.ConnectInput1(mGAnd1.Output); mGOr.ConnectInput2(mGAnd2.Output); Output = mGOr.Output; }
public FullAdder() { CarryInput = new Wire(); //your code here CarryOutput = new Wire(); m_gHf = new HalfAdder(); m_gHf.ConnectInput1(Input1); m_gHf.ConnectInput2(Input2); m_gHfCin = new HalfAdder(); m_gHfCin.ConnectInput1(m_gHf.Output); m_gHfCin.ConnectInput2(CarryInput); Output.ConnectInput(m_gHfCin.Output); m_gOrCout = new OrGate(); m_gOrCout.ConnectInput1(m_gHf.CarryOutput); m_gOrCout.ConnectInput2(m_gHfCin.CarryOutput); CarryOutput.ConnectInput(m_gOrCout.Output); }
public MultiBitOrGate(int iInputCount) : base(iInputCount) { var orArray = new OrGate[iInputCount - 1]; for (int i = 0; i < orArray.Length; i++) { orArray[i] = new OrGate(); if (i != 0) { orArray[i].ConnectInput1(orArray[i - 1].Output); orArray[i].ConnectInput2(m_wsInput[i + 1]); } else { orArray[0].ConnectInput1(m_wsInput[0]); orArray[0].ConnectInput2(m_wsInput[1]); } } Output = orArray[orArray.Length - 1].Output; }
public FullAdder() { CarryInput = new Wire(); CarryOutput = new Wire(); half1 = new HalfAdder(); half2 = new HalfAdder(); or = new OrGate(); half1.ConnectInput1(Input1); half1.ConnectInput2(Input2); half2.ConnectInput1(CarryInput); half2.ConnectInput2(half1.Output); or.ConnectInput1(half1.CarryOutput); or.ConnectInput2(half2.CarryOutput); CarryOutput.ConnectInput(or.Output); Output.ConnectInput(half2.Output); }
//A XOR B = (A ^ ~B)U(~A ^ B) public XorGate() { //init the gates var mGNot1 = new NotGate(); var mGNot2 = new NotGate(); var mGAnd1 = new AndGate(); var mGAnd2 = new AndGate(); var mGOr = new OrGate(); //wire mGAnd1.ConnectInput1(mGNot1.Output); mGAnd1.ConnectInput2(mGNot2.Input); mGAnd2.ConnectInput1(mGNot1.Input); mGAnd2.ConnectInput2(mGNot2.Output); mGOr.ConnectInput1(mGAnd1.Output); mGOr.ConnectInput2(mGAnd2.Output); //set the inputs and the output of the xor gate Output = mGOr.Output; Input1 = mGNot1.Input; Input2 = mGNot2.Input; }
public override bool TestGate() { BitwiseOrGate bwog; OrGate m_gLocalOr; for (int j = 0; j < Math.Pow(2, Size); j++) { bwog = new BitwiseOrGate(Size); bwog.Input1.ConnectInput(InitTestVariables(j)); bwog.Input2.ConnectInput(InitRandTestVar(Size)); for (int i = 0; i < Size; i++) { m_gLocalOr = new OrGate(); m_gLocalOr.ConnectInput1(bwog.Input1[i]); m_gLocalOr.ConnectInput2(bwog.Input2[i]); if (bwog.Input1[i].Value == 1 || bwog.Input2[i].Value == 1) { if (m_gLocalOr.Output.Value != 1 || bwog.m_gOrGate[i].Output.Value != 1) { return(false); } } else { if (m_gLocalOr.Output.Value != 0) { return(false); } } } // UNCOMMENT THIS LINES TO SEE THE DEBUG PRINT //System.Console.WriteLine(" Testing input1 " + " -> " + WStoString(bwog.Input1)); //System.Console.WriteLine(" Testing input2 " + " -> " + WStoString(bwog.Input2)); //System.Console.WriteLine(" Testing output " + " -> " + WStoString(bwog.Output)); } return(true); }
public MuxGate() { ControlInput = new Wire(); not = new NotGate(); and1 = new AndGate(); and2 = new AndGate(); or = new OrGate(); not.ConnectInput(ControlInput); and1.ConnectInput1(not.Output); //and1.ConnectInput2(); and2.ConnectInput1(ControlInput); //and2.ConnectInput2(Input2); Input1 = and1.Input2; Input2 = and2.Input2; or.ConnectInput1(and1.Output); or.ConnectInput2(and2.Output); Output = or.Output; }
// accoplish using 2 "AND", "OR" and "NOT" gates, // first connect input 1 and "NOT" control bit to "AND" gate 1, then connect input 2 and control bit to "AND" gate 2 // lastly connect the outputs of "AND" gates to "OR" gate public MuxGate() { ControlInput = new Wire(); // initilaize the gates and_input1 = new AndGate(); and_input2 = new AndGate(); not_contolinput_input1 = new NotGate(); or_output = new OrGate(); //step 1 not_contolinput_input1.ConnectInput(ControlInput); and_input1.ConnectInput1(Input1); and_input1.ConnectInput2(not_contolinput_input1.Output); //step 2 and_input2.ConnectInput1(Input2); and_input2.ConnectInput2(ControlInput); //step 3 or_output.ConnectInput1(and_input1.Output); or_output.ConnectInput2(and_input2.Output); Output = or_output.Output; }