Stimuli Files - AVR Simulator Docu

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Folks,

after some time of playing around with AVR Studio 5 I want to do advanced work and stimulate the ports. I spend half a day to find information, but found only out of date info and no docu for the Simulator. Even the view help is not working (The topic you requested could not be found in local help.)

Please give me a hint, where I can find the Docu (it is not part of the installed package) and how I can assign stimuli files.

Regards

Dirk

PS: The best info I found

Simulator2 Stimuli in AVR Studio
Introduction
The Simultor2 stimuli feature is intended to be an improvement over the stimuli/logging feature found in the old Simulator 1. It is still in early development, and more features will be added to it at a later time.



Improvements over the old simulator1 stimuli mechanism include:

Timing is expressed in terms of delay instead of absolute cycle counter values

Any I/O register can be assigned to (stimulated), not only port registers

Individual bits in I/O registers can be stimulated using bitwise assignments

Directives increase flexibility

Stimuli file format
A stimuli file is a simple ASCII plain text file containing stimuli commands, one command per line. Apart from comments (starting with '//') there are only 3 kinds of commands: Delays, assignments, and directives.

Delays
A delay is specified by an '#' character followed by the duration of the delay specified in CPU clock cycles. I.e., #20 means a delay of 20 clock cycles. Using delays is the only way of separating commands in time. Commands that are not separated by delays will be executed simultaneously (i.e., in the same clock cycle). In the current implementation stimuli are only evaluated between CPU single steps, meaning that the delay may be longer than specified if it would end in the middle of a multi-cycle instruction.

Assignments
Assignments are used to assign a new value to an I/O register (i.e., apply the actual stimuli). The following forms of assignments are currently supported:



Statement
Description

target = value
Direct assignment; set target equal to value

target |= value
Bitwise OR assignment; bits that are '1' in value will be set in target, remaining bits unchanged.

target &= value
Bitwise AND assignment; bits that are '0' in value will be cleared in target, remaining bits unchanged.

target ^= value
Bitwise XOR assignment; bits that are '1' in value will be toggled (inverted) in target, remaining bits unchanged.




For all forms of assignment, target is the name (case sensitive, names are in UPPER case) or numerical MEMORY address of an I/O register in the I/O map. Value is either a numerical constant (specified in decimal, octal, or hex according to C syntax), or it can have the form *source where source is the name or memory address of an I/O register (i.e., one can assign from one register to another). The current interpreter does not support expressions, i.e., one cannot say

GPIOR0 = *GPIOR1 + 1

Directives
A directive is initiated by a '$' character, followed by a command. Directives are used to control various aspects of stimuli execution and logging.



The currently supported directives are:



Directive
Arguments
Description

$stimulate
filename
Start reading of stimuli from a new file. The new file will be read in parallel with the current file.

$quit

Quit the current stimuli file, the remainder of the file will be discarded and the file is closed. (same as when hitting end of file)

$break

Break program execution. Stimuli file(s) remain open and stimuli will be resumed when program execution is resumed.

$repeat
number
Start a repeat loop, repeat number times until $endrep directive

$endrep

End of repeat loop.

$log
IO-register
Set up for logging of a register. Logging will not start until $startlog directive is executed.

$unlog
IO-register
Stop logging a register.

$startlog
filename
Start logging to named file.

$stoplog

Stop logging.




A log entry is generated whenever a logged I/O register changes value for whatever reason. The log format is compatible with the stimuli format; i.e., log output can be used as stimuli input. The log file will consist of delay statements and assignments.

Use from AVR Studio
The stimuli generator is started from AVR Studio using the menu selection Debug "“ Simulator2 Options. The stimuli file name can be typed into the text field or browsed for using the "Stimuli file" button, both located at the bottom of the options window.



The stimuli input file must be prepared in advance using a text editor. It is recommended to use the extension ".stim" for stimuli files.



Stimuli is applied when the application program is run or single-stepped. To assist debugging, the stimuli commands are echoed in AVR Studio's message output pane with a time stamp (cycle counter) as they are executed. Presently, there is no manner to disable this (apart from disabling AVR Studio "info" output altogether).



Logging can only be started by means of commands in stimuli files, there are presently no GUI facilities to set up/start logging. AVR Studio currently only supports logging to file, not to the output pane.

Known issues
Stimuli files
In assignments, the operator (=, etc) must be surrounded by spaces.

The stimuli interpreter will fail if the last line of the stimuli input file is not terminated by a newline.

There is no manner to assign values to 16- or 32-bit register tuples, e.g., to assign to ADC one must assign to ADCL and ADCH separately. See example in next section.

Error reporting leaves a lot to be desired.

The timing of stimuli can be a cycle or two off compared to delay specification because stimuli files are evealuated only between CPU single-steps in the current implementation.

Sharing violation if attempting to edit a stimuli file while open.

Example stimuli file
The following example shows how ADC conversion results can be injected into the ADC data registers, and an ADC interrupt be triggered by setting the ADIF flag in ADCSRA. This example is set up for an ATmega164 but should work on most AVR devices with an ADC. The example does not show meaningful use of ADC but illustrates how stimuli files can be used.



The example also shows use of logging and break directives.



// Initial delay

#100

// Set up logging ADC and ADCSRA to file adc.log

$log ADCL

$log ADCH

$log ADCSRA

$startlog adc.log

// start of repeat loop

$repeat 100

// Assuming TCNT1 is running, use as data for ADC

ADCL = *TCNT1L

ADCH = *TCNT1H

// Set ADIF flag in ADCSRA, this will trigger ADCC interrupt

ADCSRA |= 0x10

#30

$endrep

// Stop logging (close log file)

$stoplog

// break program execution

$break 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You may find it easier to start with Sim2 in 4.19 - it's the same simulator and the stimuli help is built into the online help and is very clear. I imagine you should then be able to take that exact same stimuli file and use it in AS5 (where it does seem they have made a complete bish of the help system)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanx for your fast answer. Still the question: How can a assign it to the simulation in AS5?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The simulator stimuli feature is not yet implemented in AVR Studio 5. That is the reason you won't find it in AS5 help... We are working on it.

- roland