BB816 Computer YouTube Series

For discussing the 65xx hardware itself or electronics projects.
User avatar
Sheep64
In Memoriam
Posts: 311
Joined: 11 Aug 2020
Location: A magnetic field

Re: 65C816 Computer YouTube Series

Post by Sheep64 »

Sheep64 on Thu 26 May 2022 wrote:
There is a very minor error in the clock circuit which may cause very infrequent error. I have only learned this by reading all of Advanced FPGA Design by Steve Kilts.
On Fri 15 Jan 2021, I mentioned to jfoucher that I am unnerved about switching clock sources. You provide an example which feels intuitively correct. The best part is that it only switches after both clock sources go high - and, specifically, in the order where the slow clock goes high then the fast clock goes high. That means we never have to consider any other cases, such as clocks in a different phase or clocks going low. It is like a sychro-mesh gearbox for clock frequencies. If I never read Steve Kilts' book, I might have been very inclined to copy your circuit and wonder why I worried about the problem.

However, counter to my intuition, any signal crossing clock domains is potential error and should be checked more thoroughly. This is particularly true if multiple, asynchronous signals are involved. Multiple signals? This is the problem but it is quite minor and may resolve itself. In Speed Select, the Q and /Q outputs of SLOW section of 74HC112 connect to J and K inputs of FAST section of 74HC112. They are always intended to be opposites. Unfortunately, when FAST clocks high, they may be 00 or 11 rather than the intended 01 or 10 due to logic level asymmetry, capacitance, ringing or other cause. In this specific case, the output glitch causes a multiplexer to select one high input rather than the other high input. Therefore, this signal glitch is swallowed by all down-stream logic. Assuming that any latch oscillates or that J or K take precedence in a manner which is not deterministic, this possibly increases the minimum speed ratio between FAST and SLOW to a factor of four plus propagation delay. Maybe. Even with the restricted range of the crystal oscillator and frequency divider (as found in Episode 23! Out now!!! Don't miss it!!!!!), the minimum FAST frequency and the maximum SLOW frequency may be in a dubious range. Even here, you may switch between FAST and SLOW thousands of times without issue or have individual chips with fortunate properties.

This borderline case can be resolved by increasing the resistor or capacitor around 555 to reduce maximum speed of SLOW oscillator, further restricting range of the frequency divider or connecting spare section of 74HC112 to absorb glitchy output. The latter is the standard FPGA double flop technique. Indeed, see clock crossing, think double flop. This is the preferred technique because the second FAST flop is guaranteed to have the intended opposite inputs. Unfortunately, that might extend the minimum speed ratio between FAST and SLOW to a factor of six plus propagation delay. Maybe. To reduce the ratio, I considered connecting one of two 74HC112 FAST inputs to a clock further upstream of the symmetric 74x74 FAST clock. That may or may not do anything useful without creating further awkward cases.

Single stepping can be exempted from a double flop. Glitchy signals are guaranteed not to occur when single stepping because your finger will be on another button when selecting clock source. Pressing two buttons simultaneously is undefined behavoir.

Anyhow, it is easy to be an armchair critic and you have my sympathy that it has taken you two hours per day over one year to get to the fun stuff, like 6522 and keyboard firmware. It doesn't help that the 6502 Forum can be a very harsh audience.
User avatar
akohlbecker
Posts: 282
Joined: 24 Jul 2021
Contact:

Re: 65C816 Computer YouTube Series

Post by akohlbecker »

Hey all, I'm back from holiday and a bout of covid. I'm slowly getting back into recording things, so you can expect the next video in a week or two. Spoiler alert: decided to pause new features and go for a 65C816 breakout board to clean up my breadboards.
Sheep64 wrote:
Sheep64 on Thu 26 May 2022 wrote:
There is a very minor error in the clock circuit which may cause very infrequent error. I have only learned this by reading all of Advanced FPGA Design by Steve Kilts.
On Fri 15 Jan 2021, I mentioned to jfoucher that I am unnerved about switching clock sources. You provide an example which feels intuitively correct. The best part is that it only switches after both clock sources go high - and, specifically, in the order where the slow clock goes high then the fast clock goes high. That means we never have to consider any other cases, such as clocks in a different phase or clocks going low. It is like a sychro-mesh gearbox for clock frequencies. If I never read Steve Kilts' book, I might have been very inclined to copy your circuit and wonder why I worried about the problem.

However, counter to my intuition, any signal crossing clock domains is potential error and should be checked more thoroughly. This is particularly true if multiple, asynchronous signals are involved. Multiple signals? This is the problem but it is quite minor and may resolve itself. In Speed Select, the Q and /Q outputs of SLOW section of 74HC112 connect to J and K inputs of FAST section of 74HC112. They are always intended to be opposites. Unfortunately, when FAST clocks high, they may be 00 or 11 rather than the intended 01 or 10 due to logic level asymmetry, capacitance, ringing or other cause. In this specific case, the output glitch causes a multiplexer to select one high input rather than the other high input. Therefore, this signal glitch is swallowed by all down-stream logic. Assuming that any latch oscillates or that J or K take precedence in a manner which is not deterministic, this possibly increases the minimum speed ratio between FAST and SLOW to a factor of four plus propagation delay. Maybe. Even with the restricted range of the crystal oscillator and frequency divider (as found in Episode 23! Out now!!! Don't miss it!!!!!), the minimum FAST frequency and the maximum SLOW frequency may be in a dubious range. Even here, you may switch between FAST and SLOW thousands of times without issue or have individual chips with fortunate properties.

This borderline case can be resolved by increasing the resistor or capacitor around 555 to reduce maximum speed of SLOW oscillator, further restricting range of the frequency divider or connecting spare section of 74HC112 to absorb glitchy output. The latter is the standard FPGA double flop technique. Indeed, see clock crossing, think double flop. This is the preferred technique because the second FAST flop is guaranteed to have the intended opposite inputs. Unfortunately, that might extend the minimum speed ratio between FAST and SLOW to a factor of six plus propagation delay. Maybe. To reduce the ratio, I considered connecting one of two 74HC112 FAST inputs to a clock further upstream of the symmetric 74x74 FAST clock. That may or may not do anything useful without creating further awkward cases.

Single stepping can be exempted from a double flop. Glitchy signals are guaranteed not to occur when single stepping because your finger will be on another button when selecting clock source. Pressing two buttons simultaneously is undefined behavoir.

Anyhow, it is easy to be an armchair critic and you have my sympathy that it has taken you two hours per day over one year to get to the fun stuff, like 6522 and keyboard firmware. It doesn't help that the 6502 Forum can be a very harsh audience.
That is really interesting stuff, I'm learning a lot thanks for sharing. I will give this a bit of a think.

I do have another design that depends on a 3-way latch going to the 3 select pins of an 8-bit multiplexer, but it does also include 2 flip flops per select bit. So it is maybe vulnerable to this as well, I'll have to check
User avatar
akohlbecker
Posts: 282
Joined: 24 Jul 2021
Contact:

Re: 65C816 Computer YouTube Series

Post by akohlbecker »

Oh and also, I'm putting the backplane project on the backburner for now. I will use my breadboards as a backplane of sorts and do a horizontal build, kind of similar to James Sharman's build. I'm basically under the same constraint as him, namely that a backplane build is not very visual on video. Best to lay the circuits down so you can see everything in a top-down shot!
Then, once the design for v1 is completed, I'll reconsider the final form
User avatar
akohlbecker
Posts: 282
Joined: 24 Jul 2021
Contact:

Re: 65C816 Computer YouTube Series

Post by akohlbecker »

Screenshot 2022-07-07 at 10.05.38.png
So this is what I came up with after reading the double-flop article this morning. Is this what you had in mind?

If SLOW and FAST have synchronized phases so that U5A is triggered too close to the falling edge of FAST, then the setup time of U5B is not met and it could go metastable. This is fine because it has up to the period of FAST minus the setup time of U7B to settle. Then, the next falling edge of FAST will correctly propagate the value to FAST_~SLOW. This adds one flip flop delay to determining the max frequency this can run at. However, that is fine because the limiting circuit is still PULSE_~RUN, so it does not change my max frequency.

One thing I'm unsure of is what happens if U5B starts changing while still in the hold time of U7B. Thankfully for this specific J-K flip flop the hold time is 0 so it shouldn't be a problem here.
kernelthread
Posts: 166
Joined: 23 Jun 2021

Re: 65C816 Computer YouTube Series

Post by kernelthread »

I used a variation of Figure 3 on this page:

https://www.eetimes.com/techniques-to-m ... itch-free/

to do clock switching between a fixed 8MHz clock and a variable 8 to 50MHz clock for a 68000 board. It was implemented in an ATF1504 CPLD.
The circuit relies on both clocks running continuously - single pulses won't go through. If you want to use it for single stepping you will have to generate additional pulses on the SLOW clock when you switch from fast to single step.
If you only want it for single stepping rather than running from two completely different unsynchronized clocks there is probably a simpler way of (1) stopping the main clock and (2) allowing a single clock pulse through before stopping again.
User avatar
akohlbecker
Posts: 282
Joined: 24 Jul 2021
Contact:

Re: 65C816 Computer YouTube Series

Post by akohlbecker »

Long time no post! :mrgreen:

I just published a video adding the 6551 UART to the build, along with an MCP2221A for USB protocol conversion. I'm pretty happy with the result, especially since I found a through-hole USB chip, as it allows me to stay within my goal of no SMD components. Here is what the new UART section looks like:
65C816-Serial.pdf
(71.56 KiB) Downloaded 57 times
At the moment the code is still pretty inefficient, as I haven't implemented interrupt-based communication yet. That will come in a future video.
User avatar
AndrewP
Posts: 368
Joined: 30 Aug 2021
Location: South Africa

Re: 65C816 Computer YouTube Series

Post by AndrewP »

Nice! Your video almost inspired me to use a W65C51 as it feels more period appropriate than the TL16C752D I've got. But it's a bit expensive for what it it does and still has the hardware bug. And that issue is what prompted me to post - I was thinking surely WDC must have fixed the issue by now and browsing the data sheet doesn't mention any issues or errors...

Until I read a little more closely
W65C51 Status Register.png
Seems the data transmit empty register just does nothing now and that's officially the way it is.

I mean I get it from WDC's point of view. It must be a very low volume IC and I doubt it is profitable. There isn't even a LQFP version and I wonder if that means they only did a single run of the buggy versions and haven't sold that stock yet. Just idle wondering.
User avatar
floobydust
Posts: 1394
Joined: 05 Mar 2013

Re: 65C816 Computer YouTube Series

Post by floobydust »

Yes... the documentation has been changed to call it a feature versus the defect that it is. Sadly, I've got around 10 of each of the new featured parts... DIP and PLCC... and can't really use any of them, as I've no interest in programming around defective hardware.
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: 65C816 Computer YouTube Series

Post by BigDumbDinosaur »

akohlbecker wrote:
I'm pretty happy with the result, especially since I found a through-hole USB chip, as it allows me to stay within my goal of no SMD components.

You could have used a socketed PLCC44 version of the 816, stayed in the goal of no SMD, but at the same time, substantially reduce board space consumption.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigDumbDinosaur
Posts: 9426
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: 65C816 Computer YouTube Series

Post by BigDumbDinosaur »

floobydust wrote:
...I've no interest in programming around defective hardware.

Amen to that! Even without the TxD bug, the 6551 would still be a garbage design.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
A0CBM
Posts: 51
Joined: 04 Nov 2015

Re: 65C816 Computer YouTube Series

Post by A0CBM »

I am curious about the 65C816 data sheet, AC characteristics has a list of the max. clock speeds for different voltages. If I plan on running about 3.5 mhz, can I use the 4 mhz timings for that speed, even if I am using 5 volts?
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: 65C816 Computer YouTube Series

Post by BigEd »

Depends what you mean on using the timings! If you're at 5 volts, the chip will respond in the number of nanoseconds it should, and if you need to make one signal arrive some number of nanoseconds before another, you should do that. The result should be a system which works up to the rated clock speed at 5 volts.

There's a real sense in which chips have no idea what frequency the system is operating at: all the important things happen in the time domain, not the frequency domain. Think about nanoseconds, instead of megahertz, and it might well all make more sense!
User avatar
Proxy
Posts: 746
Joined: 03 Aug 2018
Location: Germany

Re: 65C816 Computer YouTube Series

Post by Proxy »

A0CBM wrote:
I am curious about the 65C816 data sheet, AC characteristics has a list of the max. clock speeds for different voltages. If I plan on running about 3.5 mhz, can I use the 4 mhz timings for that speed, even if I am using 5 volts?
Personally, at such low speeds I wouldn't really look that closely at the timings anyways. The general rule is that the combined delay of the decoding logic and memory/io (ie the time between latching the upper address bits to when your RAM/ROM is stable) shouldn't exceed half a clock cycle.
For 4MHz it's 125ns, remove 10ns just to be safe. And you got 115ns to play with, which is a pretty long time for basically any modern logic/memory chips.
To get the total delay of your system you can use the datasheets of all ICs you have in series, from the CPU to whatever endpoint device you have (like an EEPROM, UART, or an SRAM chip). Just add them up and see if that value is smaller than the 115ns mentioned above.

Atlwast that's how I design my systems. Others may do it differently
User avatar
AndrewP
Posts: 368
Joined: 30 Aug 2021
Location: South Africa

Re: 65C816 Computer YouTube Series

Post by AndrewP »

A0CBM wrote:
I am curious about the 65C816 data sheet, AC characteristics has a list of the max. clock speeds for different voltages. If I plan on running about 3.5 mhz, can I use the 4 mhz timings for that speed, even if I am using 5 volts?
You can absolutely run the W65C816 at lower clock speeds than the maximums recommended by WDC at a given voltage.

But what BigEd and Proxy have mentioned is important. The clock speed basically doesn't matter* it is the rise, fall and delay time of the signals that you need to think about.
SDS00002.png
Above is a view of an '816 running at 5Hz (Hertz, not Megahertz) at 5V and even at that very low speed notice that once PHI2 (in yellow) falls the address lines (in green) are already set about 11ns later.
SDS00001.png
Whereas here the same program on the same '816 is running at 36MHz at 5V and you'll notice that the propagation delay from PHI2 falling to the address line being set is still 11ns. (The RWB signal is in cyan and pink is not connected.)

Interestingly the '816s response time barely changes until under 4.2V

* Well, I mean, obviously the clock speed does matter. Too fast and the '816 is still doing stuff internally when PHI2 rises on the second half of the cycle. And all your logic propagation timings must fit within your chosen clock.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: 65C816 Computer YouTube Series

Post by GARTHWILSON »

A0CBM wrote:
I am curious about the 65C816 data sheet, AC characteristics has a list of the max. clock speeds for different voltages. If I plan on running about 3.5 mhz, can I use the 4 mhz timings for that speed, even if I am using 5 volts?
The S in W65C816S stands for "static," meaning it will run down to DC, meaning you can even stop the clock and internal registers will keep their data and status.  You could run at one cycle every ten hours if you wanted to.  However, if you're running at 5V, use the 5V specifications, even at lower frequencies.  Do not use the 2.5V column just because it's rated for 4MHz.  At 5V, the timing margins will still meet the what's guaranteed in the 5V column.  BTW, do capitalize the M in MHz.  Lower-case m in numbers stands for "milli," ie, one one thousandth, whereas capital M stands for "mega," ie, one million (not one one millionth, which would be micro, represented by µ or u).  3.5mhz would be one cycle every 4 minutes and 46 seconds.
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?
Post Reply