Class: CacheSim::MainMemory

Inherits:
Object
  • Object
show all
Defined in:
cache_simulation.rb

Overview

This is the class that creates the simulated main memory

Initialization:

main_memory = CacheSim::MainMemory.new(size)

After initialization, @content is the only thing that can be changed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ MainMemory

Note:

This function just creates dummy data in the cache. Currently it fills it with hexadecimal numbers.

Initializes new MainMemory object

Parameters:

  • size (Integer)

    reflects the total size of main memory array



293
294
295
296
# File 'cache_simulation.rb', line 293

def initialize(size)
  @size = size
  @content = initialize_content
end

Instance Attribute Details

#contentArray

Returns the content of the cache

Returns:

  • (Array)

    array of strings representing current data in the cache



287
288
289
# File 'cache_simulation.rb', line 287

def content
  @content
end