gnupic@linuxhacker.org

gnupic@linuxhacker.org


Subject: Re: gpsim logging writes to IO ports
From: Ralf Forsberg
Date: Sun, 9 Feb 2003 13:38:46 +0100

On Sun, Feb 09, 2003 at 11:25:01AM +0000, Alex Holden wrote:
> 
> Now I'm attempting to write a module with very little experience of
> coding in C++. I don't suppose anyone's written a "subtitles for the
> hard of thinking" guide to writing gpsim modules have they? I want my
> module to be able to:
> 
> * Watch the state of some digital input pins, and read the cycle counter
> when they change.
> * Control the state of some digital output pins from the background
> simulation.

You could look at the modules/logic.cc module.

> * Get called every "n" processor simulation cycles (or getting called
> once every cycle would do) to do some background simulation work, and be
> able to read the processor cycle counter from here also.

Try gpsim_set_break_delta(). (Example in InputPort::callback(),
paraface.cc.)

> * Write data to the log (Ok, the module itself could open a file and log
> to it, but it'd be nicer to use the Gpsim log facility).

There is module1(int) and module2(int,int), but those are kinda limited
and shared by all modules...

> * Get notified when the processor has been reset so I can also reset my
> simulation.

Add a gpsimInterface::reset(), and call gi.reset() from
pic_processor::reset(). Then use gpsim_register_interface() and 
gpsim_register_reset() from your module. (I can implement this in gpsim
if you want).

 / Ralf


gnupic@linuxhacker.org