示例#1
0
        public void TestMethod2()
        {
            // test add
            RegisterFile <int> iRF = new RegisterFile <int>(16);
            Memory             m   = new Memory(5000);
            addi a = new addi(0, 1, 15);

            a.Process(iRF, m);
            Assert.AreEqual <int>(15, iRF[0]);
        }
示例#2
0
        public void TestMethod7()
        {
            // test bnz (take branch)
            RegisterFile <int> iRF = new RegisterFile <int>(16);
            Memory             m   = new Memory(5000);
            addi a = new addi(2, 0, 1);
            bnz  b = new bnz(2, 10);

            a.Process(iRF, m);
            b.Process(iRF, m);
            Assert.AreEqual <int>(10, iRF[15]);
        }
示例#3
0
        public void TestMethod4()
        {
            // test mul
            RegisterFile <int> iRF = new RegisterFile <int>(16);
            Memory             m   = new Memory(5000);
            addi a  = new addi(0, 1, 2);
            muli mu = new muli(0, 0, 2);

            a.Process(iRF, m);
            mu.Process(iRF, m);
            Assert.AreEqual <int>(4, iRF[0]);
        }
示例#4
0
        public void TestMethod13()
        {
            // test ble (don't take branch with rd > 0)
            RegisterFile <int> iRF = new RegisterFile <int>(16);
            Memory             m   = new Memory(5000);
            addi a = new addi(2, 0, 1);
            ble  b = new ble(2, 10);

            a.Process(iRF, m);
            b.Process(iRF, m);
            Assert.AreEqual <int>(0, iRF[15]);
        }
示例#5
0
        public void TestMethod16()
        {
            // test st
            RegisterFile <int> iRF = new RegisterFile <int>(16);
            Memory             m   = new Memory(5000);

            addi a = new addi(0, 1, 1);
            addi b = new addi(1, 1, 1);
            st   s = new st(0, 1, 1);
            ld   l = new ld(0, 1, 1);

            a.Process(iRF, m);
            b.Process(iRF, m);
            s.Process(iRF, m);
            l.Process(iRF, m);

            Assert.AreEqual(1, iRF[0]);
        }