More GEAR - Improved Emulation of the Propeller
mirror
Posts: 322
What is GEAR? GEAR is a C# program that simulates the inner workings of the Propeller chip.
Who wrote GEAR? The original version of GEAR was written by asterick, and his version and notes can be found here: (especially the first posting!)
http://forums.parallax.com/showthread.php?p=624986
So why this version? asterick has not been seen on this forum for quite some time. In the meantime, I've made several enhancements to GEAR which are presented here.
On 26 October 2009 - V09_10_26
* Many thanks to Bob Anderson for identifying bugs in and subsequently testing improvements to the emulation of SUBS, SUBSX, CMPSX and REV.
On 5 June 2009 - V09_06_05 (140)
* Many thanks to Ben Levitt for improving the behaviour of GEAR. (Reload Binary, Open to PlugIn, Close PlugIn)
* Improvements in SerialIO plugin (Ben Levitt).
On 11 May 2009 - V09_05_12 (50)
* Fixed memory references of the form LONG[noparse][[/noparse] &MyVar ][noparse][[/noparse] 2 ], this case was being emulated as LONG[noparse][[/noparse] 2 ][noparse][[/noparse] &MyVar ].
* Included SerialIO plugin (with thanks to Ben Levitt) in the distribution.
On 16 October 2008 - V08_10_16 (151)
* An extra function has been added which allows hot keys to be disabled for a plugin. Simply add the following function to your plugin:
public override Boolean AllowHotKeys { get { return false; } }
On 29 April 2008 - V08 04 29 (159)
* The lastest stimulus.zip is now included in V08_04_29.zip.
* 'R' and 'S' keys can now be used to run, stop and step the currently active cog.
* Floating the cursor over an assembly cog page shows the values stored at the source and destination registers for the instruction line that's under the mouse. The values are shown as both hex and decimal.
On 23 January 2008
* Updated stimulus.zip. Still works with V08_01_18 of GEAR.
* The stimulus plug-in page has a context menu which allows a new stimulus file to be loaded and the current one to be saved.
* Editing of the stimulus file is allowed - previously it was read-only.
* As part of the stimulus file, it is now possible to include the words reset and stop.
reset - simulates a reset of the processor.
stop - causes a breakpoint - click Run to go to the next stop / breakpoint
How's this for something you haven't been able to do til now!!
On 21 January 2008
* Added stimulus.zip which updates stimulus.xml and the example stimulus file. It is now possible to do clock and pwm generation. You need the V08_01_18 version of GEAR, but if you already have that then all you need is the stimulus.zip file.
V08_01_18 (140)
* Pin toggling by means of a stimulus file. The other proposed functions (clock and simulated serial) may be written as part of stimulus.xml, but several changes were required in GEAR to make it all work.
V08_01_13 (86)
* Better disassembly of PASM
* Some fixes in assembly language emulation
* An alternative / short instruction set for the spin bytecodes (the original is still available)
* The ability to display numbers as hex or decimal
* The ability to add a single breakpoint (just click on a line of code).
* Improved simulation of the timing from the output pins
Post Edited (mirror) : 10/26/2009 3:50:59 AM GMT
Who wrote GEAR? The original version of GEAR was written by asterick, and his version and notes can be found here: (especially the first posting!)
http://forums.parallax.com/showthread.php?p=624986
So why this version? asterick has not been seen on this forum for quite some time. In the meantime, I've made several enhancements to GEAR which are presented here.
On 26 October 2009 - V09_10_26
* Many thanks to Bob Anderson for identifying bugs in and subsequently testing improvements to the emulation of SUBS, SUBSX, CMPSX and REV.
On 5 June 2009 - V09_06_05 (140)
* Many thanks to Ben Levitt for improving the behaviour of GEAR. (Reload Binary, Open to PlugIn, Close PlugIn)
* Improvements in SerialIO plugin (Ben Levitt).
On 11 May 2009 - V09_05_12 (50)
* Fixed memory references of the form LONG[noparse][[/noparse] &MyVar ][noparse][[/noparse] 2 ], this case was being emulated as LONG[noparse][[/noparse] 2 ][noparse][[/noparse] &MyVar ].
* Included SerialIO plugin (with thanks to Ben Levitt) in the distribution.
On 16 October 2008 - V08_10_16 (151)
* An extra function has been added which allows hot keys to be disabled for a plugin. Simply add the following function to your plugin:
public override Boolean AllowHotKeys { get { return false; } }
On 29 April 2008 - V08 04 29 (159)
* The lastest stimulus.zip is now included in V08_04_29.zip.
* 'R' and 'S' keys can now be used to run, stop and step the currently active cog.
* Floating the cursor over an assembly cog page shows the values stored at the source and destination registers for the instruction line that's under the mouse. The values are shown as both hex and decimal.
On 23 January 2008
* Updated stimulus.zip. Still works with V08_01_18 of GEAR.
* The stimulus plug-in page has a context menu which allows a new stimulus file to be loaded and the current one to be saved.
* Editing of the stimulus file is allowed - previously it was read-only.
* As part of the stimulus file, it is now possible to include the words reset and stop.
reset - simulates a reset of the processor.
stop - causes a breakpoint - click Run to go to the next stop / breakpoint
How's this for something you haven't been able to do til now!!
! Stimulus File breakpoint example ! (diagnosing the first microseconds of life) 10u stop +10u stop +10u stop +10u stop +10u stop +10u reset
On 21 January 2008
* Added stimulus.zip which updates stimulus.xml and the example stimulus file. It is now possible to do clock and pwm generation. You need the V08_01_18 version of GEAR, but if you already have that then all you need is the stimulus.zip file.
V08_01_18 (140)
* Pin toggling by means of a stimulus file. The other proposed functions (clock and simulated serial) may be written as part of stimulus.xml, but several changes were required in GEAR to make it all work.
V08_01_13 (86)
* Better disassembly of PASM
* Some fixes in assembly language emulation
* An alternative / short instruction set for the spin bytecodes (the original is still available)
* The ability to display numbers as hex or decimal
* The ability to add a single breakpoint (just click on a line of code).
* Improved simulation of the timing from the output pins
Post Edited (mirror) : 10/26/2009 3:50:59 AM GMT
zip
133K
Comments
Thanks for the effort.
Steven
The breakpoint significantly improves the usefulness of Gear.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Gear is very fine program.
But if it have TGB input emulation it have more power.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
Sapieha
But, do you realise that add in's can be written for GEAR. A number of example plugins were written by asterick. Personally, I've never used the plugins.
I generally·use·GEAR to simulate small subsets of code, not the entire application. It's great for nutting out concepts - eg. watching a block of memory (like a circular buffer) as you step through code.
Are you planning on taking-over development?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
I don't mind taking over development, but don't have as much free time as some of the other more prolific programmers on this forum. Part of the challange is that I do most of my PC development using Delphi, so I find working with the C# GUI components to be a bit handicapped in comparison.
Having said all that, what's the current wishlist?
·
I'd really like:
a) 'serial' connection to PC (i.e. being able to have GEAR run simple_serial et al, and have the output appear in (say) Hyperterminal)
b) ability to toggle 'switches' on pins
c) ability for GEAR to read a text (CSV?) file that describes pin values over time
d) I2C emulation - again reading from a text file
Not much to ask really LOL!
Seriously though, just knowing that it's not a frozen product is good news - many thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
Comments welcome.
Wow - you're on the ball!
Re: your scheme:
1. If you supply (say) '1m clk=2...' after you've already supplied '+10u...', does that mean 1m from start, or 1m after the 10u start (I think the former)?
2. Would it be more efficient to just supply pin data as a 32bit binary string?
Looks like a good start though - thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
To demonstrate:
1) Load a binary file into GEAR, something generated from the following will work fine:
2) Open the stimulus.xml plug-in from the tool bar, and open the test.stm file.
3) Open the Logic Probe.
3) Click Run.
4) Wait for the action to be displayed on the Logic Probe.
5) Press Reset and watch it all again - there's no need to stop or step.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.co.uk
You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
BTW: I type as I'm thinking, so please don't take any offense at my writing style
The clock generation setting are a bit different to what was originally proposed. Briefly, the syntax is:
clock=[noparse][[/noparse]pin] sets the pin number.
low=[noparse][[/noparse]time] sets how long the pin is low for.
high=[noparse][[/noparse]time] sets how long the pin is high for.
period=[noparse][[/noparse]time] sets the period, but leaves the ratio of high to low time unchanged (or sets to 50%)
pwm=[noparse][[/noparse]0.001 to 0.999] sets the ratio of high to low time without changing the period.
Once a clock is running it can be updated by modifying a single parameter at a time. The example stimulus file shows varying pwm and period examples.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stop the code at the exact point in time that you're interested in.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am keen to try it out under mono again on linux.
Ideally shoving the code back into sourceforge, or in a similar repository. (I won't argue if its bzr a based system)
We should be able to get added to the source forge project pretty easily if that works for you.
m@
The changes are:
1) Use 'R' (or 'r') to run the current cog. 'S' will stop the current cog. If the cog is already stopped, then 'S' will step to the next instruction.
2) For a PASM cog, the values stored at the source and destination registers will be shown for the line under the mouse. They're shown as both hex and decimal.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
===================================
I put together a Serial IO plugin that lets you communicate interactively with the simulated Propeller. It talks to a FullDuplexSerial object running on the simulated chip (or anything pin-compatible). Just rename this file from SerialIO.xml.txt to SerialIO.xml, and put it in your gear directory with your other plugins.
Load it up and you can set the RxPin, TxPin and Baud, and then Press the Reset Serial button to apply your settings.
Then just type to send, and stare at the screen to receive. [noparse]:)[/noparse]
Copy and Paste work too.
Let me know what you think, and if there are crucial features that I'm blatantly missing. [noparse]:)[/noparse]
Ben
Post Edited (benjie) : 5/10/2009 4:41:41 AM GMT
In spin code on a real Propeller chip, the expression long[noparse][[/noparse] a ][noparse][[/noparse] b ] evaluates to long[noparse][[/noparse]a + b*4].
Similarly, short[noparse][[/noparse] a ][noparse][[/noparse] b ] == short[noparse][[/noparse]a + b*2] and byte[noparse][[/noparse] a ][noparse][[/noparse] b ] == byte[noparse][[/noparse]a + b].
But in gear, long[noparse][[/noparse] a ][noparse][[/noparse] b ] seems to always evaluate to 0.
Any suggestions where in the gear code to look for a way to fix this?
(For now, this is easily worked around in spin code by using the long[noparse][[/noparse]a + b*4] format.)
Ben
Post Edited (benjie) : 5/10/2009 12:21:32 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
I run XP SP3 and not have problems to start Gear relase V08_10_16
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.
Sapieha
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Just to see how many VMs we can stack up [noparse]:)[/noparse]
Anyway Gear running ZiCog won't respond after hitting "run". Just keeps running eventually taking down XP.
What are the known limitations on what Gear can do at present?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Ben,
Do you have a minimal example to demonstrate the error and I'll look into it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Three major limitations that I know of:
1) It's slow - like really, really slooowww. It's best for debugging snippets of code.
2) The spin bytecodes are functionally simulated, but not time simulated. Spin takes quite a few more clocks to run on the real Propeller than under GEAR. The PASM simulation is "time-accurate".
3) Very little simulation of external hardware.
You could try stepping through the code - rather than running. To see if there is a reason for the "lockup" - like maybe waiting for some sort of hardware event.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The minimal code to see the problem would be something like:
Ben
Thanks for the code! It was being emulated as:
See the top post for a new version.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
But I think you may have built the fix from an older version of the code, because I can no longer override AllowHotKeys.
Also, if you want to include the SerialIO plugin with the main distribution, feel free. [noparse]:)[/noparse]
I included SerialIO - it looks good!
See the top post for the new version.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I've been using it to debug changes to my remote controlled airplane autopilot code while I'm out of the country and away from the hardware. I've been pasting in raw GPS data and watching it churn, calculate, and spit out debug info. [noparse]:)[/noparse]
Ben