home *** CD-ROM | disk | FTP | other *** search
-
- Z80 Processor Expansion Card
- (c) Adrian Lees 1994
- v1.01
-
- Notes about the Design
- ----------------------
-
- Because the prototype was constructed using 74LS series logic
- the 74LS05 IC, which had to be included to drive the PIRQ* line
- correctly, was used in buffering the control signals used by
- the card. (Acorn state that these lines can only drive 1 LS i/p)
- For the same reason a 74LS245 was included in the data path,
- because each of the data outpus BD0-BD15 is also rated at 1 LS
- i/p. This buffer is not strictly necessary if the circuit is
- constructed using 74HC logic.
-
- Initially the double inversion applied to the PS* might appear
- pointless, but this is due to the need to buffer the PS* line.
- An active low signal is required to drive the CE* input of
- the data bus buffer and hence the signal must be passed through
- two stages of the 74LS05, ie. two inverters.
-
- Whilst I admit that some of the logic employed is not perhaps
- the most elegant solution I have tried to minimise the number
- of ICs being used, firstly to simplify construction and also
- to minimise the power requirements of the card. Hence, I have
- tended to use the gates available, for example I have used
- the spare open-collector inverters where usually a normal
- inverter would be more appropriate. Only one gate is left
- unused - a dual-input NAND gate. (1/4 of the 74LS00 IC)
-
- Should you require more memory for the Z80 it would be a simple
- matter to connect the A15 line between the 374 latch the memory
- bank and the Z80 and provide the necessary decoding to select
- between, for example, 2 62256 devices, thus allowing the full
- 64K memory map of the Z80 to be utilised.
-
- Alternatively, a lower capacity RAM chip could be used if only
- small programs were to be used, thus simplifying the circuitry.
-
- Input/Output facilities
- -----------------------
-
- The present circuit does not implement any input/output hardware
- for the Z80 processor. All input/output accesses will generate
- an interrupt to the Archimedes and this is intended simply as a
- mechanism by which the Z80 can inform the Arc. when processing
- as been completed. This expansion card is intended purely for
- developing Z80 software, however, should you wish to modify the
- design for a practical application by including some input/output
- hardware then obviously feel free to do so !
-
-
- Programming Details
- -------------------
-
- All accesses should be byte accessess, due to the 8-bit nature
- of the Z80 processor. ie. LDRB and STRB instructions should be used.
-
-
- Offset (bytes) Read Write
- into address
- space
- ----------------------------------------------------------------
- 0 Expansion card ID byte High byte of address
- A8-A15
-
- 4 Read status of Set status of
- Z80 processor. Z80 processor
-
- Bit Bit
- 0 - BUSACK, 0 - BUSREQ,
- 0 = bus under 0 = request bus
- control of Arc. 1 = release bus
- 1 - HALT, 1 - RESET,
- 0 = processor 0 = normal operation
- halted. 1 = reset processor
- 2 - Enable interrupts
- to Archimedes
- 0 = Disabled
- 1 = Enabled
-
- 8 Clear IRQ flag Generate NMI
- from Z80 processor
-
-
- Procedures
- ----------
-
- Note that in the examples below whenever a write operation is performed
- to offset 4, the 'Set status' address, all signals except the one being
- changed are returned to their 'normal' conditions. In real code, a
- record should be retained of the last value written to this address and
- then only the required bit should be changed before writing to the
- hardware.
-
- Writing to processor memory
- ---------------------------
-
- 1. Set BUSREQ* line active (low) by writing 0 into bit 0 of offset 4
- 2. Wait until BUSACK* line goes low by reading from offset 4
-
- [
- [ 3. Write high-byte of address to latch at offset 0
- [ 4. Write data to offset ((1<<13) + low_byte of address)
- [
- repeat as necessary, until all data transferred.
-
- Note: The (1<<13) term is necessary, ie. LA13 must be high, to
- access the Z80 memory, rather than the input/output registers
- described above.
-
- 5. Set BUSREQ* line inactive (high) by writing a 1 to bit 0 of offset 4
-
-
- For example, suppose the base address of the expansion card memory is
- held in R2, the Z80 address to be written to is in R1, and the data to
- be written is in R0:
-
- MOV R3,#0 ;NB. This also disables interrupts
- ; from the Z80 processor
- STRB R3,[R2,#4] ;request ownership of Z80 bus
-
- .acklp LDRB R3,[R2,#4]
- TST R3,#1:BNE acklp ;wait until acknowledged
-
- MOV R3,R1,LSR#8 ;extract high-byte of address
- STRB R3,[R2] ;latch
-
- AND R3,R1,#&FF ;extract low-byte of address
- ORR R3,R3,#1<<13 ;address upper-half of card's workspace
- STRB R0,[R2,R3] ;write to workspace
-
- MOV R3,#1 ;releases bus and disables interrupts
- STRB R3,[R2,#4] ;release ownership of bus
-
- Reading from processor memory
- -----------------------------
-
- This process is identical to the above operation except that the direction
- of the transfer is reversed. ie. the above code can be used with the
- STRB R0,[R2,R3] instruction replaced by LDRB R0,[R2,R3].
-
- Resetting processor
- -------------------
-
- Forcing a reset of the Z80 processor requires a pulse to be sent along one
- output line. The 'timing' for this pulse needs to be done in software, in
- order to simplify the hardware. The pulse must have a minimum width of 750ns
- to ensure a complete reset operation, which on all present systems is easily
- catered for by writing to the podule with _SLOW_ cycle access, as follows:
-
- MOV R0,#2
- STRB R0,[R2,#4] ;take RESET line active
- LDRB R0,[R2,#4] ;read status
- MOV R0,#0
- STRB R0,[R2,#4] ;inactive
-
- Note: The read operation from the status register appears to serve no
- useful purpose, but actually it is essential for correct operation. The _SLOW_
- cycle access via IOC is fixed at 625ns, and hence by performing two
- accesses to the expansion card (this read operation and the second write
- operation) we can ensure that the pulse exceeds 750ns, independent of the
- computer being used. (For the faster Archimedes machines the time required
- to execute the MOV R0,#0 and STRB R0,[R2,#4] instructions would be
- insufficient to provide the extra 125ns delay)
-
- Generate NMI to Z80 processor
- -----------------------------
-
- Write to offset 8
-
- STRB R0,[R2,#8]
-
- The data written is unimportant.
-
-
- Clear IRQ flag on expansion card
- --------------------------------
-
- This would only be performed by the interrupt handler which is to
- respond to an IRQ signal from the Z80. Simply reading from offset 8
- clears the IRQ flag. The data read should be ignored.
-
- LDRB R0,[R2,#8]
-
-
- Halting the processor and Downloading programs
- ----------------------------------------------
-
- The processor can be paused by using the BUSREQ* line but as soon as
- this is released the processor will recommence execution, unless is it
- has been halted. This could cause the processor to behave unpredictably
- before you have chance to reset it after sending it a new program. Hence,
- the program could become corrupted before execution commences. Some method
- of halting the processor is required so that we can start it under
- controlled conditions, when _we_ want to.
-
- The Z80 provides no hardware capability for forcing the processor into
- a halt state. However, by writing a halt instruction into location 0 and
- then performing a Reset we can force into a halt state via software.
- Then the new program can be transferred to the processor's memory by
- claiming the bus as usual. When we release the bus the processor remains
- halted until we tell it to commence execution by sending a further reset
- pulse.
-
- This is summarised below:
-
- 1. Claim bus, write &76 (HALT) into location 0, release bus.
- 2. Reset processor.
- 3. Claim bus, write program into Z80 memory, release bus.
- 4. Reset processor.
-
-
-