gnupic: Re: [gnupic] Remarks to gpsim of 05/12/2006
Subject:
Re: [gnupic] Remarks to gpsim of 05/12/2006
From:
Scott Dattalo ####@####.####
Date:
23 May 2006 00:08:21 +0100
Message-Id: <4472445F.9010807@dattalo.com>
Scott Dattalo wrote:
> Let me design a file stimulus. I have another application I can use this
> for too.
I have an application where I'd like to configure the processor/system
state in some manner and validate the system state at a subsequent time:
set up input state
simulate the code
validate output state
For example, take something like a square root routine. You might want
to specify a number whose root you wish to compute and then at the end
of the routine verify that the correct value is returned. You could
imagine a file containing 2^16 inputs and their corresponding 2^16 outputs.
The simplest file format I can imagine is one where each line contains a
list of commands. For example, let's assume that N_hi and N_lo are the
16-bit input to the square root routine and that 'root' is the 8-bit
result. Here's how a stimulus file might look:
-------------------------
N_hi = 0; N_lo = 0 # input condition
(root == 0) # expected result
N_hi = 0; N_lo = 1
(root == 1)
N_hi = 0; N_lo = 2
(root == 1)
N_hi = 0; N_lo = 3
(root == 1)
N_hi = 0; N_lo = 4
(root == 2)
# and so on
------------------------
The stimulus could then be used like so:
gpsim> module load file_stimulus FS1
gpsim> FS1.file = "SquareRootData"
And in the PIC program under test:
; Get the next input from the file stimulus
.command "FS1.stepcommand=true"
nop
call SqrtRoutine
; now validate the results
.command "FS1.stepcommand=true"
nop
The File Stimulus attribute '.stepcommand' reads the next line in the
file and passes it through the gpsim parser. Conditional commands must
evaluate to true for the simulation to continue.
Timed commands
--------------
Now, I realize that Tobias requires something different. Instead, he
wants to supply data to a stimulus at a specific point in time. I think
the best way to do this is to instantiate a pullup resistor and modulate
it's pullup voltage.
gpsim> module load file_stimulus FS2
gpsim> FS2.file = "PinStimulusData"
gpsim> module load pullup V1 # we'll use a pullup as a voltage source
gpsim> node nRA0
gpsim> attach nRA0 porta0 V1.pin
Now suppose he wishes to create a voltage ramp and make sure that it
causes the variable 'hasTripped' only to be set at some particular voltage:
@0x100 V1.voltage = 0.0
@0x200 V1.voltage = 0.5
@0x210 (hasTripped = 0) # make sure some internal state is correct
@0x300 V1.voltage = 1.5
@0x310 (hasTripped = 1) # should've tripped at ~ 1.2 volts
etc.
The @NNNN prefix tells gpsim to execute the list of commands at a
particular cycle.
Periodic sequences.
-------------------
The File Stimulus could support a "jump to line command". For example,
FS1.starttime = cycles # specify base cycle to be the current cycle
FS1.line = 5 # start executing at line 5
The '.starttime' attribute represents the offset cycle to which the
'@NNNN' prefix is added. The '.line' attribute specifies the next line
from which the File Stimulus should read (I'm thinking of files and not
named pipes). Here's an example of a periodic stimulus:
@0x100 V1.voltage = 0.0
@0x200 V1.voltage = 0.5
@0x210 (hasTripped = 0) # make sure some internal state is correct
@0x300 V1.voltage = 1.5
@0x310 (hasTripped = 1) # should've tripped at ~ 1.2 volts
@0x400 FS1.starttime = cycles; FS1.line = 0;
The last line turns the ramp into a 0x400 cycle repeating sequence.
---
I think that was longer than Peter's post! And speaking of Peter's post,
you probably notice that they're similar. I borrowed Peter's ideas and
recast them into a gpsim form. The major difference is that the file
stimulus as I've proposed it is nothing more than a list of gpsim
commands that can be executed at the rate the user (or the simulation)
requires.
Comments?
Scott