6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Sep 20, 2024 6:39 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Mon Nov 13, 2017 1:21 pm 
Offline

Joined: Mon Nov 13, 2017 12:04 pm
Posts: 7
Hello!

I'm sorry if I missed the post that already contains an answer to my question.
I'm wondering what are the hard limits of cycle stealing for 6502, Sally (Atari version of 6502), 6510 and CMOS 6502(that I assume is available as of today)? Such behavior would of course pose a problem for a programmer (leaving him/her almost without cpu cycles), but if we assume that the dma is so powerful/sophisticated that it's worth doing, how far could we go?


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 13, 2017 2:12 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Welcome!

By 'cycle-stealing' it sounds like you mean stalling the CPU while something else has use of memory. I don't see any hardware reason why you couldn't do that indefinitely. What would probably limit you in a realistic system is any realtime nature of the software environment. For example, interrupt latency would be increased, user interfaces might stutter or be perceived as unreliable, audio and video outputs would not be updated. For human interaction, a few tens of milliseconds stutter might be about as much as would be tolerable. For audio output, latency is very important, although I don't have a number for it. (It seems MIDI clocks at around the millisecond level.)


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 13, 2017 6:18 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
Welcome, pokey :)

You need to consider whether the CPU is stopped via the RDY input or via clock stretching.

NMOS members of the 6500 family have a limit to how far the clock can be stretched; this is listed in the data sheet as the maximum pulse width for the clock input -- ie, how slow the CPU clock can be. Exceeding the limit can result in data loss -- the CPU will become unreliable. Anecdotal reports indicate the spec is very conservative, and can be exceeded by a large margin. Nevertheless you can't stretch the clock indefinitely (with NMOS).

Modern WDC 65C02 processors can tolerate indefinite clock stretching. Rockwell and other vintage CMOS chips can also be stopped indefinitely but only with the clock input in the high state. All of this info (except the anecdotal reports :) ) can be found in the pertinent datasheets. For some related background you may find my Visual Guide to 65xx CPU Timing helpful.


For all 6500 CPU's the RDY input can be used to stop operations indefinitely. (Slight exception: with NMOS CPU's RDY won't suspend a write cycle; the CPU will halt on the next read instead.) Of course you'll still need to consider the limitations Ed mentioned.

Do you have a project in mind? We'd be glad to hear about it!

cheers
Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Last edited by Dr Jefyll on Mon Nov 13, 2017 6:28 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 13, 2017 6:19 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
(Very good point about clocking!)


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 13, 2017 7:29 pm 
Offline

Joined: Mon Nov 13, 2017 12:04 pm
Posts: 7
Thank you very much for you responses!

Dr Jefyll wrote:
Do you have a project in mind? We'd be glad to hear about it!

I'm pondering on a design of something like the essentials of 6502-based home computer that could have been made in a400/a800 era. Given that I'm totally clueless when it comes to electronics I'm almost certain that I'll never get it done but still can't stop - it's too much fun. No hardware to speak of at the moment unfortunately - I'm still validating the higher level aspects of the design (bolting the 'chipset emulation' on 6502 emulator and playing with it, e.t.c.)

Dr Jefyll wrote:
You need to consider whether the CPU is stopped via the RDY input or via clock stretching.


If I remember correctly Atari (before Sally) had to go for clock stretching and I don't remember why (my guess is that RDY is leaving the bus in a state they where not happy with, but I really need to look it up)

BigEd wrote:
For example, interrupt latency would be increased, user interfaces might stutter or be perceived as unreliable, audio and video outputs would not be updated.


I intend to place that burden on the programmer (damage control for lost cycles), but I'm planning a really simple system where I beleive it's not very hard to do.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 13, 2017 9:40 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
pokey wrote:
I'm pondering on a design of something like the essentials of 6502-based home computer that could have been made in a400/a800 era.
Cool. So a retro vision, but implemented in FPGA?

pokey wrote:
Given that I'm totally clueless when it comes to electronics I'm almost certain that I'll never get it done but still can't stop - it's too much fun.
Hmm. Reading that, I'm reminded of an entertaining remark from one of the other forum members:
Arlet wrote:
Most progress is made by people underestimating the problem :)


pokey wrote:
If I remember correctly Atari (before Sally) had to go for clock stretching and I don't remember why (my guess is that RDY is leaving the bus in a state they where not happy with, but I really need to look it up)
I'm also unsure, but it could well be because of the "slight exception" I mentioned -- ie, that, with NMOS CPU's, the RDY input won't halt a write cycle. That could be a show-stopper if -- as with video -- timing irregularities can't be tolerated. So, not exactly slight, in those circumstances.

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 13, 2017 10:57 pm 
Offline

Joined: Sun Jul 28, 2013 12:59 am
Posts: 235
Dr Jefyll wrote:
I'm also unsure, but it could well be because of the "slight exception" I mentioned -- ie, that, with NMOS CPU's, the RDY input won't halt a write cycle. That could be a show-stopper if -- as with video -- timing irregularities can't be tolerated. So, not exactly slight, in those circumstances.

If I recall correctly, the most that the CPU will do is three write cycles in a row (for IRQ response). Throwing a small FIFO into the design that will stall the CPU if possible whenever the FIFO is less than full could cover for that scenario (the FIFO will basically always have at least one byte of data ready, so the output timing becomes predictable). That said, this is an off-the-cuff thought, and maybe clock stretching is or was either easier or cheaper.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 14, 2017 7:00 am 
Offline

Joined: Mon Nov 13, 2017 12:04 pm
Posts: 7
Dr Jefyll wrote:
Cool. So a retro vision, but implemented in FPGA?


Honestly, as software (rather than hardware) guy I'd be perfectly happy with just an emulator. However it's no fun unless I keep it within Atari's gate/money limits, and the closest I can get to substantiating that claim is to implement it in FPGA (not just in one chip but rather implementing each chip separately pretending they're in DIP-40 or lesser package) and paying attention to the older chip limits.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 14, 2017 10:25 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Interesting challenge - do post updates!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: