Bug fix: check if vm exists
[avr-sim.git] / Device.h
blobce86a75b59e990e87f78e3766029e5febedc6f88
1 #ifndef DEVICE_H_
2 #define DEVICE_H_
4 #include "SimulationObject.h"
5 #include "Bus.h"
6 #include <string>
7 #include <vector>
9 namespace avr {
10 typedef unsigned long long ClockFrequency;
12 class ERam;
13 class Core;
14 class Hardware;
15 class Eeprom;
16 class DebugInterface;
18 class ScriptEngine;
19 class Program;
20 class HardwareSettings;
21 class DeviceSettings;
23 class Device : public SimulationObject {
24 public:
25 Device(SimulationClock & clock, const char *devicename = 0);
26 ~Device();
28 public:
29 void load(const Program & program);
30 void addAnalyzers(ScriptEngine *vm,
31 const std::list<const char *> & analyzers);
33 void step();
34 void setClockFrequency(ClockFrequency frq);
35 void reset(unsigned int type);
37 public:
38 DebugInterface *debugInterface();
40 private:
41 // Construction methods for DeviceSettings
42 void buildCore(unsigned int ioSpaceSize, unsigned int ramSize,
43 unsigned int flashSize, unsigned int stackMask,
44 int pcBytes = 2, ERam *eram = 0);
45 void buildHardware(const char *hwname, HardwareSettings & hws);
46 void addIOReg(unsigned int address, const std::string & name,
47 unsigned char initial = 0);
48 void addInterrupt(unsigned int vector, unsigned int address,
49 const char *name);
51 private:
52 static const ClockFrequency defaultFrequency = 8000000;
53 ClockOffset frq;
54 Core *core;
56 Bus bus;
57 Eeprom *eeprom;
59 private:
60 struct IntVect {
61 IntVect() {}
62 IntVect(unsigned int addr, const std::string & name)
63 : address(addr), name(name) {}
64 unsigned int address;
65 std::string name;
67 std::vector< IntVect > intVectors;
69 friend class DeviceSettings;
73 #endif /*DEVICE_H_*/