Device Class Reference
|
yasimavr
|
Basic AVR device model. More...
#include <sim_device.h>
Public Types | |
| enum | State { State_Limbo = 0x00 , State_Ready = 0x10 , State_Running = 0x21 , State_Sleeping = 0x31 , State_Halted = 0x41 , State_Reset = 0x51 , State_Break = 0x60 , State_Done = 0x70 , State_Crashed = 0x80 , State_Destroying = 0xFF } |
| enum | ResetFlag { Reset_PowerOn = 0x00000001 , Reset_WDT = 0x00000002 , Reset_BOD = 0x00000004 , Reset_SW = 0x00000008 , Reset_Ext = 0x00000010 , Reset_Halt = 0x00010000 } |
| enum | Option { Option_ResetOnPinShorting = 0x01 , Option_IgnoreBadCpuIO = 0x02 , Option_IgnoreBadCpuLPM = 0x04 , Option_DisablePseudoSleep = 0x08 , Option_InfiniteLoopDetect = 0x10 } |
Protected Member Functions | |
| virtual bool | arch_init () |
| virtual bool | core_ctlreq (ctlreq_id_t req, ctlreq_data_t *reqdata) |
| virtual bool | program (const Firmware &firmware) |
| void | erase_peripherals () |
| virtual flash_addr_t | reset_vector () |
Friends | |
| class | DeviceDebugProbe |
Detailed Description
Basic AVR device model.
This is the top-level object for a AVR MCU simulation model.
Member Enumeration Documentation
◆ Option
| enum Device::Option |
Device option enum
These options are to be used with set_option() and test_option() to alter the behaviour of the simulation model.
◆ ResetFlag
| enum Device::ResetFlag |
◆ State
| enum Device::State |
Device model state enum.
| Enumerator | |
|---|---|
| State_Limbo | Device constructed but not yet initialised. |
| State_Ready | Device initialised but no firmware loaded yet. |
| State_Running | Device executing the firmware. |
| State_Sleeping | Device in sleep mode. |
| State_Halted | CPU halted but peripherals are running normally. |
| State_Reset | Device being reset (taken into account at the next cycle) |
| State_Break | Device halted by a BREAK instruction. |
| State_Done | Final state without any error. |
| State_Crashed | Final state with error. |
| State_Destroying | Transiting state during destruction. |
Constructor & Destructor Documentation
◆ Device() [1/2]
| Device::Device | ( | Core & | core, |
| const DeviceConfiguration & | config | ||
| ) |
Construct a device model
◆ ~Device()
|
virtualdefault |
◆ Device() [2/2]
|
delete |
Member Function Documentation
◆ add_ioreg_handler()
| void Device::add_ioreg_handler | ( | reg_addr_t | addr, |
| IORegHandler & | handler, | ||
| bitmask_t | bits, | ||
| IORegister::BitMode | bitmode | ||
| ) |
Adds a handler to a I/O register.
- Parameters
-
addr address of the I/O register, in I/O address space handler handler to add bits masks for adding bits to use in the register bitmode mode for the bits added
- Note
- The register is allocated if it does not exist yet.
◆ arch_init()
|
protectedvirtual |
Stub for any architecture specific initialisation step. The default implementation does nothing.
- Returns
- true if initialisation is successful, false in case of error.
◆ attach_peripheral()
| void Device::attach_peripheral | ( | Peripheral & | ctl | ) |
Attach a peripheral to the device. The device takes ownership of the peripheral and will destroy it upon destruction.
- Parameters
-
ctl peripheral to attach
◆ config()
|
inline |
◆ core()
|
inline |
◆ core_ctlreq()
|
protectedvirtual |
Callback for processing the requests to the core.
- See also
- ctlreq()
Reimplemented in ArchAVR_Device, and ArchXT_Device.
◆ crash()
| void Device::crash | ( | uint16_t | reason, |
| const char * | text | ||
| ) |
Set the device to the crashed state
- Parameters
-
reason one of the CRASH_XXX codes text message of the crash
◆ ctlreq()
| bool Device::ctlreq | ( | ctl_id_t | id, |
| ctlreq_id_t | req, | ||
| ctlreq_data_t * | reqdata = nullptr |
||
| ) |
Process a peripheral request. This is the mechanism used to interrogate peripherals or the device itself.
- Parameters
-
id identifier of the peripheral to interrogate req request identifier, specific to each peripheral reqdata data structure of the request
- Returns
- true if the request could be processed, false otherwise.
◆ cycle()
|
inline |
◆ cycle_manager()
|
inline |
◆ erase_peripherals()
|
protected |
◆ exec_cycle()
| cycle_count_t Device::exec_cycle | ( | ) |
Execute one instruction cycle.
- Returns
- the number of clock cycle consumed by the instruction, or 0 if something wrong happened.
◆ find_peripheral()
| Peripheral * Device::find_peripheral | ( | ctl_id_t | id | ) |
Finds a peripheral given its identifier the device itself.
- Returns
- the peripheral if found or nullptr
◆ find_pin()
Find a device pin with the given identifier
- Returns
- the pin if found, or nullptr
◆ frequency()
|
inline |
◆ init()
| bool Device::init | ( | CycleManager & | cycle_manager | ) |
Initialise a device. This must be called once before the simulation is started. This function allows all peripherals to allocate resources and connect signals.
- Parameters
-
cycle_manager used for scheduling timers during the device model execution.
- Returns
- true if the initialisation has succeeded, false if it failed.
◆ load_firmware()
| bool Device::load_firmware | ( | const Firmware & | firmware | ) |
Load a firmware into the device non-volatile memories.
- Returns
- true if the load succeeded, false if it failed
- See also
- Firmware
◆ log_handler()
|
inline |
◆ logger()
|
inline |
◆ operator=()
◆ pin_manager()
|
inline |
◆ program()
|
protectedvirtual |
Implementation of the programming of the non-volatile memories of the device. The basic implementation only loads the flash and the fuses, the rest is the responsibility of architecture-specific implementations.
- Returns
- true if the load succeeded, false if it failed
- See also
- Firmware
Reimplemented in ArchAVR_Device, and ArchXT_Device.
◆ reset()
| void Device::reset | ( | int | reset_flag = Reset_PowerOn | ) |
Simulates a MCU reset.
- Parameters
-
reset_flag combination of ResetFlag enum values, indicating the source of the reset signal
◆ reset_vector()
|
protectedvirtual |
Returns the reset vector address in bytes. The default implementation returns 0x0000.
Reimplemented in ArchAVR_Device.
◆ set_option()
| void Device::set_option | ( | Option | option, |
| bool | value | ||
| ) |
Set or clear a device option.
- See also
- Device::Option
◆ sleep_mode()
|
inline |
◆ state()
|
inline |
◆ test_option()
| bool Device::test_option | ( | Option | option | ) | const |
Returns whether a device option is set.
- See also
- Device::Option
Friends And Related Symbol Documentation
◆ DeviceDebugProbe
|
friend |
The documentation for this class was generated from the following files:
Generated by