SimAVR
AVR Simulator
avr_t Struct Reference

Main AVR instance. More...

#include <sim_avr.h>

Collaboration diagram for avr_t:

Data Fields

const char * mmcu
 name of the AVR More...
 
uint16_t ramend
 
uint32_t flashend
 
uint32_t e2end
 
uint8_t vector_size
 
uint8_t signature [3]
 
uint8_t fuse [4]
 
avr_io_addr_t rampz
 optional, only for ELPM/SPM on >64Kb cores More...
 
avr_io_addr_t eind
 optional, only for EIJMP/EICALL on >64Kb cores More...
 
uint8_t address_size
 2, or 3 for cores >128KB in flash More...
 
uint32_t codeend
 filled by the ELF data, this allow tracking of invalid jumps More...
 
int state
 stopped, running, sleeping More...
 
uint32_t frequency
 frequency we are running at More...
 
uint32_t vcc
 
uint32_t avcc
 
uint32_t aref
 (optional) voltages in millivolts More...
 
avr_cycle_count_t cycle
 current cycle More...
 
avr_cycle_count_t run_cycle_count
 cycles to run before next timer More...
 
avr_cycle_count_t run_cycle_limit
 maximum run cycle interval limit More...
 
uint32_t sleep_usec
 Sleep requests are accumulated in sleep_usec until the minimum sleep value is reached, at which point sleep_usec is cleared and the sleep request is passed on to the operating system. More...
 
void(* init )(struct avr_t *avr)
 Called at init time. More...
 
void(* special_init )(struct avr_t *avr, void *data)
 called at init time (for special purposes like using a memory mapped file as flash see: simduino) More...
 
void(* special_deinit )(struct avr_t *avr, void *data)
 called at termination time ( to clean special initializations) More...
 
void * special_data
 value passed to special_init() and special_deinit() More...
 
void(* reset )(struct avr_t *avr)
 called at reset time More...
 
avr_run_t run
 Default AVR core run function. More...
 
void(* sleep )(struct avr_t *avr, avr_cycle_count_t howLong)
 Sleep default behaviour. More...
 
avr_irq_pool_t irq_pool
 Every IRQs will be stored in this pool. More...
 
uint8_t sreg [8]
 Mirror of the SREG register, to facilitate the access to bits in the opcode decoder. More...
 
int8_t interrupt_state
 Interrupt state: 00: idle (no wait, no pending interrupts) or disabled <0: wait till zero >0: interrupt pending. More...
 
avr_flashaddr_t pc
 Current PC Note that the PC is representing /bytes/ while the AVR value is assumed to be "words". More...
 
struct {
   struct avr_irq_t *   irq
 optional, used only if asked for with avr_iomem_getirq() More...
 
   struct {
      void *   param
 
      avr_io_read_t   c
 
   }   r
 
   struct {
      void *   param
 
      avr_io_write_t   c
 
   }   w
 
io [MAX_IOs]
 Callback when specific IO registers are read/written. More...
 
int io_shared_io_count
 This block allows sharing of the IO write/read on addresses between multiple callbacks. More...
 
struct {
   int   used
 
   struct {
      void *   param
 
