Overview

Namespaces

  • Csim
    • Controller
    • Model
    • Util
  • PHP

Classes

  • Cache
  • CacheCell
  • CacheLayout
  • Execution
  • Instruction
  • InstructionType
  • Set
  • SimulationState

Exceptions

  • InvalidInstructionException
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace Csim\Model;
 4: 
 5: /**
 6:  * Represents one set in a cache.
 7:  */
 8: class Set {
 9: 
10:     private $tag;
11:     private $layout;
12: 
13:     /**
14:      * Constructs a new Set with the specified layout. The newly constructed set is 
15:      * not mapped to any address.
16:      */
17:     public function __construct(\Csim\Model\CacheLayout $layout) {
18:         $this->layout = $layout;
19:         $this->size = $layout->getBlockCount() * $layout->getBlockSize();
20:         $this->tag_size = $layout->getTagBits();
21:     }
22: 
23:     /**
24:      * Loads the specified address.
25:      * 
26:      * @param integer $address The address that shall be loaded.
27:      * @return integer The index of the block with the newly loaded address.
28:      */
29:     public function loadAddress($address) {
30:         $this->tag = $address & $this->layout->getTagBitMask();
31:         $index = ($address & $this->layout->getIndexBitMask()) >> $this->layout->getOffsetBits();
32:         return $index;
33:     }
34: 
35:     /**
36:      * Returns the location of the specified address in this set if the set contains that address,
37:      * otherwise returns NULL.
38:      * 
39:      * @return \Csim\Model\CacheCell A CacheCell with set number equal to zero and index/offset set
40:      *                                to the cell where the searched address was found. Returns NULL
41:      *                                if the address was not found.
42:      */
43:     public function addressLocation(\Csim\Model\Instruction $instruction) {
44:         if ($instruction->addressEquals($this->tag, $this->layout->getTagBitMask())) {
45:             $index = ($this->layout->getIndexBitMask() & $instruction->getAddress()) >> 
46:                     $this->layout->getOffsetBits();
47:             $offset = $this->layout->getOffsetBitMask() & $instruction->getAddress();
48:             return new \Csim\Model\CacheCell(0, $index, $offset);
49:         } else {
50:             return NULL;
51:         }
52:     }
53: 
54: }
55: 
csim-jquery-nophpfw API documentation generated by ApiGen 2.8.0