Example #1
0
        public void iTLBTest_All_Valid()
        {
            const int ENTRIES = 256;

            iTLB TLB = new iTLB();

            //Test Vars
            ulong Curr_Entry;
            ulong Curr_Addr;
            ulong Result;
            ulong Expected_Result;

            //PTE Contains
            //4 Unused Bits
            //4 bit protection
            //1 Valid Bit
            //31 bit page address tag
            //24 bit physical addr
            ulong[] Entries = new ulong[ENTRIES];
            for (int i = 0; i < ENTRIES; i++)
            {
                ulong unused = 0x0;             //4 Unused Bits
                ulong prot = ((ulong)0xF) << 56;         //4 bit protection
                ulong valid = ((ulong)0x1) << 55;        //1 Valid Bit
                ulong tag = (((ulong)(i & 0x07FFFFFFF)) << 24);   //31 bit page address tag
                ulong phys_addr = 0xFFFFFF;    //24 bit physical addr

                Entries[i] = unused | prot | valid | tag | phys_addr;

            }
            //Virtual Address Contains
            //5 bit page index
            //31 bit page address tag
            //12 bit page offset
            ulong[] Virtual_Addrs = new ulong[ENTRIES];
            for (int i = 0; i < ENTRIES; i++)
            {
                Virtual_Addrs[i] =
                    ((ulong)(0x001F & (i % iTLB.ENTRIES)) << 43) |       //5 bit page index (leading bit of 0)
                    ((ulong)(0x07FFFFFFF & i) << 12) |       //31 bit page address tag
                    (0x0FFF);                                //12 bit page offset

            }

            for (int i = 0; i < ENTRIES; i++)
            {
                Curr_Entry = Entries[i];
                Curr_Addr = Virtual_Addrs[i];
                Expected_Result = id_TLBParser.getPhyicalAddressFromPageTableEntry(Curr_Entry);

                TLB.setEntry_LRU(Curr_Addr, Curr_Entry);
                Result = TLB.searchBanks(Curr_Addr);
                Assert.AreEqual(Expected_Result, Result);
            }
        }
Example #2
0
        public static ulong SearchiTLB(VirtualPageTable vpt, iTLB itlb, TLB tlb, ulong virtualAddress)
        {
            ulong result = itlb.searchBanks(virtualAddress);
            ulong generatedVirtualAndPhysicalAddressPair;

            if (result == Constants.NOT_FOUND)
            {
                //itlb miss
                result = tlb.searchBanks(virtualAddress);

                if (result != Constants.NOT_FOUND)
                {
                    //copy to itlb using LRU
                    return result;
                }
                else
                {

                    //signal tlb miss

                    generatedVirtualAndPhysicalAddressPair = AddressGenerator.GeneratorSixtyBitVirtualPhysicalPair();
                    result = vpt.search(generatedVirtualAndPhysicalAddressPair);

                    if (false)//result == Constants.PAGE_FAULT)
                    {
                        //signal page fault
                        //copy page from disk
                    }
                }
            }
            else
            {

            }
            return 0;
        }