Class: RPicSim::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/rpicsim/variable.rb

Overview

Instances of this class represents a variable in the memory of the simulated microcontroller. This class provides methods for reading, writing, and getting address of the variable.

Instance Method Summary collapse

Instance Method Details

#addressInteger

The main (lowest) address of this variable.

Returns:

  • (Integer)


54
55
56
# File 'lib/rpicsim/variable.rb', line 54

def address
  @storage.address
end

#addressesArray(Integer)

The addresses in memory occupied by this variable.

Returns:

  • (Array(Integer))


48
49
50
# File 'lib/rpicsim/variable.rb', line 48

def addresses
  @storage.addresses
end

#memory_valueObject

Reads the value directly from the memory object backing the register. For some types of variables, this is the same as #value.



37
38
39
# File 'lib/rpicsim/variable.rb', line 37

def memory_value
  @storage.memory_value
end

#memory_value=(val) ⇒ Object

Writes the value to the variable in a lower-level way that overrides any read-only bits. For some types of variables, this is the same as #value=.



31
32
33
# File 'lib/rpicsim/variable.rb', line 31

def memory_value=(val)
  @storage.memory_value = val
end

#nameSymbol

The name of the variable.

Returns:

  • (Symbol)


60
61
62
# File 'lib/rpicsim/variable.rb', line 60

def name
  @storage.name
end

#to_sString

Returns:

  • (String)


42
43
44
# File 'lib/rpicsim/variable.rb', line 42

def to_s
  @storage.to_s
end

#valueInteger

Reads the value of the variable.

Returns:

  • (Integer)


18
19
20
# File 'lib/rpicsim/variable.rb', line 18

def value
  @storage.value
end

#value=(val) ⇒ Integer

Writes the value to the variable.

Returns:

  • (Integer)


24
25
26
# File 'lib/rpicsim/variable.rb', line 24

def value=(val)
  @storage.value = val
end