inexpensive FPGA-based 6502 CPU replacement and Disk II emulator

13 replies [Last post]
Offline
Joined: Nov 11 2015
Posts: 13

Hi Folks,

I'm new here. Thought I would stop by and say hi! and tell you all about a project I've been working on. I went looking for a good forum to post this on and found this one. (If there are other Apple II communities where it might be more appropriate to post this, please let me know.)

A few weeks ago, I went looking for an in-circuit emulator/debugger for my trusty old Apple II and stumbled across a project called "ICE-T65"

http://www.stardot.org.uk/forums/viewtopic.php?f=44&t=9655

The hardware is a small FPGA mounted on a 40-pin board that has a similar form-factor to a 6502 processor, and with the right software, can be used as a pin-compatible, plug-in replacement for a 6502. Installation is as simple as popping out the CPU and putting this board in it's place.

The hardware is generic and can be used for many projects. And it costs less than $100.

The magic software that re-creates a 6502 is all open source. David Banks combined a 6502 soft-core (to emulate the 6502) with an Atmel AVR soft-core (to act as a debugger) and wired them up such that the AVR can poke inside the 6502, including breakpoints, watchpoints, register reads, etc.

The debugger is written in C, and the AVR core is the same one used in an Arduindo, so it's easy to program for.

He developed the project for use with an Acorn Atom, but it simulates a real 6502 well enough that I was able to drop it into an Apple //e and have it work out of the box.

Really, really cool to see an Apple II boot up with the cpu removed and replaced with an FPGA. And the hardware backed 6502 debugging is awesome.

I'm a software developer, and I've never done any real hardware development, certainly not working with an FPGA. For me this was an opportunity to learn VHDL and teach myself how to design FPGA code.

My goal then became to add a virtual Disk II interface into the FPGA code. Initially, I was thinking of using an SD card for backing store, but then decided it would be more flexible if I added a network interface and allowed it to boot disk images over the network. (i.e. you can use this to boot a real physical Apple II from a disk image hosted on a web site)

The beginnings of my project are here:

http://www.stardot.org.uk/forums/viewtopic.php?f=3&t=10334

There's been more progress since then. If people are interested, I will follow up with updated information.

Best,
Dan

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Offline
Joined: May 2 2010
Posts: 47
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

very cool Dan, and Hoglet (Dave). See you over on *.

Offline
Joined: Jan 28 2014
Posts: 6
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

That's amazing Dan!