      void *   c
 
   }   io [4]
 
io_shared_io [4]
 
uint8_t * flash
 Flash memory (initialized to 0xff, and code loaded into it) More...
 
uint8_t * data
 SRAM memory, starting by the general purpose registers, and IO registers. More...
 
struct avr_io_tio_port
 Queue of io modules. More...
 
avr_cycle_timer_pool_t cycle_timers
 Cycle timers tracking & delivery. More...
 
avr_int_table_t interrupts
 Interrupt vectors and delivery fifo. More...
 
uint8_t trace:1
 DEBUG ONLY – value ignored if CONFIG_SIMAVR_TRACE = 0. More...
 
uint8_t log:2
 log level, default to 1 More...
 
struct avr_trace_data_ttrace_data
 Only used if CONFIG_SIMAVR_TRACE is defined. More...
 
struct avr_vcd_tvcd
 Value Change Dump file (waveforms) This is the VCD file that gets allocated if the firmware that is loaded explicitly asks for a trace to be generated, and allocates it's own symbols using AVR_MMCU_TAG_VCD_TRACE (see avr_mcu_section.h) More...
 
struct avr_gdb_tgdb
 gdb hooking structure. Only present when gdb server is active More...
 
int gdb_port
 if non-zero, the gdb server will be started when the core crashed even if not activated at startup if zero, the simulator will just exit() in case of a crash More...
 

Detailed Description

Main AVR instance.

Some of these fields are set by the AVR "Core" definition files the rest is runtime data (as little as possible)

Field Documentation

uint8_t address_size

2, or 3 for cores >128KB in flash

uint32_t aref

(optional) voltages in millivolts

uint32_t avcc
void* c
uint32_t codeend

filled by the ELF data, this allow tracking of invalid jumps

current cycle

avr_cycle_timer_pool_t cycle_timers

Cycle timers tracking & delivery.

uint8_t* data

SRAM memory, starting by the general purpose registers, and IO registers.

uint32_t e2end

optional, only for EIJMP/EICALL on >64Kb cores

uint8_t* flash

Flash memory (initialized to 0xff, and code loaded into it)

uint32_t flashend
uint32_t frequency

frequency we are running at

uint8_t fuse[4]
struct avr_gdb_t* gdb

gdb hooking structure. Only present when gdb server is active

int gdb_port

if non-zero, the gdb server will be started when the core crashed even if not activated at startup if zero, the simulator will just exit() in case of a crash

void(* init) (struct avr_t *avr)

Called at init time.

int8_t interrupt_state

Interrupt state: 00: idle (no wait, no pending interrupts) or disabled <0: wait till zero >0: interrupt pending.

interrupt state

avr_int_table_t interrupts

Interrupt vectors and delivery fifo.

struct { ... } io[MAX_IOs]

Callback when specific IO registers are read/written.

There is one drawback here, there is in way of knowing what is the "beginning of useful sram" on a core, so there is no way to deduce what is the maximum IO register for a core, and thus, we can't allocate this table dynamically. If you wanted to emulate the BIG AVRs, and XMegas, this would need work.

struct { ... } io[4]
struct avr_io_t* io_port

Queue of io modules.

struct { ... } io_shared_io[4]
int io_shared_io_count

This block allows sharing of the IO write/read on addresses between multiple callbacks.

In 99% of case it's not needed, however on the tiny* (tiny85 at last) some registers have bits that are used by different IO modules. If this case is detected, a special "dispatch" callback is installed that will handle this particular case, without impacting the performance of the other, normal cases...

struct avr_irq_t* irq

optional, used only if asked for with avr_iomem_getirq()

avr_irq_pool_t irq_pool

Every IRQs will be stored in this pool.

It is not mandatory (yet) but will allow listing IRQs and their connections

uint8_t log

log level, default to 1

const char* mmcu

name of the AVR

void* param

Current PC Note that the PC is representing /bytes/ while the AVR value is assumed to be "words".

This is in line with what GDB does... this is why you will see >>1 and <<1 in the decoder to handle jumps. It CAN be a little confusing, so concentrate, young grasshopper.

struct { ... } r
uint16_t ramend

optional, only for ELPM/SPM on >64Kb cores

void(* reset) (struct avr_t *avr)

called at reset time

avr_run_t run

Default AVR core run function.

Two modes are available, a "raw" run that goes as fast as it can, and a "gdb" mode that also watchouts for gdb events and is a little bit slower.

avr_cycle_count_t run_cycle_count

cycles to run before next timer

avr_cycle_count_t run_cycle_limit

maximum run cycle interval limit

uint8_t signature[3]
void(* sleep) (struct avr_t *avr, avr_cycle_count_t howLong)

Sleep default behaviour.

In "raw" mode, it calls usleep, in gdb mode, it waits for howLong for gdb command on it's sockets.

uint32_t sleep_usec

Sleep requests are accumulated in sleep_usec until the minimum sleep value is reached, at which point sleep_usec is cleared and the sleep request is passed on to the operating system.

void* special_data

value passed to special_init() and special_deinit()

void(* special_deinit) (struct avr_t *avr, void *data)

called at termination time ( to clean special initializations)

void(* special_init) (struct avr_t *avr, void *data)

called at init time (for special purposes like using a memory mapped file as flash see: simduino)

uint8_t sreg[8]

Mirror of the SREG register, to facilitate the access to bits in the opcode decoder.

This array is re-synthesized back/forth when SREG changes

int state

stopped, running, sleeping

uint8_t trace

DEBUG ONLY – value ignored if CONFIG_SIMAVR_TRACE = 0.

struct avr_trace_data_t* trace_data

Only used if CONFIG_SIMAVR_TRACE is defined.

int used
uint32_t vcc
struct avr_vcd_t* vcd

Value Change Dump file (waveforms) This is the VCD file that gets allocated if the firmware that is loaded explicitly asks for a trace to be generated, and allocates it's own symbols using AVR_MMCU_TAG_VCD_TRACE (see avr_mcu_section.h)

uint8_t vector_size
struct { ... } w

The documentation for this struct was generated from the following file: