forked from kstenerud/Musashi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim.h
59 lines (45 loc) · 1.47 KB
/
sim.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include "peripheralBase.h"
#include "peripheralTypes.h"
#include "port.h"
namespace mc68k
{
class Mc68k;
class Sim final : public PeripheralBase<g_simBase, g_simSize>
{
public:
enum PicrBits : uint16_t
{
PivMask = 0xff, // Periodic Interrupt Vector
PirqlMask = 0x700, // Periodic Interrupt Request Level
PirqlShift = 8,
};
enum PitrBits : uint16_t
{
Pitm = 0xff, // Periodic Interrupt Timing Modulus
Ptp = (1<<8) // Periodic Timer Prescaler Control, 0 = off, 1 = prescaled by 512
};
explicit Sim(Mc68k& _mc68k);
uint16_t read16(PeriphAddress _addr) override;
uint8_t read8(PeriphAddress _addr) override;
void write8(PeriphAddress _addr, uint8_t _val) override;
void write16(PeriphAddress _addr, uint16_t _val) override;
void exec(uint32_t _deltaCycles) override;
Port& getPortE() { return m_portE; }
Port& getPortF() { return m_portF; }
uint32_t getSystemClockHz() const { return m_systemClockHz; }
void setExternalClockHz(const uint32_t _hz);
private:
void initTimer();
void updateClock();
static void logChipSelectPinAssignments(uint16_t _val, int _index, int _count);
static void logChipSelectBaseAddressRegister(uint32_t _index, uint16_t _val);
static void logChipSelectOptionRegister(uint32_t _index, uint16_t _val);
Mc68k& m_mc68k;
int32_t m_timerLoadValue = 0;
int32_t m_timerCurrentValue = 0;
Port m_portE, m_portF;
uint32_t m_externalClockHz = 32768;
uint32_t m_systemClockHz = 0;
};
}