Confused about Data Bus behaviour during write cycles
Posted: Thu Feb 26, 2026 10:44 pm
Hello, friends.
I'm working on a 6502 emulator as a hobby project. I've been making much use of the indispensable Visual6502 simulator in this endeavour, which has greatly aided me (along with many other resources including this forum). However, there is one behaviour of the simulator that I don't fully understand, and I was hoping someone here might be able to explain it.
In short, when executing an opcode that has multiple write cycles in succession, such as BRK or JSR pushing the PC (and processor flags, in BRKs case) to the stack, a previous value that was on the databus appears in the first half-cycle of the later write cycles.
As shown in this image, during cycles 9 and 10, the value 0x42 (the next byte after the BRK opcode) appears on the databus again. (If the image is hard to read, here's a link that should load the inputs on the simulator.) As far as I can tell, no internal register or latch (at least, none that Visual6502 exposes as traceable) holds the 0x42 value during the half cycle the bus is being used for writing. The "idl" latch (which I think is the Visual6502 name for one of the latches used for ALU input and not the Input Data Latch from Hanson's diagram?) does hold this value, but that's several cycles too early.
What I suspect is happening is that the Internal Data Latch stores the last read value and it's put on the bus for that half-cycle once the write is finished? If that's the case, does this happen every time, even for read cycles (since I think the behaviour would match)? I can't seem to find any source that explicitly confirms that's what's happening though. The NESdev wiki does say that the DL is put on one of DB/ADH/ADL each Phi1, but the listed datapath node names make reference to the internal data bus instead and, in the simulator, aren't active on the cycles I'm confused about. The Breaking NES 6502 book also says that the "db" the DL/DB datapath node refers to is the internal bus.
I should also say that I'm very much approaching this from a "high-level (i.e. programmer) down" view, since I don't have a particularly strong grasp of electrical engineering (the Visual6502 diagram is very difficult for me to parse, for example), so if the answer would be obvious from a lower-level hardware perspective, I'll have to ask you to humour me.
Thanks in advance for any insight you might have.
I'm working on a 6502 emulator as a hobby project. I've been making much use of the indispensable Visual6502 simulator in this endeavour, which has greatly aided me (along with many other resources including this forum). However, there is one behaviour of the simulator that I don't fully understand, and I was hoping someone here might be able to explain it.
In short, when executing an opcode that has multiple write cycles in succession, such as BRK or JSR pushing the PC (and processor flags, in BRKs case) to the stack, a previous value that was on the databus appears in the first half-cycle of the later write cycles.
As shown in this image, during cycles 9 and 10, the value 0x42 (the next byte after the BRK opcode) appears on the databus again. (If the image is hard to read, here's a link that should load the inputs on the simulator.) As far as I can tell, no internal register or latch (at least, none that Visual6502 exposes as traceable) holds the 0x42 value during the half cycle the bus is being used for writing. The "idl" latch (which I think is the Visual6502 name for one of the latches used for ALU input and not the Input Data Latch from Hanson's diagram?) does hold this value, but that's several cycles too early.
What I suspect is happening is that the Internal Data Latch stores the last read value and it's put on the bus for that half-cycle once the write is finished? If that's the case, does this happen every time, even for read cycles (since I think the behaviour would match)? I can't seem to find any source that explicitly confirms that's what's happening though. The NESdev wiki does say that the DL is put on one of DB/ADH/ADL each Phi1, but the listed datapath node names make reference to the internal data bus instead and, in the simulator, aren't active on the cycles I'm confused about. The Breaking NES 6502 book also says that the "db" the DL/DB datapath node refers to is the internal bus.
I should also say that I'm very much approaching this from a "high-level (i.e. programmer) down" view, since I don't have a particularly strong grasp of electrical engineering (the Visual6502 diagram is very difficult for me to parse, for example), so if the answer would be obvious from a lower-level hardware perspective, I'll have to ask you to humour me.
Thanks in advance for any insight you might have.