4 #include "SimulationObject.h"
11 typedef unsigned long long ClockFrequency
;
23 class HardwareSettings
;
29 * @brief A facade to the complete Atmel AVR chip.
31 * This class represents a complete Atmel AVR chip and
32 * forms a facade for the outside "world".
33 * The class contains some useful construction methods
34 * used by the DeviceSettings class.
36 class Device
: public sim::SimulationObject
{
38 Device(sim::SimulationClock
& clock
,
39 const char *devicename
= 0,
40 bool allowStopping
= true);
45 * Loads the useful sections from the program file
46 * into eeprom, sram and flash.
48 void load(Program
& program
);
51 * Instantiates and adds an analyzer to the core.
53 void addAnalyzer(const char *name
);
56 * Adds an analyzer to the core.
58 void addAnalyzer(Analyzer
*analyzer
);
61 * Adds a trace analyzer to the core
62 * which outputs to the specified file.
64 void trace(const char *tracefile
);
67 * Performs a single cpu cycle.
72 * Change the clock frequency of the device.
74 void setClockFrequency(ClockFrequency frq
);
79 void reset(unsigned int type
);
81 Pin
*getPin(unsigned int id
) const;
82 Pin
*getPin(const std::string
& name
) const;
86 * Returns an interface for debugging, this interface
87 * has access to some protected parts of the core.
89 DebugInterface
*debugInterface();
92 // Construction methods for DeviceSettings
93 void buildCore(unsigned int ioSpaceSize
, unsigned int ramSize
,
94 unsigned int flashSize
, unsigned int pageSize
,
95 unsigned int stackMask
, int pcBytes
= 2,
97 void buildHardware(const char *hwname
, HardwareSettings
& hws
);
98 void addIOReg(unsigned int address
, const std::string
& name
,
99 unsigned char initial
= 0);
100 void addInterrupt(unsigned int vector
, unsigned int address
,
102 void addPin(unsigned int id
, const char *name
, unsigned int num
);
105 static const ClockFrequency defaultFrequency
= 8000000;
106 sim::ClockOffset frq
;
113 std::vector
<Pin
*> pins
;
114 std::map
<std::string
, Pin
*> name2pin
;
116 friend class DeviceSettings
;
119 inline Pin
*Device::getPin(unsigned int id
) const {
120 if( id
>= pins
.size() )
122 return pins
[ id
- 1 ];