@@ -23,11 +23,10 @@ describe('EEPROM', () => {
2323 describe ( 'Reading the EEPROM' , ( ) => {
2424 it ( 'should return 0xff when reading from an empty location' , ( ) => {
2525 const cpu = new CPU ( new Uint16Array ( 0x1000 ) ) ;
26- const eeprom = new AVREEPROM ( cpu , new EEPROMMemoryBackend ( 1024 ) ) ;
26+ new AVREEPROM ( cpu , new EEPROMMemoryBackend ( 1024 ) ) ;
2727 cpu . writeData ( EEARL , 0 ) ;
2828 cpu . writeData ( EEARH , 0 ) ;
2929 cpu . writeData ( EECR , EERE ) ;
30- eeprom . tick ( ) ;
3130 cpu . tick ( ) ;
3231 expect ( cpu . cycles ) . toEqual ( 4 ) ;
3332 expect ( cpu . data [ EEDR ] ) . toEqual ( 0xff ) ;
@@ -36,12 +35,11 @@ describe('EEPROM', () => {
3635 it ( 'should return the value stored at the given EEPROM address' , ( ) => {
3736 const cpu = new CPU ( new Uint16Array ( 0x1000 ) ) ;
3837 const eepromBackend = new EEPROMMemoryBackend ( 1024 ) ;
39- const eeprom = new AVREEPROM ( cpu , eepromBackend ) ;
38+ new AVREEPROM ( cpu , eepromBackend ) ;
4039 eepromBackend . memory [ 0x250 ] = 0x42 ;
4140 cpu . writeData ( EEARL , 0x50 ) ;
4241 cpu . writeData ( EEARH , 0x2 ) ;
4342 cpu . writeData ( EECR , EERE ) ;
44- eeprom . tick ( ) ;
4543 cpu . tick ( ) ;
4644 expect ( cpu . data [ EEDR ] ) . toEqual ( 0x42 ) ;
4745 } ) ;
@@ -51,13 +49,12 @@ describe('EEPROM', () => {
5149 it ( 'should write a byte to the given EEPROM address' , ( ) => {
5250 const cpu = new CPU ( new Uint16Array ( 0x1000 ) ) ;
5351 const eepromBackend = new EEPROMMemoryBackend ( 1024 ) ;
54- const eeprom = new AVREEPROM ( cpu , eepromBackend ) ;
52+ new AVREEPROM ( cpu , eepromBackend ) ;
5553 cpu . writeData ( EEDR , 0x55 ) ;
5654 cpu . writeData ( EEARL , 15 ) ;
5755 cpu . writeData ( EEARH , 0 ) ;
5856 cpu . writeData ( EECR , EEMPE ) ;
5957 cpu . writeData ( EECR , EEPE ) ;
60- eeprom . tick ( ) ;
6158 cpu . tick ( ) ;
6259 expect ( cpu . cycles ) . toEqual ( 2 ) ;
6360 expect ( eepromBackend . memory [ 15 ] ) . toEqual ( 0x55 ) ;
@@ -84,10 +81,10 @@ describe('EEPROM', () => {
8481
8582 const cpu = new CPU ( program ) ;
8683 const eepromBackend = new EEPROMMemoryBackend ( 1024 ) ;
87- const eeprom = new AVREEPROM ( cpu , eepromBackend ) ;
84+ new AVREEPROM ( cpu , eepromBackend ) ;
8885 eepromBackend . memory [ 9 ] = 0x0f ; // high four bits are cleared
8986
90- const runner = new TestProgramRunner ( cpu , eeprom ) ;
87+ const runner = new TestProgramRunner ( cpu ) ;
9188 runner . runInstructions ( instructionCount ) ;
9289
9390 // EEPROM was 0x0f, and our program wrote 0x55.
@@ -98,22 +95,20 @@ describe('EEPROM', () => {
9895 it ( 'should clear the EEPE bit and fire an interrupt when write has been completed' , ( ) => {
9996 const cpu = new CPU ( new Uint16Array ( 0x1000 ) ) ;
10097 const eepromBackend = new EEPROMMemoryBackend ( 1024 ) ;
101- const eeprom = new AVREEPROM ( cpu , eepromBackend ) ;
98+ new AVREEPROM ( cpu , eepromBackend ) ;
10299 cpu . writeData ( EEDR , 0x55 ) ;
103100 cpu . writeData ( EEARL , 15 ) ;
104101 cpu . writeData ( EEARH , 0 ) ;
105102 cpu . writeData ( EECR , EEMPE | EERIE ) ;
106103 cpu . data [ SREG ] = 0x80 ; // SREG: I-------
107104 cpu . writeData ( EECR , EEPE ) ;
108105 cpu . cycles += 1000 ;
109- eeprom . tick ( ) ;
110106 cpu . tick ( ) ;
111107 // At this point, write shouldn't be complete yet
112108 expect ( cpu . data [ EECR ] & EEPE ) . toEqual ( EEPE ) ;
113109 expect ( cpu . pc ) . toEqual ( 0 ) ;
114110 cpu . cycles += 10000000 ;
115111 // And now, 10 million cycles later, it should.
116- eeprom . tick ( ) ;
117112 cpu . tick ( ) ;
118113 expect ( eepromBackend . memory [ 15 ] ) . toEqual ( 0x55 ) ;
119114 expect ( cpu . data [ EECR ] & EEPE ) . toEqual ( 0 ) ;
@@ -123,16 +118,14 @@ describe('EEPROM', () => {
123118 it ( 'should skip the write if EEMPE is clear' , ( ) => {
124119 const cpu = new CPU ( new Uint16Array ( 0x1000 ) ) ;
125120 const eepromBackend = new EEPROMMemoryBackend ( 1024 ) ;
126- const eeprom = new AVREEPROM ( cpu , eepromBackend ) ;
121+ new AVREEPROM ( cpu , eepromBackend ) ;
127122 cpu . writeData ( EEDR , 0x55 ) ;
128123 cpu . writeData ( EEARL , 15 ) ;
129124 cpu . writeData ( EEARH , 0 ) ;
130125 cpu . writeData ( EECR , EEMPE ) ;
131126 cpu . cycles = 8 ; // waiting for more than 4 cycles should clear EEMPE
132- eeprom . tick ( ) ;
133127 cpu . tick ( ) ;
134128 cpu . writeData ( EECR , EEPE ) ;
135- eeprom . tick ( ) ;
136129 cpu . tick ( ) ;
137130 // Ensure that nothing was written, and EEPE bit is clear
138131 expect ( cpu . cycles ) . toEqual ( 8 ) ;
@@ -143,15 +136,14 @@ describe('EEPROM', () => {
143136 it ( 'should skip the write if another write is already in progress' , ( ) => {
144137 const cpu = new CPU ( new Uint16Array ( 0x1000 ) ) ;
145138 const eepromBackend = new EEPROMMemoryBackend ( 1024 ) ;
146- const eeprom = new AVREEPROM ( cpu , eepromBackend ) ;
139+ new AVREEPROM ( cpu , eepromBackend ) ;
147140
148141 // Write 0x55 to address 15
149142 cpu . writeData ( EEDR , 0x55 ) ;
150143 cpu . writeData ( EEARL , 15 ) ;
151144 cpu . writeData ( EEARH , 0 ) ;
152145 cpu . writeData ( EECR , EEMPE ) ;
153146 cpu . writeData ( EECR , EEPE ) ;
154- eeprom . tick ( ) ;
155147 cpu . tick ( ) ;
156148 expect ( cpu . cycles ) . toEqual ( 2 ) ;
157149
@@ -161,7 +153,6 @@ describe('EEPROM', () => {
161153 cpu . writeData ( EEARH , 0 ) ;
162154 cpu . writeData ( EECR , EEMPE ) ;
163155 cpu . writeData ( EECR , EEPE ) ;
164- eeprom . tick ( ) ;
165156 cpu . tick ( ) ;
166157
167158 // Ensure that second write didn't happen
@@ -173,21 +164,19 @@ describe('EEPROM', () => {
173164 it ( 'should write two bytes sucessfully' , ( ) => {
174165 const cpu = new CPU ( new Uint16Array ( 0x1000 ) ) ;
175166 const eepromBackend = new EEPROMMemoryBackend ( 1024 ) ;
176- const eeprom = new AVREEPROM ( cpu , eepromBackend ) ;
167+ new AVREEPROM ( cpu , eepromBackend ) ;
177168
178169 // Write 0x55 to address 15
179170 cpu . writeData ( EEDR , 0x55 ) ;
180171 cpu . writeData ( EEARL , 15 ) ;
181172 cpu . writeData ( EEARH , 0 ) ;
182173 cpu . writeData ( EECR , EEMPE ) ;
183174 cpu . writeData ( EECR , EEPE ) ;
184- eeprom . tick ( ) ;
185175 cpu . tick ( ) ;
186176 expect ( cpu . cycles ) . toEqual ( 2 ) ;
187177
188178 // wait long enough time for the first write to finish
189179 cpu . cycles += 10000000 ;
190- eeprom . tick ( ) ;
191180 cpu . tick ( ) ;
192181
193182 // Write 0x66 to address 16
@@ -196,7 +185,6 @@ describe('EEPROM', () => {
196185 cpu . writeData ( EEARH , 0 ) ;
197186 cpu . writeData ( EECR , EEMPE ) ;
198187 cpu . writeData ( EECR , EEPE ) ;
199- eeprom . tick ( ) ;
200188 cpu . tick ( ) ;
201189
202190 // Ensure both writes took place
@@ -226,10 +214,10 @@ describe('EEPROM', () => {
226214
227215 const cpu = new CPU ( program ) ;
228216 const eepromBackend = new EEPROMMemoryBackend ( 1024 ) ;
229- const eeprom = new AVREEPROM ( cpu , eepromBackend ) ;
217+ new AVREEPROM ( cpu , eepromBackend ) ;
230218 eepromBackend . memory [ 9 ] = 0x22 ;
231219
232- const runner = new TestProgramRunner ( cpu , eeprom ) ;
220+ const runner = new TestProgramRunner ( cpu ) ;
233221 runner . runInstructions ( instructionCount ) ;
234222
235223 expect ( eepromBackend . memory [ 9 ] ) . toEqual ( 0xff ) ;
0 commit comments