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; }
public Demux() { Input = new Wire(); Control = new Wire(); Output1 = new Wire(); Output2 = new Wire(); //your code here m_gAnd1 = new AndGate(); m_gAnd2 = new AndGate(); m_gNot = new NotGate(); Output1.Value = 0; Output2.Value = 0; m_gNot.ConnectInput(Control); m_gAnd1.ConnectInput1(Input); m_gAnd1.ConnectInput2(m_gNot.Output); m_gAnd2.ConnectInput1(Input); m_gAnd2.ConnectInput2(Control); Output1 = m_gAnd1.Output; Output2 = m_gAnd2.Output; }
public MuxGate() { ControlInput = new Wire(); //Init the variables m_gAnd1 = new AndGate(); m_gAnd2 = new AndGate(); m_gAnd3 = new AndGate(); m_gNot = new NotGate(); m_gmOr = new MultiBitOrGate(3); m_ws = new WireSet(3); //Connect the wires m_gNot.ConnectInput(ControlInput); m_gAnd1.ConnectInput1(Input1); m_gAnd1.ConnectInput2(Input2); m_gAnd2.ConnectInput1(Input2); m_gAnd2.ConnectInput2(ControlInput); m_gAnd3.ConnectInput1(Input1); m_gAnd3.ConnectInput2(m_gNot.Output); m_ws[0].ConnectInput(m_gAnd1.Output); m_ws[1].ConnectInput(m_gAnd2.Output); m_ws[2].ConnectInput(m_gAnd3.Output); m_gmOr.ConnectInput(m_ws); Output = m_gmOr.Output; }
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; }
// accoplish using 2 "AND" and "NOT" gates, // first connect input and "NOT" control bit to "AND" gate 1, then connect input and control bit to "AND" gate 2 // lastly connect the outputs public Demux() { Input = new Wire(); Control = new Wire(); Output1 = new Wire(); Output2 = new Wire(); // initilaize the gates and_output1 = new AndGate(); and_output2 = new AndGate(); not_contolinput_input1 = new NotGate(); //step 1 not_contolinput_input1.ConnectInput(Control); and_output1.ConnectInput1(Input); and_output1.ConnectInput2(not_contolinput_input1.Output); //step 2 and_output2.ConnectInput1(Input); and_output2.ConnectInput2(Control); //step 3 Output1 = and_output1.Output; Output2 = and_output2.Output; }
public AAndNotBGate() { m_gNot = new NotGate(); m_gAnd = new AndGate(); m_gNot.ConnectInput(Input2); m_gAnd.ConnectInput1(Input1); m_gAnd.ConnectInput2(m_gNot.Output); Output = m_gAnd.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 AndGate() { //init the gates m_gNand = new NAndGate(); m_gNot = new NotGate(); //wire the output of the nand gate to the input of the not m_gNot.ConnectInput(m_gNand.Output); //set the inputs and the output of the and gate Output = m_gNot.Output; Input1 = m_gNand.Input1; Input2 = m_gNand.Input2; }
//iterating each bit of the input and using the "NOT" gate to reverse the bit. public BitwiseNotGate(int iSize) { Size = iSize; Input = new WireSet(Size); Output = new WireSet(Size); for (int bit = 0; bit < iSize; bit++) { not_gate_operation = new NotGate(); not_gate_operation.ConnectInput(Input[bit]); Output[bit].ConnectInput(not_gate_operation.Output); } }
public BitwiseNotGate(int iSize) { Size = iSize; Input = new WireSet(Size); Output = new WireSet(Size); not = new NotGate(); for (int i = 0; i < Size; i++) { not.ConnectInput(Input[i]); Output[i].ConnectInput(not.Output); not = new NotGate(); } }
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; }
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 BitwiseNotGate(int iSize) { Size = iSize; Input = new WireSet(Size); Output = new WireSet(Size); //your code here m_gates = new NotGate[iSize]; for (int i = 0; i < iSize; i++) { var gate = new NotGate(); m_gates[i] = gate; gate.ConnectInput(Input[i]); Output[i].ConnectInput(gate.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; }
//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 Demux() { Input = new Wire(); Control = new Wire(); m_gAnd1 = new AndGate(); m_gAnd2 = new AndGate(); m_gNot = new NotGate(); m_gNot.ConnectInput(Control); m_gAnd1.ConnectInput1(m_gNot.Output); m_gAnd1.ConnectInput2(Input); m_gAnd2.ConnectInput1(Control); m_gAnd2.ConnectInput2(Input); Output1 = m_gAnd1.Output; Output2 = m_gAnd2.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; }
//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; }
// 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; }
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; }
public ALU(int iSize) { Size = iSize; InputX = new WireSet(Size); InputY = new WireSet(Size); ZeroX = new Wire(); ZeroY = new Wire(); NotX = new Wire(); NotY = new Wire(); F = new Wire(); NotOutput = new Wire(); Negative = new Wire(); Zero = new Wire(); //Create and connect all the internal components Output = new WireSet(Size); m_wsZero = new WireSet(Size); for (int i = 0; i < Size; i++) { m_wsZero[i].Value = 0; } m_gZxMux = new BitwiseMultiwayMux(Size, 1); m_gZxMux.ConnectInput(0, InputX); m_gZxMux.ConnectInput(1, m_wsZero); m_gZxMux.Control[0].ConnectInput(ZeroX); m_gNxNot = new BitwiseNotGate(Size); m_gNxNot.ConnectInput(m_gZxMux.Output); m_gNxMux = new BitwiseMultiwayMux(Size, 1); m_gNxMux.ConnectInput(0, m_gZxMux.Output); m_gNxMux.ConnectInput(1, m_gNxNot.Output); m_gNxMux.Control[0].ConnectInput(NotX); m_gZyMux = new BitwiseMultiwayMux(Size, 1); m_gZyMux.ConnectInput(0, InputY); m_gZyMux.ConnectInput(1, m_wsZero); m_gZyMux.Control[0].ConnectInput(ZeroY); m_gNyNot = new BitwiseNotGate(Size); m_gNyNot.ConnectInput(m_gZyMux.Output); m_gNyMux = new BitwiseMultiwayMux(Size, 1); m_gNyMux.ConnectInput(0, m_gZyMux.Output); m_gNyMux.ConnectInput(1, m_gNyNot.Output); m_gNyMux.Control[0].ConnectInput(NotY); m_gFAdder = new MultiBitAdder(Size); m_gFAdder.ConnectInput1(m_gNxMux.Output); m_gFAdder.ConnectInput2(m_gNyMux.Output); m_gFAnd = new BitwiseAndGate(Size); m_gFAnd.ConnectInput1(m_gNxMux.Output); m_gFAnd.ConnectInput2(m_gNyMux.Output); m_gFMux = new BitwiseMultiwayMux(Size, 1); m_gFMux.ConnectInput(0, m_gFAnd.Output); m_gFMux.ConnectInput(1, m_gFAdder.Output); m_gFMux.Control[0].ConnectInput(F); m_gNoNot = new BitwiseNotGate(Size); m_gNoNot.ConnectInput(m_gFMux.Output); m_gNoMux = new BitwiseMultiwayMux(Size, 1); m_gNoMux.ConnectInput(0, m_gFMux.Output); m_gNoMux.ConnectInput(1, m_gNoNot.Output); m_gNoMux.Control[0].ConnectInput(NotOutput); Output.ConnectInput(m_gNoMux.Output); m_gZrOr = new MultiBitOrGate(Size); m_gZrOr.ConnectInput(Output); m_gZrNot = new NotGate(); m_gZrNot.ConnectInput(m_gZrOr.Output); Zero.ConnectInput(m_gZrNot.Output); Negative.ConnectInput(Output[Size - 1]); }
public ALU(int iSize) { Size = iSize; InputX = new WireSet(Size); InputY = new WireSet(Size); ZeroX = new Wire(); ZeroY = new Wire(); NotX = new Wire(); NotY = new Wire(); F = new Wire(); NotOutput = new Wire(); Negative = new Wire(); Zero = new Wire(); //Create and connect all the internal components muxZeroX = new BitwiseMux(Size); muxZeroY = new BitwiseMux(Size); muxNegX = new BitwiseMux(Size); muxNegY = new BitwiseMux(Size); muxFunc = new BitwiseMux(Size); muxNegOut = new BitwiseMux(Size); mbAdder = new MultiBitAdder(Size); bwAnd = new BitwiseAndGate(Size); mbOr = new MultiBitOrGate(Size); bwNot1 = new BitwiseNotGate(Size); bwNot2 = new BitwiseNotGate(Size); bwNot3 = new BitwiseNotGate(Size); zeroWS = new WireSet(Size); negAnd = new AndGate(); notBit = new Wire(); not1 = new NotGate(); // Zero X muxZeroX.Input1.ConnectInput(InputX); muxZeroX.Input2.ConnectInput(zeroWS); muxZeroX.ConnectControl(ZeroX); // Not X bwNot1.ConnectInput(muxZeroX.Output); muxNegX.Input1.ConnectInput(muxZeroX.Output); muxNegX.Input2.ConnectInput(bwNot1.Output); muxNegX.ConnectControl(NotX); // Zero Y muxZeroY.Input1.ConnectInput(InputY); muxZeroY.Input2.ConnectInput(zeroWS); muxZeroY.ConnectControl(ZeroY); // Not Y bwNot2.ConnectInput(muxZeroY.Output); muxNegY.Input1.ConnectInput(muxZeroY.Output); muxNegY.Input2.ConnectInput(bwNot2.Output); muxNegY.ConnectControl(NotY); // Func mbAdder.ConnectInput1(muxNegX.Output); mbAdder.ConnectInput2(muxNegY.Output); bwAnd.Input1.ConnectInput(muxNegX.Output); bwAnd.Input2.ConnectInput(muxNegY.Output); muxFunc.Input1.ConnectInput(bwAnd.Output); muxFunc.Input2.ConnectInput(mbAdder.Output); muxFunc.ConnectControl(F); // Not Output bwNot3.ConnectInput(muxFunc.Output); muxNegOut.Input1.ConnectInput(muxFunc.Output); muxNegOut.Input2.ConnectInput(bwNot3.Output); muxNegOut.ConnectControl(NotOutput); // Zero mbOr.ConnectInput(muxNegOut.Output); not1.ConnectInput(mbOr.Output); Zero.Value = not1.Output.Value; // Negative notBit.Value = 1; negAnd.Input1.ConnectInput(notBit); negAnd.Input2.ConnectInput(muxNegOut.Output[muxNegOut.Size - 1]); // Output //Output = bwAnd.Output; Output = muxNegOut.Output; }