I've read page 37 of `Documentation.docx` regarding interfacing external hardware via data/address buses to help me get my custom Experimenter bus card going. I'm looking for a bit of feedback to be sure my assumptions on how this all works is correct.
To start with, I put together a very small test program:
mvi a,255
out 255
nop
in 255
nop
hlt...which I hand compiled to switches 076, 377, 232, 377, 000, 333, 377, 000, 166 and entered starting at address 0x0000. (This was from a fresh default power-up, so nothing else running). I used address 255 so I could verify it was working as expected by watching the LEDs on the register output card.
I hooked up a logic analyzer to the pins on my bus card (see previous posts about that), and here's what I see when I run it:
For reference, the channels are:
- A0 - address line 0
- A1 - address line 1
- Select - address lines 2 through 7 AND-ed together (so it will go high on any bus address from 252 to 255)
- Bus INP - the 'INPUT' bus line
- Bus OUT - the 'OUTPUT' bus line
- WAIT - the 'WAIT' bus line
So, it's pretty straight forward as the lil' program runs: first comes the `OUT` command, the select and A0/A1 are high, so it's addressed to port 255 all as expected. The OUT line is high for about 940ns (consistent for a number of runs). The address is set at the same time as the OUT line goes high.
Next, the INPUT line goes high. I see there's a small (250ns) delay before the INPUT line goes high after address is set, which is a good thing. The INPUT line is high for just under 3.19us (again consistent over a number of runs)
The WAIT line is low, as expected, throughout the whole run. (It goes high when we hit the HLT instruction).
My questions about all of this:
First: that tight timing from the address setting to setting output line high. I see this in the code for Altail8800.ino:
It doesn't look like the 4 additional `host_set_data_leds()` are adding any time as described in the comment. I need to check the compiler listing - I wonder if the compiler is optimizing those additional calls out, or is it just that writing to the output register is so fast that 4 extra calls don't add significant time?
Second: The sequence of the INPUT handling; the flow is to the set the address lines and check the WAIT line. If WAIT is low, then set the INPUT line high, read the data, then set INPUT low.
If the WAIT was high, turn INPUT on, read data, set INPUT low, do a little housekeeping, and loop through that until WAIT is low:
Either way, the WAIT line is checked *before* the INPUT line goes high, so it seems like a bus device would have no chance to assert WAIT to force a wait state to be sure it's data is ready - does that seem legit?
Third question (related to question 2 for INPUT) - if somehow the WAIT line was asserted by the bus device before the INPUT line went high, the code continually toggles the INPUT line which might be a problem for the bus device. Is that right?
Seems like I'm just missing the point on the INPUT handling?
Last question - the duration of the INPUT is longer than the max 1500ns time in the document, but it's consistently longer at around 3.19us. This isn't a big deal, but differs from doc, and I'm not sure where I see where the extra time is coming from in the code.
I'd really appreciate it if anyone has anything comments on my questions or to let me know I'm off base on this. :)
Thanks much!
Matt