rpicsim 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffc22a3d36cfe7fe55d2bd971e0e01410e639dcc
4
- data.tar.gz: a8589f0756b0cb3fd7fbd9af22727945318414e3
3
+ metadata.gz: d1626d315076308dfcdf30160e32e355689ac8b3
4
+ data.tar.gz: 07b107ae6c4aa4c34cdd8b5b684c5b242f3f361c
5
5
  SHA512:
6
- metadata.gz: 9d5209c814cf043635c779466ba9687246228644a368f6d7bea5d53d4a5944b8f7dbe04f83ee548db9c77b3ec3d1151323350146bf6639105bd6c992a7656195
7
- data.tar.gz: c106a56ba5c1ac8932b0563d91f9d38eb03bc3fcfc29349ab90fadc02ffdfd0c837a9ab0e27c59c57a95ef22b01996a598feb6abdc3b0d9eefc5158426db2388
6
+ metadata.gz: 3bc9bf16d3737047d0995df8bf144cbd067d80c7e174c8d919ffe22cc3a6eea5b23d1f23cc89121b85a74f1a2461673325d84026944bfc568859bf9123bae171
7
+ data.tar.gz: 48e61eb950d62b15321f11c7cfe9c79ccb78951bf1d4b47b684451ea8cf3139ba8ecf70283eec8d386d8667e71213d8c95a7773263d7539690e99555a61d4cbc
@@ -49,7 +49,7 @@ RPicSim is distributed as a Ruby gem named `rpicsim`. To install RPicSim, run:
49
49
  jgem install rpicsim
50
50
 
51
51
 
52
- RPicSim has been tested with MPLAB X v1.85, v1.90, v1.95, v2.00, v2.05, v2.10, v2.15, and v2.20.
52
+ RPicSim has been tested with MPLAB X v1.85, v1.90, v1.95, v2.00, v2.05, v2.10, v2.15, v2.20, v3.05, and v3.10.
53
53
  However, it uses a lot of undocumented and internal features of the Microchip Java libraries, so it will probably need to be updated as new versions of MPLAB X are released.
54
54
 
55
55
  RPicSim is not intended to replace formal specifications, code reviews, and rigorous testing of your firmware on actual hardware.
data/README.md CHANGED
@@ -51,7 +51,7 @@ RPicSim is distributed as a Ruby gem named `rpicsim`. To install RPicSim, run:
51
51
  jgem install rpicsim
52
52
 
53
53
 
54
- RPicSim has been tested with MPLAB X v1.85, v1.90, v1.95, v2.00, v2.05, v2.10, v2.15, and v2.20.
54
+ RPicSim has been tested with MPLAB X v1.85, v1.90, v1.95, v2.00, v2.05, v2.10, v2.15, v2.20, v3.05, and v3.10.
55
55
  However, it uses a lot of undocumented and internal features of the Microchip Java libraries, so it will probably need to be updated as new versions of MPLAB X are released.
56
56
 
57
57
  RPicSim is not intended to replace formal specifications, code reviews, and rigorous testing of your firmware on actual hardware.
@@ -1,11 +1,18 @@
1
1
  Change log
2
2
  ====
3
3
 
