Breaking 6502 apart

Topics pertaining to the emulation or simulation of the 65xx microprocessors and their peripheral chips.
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaking 6502 apart

Post by org »

I try to explain my simulation of whole /NMI pin logic.

Overview:
6502.org wrote:
Image no longer available: http://ogamespec.com/imgstore/whc506de23b60f71.jpg
So I simulate output as follow:

Code: Select all

        b = NOR ( NAND(NOT(NMI_PAD), PHI2), NMI_LATCH);
        NMI_LATCH = NOR ( NAND(NMI_PAD, PHI2), b );
        OUTPUT_LINE = NOT(NMI_LATCH);
(b is temporary value)

I drawn NAND/NOR counterpart of trigger on picture. So I think we need those "~".

As output I'm getting following data:

Code: Select all

L N Ф  L*O
0 0 0 | 0 1
0 0 1 | 0 1
0 1 0 | 0 1
0 1 1 | 1 0
1 0 0 | 0 1
1 0 1 | 0 1
1 1 0 | 0 1
1 1 1 | 1 0
Where :
L - latch value before iteration
N - NMI pin level
Ф - PHI2
L* - latch value after iteration
O - output line

And it even worse, if you try to simulate /IRQ. It has additional PHI1 transfer gate + latch as output. In that case I'm getting only '1's on out.
Attachments
MISC_trans.png
Last edited by org on Fri Oct 05, 2012 6:35 am, edited 1 time in total.
6502 addict
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Breaking 6502 apart

Post by BigEd »

It's not a nor of a NAND: it's a nor of an and.
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaking 6502 apart

Post by org »

Indeed, this is NOR of ANDs, I just checked truth table, thanks ))) Now everything works good )

Transition states of /NMI output line:

Code: Select all

L I Ф |L* O
0 0 0 | 0 1
0 0 1 | 1 0
0 1 0 | 0 1
0 1 1 | 0 1
1 0 0 | 1 0
1 0 1 | 1 0
1 1 0 | 1 0
1 1 1 | 0 1
Transition stated of /IRQ and RES lines (both have additional output static latch):

Code: Select all

L I P |L* O
0 0 0 | 0 1
0 0 1 | 0 1
0 1 0 | 0 1
0 1 1 | 1 1
1 0 0 | 1 0
1 0 1 | 0 0
1 1 0 | 1 0
1 1 1 | 1 0
Simulation can be found here:
http://code.google.com/p/breaks/source/ ... SRC/MISC.c

(I added some convenient macros like NAND / NOR, to increase source code readability)

Also I started my 6502 debugger:
Image
It may look more complicated, than other 6502 debuggers you've seen before :)
6502 addict
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaking 6502 apart

Post by org »

And another thing I want to show you:

http://ogamespec.com/6502/PLA.htm

This is tracing of PLA lines for every opcode on each cycle.
6502 addict
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Breaking 6502 apart

Post by BigEd »

Great stuff!
Have you tried to run your Breaks6502.exe on Linux using WINE? I'm willing to try it if you make the exe available (maybe in a zip file)
Cheers
Ed
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaking 6502 apart

Post by org »

It should run under WINE without any trouble. I'm using plain winapi.

Here:
http://code.google.com/p/breaks/source/ ... runk/Build
6502 addict
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Breaking 6502 apart

Post by BigEd »

Thanks - it does open the front panel and another window! Some but not all checkboxes work, and the Step button causes the clocks to toggle and produces some output on the console. (I don't see anything in the second window)

Code: Select all

$ ./Breaks.exe
Debug console opened
IR unchanged: PHI1=0 / fetch=0

IR unchanged: PHI1=1 / fetch=0

IR unchanged: PHI1=0 / fetch=0

IR unchanged: PHI1=1 / fetch=0
This is a good sign, I think, for Linux users.
Cheers
Ed
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaking 6502 apart

Post by org »

Quote:
Some but not all checkboxes work
Its not ready yet :) I'm going to start simulate random logic soon. Most interesting part of my research )
6502 addict
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Breaking 6502 apart

Post by BigEd »

org wrote:
Its not ready yet :) I'm going to start simulate random logic soon. Most interesting part of my research )
Understood - look forward to more updates!
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaking 6502 apart

Post by org »

Fixed some errors in PCL circuit and completed Program Counter increment logic.

I do not know why PCHS/PCLS registers are get inverted after every PC increment.

For example when PCHS/PCLS=0x1234 incremented, it become 0xEDCA (inverted 0x1235). So if you try to increment it again, without altering PCHS/PCLS it become again 0x1234 (inverted 0xEDCB) :mrgreen:

I guess PCHS/PCLS is additionally inverted somewhere through ADH/ADL bus for example (since PC is connected to ADx bus via some drivers)

PC get incremented when IPC driver become low.
6502 addict
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaking 6502 apart

Post by org »

Completed Predecode logic simulation.

Predecode has two outputs : /TWOCYCLE and /IMPLIED.

Predecode determine whenever instruction takes 2 cycles to execute or it has no operands (implied).

Two-cycles instructions are actually all implied (except push/pull) + ALU operations with immediate operand.

I attached screenshots with list of 2-cycle and implied 6502 instructions.
Attachments
PD_TWOCYCLE.jpg
PD_IMPLIED.jpg
6502 addict
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Breaking 6502 apart

Post by BigEd »

Do you still have the inverting PC problem? I think it must be a bug - I'm pretty sure I've never seen it on visual6502.
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaking 6502 apart

Post by org »

I'm going to research reset sequence, to know more details on PC updating, so it must be fixed.

I cannot detect bug, by looking from inside of PC logic.
6502 addict
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaking 6502 apart

Post by org »

In case you guys remember me, I started my own site for Breaks project:

http://breaknes.com/

And I'm gonna return to 6502 soon, I have some progress to show you )
6502 addict
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Breaking 6502 apart

Post by BigEd »

Very nice - I'm surprised that Icc isn't the best compiler for Intel.

How much 6502 simulation is working now? Can you run short instruction sequences?

Cheers
Ed
Post Reply