I really would like to have suggestions and feedback from someone. It's about digital logic, in detail, the Z80 interfacing. In this design, I used a 74HC30 which is a 8-input NAND Gate. I'm using it to detect when the device is addressed by the CPU. Now, since not all the signals can reach the stable state at the same time, noise from the NAND output is expected.
The Z80 asserts the /IOREQ when the address line ( and /M1 ) are stable, hence I'm using this signal as the clock for the D-type Flip Flop.
And it works. Look at the logic analyzer image. The /WAIT is the Q output from the Flip Flop, "out" is the NAND output, and IOREQ is the signal that drives the Flip-Flop's CLOCK input. As you can see, glitches and noise from the "out" is expected, however, /IOREQ is asserted when all the address line are stable ( /M1 too ), so the data we latch into the Flip-Flop is always defined ( and correct ). If the device is addressed, we will latch a 0, otherwise 1.
BUT...
There is another device connected to the Z80, whose firmware forces the Z80 to continuously poll an I/O port until the data is collected. The address where this device is supposed to answer does not collide with the address space I reserved for my device. The effect of such firmware is that my Flip-Flip continuously loads the data, and for some reason bad things start to happen. The /WAIT gets activated when it should not.
To investigate this, I used an oscilloscope.
As you can see, the "DATA" line is Dramatically noisy. The /WAIT has been asserted because the "DATA" was violating the Flip-Flop setup time. As you can see, when /WAIT goes low ( that is also when the rising edge of IOREQ reaches the CLOCK input ), the data is not as high as it should have been.
Without continuous polling, anything is fine.
I can't understand what is wrong. On the logic analyzer seems that the glitches are far enough, but in practice I can count several false /WAIT when a continuous polling is running.
I edited this question and added more images for better investigation.
Where the circuit lives.
Signals At the NAND gate inputs.
Blue: the NAND gate output, Yellow: the output after passing a trigger Schmitt NOT (74LS14)
the Q and /Q flip-flop outputs. For unknown reason, when a pulse is applied to clock input, the Q output drops a little. I suspect that this is because of bad contacts on the breadboard.
Yellow the Q output,Blue: the /IOREQ signal after the NOT gate (at the moment a 74LS14 not 74HC04). The wider pulse is because as soon as the Q goes low, the Z80 enters the wait mode, and /IOREQ can't change until it exits it. Here is plain to see that on the pulse, the Q output is affected.
I noticed that when the Z80 answers the interrupt, and so stops polling the IO port, things look much better. I suppose that the power supply rail need a dramatic improvement, as well as the ground line... Do you agree with me?
Last but not least, two more photos
Here we see the Q output and the 74HC30 output. Since the Q drop occurs on the pulse produced by the /IOREQ, considering that the NAND output is correctly low, the timing are correct. The mess is produced by the noise, and ...
... the 74LS14 could resolve the problem, but this needs two NOT gates, so, the question is: Is it possible to reshape a signal using "simple analog parts like diodes"?