@@ -11,33 +11,6 @@ import { avrInterrupt } from './interrupt';
11
11
12
12
const registerSpace = 0x100 ;
13
13
14
- // eslint-disable-next-line @typescript-eslint/interface-name-prefix
15
- export interface ICPU {
16
- readonly data : Uint8Array ;
17
- readonly dataView : DataView ;
18
- readonly progMem : Uint16Array ;
19
- readonly progBytes : Uint8Array ;
20
-
21
- /**
22
- * Whether the program counter (PC) can address 22 bits (the default is 16)
23
- */
24
- readonly pc22Bits : boolean ;
25
-
26
- /**
27
- * Program counter
28
- */
29
- pc : u32 ;
30
-
31
- /**
32
- * Clock cycle counter
33
- */
34
- cycles : number ;
35
-
36
- readData ( addr : u16 ) : u8 ;
37
- writeData ( addr : u16 , value : u8 , mask ?: u8 ) : void ;
38
- onWatchdogReset ( ) : void ;
39
- }
40
-
41
14
export type CPUMemoryHook = ( value : u8 , oldValue : u8 , addr : u16 , mask : u8 ) => boolean | void ;
42
15
export interface CPUMemoryHooks {
43
16
[ key : number ] : CPUMemoryHook ;
@@ -66,7 +39,7 @@ interface AVRClockEventEntry {
66
39
next : AVRClockEventEntry | null ;
67
40
}
68
41
69
- export class CPU implements ICPU {
42
+ export class CPU {
70
43
readonly data : Uint8Array = new Uint8Array ( this . sramBytes + registerSpace ) ;
71
44
readonly data16 = new Uint16Array ( this . data . buffer ) ;
72
45
readonly dataView = new DataView ( this . data . buffer ) ;
@@ -76,6 +49,10 @@ export class CPU implements ICPU {
76
49
private readonly pendingInterrupts : AVRInterruptConfig [ ] = [ ] ;
77
50
private nextClockEvent : AVRClockEventEntry | null = null ;
78
51
private readonly clockEventPool : AVRClockEventEntry [ ] = [ ] ; // helps avoid garbage collection
52
+
53
+ /**
54
+ * Whether the program counter (PC) can address 22 bits (the default is 16)
55
+ */
79
56
readonly pc22Bits = this . progBytes . length > 0x20000 ;
80
57
81
58
readonly gpioPorts = new Set < AVRIOPort > ( ) ;
@@ -89,8 +66,16 @@ export class CPU implements ICPU {
89
66
/* empty by default */
90
67
} ;
91
68
69
+ /**
70
+ * Program counter
71
+ */
92
72
pc : u32 = 0 ;
93
- cycles : u32 = 0 ;
73
+
74
+ /**
75
+ * Clock cycle counter
76
+ */
77
+ cycles = 0 ;
78
+
94
79
nextInterrupt : i16 = - 1 ;
95
80
96
81
constructor ( public progMem : Uint16Array , private sramBytes = 8192 ) {
0 commit comments