Пример #1
0
        public void LeftShift()
        {
            var alu = new ALU();

            alu.StageValue(0, 1);
            alu.PerformAction(ALUCalculation.ShiftLeft, 1);

            Assert.AreEqual(2, alu.ReadResult());
        }
Пример #2
0
        public void Not()
        {
            var alu = new ALU();

            alu.StageValue(0, -1);
            alu.PerformAction(ALUCalculation.Not);

            Assert.AreEqual(0, alu.ReadResult());
        }
Пример #3
0
        public void Divide()
        {
            var alu = new ALU();

            alu.StageValue(0, 4);
            alu.StageValue(1, 2);
            alu.PerformAction(ALUCalculation.Divide);

            Assert.AreEqual(2, alu.ReadResult());
        }
Пример #4
0
        public void Multiply()
        {
            var alu = new ALU();

            alu.StageValue(0, 2);
            alu.StageValue(1, 3);
            alu.PerformAction(ALUCalculation.Multiply);

            Assert.AreEqual(6, alu.ReadResult());
        }
Пример #5
0
        public void Subtract()
        {
            var alu = new ALU();

            alu.StageValue(0, 2);
            alu.StageValue(1, 1);
            alu.PerformAction(ALUCalculation.Subtract);

            Assert.AreEqual(1, alu.ReadResult());
        }
Пример #6
0
        public void Add()
        {
            var alu = new ALU();

            alu.StageValue(0, 1);
            alu.StageValue(1, 1);
            alu.PerformAction(ALUCalculation.Add);

            Assert.AreEqual(2, alu.ReadResult());
        }
Пример #7
0
        public void RightShiftZeroFill()
        {
            var alu = new ALU();

            unchecked
            {
                alu.StageValue(0, (long)0x80_00_00_00_00_00_00_00);
                alu.PerformAction(ALUCalculation.ShiftRightZeroFill, 1);
            }

            Assert.AreEqual(0x40_00_00_00_00_00_00_00, alu.ReadResult());
        }