Breaks Debugger + 6502 Simulator on gate level

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

Breaks Debugger + 6502 Simulator on gate level

Post by org »

After many years of research and experiments I think it is time to present you the result - the 6502 simulator (or emulator) on the gate level - Breaks Debugger.

https://github.com/emu-russia/breaks/re ... s-debug-17

(If you're interested you can read the development history of previous versions there)

The Debugger consists of two parts - GUI in c# to display the internals of the processor and native code in c++ which contains the actual emulation of the processor. When you click on the "Step" button, the processor performs one half-cycle and the GUI shows you what's there. The debugger also includes a simple assembler that compiles a 64 Kbyte memory blob at once.

The data flow diagram for the lower part with slight modifications is taken from the dissection of 6502 by ttlworks. Thanks ttlworks! :)

It is possible to dump the internals as Markdown with pictures, for this you need to create a folder WikiMarkdown, where results will be stored.

An example of what results can be seen here: https://github.com/emu-russia/breaks/bl ... /ops/A2.md

Source code of the 6502 emulator here: https://github.com/emu-russia/breaks/tr ... /M6502Core
Attachments
BreaksDebug_17.zip
(712.42 KiB) Downloaded 90 times
149550095-053e9276-df3b-4868-b8d4-b5987c47209a.png
148691773-e7dbd64a-8067-41f2-82c5-94662ee20311.png
Last edited by org on Fri Jan 21, 2022 5:26 pm, edited 3 times in total.
6502 addict
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaks Debugger + 6502 Simulator on gate level

Post by org »

Fixed the emulation of the tricky S register.

https://github.com/emu-russia/breaks/re ... s-debug-15
6502 addict
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Breaks Debugger + 6502 Simulator on gate level

Post by BigEd »

It was a great joy to see how the 6502 uses S as a temporary during JSR!
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaks Debugger + 6502 Simulator on gate level

Post by org »

https://github.com/emu-russia/breaks/re ... s-debug-16

All 6502 instructions are now executed correctly.
6502 addict
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaks Debugger + 6502 Simulator on gate level

Post by org »

UnitTest Mode

To run the debugger in unit test mode, you need to create a JSON like this:

Code: Select all

json
{
	"CompileFromSource": true,
	"MemDumpInput": "mem.bin",
	"AsmSource": "Test.asm",
	"RamStart": "0",
	"RamSize": "0x800",
	"RomStart": "0xc000",
	"RomSize": "0x4000",
	"RunUntilBrk": true,
	"RunCycleAmount": true,
	"CycleMax": 10000,
	"DumpMem": true,
	"JsonResult": "res.json",
	"MemDumpOutput": "mem2.bin"
}
And run with parameter:

Code: Select all

BreaksDebugger Test.json
As input code, you can use 64 Kbytes memory dump (MemDumpInput) or assembly language source (AsmSource).

Simulator will run until it encounters instruction `BRK` (RunUntilBrk) or specified number of cycles (RunCycleAmount, CycleMax) (These are cycles, not half-cycles).

The output will be a memory dump after simulation (MemDumpOutput) and JSON with simulation results (JsonResult).
6502 addict
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaks Debugger + 6502 Simulator on gate level

Post by org »

The M6502Core is tested in the Nintendulator:

https://github.com/emu-russia/breaks/re ... s-debug-17
6502 addict
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Breaks Debugger + 6502 Simulator on gate level

Post by BigEd »

Oh, do I take it you found a couple of bugs not spotted by Klaus Dormann's test?
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaks Debugger + 6502 Simulator on gate level

Post by org »

Thanks for the tip, I'll check them out too!
6502 addict
User avatar
org
Posts: 201
Joined: 22 Jun 2012
Contact:

Re: Breaks Debugger + 6502 Simulator on gate level

Post by org »

All functional tests of the 6502 by Klaus Dormann are successful.

I ran the unit test with these parameters:

Code: Select all

{
	"CompileFromSource": false,
	"MemDumpInput": "6502_functional_test.bin",
	"AsmSource": "Test.asm",
	"RamStart": "0",
	"RamSize": "0x8000",
	"RomStart": "0xc000",
	"RomSize": "0x4000",
	"RunUntilBrk": false,
	"RunCycleAmount": true,
	"CycleMax": 120000000,
	"RunUntilPC": true,
	"PC": "0x3469",
	"TraceMemOps": false,
	"TraceCLK": true,
	"DumpMem": true,
	"JsonResult": "res.json",
	"MemDumpOutput": "mem_out.bin"
}
The original image was slightly patched (RESET = 0x0400).

The state of the registers and the CLK on the output:

Code: Select all

{"A":"0xF0","X":"0x0E","Y":"0xFF","S":"0xFF","PC":"0x3469","C":1,"Z":0,"I":0,"D":0,"V":1,"N":1,"CLK":96241361}
Attachments
reset_patch.jpg
page_2.jpg
page_0.jpg
6502 addict
Post Reply