4
+ 1.1.1
5
+ ----
6
+ Released on 2019-04-17.
7
+
8
+ - Fixes a bug in the code that reads signed 32-bit integers.
9
+ - Allows variables defined with {RPicSim::Sim#def_var} to overlap.
10
+
4
11
  1.1.0
5
12
  ----
6
13
  Released on 2015-07-27.
7
14
 
8
- - Added support for MPLAB X v3.05.
15
+ - Added support for MPLAB X v3.05. This version also works with MPLAB X v3.10, which was released later.
9
16
 
10
17
  1.0.0
11
18
  ----
@@ -1,85 +1,85 @@
1
- Defining your simulation class
2
- ====
3
-
4
- In order to run a simulation of your firmware using RPicSim, you must make a new subclass of {RPicSim::Sim}. This class is called your _simulation class_. Below is an example:
5
-
6
- class MySim < RPicSim::Sim
7
- use_device "PIC10F322"
8
- use_file File.dirname(__FILE__) + "../firmware/dist/firmware.cof"
9
- end
10
-
11
- A full list of the special RPicSim methods you can call inside your class definition can be found by looking at the documentation for {RPicSim::Sim::ClassDefinitionMethods}.
12
-
13
- Required properties
14
- ----
15
-
16
- There are two things you must do inside a simulation class.
17
-
18
- First, call {RPicSim::Sim::ClassDefinitionMethods#use_device use_device} in order to specify the PIC device your firmware runs on. Unfortunately, RPicSim cannot just detect this information from your COF file. The argument to `use_device` should be a simple string containing the official name of the PIC device, like "PIC10F322".
19
-
20
- Second, call {RPicSim::Sim::ClassDefinitionMethods#use_file use_file} to specify the path to your COF or HEX file. This must be done after calling `use_device`.
21
- In the example, we start with `File.dirname(__FILE__)`, which is the name of the directory that the current Ruby file is in, and add a string to that.
22
- This allows us to move our tests and firmware files around on the disk without changing the `use_file` line.
23
-
24
- Pins
25
- ----
26
-
27
- You can use {RPicSim::Sim::ClassDefinitionMethods#def_pin def_pin} in your simulation class to define an alternative name for a pin. For more information, see {file:Pins.md}.
28
-
29
-
30
- Variables
31
- ----
32
-
33
- You can use {RPicSim::Sim::ClassDefinitionMethods#def_var def_var} in your simulation class to define a variable in RAM, program memory, or EEPROM.
34
- For more information, see {file:Variables.md}.
35
-
36
-
37
- Methods
38
- ----
39
-
40
- It is sometimes helpful to define your own methods in the simulation class. For example, here are some methods that help us simulate the effect of the user placing a jumper between RA1 and GND:
41
-
42
- class MySim < RPicSim::Sim
43
- use_device "PIC10F322"
44
- use_file File.dirname(__FILE__) + "../firmware/dist/firmware.cof"
45
-
46
- def jumper_on
47
- pin(:RA1).set false
48
- end
49
-
50
- def jumper_off
51
- pin(:RA1).set true
52
- end
53
- end
54
-
55
- By making these `jumper_on` and `jumper_off` methods, we can write lots of tests that manipulate the jumper but we don't have to constantly worry about how the hardware jumper is implemented when writing or reading those tests.
56
- This makes our tests easier to read and change.
57
-
58
- If you have an instance of the simulation class, you can call such a method in the usual way:
59
-
60
- sim.jumper_on
61
-
62
-
63
- Using the simulation class
64
- ----
65
-
66
- To start a new simulation, you can simply make a new instance of the simulation class. For example:
67
-
68
- sim = MySim.new
69
-
70
- However, if you are using RSpec and RPicSim's {file:RSpecIntegration.md RSpec Integration}, then you should not create a new instance yourself.
71
- Instead, make a before hook that calls {RPicSim::RSpec::Helpers#start_sim start_sim}.
72
- This will start the simulation for you and use it to make some other methods and features available in your examples.
73
- After running {RPicSim::RSpec::Helpers#start_sim start_sim}, you will be able to access your simulation object using the method `sim`.
74
-
75
- For example:
76
-
77
- describe "my firmware" do
78
- before do
79
- start_sim MySim
80
- end
81
-
82
- it "runs to the :abc label" do
83
- sim.run_to :abc, cycle_limit: 100
84
- end
85
- end
1
+ Defining your simulation class
2
+ ====
3
+
4
+ In order to run a simulation of your firmware using RPicSim, you must make a new subclass of {RPicSim::Sim}. This class is called your _simulation class_. Below is an example:
5
+
6
+ class MySim < RPicSim::Sim
7
+ use_device "PIC10F322"
8
+ use_file File.dirname(__FILE__) + "../firmware/dist/firmware.cof"
9
+ end
10
+
11
+ A full list of the special RPicSim methods you can call inside your class definition can be found by looking at the documentation for {RPicSim::Sim::ClassDefinitionMethods}.
12
+
13
+ Required properties
14
+ ----
15
+
16
+ There are two things you must do inside a simulation class.
17
+
18
+ First, call {RPicSim::Sim::ClassDefinitionMethods#use_device use_device} in order to specify the PIC device your firmware runs on. Unfortunately, RPicSim cannot just detect this information from your COF file. The argument to `use_device` should be a simple string containing the official name of the PIC device, like "PIC10F322".
19
+
20
+ Second, call {RPicSim::Sim::ClassDefinitionMethods#use_file use_file} to specify the path to your COF or HEX file. This must be done after calling `use_device`.
21
+ In the example, we start with `File.dirname(__FILE__)`, which is the name of the directory that the current Ruby file is in, and add a string to that.
22
+ This allows us to move our tests and firmware files around on the disk without changing the `use_file` line.
23
+
24
+ Pins
25
+ ----
26
+
27
+ You can use {RPicSim::Sim::ClassDefinitionMethods#def_pin def_pin} in your simulation class to define an alternative name for a pin. For more information, see {file:Pins.md}.
28
+
29
+
30
+ Variables
31
+ ----
32
+
33
+ You can use {RPicSim::Sim::ClassDefinitionMethods#def_var def_var} in your simulation class to define a variable in RAM, program memory, or EEPROM.
34
+ For more information, see {file:Variables.md}.
35
+
36
+
37
+ Methods
38
+ ----
39
+
40
+ It is sometimes helpful to define your own methods in the simulation class. For example, here are some methods that help us simulate the effect of the user placing a jumper between RA1 and GND:
41
+
42
+ class MySim < RPicSim::Sim
43
+ use_device "PIC10F322"
44
+ use_file File.dirname(__FILE__) + "../firmware/dist/firmware.cof"
45
+
46
+ def jumper_on
47
+ pin(:RA1).set false
48
+ end
49
+
50
+ def jumper_off
51
+ pin(:RA1).set true
52
+ end
53
+ end
54
+
55
+ By making these `jumper_on` and `jumper_off` methods, we can write lots of tests that manipulate the jumper but we don't have to constantly worry about how the hardware jumper is implemented when writing or reading those tests.
56
+ This makes our tests easier to read and change.
57
+
58
+ If you have an instance of the simulation class, you can call such a method in the usual way:
59
+
60
+ sim.jumper_on
61
+
62
+
63
+ Using the simulation class
64
+ ----
65
+
66
+ To start a new simulation, you can simply make a new instance of the simulation class. For example:
67
+
68
+ sim = MySim.new
69
+
70
+ However, if you are using RSpec and RPicSim's {file:RSpecIntegration.md RSpec Integration}, then you should not create a new instance yourself.
71
+ Instead, make a before hook that calls {RPicSim::RSpec::Helpers#start_sim start_sim}.
72
+ This will set up the simulation for you and use it to make some other methods and features available in your RSpec examples.
73
+ After running {RPicSim::RSpec::Helpers#start_sim start_sim}, you will be able to access your simulation object using the method `sim`.
74
+
75
+ For example:
76
+
77
+ describe "my firmware" do
78
+ before do
79
+ start_sim MySim
80
+ end
81
+
82
+ it "runs to the :abc label" do
83
+ sim.run_to :abc, cycle_limit: 100
84
+ end
85
+ end
@@ -213,7 +213,7 @@ These issues might affect other PIC architectures as well.
213
213
  * **No intermediate values:** In MPLAB X 1.85, setting a pin to any voltage other than 0 V will result in an ADC reading of 255.
214
214
 
215
215
  These issues are tested in `spec/integration/adc_midrange_spec.rb`. The bad modulus issue was {http://www.microchip.com/forums/m760886.aspx reported to Microchip} in November 2013.
216
- The midrange ADC seems to work correctly in MPLAB X 3.05.
216
+ The midrange ADC seems to work correctly in MPLAB X v3.05 and later.
217
217
 
218
218
 
219
219
  Variables from XC8 are not correctly identified
@@ -1,5 +1,5 @@
1
1
  # Supported compilers
2
2
 
3
- RPicSim supports any compiler that can generate a standard Microchip COF file that is recognized by the COF-loading code in MPLAB X. If your compiler does not generate such a file, then you could use an Intel HEX file instead, but then RPicSim will not automatically have access to your firmware's symbol table, so it will not know where variables, functions, and labels are located.
3
+ RPicSim supports any compiler that can generate a standard Microchip COF or ELF file that is recognized by the file loading code in MPLAB X. If your compiler does not generate such a file, then you could use an Intel HEX file instead, but then RPicSim will not automatically have access to your firmware's symbol table, so it will not know where variables, functions, and labels are located.
4
4
 
5
- RPicSim has been extensively tested with COF files produced by MPASM. At the time of this writing, it has not been tested with XC8 or C18.
5
+ RPicSim has been extensively tested with COF files produced by MPASM, and the ELF files produced by XC8. It also has support for reading symbols from the SYM file produced by XC8. At the time of this writing, it has not been tested with C18.
@@ -202,10 +202,11 @@ module RPicSim::Storage
202
202
  end
203
203
 
204
204
  def value
205
- val = @memory.read_byte(@address) + 0x100 * @memory.read_byte(@address + 1) +
205
+ val =
206
+ @memory.read_byte(@address) +
207
+ 0x100 * @memory.read_byte(@address + 1) +
206
208
  0x10000 * @memory.read_byte(@address + 2) +
207
- 0x1000000 * @memory.read_byte(@address + 3) +
208
- 0x100000000 * @memory.read_byte(@address + 4)
209
+ 0x1000000 * @memory.read_byte(@address + 3)
209
210
  val -= 0x100000000 if val >= 0x80000000
210
211
  val
211
212
  end
@@ -12,7 +12,6 @@ module RPicSim
12
12
  @memory_types = []
13
13
  @symbols_for_memory = {}
14
14
  @vars_for_memory = {}
15
- @vars_for_memory_by_address = {}
16
15
  end
17
16
 
18
17
  def def_memory_type(name, symbols)
@@ -20,7 +19,6 @@ module RPicSim
20
19
  @memory_types << name
21
20
  @symbols_for_memory[name] = symbols
22
21
  @vars_for_memory[name] = {}
23
- @vars_for_memory_by_address[name] = {}
24
22
  end
25
23
 
26
24
  def def_var(name, type, opts = {})
@@ -70,15 +68,6 @@ module RPicSim
70
68
  variable.size = @address_increment
71
69
  end
72
70
 
73
- vars_by_address = @vars_for_memory_by_address[memory_type]
74
- variable.addresses.each do |occupied_address|
75
- if vars_by_address[occupied_address]
76
- raise 'Variable %s overlaps with %s at 0x%x' %
77
- [variable, vars_by_address[occupied_address], occupied_address]
78
- end
79
- vars_by_address[occupied_address] = variable
80
- end
81
-
82
71
  @vars_for_memory[memory_type][name] = variable
83
72
  end
84
73
 
@@ -2,5 +2,5 @@
2
2
  module RPicSim
3
3
  # The version number of this gem, as a string.
4
4
  # @return [String]
5
- VERSION = '1.1.0'
5
+ VERSION = '1.1.1'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpicsim
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pololu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-27 00:00:00.000000000 Z
11
+ date: 2019-04-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -108,9 +108,8 @@ requirements:
108
108
  - JRuby
109
109
  - MPLAB X
110
110
  rubyforge_project:
111
- rubygems_version: 2.4.8
111
+ rubygems_version: 2.6.8
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: RPicSim provides an interface to the MPLAB X PIC simulator that allows you to write simulator-based automated tests of PIC firmware with Ruby and RSpec.
115
115
  test_files: []
116
- has_rdoc: