Beispiel #1
0
        public void TLBTest_All_Valid()
        {
            const int ENTRIES = 512;

            TLB TLB = new TLB();

            //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) << 54;         //4 bit protection
                ulong valid = ((ulong)0x1) << 53;        //1 Valid Bit
                ulong tag = (((ulong)(i & 0x01FFFFFFF)) << 24);   //29 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)(0x03F & (i % TLB.ENTRIES)) << 41) |     //7 bit page index
                    ((ulong)(0x01FFFFFFF & i) << 12) |       //29 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 = TLBEntryParser.getPhyicalAddressFromPageTableEntry(Curr_Entry);

                TLB.setEntry_LRU(Curr_Addr, Curr_Entry);
                Result = TLB.searchBanks(Curr_Addr);
                Assert.AreEqual(Expected_Result, Result);
            }
        }
        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;
        }