예제 #1
0
            public void WriteBack(ushort pageIndex, ushort frameIndex)
            {
                TlbEntry newEntry = new TlbEntry(pageIndex, frameIndex);

                //look for an empty entry
                for (int i = 0; i < EntriesPerTLB; i++)
                {
                    if (_entries[i].PageIndex == null)
                    {
                        _entries[i] = newEntry;
                        return;
                    }
                }

                //swap a resident entry with a biggest counter
                int maxValue = 0, maxIndex = 0;

                for (int i = 0; i < EntriesPerTLB; i++)
                {
                    if (_entries[i].Counter > maxValue)
                    {
                        maxValue = _entries[i].Counter;
                        maxIndex = i;
                    }
                }
                _entries[maxIndex] = newEntry;
            }
예제 #2
0
 public TLB()
 {
     for (int i = 0; i < 16; i++)
     {
         _entries[i] = new TlbEntry();
     }
 }
예제 #3
0
        internal static (int index, TlbEntry entry) CreateTlbEntry(uint virtualAddress,
                                                                   uint physicalAddress, bool rw = true, bool supervisor = false)
        {
            var entry = physicalAddress & 0xFFFFFC00;

            entry |= rw ? PageTableFlags.Rw : 0;
            entry |= supervisor ? PageTableFlags.Supervisor : 0;
            var tag      = TlbEntry.TagFromAddress(virtualAddress);
            var tlbEntry = new TlbEntry
            {
                entry = entry,
                tag   = tag,
            };
            var index = TlbEntry.IndexFromTag(tag);

            return(index, tlbEntry);
        }