6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Nov 12, 2024 10:03 am

All times are UTC




Post new topic Reply to topic  [ 558 posts ]  Go to page Previous  1 ... 16, 17, 18, 19, 20, 21, 22 ... 38  Next
Author Message
 Post subject: Re: TTL 6502 Here I come
PostPosted: Wed Aug 02, 2017 2:45 am 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Dr Jefyll wrote:
But now you're getting distracted with new hardware!? :wink:
Yeah, I know, :lol: but just look at all the fun we're having! :wink:

Quote:
It'd be better to increase the address setup time seen by the peripheral by having the OE and WE pulses endure for only half of the 2-cycle period.
Sold! Love your circuit.

The whole question of the right split between address setup time and pulse width is key ...

Address Setup time is quoted as 10ns for SC26C92 UART, whereas the minimum pulse width is fully 70ns! By those figures, it seems favouring the pulse width in the tradeoff may be best here. At 20MHz, a 25/75 split feels just right (100ns cycle with a wait-state), especially considering how quickly the WDC 65C02 gets an address on the bus. But the TTL CPU is much slower on that score. It takes 21ns for it to produce an address (in theory that is) and it really needs the additional setup time that a 50/50 split affords. However, that ratio likely would put the pulse width offside for the UART (I know the UART works with a 62.5ns pulse, but 50ns seems like a stretch). I need a 50/75 split :mrgreen:

Quote:
But I'd be happier if it also allowed extra time after OE and WE go false.
Me too! An extra half-cycle would be just great ...

GARTHWILSON wrote:
I'd recommend putting a 22pF capacitor across that resistor
Does "across" mean "in parallel with" in this context?

ttlworks wrote:
Downside of this approach is, that there _always_ would have to be a wait state for generating the PHI2' signal, even if the CPU is running at 1MHz in "slow mode".
Currently, a wait state is only generated by the SBC if it's on the FAST clock. I think I can do the same when using RDY by adding a gate on the enable signal of the wait-state circuit. There is also a jumper which disables wait-states altogether when running with slower oscillators.

Quote:
But the only peripheral which needs /OE and /WE generated from PHI2' is the UART.
Yes! That little chip sure brings lots of subtleties along :)

Quote:
If everything but the RAM would have a wait state, the 6522\6526 would have a wait state, too... and I think this would generate two successive read cycles (or write cycles) to the same address on the chip. This probably would give us _another_ problem.
Agreed. For sure that's a problem. It's tempting to only invoke the wait state logic for ROM and the UART. After all, the VIA runs just fine at 20MHz now on the SBC. But, that probably changes with the TTL CPU. It will likely violate the required address setup time for the VIA (as mentioned above, the TTL CPU will take 21ns to generate an address, leaving only 4ns setup time at 20MHz. That works for fast RAM, but everything else will probably need a wait state). Maybe the solution is to run the VIA with PHI2/2 all the time if wait states are enabled? That way, it won't double up reads and writes when it's chip select is asserted.

Dwight wrote:
Why not just stall the clock for both the processor and the peripheral.
That's what the SBC does now ... and given all the complications above, I wish I could keep it that way!

But the problem with the current wait-state circuit in the SBC is that it takes too long to trigger (too many gates in series) and by then PHI2 has gone high already. It all works perfectly well at 16MHz with the 65C02. (Funny thing, a wait-state circuit that only works at slower clock rates :roll: :lol:). At 20MHz with the TTL CPU, we only have 4ns after the address is stable to detect and trigger the wait state before the rise of PHI2 - a tall order I think. By contrast, the RDY signal must be brought low only before the fall of PHI2 - plenty of time for that.

Dr Jefyll wrote:
Just stick in an extra half-cycle after OE and WE go false. Of course an entire extra cycle would do the trick, but that's more of a performance hit.
It does seem one potential solution is to go ahead with an RDY wait-state circuit and add a second flip-flop to extend the wait-state to three cycles for the UART, one cycle of address setup and two cycles of pulse width. Or were you suggesting a hybrid approach, using RDY to pause the CPU but the also pausing the clock to stretch the pulse width in the middle of the wait-state?

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Wed Aug 02, 2017 2:56 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8539
Location: Southern California
Drass wrote:
GARTHWILSON wrote:
I'd recommend putting a 22pF capacitor across that resistor
Does "across" mean "in parallel with" in this context?

Yes. One end of the capacitor goes to one end of the resistor, and the other end of the capacitor goes to the other end of the resistor.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Aug 04, 2017 5:42 am 
Offline
User avatar

