Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Arduino-based 1541 emulator. Possible?
2013-04-22 10:47
Flavioweb

Registered: Nov 2011
Posts: 463
Arduino-based 1541 emulator. Possible?

Talking about Arduino with an hw-hacker father of a friend, i started to thinking about on how to build a full-compatible 1541 clone (6510, cia, ram, etc...) using Arduino hw.
I found this 6502 emulator:
http://www.df.lth.se/~richard/6502emu2.pde

May be possible to build a full sd card reader fully 1541 compatible (for low level drive programming)?
2013-04-22 11:51
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
anything is possible, if the Arduino has possibility for interfacing to the C64. (user/serial ports)

i suspect it has not, and you have to solder a usb interface to the c64 no ?
2013-04-22 13:12
lft

Registered: Jul 2007
Posts: 369
Quoting Flavioweb

I found this 6502 emulator:
http://www.df.lth.se/~richard/6502emu2.pde


This 6502 emulator is not cycle-exact. You would probably have to write a 6502 emulator in assembly language. This could very well be possible on a 20 MHz AVR, but don't forget you also have to emulate four 16-bit latched timers that are updated every microsecond.

SIDwave: Whatever the problem is, it's not the electrical interfacing.
2013-04-22 13:13
Fierman

Registered: Feb 2002
Posts: 85
interfacing is the least of your problems. timing and speed are, and you can just forget about using an older atmel based arduino for this purpose. it won't do.
2013-04-22 17:55
Krill

Registered: Apr 2002
Posts: 2980
I also doubt that it's possible at all with 20 MHz.
There will be lots of issues concerning updating all internal state (as lft said) while operating in a very tight serial input-to-output response time frame.
We're talking about less than 20 AVR cycles per 6502 cycle for emulation of not only the 6502 but also a few other chips and glue logic here.
Better go for something faster.
2013-04-22 18:49
chatGPZ

Registered: Dec 2001
Posts: 11386
<Post edited by chatGPZ on 22/4-2013 21:19>

ppl have tried it with faster (100mhz) embedded systems - with little success. the problem is that the timing must be cycle exact in relation to the "outside world" - which is close to unpossible unless you have virtually "unlimited" resources.

or if you just want to hear that it can be done, easily - ask jim drew on lemon =)
2013-04-22 18:50
WVL

Registered: Mar 2002
Posts: 902
I've got some experience with AVR's and there's no way you could do an emulation of the 1541 hardware on an Arduino (with AVR chips). You could probably do an IEC emulation and support generic load/save/getbyte commands, but that would be about all. Another problem is the amount of memory that's available : the Nano and Uno only have 2KB of memory, the Mega still only has 32KB... Having no memory means you have to read really fast from SD at the same time when you have to be really precise with your timing to communicate with your 64, impossible.

I even doubt it would be possible with the new Due that has a cortex M3 @ 84MHz, and that one also only has 96KB, still not even close enough to hold a single .d64..

Forget it.

It's not for nothing that the ultimate and chamelon are FPGA based..
2013-04-22 19:05
Krill

Registered: Apr 2002
Posts: 2980
Quoting Groepaz
the timing must be cycle exact in relation to the "outside world" - which is close to unpossible unless you have virtually "unlimited" resources.

This sounds a bit funny. Care to elaborate?
2013-04-22 19:24
chatGPZ

Registered: Dec 2001
Posts: 11386
"This sounds a bit funny. Care to elaborate?"
just a failed attempt to say "We're talking about less than 20 AVR cycles per 6502 cycle for emulation of not only the 6502 but also a few other chips and glue logic here. Better go for something faster." :=)

PS: http://www.forum64.de/wbb3/board65-neue-hardware/board284-masse..
2013-04-22 19:53
Skoe
Account closed

Registered: Jan 2008
Posts: 34
I started to do it with an XMOS at about 400 MIPS shared among 8 Hardware-Threads some years ago (This one: XS1-L6A-64-TQ48). It was a mixture of C Code and Assembly. The I/O-Timing was sub-cycle accurate (+/- 100 ns AFAIR, compared with a logic analyzer to the real thing) and many fast loaders worked already. But only the ones that used the subset of the VIAs I implemented ;)

When I started another refactoring of my code I lost the patience and suspended the project - possibly forever.

What I can say today: I used less than 50% of the processing power and the code wasn't well optimized. So it is quite sure that it is doable on that controller. But I am sure it is not possible on < 100 MIPS with a compatibility of e.g. a 1541U. Today I think the cheapest solution that would be no pain in the ass to implement (compared to the evilness of sub-µs realtime on a controller) with > 99% compatibility could be based on a low-cost ARM controller (e.g. LPC13xx) for high-level tasks and a very small FPGA for CPU/VIAs/Head etc.

But as there is the 1541U/Chameleon for high compatibility and the sd2iec/arm2iec for low cost I'm not interested in another solution anymore.
2013-04-22 20:22
Krill

