2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
23#include "../types/evmu_peripheral.h"
26#include <gimbal/meta/signals/gimbal_signal.h>
29
30
31
32#define EVMU_CPU_TYPE (GBL_TYPEID
(EvmuCpu))
33#define EVMU_CPU(self) (GBL_CAST(EvmuCpu, self))
38#define EVMU_CPU_NAME "cpu"
40#define GBL_SELF_TYPE EvmuCpu
44GBL_FORWARD_DECLARE_STRUCT(EvmuCpu);
50
51
52
53
54
55
56
57
58
59GBL_CLASS_DERIVE(EvmuCpu, EvmuPeripheral)
61 EVMU_RESULT (*pFnFetch) (GBL_SELF,
63 EvmuInstruction* pEncoded);
65 EVMU_RESULT (*pFnDecode) (GBL_SELF,
66 const EvmuInstruction* pEncoded,
67 EvmuDecodedInstruction* pDecoded);
69 EVMU_RESULT (*pFnExecute)(GBL_SELF,
70 const EvmuDecodedInstruction* pInstr);
72 EVMU_RESULT (*pFnRunNext)(GBL_SELF);
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91GBL_INSTANCE_DERIVE(
EvmuCpu, EvmuPeripheral)
107 (pcChange, (GBL_INSTANCE_TYPE, pReceiver), (GBL_UINT16_TYPE, pc))
115
116
117
118
126
127
128
129
141
142
143
144
147 const EvmuDecodedInstruction* pInstr) GBL_NOEXCEPT;
#define EVMU_EXPORT
Define used for adding attributes to export public symbols.
uint16_t EvmuPc
Program counter for EvmuCpu instructions.
GblType EvmuCpu_type(void)
Returns the GblType UUID associated with EvmuCpu.
uint8_t EvmuWord
Represents a single 8-bit CPU word.
#define GBL_PROPERTIES(object,...)
uint32_t haltAfterNext
Halts the CPU execution after the next instruction.
void EvmuCpu_setPc(EvmuCpu *pSelf, EvmuPc address)
Sets the address of the program counter, so that it will be the next executed instruction.
uint32_t halted
Halts CPU execution.
double EvmuCpu_secs(const EvmuCpu *pSelf)
Returns the number of seconds per instruction for the currently executing instruction.
EVMU_RESULT EvmuCpu_runNext(EvmuCpu *pSelf)
Fetches and executes the next instruction, which is located at the address pointed to by the program ...
int32_t EvmuCpu_operand(const EvmuCpu *pSelf, size_t idx)
Returns the operand of the currently executing instruction at index idx.
uint32_t pcChanged
User toggle (reset to false) which be set upon PC change.
EVMU_RESULT EvmuCpu_execute(EvmuCpu *pSelf, const EvmuDecodedInstruction *pInstr)
Immediately executes an externally provided decoded instruction rather than fetching one from ROM or ...
EvmuWord EvmuCpu_opcode(const EvmuCpu *pSelf)
Returns the opcode of the currently executing instruction.
size_t EvmuCpu_cycles(const EvmuCpu *pSelf)
Returns the number of cycles per instruction for the currently executing instruction.
EvmuPc EvmuCpu_pc(const EvmuCpu *pSelf)
Returns the address for the program counter, which points to the next instruction.
#define GBL_CLASS_CAST(cType, klass)
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)