@@ -11,33 +11,6 @@ import { avrInterrupt } from './interrupt';
1111
1212const registerSpace = 0x100 ;
1313
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-
4114export type CPUMemoryHook = ( value : u8 , oldValue : u8 , addr : u16 , mask : u8 ) => boolean | void ;
4215export interface CPUMemoryHooks {
4316 [ key : number ] : CPUMemoryHook ;
@@ -66,7 +39,7 @@ interface AVRClockEventEntry {
6639 next : AVRClockEventEntry | null ;
6740}
6841
69- export class CPU implements ICPU {
42+ export class CPU {
7043 readonly data : Uint8Array = new Uint8Array ( this . sramBytes + registerSpace ) ;
7144 readonly data16 = new Uint16Array ( this . data . buffer ) ;
7245 readonly dataView = new DataView ( this . data . buffer ) ;
@@ -76,6 +49,10 @@ export class CPU implements ICPU {
7649 private readonly pendingInterrupts : AVRInterruptConfig [ ] = [ ] ;
7750 private nextClockEvent : AVRClockEventEntry | null = null ;
7851 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+ */
7956 readonly pc22Bits = this . progBytes . length > 0x20000 ;
8057
8158 readonly gpioPorts = new Set < AVRIOPort > ( ) ;
@@ -89,8 +66,16 @@ export class CPU implements ICPU {
8966 /* empty by default */
9067 } ;
9168
69+ /**
70+ * Program counter
71+ */
9272 pc : u32 = 0 ;
93- cycles : u32 = 0 ;
73+
74+ /**
75+ * Clock cycle counter
76+ */
77+ cycles = 0 ;
78+
9479 nextInterrupt : i16 = - 1 ;
9580
9681 constructor ( public progMem : Uint16Array , private sramBytes = 8192 ) {
0 commit comments