Registered: Apr 2002
Posts: 2980
Quoting Groepaz
if you just want to hear that it can be done, easily - ask jim drew on lemon =)

Trying to ignore that guy, he uses to claim having done all sorts of drive feats but _always_ fails to deliver code or details, taking forever to find lost source codes etc.
2013-04-22 20:50
Moloch

Registered: Jan 2002
Posts: 2928
Quote: Quoting Groepaz
if you just want to hear that it can be done, easily - ask jim drew on lemon =)

Trying to ignore that guy, he uses to claim having done all sorts of drive feats but _always_ fails to deliver code or details, taking forever to find lost source codes etc.


yes, thats the reason groepaz left that smiley :D

that guy can't be believed for anything
2013-04-24 12:32
Radiant

Registered: Sep 2004
Posts: 639
Would it be possible on a Raspberry Pi?
2013-04-25 07:43
Krill

Registered: Apr 2002
Posts: 2980
The problem with bigger systems like the Raspberry Pi is that you have to jump through a few hoops to get reliable real-time behaviour. The main issues are the cache and variable timing due to DRAM access. The ARM CPUs used though should have scratchpad memory in the order of 32 or so kB for fast deterministic access. Might be possible, but it won't be easy. There might be more surprises on the GPIO path. Good idea though to suggest Raspberry Pi.
2013-04-25 15:18
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
and i must repeat myself: you need interface to C64. usb/par port, else forget this!
2013-04-25 17:39
WVL

Registered: Mar 2002
Posts: 902
The new beaglebone would probably be better, but realtime stuff will still be a problem...

Better stick to a combination of an AVR/Atmel/whatever cpu for high-level non-realtime stuff and an FPGA for the realtime hardware emulation imho..
2013-04-25 18:31
chatGPZ

Registered: Dec 2001
Posts: 11386
just wait for jim to prove you wrong, all of you!
2013-04-25 18:37
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: and i must repeat myself: you need interface to C64. usb/par port, else forget this!

Most (all) embedded platforms have GPIOs, you need 3 (data, clk, atn) + some buffers and level converters. Now drop it, compared to timing problems HW interfacing is nothing.
2013-04-26 15:32
CreaMD

Registered: Dec 2001
Posts: 3057
So if I get it right, for emulation you need precisely definable logic with exact controllable timing at all times. And this is the reason why 1541 emulation was never mad on PC, because there is no possibility to have 100% control over timing, even when booting into dos (coz every machine ha different specs and speeds of ram.. and various idiotic processor hacks for instruction fetching and all that crap.

hm?
2013-04-26 15:55
JackAsser

Registered: Jun 2002
Posts: 2014
You can do it on x86. With fast enough CPU and an RTOS guaranteeing CPU time etc. Or by doing your stuff in DOS/BIOS and disable instruction and memory caches to get complete control over timing. Fast enough CPU using a high precision timer would suffice. But in a "normal" OS environment like Windows, Linux or Mac OS the timing will be too jittery. You might be able to do it by scheduling a timer interrupt at a really high priority as a kernel driver/module.
2013-04-26 16:01
CreaMD

Registered: Dec 2001
Posts: 3057
Jackasser.. thanx.
2013-04-26 17:33
WVL

Registered: Mar 2002
Posts: 902
I think something like this :

http://www.adafruit.com/products/451

plus an arduino with an LCD (for selecting .d64) and SD reader could make a nice 1541 emulator
2013-04-26 17:49
tlr

Registered: Sep 2003
Posts: 1790
Quoting WVL
I think something like this :

http://www.adafruit.com/products/451

plus an arduino with an LCD (for selecting .d64) and SD reader could make a nice 1541 emulator

That's a tiny FPGA. 22kLE isn't much. and not putting the full drive emulation into the FPGA is probably going to make stuff more complicated. Remember, you still need to act on 1 us events and synchronize that with your cycle exact emulation running asynchronously in software.
It might be cheaper in material costs though, but that only matters in high volumes.
2013-04-26 17:58
WVL

Registered: Mar 2002
Posts: 902
I think the ultimate I doesnt have a lot more logic elements? also the ultimate needs to emulate a cpu in the fpga aswell...

Basically all your arduino/whatever cpu has to do is let the user select an image and transfer it to the FPGA's memory..

Just checked, the ultimate I has about 5500 logic cells, while this cyclone II has 22000! that's 4x more than an ultimate I!
2013-04-26 18:08
tlr

Registered: Sep 2003
Posts: 1790
Quoting WVL
I think the ultimate I doesnt have a lot more logic elements? also the ultimate needs to emulate a cpu in the fpga aswell...

Basically all your arduino/whatever cpu has to do is let the user select an image and transfer it to the FPGA's memory..

Just checked, the ultimate I has about 5500 logic cells, while this cyclone II has 22000! that's 4x more than an ultimate I!

Actually you're right, sorry. I guess I'm just spoilt by more high end ones. ;)
So why not run the full emulation in the FPGA?
2013-04-26 19:01
chatGPZ