Please keep us posted here as well (I'm not on *.).

Offline
Joined: Nov 11 2015
Posts: 13
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

I've got it basically working now - I've got the GODIL FPGA board plugged into the CPU socket and it exposes a 2-wire serial port which acts as a console. I also exposed a 6-wire SPI bus which is connected to an Arduino W5200 daugherboard, thus providing the network interface.

You can enter a URL at the console command prompt and it will do a DNS lookup and then connect via HTTP to the requested server.

For example, one of the first URLs I successfully booted from was:

http://mirrors.apple2.org.za/ftp.apple.asimov.net/images/games/action/mario_bros.dsk

It emulates enough of a Disk II to detect what track is being accessed and when a disk read is occurring and downloads each track on-the-fly as needed into an 8K buffer.

So far, it can handle .DSK, .DO, and .NIB files.

The code is in reasonable enough shape that I could probably post it if someone wanted to give it a try, but the big catch is that it requires the larger of the two GODILs (a $10 difference), which is unfortunately, currently out of stock.

http://shop.trenz-electronic.de/en/TE0261-00B-GODIL40_XC3S500E-DIL-FPGA-module-40-pin-DIL

I'm in the process of refactoring it to act as a true peripheral, rather than a CPU replacement. Essentially splitting out the Disk II emulator from the ICE functionality so that I can mount the GODIL on a peripheral card and use it as a stand-alone Disk II emulator.

Hopefully, by doing that, I can also shrink it down to fit on the smaller GODIL, which seems to be more available...

Offline
Joined: Nov 11 2015
Posts: 13
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

I've split this up into two phases:

1. Shrink the code to fit on the smaller FPGA (250K elements)
2. Figure out how to mount it on a peripheral card instead of using the CPU socket

So far, I've accomplished #1 by removing the ICE functionality. That functionality wouldn't work when running from a peripheral card anyway, so this was a necessary step, and nicely allows everything to fit inside the smaller part.

Looks like the larger part (500K) is back in stock now as well. I would definitely recommend getting that one since it's only ~$10 more, but the smaller one (250K) should work as well.

Offline
Joined: Nov 11 2015
Posts: 13
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

BTW, here's the parts list:

1. A 40-pin GODIL FPGA board (either 250K or 500K sized)
2. An Arduino W5200 ethernet shield
3. 6 jumper wires to connect the two boards
4. 5v Serial to USB adapter

I haven't yet found a good way to mount it on a peripheral board, so I'm still pondering how to do this. I've never had a board manufactured before, but I'm thinking this might be what is required. (If anyone has experience with this, I'd love to chat about it.)

The good news is that the CPU replacement version works great in the mean time. And it is very simple to install. Smile

If anyone wants to give it a try, I can walk you through the steps of wiring it all up as well as supply the code to program it with...

Offline
Joined: Nov 11 2015
Posts: 13
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

twopaddle wrote:

That is very very cool! I'm impressed. If you get to the point where you have it on an interface card, sign me up! Now... if you could come up with a way for it to fake a printer card that would hypothetically deposit printer output files onto a network (maybe with a secondary card and an interconnecting cable between the NIC and the "printer card"??) then you would have truly the ultimate Apple II peripheral. It would allow these old machines to effectively and (sortof usefully!) function on a modern network!

Thanks for the suggestion. I took it as a challenge and implemented basic parallel port emulation. After a bit of debugging, it at least passes a basic Print Shop test.

It needs a server listening on port 9100, which is the standard TCP/IP printer port. I used the netcat tool to set up a simple server on another computer which listens for data on that port and dumps it to a file ("nc -l -p 9100 > printer.txt") then told my DiskII-network device to connect to the server.

Then I booted The Print Shop and went to setup - configuring it for an Apple DMP/ImageWriter and an Apple Parallel Interface.

Then I let it print it's test page.

Which happily created a printer.txt file on the server. Smile

To verify that the printout was valid, I loaded up Adobe Acrobat Distiller and fed it the "IWEM" file from the "System Tools 2" disk of GSOS System 6.0.1. This put Distiller in ImageWriter emulation mode.

I then fed it the printer.txt file, and it dumped out a very nice PDF. Smile

I don't see an obvious way to add an attachment, or I would post the PDF...

Offline
Joined: Nov 11 2015
Posts: 13
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

(BTW, it doesn't require two physical cards. The peripheral cards have access to the whole address bus, so a single physical card can "pretend" it's sitting in multiple slots -- appearing to be in both Slot 6 and Slot 1 at the same time, providing two different functions.)

Offline
Joined: Dec 2 2013
Posts: 27
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

dzenc wrote:

(BTW, it doesn't require two physical cards. The peripheral cards have access to the whole address bus, so a single physical card can "pretend" it's sitting in multiple slots -- appearing to be in both Slot 6 and Slot 1 at the same time, providing two different functions.)

I did not know that. I had always assumed that there was some address decoding associated with each of the slots, so as to prevent conflicts. Now you really have me intrigued.

Offline
Joined: Dec 2 2013
Posts: 27
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

dzenc wrote:

Thanks for the suggestion. I took it as a challenge and implemented basic parallel port emulation. After a bit of debugging, it at least passes a basic Print Shop test.

It needs a server listening on port 9100, which is the standard TCP/IP printer port. I used the netcat tool to set up a simple server on another computer which listens for data on that port and dumps it to a file ("nc -l -p 9100 > printer.txt") then told my DiskII-network device to connect to the server.

Then I booted The Print Shop and went to setup - configuring it for an Apple DMP/ImageWriter and an Apple Parallel Interface.

Then I let it print it's test page.

Which happily created a printer.txt file on the server. Smile

To verify that the printout was valid, I loaded up Adobe Acrobat Distiller and fed it the "IWEM" file from the "System Tools 2" disk of GSOS System 6.0.1. This put Distiller in ImageWriter emulation mode.

I then fed it the printer.txt file, and it dumped out a very nice PDF. Smile

I don't see an obvious way to add an attachment, or I would post the PDF...

Wow! Now I'm triply impressed. Since you took up my challenge on the printing, I think I'm going to have to take up your challenge on butchering an Apple II to include one of these. That is just too cool.

If you can somehow get it onto a card, include a little software to assist us mortals in selecting disk images and network printers, then I personally think you have the foundation here for the Apple II retro-peripheral of the 2010s!

Offline
Joined: Nov 11 2015
Posts: 13
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

twopaddle wrote:

I had always assumed that there was some address decoding associated with each of the slots, so as to prevent conflicts. Now you really have me intrigued.

There is. You just don't *have* to use it. Wink

twopaddle wrote:

Since you took up my challenge on the printing, I think I'm going to have to take up your challenge on butchering an Apple II to include one of these. That is just too cool.

Cool! Let me know how I can help.

twopaddle wrote:

If you can somehow get it onto a card, include a little software to assist us mortals in selecting disk images and network printers, then I personally think you have the foundation here for the Apple II retro-peripheral of the 2010s!

Yeah, the peripheral part I'm still figuring out, but might need a little help with. I'm hoping someone who has manufactured a board before can give me some pointers...

In terms of general "ease of use," I've been thinking about that as well. Right now, it's not too bad -- along with the (outgoing) print server support I also added (incoming) telnet support. So now you can telnet to the device console instead of using a serial port.

What I now do to load disks is (a) open open a web browser on my PC and point it at a web server that hosts DSK images -- either an asimov mirror on the web, or a web site I'm hosting locally. (b) find the disk I want to mount, right click on it and pick "copy link location..." and then paste that link into the telnet session that I've opened to the DiskII-network device.

It's a bit clunky, but reasonably quick, and using a web browser allows me to easily browse around and select exactly the disk I want to load...

Printing isn't nearly as straightforward.

But yeah, somebody really needs to write an all-in-one PC-side server for this thing. Wink

Offline
Joined: Nov 11 2015
Posts: 13
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

FYI - Shipping cost on the GODIL from Germany to the US is rather expensive. It arrived quickly (2 business days), but still...

I inquired about lower cost shipping options, and this is what they said:

Quote:

We can ship a parcel with German post as well. The price depends on the weight, around 20-40 EUR I would guess. The lead time will be 2-3 weeks.

If you want to change the shipping, please leave a comment in the comment field while ordering.

stynx's picture
Offline
Joined: Apr 19 2012
Posts: 182
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

dzenc wrote:

FYI - Shipping cost on the GODIL from Germany to the US is rather expensive. It arrived quickly (2 business days), but still...
I inquired about lower cost shipping options, and this is what they said:

Quote:

We can ship a parcel with German post as well. The price depends on the weight, around 20-40 EUR I would guess. The lead time will be 2-3 weeks.
If you want to change the shipping, please leave a comment in the comment field while ordering.

That's expensive! I live in Germany and shipping to the US was rather cheap. I cannot really understand the high shipping cost...
The shop prices of the GoDIL are without sales tax. The overall cost is about 20% higher (in Germany) than the shop price for each module.
Shipping was less than 10€ for the 4 modules together that i bought.

-Jonas

Offline
Joined: Nov 11 2015
Posts: 13
Re: inexpensive FPGA-based 6502 CPU replacement and Disk II ...

twopaddle wrote:

If you can somehow get it onto a card, include a little software to assist us mortals in selecting disk images and network printers, then I personally think you have the foundation here for the Apple II retro-peripheral of the 2010s!

So... I got a friend to help me lay out a PCB over the weekend. Well, more than help - I would say he did at least 2/3 of the work.

The end result is a nice Apple II peripheral card which can hold the FPGA and network chip.

And I placed the fab order this morning for 1 prototype unit to test. Smile

This is all very exciting for me - never in my wildest dreams, even as a young kid learning to code on my trusty Apple II, did I ever think I would end up manufacturing an Apple II peripheral card.

The web site says it will arrive towards the end of December. Will keep you guys posted when it gets here...

Best,
Dan