home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / emulate / progs / z80card / document / Technical < prev   
Encoding:
Text File  |  1994-04-12  |  8.2 KB  |  216 lines

  1.  
  2. Z80 Processor Expansion Card
  3. (c) Adrian Lees 1994
  4. v1.01
  5.  
  6. Notes about the Design
  7. ----------------------
  8.  
  9. Because the prototype was constructed using 74LS series logic
  10. the 74LS05 IC, which had to be included to drive the PIRQ* line
  11. correctly, was used in buffering the control signals used by
  12. the card. (Acorn state that these lines can only drive 1 LS i/p)
  13. For the same reason a 74LS245 was included in the data path,
  14. because each of the data outpus BD0-BD15 is also rated at 1 LS
  15. i/p. This buffer is not strictly necessary if the circuit is
  16. constructed using 74HC logic.
  17.  
  18. Initially the double inversion applied to the PS* might appear
  19. pointless, but this is due to the need to buffer the PS* line.
  20. An active low signal is required to drive the CE* input of
  21. the data bus buffer and hence the signal must be passed through
  22. two stages of the 74LS05, ie. two inverters.
  23.  
  24. Whilst I admit that some of the logic employed is not perhaps
  25. the most elegant solution I have tried to minimise the number
  26. of ICs being used, firstly to simplify construction and also
  27. to minimise the power requirements of the card. Hence, I have
  28. tended to use the gates available, for example I have used
  29. the spare open-collector inverters where usually a normal
  30. inverter would be more appropriate. Only one gate is left
  31. unused - a dual-input NAND gate. (1/4 of the 74LS00 IC)
  32.  
  33. Should you require more memory for the Z80 it would be a simple
  34. matter to connect the A15 line between the 374 latch the memory
  35. bank and the Z80 and provide the necessary decoding to select
  36. between, for example, 2 62256 devices, thus allowing the full
  37. 64K memory map of the Z80 to be utilised.
  38.  
  39. Alternatively, a lower capacity RAM chip could be used if only
  40. small programs were to be used, thus simplifying the circuitry.
  41.  
  42. Input/Output facilities
  43. -----------------------
  44.  
  45. The present circuit does not implement any input/output hardware
  46. for the Z80 processor. All input/output accesses will generate
  47. an interrupt to the Archimedes and this is intended simply as a
  48. mechanism by which the Z80 can inform the Arc. when processing
  49. as been completed. This expansion card is intended purely for
  50. developing Z80 software, however, should you wish to modify the
  51. design for a practical application by including some input/output
  52. hardware then obviously feel free to do so !
  53.  
  54.  
  55. Programming Details
  56. -------------------
  57.  
  58. All accesses should be byte accessess, due to the 8-bit nature
  59. of the Z80 processor. ie. LDRB and STRB instructions should be used.
  60.  
  61.  
  62. Offset (bytes)  Read                    Write
  63. into address
  64. space
  65. ----------------------------------------------------------------
  66. 0               Expansion card ID byte  High byte of address
  67.                                         A8-A15
  68.  
  69. 4               Read status of          Set status of
  70.                 Z80 processor.          Z80 processor
  71.  
  72.                 Bit                     Bit
  73.                 0 - BUSACK,             0 - BUSREQ,
  74.                     0 = bus under           0 = request bus
  75.                         control of Arc.     1 = release bus
  76.                 1 - HALT,               1 - RESET,
  77.                     0 = processor           0 = normal operation
  78.                         halted.             1 = reset processor
  79.                                         2 - Enable interrupts
  80.                                             to Archimedes
  81.                                             0 = Disabled
  82.                                             1 = Enabled 
  83.  
  84. 8               Clear IRQ flag          Generate NMI
  85.                 from Z80 processor
  86.  
  87.  
  88. Procedures
  89. ----------
  90.  
  91. Note that in the examples below whenever a write operation is performed
  92. to offset 4, the 'Set status' address, all signals except the one being
  93. changed are returned to their 'normal' conditions. In real code, a
  94. record should be retained of the last value written to this address and
  95. then only the required bit should be changed before writing to the
  96. hardware.
  97.  
  98. Writing to processor memory
  99. ---------------------------
  100.  
  101. 1. Set BUSREQ* line active (low) by writing 0 into bit 0 of offset 4
  102. 2. Wait until BUSACK* line goes low by reading from offset 4
  103.  
  104. [
  105. [  3. Write high-byte of address to latch at offset 0
  106. [  4. Write data to offset ((1<<13) + low_byte of address)
  107. [
  108. repeat as necessary, until all data transferred.
  109.  
  110. Note: The (1<<13) term is necessary, ie. LA13 must be high, to
  111. access the Z80 memory, rather than the input/output registers
  112. described above.
  113.  
  114. 5. Set BUSREQ* line inactive (high) by writing a 1 to bit 0 of offset 4
  115.  
  116.  
  117. For example, suppose the base address of the expansion card memory is
  118. held in R2, the Z80 address to be written to is in R1, and the data to
  119. be written is in R0:
  120.  
  121.          MOV R3,#0              ;NB. This also disables interrupts
  122.                                 ;    from the Z80 processor
  123.          STRB R3,[R2,#4]        ;request ownership of Z80 bus
  124.  
  125.  .acklp  LDRB R3,[R2,#4]
  126.          TST R3,#1:BNE acklp    ;wait until acknowledged
  127.  
  128.          MOV R3,R1,LSR#8        ;extract high-byte of address
  129.          STRB R3,[R2]           ;latch
  130.  
  131.          AND R3,R1,#&FF         ;extract low-byte of address
  132.          ORR R3,R3,#1<<13       ;address upper-half of card's workspace
  133.          STRB R0,[R2,R3]        ;write to workspace
  134.  
  135.          MOV R3,#1              ;releases bus and disables interrupts
  136.          STRB R3,[R2,#4]        ;release ownership of bus
  137.  
  138. Reading from processor memory
  139. -----------------------------
  140.  
  141. This process is identical to the above operation except that the direction
  142. of the transfer is reversed. ie. the above code can be used with the
  143. STRB R0,[R2,R3] instruction replaced by LDRB R0,[R2,R3].
  144.  
  145. Resetting processor
  146. -------------------
  147.  
  148. Forcing a reset of the Z80 processor requires a pulse to be sent along one
  149. output line. The 'timing' for this pulse needs to be done in software, in
  150. order to simplify the hardware. The pulse must have a minimum width of 750ns
  151. to ensure a complete reset operation, which on all present systems is easily
  152. catered for by writing to the podule with _SLOW_ cycle access, as follows:
  153.  
  154.         MOV R0,#2
  155.         STRB R0,[R2,#4]         ;take RESET line active
  156.         LDRB R0,[R2,#4]         ;read status
  157.         MOV R0,#0
  158.         STRB R0,[R2,#4]         ;inactive
  159.  
  160. Note: The read operation from the status register appears to serve no
  161. useful purpose, but actually it is essential for correct operation. The _SLOW_
  162. cycle access via IOC is fixed at 625ns, and hence by performing two
  163. accesses to the expansion card (this read operation and the second write
  164. operation) we can ensure that the pulse exceeds 750ns, independent of the
  165. computer being used. (For the faster Archimedes machines the time required
  166. to execute the MOV R0,#0 and STRB R0,[R2,#4] instructions would be
  167. insufficient to provide the extra 125ns delay)
  168.  
  169. Generate NMI to Z80 processor
  170. -----------------------------
  171.  
  172. Write to offset 8
  173.  
  174.         STRB R0,[R2,#8]
  175.  
  176. The data written is unimportant.
  177.  
  178.  
  179. Clear IRQ flag on expansion card
  180. --------------------------------
  181.  
  182. This would only be performed by the interrupt handler which is to
  183. respond to an IRQ signal from the Z80. Simply reading from offset 8
  184. clears the IRQ flag. The data read should be ignored.
  185.  
  186.         LDRB R0,[R2,#8]
  187.  
  188.  
  189. Halting the processor and Downloading programs
  190. ----------------------------------------------
  191.  
  192. The processor can be paused by using the BUSREQ* line but as soon as
  193. this is released the processor will recommence execution, unless is it
  194. has been halted. This could cause the processor to behave unpredictably
  195. before you have chance to reset it after sending it a new program. Hence,
  196. the program could become corrupted before execution commences. Some method
  197. of halting the processor is required so that we can start it under
  198. controlled conditions, when _we_ want to.
  199.  
  200. The Z80 provides no hardware capability for forcing the processor into
  201. a halt state. However, by writing a halt instruction into location 0 and
  202. then performing a Reset we can force into a halt state via software.
  203. Then the new program can be transferred to the processor's memory by
  204. claiming the bus as usual. When we release the bus the processor remains
  205. halted until we tell it to commence execution by sending a further reset
  206. pulse.
  207.  
  208. This is summarised below:
  209.  
  210.   1. Claim bus, write &76 (HALT) into location 0, release bus.
  211.   2. Reset processor.
  212.   3. Claim bus, write program into Z80 memory, release bus.
  213.   4. Reset processor.
  214.  
  215.  
  216.