Registered: Dec 2001
Posts: 11386
"You might be able to do it by scheduling a timer interrupt at a really high priority as a kernel driver/module."
and thats precisely what openCBM does :)

and i dont think putting parts of the emulation into an FPGA and another part into software is a good idea or would save timer and/or money. once you have all the other chips in the fpga, adding the cpu aswell is least of all problems :)
2013-04-26 19:14
Bitbreaker

Registered: Oct 2002
Posts: 508
There is the 1541 Ultimate. Where's the problem and what did i get wrong? Or do we just urgently need some more flaky ghetto-solutions? :-)
2013-04-26 19:34
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: "You might be able to do it by scheduling a timer interrupt at a really high priority as a kernel driver/module."
and thats precisely what openCBM does :)

and i dont think putting parts of the emulation into an FPGA and another part into software is a good idea or would save timer and/or money. once you have all the other chips in the fpga, adding the cpu aswell is least of all problems :)


Oh does opencbm support custom drivecode? I thought it only implemented iec which more or less is possible to implement in user space since the protocol is clocked. Anyway, cool if it does support custom drive code! :)
2013-04-27 10:59
CreaMD

Registered: Dec 2001
Posts: 3057
Groepaz? So is there chance to have "true drive emulation" on stock PC that way?
2013-04-27 11:44
Kisiel
Account closed

Registered: Jul 2003
Posts: 56
True drive emulation is not possible :)
http://projekt64.filety.net/index.php?dir=UK1541/&file=Level%20..

On this short presentation you can find vectors calculated in drive (UK1541) so this means cortex is enough to have true drive emulation. Old board is only to have IEC bus, VIA is removed.
Have another dream guys :P
2013-04-27 22:09
CreaMD

Registered: Dec 2001
Posts: 3057
Kisiel, I need it explained to me, as to a child. I don't undesrstand what is cortex. And also don't get if you mean that emulation actually is possible on stock PC (without hadware hacks), or not.
2013-04-27 22:34
chatGPZ

Registered: Dec 2001
Posts: 11386
"Oh does opencbm support custom drivecode? I thought it only implemented iec which more or less is possible to implement in user space since the protocol is clocked. Anyway, cool if it does support custom drive code! :)"
not really "custom" (as in not user defined) - but it uploads own drivecode for the "fast" and "warp" type of transfers.
"So is there chance to have "true drive emulation" on stock PC that way?"
sure possible - but not the way you'd possibly want it to be (it'll block the pc)

and "cortex" is the marketing term for a certain ARM core/controller type (similar to what you'll find in many smartphones or netbooks)
2013-04-27 22:42
Kisiel
Account closed

Registered: Jul 2003
Posts: 56
Cortex ????
one of ARM family http://en.wikipedia.org/wiki/ARM_architecture , thumb 2 only, small RAM and ROM.

I don't know what is STOCK PC, you have VICE on "stock PC" and for drive emulation one program for dos.

This topic is about Arduino 1541 emulation (ATmega8, ATmega168, ATmega328, ATmega1280.), so I think it's not possible but is possible on Cortex as I proved in video presentation.
2013-04-28 20:06
CreaMD

Registered: Dec 2001
Posts: 3057
Thanx for explanation Kisiel. I seemed like if you were replying on my post, that's why I asked.
2013-04-28 20:52
Krill

Registered: Apr 2002
Posts: 2980
That video doesn't prove much. Implementing some custom serial protocol is one thing, actually providing full compatibility for all types of disk access, speeders and custom routines another.
That said, i'm not doubting it's possible with an ARM CPU, just that this video feels like those dubious grainy blurred UFO "proof" things.
2013-04-29 01:15
chatGPZ

Registered: Dec 2001
Posts: 11386
hehe, i stopped watching video "proofs" of whatever years ago, although some of them at least have some entertainment value =)
and what krill says :) (actually supporting typical demo stuff is on the easier side of things, as that usually involves async protocolls anyway and thus timing isnt all that important - now try running some copyprotected original games on it =P)
2013-04-29 05:33
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
Maybe the Raspberry Pie is more suited..?

LFT has done a cross development suite for his own use. (asm + tools run on RP, connected to C64)
2013-04-29 07:41
Krill

Registered: Apr 2002
Posts: 2980
Scroll up, Raspberry Pi has already been discussed to some degree.
2013-04-29 12:33
Kisiel
Account closed

Registered: Jul 2003
Posts: 56
its not sd2iec multi protocol emulation. it's cycle exact 6502 core with VIA emulation (4kB RAM,16kB ROM, timers, SOE handling etc). So far no illegal opcodes.it took me half year to code this emu. Now i am working on stage 2, sd to gcr. see new prototype on Silesia Party 7 as other guys.
Thanks for support but topic is Arudinio not UK1541.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Neon Vincent
Endurion
Chrx/Design/Chaos
Matt
Guests online: 111
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.087 sec.