Module: RPicSim::Sim::ClassDefinitionMethods
- Included in:
- RPicSim::Sim
- Defined in:
- lib/rpicsim/sim.rb
Overview
These methods should be called while defining a subclass of RPicSim::Sim.
Instance Method Summary collapse
-
#def_pin(our_name, datasheet_name) ⇒ Object
Define a pin alias.
-
#def_symbol(name, address, memory_type = nil) ⇒ Object
Define a symbol.
-
#def_var(name, type, opts = {}) ⇒ Object
Define a variable.
-
#import_symbols(symbol_source) ⇒ Object
Specifies additional symbols to use in the simulation.
-
#use_device(device) ⇒ Object
Specifies what exact device the firmware runs on.
-
#use_file(filename) ⇒ Object
Specifies the path to the firmware file.
Instance Method Details
#def_pin(our_name, datasheet_name) ⇒ Object
Define a pin alias.
72 73 74 75 76 77 |
# File 'lib/rpicsim/sim.rb', line 72 def def_pin(our_name, datasheet_name) our_name = our_name.to_sym @pin_aliases[our_name] = datasheet_name.to_sym self::Shortcuts.send(:define_method, our_name) { pin our_name } end |
#def_symbol(name, address, memory_type = nil) ⇒ Object
Define a symbol. Normally symbols are loaded by #use_file or #import_symbols, but this method allows for adding additional symbols one at a time.
See ProgramFile#def_symbol for details about the parameters this method takes.
61 62 63 |
# File 'lib/rpicsim/sim.rb', line 61 def def_symbol(name, address, memory_type = nil) program_file.def_symbol name, address, memory_type end |
#def_var(name, type, opts = {}) ⇒ Object
Define a variable.
98 99 100 101 102 103 104 105 106 |
# File 'lib/rpicsim/sim.rb', line 98 def def_var(name, type, opts = {}) if @variable_set.nil? raise 'The device and filename need to be specified before defining variables.' end @variable_set.def_var(name, type, opts) self::Shortcuts.send(:define_method, name) { var name } end |
#import_symbols(symbol_source) ⇒ Object
Specifies additional symbols to use in the simulation. Symbols might be loaded from the program file when you call #use_file, but if those symbols are not sufficient then you can call this method to incorporate another source of symbols.
See ProgramFile#import_symbols for details on what the parameter should be.
51 52 53 |
# File 'lib/rpicsim/sim.rb', line 51 def import_symbols(symbol_source) program_file.import_symbols(symbol_source) end |
#use_device(device) ⇒ Object
Specifies what exact device the firmware runs on.
29 30 31 32 |
# File 'lib/rpicsim/sim.rb', line 29 def use_device(device) @device = device @assembly = Mplab::MplabAssembly.new(device) end |
#use_file(filename) ⇒ Object
Specifies the path to the firmware file. The file can be a HEX or COF file, but COF is recommended so that you can access symbol/label addresses and other debugging information. You must call #use_device before calling this.
38 39 40 41 42 |
# File 'lib/rpicsim/sim.rb', line 38 def use_file(filename) raise "The device needs to be specified before filename (e.g. 'use_device \"PIC10F322\"')" unless @device @filename = filename.to_s load_program_file end |