title: why translate functions are seen in tlb.cc in gem5 for any architecture?
body: <p>Firstly, why a TLB code should have translate functions? Aren't they supposed to just index using the virtual address and give the corresponding matching physical address.</p>
  
  <p>Secondly, what does the names translateInt, finalizePhysical suggest about the happening in their codes.</p>
  
  <p>And finally, the intuition behind the parameters to the function req->setpaddr() for different cases, like multiplying with MiscReg as in the case when the prefix matches IntAddrPrefixMSR.</p>
  
  <pre><code>else if (prefix == IntAddrPrefixMSR) {
      vaddr = (vaddr &gt;&gt; 3) &amp; ~IntAddrPrefixMask;
      req-&gt;setFlags(Request::MMAPPED_IPR);
  
      MiscRegIndex regNum;
      if (!msrAddrToIndex(regNum, vaddr))
          return std::make_shared&lt;GeneralProtection&gt;(0);
  
      //The index is multiplied by the size of a MiscReg so that
      //any memory dependence calculations will not see these as
      //overlapping.
      req-&gt;setPaddr((Addr)regNum * sizeof(MiscReg));
      return NoFault;
  } else if (prefix == IntAddrPrefixIO) {
      // TODO If CPL &gt; IOPL or in virtual mode, check the I/O permission
      // bitmap in the TSS.
  
      Addr IOPort = vaddr &amp; ~IntAddrPrefixMask;
      // Make sure the address fits in the expected 16 bit IO address
      // space.
      assert(!(IOPort &amp; ~0xFFFF));
      if (IOPort == 0xCF8 &amp;&amp; req-&gt;getSize() == 4) {
          req-&gt;setFlags(Request::MMAPPED_IPR);
          req-&gt;setPaddr(MISCREG_PCI_CONFIG_ADDRESS * sizeof(MiscReg));
      } else if ((IOPort &amp; ~mask(2)) == 0xCFC) {
          req-&gt;setFlags(Request::UNCACHEABLE | Request::STRICT_ORDER);
          Addr configAddress =
              tc-&gt;readMiscRegNoEffect(MISCREG_PCI_CONFIG_ADDRESS);
          if (bits(configAddress, 31, 31)) {
              req-&gt;setPaddr(PhysAddrPrefixPciConfig |
                      mbits(configAddress, 30, 2) |
                      (IOPort &amp; mask(2)));
          } else {
              req-&gt;setPaddr(PhysAddrPrefixIO | IOPort);
          }
      } else {
          req-&gt;setFlags(Request::UNCACHEABLE | Request::STRICT_ORDER);
          req-&gt;setPaddr(PhysAddrPrefixIO | IOPort);
      }
      return NoFault;
  </code></pre>