Class: Remian::Control
- Inherits:
-
Object
- Object
- Remian::Control
- Defined in:
- lib/remian/control.rb
Instance Attribute Summary collapse
-
#clock ⇒ Object
Returns the value of attribute clock.
-
#decoder ⇒ Object
Returns the value of attribute decoder.
-
#instruction_set ⇒ Object
Returns the value of attribute instruction_set.
-
#memory ⇒ Object
Returns the value of attribute memory.
-
#options ⇒ Object
Returns the value of attribute options.
-
#registers ⇒ Object
Returns the value of attribute registers.
Instance Method Summary collapse
-
#initialize(data, options = {}) ⇒ Control
constructor
A new instance of Control.
- #start(start_address = 1) ⇒ Object
Constructor Details
#initialize(data, options = {}) ⇒ Control
Returns a new instance of Control.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/remian/control.rb', line 20 def initialize data, = {} @options = option_defaults.merge @registers = {address: nil} @clock = Clock.new @options[:clock_speed] @decoder = Decoder.new @memory = Memory.new @options[:memory_size] @memory.write_data data @instruction_set = InstructionSet.new @memory, @registers end |
Instance Attribute Details
#clock ⇒ Object
Returns the value of attribute clock.
14 15 16 |
# File 'lib/remian/control.rb', line 14 def clock @clock end |
#decoder ⇒ Object
Returns the value of attribute decoder.
16 17 18 |
# File 'lib/remian/control.rb', line 16 def decoder @decoder end |
#instruction_set ⇒ Object
Returns the value of attribute instruction_set.
18 19 20 |
# File 'lib/remian/control.rb', line 18 def instruction_set @instruction_set end |
#memory ⇒ Object
Returns the value of attribute memory.
15 16 17 |
# File 'lib/remian/control.rb', line 15 def memory @memory end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/remian/control.rb', line 13 def @options end |
#registers ⇒ Object
Returns the value of attribute registers.
17 18 19 |
# File 'lib/remian/control.rb', line 17 def registers @registers end |
Instance Method Details
#start(start_address = 1) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/remian/control.rb', line 33 def start start_address = 1 @registers[:address] = start_address while @clock.tick_delay cycle end end |