Joined: Fri Nov 09, 2012 5:54 pm
Posts: 1431
Spent some more thoughts on making use of Jeff's circuitry.

IMHO running the 6522 with PHI2/2 isn't a good idea...
because if we would be (hypothetically spoken) using the SBC later for testing a TTL implementation of the 6526,
we can't test if it would be working at 20 MHz.

I'm attaching a schematic about how I would be trying to build the RDY wait state circuitry "if it would be my project",
the schematic adds wait states for UART and ROM access only:

Attachment:
rdy.png
rdy.png [ 6.96 KiB | Viewed 1400 times ]


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Aug 04, 2017 12:26 pm 
Offline
User avatar

Joined: Fri Nov 09, 2012 5:54 pm
Posts: 1431
Dang !

From the datasheet of the SC26C92C1A UART in the SBC,
it appears that /WE and /RD for that UART have to be active for >70ns !

With the schematic in my posting above...
if the CPU would be runing at 20MHz, /WE and /RD would be active for one cycle, and that's 50ns.

So the UART needs two wait states, and /WE and /RD need to be active in those two wait states.

Fortunately, Jeff did a circuitry for two wait states:

Image


So after modifying my schematic to have two wait states, it looks like this:

Attachment:
rdy2.png
rdy2.png [ 8.98 KiB | Viewed 1373 times ]


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Aug 04, 2017 3:18 pm 
Offline
User avatar

Joined: Fri Nov 09, 2012 5:54 pm
Posts: 1431
Houston, we have a problem.

The W65C22 datasheet says, that address and /CS are supposed to be stable >10ns before the rising edge of PHI2.

If the CPU is running at 20MHz, PHI2 would be low for 25ns.

This gives a setup time for TTL CPU plus address decoder of <15ns after the falling edge of PHI2.

WDC datasheets might be on the conservative side, since there are rumors that a W65C02 could be overclocked to 20MHz.
That's 42.8% more than specified. When considering this for the W65C22 VIA timing:
There might be (in theory) a chance that >7ns before the rising edge of PHI2 might do for the VIA,
what would give CPU plus address decoder a setup time of 18ns after the falling edge of PHI2.

Maybe one would want to check if the TTL CPU works at more than 20MHz,
so we should consider the option to add a wait state for VIA read/write access.

On the other hand, if we would be (hypothetically spoken) trying to build a TTL implementation of the 6526 later,
it would have a setup time relative to the _falling_ edge of PHI2, and that's why we need jumpers to disable that wait state.

IMHO the best trick is to tinker with the VIA /CS signal, so the VIA still can be clocked with PHI2.

A little schematic of what circuitry might be required:

Attachment:
rdy_via.png
rdy_via.png [ 4.98 KiB | Viewed 1358 times ]


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Aug 04, 2017 5:39 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8539
Location: Southern California
ttlworks wrote:
Houston, we have a problem.

The W65C22 datasheet says, that address and /CS are supposed to be stable >10ns before the rising edge of PHI2.

If the CPU is running at 20MHz, PHI2 would be low for 25ns.

This gives a setup time for TTL CPU plus address decoder of <15ns after the falling edge of PHI2.

WDC datasheets might be on the conservative side, since there are rumors that a W65C02 could be overclocked to 20MHz.

WDC says that at room temperature and 5V, the W65C02S will usually top out at 25MHz, although it's not guaranteed to, let alone to meet the timing specs at that speed. But someone here—I don't remember who—recently got it going at 16MHz at 3.3V, twice the specified clock rate for that voltage. Regardless, in all cases, the VIA's register-select, R/W, and chip-select signals have to be valid before phase 2 rises (as ttlworks said above). How long? 3ns? 5ns? 7? All WDC guarantees is that it won't be over 10ns at 5V and across the temperature range; so the way to be absolutely sure it won't fail for lack of setup time is to give it 10ns or more.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Aug 04, 2017 6:26 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
To be pedantic, just because you can overclock the CPU, doesn't mean you can overclock the VIA.


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Aug 04, 2017 7:37 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8539
Location: Southern California
whartung wrote:
To be pedantic, just because you can overclock the CPU, doesn't mean you can overclock the VIA.

Well, overclocking by definition means no guarantees from the manufacturer; but they do give the same graph of possible speed as a function of voltage for both, with the line crossing 25MHz at 5V. The only way to really find out what you can do is to try it. My workbench computer has 4MHz VIAs, and I found no problems below 7MHz clock speed. I did the test with a variable-frequency oscillator, so I could set it at 6.95MHz, 6.99MHz, 7.02MHz, etc. for example, not having to go in increments of what the available crystal oscillators offered.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Aug 04, 2017 7:49 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
GARTHWILSON wrote:
But someone here—I don't remember who—recently got it going at 16MHz at 3.3V, twice the specified clock rate for that voltage.
Is this the post you're thinking of? Windfall seems to being saying the WDC '02 and '816 both are capable of 24 MHz at 3.3V. :shock:

