//iterates each bit of the 2 inputs and making or operation using "OR" gate - saves the output in Output public BitwiseAndGate(int iSize) : base(iSize) { for (int bit = 0; bit < iSize; bit++) { and_gate_per_bit = new AndGate(); and_gate_per_bit.ConnectInput1(Input1[bit]); and_gate_per_bit.ConnectInput2(Input2[bit]); Output[bit].ConnectInput(and_gate_per_bit.Output); } }
private Wire calc(Wire input1, Wire input2, int wireNum) { andGate = new AndGate(); andGate.ConnectInput1(input1); andGate.ConnectInput2(input2); if (wireNum < 0) { return(andGate.Output); } return(calc(andGate.Output, this.m_wsInput[wireNum], wireNum - 1)); }
public HalfAdder() { //your code here ag = new AndGate(); xog = new XorGate(); ag.ConnectInput1(Input1); ag.ConnectInput2(Input2); xog.ConnectInput1(Input1); xog.ConnectInput2(Input2); CarryOutput = ag.Output; Output = xog.Output; }
public BitwiseAndGate(int iSize) : base(iSize) { BitwiseAnd = new AndGate[iSize]; for (int i = 0; i < iSize; i++) { BitwiseAnd[i] = new AndGate(); BitwiseAnd[i].ConnectInput1(Input1[i]); BitwiseAnd[i].ConnectInput2(Input2[i]); Output[i].ConnectInput(BitwiseAnd[i].Output); } }
//nand gate is defines as not-AND gate, the procedure is completed using the AND,NOT gates. public NAndGate() { and_input = new AndGate(); not_output = new NotGate(); and_input.ConnectInput1(Input1); and_input.ConnectInput2(Input2); not_output.ConnectInput(and_input.Output); Output = not_output.Output; }
public HalfAdder() { CarryOutput = new Wire(); and = new AndGate(); xor = new XorGate(); Input1 = and.Input1; Input2 = and.Input2; xor.ConnectInput1(Input1); xor.ConnectInput2(Input2); Output = xor.Output; CarryOutput = and.Output; }
//your code here public HalfAdder() { //your code here XorGate xor = new XorGate(); AndGate and = new AndGate(); xor.ConnectInput1(Input1); xor.ConnectInput2(Input2); and.ConnectInput1(Input2); and.ConnectInput2(Input1); Output = xor.Output; CarryOutput = and.Output; }
public HalfAdder() { CarryOutput = new Wire(); m_xorGate = new XorGate(); m_andGate = new AndGate(); m_xorGate.Input1.ConnectInput(Input1); m_xorGate.Input2.ConnectInput(Input2); Output.ConnectInput(m_xorGate.Output); m_andGate.Input1.ConnectInput(Input1); m_andGate.Input2.ConnectInput(Input2); CarryOutput.ConnectInput(m_andGate.Output); }
public HalfAdder() { CarryOutput = new Wire(); xor = new XorGate(); and = new AndGate(); xor.ConnectInput1(Input1); xor.ConnectInput2(Input2); and.ConnectInput1(Input1); and.ConnectInput2(Input2); CarryOutput.ConnectInput(and.Output); Output.ConnectInput(xor.Output); }
public BitwiseAndGate(int iSize) : base(iSize) { and = new AndGate(); for (int i = 0; i < Size; i++) { and.ConnectInput1(Input1[i]); and.ConnectInput2(Input2[i]); Output[i].ConnectInput(and.Output); and = new AndGate(); } }
public HalfAdder() { //your code here m_gXor = new XorGate(); m_gAnd = new AndGate(); m_gXor.ConnectInput1(Input1); m_gXor.ConnectInput2(Input2); Output.ConnectInput(m_gXor.Output); m_gAnd.ConnectInput1(Input1); m_gAnd.ConnectInput2(Input2); CarryOutput = new Wire(); CarryOutput.ConnectInput(m_gAnd.Output); }
//making and operation for 2 consecutive bits(wires) until the last bit. first bit is constant - 1 public MultiBitAndGate(int iInputCount) : base(iInputCount) { size_of_wire = iInputCount; result = new Wire(); result.Value = 1; for (int bit = 0; bit < iInputCount; bit++) { and_operator = new AndGate(); and_operator.ConnectInput1(result); and_operator.ConnectInput2(m_wsInput[bit]); result = and_operator.Output; } Output = result; }
public MultiBitAndGate(int iInputCount) : base(iInputCount) { //your code here and = new AndGate[iInputCount - 1]; and[0] = new AndGate(); and[0].ConnectInput1(m_wsInput[0]); and[0].ConnectInput2(m_wsInput[1]); for (int i = 2; i < iInputCount; i++) { and[i - 1] = new AndGate(); and[i - 1].ConnectInput1(and[i - 2].Output); and[i - 1].ConnectInput2(m_wsInput[i]); } Output.ConnectInput(and[iInputCount - 2].Output); }
public OrGate() { //init the gates m_gNot1 = new NotGate(); //outside the parentheses m_gNot2 = new NotGate(); //a m_gNot3 = new NotGate(); //b m_gAnd = new AndGate(); //connect the gates m_gAnd.ConnectInput1(m_gNot2.Output); m_gAnd.ConnectInput2(m_gNot3.Output); m_gNot1.ConnectInput(m_gAnd.Output); //set the inputs and the output of the or gate Output = m_gNot1.Output; Input1 = m_gNot2.Input; Input2 = m_gNot3.Input; }
//your code here public MultiBitAndGate(int iInputCount) : base(iInputCount) { AndGate[] and = new AndGate[iInputCount - 1]; // reminder - make the first one outside the for loop and[0] = new AndGate(); and[0].ConnectInput1(m_wsInput[0]); //assuming there are at least two bits and[0].ConnectInput2(m_wsInput[1]); for (int i = 1; i < iInputCount - 1; i++) { and[i] = new AndGate(); and[i].ConnectInput1(and[i - 1].Output); and[i].ConnectInput2(m_wsInput[i + 1]); } Output.ConnectInput(and[iInputCount - 2].Output); }
public Demux() { Input = new Wire(); //your code here Control = new Wire(); m_gNot = new NotGate(); m_gAnd1 = new AndGate(); m_gAnd2 = new AndGate(); m_gNot.ConnectInput(Control); m_gAnd1.ConnectInput1(Input); m_gAnd1.ConnectInput2(m_gNot.Output); m_gAnd2.ConnectInput1(Control); m_gAnd2.ConnectInput2(Input); Output1 = m_gAnd1.Output; Output2 = m_gAnd2.Output; }
public HalfAdder() { CarryOutput = new Wire(); var gXor = new XorGate(); var gAnd = new AndGate(); Input1 = gAnd.Input1; Input2 = gAnd.Input2; gXor.ConnectInput1(Input1); gXor.ConnectInput2(Input2); Output = gXor.Output; CarryOutput = gAnd.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 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() { 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; }
//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 BitwiseAndGate(int iSize) : base(iSize) { m_gAnd = new AndGate[iSize]; WireSet ws_resault = new WireSet(iSize); //your code here for (int i = 0; i < iSize; i++) { m_gAnd[i] = new AndGate(); m_gAnd[i].ConnectInput1(Input1[i]); m_gAnd[i].ConnectInput2(Input2[i]); ws_resault[i].ConnectInput(m_gAnd[i].Output); } Output.ConnectInput(ws_resault); }
//your code here public Demux() { Input = new Wire(); Control = new Wire(); //init AndGate and1 = new AndGate(); AndGate and2 = new AndGate(); NotGate not = new NotGate(); and1.ConnectInput1(Input); and2.ConnectInput2(Input); not.ConnectInput(Control); and1.ConnectInput2(not.Output); and2.ConnectInput1(Control); Output1 = and1.Output; Output2 = and2.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; }
// creating the halfadder by using the "xor" and "and gates" for the output and the carry public HalfAdder() { // initilaize the gates CarryOutput = new Wire(); xor_op = new XorGate(); and_op = new AndGate(); //xor operation for the sum output xor_op.ConnectInput1(Input1); xor_op.ConnectInput2(Input2); //and operation for the carry output and_op.ConnectInput1(Input1); and_op.ConnectInput2(Input2); //connecting outputs Output.ConnectInput(xor_op.Output); CarryOutput.ConnectInput(and_op.Output); }
public MultiBitAndGate(int iInputCount) : base(iInputCount) { m_AndGates = new AndGate[iInputCount - 1]; for (int i = 0; i < m_AndGates.Length; i++) { m_AndGates[i] = new AndGate(); } m_AndGates[0].ConnectInput1(m_wsInput[0]); m_AndGates[0].ConnectInput2(m_wsInput[1]); for (int i = 1; i < (iInputCount - 1); i++) { m_AndGates[i].ConnectInput1(m_AndGates[i - 1].Output); m_AndGates[i].ConnectInput2(m_wsInput[i + 1]); } Output = m_AndGates[iInputCount - 2].Output; }
public MultiBitAndGate(int iInputCount) : base(iInputCount) { and = new AndGate(); and.ConnectInput1(m_wsInput[0]); and.ConnectInput2(m_wsInput[1]); Wire temp = and.Output; for (int i = 2; i < m_wsInput.Size; i++) { and = new AndGate(); and.ConnectInput1(temp); and.ConnectInput2(m_wsInput[i]); temp = and.Output; } Output = temp; }
//your code here public Demux() { Input = new Wire(); var mGAnd1 = new AndGate(); var mGAnd2 = new AndGate(); var mGNot1 = new NotGate(); Control = new Wire(); mGNot1.ConnectInput(Control); mGAnd2.ConnectInput1(Input); mGAnd2.ConnectInput2(Control); mGAnd1.ConnectInput1(Input); mGAnd1.ConnectInput2(mGNot1.Output); Output1 = mGAnd1.Output; Output2 = mGAnd2.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; }