GaBuZoMeu wrote:
You have made no provisions to /ABORT and to slow down (using RDY or manipulating PHI2)...
BigDumbDinosaur wrote:
Okay...
My mods to V2.2 to add wait-stating won't work...something that was determined in my sleep last night.
I'll explain.
When the 65C816 is stopped by negating
RDY it halts in what is effectively the Ø2 high state, the same as if the Ø2 clock had been "frozen" in the high phase. While halted, the '816 will maintain the state of
A0-A15,
RWB,
MLB,
VPB,
VDA,
VPA and
E as they were immediately prior to the negating of
RDY. If the '816 was halted during a write cycle,
D0-D7 will contain whatever it is that the '816 is writing. The
MX output will reflect
X, since the internal clock will be high.
Now, here's the problem. The CPLD in V2.2 is being used only to generate chip selects via combinatorial logic. Discrete logic is being used to generate the
/RD and
/WD signals, as well as the
A16-A19 address bits. Also, a bus transceiver acting as a level converter sits in between the MPU's
D0-D7 connections and the system's RAM, ROM and I/O. Ø2 is used to qualify
/RD and
/WD. Ø1 (inverted Ø2) is used to open and close the 'AC573 latch that captures the
A16-A19 address bits. Ø1 is also used to gate the data bus transceiver so it isolates the rest of the data bus from the '816 while Ø2 is low, which is when the bank bits are emitted.
Considering all this, it is patent that merely halting the '816 with
RDY won't work as expected—significant problems will arise. The first one is the state of
/RD or
/WD (depending on if the '816 has been halted during a read or write cycle, respectively) will not be maintained while the '816 is stopped. Instead,
/RD or
/WD will rise and fall as the clock falls and rises, possibly confusing the device being accessed.
Adding to the confusion, each time Ø2 falls, the data bus transceiver will go to the high-Z state, breaking the connection between the '816 and the device being accessed. Again, during a wait-stated write cycle the device being accessed may malfunction due to inadvertent timing violations.
More onerously, the latch that captures the bank bits and generates
A16-A19 will open each time Ø1 goes high during the wait-state and then close again when Ø1 goes low. The problem is that while the latch is open it will be capturing data, not bank bits. Hence the effective address seen by the rest of the system will change during the wait-state, causing no end of grief.
Faced with these little contretemps, I have to make one of two choices: forego wait-stating in V2.2 or concoct a different way to accommodate slow hardware. Wait-stating is not essential, as the chosen hardware can run quite fast...12.5 MHz is easy with POC V1.1, which is 100 percent discrete logic. On the other hand, I have aspirations of trying to get the speed higher in V2, which will demand wait-states on ROM and some of the I/O hardware. So, what's a broken down old dinosaur to do?
While contemplating this matter, I was staring at the schematic, specifically the clock generator circuitry, and thinking about what goes on inside the '816 while
RDY is low. That's when I decided the solution might be in halting the clock during Ø2 high for the required amount of time and then letting it resume. I would be simulating externally what the '816 does internally during a wait-state (also when the
WAI instruction has been executed).
The basic clock generator circuit in all my POC units is:
Attachment:
File comment: Two-Phase Clock Generator
clock_generator_2phase.gif [ 16.09 KiB | Viewed 3216 times ]
I use the 74AC74 flip-flop to strengthen the clock signal, assure symmetry and in the case of V2.2, generate the Ø1 signal that gates the bank bits latch and the data bus transceiver. As is typical of this sort of circuit, the
/CLR and
/PRE inputs to the flop are tied to
Vcc, which causes the flop's
Q and
/Q outputs to follow the
D input as the clock oscillator's output goes high on each cycle. Of course,
/CLR and
/PRE can be used in other ways, as can be seen by examining the flop's function table:
Attachment:
File comment: 74xx74 Flip-Flop Function Table
74xx74_function_table.gif [ 29.76 KiB | Viewed 3216 times ]
In particular, note the first row in the table, in which
/PRE is low. In this case,
Q will stay high and
/Q will stay low, without regard to what is going on at the
CLK and
D inputs.
Q high and
/Q low is the Ø2 high state.
So, my thinking goes, if I assert
/PRE when a wait-state is needed, Ø2 will be "frozen" high, causing the '816 to halt as though
RDY has been brought low. With Ø2 continuously high, the state of
/RD and
/WD will be maintained. At the same time, Ø1 will be "frozen" low. Hence the data bus transceiver will remain gated to maintain the path between the '816 and the rest of the system, and the bank bits latch will remain closed, thus maintaining the state of
A16-A19. So far, so good.
Naturally, solutions may give rise to new problems. Since it would be the CPLD that would make the determination when a wait-state is needed and how long it should be, it must have a continuously running clock input and most importantly, that clock must stay in sync and phase with the Ø2 clock when the latter is not halted. The unused second section of the flop can be used to produce the CPLD's clock, which is referred to as the
GCLK.
Here's the modified clock generator circuit:
Attachment:
File comment: Modified Two-Phase Clock Generator
clock_generator_2phase_modified.gif [ 24.63 KiB | Viewed 3216 times ]
Note the netlist symbol
/STP (top right corner). This will be an output from the CPLD. Normally,
/STP will be driven high, keeping U1a's
/PRE high—Ø1 and Ø2 will run. When the CPLD has determined that a wait-state is required, it will drive
/STP low, driving U1a's
/PRE low and freezing the Ø1 and Ø2 clocks.
Where the trickiness will come in is in timing. If this is to work, the CPLD must assert
/STP immediately after
GCLK has gone high in order to start the wait-state. When the wait-state has expired,
/STP must be deasserted immediately after
GCLK has again gone high so Ø2 and
GCLK remain in phase.
Opinions?
Incidentally, I'd expect this arrangment would also work with the 65C02.
————————————————————————————————————
Edit: I started a
separate topic on using Ø2-high stretching to achieve wait-states.