class RPicSim::Storage::MemoryInteger
This class and its subclasses represent integers stored in RAM.
Attributes
address[R]
memory[W]
name[R]
Public Class Methods
new(name, address)
click to toggle source
Creates a new MemoryInteger
object not bound to any memory yet. @param name [Symbol] The name of the variable. @param address [Integer] should be the address of the variable
# File lib/rpicsim/storage/memory_integer.rb, line 11 def initialize(name, address) @name = name @address = address end
Public Instance Methods
addresses()
click to toggle source
@return [Range] The addresses of each byte that is part of this variable.
# File lib/rpicsim/storage/memory_integer.rb, line 25 def addresses address ... (address + size) end
bind(memory)
click to toggle source
Creates a new Variable
that is bound to the specified memory. @param memory [RPicSim::Memory]
# File lib/rpicsim/storage/memory_integer.rb, line 18 def bind(memory) bound_var = dup bound_var.memory = memory bound_var end
inspect()
click to toggle source
# File lib/rpicsim/storage/memory_integer.rb, line 53 def inspect '<%s %s 0x%x>' % [self.class, name, address] end
memory_value(val)
click to toggle source
# File lib/rpicsim/storage/memory_integer.rb, line 45 def memory_value(val) value end
memory_value=(val)
click to toggle source
# File lib/rpicsim/storage/memory_integer.rb, line 41 def memory_value=(val) self.value = val end
to_s()
click to toggle source
# File lib/rpicsim/storage/memory_integer.rb, line 49 def to_s name.to_s end
value()
click to toggle source
Reads the value of the variable from memory. @return [Integer]
# File lib/rpicsim/storage/memory_integer.rb, line 31 def value raise NoMethodError, 'value not implemented' end
value=(val)
click to toggle source
Writes to the value to the variable's memory. @return [Integer]
# File lib/rpicsim/storage/memory_integer.rb, line 37 def value=(val) raise NoMethodError, 'value= not implemented' end
Private Instance Methods
check_value(value, allowed_values)
click to toggle source
# File lib/rpicsim/storage/memory_integer.rb, line 59 def check_value(value, allowed_values) if !allowed_values.include?(value) raise ArgumentError, "Invalid value #{value} written to #{name}." end end