whartung wrote:
To be pedantic, just because you can overclock the CPU, doesn't mean you can overclock the VIA.
Certainly there's no guarantee. But, given that WDC's CPU spec is known to be very conservative, it isn't unreasonable to suppose their VIA spec might also be.

_________________
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  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Aug 04, 2017 8:42 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8539
Location: Southern California
Dr Jefyll wrote:
GARTHWILSON wrote:
But someone here—I don't remember who—recently got it going at 16MHz at 3.3V, twice the specified clock rate for that voltage.
Is this the post you're thinking of? Windfall seems to being saying the WDC '02 and '816 both are capable of 24 MHz at 3.3V. :shock:

Wow, so it's considerably better than I remembered! :o

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Aug 04, 2017 9:21 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Dieter and Jeff, those circuits are great. Certainly MUCH simpler than any of my attempts! Thank you.

GARTHWILSON wrote:
Regardless, in all cases, the VIA's register-select, R/W, and chip-select signals have to be valid before phase 2 rises (as ttlworks said above). How long? 3ns? 5ns? 7? All WDC guarantees is that it won't be over 10ns at 5V and across the temperature range; so the way to be absolutely sure it won't fail for lack of setup time is to give it 10ns or more.
It's interesting to note that decoding the microcode in the TTL CPU costs 8ns to 10ns, which means that opting for Horizontal Microcode might have allowed for the setup time to be at spec. That's water under the bridge now, of course. As it stands, I think I can get an address on the bus in about 19ns, at best (vs. 15ns required to meet the spec). It'll be interesting to see what happens. Either way, including a VIA wait-state circuit in the SBC only makes sense, and it can always be disabled to test things. I like Dieter's idea to delay the onset of the /CS signal to avoid the double reads and writes.

Dr Jefyll wrote:
AFAIK the 'C02 never places a partial address on the bus -- I believe they *did* entirely eliminate that particular misbehavior. In every case where the NMOS chip would've produced a partial address, the CMOS chip will place PC on the bus instead -- I've seen no evidence to contradict this. But this doesn't cover the situation mentioned upthread, namely an indexed STA without a page crossing.
Btw, Jeff, sorry, I forgot to highlight this clarification. I had in fact missed the subtle distinction that the "misbehaviour" has been in fact fixed and that the STA issue is actually another category of problem altogether - unfortunate though it is! Anyway, thanks for clarifying.

_________________
C74-6502 Website: https://c74project.com


Last edited by Drass on Sat Aug 05, 2017 12:55 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Fri Aug 04, 2017 10:40 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
Drass wrote:
Anyway, thanks for clarifying.
Thank you for bringing it up, and yes it's another category of problem.

It's well known that an extra cycle during indexing can indicate there's been a carry from the low byte, and this optional, extra cycle is when the complete address will appear. The wrinkle is it's only optional for read instructions (LDA, ADC, CMP etc). For STA -- a write -- the extra cycle always occurs. So, we might have:
  • no extra cycle (indexing without carry: LDA, ADC, CMP etc)
  • the extra cycle that occurs when indexing with a carry (applicable to STA, LDA, ADC, CMP etc)
  • the extra cycle that occurs when indexing without a carry (applicable to STA)
.
In the latter case an NMOS '02 will read from the complete address then (on the extra cycle) write to it. And Drass discovered the 'C02 does the same. It'd be better to read using PC then write to the complete address, but the CMOS fix doesn't extend that far. The fix does kick in with a page crossing. Whereas NMOS reads from the partial address then writes to the complete address, CMOS reads using PC then writes to the complete address.

