コード例 #1
0
        public static bool[] ALU(bool[] x, bool[] y, bool zx, bool nx, bool zy, bool ny, bool f, bool no, out bool zr, out bool ng)
        {
            bool[] result = new bool[16];
            bool[] ground = new bool[16] {
                true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
            };

            //zx, nx
            x = BoolLogic.Mux16(x, (bool[])ground.Clone(), zx);
            x = BoolLogic.Mux16(x, BoolLogic.Not16(x), nx);

            //zy, ny
            y = BoolLogic.Mux16(y, (bool[])ground.Clone(), zy);
            x = BoolLogic.Mux16(y, BoolLogic.Not16(y), ny);

            bool[] temp1, temp2;

            temp1 = Add16(x, y);
            temp2 = BoolLogic.And16(x, y);

            // MUX에 의해 골라진 걸 result에 넣음
            result = BoolLogic.Mux16(temp1, temp2, f);
            BoolLogic.Mux16(result, BoolLogic.Not16(result), no);

            // out
            ng = result[15];
            zr = BoolLogic.Or16Way(result);
            return(result);
        }
コード例 #2
0
 static bool FullAdder_Carry(bool a, bool b, bool c)
 {
     return(BoolLogic.Or(HalfAdder_Carry(a, b), HalfAdder_Carry(HalfAdder_Sum(a, b), c)));
 }
コード例 #3
0
 public static void FullAdder(bool a, bool b, bool c, out bool sum, out bool carry)
 {
     carry = BoolLogic.Or(HalfAdder_Carry(a, b), HalfAdder_Carry(HalfAdder_Sum(a, b), c));
     sum   = HalfAdder_Sum(HalfAdder_Sum(a, b), c);
 }
コード例 #4
0
 static bool HalfAdder_Sum(bool a, bool b)
 {
     return(BoolLogic.Xor(a, b));
 }
コード例 #5
0
 static bool HalfAdder_Carry(bool a, bool b)
 {
     return(BoolLogic.And(a, b));
 }
コード例 #6
0
 public static void HalfAdder(bool a, bool b, out bool sum, out bool carry)
 {
     sum   = BoolLogic.Xor(a, b);
     carry = BoolLogic.And(a, b);
 }