Class: CacheSim::Slot
- Inherits:
-
Object
- Object
- CacheSim::Slot
- Defined in:
- cache_simulation.rb
Overview
This class creates the slots. Initialization:
slot = CacheSim::Slot.new(num, is_dirty, is_valid, tag, saved_blocks)
Instance Attribute Summary collapse
-
#is_dirty ⇒ Boolean
Returns whether a slot currently is dirty (has content not copied to main memory).
-
#is_valid ⇒ Boolean
Returns whether a slot currently has valid content or not.
-
#num ⇒ String
readonly
Gets the current slot number.
-
#saved_blocks ⇒ Array
Returns array of saved blocks.
-
#tag ⇒ String
Returns current hexadecimal tag in the slot.
Instance Method Summary collapse
-
#initialize(num, is_dirty, is_valid, tag, saved_blocks) ⇒ Slot
constructor
Initalizes new Slot object.
Constructor Details
#initialize(num, is_dirty, is_valid, tag, saved_blocks) ⇒ Slot
Note:
Generally you will want to initialize slots as empty. See the example.
Initalizes new Slot object
48 49 50 51 52 53 54 |
# File 'cache_simulation.rb', line 48 def initialize(num, is_dirty, is_valid, tag, saved_blocks) @num = num @is_dirty = is_dirty @is_valid = is_valid @tag = tag @saved_blocks = saved_blocks end |
Instance Attribute Details
#is_dirty ⇒ Boolean
Returns whether a slot currently is dirty (has content not copied to main memory)
29 30 31 |
# File 'cache_simulation.rb', line 29 def is_dirty @is_dirty end |
#is_valid ⇒ Boolean
Returns whether a slot currently has valid content or not
26 27 28 |
# File 'cache_simulation.rb', line 26 def is_valid @is_valid end |
#num ⇒ String (readonly)
Gets the current slot number
23 24 25 |
# File 'cache_simulation.rb', line 23 def num @num end |
#saved_blocks ⇒ Array
Returns array of saved blocks. Defaults to array of zeros if empty.
35 36 37 |
# File 'cache_simulation.rb', line 35 def saved_blocks @saved_blocks end |
#tag ⇒ String
Returns current hexadecimal tag in the slot
32 33 34 |
# File 'cache_simulation.rb', line 32 def tag @tag end |