(There are other categories of extra cycles, of course -- they don't all result from indexing.)

_________________
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  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Wed Aug 23, 2017 2:20 am 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
I finally had a chance to implement the wait-state circuit above on the SBC, and only then did it dawn on me that it will not work with the TTL CPU after all. The problem is that the J-K flip flops require that chip-enable signals be available before the rising edge of PHI2, and that runs into the same issue as before: namely that the TTL CPU takes too long to generate an address and leaves no time for the downstream logic. At 20MHz, the /CS signals just don't get there in time.

But in fact RDY doesn't have to go low until just before the falling edge of PHI2 in order to take effect, so there is considerably more time here to react. Kicking the issue around with dr Jefyll and ttlworks produced the following alternative circuit:
Attachment:
RDY.png
RDY.png [ 5.7 KiB | Viewed 1207 times ]
Notice in the timing diagrams that the /CS signal can arrive after the rise of PHI2, and the circuit allows it to continue through the OR-gate to bring RDY low in time to pause the CPU. The flip-flop then looks after bringing RDY high again in the subsequent cycle. As expected, a two-cycle version of the circuit chains two flip-flops together, and we can generate the delayed /RD and /WE signals for the UART just as before.

Similarly, the CE signal for the VIA can be delayed also as before to prevent spurious reads or writes to that chip. ROM presents no issue in this regard, but we do have to be careful with writes to RAM. Fortunately, the TTL CPU does supply a valid address just prior to the rise of PHI2 and the setup time for RAM is mercifully short. In addition, the single gate-delay between PHI2 and /WE provides a little additional comfort in this respect. All told, I'm fairly certain no writes to RAM can occur with an invalid address. Even so, fingers are firmly crossed on all this. The hope is that if the TTL CPU can actually manage 20MHz, it will do so with all supporting ICs fully functional. :)

Below is the circuit as adapted to the SBC, using just an additional 74AC32 and a 74AC175 to make it work. I've now run a couple of tests with the 65C02 on a breadboard and finished re-routing the SBC. (Incidentally, my only evidence that the RDY circuit works correctly is that I observed A15 cycling every ~32.5ms with the data bus fixed at $A9 and a 2MHz clock - 65,536 addresses at 500ns each - and then saw the interval double with single wait-states engaged. Not exactly proof, but it'll have to do). I also took the opportunity in passing to rewire the RS-232 ports as DTE ports and also made sure /OE is qualified by PHI2 for the UART, among other things.

... and, I'm happy to say, THAT IS THAT - all four cards in this crazy project are now ready for manufacture (REGISTERS, ALU & CU, K-24 and SBC cards). With some luck, I'll be posting a pic of a 4-board panel soon! :shock:

Cheers for now,
Drass


Attachments:
RDY_SBC.png
RDY_SBC.png [ 42.29 KiB | Viewed 1207 times ]

_________________
C74-6502 Website: https://c74project.com
Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Sat Aug 26, 2017 12:50 am 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Dr Jefyll wrote:
ttlworks wrote:
@Garth:
Resistor with a 22pF capacitor in parallel sounds good.
The question now is: how big the resistor should be to make sure that the WAI instruction still works.
Hmm, if the capacitor is included then the resistor value is not so critical. I'm beginning to think this needs more thought (ie; a low value is still desirable). But without the cap you'd definitely want the resistor value to be quite low -- low enough to charge the capacitance of the RDY pin within the time available.
Just wanted to share the results of some testing I did as a follow-up to this in case others find it helpful. As I understand, this is a bit of a Goldilocks affair; we're looking for a resistor value that's not to high and not too low.

In my testing, I connected a pull-up resistor to simulate external circuitry holding RDY high and then triggered a WAI instruction on the WDC 65C02. Measuring on the RDY pin, I found a WAI instruction is able to pull RDY low even with very low resistor values for the pull-up. 220 Ohms seems to be the threshold. That is, RDY sits just at 1.35V when the CPU is in a WAI state and the RDY pin is being pulled high through a 220 Ohm resistor. A 470 Ohm resistor allows RDY to be pulled by WAI down to 0.6V while a 2k2 Ohm resistor allows RDY to go to 0.13V.

So, I think this says that a 470 Ohm resistor is high enough to make sure WAI still works. The question is whether it's also sufficiently low to make sure the wait-state circuitry can pull RDY low quickly when it needs to. I'm not sure how to figure out the time constants involved here. For reference, the wait-state circuit will need to pull RDY low in less than about 15ns for things to work well (assuming 20MHz operation and 7ns setup time for RDY). I gotta believe that's a comfortable margin in this instance.

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
 Post subject: Re: TTL 6502 Here I come
PostPosted: Sat Aug 26, 2017 3:42 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8482
Location: Midwestern USA
Drass wrote:
In my testing, I connected a pull-up resistor to simulate external circuitry holding RDY high and then triggered a WAI instruction on the WDC 65C02.

Why are you making this so difficult? Use a small signal Schottky diode to isolate RDY from whatever is connected to it, along with a suitable pullup resistor in the 2.2K to 3.3K range.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 558 posts ]  Go to page Previous  1 ... 16, 17, 18, 19, 20, 21, 22 ... 38  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 0 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: