The Z8000 Microprocessor - A Design Handbook PDF
The Z8000 Microprocessor - A Design Handbook PDF
The Z8000 Microprocessor - A Design Handbook PDF
A Design Handbook
- BRADL Y K. FAWCETT
Senior Staff Engineer
Zilog, Inc.
Zilog assumes no responsibility for the use of any circuitry other than
circuitry embodied in a Zilog product. No other circuit patent licenses are implied.
10 9 8 7 6 5 4 3 2 1
ISBN 0-13-983742-6
ISBN 0-13-983734-5 {pbk}
PREFACE viii
Chapter 1
THE 28000 CPU 1
Operating Systems, 2
TheZ-Bus, 4
Z8000 CPU Architecture, 7
System and Normal Modes, 9
Z8002 Pin Configuration, 9
Z8001 Pin Configuration, 15
Segmented Addressing and Memory Management, 17
Segmented and Nonsegmented Modes, 20
CPU Operating States, 20
System Inputs, 22
CPU Clock Requirements, 22
Chapter 2
CPU REGISTERS 24
iii
iv Contents
Chapter 3
INTERFACING TO MEMORY 32
Memory Address Spaces, 32
Memory Organization, 34
Memory Control Logic, 36
Example 1: Interfacing to Z6132'S, 41
Example 2: Interfacing to Z6132'S and 2716'S, 46
Memory Refresh, 47
Chapter 4
INTERFACING TO PERIPHERALS 50
I/O Address Spaces, 50
I/O Interface Signals, 51
I/O Control Logic, 53
Z-Bus Interrupt Signals, 55
Chapter 5
INSTRUCTION AND INTERFACE TIMING 56
Instruction Prefetch, 56
Basic Timing Periods, 57
Memory Cycles, 58
I/O Cycles, 62
Internal Operation Cycles, 65
Memory Refresh Cycles, 66
AC Timing Characteristics, 68
Memory Interface Timing: an Example, 69
Wait-State Generation, 71
Chapter 6
INTERRUPTS, TRAPS, AND RESETS 74
Interrupts, 74
Traps, 75
Interrupt and Trap Handling, 77
Priorities of Exceptions, 77
Interrupt Acknowledge, 78
Saving Program Status, 78
Program Status Area, 80
Interrupt Returns, 84
Contents v
Chapter 7
BUS AND RESOURCE SHARING 101
Chapter 8
THE INSTRUCTION SET 113
Chapter 9
THE Z8010 MEMORY MANAGEMENT UNIT 152
Chapter 10
EXTENDED PROCESSOR UNITS 183
Chapter 11
A Z8000 DESIGN EXAMPLE 190
Chapter 12
Z8000 FAMILY DEVICES 206
Z-Bus Peripheral Interface, 207
Peripheral Interrupt Structure, 209
Z8036 CIO, 212
Z8038 FlO, 219
FIFO Buffer Expansion, 234
Z8030 SCC, 237
Z8065 BEP, 242
Z8068 DCP, 247
Z8052 CR TC, 248
Z8016 DTC, 249
Z6132 RAM, 251
Chapter 13
Z-BUS MICROCOMPUTERS 255
Appendix A
Z8000 CPU DC AND AC ELECTRICAL CHARACTERISTICS 285
Appendix B
GLOSSARY 290
Appendix C
BIBLIOGRAPHY 301
INDEX 302
Preface
With the advent of the 16-bit microprocessor, computing power and features
formerly available only in minicomputers and large-scale computers are now
provided on a single integrated-circuit chip. This text is a detailed study of
one such microprocessor, the Z8000.
The emphasis of this book is on logic design with the Z8001 and Z8002
microprocessors. Other components in the Z8000 family of parts are also
discussed. The components described in this book are available from
Zilog, Inc.
1315 Dell Avenue
Campbell, CA 95008
viii
Preface ix
BRADLY K. FA WCET T
ZILOG SALES OFFICES
x
1
Microprocessors were introduced in the early 1970s as 4-bit and 8-bit proces-
sors that were used largely as programmable logic devices. These devices
could handle simple tasks in products such as calculators, games, and control
systems. The advent of more sophisticated 8-bit microprocessors, such as
the Z80, led to the design of microprocessor-based computer systems with
sufficient memory resources to perform simple data processing tasks and
more complex control functions. However, these 8-bit systems could rarely
match the memory addressing and data processing abilities of the minicom-
puters and mainframe computers available at the time.
The Z8000 microprocessor represents a further step in the evolution of
microelectronics-a 16-bit central processing unit (CPU) with features that,
until now, could be found only in sophisticated mini- and large- scale comput-
ers. The Z8000 is not an extension of 8-bit architectures; its architecture is
closer to that of popular minicomputers such as the PDP-11 than to the Z80.
The high throughput, abundant CPU resources, and powerful instruction set
of the Z8000 extend well beyond traditional microprocessor architectures.
Special features in the Z8000 support operating-system-type environments,
manipulation of complex data structures, and multiprocessing systems.
Thus the Z8000 incorporates on one LSI chip an architecture designed to ac-
commodate a wide range of applications, from relatively simple control sys-
tems to powerful data processing computers.
The Z8000 microprocessor is available in two versions: the Z8001 and
Z8002. The Z8001 is a 48-pin CPU that can directly access 8 megabytes of
memory per memory address space; the Z8002 is a 40-pin CPU that can di-
1
2 The Z8000 CPU Chap. 1
rectly access 65,536 bytes of memory per memory space. A memory manage-
ment unit, the Z8010 MMU, can be used with the Z8001 in memory-intensive
applications to organize and control memory use efficiently. An entire family
of support devices is available, including intelligent peripheral controllers,
serial and parallel input/output devices, and direct memory access (DMA)
controllers.
The architectural features of the Z8000 CPU include sixteen 16-bit
general-purpose registers, eight addressing modes, and an instruction set
more powerful than that of most minicomputers. Data types ranging from
single bits to 32-bit fields and byte strings are supported. The 110 instruc-
tion types combine with the addressing modes and data types to form a set
of over 400 distinct instructions. These CPU resources exhibit a high degree
of regularity. For example, more than 90% of the instructions use any of
five main addressing modes, and operate on 8-bit, 16-bit, or 32-bit data
types. This regularity in the CPU architecture greatly simplifies the program-
ming of Z8000 processors. Operating system support is provided by features
such as system and normal modes, multiple stacks, and a sophisticated inter-
rupt structure. Hardware and software support of multiprocessing environ-
ments also is included in the Z8000 architecture.
External devices called Extended Processor Units (EPUs) can be used to
extend the Z8000's basic instruction set. EPUs unburden the CPU by per-
forming complex, time-consuming tasks such as floating-point arithmetic or
data base management.
OPERATING SYSTEMS
The limited CPU resources and relatively small address spaces of previous
generations of microprocessors made it difficult, if not impossible, to de-
velop systems based on those microprocessors that could process more than
one programming task at a time. (A programming task is the execution of
one program, operating on its data.) Thus microcomputer systems have tra-
ditionally been single-user, single-task systems in which the user has direct
control over the machine hardware. In contrast, the Z8000's regular archi-
tecture and large address space facilitate the design of Z8000-based systems
that can handle multiple users and multiple programming tasks.
When multiple programming tasks are executed concurrently on a com-
puter system, each task requires the use of some of the system's hardware re-
sources. These resources include the CPU, memory, and input/output (I/O)
devices. Invariably, there are not enough resources in the system to support
the simultaneous execution of all the programming tasks; a method for shar-
ing various resources between all the system's tasks must be defined. Multi-
tasking computer systems usually employ a supervisory software program to
coordinate and control the various programming tasks; such supervisory soft-
Operating Systems 3
the execution of a given task should be the results that would appear if the pro-
gramming task were run sequentially from start to finish without interruption.
The operating system must control the allocation of memory space as
well as the allocation of CPU time. As the operating system switches the
CPU from one programming task to another, it must ensure that the program
is available in main memory for the CPU. Memory space for each task's
program and data must be allocated in a manner that ensures that the
execution of one task does not interfere with the execution of any other
task. Often, memory allocation during task switching involves moving code
or data between main memory and a secondary storage device such as a disk
or magnetic tape. (The management of memory resources in Z8000 systems
is discussed in Chapter 9.)
I/O handling and allocation is also an integral part of most operating
systems. As mentioned above, having the operating system control all I/O
accesses frees the individual users from having to know the details of the
hardware and keeps tasks from interfering with each other. I/O devices
often must be allocated to a specific task; for example, if a user wants to
print a table of data, no other task should be allowed to use that printer
until that user's print operation is complete. Interrupt processing must also
be controlled by the operating system, not by the applications programs;
since interrupts are caused by events external to the CPU operations, there is
no way to predict which user's task will be running when an interrupt
occurs.
Other functions that are controlled by operating systems include task
synchronization (in applications where the ordering of tasks is critical), task
communication (in applications where data are passed between tasks), de-
bugging functions, and other resource allocation problems within a given com-
puter system. Operating systems, like hardware designs, can be general
purpose in nature or oriented to a particular application.
Many features of the Z8000 CPU architecture are designed to support
the implementation of operating system software on Z8000-based computer
systems. These features will be emphasized throughout this book as the
various parts of the architecture are discussed. However, this does not mean
to imply that Z8000-based systems must include an operating system. Many
applications, such as most process control applications, would involve
running only one programming task, making operating system software
unnecessary.
THE Z-BUS
circuitry for performing arithmetic and logical functions (an arithmetic and
logic unit, or ALU), some storage for ALU operands and results (registers),
and control logic. The control logic decodes instructions and determines
their execution and sequencing by sending the appropriate signals to the
ALU and registers in the CPU, and the external storage and I/O devices out-
side the CPU. Of course, the instructions and data to be acted on must exist
somewhere and be available to the CPU; hence storage devices such as semi-
conductor memories need to be interfaced to the CPU. The manipUlation of
programs and data by the CPU would be useless without some method of
getting inforlnation from and sending results to the outside world; thus input
and output devices such as card readers, cathode ray tube (CRT) terminals,
and printers are needed. All four parts-CPU, storage, input, and output-
must be present in some form in a computer system.
The Z8001 and Z8002 devices are microprocessors, not microcomput-
ers. These chips comprise only the CPU portion of a computer system. Thus
hardware design with the Z8000 microprocessors is largely a matter of inter-
facing the Z8000 CPUs with the appropriate memory and I/O devices. The
specification of the signals used to interface the Z8001 and Z8002 to other
components in the Z8000 family of parts is called the Z-Bus. A discussion
of how to interface memory and peripheral devices to the Z8000 micro-
processor is, then, actually a discussion of the Z-Bus signals.
The Z-Bus is not a hardware bus definition like the S-100 or similar
buses, where certain signals are assigned to certain pins on a specific type of
connector for a specific type of circuit board. The Z-Bus is merely the
logical definition of the interface signals used in a Z8000-based system; the
actual hardware implementation of this interface is left up to the designer.
Two types of operations can occur on the Z-Bus: transactions and
requests. Transactions involve the transfer of data between two Z-Bus-
compatible devices. Transactions are initiated by the bus master, that is, the
one device in the system (usually a CPU) that has control of the Z-Bus. All
data transfers occur over a 16-bit time-multiplexed address/data bus. The
timing of Z-Bus data transfers is asynchronous; the sending and receiving de-
vice do not need to be synchronized by a common clock. Several Z-Bus sig-
nals are used to control the transfer, and only one transaction can proceed at
a time.
Six kinds of transactions can occur on the Z-Bus: memory transactions,
I/O transactions, interrupt and trap acknowledgments, EPU transfers,
6 The Z8000 CPU Chap. 1
7
8 The Z8000 CPU Chap. 1
I--------------------~
l !
:l
I I
II ~
EXECUTION
CONTROL -
.1 EXCEPTION
HANDLING
CONTROL
II
L..--,-------.-l
I t I
I I
L~~~ _________________ ~
The Z8000 CPUs execute in two different operating modes: system mode
and normal mode. A control bit in the flag and control word (FCW) de-
termines the current operating mode. The operating modes dictate which
instructions can be executed and which stack pointers are used. In the
system mode, all instructions can be executed; in the normal mode, instruc-
tions that directly affect the system hardware cannot be executed. The set
of instructions that can be executed in system mode only are called
privileged instructions and consist of all the input and output instructions,
instructions that affect the FCW, PSAP, and refresh registers in the CPU, and
the multi-micro instructions. (These instructions are described in Chapter 8.
The stack pointers are discussed in Chapter 2.)
The CPU switches operating modes whenever the appropriate bit in the
FCW is changed. This bit can be altered by a Load Control (LDCTL) instruc-
tion or by an exception condition (interrupt, trap, or reset). The Load Con-
trol instruction is a privileged instruction and provides a means for switching
from system to normal mode. A special instruction, the System Call (SC), is
used to generate a trap, providing a controlled means of switching from the
normal to the system mode. An attempt to execute a privileged instruction
while in the normal mode also generates a trap condition.
The distinction between system and normal modes allows the imple-
mentation of protected operating systems on Z8000-based computers. Oper-
ating system software would run in the system mode, controlling the system's
resources and managing the execution of users' applications programs, which
would run in the normal mode. Since normal-mode users cannot execute
privileged instructions, those users cannot directly control those aspects of
the CPU that affect the system's hardware configuration. If a normal-mode
program needs to perform a hardware-related function such as an I/O opera-
tion, a request to the operating system can be made, via the trap mechanism
(see Chapter 6). Thus only the operating system software performs hard-
ware-related functions.
Figure 1.5 shows the Z8002 CPU with the pins grouped according to function.
Activity on these pins is governed by the Z-Bus protocols.
Address/Data Bus
9
10 The Z8000 CPU Chap. 1
AS AD,s
BUS{
TIMINO
OS
~ AD'3
AD"
READ/WRITE AD"
NORMALI~ AD,o
BYTE/WORD
ADa ADDRESS I
STATUS DATA BUS
ST 3
ST,
ST, ADs
STo AD.
WAIT
CPu{ -_
CONTROL Z8002
STOP CPU AD,
ADD
BUSRQ
BUS{ -
CONTROL BUSAK
INTERRUPTS{ =: NMI
VI
N"Vi
MUL TI·MICRO { MI
CONTRCloL MO
+5 V GND elK
t
RESET Figure 1.5 Z8002 pin functions.
times data. ADO is the least significant bit position, and AD15 is the most
significant. The addresses on this bus can be memory or I/O port addresses,
depending on the type of transaction taking place. In the Z8002, I/O and
memory addresses are always 16-bit words; the Z8002 can directly address
65,536 bytes of memory (64K bytes, where K = 1024) and 65,536 peripheral
devices per address space. Addresses are always emitted by the CPU, but data
can be an input or output, depending on whether the current transaction is a
read or a write operation.
The address/data bus is a multiplexed bus in order to minimize the pin
count on the CPU's package. Sixteen additional pins would be required to
have separate, dedicated address and data buses, with very little, if any, gain
in processor efficiency. Separate address and data lines could improve pro-
cessor performance only during transactions where the address and data can
be sent out simultaneously, that is, only during write operations. However,
since instruction fetches are always memory read operation, read operations
typically occur about eight times as often as write operations. Furthermore,
most memory chips currently available cannot simultaneously accept both
the address and data to be stored, so separate address and data buses would
provide no timing advantage during memory writes. Therefore, the benefits
of a package with fewer pins-higher reliability, smaller size, and decreased
Z8002 Pin Configuration 11
The bus timing signals-address strobe (AS), data strobe (DS), and memory
request (MREQ)-are CPU outputs that control bus transactions by deter-
mining when the address/data bus holds addresses and when it holds data.
In a typical data transfer, AS goes active (the bar above the signal name de-
notes an active low signal), indicating to external memory and I/O devices
that valid address and status information is present on the bus. (The status
lines are discussed below.) Thus the occurrence of an address strobe signals
the start of a data transfer. Sometime later, AS becomes inactive and DS
goes low, indicating that the data to be written to the previously addressed
external device are now on the address/data bus, or that the data to be read
from the device can be placed on the bus (Fig. 1.6). The timing of data
transfers between the CPU and other devices is determined solely by the ad-
dress and data strobes; the CPU and other devices do not have to share a
AS
DS
,'----
Z·Bus Read Transactions
ADO-AD15 --~(
VALID
ADDRESS ~~_ _ _D_AT_A_FR_O_M_CP_U_ _ _)~---
AS
u '---
Riw _ _---l\~ ______________'__
_C
DS
1
\ \ . -_ _- . . . 1
common clock signal. The address and data strobes are mutually exclusive,
of course; only one or the other is active at any given time during the data
transfer.
The MREQ signal indicates that the address/data bus is holding a mem-
ory address, and its falling edge can be used to time control signals to a
memory system. However, as discussed below, certain of the status signals
also can be used to differentiate between memory and I/O transactions; as a
result, the MREQ signal is not used in many Z8000 system designs.
Status Signals
The status signals are CPU outputs that describe the type of transaction that
is occurring on the address/data bus. This status information would be used
to enable the appropriate buffers, drivers, and chip select logic necessary for
proper completion of the data transfer.
The read/write signal (R/W) describes the direction of the current data
transfer; a low signal indicates that the CPU is writing data to an external
device and a high signal indicates that the CPU is reading data from an
external device (Fig. 1.6).
The byte/word line (B/W) describes the size of the data field being
transferred; a low indicates that a word (16 bits) is being transferred, whereas
a high indicates a byte (8-bit) transfer. Bytes of data might be transferred on
the lower half (ADO-AD7) or upper half (AD8-AD15) of the bus, depending
on the address of the device involved in the transaction (see Chapter 3).
The normal/system signal (N /8) indicates the current operating mode of
the CPU; a low indicates system mode and a high indicates normal mode.
This signal could be used by memory control logic to define two separate
memory address spaces: normal-mode memory and system-mode memory.
In other words, a Z8002-based system could include two separate areas of
memory, with each area containing a maximum of 64K bytes. Memory
accesses made when the N /S pin is high would access normal-mode memory,
and accesses made when the N/S pin is low would access system-mode
memory. The operating system software, which runs in system mode, would
be in system-mode memory, inaccessible to the users' programs, which run in
the normal mode and reside in normal-mode memory. Thus systems with
memory control logic that uses the N /8 signal to distinguish two memory
address spaces would have built-in protection features that prevent individual
users from accessing the operating system software.
Four additional status signals, STO, ST1, ST2, and ST3, define the exact
type of transaction occurring on the bus, as shown in Table 1.1.
The internal operation status code (0000) indicates that the CPU is in-
volved in an AL U or other internal operation and that no data transfers are
occurring on the bus. Internal CPU cycles will occur during the execution of
Z8002 Pin Configuration 13
0 0 0 0 Internal operation
0 0 0 1 Memory refresh
0 0 1 0 Standard I/O reference
0 0 1 1 Special I/O reference
0 1 0 0 Segment trap acknowledge
0 1 0 1 Nonmaskable interrupt acknowledge
0 1 1 0 Nonvectored interrupt acknowledge
0 1 1 1 Vectored interrupt acknowledge
1 0 0 0 Data memory reference
1 0 0 1 Stack memory reference
1 0 1 0 EPU-data memory transfer
1 0 1 1 EPU-stack memory transfer
1 1 0 0 Instruction fetch, nth word (IFn)
1 1 0 1 Instruction fetch, first word (IF1)
1 1 1 0 CPU -EPU transfer
1 1 1 1 Reserved (not used in Z800l and Z8002)
STANDARD I/O
PROGRAM PROGRAM
SPECIAL I/O
DATA DATA
sponding to the 1000 status code), a stack memory address space (the 1001
code), and a program memory address space (the 1100 and 1101 codes).
Program code would be located in the program memory space and the data
to be acted on in the data memory space. Stack memory is used as tempo-
rary storage and to hold program status information in the event of a sub-
routine call or exception condition. When combined with the N /S signal, six
memory address spaces are possible: system-mode data, system-mode stack,
system-mode program, normal-mode data, normal-mode stack, and normal-
mode program (Fig. 1.7). For the Z8002, each of these spaces can hold up
to 64K bytes of memory.
Extended Processor Units (EPUs) are devices that can be added to a
Z8000 system to unburden the CPU from complex tasks, such as floating-
point arithmetic. EPUs are designed to act on data resident in their internal
registers; the CPU is responsible for transferring data between the EPUs
registers and the rest of the system. Three status codes are reserved for
transactions involving EPUs: the 1010 status indicates a transfer between an
EPU register and data memory, a 1011 status indicates a transfer between
an EPU register and stack memory, and alII 0 status indicates a transfer
between an EPU register and a CPU register. (EPUs are discussed in Chapter
10.)
Status codes 0100 through 0111 indicate that the current bus activity
is an interrupt or trap acknowledge sequence (see Chapter 6). These status
lines would be decoded to generate the appropriate acknowledge signal for
the interrupting device.
The 1111 status code is reserved for use in future, upward-compatible
Z8000-family CPUs.
CPU Control
These control signals are CPU inputs that allow external devices to delay the
operation of the CPU. The WAIT line can be used by memory or peripheral
devices to increase the delay between the address strobe and data strobe
during bus transactions. Data transfers on the Z-Bus are asynchronous; a
slow memory or I/O device can stretch the timing of data transfers by an
arbitrary length through control of the CPU's WAIT input. (Timing details
are discussed in Chapter 5.) The STOP input is used to halt CPU operation
Z8001 Pin Configuration 15
immediately before the fetch of the next instruction. EPUs use the STOP
signal to synchronize their activities with the CPU.
Interrupts
Three different types of interrupt inputs are supported by the Z8000 archi-
tecture: nonmaskable interrupts, nonvectored interrupts, and vectored inter-
rupts. The NMI signal is an interrupt input that cannot be disabled. N on-
maskable interrupts usually are reserved for catastrophic events that require
the immediate attention of the CPU, such as an imminent power failure.
The nonvectored interrupt (NVI) and vectored interrupt (VI) inputs can be
enabled and disabled via manipulation of the CPU's flag and control word
(FCW). When an interrupt is detected at one of these three inputs, informa-
tion about the currently executing program is saved, and a routine to handle
the interrupt is invoked (see Chapter 6). Nonmaskable interrupts and non-
vectored interrupts each have one routine specified for servicing the inter-
rupt. Vectored interrupts can result in the execution of one of a number of
possible interrupt service routines. Which of those routines is executed will
depend on a byte of data, called a vector, that is received from the inter-
rupting device during the interrupt acknowledge cycle.
Bus Control
Multi-micro Control
The multi-micro in (MI) and multi-micro out (MO) signals are the CPUs
interface to the Z-Bus resource-request daisy chain. These signals allow
multiple processors to share common resources in a well-defined and con-
trolled manner. (Z-Bus resource requests are discussed in Chapter 7.)
The Z8001 differs from the Z8002 in the manner and range of memory
addressing. All of the signal pins previously described for the Z8002 are also
on the Z8001, and the Z8001 has eight additional pins (Fig. 1.8). These
16 The Z8000 CPU Chap. 1
BUS{
TIMING
READ!WRTfE AD"
NORMALlSYSfEM AD10
BYTE/WORD
ADDRESS I
STATUS
ST J DATA BUS
ST 2
ST,
STo
BUS{ - BUSRQ
CONTROL BUSAK SNs
SN 5
_NMI SN,
INTERRUPTS _ ~__
SEGMENT
SNJ
NUMBER
{ NVI SN2
SN,
MULTIOMICRO{ SNo
CONTROL
SEGMENT
TRAP
eight additional signals are used to increase the Z8001's memory addressing
capabilities.
Segment Number
Segment Trap
The segment trap signal (SEGT) is an input to the cpu. Memory manage-
ment logic can use this signal to cause a trap if an illegal memory access is
attempted.
SEGMENTED ADDRESSING AND MEMORY MANAGEMENT
The Z8001 and Z8002 CPUs generate memory addresses of different lengths
and types. The Z8002 uses a 16-bit address to specify one of 64K bytes of
memory in a memory address space. Within each address space, memory is
addressed in a linear manner. The Z8001 uses 23 bits to address memory,
but this address is separated into a 7-bit segment number and a 16-bit seg-
ment offset. The segment number and offset portions of the address are dis-
tinct; the segment number specifies one of 128 possible segments, or blocks,
of memory, and the offset specifies one of up to 64K bytes in that segment.
Each memory segment is an independent block of memory; instructions and
mUltiple-byte data elements cannot cross segment boundaries. The segment
number cannot be altered by effective address calculations during instruction
execution, such as indexing. The Z8001 can address 128 memory segments
per memory address space, with each segment having a maximum of 64K
bytes.
This division of memory into distinct blocks, called memory segmenta-
tion, provides a natural way of partitioning memory into different functional
areas. Modern structured programming techniques dictate that a program's
memory be divided into distinct areas dedicated to particular uses. For ex-
ample, different areas of memory might hold the program's instruction code,
data variables, and a buffer for an I/O device. Each of these memory areas
may have particular attributes associated with that section; the program code
might be in read-only memory, and an I/O buffer's memory might be accessi-
ble only during system-mode operation. Segmentation reflects this use of
memory by allowing the programmer to specify different segments for each
distinct memory area. Thus segmentation provides a convenient means for
partitioning a large memory address space.
Further advantages of segmentation are realized when implementing a
memory management scheme for providing memory protection and reloca-
tion. Memory is a limited resource within a computer system, a resource
that often must be shared by many different and complex programming
tasks. Memory management involves the efficient organization of those
memory resources, while ensuring that each task has sufficient memory
available when needed, without corrupting the execution of other tasks.
Thus memory management is the process of allocating and protecting the
system's memory resources; it is usually implemented with a combination of
hardware logic and operating system software. A typical configuration
would consist of memory-control logic that is programmed dynamically by
the operating system.
The primary means of controlling the allocation of memory is by map-
ping logical addresses to physical addresses. As a processor executes a task,
program code and data must be read from and written to memory. The
addresses that appear in the program and are output by the CPU are called
17
18 The Z8000 CPU Chap. 1
LOGICAL PHYSICAL
ADDRESSES ADDRESSES
logical addresses. On the other hand, the actual memory addresses in the
system's hardware that access particular locations are called physical ad-
dresses. In simple systems with no memory management, logical and physi-
cal addresses are identical (Fig. 1.9). In more complex systems, the memory
manager maps the logical addresses into the physical address space as pro-
grams execute (Fig. 1.10). Thus each independent user of the system need
not be concerned that the logical addresses within a given applications pro-
gram are the same as the logical addresses of another program on the system;
the memory manager will route the logical addresses for each user into dif-
ferent physical memory addresses.
For example, Fig. 1.11 illustrates a system with two users, both of
whom have specified logical addresses 4000 to 5000 in their programs.
When user A's program is running, the memory manager will translate user
A's logical addresses to physical addresses 3000 to 4000; when user B's
program is running, the memory manager will translate user B's logical ad-
dresses to physical addresses 7000 to 8000. Of course, the operating system
will have to inform the memory manager each time it switches between tasks.
Thus, using a mapping algorithm, the memory manager can place each task's
code and data anywhere within physical memory. Logical addresses emitted
by each programming task are translated by the memory manager to the
proper physical addresses for that task's code and data.
The logical address space might be larger, smaller, or equal in size to the
MEMORY
MANAGER
LOGICAL PHYSICAL
ADDRESSES ADDRESSES
MEMORY
LOGICAL MANAGER
ADDRESSES PHYSICAL
ADDRESSES
4000~---...
5000~---"'" 1------13000
I - - - - - - - t 4000
1------17000
1------18000
4000~- _ _...,
physical address space. Systems whose logical address space is larger than
the physical address space are called virtual memory systems. In virtual
memory systems, or in systems with a large number of different program-
ming tasks, the memory requirements for all tasks currently running under
operating system control might exceed the available physical memory.
Therefore, for some users, only parts of their program's code and data may
be in main memory at any given time. Suppose that the addresses that are
"missing" in main memory for a given task are somehow marked in the
memory manager. The memory manager can stop execution by causing a
trap when a reference is made to a "missing" address. The trap routine
could then retrieve the task's missing code or data from an intermediate
storage device (a floppy disk system, for example), place it in physical
memory, and allow the task to continue execution from where it left off.
Space in physical memory would have to be found, which might involve
bumping some other task's code or data onto the disk or other storage
device. The operating system would have to keep careful track of which
areas of physical memory are being used and in what way they are being
used.
The use of segmented addressing in the Z8001 supports the implemen-
tation of memory management logic in Z8001-based systems. A memory
segment is essentially a standard, variable-sized block of memory that can
be assigned common attributes. Translation of logical to physical addresses
can occur on a segment-by-segment basis. Virtual memory systems can swap
entire segments between main memory and intermediate storage devices,
as needed. MemorY,attributes such as read-only or system-mode-only ean be
assigned to segments. The memory manager would use the Z8001 's segment
trap (SEGT) input to signal the CPU in the event of an illegal access, such as
20 The Z8000 CPU Chap. 1
The type of addressing scheme used in a Z8000 system will affect how ad-
dresses are stored in that system. The Z8002's 16-bit addresses, sometimes
called nonsegmented addresses, can be stored in a 16-bit register or in a word
of memory. The Z8001 's 23-bit segmented addresses, on the other hand, are
embedded in a 32-bit-long word, and therefore require two 16-bit registers
or two words of memory when stored. However, a method of using non-
segmented addresses in Z8001 programs is provided.
The Z8001 executes programs in one of two segmentation modes,
segmented mode or nonsegmented mode, as determined by a control bit in
the CPU's flag and control word (FCW). The segmentation mode determines
the size and format of addresses that are directly manipulated by the pro-
gram; in the segmented mode, programs act on 23-bit segmented addresses,
and in the nonsegmented mode, programs act on 16-bit nonsegmented ad-
dresses. The segmented mode is available only on the Z8001; the Z8002
always executes in the nonsegmented mode. Therefore, programs written
for the Z8002 can be run on the Z8001 in the nonsegmented mode without
alteration.
The Z8000 CPUs have three basic operating states: running state, stop/re-
fresh state, and bus-disconnect state. Figure 1.12 illustrates these states and
the conditions that can cause a change in state.
The running state is the normal state of the processor, wherein the CPU
is executing instructions and handling exception conditions (interrupts and
traps). While the CPU is in the running state, execution is controlled by the
program counter (PC) and the flag and control word (FCW). The PC holds
the memory address from which the next instruction is to be fetched. The
CPU Operating States 21
STOP RELEASED. OR
PERIODIC REFRESH
COMPLETED
BUSREQ RELEASED.
STOP INACTIVE STOP ASSERTED. OR
PERIODIC REFRESH
REQUESTED
BUSREQ RELEASED.
STOP ACTIVE
BUSREQ ASSERTED.
AND ACKNOWLEDGED ON
Figure 1.12 Z8000 operating states
BUSACK and transitions.
FCW contains control bits that determine the operating modes (system or
normal, segmented or nonsegmented) and which interrupts are enabled.
Instruction execution consists of two steps: (1) a single instruction of one
or more words is fetched from program memory (IF1 or IFn status on the
STO-ST3 lines) at the address specified by the PC, and (2) the operation
specified by the instruction is performed, with the PC and the flags in the
FCW updated accordingly. After each instruction's execution, the CPU
checks if any interrupts or traps are pending and enabled. If so, instruction
execution is halted and an acknowledge sequence is performed (see Chapter
6). Three conditions can cause the CPU to leave the running state: a refresh
request from the automatic memory refresh logic, the activation of the
STOP input (a low at the input), or a bus request.
While in the stop/refresh state, the CPU generates memory refresh
cycles (see Chapters 5 and 10), and does not perform any other functions.
This feature is used by EPUs to suspend program execution. The CPU re-
turns to the running state when the automatic refresh logic has completed
its memory refresh operation, or when the STOP input is inactivated (returns
high). A bus request while in the stop/refresh state will cause a transition to
the bus-disconnect state.
The CPU enters the bus-disconnect state after receiving a bus request
on the BUSREQ input and acknowledging it on the BUSACK output. While
in this state, the CPU disconnects itself from the bus by tri-stating the
address/data bus, bus timing, and bus status outputs. The CPU leaves this
state when BUSREQ is inactivated. The bus-disconnect state is the highest-
priority state, in that a bus request will force the CPU into this state regard-
less of what other state it is in and what other inputs it receives.
22 The Z8000 CPU Chap. 1
ADo 48 ADa
ADg 47 SNs
AD 10 46 SNs
AD11 4 45 AD7
SYSTEM INPUTS
Figure 1.13 shows the full pin diagram for the Z8001 and Z8002. The
Z8000 CPUs need a +5- V power source and draw a maximum of 300 mAo
A single-phase clock is required; the clock specifications are discussed below.
The RESET input provides a means of putting the CPU in a known starting
condition (see Chapter 6). Note that one pin on each of the CPUs is not
used; that pin is reserved for use on future upward-compatible Z8000 CPUs.
The Z8000 CPUs are dynamic MOS parts which require a single-phase clock
input. The maximum clock rate is 4 MHz for the Z8001 and Z8002, 6 MHz
for the Z8001A and Z8002A, and 10 MHz for the Z8001B and Z8002B.
Since the parts are dynamic, the clock cannot be held high or low for more
than 2 J.1s; therefore, the slowest allowable clock rate is 250 kHz. A TTL-
generated clock signal is not adequate to drive the Z8000; active drivers are
required to meet the stringent level, rise-time, and fall-time requirements.
CPU Clock Requirements 23
Vee
0.011'F
R2 OPTIONAL
0.01"F 120 I BYPASS
01
2N57710R
R1 2N3546
33011 33011
470 R5
22
MOS CLOCK
D R6
22
1/6S04 8 MHz 1/6S04
02
2N5772
OR 2N3646
CLOCK
E 1/6S04
o
1/6S04
CLOCK Figure 1.14 Z8000 CPU clock driver
circuitry,
The clock input high voltage must be not more than 0.3 V above or less than
0.4 V below the +5-V power input. Rise and fall times cannot exceed 20 ns
for the 4-MHz parts and 10 ns for the 6-MHz parts.
Figure 1.14 shows a clock driver circuit for the 4-MHz Z8000. A
4-MHz square wave is generated by dividing an 8-MHz crystal oscillator with
a toggling flip-flop. A resistive pull-up could ensure the required clock-high
level but cannot guarantee the required rise time while driving the chip's
50-pF input capacitance. The rise-time and fall-time requirements dictate
the use of active pull-up and pull-down circuitry for the CPU clock. A TTL
clock also is generated, for possible use by other circuits in the system.
2
CPU Registers
24
Z8002 General-Purpose Registers 25
76543210
I I I I I I I I I BITS IN A BYTE
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Figure 2.1 N urn bering of bi ts in reg-
I I I I I I I I I I I I I I I I BITS IN A WORD
isters.
word registers into pairs (in fact, long-word registers are sometimes called
register pairs); long-word register RRO consists of word registers RO and Rl,
RR2 consists of R2 and R3, and so on. The even-numbered register is the
most significant word of the long word. The quad-word registers (RQO, ... ,
RQ12) are accessed only by the multiply and divide instructions. Each con-
sists of four word registers; quad register RQO consists of word registers RO
through R3, with RO being most significant. As a result of these groupings,
half of the 16-bit ,registers and all of the 32-bit and 64-bit registers have
addressable halves. For example, each half of word register RO can be
addressed separately as byte registers RHO and RLO. Half of the 32-bit
registers and all of the 64-bit registers have addressable quarters. This type
of register hierarchy facilitates many programming tasks.
All of these registers are general purpose in nature and can be used to
hold data or addresses. Each register can be used as an accumulator, that is,
the source or destination of data involved in an AL U operation. Every word
register, except RO, can hold a memory or I/O address (for indirect memory
or I/O references), an index (for indexed memory references), or a stack
pointer. Since all of these registers are general purpose, the particular use to
which a register is put can vary during the course of a program, giving the
programmer a great deal of flexibility. This architecture avoids the program-
ming bottlenecks of an implied or dedicated register architecture, in which
register contents must be saved and restored whenever the need for registers
RO 17 RHO :7 RLO oI
RRO {
R111S RH1 RL1
ROO
R21 RH2' RL2
RR2 {
R31 RH3 RL3
R611S
RR6 {
R91
R06
RR10
{ R10 I
R111
{ R121
RR12
R131
RR14
1",1 R1S' SYSTEM STACK POINTER
R012
I ADDRESS
L..--L-I_I~I~I,----,I--LI----LI----LI--LI--L.I-.1..
1 -.1..1---1-1---1....1---1....1......1
II PROGRAM
COUNTER
r UPPER POINTER
1 1 1 1 1
9 8
RATE
1 I 1 1 1
ROW
1 1
the result of an operation is zero and cleared if the result is nonzero. Bit 5,
the sign flag (S), is set when the result of an arithmetic operation is negative
in two's-complement notation; that is, the most significant bit of the result
is a 1. Bit 4, the parity/overflow flag (P IV), is an odd-parity bit for logical
operations, and an overflow flag for arithmetic operations. When set, the
overflow flag indicates that the result is greater than the largest number or
less than the smallest number that can be represented in two's-complement
notation in the destination register. Bit 3, the decimal adjust flag (D), is
used for BCD arithmetic and indicates whether the last operation was an
addition or subtraction. The Decimal Adjust Byte (DAB) instruction uses this
flag as part of an algorithm for adjusting the binary results of an addition or
subtraction of BCD digits into the correct BCD form. Bit 2, the half-carry
flag (H), also is used by the DAB instruction; it indicates a carry out or a
borrow into bit 3 as a result of an addition or subtraction of BCD digits.
Neither the D nor the H flags are normally accessed by the programmer. Bits
o and 1 of the FCW are not used.
The processor flags provide a means of controlling program branches
and loops. The result of executing one instruction that alters the flags may
determine the operation of a subsequent instruction that tests the flags'
values, typically a conditional jump or return. The whole lower byte of the
FCW can be read from or written to a byte register in system or normal
modes using a special control instruction.
The upper byte of the FCW (bits 8-15) contains control bits that deter-
mine the operating modes of the CPU and control the interrupts. Bit 15 is
always a 0 in the Z8002, signifying that the Z8002 always runs in the non-
segmented mode. Bit 14 is a the system/normal bit (S/N); when this bit is a
1, the CPU is in the system mode, and when this bit is a 0, the CPU is in the
28 CPU Registers Chap. 2
normal mode. The N /8 output pin is the complement of the SIN bit in the
FCW. Bit 13 is the extended processor architecture enable bit (EPA). When
set to 1, this bit indicates that Extended Processor Units are present in the
system, and, therefore, instructions reserved for EPUs will be executed.
When the EPA bit is 0, the occurrence of an instruction code reserved for
EPUs will cause a trap (see Chapters 6 and 10). Bit 12 is the vectored inter-
rupt enable bit (VIE) and bit 11 is the nonvectored interrupt enable bit
(NVIE). Setting the appropriate bit to a 1 enables the interrupt. Bits 8, 9,
and 10 of the FCW are not used. These control bits can only be accessed in
the system mode, via privileged CPU control instructions (see Chapter 9).
Thus only the operating system software can alter the CPU's operating modes.
The program status area pointer (PSAP) holds a 16-bit address that
points to an area in memory called the program status area. The program
status area holds a list of the program status values (values for the PC and
FCW) for every possible interrupt and trap service routine; the program
status area resides in the system program memory address space. The low-
order byte of the PSAP is always zero. (The program status area is described
in Chapter 6.).
The refresh control register, consisting of a 9-bit row counter, a 6-bit
rate counter, and an enable bit, is used to implement CPU-controlled, auto-
matic refresh for dynamic memory. This refresh mechanism is discussed in
Chapter 3.
The Z8001 's general-purpose register set, shown in Fig. 2.4, is identical to the
Z8002, with the exception of the implied stack pointer. Any general-
AO 17 AHO 0:7 RLO 01
AAO {
AI 15 RHI ALI 01
ROO
R2 RH2 RL2
AA2 {
R3 RH3 AL3
R4 RH4 RL4
RR4 {
RS AHS RLS
R04
R6 RH6 RLB
RR61
R7 RH7 AL7
A8 5 o1
AAB {
A9
I
ROB
~=============:
RA12 { R12 ~==================~
R13
RI'~==~S~YST~EM~S~TA~CK~PO~IN~TE~R(~SEG~.N~O~'==~ RO'2
The Z8001 's control registers include the program status registers, PSAP, and
refresh control register (Fig. 2.6).
A reserved word, the FCW, and the PC define the Z8001's program
status registers. The reserved word is not used in the Z8001 but is reserved
for use in future, upward-compatible Z8000 family processors. The program
counter is two words long, where one word holds the segment number and
the other word holds the offset. The flag and control word is identical to
the Z8002 's FCW, with the exception of bit 15. This bit is the segmenta-
tion-mode bit; when set to 1, the CPU operates in the segmented mode, and
when cleared to 0, the CPU operates in the nonsegmented mode. In the
segmented mode, programs manipulate 23-bit segmented addresses; in the
nonsegmented mode, programs manipulate 16-bit nonsegmented addresses.
Thus Z8002 programs can be run on the Z8001 in the nonsegmented mode.
However, the Z8001 always outputs segmented addresses during memory
accesses, regardless of the operating mode. When a memory access is made
in the nonsegmented mode, the offset is the I6-bit nonsegmented address
generated by the program, and the segment number is the value of the
segment number field of the program counter. In other words, the Z8001 in
the nonsegmented mode is actually holding a fixed segment number on the
SNO-SN6 outputs, and making all its accesses to that one segment. That
segment will be the segment number that was in the program counter when
the CPU was placed in the nonsegmented mode. The remaining bits of the
Z8001 's FCW function in the same manner as the corresponding bits in the
Z8002's FCW, as described previously.
30 CPU Registers Chap. 2
16 0
L.IS_EG_I~S_IN~IE_P_A~I_VI_E~IN_V_'E~I_o~__~_O~I~C~I~Z~I_S~I_PIV~I_DA~I_H~I__O~~I}~~~1t~~
I o
SEGMENT NUMBER
I
I 0
0 I} PROGRAM
. SEGMENT OFFSET .
=================================================1
r"'1L.
Z8001 Program Status Registers COUNTER
15
SEGMENT NUMBER
I
UPPER OFFSET
I I I
Z8001 Program Status Area Pointer
15
RATE ROW
mented mode, R15 is the implied stack pointer, and therefore only the
normal-mode copy of R14 can be accessed. This operation is summarized in
Table 2.1.
The PSAP in the Z8001 consists of two words that hold the segment
number and offset address of the program status area (see Chapter 6). The
low-order byte of the offset is always zero. The refresh control register has the
same configuration in the Z8001 and Z8002, and is described in Chapter 3.
3
Interfacing to Memory
The Z8000 CPUs transfer data to and from memory asynchronously on the
16-bit multiplexed address/data bus. As discussed previously, the Z8001 and
Z8002 have different memory addressing capabilities. The Z8002 generates
16-bit addresses and can directly address 64K bytes of memory per memory
address space. The Z8001 generates 23-bit segmented addresses, consisting
of a 7-bit segment number and a 16-bit offset, and can directly address 8M
bytes of memory (128 segments of 64K bytes each) per memory address
space.
Up to six different memory address spaces can be defined using the N /8 and
STO-ST3 signals, as described in Chapter 1: system-mode program, system-
mode data, system-mode stack, normal-mode program, normal-mode data,
and normal-mode stack (Fig. 1.7). Thus, by using the status signals to define
distinct memory address spaces, up to a sixfold increase in the addressing
range can be realized.
In some applications, complete separation of these memory address
spaces may not be desirable. Normal-mode programs often need to pass in-
32
Memory Address Spaces 33
NORMAL-MODE
DATA MEMORY
SYSTEM-MODE
DATA MEMORY
tion placed on the stack during interrupt handling; therefore, the data and
stack address spaces might share some common memory locations. Thus
most Z8000 systems will have some memory locations that are shared among
the six possible memory address spaces. (In Z8001 systems with a program-
mable memory manager, such as the Z8010 MMU, this problem is not as
critical, since the attributes of a particular memory segment can be changed
during program execution by reprogramming the memory manager.)
Few systems will, in practice, require the full addressing range of the
CPU for all six possible memory address spaces. Few Z8001 applications,
for example, need both 8M bytes of system-mode stack and 8M bytes of
normal-mode stack.
MEMORY ORGANIZATION
Each memory address space in the Z8002 and each memory segment in the
Z8001 is a string of up to 64K bytes numbered consecutively in ascending
order. The byte is the basic addressable memory element in Z8000 systems,
and, therefore, each address emitted by a Z8000 CPU designates a particular
byte of memory. However, three other types of data elements in memory are
addressable: bits, words, and long words. The type of data element addressed
depends on the instruction being executed. Certain instructions act on spe-
cific bits in memory by specifying a byte or word address and the number of
the bit within the byte or word. Most of the instructions for performing
arithmetic and logical operations on data have byte, word, and long-word
formats. A few special instructions act on strings of bytes or words, where
the length of the string is given in a register; however, these instructions
access the bytes or words one at a time.
Although memory is addressed as bytes, the Z8000 architecture defines
a 16-bit-wide data path (the 16-bit address/data bus), and memory is orga-
nized in the same way, as 16-bit words. Each 16-bit word of memory is made
up of two 8-bit bytes; thus each Z8002 memory address space and Z8001
memory segment actually contains up to 32K words of memory, where both
bytes in a word are accessible. A memory segment consists of two banks of
~g.~RESS Al--~
76543210
I I I I I I I I I BITS IN A BYTE
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Figure 3.3. Numbering of bits in
I I I I I I I I I I I I I I I I I BITS IN A WORD bytes and words of memory.
up to 32K bytes each, as shown in Fig. 3.2; one bank holds the bytes with
even-numbered addresses, and the other bank holds the bytes with odd-
numbered addresses. A word always consists of an even-addressed byte and
the next consecutive odd-addressed byte. Therefore, only the upper 15 bits
of the address (the offset in segmented addresses), A1-A15, are needed to
specify a word in memory. However, each byte in a word can be addressed
separately; the least significant bit of the address, AO, is used to specify a
byte within a word during byte accesses. All Z8000 instruction fetches and
stack references are word accesses, but data references can be byte or word
accesses.
Bits in bytes and words are numbered right to left in the traditional
fashion; that is, the rightmost bit is the least significant bit and is labeled bit
o (Fig. 3.3). Thus bit position n corresponds to the value 2 n in the represen-
tation of positive binary numbers.
The two bytes in a word, however, are numbered left to right; the most
significant byte in the word is the even-addressed byte (AO = 0), and the
least significant byte is the odd-addressed byte (AO = 1), as shown in Fig.
3.4. The address of a word is the address of its most significant byte; there-
fore, words always have even addresses (AO = 0) (Fig. 3.5). For example, the
word at memory address 6000 consists of the byte with address 6000 (the
most significant half of the word) and the byte at address 6001 (the least
significant half of the word). This convention is the opposite of many
machines, such as the PDP-II minicomputers, and may seem confusing at
first, since the most significant byte of a word has an address that is numer-
AO=O AO=1
LOWEST
16-BIT
ADDRESS
HIGHEST
ltg~Ess Figure 3.4 Sequencing of bytes in
015 08 07 DO memory.
36 Interfacing to Memory Chap. 3
Address n
BYTE
Address n Address n + 1
I !UPP~R ~OR~/UP~ER ~YT~ I I}
Address n + 2 Address n + 3 LONG WORD
Figure 3.5 Addressing of data ele-
'L===========rL::~~=======1
_ ~OW7R ~OR~/LO~ER !BYT~ •
ments in memory.
[
~
0000 [ 0000 AO
""
[ [
0001 5B
0010 [ 0010 C2
"" 0011
0100
35
02
0100 [
""" 0101 AB
0110 [ 0110 2B
ically one smaller than the least significant byte of that word. However, this
type of memory organization greatly simplifies the manipulation of strings
of byte data. Strings of bytes can be stored in consecutive memory locations
and addressed in consecutive numeric order (Fig. 3.4).
Some Z8000 instructions allow manipulation of long-word (32-bit) data
elements. Just as with words, the address of a long-word memory operand is
the address of its most significant byte (Fig. 3.5), which is also the byte in
the long word with the smallest numerical address. Words and long words in
memory always start on even addresses. An example of byte, word, and
long-word addressing is illustrated in Fig. 3.6.
WAIT \r-------------,
STATUS { : : ;
NIS
STO:3
MREQ
=:J CONTROL
TIMING ~
{
OS ----'
BUS
DATA
memory and the CPU is determined by the address and data strobes (AS
and DS). The memory control logic might generate WAIT signals if memory
access times are longer than the default CPU memory cycle timing (see Chap-
ter 5). The status lines (N/S, B/W, R/W, STO-ST3) and, in ZSOOl systems,
the segment number, are used to generate chip selects to the memory, since
they define the address space, segment, and type of memory access. (The
MREQ signal might be used in place of the STO-ST3 lines to signal a mem-
ory access in systems where separate program, data, and stack memory ad-
dress spaces are not distinguished.) Thus this group of signals, together with
the address/data bus, defines the Z-Bus signals used for CPU-memory trans-
fers (Fig. 3.S). Of course, not every system will use everyone of these sig-
nals; for example, a system designed for word accesses only might not use
the B/W CPU output.
The start of a Z-Bus transaction is signaled by AS going low (Fig. 3.9).
The status signals and the address on the address/data bus are guaranteed to
be valid at the rising edge of AS; this edge can be used to latch the address
and status information. (The address can also be latched by the falling edge
of MREQ, which happens slightly sooner.)
During memory reads, DS going low indicates that the CPU has reversed
the direction of the address/data bus, and the data to be read from memory
can be placed on the bus. Thus DS would be used to enable the buffers that
drive the data from memory onto the bus. For memory writes, DS goes low
after the address is replaced on the bus by the data to be written; DS would
then be used to enable the write to memory. The memory control logic can
lengthen the data transfer timing by pulling the WAIT line low, thereby
38 Interfacing to Memory Chap. 3
STATUS>
BUS --AS-
MASTER --05- MEMORY
--R/W-
--B/W-
_WAIT--
ADO-AD15~&CS
EXTENDED ADDRESS
STATUS
DECODE
Figure 3.8 Z-Bus signals for CPU-
memory transactions.
allowing the Z8000 CPUs to interface with memories with arbitfarily long
access times.
The status lines are used to generate memory chip enables and help
control the bus buffering. The STO-ST3 lines, decoded to provide instruc-
tion fetch, data access, or stack access status signals, can be used in conjunc-
tion with the N /S signal to select a particular memory address space. The
R/Wand B/W lines are used with the DS signal to drive the data buffers and
enable writes to memory.
Address bits Al-A15 are propagated to address-decode circuitry to
access a particular word in the specified memory address space and/or seg-
ment. Address bit AO is used by the control logic to select a particular byte
in the word addressed by Al-A15 during byte accesses, as described below.
During memory reads, the R/W line will be high. Regardless of the
state of the B/W line, the memory control logic should place a word of data
on the bus during DS active. The data should be the contents of the word of
memory specified by address bits Al-A15 latched during AS. If the B/W
line is low, indicating a word transfer, the CPU will, of course, read the
entire word of data. If the B/W line is high, indicating a byte transfer, logic
internal to the CPU will select one-half of the word of data returned on the
bus as the byte to be read; if AO was 0 during the address strobe, the CPU
will read the upper half (D8-D15) of the bus, and if AO was 1, the CPU will
read the lower half (DO-D7) of the bus. Thus, for memory reads, the
memory control logic can ignore the state of the B/W line and AO, and just
return the contents of the word addressed by Al-A15 (Fig. 3.10); during
byte reads, the CPU will internally select the appropriate half of the word.
For memory writes, the R/W line is low. If the B/W is also low, sig-
Memory Control Logic 39
ADO·AD15 - - - - ( VALID
ADDRESS ----------.4(
),J- DATA TO CPU )-----
AS~
MREQ
\\.--____----'r-
STO·ST3 -<'-_____ ---I>---
M_E_MO_R_Y_AC_C_ES_S_ST_A_TU_S_ _ _ _
R/W~ ~
DS
\\.--_--'1
Z·BUS MEMORY READ TIMING
AS\ /
nifying a word transfer, the memory control logic can ignore AO. The word
of data supplied by the CPU during DS active is written into the memory
word addressed by A1-A15 (Fig. 3.11). If the B/W line is high, signifying a
byte transfer, the CPU will duplicate the byte of data on both halves of the
address/data bus during DS active. The memory control logic should exam-
ine the value of AO to decide which bank of bytes is to be written; A1-A15
address a word, and the high-order byte of that word receives the written
data if AO = 0, and the low-order byte of that word receives the data if AO =
1 (Fig. 3.12). Therefore, the only time the memory control logic needs to
examine AO and select just one byte of the word addressed by A1-A15 is
40 Interfacing to Memory Chap. 3
~
A15-------'\
FROM
BUS ~ }32KWORDS
A1------,j
015 DO
TO BUS
;~f'~~
AD
A15-------'\
FROM
BUS
A1--------,)
DO
FROM
BUS
Figure 3.11 Writing words to mem-
ory.
Example 1: Interfacing to Z6132'S 41
R/WLOW
A15-----.J\
FROM
BUS
A1-----,/
015 00
FROM
BUS
Figure 3.12 Writing bytes to mem-
ory.
program counter should always hold an even value. The implied system- and
normal-mode stack pointers should also have even-valued contents.
The timing of the address strobe (AS) in relation to the address and
status signals at the memory control logic should be examined carefully.
The status and address lines are guaranteed to be stable CPU outputs before
the rising edge of AS. However, these signals may pass through buffers and
decoders before reaching the memory control logic. If AS is used to latch
these signals at the memory controller, the maximum delay time for the
status and address signals to pass through any intermediate decoding or buf-
fering logic must be taken into account, and the AS to the memory control
logic may need to be delayed accordingly. (Appendix A contains timing
information for the Z8000 CPUs.)
Rather simple memory control logic is needed in Z8000 systems when using
Z-Bus-compatible memories such as the Zilog Z6l32 Quasi-Static RAM. The
Z6l32 is a 4K X 8 dynamic RAM with on-board memory refresh capability.
A functional pin diagram is shown in Fig. 3.13. Inputs include 12 bits of ad-
dress, for addressing the 4096 bytes of memory on the chip, an address clock
(AC), a data strobe (DS), a write enable (WE), and a chip select (CS). Data
lines DO-D7 serve as data inputs during memory writes and data outputs
during memory reads. The BUSY signal is an input or output, depending on
the refresh mode chosen.
A read or write operation to a Z6l32 memory chip starts on the rising
edge of the address clock (AC) input, at which point the chip select (CS),
write enable (WE), and address inputs AO-All are examined (Fig. 3.14). If
26 22 27 20
10 AO
A1
A2
A3
AS Z6132
RAM
28
GND _ 1 4
23
A~A11 ( ADDRESS
INVALID )
AC~ I
CS \ I
WE
/ \
D~D7 TRI-STATED
( DATA OUT
VALID )
DS
\ I
Z6132 Read Timing
A~A11----------~(~__~~~__~~______________________________
CS
WE
\ /
D~D7----------------______________~(~_______~~:~~~~_IN______~)~________
DS
\~_~I
Z6132 Write Timing
42
Example 1: Interfacing to Z6132'S 43
the chip is not selected (CS is high), all other inputs are ignored for the rest
of that cycle, that is, until the next rising edge of AC. For a memory read
(WE high), a low on the DS will activate the data outputs DO-D7; in other
words, the DS is a data output enable signal. For memory writes (WE low),
the falling edge of DS latches the data on the DO-D7 inputs into the ad-
dressed memory location. Note that the Z6132 timing is very similar to the
Z-bus memory timing shown in Fig. 3.9. (Further details of Z6132 opera-
tion are discussed in Chapter 12.)
Consider a Z8002-based system with 4K words of memory, where the
six memory address spaces are not differentiated; in other words, the same
4K words of memory are accessed by the CPU for system-mode and normal-
mode program, data, and stack references. Thus the MREQ signal can be
used in lieu of the STO-ST3 status lines to indicate a memory access. The
4K words of memory can be organized as two banks of 4K bytes each, where
one Z6132 chip holds the even-addressed bytes, and a second Z6132 holds
the odd-addressed bytes (Fig. 3.15). During word and byte read transac-
tions, both banks are accessed simultaneously, and the word on the address/
data bus consists of one byte from each bank. For byte writes, the banks
are accessed separately.
A connection diagram for this memory interface is shown in Fig. 3.16.
Ignoring detailed timing considerations for now, the AS CPU output would
connect directly to the Z6132's AC input; the DS CPU output connects to
the memory's DS input; the R/W CPU output connects to the memory's WE
input. The BUSY outputs from memory are tied to the CPU's WAIT input.
Addresses are latched internally in the Z6132 by the rising edge of AC,
and the Z6132's data lines are tri-stated except when DS is active. As a
result, the address/data bus does not need to be demultiplexed or latched
external to the memory chips. The Z6132's address inputs AO-A11 are used
to select one of 4096 bytes in the memory chip. Since the address bit on
AC, os, WE
Z6132 Z6132
-
Z8000 4Kx8 4Kx8
CPU (ODD BANK) (EVEN BANK)
ODD
cs
BUSY
f"
Z6132 (ODD)
...-f- cs
WAIT
I AC os WE Alll0 9 8 7 6 5 4 3 2 1 AO 07 6 5 4 3 2 1 DO
AD15
14
13
12
11
10
9
8
7
6
5
4
Z8002 3
(Z·BUS) 2
1
ADO
AS
os
R/W
B/W
MREQ - ~
+-n _ '-
AC
BUSY
os WE All 10 9 8 7 6 5 4 3 2 1 AO
Z6132 (ODD)
07 6 5 4 3 2 1 DO
~~I"
Figure 3.16 Z8002-Z6132 interface logic for a 4K word system.
bus line ADO is used to address bytes in a word, not to address the word
itself, this line is not used as an address input to the Z6I32's. Thus ADI
supplies the AD memory address input, AD2 is connected to the memory's
AI, and so on. (Since only 4K words are being addressed, the address bits
that appear on bus signals AD13, AD14, and AD15 are not used.) The Z6I32
that holds the even-addressed bytes has its data lines connected to the
upper half of the CPU's address/data bus, since the even-addressed byte is
the most significant byte in a word. The Z6I32 with the odd-addressed bytes
has its data lines connected to the lower half of the address/data bus.
The chip-select signals to memory are generated from the R/W, B/W,
and MREQ status lines and the address bit on ADO. Chip selects are latched
internally in the Z6I32 by the rising edge of AC. Assuming that MREQ is
active, both Z6I32's are to be chip selected if the B/W line is low, indicating
a word access, or if the R/W line is high, indicating a memory read. For byte
writes, the Z6I32 holding the even-addressed bytes is chip selected if ADO is
a 0 during AS active, and the Z6I32 holding the odd-addressed bank of
bytes is chip selected if ADO is a 1 during AS active.
Example 1: I nterfacing to Z6132'S 45
Z6132 Z6132
Z8000 CPU
EVEN BANK ODD BANK
AS - - - - - - - - - - - - - - - - A C : - - - - - - - - - - - AC
os - - - - - - - - - - - - 0 $ , - - - - - - - - - os
R/W - - - - - - - - - - - - - W E : - - - - - - - - - - - WE
B U S Y - - - - - - - - - - BUSY
AD,--------------------------
AD , - - - - - - - - - - - -
AD 2 - - - - - - - - - - - - - -
Ao
A,
Ao -
A, -
Do
D,
1
AD 3 - - - - - - - - - - - - A2 A2 - D2
AD 4 - - - - - - - - - - - - - - - A3 A3 - D3
AD 5 - - - - - - - - - - - - A4 A4 - D4
ADs------------- A5 A5 - D5
AD,------------ As As - Ds
ADs------------ A7 - Do A7 D7
AD g - - - - - - - - - - - - - As - D, As
AO,o----------- Ag- D2 Ag
AD ,, - - - - - - - - - - - A, o - D3 A '0
AD ,2 - - - - - - - - - - - ,1 -A 04 A"
AD ,3 - - - - - - - - - - - . - - - - D5
AD , 4-----------1r-+--- Ds
AD ,5 ----------.-+-+---- D7
BYTE/WORD - - - t - - - - I
RIw 0--
'/,LS157
ADO
Za Zb
TO TO
LS138 EVEN LS138 ODD
cs cs
This design can be easily expanded to include the full 64K bytes addres-
sable by the Z8002. The address bits output by the CPU on AD13, AD14,
and AD15 are decoded to generate chip selects to eight pairs of Z6132 mem-
ories, where each pair of memory devices holds 4K words. In Fig. 3.17, two
74LS138 3-to-8 decoders are used to decode the upper three address bits to
generate the chip-select signals to the memories. A 74LS157 2-to-1 multi-
plexer replaces the combinational logic of the previous example, and it enables
the 74LS138's to activate the chip selects for the odd bank of bytes, even
bank of bytes, or both, as determined by the B/W, R/W, and ADO signals.
Not shown in Fig. 3.16, but still necessary, is the MREQ signal, which would
also be used as an enable signal to the 74LS138 decoders.
If separate memory address spaces are required, the N /8 and STO-ST3
status signals must also be decoded and used as part of the logic that gener-
ates the chip selects. Similarly, the segment number in a Z8001 system
would be decoded as part of the chip-select logic to select only the appropri-
ate memory devices within the particular memory segment being accessed.
46 Interfacing to Memory Chap. 3
If the access time of the memory being used is longer than the normal
interval from the rising edge of AS to the rising edge of DS, WAIT signals to
the CPU may need to be generated. (Wait-state generation is discussed in
Chapter 5.)
In both of the examples above, signals from the Z8000 CPU are directly
connected to the appropriate memory and logic devices. In actual systems,
buffering is usually required for CPU outputs, since the CPU can drive only
one standard TTL load. (CPU bus and signal buffering is discussed in Chap-
ter 11.)
I
WAIT
WAIT-
STATE
GENERATOR I
I_------~
I
LATCH
ADO-AD151\~~_ _ _ _--,
AS 1--------'
ADO-AD15
~ .-------~
STO-ST3
~
H - PROGRAM 1
o 1
Q
1
o
74LS42 I'" « « «
4·TO-16
.....~D,;..;.AT:.;..::A_+__r_......
DECODER IO
~_--iI
IV STACK D-- DATA/stAcK AO-All 00-07 AO-All 00-07
ADO Z6132
S Z6132
-l
bJ
RM (ODD)
C (EVEN)
E S
r - Ao EVEN _ '-------I
ZA
BNi 1---..-1f----1 A
L I-- Bo
1 74LS157
MULTIPLEXER
MEMORY REFRESH
The Z80 CPU was the first microprocessor that included logic for automat-
ically refreshing dynamic memories. In Z80 systems, a refresh is performed
48 Interfacing to Memory Chap. 3
after each instruction fetch cycle. The Z8000 CPUs also have automatic
memory refresh capability. The Z8000 refresh function is more flexible
than the Z80's; the refresh operation can be enabled or disabled and the
refresh rate can be set under program control.
The refresh function in the Z8000 CPUs is controlled by one of the
CPU control registers, the refresh register. The refresh register is identical in
format in the Z8001 and the Z8002; it contains an enable bit, a 6-bit rate
counter, and a 9-bit row address counter (Fig. 3.19). The enable bit, bit 15,
is set to enable automatic refresh and reset to disable refresh. The rate
counter, bits 9 through 14, determines the time between successive refreshes.
When a refresh cycle occurs, the row address in the row counter, bits 0-8, is
output on the address/data bus.
The rate counter is a programmable 6-bit prescaler which can be loaded
with a value from 0 to 63. This counter is decremented every four CPU
clock cycles (every 1 /1S at 4 MHz). A refresh cycle is performed as soon as
possible after the transition from a count of 1 to a count of O. The original
starting count is automatically reloaded after the counter reaches O. Loading
a starting count of zero provides the longest possible period between refresh
cycles: 64 X 4 X the clock period.
During a refresh cycle, the row counter in the refresh register is output
on ADO-AD8, and the ST3-STO status lines are set to 0001. Since memory
in Z8000 systems is word organized, and ADO is used only to distinguish
bytes within a word, ADO is not considered part of the memory's row ad-
dress, and is always 0 in the refresh register. The row counter is incremented
by two after each refresh; thus the row counter cycles through 256 distinct
addresses on the AD1-AD8 lines, providing refresh for up to 256 rows of dy-
namic memory. (Most 16K dynamic RAMs are organized with 128 rows to
be refreshed. Some 64K RAMs have 256 rows to be refreshed.)
A memory refresh cycle occurs as soon as possible after the rate count
goes to zero. The refresh cycle takes three CPU clock periods; refresh timing
will be analyzed in Chapter 5. Of course, the CPU cannot issue memory re-
freshes when it does not have control of the bus due to a bus request from
another device, such as a DMA controller. However, internal circuitry in the
CPU will record up to two missed refresh cycles and issue those refreshes
immediately after regaining control of the bus.
The refresh register can be read from or written to using the Load Con-
trol (LDCTL) instruction when the CPU is in the system mode. Resetting
the CPU causes bit 15 of the refresh register to be reset, disabling the auto-
matic refresh function. Automatic memory refresh is begun by loading a
rate that guarantees the proper interval between refreshes into the rate
15 14
ROW COUNTER
0 1 2 3 4 5 6 7 8 9 A B C 0 E F
0
1
2
3
w 4 NO REFRESH
!;:
III 5
a:: --f-
w
Q. 6
Q.
~
u.. 7
o
W 8 256 4 8 12 16 20 24 28
...I
III
III 9 32 36 40 44 48 52 56 60
Z
a:: A 64 68 72 76 80 84 88 92
w
Q.
Q. B 96 100 104 108 112 116 120 124
~
C 128 132 136 140 144 148 152 156
0 160 164 168 172 176 180 184 188
E 192 196 200 204 208 212 216 220
F 224 228 232 236 240 244 248 252 Figure 3.20 Refresh period in clock
cycles.
counter and setting bit 15. Figure 3.20 shows the relationship between the
value loaded into the upper byte of the refresh register and the number of
clock cycles between each refresh. For example, loading a 9EOO into the
refresh register means that a refresh will be generated every 60 clock cycles
(every 15 I1S in a. 4-MHz system, which is adequate to satisfy the worst-case
refresh requirements of typical 16K RAMs).
When reading the refresh register using the LDCTL instruction, only the
row counter portion (bits 0-8) of the register can be read. Thus the next
row address to be refreshed can be read anytime while in the system mode.
4
Interfacing to Peripherals
The Z8000 CPUs interface to I/O devices in the same manner as memory:
asynchronous data transfers on the 16-bit multiplexed address/data bus. I/O
addresses emitted by the CPU on the bus are always 16 bits long. (The seg-
ment number output by the Z8001 applies only to memory addressing, and
is not used for I/O addressing.) Thus the Z8000 can address up to 65,536
I/O devices per I/O address space. Each peripheral device can be byte or
word organized; both byte and word I/O instructions are included in the
instruction set.
There are two I/O address spaces in Z8000 systems: standard I/O and special
I/O (Fig. 1.6). These I/O address spaces are distinct from the memory ad-
dress spaces; they can be accessed only by the execution of specific I/O in-
structions. All I/O instructions are privileged instructions and therefore can
be executed in the system mode only. Thus, in an operating system environ-
ment, only the operating system software can access peripheral devices. If
an applications program running in the normal mode attempts an I/O in-
struction, a trap will occur (see Chapter 6). Therefore, the separation of the
I/O and memory address spaces and the inclusion of specific I/O instructions
lead to a built-in protection mechanism for operating system applications.
Memory-mapped I/O schemes are possible in Z8000 systems, but since in-
structions that act on memory can then cause I/O data transfers, it would be
50
I/O Interface Signals 51
The set of Z-Bus signals used to interface a Z8000 CPU to a peripheral device
is similar to the signals used for interfacing to memory. Data transfers occur
on the 16-bit multiplexed address/data bus. The chip-select signal to a pe-
ripheral is decoded from the 16-bit address that appears on the bus at the
start of an I/O transaction and from the STO-ST3 status lines, which signal
when an I/O transfer is occurring. Timing of data transfers between the CPU
and peripherals is controlled by the address and data strobes (AS and DS).
The peripheral might return an active WAIT signal during data transfers to
extend the data transfer timing. The R/W and B/W signals define the direc-
tion and size of the data transfer. Thus these signals, together with the
RESET line, define the Z-Bus interface to peripheral devices (Fig. 4.1).
The Z8000 CPU accesses peripherals in a manner similar to memory ac-
cesses. The start of a CPU-peripheral data transfer is signaled by AS going
low (Fig. 4.2). The status signals (which should indicate standard or special
I/O status) and the peripheral address on the address/data bus are guaranteed
to be valid at the rising edge of AS; this edge can be used to latch these sig-
nals, if necessary. The status and address signals would be decoded to gener-
ate the chip-select signals to the system's peripheral devices.
During I/O read operations, DS going low indicates that the CPU has
52 I nterfacing to Peripherals Chap. 4
< >
ADo-AD,s
-RESET_
A~-AD"=l~
STATUS
DECODE
Figure 4.1 Z-Bus signals for CPU-
peripheral data transfers.
reversed the direction of the address/data bus, and the data to be read from
the addressed peripheral can be placed on the bus. Thus DS can be used to
enable the buffers that drive data from the peripheral onto the bus. For I/O
writes, DS goes low after the CPU replaces the address on the bus with the
ADO-AD15 --~(
VALID
ADDRESS )>-----------4(DATA TO CPU)---.
VALID
ADO-AD15 --~( ADDRESS }--{ DATA FROM CPU )--
-----------~
AS\ I
STO-ST3 --~('-______________I/O_S_T_AT_U_S_ _ _ _ _ _ _ _ _ _ _ _ ..J}______
R/VI
\ c=
\\.--_---11
Write Cycle Timing
BYTE RETURNED
FORAO=~
Z·BUS
Z8000 PERIPHERAL
A ~
AD3-AD15 ( )
~ '---"
A .,--...
ADO-AD7 ( )
~
r
BYTE RETURNED
FOR AO=1
Figure4.3 CPU-peripheral byte data
transfers.
data to be written; DS is used to enable the write to the peripheral. The I/O
device can lengthen the data transfer timing by asserting an active WAIT sig-
nal, thereby allowing the Z8000 CPUs to interface to I/O devices with arbi-
trarily long access times. The timing of data transfers is determined entirely
by the AS, DS, and WAIT signals; the CPU clock is not part of the Z-Bus
interface.
Data transactions in a Z8000 system can be 8-bit or 16-bit transfers, al-
lowing the use of both byte-oriented and word-oriented peripherals. The
Z8000 handles byte I/O transactions in much the same manner as byte mem-
ory operations. For byte write I/O operations, the CPU outputs the byte of
data on both halves of the address/data bus during DS, and the byte periph-
eral can read the data from either half of the bus. For byte read I/O opera-
tions, the CPU will read the whole word returned on the bus, and internally
select one byte of that word. If AO (port address bit 0) was a 0 during AS
active, the CPU will select the upper half of the bus as the byte to be read; if
AO was aI, the CPU will read the byte from the lower half of the bus (Fig.
4.3). Thus byte peripherals must use the appropriate half of the bus for data
transfers-the upper half of the bus if the peripheral has an even port ad-
dress, and the lower half of the bus if the peripheral has an odd port address.
For word I/O operations, the CPU will read or write a whole 16-bit word re-
gardless of the port address, and, therefore, word peripherals can have an
even or an odd address.
I/O control logic is the logic needed to interface a particular I/O device to
the Z-Bus signals from the CPU. Z8000 family peripherals, such as the
Z8036 Counter/Timer and Parallel I/O Unit, are Z-Bus compatible and need
very little interface logic. These devices connect directly to the Z-Bus, and
the only external logic needed is the logic for decoding the address and
status lines to generate chip selects (see Chapter 12).
Other peripherals besides Z8000 family devices can be used with a
Z8000 CPU. In most cases, interface logic is needed to multiplex, demulti-
54 Interfacing to Peripherals Chap. 4
plex, and drive the address/data bus, to generate chip selects from the ad-
dress and status signals, and to generate the appropriate timing signals for
that peripheral from the address and data strobes.
For example, suppose that a Z8000 system has an byte I/O device con-
sisting of eight lamps and eight switches. This peripheral is assigned I/O port
address 0003. When reading port 0003, the CPU will read a byte of data
from the switches. When writing to port 0003, the Z8000 will write a byte
of data to the lamps. Figure' 4.4 is a block diagram of the logic used to im-
plement the interface between the CPU and the lamps and switches. The ad-
dress and status lines are latched by the rising edge of AS. If the address
lines are 0003 and the ST3-STO status lines are 0010 (standard I/O status),
the decode logic pulls the SELECT signal low. If the operation is a write
(R/W low), the data on the lower half of the bus are latched by the data
strobe and propagated to the lamps. If the operation is a read, the tri-state
buffer is enabled by the data strobe, feeding the output of the eight switches
onto the address/data bus, where it can be read by the CPU. This byte I/O
device must have an odd address since all data connections are made to the
lower half of the address/data bus.
An example of a Z-Bus interface to Z80 peripherals is illustrated in
Chapter 11.
AS
t
ClK
STO-ST3
ADO-AD15
v
lATCH
J..
DECODE
lOGIC
-
SELECT
r--v'
....
0
0:(
6
.0
0:(
~ .
.. ;.. . lATCH
. lAMP
DRIVERS
ClK
DS
R/W =r>-
-
t
SWITCHES
- TRI-STATE
BUFFER
A.
, ~
-<l-
EN !
t
L-==rJ
Figure 4.4 Z-Bus interface to a byte peripheral consisting of switches
and lamps.
Z-Bus I nterrupt Signals 55
_INT--
CPU
~
~ DECODE _
INTACK
PERIPHERAL
L
r --
-IE
_ I-
1EO Figure 4.5 Z-Bus interrupt signals.
Besides responding to data transactions on the Z-Bus (which are always initi-
ated by a CPU or some other bus master), peripherals in Z8000 systems can
also request the CPU's attention via the CPU's interrupt inputs. The CPU re-
sponds to an interrupt by entering an interrupt acknowledge cycle; the inter-
rupt acknowledge signal to the peripheral is generated by decoding the STO-
ST3 status signals (see Table 1.1). Peripherals can use any of the CPU's
interrupt inputs (NMI, NVI, or VI), and more than one peripheral can be
connected to the same CPU interrupt input. Interrupt priority among pe-
ripherals that share a CPU interrupt line is determined by a hardware daisy
chain. Each I/O device sharing the interrupt has an input, Interrupt Enable
In (lEI), and an output, Interrupt Enable Out (lEO), that are used to estab-
lish an interrupt-under-service daisy chain. Thus the Z-Bus signals necessary
for interrupt requests from a peripheral include an interrupt (INT) signal
from the peripheral, an interrupt acknowledge (INT ACK) signal from the
CPU (decoded from the STO-ST3 signals), and the lEI and lEO daisy-chain
signals (Fig. 4.5). Interrupts and the interrupt daisy chain are described in
detail in Chapter 6.
The CPU's vectored interrupt (VI) input is the most commonly used in-
terrupt for peripheral control. During the interrupt acknowledge cycle for
vectored interrupts, an 8-bit vector is output by the interrupting device. The
CPU reads this vector and uses it to determine the location of the interrupt
service routine. During the vectored interrupt acknowledge sequence, the
CPU reads the vector from the bottom half of the address/data bus (ADO-
AD7). The interface logic for an I/O device is usually much simpler if all
transfers between the device and the CPU can occur on the same bus lines.
Thus byte peripherals that use vectored interrupts are usually connected to
the bottom half of the address/data bus, so both the data and the interrupt
vector can be transferred on ADO-AD7. These byte peripherals would, then,
have odd addresses.
5
Instruction and
Interface Timing
The Z8000 CPUs execute instructions by stepping through basic timing se-
quences such as memory reads and writes, I/O reads and writes, and inter-
rupt acknowledgments. These timing sequences, called machine cycles, are
designed to use the Z8000's multiplexed addresss/data bus in an efficient
manner. Typical Z8000 systems will use the bus for transactions well over
80% of execution time. (In comparison, the Z80 is involved in transactions
on its address and data buses about 65% of its execution time.) Thus Z8000
systems often have better throughput than competitive devices that run at
faster clock speeds.
Throughput in Z8000 CPUs is optimized in two ways. First, the en-
coding of instruction operation codes (opcodes) is designed so that the most
frequently used instructions, such as jumps and loads, have short opcodes
and fast execution times. For example, a register-to-register load has a single
word opcode and executes in three CPU clock cycles. Second, the execution
of an instruction is overlapped with the fetch of the next instruction when-
ever possible, as explained below.
INSTRUCTION PREFETCH
Most Z8000 instructions conclude with several clock periods dedicated to in-
ternal CPU operations, such as arithmetic operations where a CPU register is
the destination. While these internal operations are being executed, the CPU
will start to fetch the next instruction's opcode (Fig. 5.1). This overlapping
56
Basic Timing Periods 57
Figure 5.2 illustrates the three basic timing periods of the Z8000: clock
cycles, bus transactions, and machine cycles. A clock cycle, also called a T-
state, is one cycle of the CPU clock, starting with a rising edge. A bus trans-
action is the time required for a single data transaction on the address/data
bus (that is, the time needed to move one 16-bit word of data between the
CPU and a memory or I/O device). The start of a bus transaction is signaled
by AS going low; bus transactions end with the rising edge of DS. A bus
transaction always takes three or more clock cycles depending on the type
CPU CLOCK
v
v
Figure 5.2 Basic timing periods for the Z8000.
58 Instruction and Interface Timing Chap. 5
of transaction and the state of the CPU's WAIT input during the transac-
tion. A machine cycle is the time required for one basic CPU operation;
that is, a machine cycle is the time from the start of one bus transaction to
the start of the next bus transaction. A machine cycle can extend beyond
the end of a bus transaction, as shown in Fig. 5.2, to allow time for the
routing of data internal to the CPU after the bus transaction is completed.
There are four basic types of machine cycles that can occur during the
execution of a Z8000 instruction: memory cycles, I/O cycles, internal oper-
ation cycles, and memory refresh cycles. Instruction execution is modular;
all instructions are executed with combinations of these four basic machine
cycles.
MEMORY CYCLES
Memory transactions move data between the CPU and memory. Memory
transactions include instruction fetches, data reads and writes during instruc-
tion execution, and the storing of old program status and the fetching of
new program status during interrupt and trap processing. (Interrupts and
traps are discussed in Chapter 6.) For a given bus transaction, the code on
the STO-ST3 status lines indicates if the transaction involves a memory ac-
cess and, if so, what memory address space is being accessed (Table 5.1).
The MREQ line also can be used to signal that a memory access is taking
place.
Instruction fetches and data reads are identical memory read cycles,
with the exception of the code that appears on the STO-ST3 status signals.
Thus memory read cycles are generated to fetch instructions from memory,
to read data from memory during the execution of instructions, and to fetch
new program status during the interrupt acknowledge sequence or after a
reset.
Figure 5.3 shows the timing of a standard memory read bus transaction.
During the first clock period (Tl), a 16-bit memory address is output on the
address/data bus and the appropriate status information is generated on the
R/W, B/W, N /8, and STO-ST3 lines. A high signal on the R/W line and a
memory access status code on STO-ST 3 indicate a memory read transaction.
TABLE 5.1 STATUS CODES FOR MEMORY ACCESSES
~
Tn
.. T,
.. 41
T2
- T,
1-
CLOCK
- 1 I ~WA" ~ T
DATA SAMPL ED
FOR READ
WAIT
STATUSES
(BIW, NIS,
STo-ST3)
AS
!
MREQ
I
AD ~.
)--- (
READ
MEMORY ADDRESS
I"
DATA IN
>
OS
READ
RIW
READ I L
Figure 5.3 Memory read bus transaction timing.
The address strobe (AS) goes low, signaling that the address is present on the
bus. All address and status information is guaranteed to be valid on the
rising edge of AS. The status information stays valid for the remainder of
the bus transaction.
For the Z8001, the segment-number portion of the address is output
during the clock period preceding Tl, that is, during the last clock period of
the previous machine cycle (Tn in Fig. 5.3). The segment number is output
earlier than the offset address during a memory access cycle to compensate
for delays in memory management hardware. For example, the Z8010 MMU
uses the segment-number output by the CPU to access an internal MMU
register. The contents of that register control the address translation process
that determines what physical address will be output by the MMU for a given
logical address from the CPU. (The segment number is a part of the logical
address.) This internal MMU access does take some time, of course. But
60 Instruction and Interface Timing Chap. 5
since the CPU outputs the segment number earlier than the offset portion of
the logical address, the MMU has extra time to make its internal register
access, and is ready to complete the address translation when the offset fi-
nally does appear. Thus the delay in the MMU between receiving a valid
logical offset address from the Z8001 CPU and outputting a valid physical
address to memory is minimized. (Timing considerations for the MMU are
discussed further in Chapter 9.)
During T2 of the memory read cycle, the address is removed from the
bus. DS is lowered, indicating that the bus is available for data. The con-
tents of the addressed memory location can be placed on the bus at any time
while DS is active.
The address/data bus is sampled by the CPU on the falling edge of the
clock during T3. If the B/W line is high, indicating a byte read, only one half
of the data bus will be sampled-the upper half if AO was a 0 when the ad-
dress was emitted during T1, or the lower half if AO was a 1 (see Chapter 3).
The contents of the addressed memory location must be placed on the bus
before the middle of T3. The memory access time in a Z8000 system is,
therefore, the time from the rising edge of AS (address guaranteed valid)
until the falling edge of the clock in T3 (minus a small setup time for the
data). For a three-clock-period memory read (no active WAIT signal) on a
Z8000 system running at 4 MHz, this access time is a minimum of 360 ns.
With a 6-MHz clock, the minimum memory access time is 220 ns; with a 10-
MHz clock, the minimum memory access time is 140 ns.
If a long memory access time is necessary, the time interval between DS
going low and the start of T3 can be extended by pulling the CPU's WAIT in-
put low. The WAIT input is sampled during the middle of T2 at the falling
edge of the clock. If the WAIT input is low at this time, an additional clock
period is inserted into the bus transaction between T2 and T3. The WAIT
signal is sampled again at the falling ege of the clock during this additional
clock period; if the WAIT line is still low, yet another clock period is inser-
ted before T3, and so on. These additional clock periods are called wait
states, and designated Tw. Figure 5.4 shows memory read timing with one
wait state inserted. The status of the WAIT input is sampled during each
wait state to determine if additional wait states are to be added. Thus the
delay between T2 and T3 can be arbitrarily long, in increments of one clock
period, as controlled by the WAIT input. This allows the Z8000 to be easily
interfaced to memories with arbitrarily long access times. None of the status
or control outputs from the CPU change during wait states; in other words,
all the CPU outputs maintain the values they had at the end of T2 during all
wait states.
The memory write cycle is very similar to the memory read, as shown
in Fig. 5.5. Memory write machine cycles are used to store data in memory
during instruction execution and to store program status during the interrupt
acknowledge sequence. During T1, address and status information is output;
Memory Cycles 61
1 2 W 3
1
I J$
Vt
DATA SAMP LED
CLOCK
- ~WAIT SAMPLED _
T FOR READ
WAIT
STATUSES
(B/W. N/S.
ST o- ST3)
AS
-
MREQ
AD - --- '>--- (
>
MEMORY ADDRESS DATA IN
READ
- r---
#
OS
READ
/ ~
R/W
READ
Figure 5.4 Memory read bus transaction timing with one wait state.
the address and status signals are valid at the rising edge of AS. Memory
transaction status on the STO-ST3 lines and a low on the R/W line indicate
that this transaction is a memory write. During T2, the address is removed
from the bus, the data to be written to memory are placed on the bus by the
CPU" and DS goes active. For byte transactions (B/W high), the byte of data
to be written will appear on both halves of the address/data bus while DS is
active. The bus transaction is completed during T3 when DS goes high. The
data are guaranteed to be valid on the bus and can be written into memory
anytime while DS is low. Thus the access time for a memory write is the
time from the rising edge of AS until the rising edge of DS. As with memory
reads, the WAIT input is sampled in the middle of T2, and any resulting wait
states are added between T2 and T3.
62 Instruction and Interface Timing Chap. 5
. Tn
--- ,
.. .-
,
. 3
1-
I I ~ (~
DATA SAMPL ED
CLOCK
- WAIT
t
WAIT CYCLES ADDED
FOR READ
SAMPLED
WAIT
STATUSES
(B/W, N/S,
STo-ST3)
AS
- -
MREQ
AD
MEMORY ADDRESS DATA OUT
WRITE
OS
WRITE
R/W
WRITE
\ r
Figure 5.5 Memory write bus transaction timing.
The bus transaction time for a memory read or write is always three
clock periods, excluding possible wait states. However, for some instruc-
tions, the machine cycle for a memory access can be one to four clock cycles
longer than the bus transaction time. These extra cycles are added after T3,
but before the start of the next bus transaction; they are used to allow extra
time for the routing of data internal to the CPU.
I/O CYCLES
status lines indicate a standard I/O (0010 status) or a special I/O (0011
status) reference during I/O cycles.
I/O read timing is illustrated in Fig. 5.6. I/O bus transactions are four
clock cycles long as a minimum but can be lengthened by the addition of
wait states. During T1, the 16-bit I/O address is placed on the address/data
bus, and the appropriate status signals are output. The address and status
information are guaranteed to be valid at the rising edge of AS. An I/O read
is indicated by I/O status on the STO-ST3 lines and a high on the R/W line.
The N /8 output is always low during I/O transactions, since I/O instructions
can be executed only in the system mode. The status information remains
valid for the remainder of the bus transaction.
During T2 of the I/O read cycle, the I/O address is removed from the
bus and then DS is lowered. DS low indicates that the bus is available to
receive data from the peripheral device. Data must be placed on the bus
before the falling edge of the clock in the middle of T3, at which time the
.. T,
- T2
.. TWA
.. T3
CLOCK
- I I (~
1
T
DATA SAMPL ED
FOR READ
WAIT
SAMPLED WAIT CYCLES ADDED
WAIT
STATUSES
(B/Vi. STo-ST3)
Nli
-
- ex LOW
-
AS
r\-
HIGH
MREQ
-
AD
INPUT
> C
os
INPUT
-U ~
Rlii
INPUT
CPU samples the data bus. For a byte read (B/W high), the CPU will accept
data from one-half of the l6-bit bus, depending on the value of AD of the
I/O address output during Tl.
One wait state, TWA, is always added between T2 and T3 of the I/O
machine cycle, regardless of the state of the CPU's WAIT input. On the fall-
ing edge of the clock in the middle of TWA, the WAIT input is sampled. If
the WAIT line is low, another wait state is inserted before T3. The WAIT in-
put is sampled during each wait state, and, as with memory cycles, an arbi-
trary number of wait states can be added to the I/O cycle between T2 and
T3. N one of the status or control signals change during the wait states.
Thus the I/O bus transaction timing can be lengthened through the use of
wait states to accommodate slow peripheral devices.
The I/O write transaction timing is shown in Fig. 5.7. The I/O address
and status information is output during Tl and is valid at the rising edge of
AS. An I/O write is signaled by I/O status on the STD-ST3 lines and a low
.. T,
....-----,-_ ..
T2 TWA
.. T3
1
I I ~ ~
CLOCK
-
DATA SAMPL ED
T FOR READ
WAIT
SAMPLED WAIT CYCLES ADDED
-
STATUSES
(B/Vi, ST.-ST3)
- =x
HIS
LOW
-
AS
~
HIGH
I
I
AD
OUTPUT
-
- ex PORT ADDRESS DATA OUT
os
OUTPUT
-
RIW
OUTPUT
r\ r
Figure 5.7 I/O write bus transaction timing.
Internal Operation Cycles 65
on the R/W line. During T2, the address is removed from the address/data
bus, the data to be written are placed on the bus, and DS goes low. For a
byte write (B/W high), the byte of data to be written appears on both halves
of the bus. The data to be written remain on the bus and can be read by the
peripheral device throughout the duration of DS active. One automatic wait
state, TWA, is always inserted between T2 and T3. The rising edge of DS
marks the end of the write operation. Of course, more wait states can be
added between T2 and T3 by pulling the WAIT input low. The timing of
I/O transactions is similar to the timing of memory transactions, except for
the addition of the one automatic wait state.
r----
CLOCK
- I LI LI L
AI
AD UNDEFINED ')--
- r--
HIGH
Bi'ii UNDEFINED
I
Figure 5.8 Internal operation bus transaction timing.
66 Instruction and Interface Timing Chap. 5
CLOCK
STo-STa REFRESH
sary for the system's memory devices. Therefore, the effect of the memory
refresh on CPU throughput can be minimized. Of course, if the automatic
memory refresh mechanism is disabled (bit !5 in the refresh register is a 0),
memory refresh cycles will never occur.
As with internal operations, the WAIT input is not sampled during
memory refresh cycles. Internal operations and memory refreshes are the
only types of bus transactions that do not involve a transfer of data.
All Z8000 instructions are executed using a combination of memory,
I/O, and internal operation cycles, with refresh cycles added as dictated by
the refresh control register. For example, adding two word registers takes one
memory read cycle (an IF! cycle) that is four clock periods long. Dividing a
word register by another word register takes a five-clock-period memory
read (IF! cycle), followed by two six-clock-period and one seven-clock-period
internal cycles. Writing a byte from a register to an I/O device (direct-
address addressing mode) requires a five-clock-period and a three-clock-
period instruction fetch, and a four-clock-period I/O cycle.
Special exception conditions can cause timing sequences other than the
four basic machine cycles described above. The CPU responds to interrupts,
traps, and bus requests with special acknowledgment cycles. An active
RESET or STOP input forces the CPU into special sequences. Execution of
a HALT or MREQ (multi-micro request) instruction also alters CPU timing
sequences. These special timing cycles will be discussed in later chapters.
AC TIMING CHARACTERISTICS
Table 5.2 lists some of the timing characteristics of the Z8000 CPUs that
apply to memory and I/O interfacing. These figures are compiled for Z8001/
Z8002 CPUs running at 4 MHz and Z8001A/Z8002A CPUs running at 6
MHz. Most of these timing parameters are dependent on the cycle time of
the CPU clock; see Appendix A for the complete Z8000 AC timing charac-
teristics and the corresponding timing diagram.
During T1 of a memory or I/O access, the rising edge of AS signals that
the address and status information is valid from the CPU. TdA(As) and TdS
(AS) (first two entries of Table 5.2) define the setup time for the address
and status outputs before the rising edge of AS; TdAS(A) is the hold time
for the address after AS goes inactive. Thus if AS is used to latch the address
as part of the memory control logic, the setup and hold requirements of that
latch are dictated by these parameters. Similar setup and hold times for the
address in relation to the falling edge of MREQ are also given.
For a memory read, the delay from the rising edge of AS (address valid)
until the CPU samples the data bus defines the memory access time, TdAS(DR).
If MREQ is used in place of AS to detect a valid address, a slight gain in
access time can be realized [TdMR(DR)] .
68
Memory Interface Timing: An Example 69
During memory and I/O reads, valid data must be present on the bus
slightly before the falling edge of the clock in the middle of T3, as dictated
by the minimum requirement for TsDI(C). However, there is no hold time
requirement on the data after DS goes inactive. For memory and I/O writes,
valid data is output from the CPU before DS is pulled low [TdDW(DSW)],
and stays valid after DS returns high [TdDS(DW)]. Thus setup and hold-time
requirements for the data inputs of memory and I/O devices are easily satisfied.
TsWT(C) and ThWT(C) are the setup and hold-time requirements of the
WAIT input in relation to the falling edge of the clock in T2. These re-
quirements must be satisfied in order for the WAIT input to be properly
sampled and wait states inserted in a memory or I/O cycle.
When designing memory and I/O interface logic for Z8000-based systems,
the AC timing characteristics of the CPU as well as the basic timing of the
memory and I/O bus transactions must be taken into account. For example,
suppose that the Z8002-Z6132 system with 4K words of memory described
in Chapter 3 (repeated here as Fig. 5.10) is running with a 4-MHz CPU clock.
Since the memory access time for the Z8002 is a minimum of 360 ns, the
Z6132's must have an access time less than 360 ns. The Z6132-5 memory
chip, with a maximum access time of 300 ns, would be a logical choice.
Some AC timing characteristics of the Z6132-5 are shown in Table 5.3. As-
sume that the combinational logic in Fig. 5.10 consists of low-power Schottky
TTL logic, such as 74LSOO's, with a maximum gate delay of 10 ns.
The Z8002 's address/data bus, AS, DS, and R/W signals are connected
directly to the Z6132's. Examining Table 5.2 and 5.3, the setup and hold-
time requirements of the Z6132-5 for the address and WE signals with re-
spect to AS rising and the data with respect to DS falling are easily met by
the Z8002. For example, the Z6132-5 requires that the address stay valid
Nanoseconds
c-~-Sy
V
+i . 1...-----,..... .
1--1 Z6132 (EVEN)
4 7K
A0151-----------I-+-__+_-+---4--+__+_+_+_+_I--+~__+_+_+----.J
141-----------I-+-__+_-+---4--+__+_+_+_+_I--+~__+_+_+-~
13~--------~+-~-+~--4~++~~~~++-~
12~--------~+-~-+~-~~++~~~~++--~
11~--------~+-~-+~--4~++~~~~++---~
10~--------~+-~-+~--4~~~~~~++---~
9~--------~+-~-+~-_+~~~~~~++----~
8~--------~+--r-+~-_+-r++~~+4~++----~
71-----------I-+---+--+---4--+--+-+-+~~~__+_+-+~
61----------~+---+--+-4--+--+-~~~+4__+_~-h
5~--------~+--r-+~-_+~++~~+4~++-~
4~--------~+--r-+~-_+~++~~+4~~-~~
Z8002 3~--------_t_+--r-+~-_+-r+++_~+4~++-~+4___,
(Z-BUS) 2~--------_t_+--r-+~--+~+++-I~+4~~-~~--+--'
1~--------_t_+--r-+~--+-r+++-I~+4~~-~+4~+'
~1-4--------~+-~
OSI--4--------__+_+-_+_~
R/W l---+--<lf----------+-+--+--I-~
B/WI-4-~I----~
G3
A11 10 9 8 7 6 5 4 3 2 1 AO 076 5 4 3 2 1 DO
AC OS WE
MREQ I- G1 I _
G2
~L--~---l-r-G .....
6 I CS
Z6132 (O~~)
~ ~ G7 ~--------------------------------~
for 50 ns after AC rises [ThA(AC) in Table 5.3], whereas the ZS002 guaran-
tees that the address will remain valid 70 ns after AS goes high [TdAS(A) in
Table 5.2].
The only timing parameter that needs to be examined in this system is
the chip select (CS) setup time for the memory. The ZS002 guarantees that
status information is valid at least 50 ns before AS rises. The worst-case tim-
ing condition for the chip select occurs during byte writes, when the R/W sig-
nal must propagate through four gates (G1, G3, G4, and G6) before the CS
signal is stable. Assuming the worst-case conditions, the delay through each
gate is 10 ns, or 40 ns for all four gates. The CS signal is not valid until 40 ns
after the status is valid, or IOns before the rising edge of AS. Since the set-
up time for CS is 0, this still satisfies the timing requirements for the Z6132-5.
As memory systems get larger and more complex, the logic needed to
generate chip selects also grows more complex (see Figures 3.17 and 3.1S,
for example). In larger systems, the AS signal to memory may need to be
delayed before reaching the memory control"logic to ensure that all address
and status information meets the setup and hold-time requirements for the
Wait-State Generation 71
memory used. For example, if the delay from status valid until chip select
valid in the system analyzed above were 55 ns instead of 40 ns, the AS to
memory would have to be delayed 5 ns to ensure that the rising edge of AS
does not arrive at the memory before CS is stable. If buffers are added
between the CPU and memory control logic, the minimum and maximum
delays through the buffers also must be considered.
WAIT-STATE GENERATION
+5V
WAIT
7474 7474
CPU CLOCK
~------~--------~
CPU CLOCK
WAIT
'----E8~~--J1_
.-.
j
8
SAMPLED
lines; as long as I/O status is not present, the shift register performs a parallel
load on each positive CPU clock edge (the SN74178 is negative edge trig-
gered, so the CPU clock is inverted). The D input is propagated to the QD
output, and WAIT is held high. When I/O status does appear during Tl
of an I/O access cycle, the shift register enters its shift mode. The next posi-
tive CPU clock edge will shift the register one place to the right. The Qc
output was low prior to the shift, since the C input was low during the
last parallel load, so a low value is shifted into QD. The next two shifts will
also shift low values into QD, since QB and QA start out low; subsequent
shifts will send QD high again, since the serial input to the register is a 1.
Thus three wait states will be inserted in the cycle. If only two wait states
are required, the A input to the shift register can be tied high instead of low.
Both of the examples above used the status outputs to trigger the gener-
ation of the WAIT signal. A chip select to a given device or group of devices
could also have been used, if wait states are to be inserted only when those
Wait-State Generation 73
+5V
+5 V
A B D
SHIFT
LOAD
SN74178
SERIAL IN
°A aS °c 00
WAIT
CPU CLOCK
AS ----v
\~ ______________________ ~r--
.~
SAMPLED
particular devices are accessed. If more than three wait states are needed, 8-
bit shift registers such as the SN74165 can be used, or shift registers can be
cascaded together to any length. If WAIT signals are generated by more than
one circuit in the system, they would be ORed together before being input
to the CPU.
The ability to insert wait states into any memory, I/O, or interrupt ac-
knowledge cycle allows the CPU to be interfaced easily to slow memory and
peripheral devices. All Z-Bus data transactions are asynchronous; the access
time for a memory or I/O transaction can be arbitrarily long, in increments
of one CPU clock cycle, as determined by WAIT generation logic external to
the CPU.
6
Interrupts are the means by which a peripheral device can request the CPU's
attention. Interrupts are asynchronous events that can occur at any time
during program execution. An interrupt causes the currently executing task
to be suspended while the CPU responds to the device that asserted the inter-
74
Traps 75
TRAPS
PRIORITIES OF EXCEPTIONS
If more than one interrupt or trap condition is present at one time (that is,
when sampled during the last machine cycle of an instruction), the CPU re-
sponds to the exception condition with the highest priority. Internal traps
(extended instruction, privileged instruction, or system call) have the highest
priority, followed by nonmaskable interrupts, segmentation traps, vectored
interrupts, and nonvectored interrupts, in that order. Of course, resets have
a higher priority than any other condition; whenever the RESET pin is ac-
tive, a reset is performed immediately.
For some of the classes of events listed above there can be multiple
sources for a given event. The internal traps are mutually exclusive and, there-
fore, no priority resolution is needed within that class of events. The other
78 Interrupts, Traps, and Resets Chap. 6
exception conditions arise from external sources. If more than one device
shares a common request line (the SEGT or an interrupt line), a request for
service from more than one device using that line can occur simultaneously
at the CPU. For segmentation traps where more than one MMU signals the
trap, the Z8001 services the traps simultaneously, in that the acknowledge
sent during the interrupt acknowledge sequence is accepted by all the MMUs
(see Chapter 9). For interrupt requests, priority between multiple devices
sharing an interrupt input to the CPU is resolved external to the CPU via a
daisy-chain priority scheme. (This daisy chain is described later in the chap-
ter.) Priority resolution among the daisy-chained peripherals is done during
the interrupt acknowledge cycle.
INTERRUPT ACKNOWLEDGE
15
I~ 0 0 0 0 0 0 0 0 0 0 0 0 0
.....--,-I--1.1--11_11...-.1...1--LI--1.1----,11...-.1...1--LI--1.1--11_1...1--,-I--1.1---1
0 0 I RESERVED
WORD
FLAG AND
CONTROL
I WORD
SEGMENT NUMBER
! ! I I o 10
PROGRAM
COUNTER
SEGMENT OFFSET
I I I
~r_O.IS_IN~I_EP~AI_vl_EI...INV_IE.I_o~l_o~1_0-,-1c--,-l_z~l_s~l_p,~vl~D_A.l...I_H~I_o~,_o~II~~\~~
ADDRESS
'--~....L....-I--L...--'---I.--II_IL--.l...1--L--I.--.JL--.L.-..I....-....L.-...I.
I) PROGRAM
COUNTER
CPU pushes the PC, FCW, and an identifier word onto the stack, using the
system-mode implied stack pointer (system-mode RR14 in the Z8001, sys-
tem-mode R15 in the Z8002). Status is saved on the system stack regardless
of the CPU's operating mode at the time of the exception. For the Z8001,
both the segment number and offset portions of the PC are saved on the
stack, even if the CPU was in the nonsegmented mode when the exception
condition occurred. In other words, the CPU always enters the system mode
and, for the Z8001, the segmented mode during status saving in response to
an interrupt or trap. The PC is pushed first (the offset portion first for the
Z8001), followed by the FCW, and then the identifier word. For interrupts
and segmentation traps, the identifier is the value read from the address/data
bus during the interrupt acknowledge cycle. For internal traps, the identifier
is the first word of the instruction that caused the trap. The format for the
saved program status on the system stack is illustrated in Fig. 6.2. Table 6.1
lists the PC value that is pushed on the stack for each type of interrupt and
trap.
Z8002 Z8001
lOW lOW
ADDRFSS ADDRESS
SYSTEM STACK .------1
~~~~Tii= AFTER.- IDENTIFIER SYSTEM SP IDENTIFIER
AFTER TRAP
INTERRUPT '---FC-W--I OR INTERRUPT FCW
PC PC SEGMENT
SYSTEM STACK
PC OFFSET
~~~~Tii= BEFORE.-
SYSTEM SP .-
INTERRUPT t--------i BEFORE TRAP
OR INTERRUPT
_ 1WORD_ _1WORD __
HIQH
ADDRESS
~6GD~ESS Figure 6.2 Saved program status on
the system stack.
80 Interrupts, Traps, and Resets Chap. 6
After saving program status for the task that was interrupted, the CPU loads
in new program status values-a new PC and FCW, in other words-that de-
fine the CPU operating modes and starting address of the service routine.
This new program status is loaded from a block of memory called the Pro-
gram Status Area. Figure 6.3 is a diagram of the Program Status Area for
the Z800l and Z8002.
The starting address of the Program Status Area is determined by the
contents of the Program Status Area Pointer (PSAP), which is a CPU control
register (Fig. 6.4). The PSAP is loaded using the Load Control (LDCTL)
instruction. The PSAP is a single word register in the Z8002 (to hold a
l6-bit address) and two word registers in the Z800l (to hold a segmented
address). The low-order byte of the PSAP is always all O's; therefore, the
starting address of a Program Status Area is always on a 256-byte address
boundary in memory. The Program Status Area contains a list of the pro-
gram status values (that is, values for the PC and FCW) that are loaded into
the CPU's PC and FCW registers during exception processing to determine
the operating modes and starting location of each interrupt and trap service
routine. In other words, after saving the program status of the task that was
interrupted, the CPU fetches new program status values for the service rou-
tine by reading the appropriate memory locations in the Program Status
Area pointed to by the PSAP.
The Program Status Area holds an FCW and PC value for the service
routine for every possible type of interrupt or trap. The particular program
status values fetched from the Program Status Area are a function of the
type of exception that occurred and, for vectored interrupts, the vector
returned by the peripheral during the interrupt acknowledge cycle. For each
interrupt or trap there is, then, a block of memory in the Program Status
Program Status Area 81
.m """
HEX DECIMAL """'
. - - - - -.... --L RESERVED
z800i BYTE OFFSET
DECIMAL
o
HEX
0
t--R=-=E:-=-SE=-=R-:-:-VE::-::D~ -
- - -
EXTENDED FCW
I - - T - " ' ; ' - - - I INSTRUCTION
TRAP
PC
t----'--"-'--,-----I - - - -
10 16 PRIVILEGED FCW
I--r-::-=-':";':':--_l INSTRUCTION
TRAP PC
t----'=-==~=-=-_l- - - -
18 24 SYSTEM FCW 12
CALL
TRAP PC
t--::-:-:c:-:--::_::_-I- - - -
20 32
SEGMENT
NOT USED 16 10
TRAP
t--==~::-::--I- - - -
28 40 FCW 20 14
pC
30 48 FCW 24 18
PC
t----'~~::::----_l----
38 56 FCW 28 lC
3C 60 PC, 30 IE
40 64 PC2 32 20
VECTORED
INTERRUPTS
44 68 PCl 34 22
:
:
PC n
Io.....,;...;;.::..;~;.;;.;... ..... _ _ _ _ Figure 6.3 Program status areas for
23A 570 540 21C the Z8001 and Z8002.
Area that contains the values to be loaded into the FCW and PC to initiate
execution of the appropriate service routine.
For the Z8002, the FCW and PC are each always one word (16 bits)
long. Thus 4 bytes of memory are needed in the Program Status Area for
the program status values for each type of exception. Starting at the loca-
tion pointed to by the PSAP, the first two words of the Program Status Area
are reserved. (Reserved areas are locations that are not used by the Z8002,
but might be used by future upward-compatible Z8000 family processors.
'5 '5 0
1
0
1
SEGMENT NUMBER
I I I 0
1 0 1 0
1 0
1 0 1 0
1 0 1
o I I UPPER POINTER
I I I I 0 I 0 I 0 I o 1 0 I 0 I o I o I
I UPPER OFFSET
I I I o IO! 0 I o 1 0 I 0 I o I o I Z8002 Program Status Area Pointer
~ -~
~
} INSTRUCTION
SYSTEM
CALL
RESERVED
OC
10
14
NMI
18
NVI
1C
VI
1E
NEWPC
20
NEWPC
22
LN~
~21C
Figure 6.5 Z8002 Program Status
Area.
These areas should be filled with all O's.) The next two words, starting at ad-
dress 4 in the Program Status Area, are the FCW and PC value for the ex-
tended instruction trap service routine. This is followed by the FCW and PC
values for the privileged instruction trap and system call service routines, a
reserved area of 4 bytes, and then FCW and PC values for the nonmaskable
interrupt and nonvectored interrupt service routines, respectively (Fig. 6.5).
For vectored interrupts, an FCW value that will be loaded for all vectored in-
terrupts is at location 1C (hexadecimal) in the Program Status Area. This is
followed by a list of 256 possible PC values, corresponding to the 256 pos-
sible 8-bit vectors that can be returned by the interrupting peripheral during
the interrupt acknowledge cycle. The vector returned by the peripheral is
used as an index into this list to select the starting PC value for the interrupt
service routine; a vector of 0 corresponds to the PC value at location 1E
(hex) in the Program Status Area, a vector of 1 corresponds to the PC value
at location 20 (hex), and so on up to a vector value of 255 (FF hex). Thus
the value of the vector will determine which PC value is fetched when load-
ing the program status registers for the service routine from the Program
Status Area.
The program status registers for the Z8001 consist of a reserved word,
the FCW, and the PC (Fig. 6.1). The program counter is two words long,
where one word holds the segment number and the other holds the offset ad-
dress. Thus four words are needed in each block of the Z8001 's Program
Status Area to hold the program status values for each interrupt and trap ser-
vice routine. The first four words of the Program Status Area for the Z8001
Program Status Area 83
are reserved (Fig. 6.6). The next block of four words holds the program
status values for the extended instruction trap service routine. The first
word of this block is a reserved word, followed by an FCW value, the seg-
ment-number portion of the PC value, and finally, the offset portion of the
PC value. (When segment numbers are stored in a 16-bit word, the 7-bit seg-
ment number is placed in bits 8-14. Bit 15 and bits 0-7 are set to 0.) The
following blocks in the Program Status .Area contain the program status
values for the privileged instruction trap, system call, segmentation trap,
nonmaskable interrupt, and nonvectored interrupt service routines, in that
order. Each of these blocks has the same format: a reserved word, the FCW
value, the PC's segment number, and the PC's offset for that service routine.
Location 3A (hex) of the Z8001 's Program Status Area holds the FCW value
for all of the vectored interrupt service routines. It is followed by a list of
128 possible PC values, with each PC having a segment number and an offset
part. Thus each of the 128 possible PC values fills two words in the Program
Status Area. The 8-bit vector returned by the peripheral during the interrupt
acknowledge cycle is used as an index into this list of possible PC values. A
vector of 0 will select the first PC value, whose segment number is at loca-
tion 3C (hex) and whose offset is at location 3E (hex) of the Program Status
Area. If the vector is 2, the next PC value will be selected, and so on. Only
even-valued vectors are used in the Z8001 (that is, the least significant bit of
the vector must be a 0); therefore, there are 128 unique vectors that can be
returned by the peripheral, corresponding to the 128 PC values listed in the
Program Status Area.
If
VI
FCW 3C
NEWPC
40
NEW PC
PC SEGMENT
PC OFFSET
!y~ 44
~.
~23A
Figure 6.6 Z8001 Program Status
Area.
84 Interrupts, Traps, and Resets Chap. 6
The Program Status Area can begin at any 256-byte boundary in mem-
ory (any memory location with an offset address whose low-order byte is 0)
except for address 0 in a Z8002 system and segment 0, address 0 in a Z8001
system. (This restriction is due to the method in which the CPUs respond to
a reset, as described later in the chapter.) When new program status is
fetched during the response to an exception condition, the fetch is made in
system-mode operation with a status code of 1100 (program reference) on
the ST3-STO lines. Thus the Program Status Area always resides in the sys-
tem-mode program memory address space.
In review, when an exception condition occurs, the CPU will save the
program status (FCW and PC) of the task that was interrupted, and use the
PSAP to determine the starting location of the Program Status Area. The
CPU will then fetch new values for the program status from the Program
Status Area; these values are loaded into the FCW and PC registers in the
CPU, and execution of the service routine is begun. The new value of the
FCW is not effective until the start of the fetch of the first instruction of the
service routine; thus the new FCW value will not affect the status pins while
the fetches from the Program Status Area are being completed. The first in-
struction of the service routine will be fetched from the address specified in
the PC that was loaded from the Program Status Area. The service routine
will be running in the operating modes (segmented or nonsegmented, system
or normal, EPA and interrupts enabled or disabled) specified by the FCW
value loaded from the Program Status Area.
If desired, maskable interrupts can be disabled at the start of a service
routine by a suitable choice of the FCW's value. This would allow critical in-
formation to be stored or processed before subsequent interrupts are handled.
If interrupts are enabled before the end of the service routine, nested inter-
rupts are possible, that is, the service routine could itself be interrupted
while another interrupt's service routine is run.
Several different Program Status Areas could be set up in memory, with
different ones being used at various times during program execution. Speci-
fying a new Program Status Area would involve only changing the PSAP reg-
ister contents with a Load Control (LDCTL) instruction. For the Z8001,
changing the PSAP takes two LDCTL instructions-one for writing the seg-
ment number and the other for writing the offset. Care must be taken to
ensure that no exceptions occur between the two instructions, since an un-
intended PSAP value could be in effect at that time.
INTERRUPT RETURNS
gram Status Area. Upon completion of the service routine, execution of the
task that was interrupted by the exception is resumed. In order to terminate
the service routine and return to the interrupted task, that task's program
status must be retrieved from the system stack, where it was stored before
the service routine was run. The Z8000's Interrupt Return (lRET) instruc-
tion is used to end routines for both interrupts and traps.
Execution of the IRET in a Z8002 automatically pops three words
from the system stack: the identifier word is popped and discarded (that is,
the stack pointer is incremented without saving the identifier word), and the
interrupted task's FCW and PC values are popped and loaded into the CPU's
program status registers. After the IRET, the next instruction fetch will be
from the location addressed by the PC, which is the point at which the task
was interrupted. IRET is a privileged instruction that can be executed only
in system mode; IRET always pops the old program status from the system-
mode stack memory address space. The "popped" value of the FCW is not
effective until the next instruction fetch, so the status pins will not be af-
fected by the new FCW value until execution of the IRET is completed.
In Z8001 CPUs, execution of the IRET automatically pops four words
from the system-mode stack-the identifier, FCW, PC segment number, and
PC offset-since four words are always pushed on the stack when servicing an
exception. Therefore, the Z8001 must be in segmented mode when the
IRET is executed. It is the programmer's responsibility to ensure that the
Z8001 is in the segmented mode before any IRET instruction is encountered.
PERIPHERALS
+5V
A c D
-IEl lEO I--- IEl lEO - - IEl lEO r-- IEl lEO
Figure 6.7 Interrupt daisy chain with four devices sharing a common
interrupt line.
lEI OR
lEI AND INTACK LOW
INTACK HIGH
OS LOW
lEI HIGH
'-------<.... HIGHER-PRIORITY
DEVICE ACKNOWLEDGED
LET IEO=IEI
sees an active acknowledge signal (the status lines are guaranteed valid at the
rising edge of AS during Tl of the acknowledge cycle), it pulls its lEO out-
put low and releases the interrupt request line. When DS goes low later in
the acknowledge cycle, the peripheral examines its lEI input. If lEI is high,
the device accepts the acknowledge, and, if desired, places an identifier on
the bus (a vector in the case of vectored interrupts) before DS rises. The de-
vice is now under service.
While the service routine for a peripheral is being executed, that periph-
eral will continue to hold its lEO output low, thereby preventing lower-
priority devices on the daisy chain from requesting service via an interrupt.
However, higher-priority devices can still assert interrupts; a peripheral knows
that a higher-priority device on the daisy chain has preempted its service rou-
tine by asserting an interrupt if its lEI input goes low. When the servicing of
a peripheral is completed, the peripheral returns to the quiescent state,
wherein its lEO output follows its lEI input. [For Z8000 family peripherals,
the CPU signals the peripheral that service is complete by resetting a bit
called the interrupt-under-service bit in one of the peripheral's internal regis-
ters. This requires an I/O write to the peripheral at the end of the service
88 Interrupts, Traps, and Resets Chap. 6
WAIT
- - - - - - = - - W A I T CYCLES ADDED
is
1\..r
V1, Nv1, SEGT \ ~ C
IMTER~
iiiii~ !.-SAMPLE
MMI
AlW
B/Wn
STO-ST3~
I
~----+-----------------------------~
AD
MREQ
co
(g
90 Interrupts, Traps, and Resets Chap. 6
cycle. The interrupt and segmentation trap inputs to the CPU are sampled at
the beginning of T3 of the last machine cycle of each instructions' execu-
tion. The VI, NVI, and SEGT inputs are level triggered; that is, the input pin
must be low when sampled for the CPU to recognize the interrupt or trap re-
quest. The NMI is edge triggered; a negative edge on this input sets an NMI
flip-flop internal to the CPU. This flip-flop is examined to determine if an
NMI request is to be serviced. (Setup and hold-time requirements for these
inputs are given in the AC timing characteristics chart in Appendix A.)
If an interrupt or trap condition is detected, the Z8000 will start the
next instruction fetch, but this fetch will be abandoned before completion.
All of the proper address and status information for the next instruction
fetch will appear in Tl, and the AS is pulsed. However, no active DS signal
is generated, the instruction is never read from memory, and the PC is not
updated. The CPU spends seven clock periods in this abandoned instruction
fetch cycle; during this time, the CPU is resolving priority among compet-
ing events if more than one exception condition was detected, and decre-
menting the implied system stack pointer in preparation for saving the inter-
rupted task's program status.
This abandoned instruction fetch cycle is followed by the actual inter-
rupt acknowledge cycle. The CPU always switches to the system mode, and,
for the Z8001, the segmented mode at the start of the acknowledge cycle.
The CPU remains in these modes until it begins to execute the service rou-
tine. During Tl of the acknowledge cycle, all status signals, including the ap-
propriate acknowledge code on the STO-ST3 lines (Table 6.2), are output
and guaranteed valid at the rising edge of AS. The contents of the address/
data bus are undetermined at this time; that is, no meaningful address infor-
mation is output. MREQ is high, B/W is low, and R/W is high, indicating that
the CPU is going to read a word from the interrupting device later in this
cycle. During T2, the address/data bus is tri-stated by the CPU in anticipa-
tion of reading data placed on the bus by an external device in T3. Five
wait states are automatically included in the interrupt acknowledge cycle.
Assuming there are no externally-generated wait states, DS is lowered during
the fourth wait state. The lEI/lEO daisy chain should be settled by this
time; for Z8000 family peripherals, this normal timing would allow chains of
about 10 devices. After the fifth automatic wait state, the T3 state is en-
teredo The contents of the address/data bus are read by the CPU on the fall-
ing edge of the clock in the middle of T3. T4 and T5 clock periods are ap-
pended to this transaction, and are used internally to load the identifier read
off the bus into a temporary storage register in the CPU. Thus the interrupt
acknowledge machine cycle is always at least 10 clock cycles long.
The word of data read during T3 of the acknowledge cycle is the iden-
tifier word that is later saved on the system stack as part of the exception
processing. Thus an interrupting device can send up to 16 bits of status in-
formation to the CPU as part of the acknowledge cycle. For vectored inter-
rupts, the CPU uses the lower half of this word (the bits returned on the
ADO-AD7 bus lines) as the interrupt vector. In the Z8001, the CPU will al-
ways set bit 0 of the vector to 0, regardless of the value returned during the
acknowledge cycle, thereby guaranteeing that only even vector values are
used when indexing into the Program Status Area. If several devices are con-
nected on a daisy chain for the NMI or NVI interrupt inputs, the identifier
word typically is used in the service routine to identify the device that as-
serted the interrupt. Of course, the peripheral does not have to return an
identifier word during the acknowledge, except for vectored interrupts,
where a vector is always required.
Additional wait states can be added to the interrupt acknowledge cycle
by pulling the CPU's WAIT input low. During the middle of the third auto-
matic wait state (before DS goes low), the WAIT input is sampled; if WAIT
is active, an additional wait state is added before starting the clock period
wherein DS goes low (Fig. 6.10). During that additional wait state, the
WAIT input is again sampled, and further additional wait states are added
until WAIT returns high. Therefore, the delay between the rising edge of AS
and the falling edge of DS during the interrupt acknowledge can be arbitrar-
ily long, allowing time for long lEI/lEO daisy chains to settle. Once DS goes
low and the highest priority device that requested an interrupt has been se-
lected, the WAIT input is again sampled during the last automatic wait state
before T3. Additional wait states can be inserted here to allow the selected
device additional time to place its identifier word or vector on the bus. Thus
WAiT SAMPLED
TO EXTEND
VECTOR ACCESS
TIME
/ READ
( VECTOR
T, Tw Tw Tw Tw ~ Tw (T3
CLOCK
ADo-AD7 -I-''---+--
INTACK
AS
OS I
-j---~---
WAiT
-r--1--- _____ """T"""""T,
.I __
Figure 6.10 Wait states in the in-
terrupt acknowledge cycle.
92 Interrupts, Traps, and Resets Chap. 6
a Assumes
no externally-generated wait states.
bZ8001only.
Execution of the System Call (SC) instruction causes the CPU to process the
system call trap. This instruction allows normal-mode programs to force ex-
ecution of the service routine for the system call trap. This service routine
could be a part of the operating system that performs system-mode type op-
erations such as I/O for the normal-mode user.
The opcode for the SC instruction is one word long, where the upper
byte is an EF (hex) and the lower byte is an immediate operand from 0 to
255 as specified by the programmer (Fig. 6.11). The entire SC opcode ap-
pears on the system stack as the identifier word during status saving for the
system call stack (Fig. 6.12). The system call trap routine can read the iden-
src
I
sc BYTE
SPAFTER~ INSTRUCTION
STACK POINTER
AFTER TRAP INSTRUCTION FCW
OR INTERRUPT PC SEGMENT
FCW
PC PC OFFSET
STACK POINTER 1--------
BEFORE TRAP SP BEFORE ___
OR INTERRUPT f-------
HIGH ADDRESS
tifier from the stack, and use it to define the action to be taken. In other
words, a byte of data can be passed from the normal-mode program to the
system call service routine in the ope ode of the SC instruction itself. The
service routine might use this byte parameter to determine the type of ac-
tion that the normal-mode user is requesting via the system call. Thus the
operating system could be written so that normal-mode users can use the sys-
tem call to request anyone of up to 256 actions available in the system call
service routine.
SERVICE ROUTINES
When executing service routines, care must be taken not to change memory
or register locations that, if altered, could prevent a successful return from
the interrupt or trap. Before entering the service routine, the program status
of the interrupted task is placed on the system stack using the implied stack
pointers (R15 in the nonsegmented mode, RR14 in the segmented mode).
The Interrupt Return (lRET) instruction is used to clear this information on
the stack and return to the interrupted task at the end of the service routine.
Therefore, the implied stack pointer must have the same value when the
IRET is executed as it had when the service routine began. If the identifier
word on the stack is to be accessed in the service routine via a pop of the
stack, a word must be pushed back onto the stack to restore the stack
pointer to its starting value. (The IRET must be executed in the segmented
mode in the Z8001, as discussed previously.) Of course, the interrupted task's
program status information on the stack cannot be altered if the interrupt task
is to resume precisely where it was interrupted. Registers and memory loca-
tions that were being used by the interrupted task should not be uninten-
tionally altered by the service routine. In short, execution of the interrupted
task should produce the same results as if the task were not interrupted.
Often, a service routine will load all of the registers' contents into mem-
ory locations reserved for that purpose at the start of the service routine, use
the registers, and then restore the original register contents before returning
to the interrupted task. The Load Multiple (LDM) instruction in the Z8000
allows the user to store all of the general-purpose registers' contents into
consecutive memory locations or fill all the registers from consecutive mem-
ory locations with one instruction.
If the system distinguishes between system-mode and normal-mode
memory address spaces, the operating mode of the service routine will deter-
mine which memory areas can be accessed by that routine. If the service
routine needs to read the identifier word from the system stack, that part of
the routine will have to operate in the system mode. Segregated memory ad-
dress spaces can affect parameter passing to a service routine. When a nor-
mal-mode program executes a system call, for example, 1 byte of data is
Halt Instruction 95
HALT INSTRUCTION
CLOCK,!>
NIS SN6:0 }
AD15:0
--8------
DS
MREQ
INTERNAL
NMI
RESET
A hardware reset occurs at the end of any clock cycle when the RESET in-
put to the CPU is low. The RESET input must be held low for at least five
CPU clock cycles to initialize the CPU properly. A reset overrides all other
considerations, including interrupts, traps, bus requests, and STOP inputs.
Reset should be used to initialize the CPU as part of the system's power-
up sequence.
Reset timing for the Z8002 is illustrated in Fig. 6.14. Within five clock
cycles after RESET goes low, the address/data bus is tri-stated by the CPU;
the AS, DS, MREQ, MO, BUSACK, and STO-ST3 signals are forced high; the
SNO-SN6 segment number output goes low, and the R/W, B/W, and N/S lines
are undefined (that is, they might be high or low). Three clock periods after
RESET returns high, memory read cycles are executed in the system mode
and the values read during those read cycles are loaded into the program
status registers.
For the Z8002, two read cycles are executed; the first read fetches a
word from memory location 2 (that is, 2 is the address emitted during T1 of
the memory read) and loads it into the FCW, and the second read fetches a
I
<f
8-;l., -
<f
- ----
w
~ ~
8
---::x;---
""
"- I--- --- -----
~
~)..
-
0 V .,/
'"
--~- --
oil
!:::
:§....,
....,
Q)
<n
Q)
I-<
C'l
0
0
00
N
-.::I'
.-4
cD
~
~
1£
. on
I~ Ii
Ii l!a
Ii I~ on
.
o
on
z
II
97
98 Interrupts, Traps, and Resets Chap. 6
Z8002 Z8001
word from location 4 and loads it into the PC. These FCW and PC values are
the program status for the first routine to be executed after the reset. Figure
6.14 shows the timing of these fetches, assuming that no active WAIT signals
are generated during these memory accesses. The next machine cycle follow-
ing these two reads will be an instruction fetch from the address loaded into
the PC, under the operating modes specified in the FCW.
For the Z8001, three memory reads are executed as part of the reset
sequence; the starting FCW is fetched from segment 0, location 2, the seg-
ment number for the initial PC value is fetched from segment 0, location 4,
and the PC's offset is fetched from segment 0, location 6 (Fig. 6.15). The
following machine cycle is the instruction fetch that starts the execution of
the program at the address loaded into the PC, under the operating modes
specified in the FCW.
These initial fetches of the FCW and PC values after a reset are made
from the system-mode program memory address space (1100 status on STO-
ST3). These values in memory must be present at power-up, and, therefore,
are implemented in nonvolatile memory (ROM or PROM). Since the first six
memory locations for the Z8002 and the first eight locations in segment 0
for the Z8001 are dedicated to holding the program status values for a reset
condition, these areas cannot be used as part of a Program Status Area. In
other words, the Program Status Area cannot start at address 0 in a Z8002
system or segment 0, address 0 in a Z8001 system.
After a reset, the contents of all the CPU registers are undefined, except
for the PC and FCW, and bit 15 of the refresh register. Bit 15 (the enable
bit) of the refresh register is cleared to 0 by a reset, thereby turning off the
automatic memory refresh mechanism. All interrupt and segmentation trap
inputs are ignored during the reset processing, and any pending NMI requests
are cleared (that is, the internal NMI request flip-flop is cleared). Interrupts
are not sampled until the last machine cycle of the first instruction executed
after the reset.
INITIALIZATION ROUTINES
After a reset, the first software program executed should be a routine that
initializes the CPU control registers used in that system. The implied stack
pointers (RR14 in the segmented mode, R15 in the nonsegmented mode)
Other Context Switches 99
Other Z8000 instructions besides the System Call can cause "context
switches," in that they affect the program status registers. The Load Control
(LDCTL) instruction can be used to load the FCW, thereby changing the
CPU's operating modes. The Disable Interrupt (DI) and Enable Interrupt
(EI) instructions change just the vectored and nonvectored interrupt enable
bits in the FCW.
Complete context switches can be made with the Load Program Status
(LDPS) instruction. This instruction loads a new FCW and PC from an area
in memory that is formatted in the same manner as one block of the Pro-
gram Status Area. In the nonsegmented mode, an FCW and PC value are
loaded from memory; in the segmented mode, a reserved word, FCW, PC
segment number, and PC offset address are loaded from memory (Fig. 6.16).
These fetches are made from the data memory address space (1000 status on
NONSEGMENTED SEGMENTED
LOW ADDRESS
FCW
PC FCW
PC SEG. NO.
STO-ST3}. The new value of the FCW does not become effective until the
next instruction, so the status pins will not be affected by the new control
bits until the LDPS instruction execution is completed. The next instruction
executed is the instruction addressed by the new PC value.
Old program status is not saved by the LDPS instruction, meaning that
this is a way of permanently switching program status. The LDPS instruc-
tion is useful for initiating normal-mode users' programs from the operating
system, or for running a nonsegmented program on a Z8001. The segment-
number portion of the PC is not affected by an LDPS instruction executed
in the nonsegmented mode.
Of course, the LDCTL, EI, DI, and LDPS instructions are all privileged
instructions that can be executed only during system-mode operation.
7
Besides interrupt requests, two other request buses can be used to control
the sharing of resources in Z8000 systems. The address/data bus and its as-
sociated control and status signals are a resource that might be shared be-
tween processors and direct memory access (DMA) devices. Bus requests
are made to the CPU when another device requires control of the bus; the
Z-Bus bus request daisy chain allows multiple devices to share use of the bus
in a well-defined manner. In multiprocessor systems, resources such as mem-
ory and I/O devices often are shared by two or more processors. For ex-
ample, two separate Z8000-based systems might share a hard disk storage de-
vice, where only one processor may access the disk at a time. The Z-Bus
multiprocessor resource sharing daisy chain defines the protocol for sharing a
single resource among multiple Z8000 processors. Use of a hardware daisy-
chain scheme to control bus and multiprocessor resource requests eliminates
the need for separate priority controllers in the system.
BUS REQUESTS
In a given system, a CPU is designated as the default bus master; it uses the
bus to fetch instructions and to transfer data to and from memory and pe-
ripheral devices as required during instruction execution. If another device,
such as a DMA controller, needs to use the bus, that device must request
control of the bus from the CPU.
Typically, bus requests are initiated by DMA controllers in a Z8000
101
102 Bus and Resource Sharing Chap. 7
system, where the DMA controllers are used for high-speed data transfers
between memory and I/O devices. A peripheral device that needs servicing
would request service from the DMA controller instead of interrupting the
CPU. The DMA device requests control of the bus from the CPU, awaits
acknowledgment of that request, performs the necessary data transfers, and
then returns control of the bus to the CPU. Using a DMA controller to ser-
vice a peripheral can have two advantages over CPU-controlled transfers be-
tween I/O and memory devices. First, the overhead involved in obtaining
the bus for a DMA transfer via a bus request is less than the overhead in-
volved in processing an interrupt in the CPU. Second, DMA controllers
usually can transfer data between memory and I/O devices more efficiently
(that is, faster) than the CPU. Of course, the bus requestor must use the
address/data bus and its control and status lines in the exact same nlanner
as the CPU to execute data transfers on the bus.
The bus request timing is illustrated in Fig. 7.1. A bus request is initi-
I T, T, TJ Tx Tx Tx Tx Tx Tx
CLOCK
"USREQ
INTERNAL
BUSREQ
ated by pulling the BUSREQ input to the CPU low. The CPU samples this
input at the start of each machine cycle, that is, at the rising edge of thf'
clock of each Tl state. If BUSREQ is low at the start of the machine cycle,
the CPU will relinquish the bus at the end of the bus transaction in that
cycle (in other words, immediately after T3). The CPU gives up the bus by
tri-stating the address/data bus (ADO-AD15), bus control (AS, DS, MREQ),
bus status (N/S, B/W, R/W, STO-ST3), and, for the Z8001, segment number
(SNO-SN6) outputs. The' CPU then pulls the BUSACK output low, signal-
ing that the bus request has been acknowledged. The requesting device is
now free to use the bus to initiate data transfers. For example, a DMA
controller might transfer data between memory and I/O devices while in con-
trol of the bus. The bus requestor returns control of the bus to the CPU by
deactivating the CPU's BUSREQ input. Once the CPU issues an active
BUSACK, it cannot regain control of the bus on its own; it must wait pas-
sively for the bus requestor to return control of the bus to the CPU by rais-
ing BUSREQ. Two clock periods after BUSREQ goes high the CPU will raise
BUSACK and regain control of the bus, with execution resuming at the
point at which it was suspended by the bus request. Any device requiring
control of the bus must wait at least two clock cycles after BUSREQ has
risen (that is, until BUSACK returns high) before pulling BUSREQ down
again.
Bus requests will always be acknowledged within two machine cycles
after BUSREQ is active. Worst-case timing occurs if BUSREQ goes low im-
mediately after the start of a machine cycle; that cycle will be executed,
BUSREQ will be sensed at the start of the next cycle, and the bus request
will be honored after that second cycle's bus transaction. During normal ex-
ecution, the longest machine cycle is the eight-clock-period internal cycle,
assuming that memory and I/O cycles are not longer than 8 clocks due to ex-
ternally-generated wait states). During exception processing, the lO-clock-
period interrupt acknowledge cycle is the longest possible machine cycle
(again, excluding extra wait states). In most systems, worst-case response to
a bus request would occur when the BUSREQ is pulled low right after the
start of the aborted instruction fetch cycle during the response to an inter-
rupt. The seven-clock-period aborted instruction fetch would execute, fol-
lowed by 8 clock periods in the acknowledge cycle (BUSREQ would be
sensed at the beginning of this cycle) before BUSACK would be returned.
Thus the requesting device will always gain control of the bus soon after it
pulls BUSREQ low in Z8000 systems.
If several devices in the system are capable of requesting control of the bus,
these devices will share the BUSREQ input to the CPU. Arbitration be-
tween simultaneous requests from these devices is resolved via a priority
104 Bus and Resource Sharing Chap. 7
_ _ BUSREQ_
--BUSACK_ REQUESTOR
CPU
r--BAI- Figure 7.2 Z-Bus signals for bus re-
L - - BAO " " " ' - quests.
daisy chain. Four signals are defined as part of the Z-Bus for handling bus
requests and establishing the daisy chain: bus request (BUSREQ), bus ac-
knowledge (BUSACK), bus acknowledge in (BAI), and bus acknowledge out
(BAO) (Fig. 7.2) ..
Figure 7.3 is a block diagram of the bus request daisy chain. B USREQ
is driven by all bus requestors; a low on this line indicates that a bus re-
questor is trying to gain control of the bus. The BUSREQ signal serves two
purposes: it is used as a CPU input to request control of the bus and as a
status line to other bus requestors, indicating that some bus requestor is re-
questing or has control of the bus. BUSREQ must be bidirectional so that
each device on the chain can monitor the activity of the other devices.
BUSACK is a CPU output indicating that the CPU has relinquished bus con-
trol in response to a bus request. BAI and BAD are the signals that form the
bus request daisy chain.
The protocol of the bus request daisy chain is outlined in Fig. 7.4. In
the quiescent state (no bus requests being made and the CPU bus master has
control of the bus) each device passes its BAI input to its BA5 output. When
a device needs to request control of the bus, it samples the BUSREQ line. A
bus request can be made only if BUSREQ is initially high (that is, the CPU
has control of the bus, and no other device is requesting the bus) and has
been for two clock cycles. The request is made by pulling BUSREQ low.
The requesting device also holds its BAO output high, thereby preventing
bus acknowledgments from propagating to lower-priority devices, as ex-
plained below. The bus requestor gains control of the bus when its BAI in-
put goes low. When the device is ready to return control of the bus to the
CPU, it releases BUSREQ and allows its BAO output to follow its BAI input
(that is, it returns to the quiescent state).
BUS REQUESTORS
_ BAT BAOI---~' BAI BAO 1 - - - ' " BAT BAO f---- •••
BUSREQ BUSREO
SDSACK ' - -
+5V
GUIESCENT STATE
BAO~BAI
LOWER BUSREQ
BAO HIGH
USE THE
BUS
WHEN COMPLETE
RAISE BUSREQ
BAO~BAI
Unlike the interrupt daisy chain, the bus request daisy chain is non-
preemptive. Once a device gains control of the bus, no other devices on the
chain can make a bus request until control is returned to the CPU, regardless
of their position on the daisy chain. The daisy chain is used only to resolve
the priority of simultaneous bus requests; if two devices request the bus at
the same time, only the higher-priority device will receive the initial bus ac-
knowledge on its BAI line, since the higher-priority device holds its BAO line
high until it relinquishes control of the bus. After the higher-priority device
returns to the quiescent state, the low BUSACK will propagate to the lower-
priority device, that device will then be in control of the bus.
If the automatic memory refresh capabilities of the Z8000 CPUs are
used to refresh dynamic memories, refresh cycles may be missed while DMA
106 Bus and Resource Sharing Chap. 7
devices have control of the bus. The CPU will remember the last two
"missed" refresh row addresses and issue those refreshes immediately after
regaining control of the bus. Care must be taken to ensure that bus request-
ors do not control the bus for a long enough period of time that the dynamic
memory's contents are corrupted due to a lack of refreshes.
The Z-Bus also includes signals for implementing a hardware daisy chain for
requesting the use of a resource shared among several Z8000 processors. For
example, several microcomputer systems might share a common disk drive
or high-speed printer, where only one processor can use the shared resource
at anyone time. As each processor requires use of the shared resource, it
must poll that resource to see if it is already being used by another processor.
If not, the processor uses the resource, meanwhile locking out all other pro-
cessors until it is finished. The shared resource could be an I/O device, a
block of memory, or a shared bus.
Four Z-Bus signals make up the shared resource daisy chain: multi-
micro request (MMRQ), multi-micro status (MMST) multi-micro acknowl-
edge in (MMAI), and multi-micro acknowledge out (MMAO) (Fig. 7.5). Fig-
--MMRQ_
-MMST-- MUL TI·MICRO
Z·BUS REQUEST
COMPONENT _MMAI-----, NETWORK Figure 7.5 Z-Bus signals for sharing
_ MMAO----.J
resources in a rn ul tiprocessor sys tern.
ure 7.6 shows a typical configuration of the daisy chain. The MMRQ signal
can be driven by any device that can request use of the shared resource. A
low on this line indicates that a request has been made or granted. The
MMST is an input to each device on the daisy chain that indicates a request
is pending or the shared resource is busy. MMAI and MMAO are the ac-
knowledge signals that make up the daisy chain.
PROCESSORS
A B C
I t I t
I 1
liRO /LST
RESOURCE
QUIESCENT
STATE
MMAO=MMAI
YES
ACTIVATE
MMRQ
FORCE
MMAO LOW
When the shared resource receives a request (MMRQ goes low), it pulls the
MMST line low. This signal propagates through the MMAI/MMAO daisy
chain until reaching the highest-priority requestor. The requestor samples
its MMAI input some finite amount of time after making the request; if
MMAI is low, the requestor knows it has control of the shared resource. If
MMAI is high, some higher-priority device on the daisy chain saw the ac-
knowledge and is using the resource, so the original requestor returns to the
quiescent state and tries again later. The delay between requesting the
shared resource by pulling MMRQ low and checking for acknowledgment
by sampling the MMAI input must be long enough to allow the MMAI/
MMAO daisy chain to settle. This time would be the sum of the worst-case
MMAI to MMAO propagation delays for each device on the daisy chain.
When the processor that has control of the shared resource is finished using
the resource, it releases the resource by allowing MMRQ to go high and pass-
ing its MMAI input to its MMAO output. The shared resource lets the
MMST line go high if MMRQ is high.
Like the bus request daisy chain, the shared resource request daisy
chain is nonpreemptive. Once a processor gains control of the shared re-
source, no other device on the daisy chain can make a request until the
shared resource is freed again. Priority on the daisy chain is important only
in the case of two simultaneous requests. For example, if processor A and
processor C of Fig 7.6 simultaneously pull their MMRQ lines low, only
processor A will see a low on its MMAI input when it samples for acknowl-
edgment, since processor A will hold its MMAO line high when it makes the
request. When processor A has completed use of the resource, it will return
to the quiescent state, and processor C can reassert its request.
All four lines in the shared resource request daisy chain are unidirec-
tional, allowing the use of line drivers and receivers at each processor on the
daisy chain. Furthermore, the delay for the daisy chain settling time can be
set at each processor. Therefore, the devices on the chain can be separated
by arbitrarily long distances.
A shared resource requestor can be any device capable of implementing
the protocol. For ZSOOO CPUs, the four lines of the resource request daisy
chain are mapped into the multi-micro in (MI) and multi-micro out (MO)
pins of the CPU. The logic for this mapping is shown in Fig. 7.S. During the
quiescent state, the MO output is high; thus the MI input will reflect the
state of the MMST line, and MMAI is gated out to MMAO. MMST (on the
MI input) can be read by the CPU to check the busy status of the resource.
If the resource is not busy, the CPU pulls the MO output low. MMAO is
forced high, and the MMAI signal is now gated to the CPU's MI input. After
waiting for a predetermined delay time, the CPU reads MMAI (on the MI in-
put). If it is low, the CPU knows that the request was successful, uses the re-
source, and sets MO high when completed. If MMAI is high when read, the
request was not successfully acknowledged, and the CPU will set MO high
Shared Resource Requests 109
1 0 - - - - - - - - MMST
'-----.L:::-------..
~ c:>----.:. : :
MI ....... MMST. MMAI
>-----MMRQ
~.--------~
) 0 - - - - MMAO
M
Figure 7.8 Logic for mapping the Z-Bus resource-sharing signals to the
Z8000 CPU MO and MI pins.
MO MMRQ
MI
~
En Select
Ao ZA I---
A,
'''l 60
6,
74LS157
ZB MMAO
RESET ZFLAG
RESET S FLAG
SET ;;W RESET MO
DECREMENT
REGISTER
(EVERY SEVENTH
CPU CLOCK)
RESET S FLAG
SET S FLAG SET MO
SET Z FLAG
after execution of the MREQ, the Z flag indicates if a request was made, and
the S flag indicates if the request was granted (Table 7.1). Another instruc-
tion, Multi-Micro Set (MSET), is used to write a 1 to MO after the CPU com-
pletes its use of the shared resource.
Two other instructions act on the MO and MI pins. The Multi-Micro
Bit Test (MBIT) instruction reads the MI input and sets or resets the S flag if
MI is high or low, respectively. The Multi-Micro Reset (MRES) instruction
writes a 0 to the MO output. Thus MSET, MRES, and MBIT could be used
to implement other, user-defined resource-sharing protocols, if so desired. If
the system does not use the MI and MO pins for shared resource requests,
they can be used as a single bit of input and output for other purposes.
TABLE 7.1 MEANING OF FLAGS AFTER THE
EXECUTION OF A MREQ INSTRUCTION
-------PRIMARy SIGNALS-------
EXTENDED ADDRESS
STATUS;
BUS ---AS- PERIPHERAL
MASTER ---05- AND MEMORY
---R/W_
---B/W-
_WAIT---
_RESET_
ADO-AD15~&CS
EXTENDED ADDRESS
STATUS
DECODE
INTACK
CPU STATUS> DECODE PERIPHERAL
L --
~IEI__
1EO
RESOURCE REQUEST SIGNALS - - - - -
---MMRO_
-MMST--- MULTI·MICRO
Z·BUS
REQUEST
COMPONENT _MMAI-----, NETWORK
_MMAO-----.J Figure 7.11 Z-Bus signals.
111
112 Bus and Resource Sharing Chap. 7
If the MO and MI pins are not used in the system at all, the MREQ
instruction can be used to produce long, uninterruptible software delays.
Execution of the MREQ instruction takes 10 + 7n clock cycles, where n is
the contents of the word register specified as the operand in the MREQ
instruction.
Z-BUS SIGNALS
All of the signals comprising the Z-Bus interface have now been discussed
(Fig. 7.11). In review, the Z-Bus is a logical definition of the signals needed
to link Z8000 family components in a computer system. Two kinds of
operations can occur on the Z-Bus: transactions and requests. Four kinds of
transactions are possible: memory, I/O, interrupt acknowledge, and null.
(Null transactions occur during internal operation and memory refresh
cycles, wherein no data are being transferred.) Only one transaction can
occur at a time and it must be initiated by a bus master, that is, the device in
control of the bus. There are three types of requests: interrupt, bus, and
shared resource. A request can be initiated by a component that is not the
bus master. For each type of request, a daisy-chain priority mechanism pro-
vides arbitration between simultaneous requests, eliminating the need for
separate priority controllers.
Data transfers on the Z-Bus are asynchronous in the sense that Z-Bus
components need not be synchronized with the CPU clock. The timing of
data transfers is controlled by the AS! DS, and WAIT signals.
8
One feature of the Z8000 CPU architecture that sets it apart from previous
generations of microprocessors is its large, powerful instruction set. The in-
struction set for the Z8000 includes 110 distinct instruction types. Many of
these instructions act on byte, word, or long-word data operands. The oper-
ands in an instruction are specified using one of the Z8000's eight addressing
modes. Combining the instruction types with the various data types and op-
erand addressing modes supported by each instruction yields a set of over
400 different instructions.
The Z8000 CPUs have a full complement of data movement, arith-
metic, logical, bit manipulation, rotate, shift, and I/O instructions. Instruc-
tions are included to manipulate strings of data, to facilitate multitasking
operating systems, and to support typical high-level-language functions.
When coupled with the other architectural features of the Z8000, such as the
large memory address spaces, the Z8000 programmer is provided with com-
puting power formerly available only on large mainframe computers.
113
114 The Instruction Set Chap. 8
Instruction
Label mnemonic Operands Comments
tions for writing code in the PLZ/ ASM language are described here, so that
the programming examples shown in this chapter will be easily understood.
Table 8.1 illustrates some statements written in PLZ/ASM. A state-
ment consists of an assembly language instruction, the instruction's oper-
ands, and optionally, label and comment fields. Each of these fields must be
separated by at least one delimiter; legal PLZ/ ASM delimiters include spaces,
commas, tabs, semicolons, carriage returns, line feeds, and form feeds. Sev-
eral delimiters in a row are treated the same as just one delimiter. Each as-
sembly language instruction is denoted by that instructions's mnemonic; for
example, LD is the mnemonic for the Load instruction. Z8000 instructions
may have anywhere from zero to four operands, depending on the instruc-
tion; in the case of multiple operands, the operands must be separated by
delimiters. Labels are placed before the instruction's mnemonic, and are
always followed by a colon. Comments may be placed anywhere that a delim-
iter may appear, and are enclosed in exclamation points. Labels and comments
are always optional and are added by the programmer to make the program
easier to read, maintain, and debug.
Often, symbolic names are used to represent particular memory loca-
tions or numeric constants in PLZ/ ASM. These symbolic names, also called
identifiers, are made up of alphabetic characters (both upper- and lowercase
which are distinct), the digits 0 through 9, and the underline character (_).
Symbolic identifiers can be up to 127 characters long, and must start with an
alphabetic character.
Numbers can be written in decimal, hexadecimal, octal or binary nota-
tion, as shown in Table 8.2. A number without any prefix is interpreted as a
decimal number, the "%" prefix designates a hexadecimal number, the "%(8)"
prefix designates an octal number, and the "%(2)" prefix designates a binary
number.
When writing segmented addresses, the segment number is preceded by
two "<" symbols and followed by two ">" symbols. The offset would fol-
low immediately. For example, "«5»20" means segment 5, offset
address 20 (the 5 and 20 are both decimal values in this case).
The general-purpose CPU registers are designated as follows: RO-R15
for the word registers; RHO-RH7 and RLO-RL7 for the byte registers; RRO,
RR2, and so on, through RR14 for the long-word registers; RQO, RQ4, RQ8,
and RQ12 for the quad registers.
As with most assembly languages, the destination operand is placed
before the source operand. Thus the statement
LD RO, R2
means that the contents of register R2 are to be written into register RO.
Some other assembler conventions, such as the designation of the operand
addressing mode, will be described later.
for the source operand and a register as the destination. Thus most arithmetic,
logical, shift, and rotate instructions have a register as the destination. Input
instructions use a register for the destination and output instructions use a
register for the source. Storing data in the registers allows shorter instruc-
tions and faster execution than when operands must be fetched from mem-
ory. However, some memory-to-memory and I/O-to-memory commands are
included to improve program density; these commands normally are used to
manipulate entire strings of data.
For two of the operand addressing modes, direct address (DA) and indexed
(X), an I/O or memory address is included in the instruction itself. Nonseg-
mented memory addresses and I/O addresses are always 16 bits long, so these
addresses occupy one word in the instruction's opcode. Segmented ad-
dresses are 23 bits long and can be represented two different ways within an
instruction.
The most general format for designating a segmented address within an
instruction is the long offset format, wherein the address is stored in two
consecutive words (Fig. 8.2). The first word contains the segment number
portion of the address in bits 8-14; bits 0-7 are reserved (set to O's). Bit 15
is set to aI, which designates the long offset format. The 16-bit offset ad-
dress is placed in the next word of the instruction.
In the short offset format, the segmented address is compressed into
one word in the instruction. Bit 15 is cleared to zero, bits 8-14 hold the seg-
ment number, and bits 0-7 hold the lower byte of the offset. The upper
byte of the offset address is assumed to be all O's. Thus the short offset for-
mat can be used only to address the first 256 bytes in a segment (that is, off-
set addresses 0 to 255 in the segment).
For the Zilog PLZ/ ASM assembler, the short offset format is denoted
by enclosing the segmented address within vertical bars when writing the
instruction:
LD RO, I «5»20 I ! memory-to-register load, memory address is in short offset format!
LD RO, «5» 300 ! memory-to-register load, memory address is in long offset format!
15 14
LONG OFFSET
The short offset format can be used only when a segmented address is
included in the instruction's opcode. The short offset format cannot be used
to store a segmented address in a CPU register.
ADDRESSING MODES
REGISTER MODE
In the register (R) addressing mode, the operand is the contents of the CPU
register specified in the instruction (Fig. 8.3). The register length (byte,
INSTRUCTION REGISTER(S)
REGISTER
word, long word, or quad word) is determined by the instruction. The fol-
lowing statements use register addressing to specify both the source and des-
tination operands:
LD R2, R5 ! contents of R5 written into R2 !
ADDS RHO, RL4 ! 8-bit addition of RHO and RL4, sum goes in RHO!
MULTL RQ4, RL8 ! 32-bit multiply I
For the direct address (DA) mode, the address of the operand is included in
the instruction's opcode (Fig. 8.4). The address could be a memory address
or an I/O address, as indicated by the instruction type. For I6-bit nonseg-
men ted addresses and I/O port addresses, the address will be given in the sec-
ond word of the instruction's opcode. Segmented addresses can be stored in
an opcode in two ways: long offset format (the address is in the second and
third words of the instruction's opcode) or short offset format (the address
is in the second word of the intruction's opcode).
The operand specified by the DA mode can be in the I/O address space,
special I/O address space, or data memory address space, depending on the
instruction:
LD RO, «10»%4ACO I segmented mode, contents of data memory location 4ACO hex in
segment 10 are loaded into RO !
SOUT %OOFF, R5 ! destination is port FF hex in special I/O address space!
Typically, the address is specified using a symbolic name rather than the
numerical address:
LD RO, TOTAL ! TOTAL is previously defined symbolic name for some location in data
memory!
OPERATION
I
I
WORD(S) ADDRESS
I
OPERAND
IMEMORY OR I/O
The DA mode also is used by the Jump and Call instructions to specify
the address of the next instruction to be executed. In this case, the address
in the instruction opcode is not used to reference a data operand in a mem-
ory or I/O location, but instead is used as an immediate value that is loaded
into the program counter:
JUMP %5000 I jump to location 5000 hex I
CALL SOME_ROUTINE I SOME_ROUTINE is the symbolic name for the starting ad-
dress of a subroutine!
IMMEDIATE MODE
Immediate (1M) mode addressing means that the operand appears within the
instruction's opcode itself (Fig. 8.5). 1M mode is the only addressing mode
that does not involve specifying a register, memory, or I/O location for the
OPERATION
WORD(S) OPERAND
Figure 8.5 Immediate mode.
operand. Instructions that act on bytes or words provide the immediate oper-
and as the second word in the opcode. For byte instructions, the immediate
byte of data is duplicated in both bytes of the opcode's second word. In-
structions that operate on long words provide the immediate operand as the
second and third words of the opcode.
Since immediate operands are always part of the opcode, they are al-
ways located in the program memory address space. The" #" symbol is used
to specify immediate-mode addressing. Immediate mode often is used to
initialize memory and register locations:
LD RO, #'105407 ! 5407 hex loaded into RO !
ADDS RH8, #20 ! 20 added to contents of RH8 !
For the indirect register (lR) mode, the operand resides at some memory or
I/O location. The address of the operand is the contents of the register
specified in the opcode. In other words, a register holds the address of the
operand (Fig. 8.6). Of course, the appropriate address must be loaded into
the register before IR mode is used. The instruction type determines if the
address in the register is a memory or I/O address. Any word register except
RO can hold a nonsegmented memory address or an I/O address. Any regis-
ter pair except RRO can hold a segmented memory address.
120 The Instruction Set Chap.S
1
ADD:;;;II..-- -....... OPERAND
LD R5, @R2 ! nonsegmented mode, the destination uses IR addressing, the contents
of the data memory location whose address is in R2 is loaded into
R51
INB RHO, @R1 ! R1 holds standard I/O port address!
LD @RR14, RO ! segmented mode, source uses IR addressing, source is in stack
memory!
INDEXED MODE
For the indexed (X) mode, the operand is located in a memory location.
The address of the memory location is found by adding an address located in
the instruction's opcode, called the base address, to the contents of a word
register specified in the instruction, called an index (Fig. 8.7). The address
formed by adding the index to the base address is called the effective address
of the operand. Any general-purpose register except RO can hold an index.
The base address can be segmented or nonsegmented, depending on the cur-
rent operating mode of the CPU; if segmented, the base address can be speci-
fied using the long or short offset formats.
When using the indexed addressing mode in segmented mode, the index
is added to the offset portion of the base address, without affecting the seg-
ment number. The segment number of the effective address for the operand
is always the segment number of the base address.
INSTRUCTION REGISTER
DISPLACEMENT
WORD(S) ADDRESS
MEMORY
Operands specified using X mode are in the data memory address space,
except when this mode is used with the Jump and Call instructions. For
Jumps and Calls, the effective address is not used as the address of an oper-
and in memory, but instead is used as an immediate value that is loaded into
the program counter to execute the Jump or Call.
Indexed addressing is specified by designating the base address, fol-
lowed by the register that holds the index enclosed in parentheses:
Base address (BA) mode is the inverse of indexed mode; in BA mode, the
specified register holds a base address and the index, or displacement, is a 16-
bit value that is part of the instruction's opcode (Fig. 8.8). The operand's
effective memory address is found by adding the index to the base address.
In the nonsegmented mode, the base address can be in any register except
RO; in the segmented mode, the base address can be in any register except
RRO.
As with the indexed mode, the effective address calculation does not af-
fect the segment number of the base address; the segment-number portion of
the effective address will always be the segment number of the base address.
An operand specified using BA mode is in the stack memory address
space if the base address is in R15 in the nonsegmented mode or RR14 in
the segmented mode. Otherwise, the operand is in the data memory address
space.
Base addressing is used only with the Load (LD) instruction. Base ad-
dressing is specified by stating the register that holds the base address, fol-
lowed by an immediate index; the index is enclosed in parentheses:
The base address mode is the complement of the indexed mode and
allows access to data in a table where the index into the table is known, but
the base address of the table is computed during program execution. For ex-
122 The Instruction Set Chap. 8
WORD
ample, the BA mode might be used for accessing the corresponding elements
in several different tables of data.
For the nonsegmented mode, the base address and indexed modes are
equivalent; for each, a 16-bit value in a register is added to a 16-bit value
given in the instruction's opcode to yield an effective memory address for
the operand. The only difference occurs when R15 is used to hold the base
address or index:
LD RO, 50 (R15)
would access stack memory to obtain the source operand. The indexed
mode is used more frequently, however, since it is available in more instruc-
tions and results in faster execution than when base addressing is used.
The base indexed (BX) mode is a combination of the X and BA modes. For
the BX mode, both the base address and index are held in registers (Fig. 8.9).
In the nonsegmented mode, both the base address and the index are held in
any word register except RO. In the segmented mode, the base address may
be in any register pair except RRO and the index may be in any word register
except RO. The effective memory address of the operand is found by adding
the index to the base address. The segment-number portion of the effective
address is always the segment number of the base address; the index is added
to the offset only.
Operands specified using BX mode are in the stack memory address
space if either R15 in the nonsegmented mode or RR14 in the segmented
mode is used to hold the base address. Otherwise, the operand is in data
memory.
The base indexed mode is used only with the Load (LD) instruction.
When specifying the BX mode, the register that holds the base address is
given, followed by the register holding the index; the index is enclosed in
parentheses:
LD RO, R2(R5) I nonsegmented mode, BX mode designates source!
LDB RH2, RR14(R9) ! segmented mode, source is in stack memory!
In the relative address (RA) mode, the operand is at a memory address that
is calculated relative to the current program counter value. A displacement
is given in the instruction's opcode; this displacement is a two's-complement
number that is added to or subtracted from the program counter to yield the
address of the operand (Fig. 8.10). The maximum size of the displacement
depends on the instruction used. The PC value used is the address of the
next memory location following the currently executing instruction. In the
segmented mode, the calculation of the operand's effective address will not
affect the segment-number portion of the address; that is, the operand is al-
ways in the segment determined by the segment number in the PC.
An operand specified by RA mode is always in the program memory
address space. Relative addressing allows references to memory locations
that are a short distance backward or forward from the current PC value. It
is used by the Jump Relative (JR), Call Relative (CALR), Decrement and
Jump if Not Zero (DJNZ, DBJNZ), Load Relative (LDR, LDRB, LDRL),
and Load Address Relative (LDAR) instructions. Typically, the program-
mer uses label names in the program to specify the location to be referenced
using RA mode and lets the assembler calculate the displacement value that
becomes part of the instruction's opcode:
LDR R5, LOOP ! LOOP is a label in the program!
OPERATION
DISPLACEMENT
(2'S COMPL.)
For the JR and CALR instructions, the effective address is not used to
reference a memory location, but instead is used as an immediate value that
is loaded into the program counter.
Besides the eight addressing modes described above, the Z8000 has two ad-
ditional modes that are implied by the use of certain instructions, auto-incre-
ment and auto-decrement. Several instructions manipulate entire strings of
data in memory. These instructions address source and destination strings in
memory using indirect register addressing; that is, the address of the element
in the string currently being acted on is in a register. After each iteration of
the instruction's execution, the operand's address is incremented or decre-
mented, as specified by the instruction type, so that the register now points
to the next element of the string, ready for the next iteration of the instruc-
tion's execution.
The Z8000 CPU's assembly language instruction set can be segregated into
12 categories of instructions: data movement, arithmetic, logical, bit manip-
ulation, rotate and shift, program control, block move, block compare, block
translate, I/O, special I/O, and CPU control instructions. Tables 8.4 through
Assembly Language Instructions 125
8.15 list the instructions in each category, including the mnemonic, oper-
ands, addressing modes for the operands, clock cycles required to execute,
and a description of the operation for each instruction.
Many of the instructions can operate on byte, word, or long-word data
types. In general, if an instruction's mnemonic ends with a "B" suffix, it is a
byte instruction; if the instruction's mnemonic ends with an "L" suffix, it is
a long-word instruction; otherwise, it is a word instruction.
The number of CPU clock cycles required for execution of an instruc-
tion depends on the data type for that instruction and the segmentation
mode of the CPU. In Tables 8.4 through 8.15, NS means nonsegmented
mode, SS means segmented mode using short offset format, and SL means
segmented mode using long offset format. The execution times are calcu-
lated assuming that there are no externally-generated wait states during
memory and I/O accesses.
The carry, zero, sign, and overflow/parity flags in the FCW are used to
control the operation of certain "conditional" instructions, such as the
Jump (JP) instruction. The operation of these instructions depends on the
condition of these four flags. Sixteen different combinations of these flag
settings are encoded in a 4-bit field in the opcode called a condition code.
The mnemonics for the condition codes and the flag settings they represent
are listed in Table 8.3. Although there are only 16 unique conditions, the
F Always false
Always true
Z Zero Z=l
NZ Not zero z=o
C Carry C=l
NC No carry C=O
PL Plus 8=0
MI Minus 8=1
NE Not equal Z=O
EQ Equal Z=l
OV Overflow V=1
NOV No overflow V=0
PE Parity even P=l
PO Parity odd p=o
GE Greater than or equal (8 XOR V) = 0
LT Less than (8 XOR V) = 1
GT Greater than (Z OR (8 XOR V» = 0
LE Less than or equal (Z OR (8 XOR V» = 1
UGE Unsigned greater than Qf equal C=O
ULT Unsigned le~s than C=l
UGT Unsigned greater than ((C = 0) AND (Z = 0» = 1
ULE Unsigned less than or equal (C OR Z) = 1
126 The Instruction Set Chap. 8
The data movement instructions, listed in Table 8.4, provide one of three
functions: (1) load a register with data from a register or memory location,
(2) load a memory location with data from a register, or (3) load a register
or memory location with an immediate value. These instructions do not
affect the flags in the FCW.
The Clear instructions (CLR, CLRB) are used to clear a byte or word
register or memory location to zero. This is functionally equivalent to a
Load instruction with an immediate operand of zero.
The Exchange instructions (EX, EXB) are used to swap the contents of
two registers, or a register and a memory location. A temporary storage
register internal to the CPU is used to implement the swap. The Exchange
instruction is useful for converting Z80 or other microprocessor code into
Z8000 code, since the Z8000 uses the opposite convention of odd/even
memory addressing of bytes in words than the Z80.
The Load instructions (LD, LDB, LDL) provide for transferring data
between memory and register locations. Note that no memory-to-memory
loads are included in this group of instructions.
The Load Address instruction (LDA) loads the address of the source
operand into the destination register. The contents of the source are not
accessed; the effective address computation corresponding to the specified
addressing mode is made, and that effective address, not the data at that ad-
dress, is written into the destination. The destination must be a word
register in nonsegmented mode, and a long-word register in segmented mode.
The Load Address Relative instruction (LDAR) is similar to the LDA
instruction, except that it supports the relative address mode. The displace-
ment can range from - 32768 to +32767 and is added to the current program
counter value to yield the effective address that is loaded into the
destination.
The Load Constant instruction (LDK) is a short, fast instruction for
loading small numeric constants into a word register. The source operand
must be an immediate value between 0 and 15. The high-order 12 bits of the
destination register are cleared to zeros.
The Load Multiple instruction (LDM) provides for efficient saving and
restoring of registers' contents and can significantly lower the overhead re-
quired for procedure calls and other context switches. This instruction
TABLE 8.4 DATA MOVEMENT I NSTR UCTI ONS
Clock cycles
127
128 The Instruction Set Chap.S
ARITHMETIC INSTRUCTIONS
Table 8.5 lists the Z8000 instructions that perform integer arithmetic. The
basic instructions use standard two's-complement binary format for repre-
senting integers, but support is provided for BCD arithmetic as well. Most
instructions in this group perform a binary operation between a register's
contents and a source operand designated by one of the five basic addressing
modes (R, DA, 1M, IR, and X). The result is loaded into a register. These
instructions set the flags in the FCW to the appropriate values depending on
the result of the arithmetic operation. The P/V flag is used to indicate over-
flow for these instructions and is called the V flag.
The Add (ADD, ADDB, ADDL) and Subtract (SUB, SUBB, SUBL) in-
structions perform basic binary addition and subtraction. Multiple-precision
operations can be implemented using the Add with Carry (ADC, ADCB) and
Subtract with Carry (SBC, SBCB) instructions, but these instructions sup-
port only register addressing for both the source and destination.
The Compare instructions (CP, CPB, CPL) allow comparison of a reg-
ister's contents to another register's contents, a memory location's contents,
or an immediate value. The Compare instructions do not affect either oper-
and but set the flags based on the result that occurs when the source is sub-
tracted from the destination.
The Decimal Adjust instruction (DAB) operates only on byte registers
TABLE 8.5 ARITHMETIC INSTRUCTIONS
Clock cycles
129
130 The Instruction Set Chap. 8
and is used to implement BCD arithmetic. Two BCD digits can be packed
into a byte register, one per nibble. Byte registers so formatted can be added
or subtracted using the binary ADDB and SUBB instructions; these instruc-
tions would be followed by a DAB. The DAB instruction adjusts the desti-
nation register back into BCD format using the D and H flags.
The Decrement (DEC, DECB) and Increment (INC, INCB) instructions
are used to decrement or increment a register or memory location by an
immediate value between 1 and 16.
The Extend Sign instructions (EXTS, EXTSB, EXTSL) are used to con-
vert a small signed operand (in a register) to a larger signed operand, by
copying the sign bit (most significant bit) of the low-order half of the desti-
nation to all the bits in the high-order half of the destination. Thus an 8-bit
signed integer can be converted to 16 bits, a 16-bit integer to 32 bits, or a
32-bit integer to 64 bits.
The Divide instructions (DIV, DIVL) perform signed two's-complement
division on word or long-word operands. The DIV instruction requires a
long-word register as the destination and a word operand as the source. The
32-bit destination is divided by the source; the quotient is written into the
low-order half of the destination and the remainder is loaded into the high-
order half of the destination. For example:
DIV RR2, R5
would divide the contents of RR2 by the contents of R5 and, after the di-
vision, the quotient would be in R3 and the remainder in R2. Similarly, the
DIVL instruction requires a quad register as the destination and a long-word
register as the source:
After the division, RR4 holds the remainder and RR6 holds the quotient.
The Multiply instructions (MULT, MULTL) perform signed two's-com-
plement multiplication of word and long-word operands. MULT multi-
plies two 16-bit words and produces a 32-bit result; MUL TL multiplies two
32-bit long words and produces a 64-bit result.
The Negate instructions (NEG, NEGB) perform a two's-complement
negation on the contents of a register or memory location.
LOGICAL INSTRUCTIONS
Instructions that perform logical operations are listed in Table 8.6. These in-
structions set the Z and S flags based on the result of the logical operation.
The byte instructions also use the P IV flag as a parity flag; the P flag is set if
the result has even parity.
Logical Instructions 131
Clock cycles
The bit manipulation instructions (Table 8.7) are used to set, reset, or test
individual bits in registers or memory locations. With most other processors,
bit manipulation must be done using the logical operations with appropriate
masks, which is awkward and inefficient.
The Bit Test instructions (BIT, BITB) test the specified bit in the desti-
nation for a 1 or 0, and set the Z flag appropriately. If testing a bit in a
memory location, the number of the bit to be tested is given as an immediate
operand between 0 and 7 for BITB and between 0 and 15 for BIT. If testing
a bit in a register, the number of the bit to be tested can be an immediate
operand or the contents of a word register.
In a similar manner, the Set Bit (SET, SETB) and Reset Bit (RES,
RESB) instructions are used to set or reset any bit in a register or memory
location. For destination operands in memory, the number of the bit to be
set or reset is given as an immediate operand; for bits in registers, the number
of the bit can be given as an immediate operand or the contents of a word
register.
The Test and Set instruction (TSET) is provided to support imple-
Clock cycles
132
Rotate and Shift Instructions 133
The rotate and shift instructions (Table 8.8) are used to rotate bits in byte or
word registers and shift bits in byte, word, or long-word registers.
With the Rotate Left (RL, RLB) and Rotate Right (RR, RRB) instruc-
tions, bits in byte or word registers can be rotated by one or two bit posi-
tions. For Rotate Left, the most significant bit of the operand is loaded into
the C flag as well as rotating into the least significant bit; for Rotate Right,
the least significant bit is written to the C flag. Rotates that include the
carry flag are also available: Rotate Left through Carry (RLC, RLCB) and
Rotate Right through Carry (RRC, RRCB), as illustrated in Fig. 8.11.
The Rotate Left Digit (RLDB) and Rotate Right Digit (RRDB) instruc-
tions operate only on byte registers. BCD digits in the source register can be ro-
tated right or left with these instructions (Fig. 8.12). For RLDB, the lower
nibble of the source is moved to the upper nibble of the source; the upper
nibble of the source is moved to the lower nibble of the destination; the
lower nibble of the destination is moved to the lower nibble of the source.
The upper nibble of the destination is unaffected. The RRDB instruction
rotates nibble right in a similar fashion. If strings of BCD digits are to be
ROTATE LEFT
RL
0J4-~-~- -----o,J
RLB
0~r-----7 _------.0 ,J
ROTATE RIGHT
RR
[1~15-----O~G
RRB
Lr~-_O~-G
RRC [_I~
15 _ _ _ _ _ _ ~GJJ
-----,0
RRCB
[ . . . . . -7- ,_ _----,0 ~0J
Figure 8.11 Rotate instructions.
134
TABLE 8.8 ROTATE AND SHIFT INSTRUCTIONS
Clock cycles
t t_------'
t
Figure 8.12 Rotate Left Digit and Rotate Right Digit instructions.
135
136 The Instruction Set Chap. 8
BYTE: 1'-0
15 o 15
15 0 15 0
n = 0, 2, 4, .. ,14 n = 0, 2, 4, ' .. , 14
LOGICAL SHIFTS:
RIGHT LEFT
0
BYTE: 1'-0
15 0 15 0
WORD: 0 -Jooo-&-1_ _ _ _ _ _ _ _ _ _---I~~ ~-1,....-------------II- 0
LONG: 0
15
Rn_ _ _=-~-J
-Jooo-I&-_ _ _ _ _ _
0
~-1~_ _
15
R_n -----IIJ 0
I-;~ __ o
Li,..:.-5- - R n - +
1 -----.,l---0
LC Rn+1 1_ 0
The Shift Dynamic Arithmetic (SDA, SDAB, SDAL) and Shift Dy-
namic Logical (SDL, SDLB, SDLL) instructions allow right or left shifts by
the number of bits specified by the contents of the source operand, which is
always a word register. The source is treated as a signed two's-complement
value; positive values specify a left shift, whereas negative values specify a
right shift. The shift count can range from -8 to +8 for byte operations, -16
to +16 for word operations, and -32 to +32 for long-word operations.
The remaining shift instructions require an immediate operand as the
source. This operand determines the number of bit positions to be shifted,
and range from 0 to 8 for byte operations, 0 to 16 for word operations, and
o to 32 for long-word operations. These instructions include the Shift Left
Arithmetic (SLA, SLAB, SLAL), Shift Left Logical (SLL, SLLB, SLLL),
Shift Right Arithmetic (SRA, SRAB, SRAL), and Shift Right Logical (SRL,
SRLB, SRLL) instructions. The only difference between the arithmetic and
logical left shifts is the setting of the V flag.
The program control instructions (Table 8.9) are instructions that change the
value of the program counter.
When the Call (CALL) or Call Relative (CALR) instruction is executed,
the current PC value is pushed onto the stack using the implied stack pointer
(R15 in nonsegmented mode, RR14 in segmented mode). The PC value
pushed is the address of the next instruction following the subroutine call.
The specified destination address is then loaded into the PC; the PC then
points to the first instruction in the subroutine. For the CALR instruction~
the destination address is calculated using relative addressing and must be in
the range -4092 to +4098 bytes from the start of the CALR instruction. The
CALR has a shorter opcode than the CALL instruction.
At the end of the procedure entered with a CALL or CALR, a Return
(RET) instruction will pop the old PC value off the stack and resume execu-
tion at the instruction following the subroutine call, if the specified condi-
tion code is satisfied by the flags. If the condition code is not satisfied, the
next instruction following the RET is executed.
The Decrement and Jump if Not Zero instructions (DJNZ, DBJNZ) are
used to control execution of program loops. A word register (for DJNZ) or
byte register (for DBJNZ) is used as a loop counter. A destination address is
calculated using relative addressing. Execution of the DJNZ will cause the
register contents to be decremented by one. If the contents of the register
are not zero after the decrement, the destination address is loaded into the
PC. When the register contents reach zero, control falls through to the next
instruction after the DJNZ. The destination address must be in the range of
- 252 to +2 bytes from the start of the DJNZ instruction. Thus this instruc-
tion cannot be used to jump in a forward direction.
138 The I nstruction Set Chap. 8
Clock cycles
The DJNZ and DBJNZ instructions provide a simple, efficient loop con-
trol method for Z8000 programs. For example, the code needed to execute
a program loop exactly 50 times would read as follows:
LOB RHO, #50
having to save the flags before checking the end-of-Ioop condition and
restoring them afterwards.
The Jump (JP) and Jump Relative (JR) instructions load the PC with
the destination address if the condition code is true. If the condition code
is not satisfied by the flags, the instruction following the jump will be exe-
cuted. For the JR instruction, relative addressing is used to calculate the
destination address, which must be in the range of -254 to +256 bytes from
the start of the JR instruction.
The Interrupt Return instruction (lRET) is used to return to the inter-
rupted task after executing an interrupt or trap service routine, as described
in Chapter 6. The identifier word associated with the interrupt or trap is
popped from the system stack and discarded. Then the old program status
values for the interrupted task are popped and loaded into the FCW and PC.
The new value for the FCW is not effective until the next instruction, so the
CPU's status pins will not be affected by the new control bits until after the
IRET instruction execution is complete. IRET is a privileged instruction
and, therefore, can only be executed in system mode. A ZSOOI must be in
segmented mode when an IRET is performed.
The System Call instruction (SC) causes the CPU to process a system
call trap, as described in Chapter 6. This instruction allows normal-mode
users access to the operating system functions in the system call trap service
routine. The SC instruction requires an immediate operand between 0 and
255; this operand is encoded into the opcode that is saved on the stack as the
identifier word when processing the system call trap.
Clock cycles
data is being moved in memory and other operations are contained in the
loop. The third operand in these instructions is a word register that holds a
count that is decremented each time the instruction is executed.
The Load, Increment and Repeat (LDIR, LDIRB) and Load, Decre-
ment and Repeat (LDDR, LDDRB) instructions are automatically repeating
forms of the block transfer instructions. These instructions are, in essence,
a one-instruction loop. The third operand is a word register that holds the
count of how many times the instruction is to be executed. Thus a block
of 64K bytes of data can be relocated within memory with one Z8000
instruction.
The automatically repeating forms of the block move instructions are
interruptible at their elementary level, that is, after each iteration of the
byte or word transfer. The address saved on the stack during exception pro-
cessing would be the address of the block move instruction itself. Of course,
the service routine should not alter any of the registers being used by the
block move to hold memory addresses or the repetition count.
Two types of block compare instructions are provided: one for comparing
the elements of a string of bytes or words in memory to the contents of a
Block Translate Instructions 141
The block translate instructions (Table 8.12) operate only on byte strings in
memory. One set of instructions is used to translate a string of bytes from
one code to another; another set of block translate instructions is used to
TABLE 8.11 BLOCK COMPARE INSTRUCTIONS
Clock cycles
142
TABLE 8.12 BLOCK TRANSLATE INSTRUCTIONS
Clock cycles
143
144 The Instruction Set Chap. 8
scan a string of bytes for elements with a special meaning. All of the block
translate instructions use byte register RHI as a temporary storage area
during their execution.
The Translate and Decrement instruction (TRDB) has three operands.
The source and destination operands are in memory and are specified using
indirect register addressing. The third operand is a count that is decre-
mented each time the instruction is executed. The location addressed by
the destination register is called the target byte and its contents are used as
an index into a table of translation values whose base address is in the source
register. The element of the table whose address is found by adding the tar-
get byte to the base address of the table replaces the target byte at the des-
tination address. The destination register is then decremented by one to
point to the next element of the string to be translated.
Suppose that a string of bytes holding ASCII characters is to be trans-
lated into the corresponding EBCDIC characters. A table is built in memory
wherein each EBCDIC character is placed at the table location corresponding
to the ASCII value for that character. For example, the thirtieth (hexa-
decimal) element of the table should contain the EBCDIC code for a "0,"
since 30 (hex) is the ASCII code for a "0." The base address (that is, lowest
address) of the table is loaded into the source register for the TRDB instruc-
tion. The highest address in the ASCII string to be translated is loaded into
the destination register and the TRDB instruction is used to perform the
translation. The destination register is automatically decremented to point
to the next byte to be translated.
The Translate and Increment instruction (TRIB) is similar, with the des-
tination register being incremented instead of decremented after each execu-
tion. TRDB and TRIB typically are used in a program loop to translate an
entire string of data.
The Translate, Decrement and Repeat (TRDRB) and Translate, Incre-
ment and Repeat (TRIRB) are automatically repeating forms of the translate
instructions. The instruction repeats until the contents of the count register
reach zero. These instructions are interruptible after each iteration of the
operation.
The Translate, Test and Decrement instruction (TRTDB) works in a
similar manner and is used to scan a string for special characters. The con-
tents of the location addressed by the first source register is used as an index
into a table of values whose base address is contained in the second source
register. This element of the table is loaded into RHI and, if it is zero, the
Z flag is set. The contents of the location addressed by the source are not
altered by this instruction. The first source register is then decremented to
point to the next element of the string being scanned. This instruction typi-
cally is used in a loop, where a string is scanned until a nonzero value is
found in the table. The Translate, Test and Increment instruction (TRTIB)
is similar, except the first source address is incremented.
I/O Instructions 145
I/O INSTRUCTIONS
The instructions used to access the standard I/O address space are listed in
Table 8.13. All I/O instructions are privileged, meaning that they can be
executed in the system mode only.
The Input instructions (IN, INB) are used to input a byte or word of
data from an I/O device. The destination is always a register. The I/O port
address can be specified using the direct address or indirect register address-
ing modes. No flags are affected.
For the Input and Decrement instructions (IND, INDB), the destination
is a memory location and the source is an I/O port. Both the memory and
I/O port address are specified using indirect register addressing. After ex-
ecution, the destination register is decremented to point at the next lower
memory location, in preparation for another execution of the instruction.
Thus this instruction would be used in a program loop to load strings of data
from an I/O port to consecutive memory locations. The third operand is a
word register that holds a count that is decremented each time the instruc-
tion is executed. The Input and Increment instructions (INI, INIB) are sim-
ilar, with the destination register being incremented each time the instruc-
tion is executed.
The Input, Decrement and Repeat (INDR, INDRB) and Input, Incre-
ment and Repeat (INIR, INIRB) are automatically repeating forms of the in-
put instruction. The instruction repeats until the count reaches zero; there-
fore, up to 64K bytes of data can be read from an I/O port and placed in
memory with one instruction.
The Output instruction (OUT, OUTB) is used to write a byte or word
of data from a register to a peripheral device. Block output instructions are
available for writing data in consecutive memory locations to an I/O port.
These are analogous to the input commands, and include the Output and
Decrement (OUTD, OUTDB), Output and Increment (OUTI, OUTIB), Out-
put, Decrement and Repeat (OTDR, OTDRB), and Output, Increment and
Repeat (OTIR, OTIRB) commands.
All the repeating I/O instructions are interruptible after each iteration
of the instruction. For byte I/O operations, the I/O port address will deter-
TABLE 8.13 I/O INSTRUCTIONS
Clock cycles
146
CPU Control Instructions 147
mine which half of the address/data bus is used for the byte data transfer,
as explained in Chapter 4. Byte data are transferred on ADO-AD7 for odd
port addresses, and on AD8-AD15 for even port addresses.
The special I/O instructions (Table 8.14) are used to access the peripherals in
the special I/O address space and are identical in format to the I/O instruc-
tions described above. In fact, the only difference between executing an I/O
instruction and the corresponding special I/O instruction is the status code
emitted on the STO-ST3 lines during I/O access machine cycles. Note that
the Special Input (SIN) and Special Output (SOUT) instructions do not sup-
port the indirect register addressing mode for specifying I/O port addresses.
All special I/O instructions are privileged instructions.
The CPU control instructions (Table 8.15) are instructions that operate on
the CPU control registers (the FCW, PC, and refresh register) or perform
other CPU-related functions.
Several instructions can be used to manipulate the flags in the FCW.
The Set Flag instruction (SETFLG) is used to load a 1 into any combination
of the C, S, Z, or P/V flags. The operands are the flags themselves; one, two,
three, or four operands can be specified, in any order:
LDCTLB RHO, FLAGS ! load the flag byte of the FCW into RHO!
LDCTLB FLAGS, RL6 ! load contents of RL6 into low half of FCW !
Clock cycles
148
CPU Control Instructions 149
Clock cycles
to transfer words between any general-purpose register and the CPU control
registers. LDCTL can read or write to the FCW, refresh register, PSAP seg-
ment number (ZSOOl only), or PSAP offset. When loading control registers,
bits marked "reserved" in the destination should be loaded with O's. The
value of those bits when read from control registers and loaded into general-
purpose registers is undefined. Only the row counter portion (bits O-S) of
the refresh register can be read. The normal-mode implied stack pointer can
be accessed while in the system mode with the LDCTL instruction. This al-
lows the operating system to initialize the implied stack pointers for normal-
mode users. Table S.16 shows examples of the LDCTL instruction.
The Load Program Status instruction (LDPS) loads new program status
(an FCW and PC value) from the memory area specified as the operand, as
discussed in Chapter 6. The old program status is not saved, so execution of
the LDPS instruction causes a permanent change in the program environ-
ment. LDPS is a privileged instruction.
The Multi-Micro Request (MREQ), Multi-Micro Bit (MBIT), Multi-
Micro Set (MSET), and Multi-Micro Reset (MRES) instructions are privileged
instructions that act on the MI and MO CPU signals. These signals usually
are used to implement resource sharing in multiprocessor systems, as de-
scribed in Chapter 7.
LDCTL RO, NSPSEG ! read segment number in normal-mode stack pointer while in
system mode !
MEMORY ALLOCATION
152
Segmentation and Memory Allocation 153
ory addresses manipulated within a program and emitted by the CPU during
execution. Physical addresses are the memory addresses seen at the memory
control logic and input to the acutal memory devices (RAM, ROM, or PROM).
In simple systems without memory management capability, the logical and
physical addresses are the same. In more complex systems, a memory man-
ager is used to translate logical addresses into different physical addresses.
The memory management unit stands between the CPU and memory in a
system, accepting logical addresses from the CPU and outputting the corre-
sponding physical addresses to memory. Thus a given programming task
can be relocated anywhere within physical memory by the memory manager
through address translation.
This separation of logical and physical addresses is necessary in most
multitasking systems. The amount of memory in a computer system is
finite. In multitasking systems, the memory requirements for all the tasks in
the system usually exceeds the amount of physical memory in that system.
However, not every task's code and data are needed in main memory at the
same time; secondary storage devices such as tapes and disks can be used to
store tasks not currently being executed. When a task's code or data is needed,
it can be written from the secondary storage device into memory. Of course,
the operating system must keep track of which memory areas are being used
for each task running on the system at any given time. With a memory man-
ager that provides address translation, a new task can be placed in any "open"
area of memory (that is, an area not currently being used by some other
task).
The ability to relocate tasks anywhere within memory can significantly
increase the performance and flexibility of a system. An individual user does
not need to be concerned that the logical addresses within his program are
the same as the logical addresses for another program on the system; the
memory manager will route each task's logical addresses to different areas of
physicalmemory. The cumbersome techniques of reserving fixed areas ofmem-
ory for overlays in a large program can be replaced by more efficient algo-
rithms using the memory manager to relocate program code. Separating logi-
cal and physical addresses also facilitates the sharing of code or data between
two different tasks, since two or more logical addresses can be mapped to the
same physical address.
USER A
USER B
SEG.5
PROGRAM
SEG.5
DATA
SEG.12
DATA
---
READ/W~ITE---- - ___ _
""
""
"" \ //
\ I
A. SEa 5 \ I
DATA \ I
")1 4
/ " II
/ 'I"
/I /
// I
I
/ / / /
/ I I I
I / /
I I / /
\ / I I /
\ I I I /
\, / I I /
EXECUTE I / / I
ONLY " I I I
" I I I
I" I /
B. SEa 5 I \ / /
READ/WRITE PRoaRAM / l'",
," / I I "
/ /
I /
"\
" / I \
B. SEa 12 READ/WRITE I
DATA 'f...
B. SEa 2 I "
STACK / "
,
,,
,,
" ,,
,,
,
"-
"-
"- ,,
Figure 9.2 Mapping logical ad-
dresses to physical addresses.
Within the Z8010 MMU, special registers are used to hold the starting
address in physical memory for each segment. The offset address emitted by
the CPU during Tl of a memory access cycle is added to this starting address
for the segment to produce the physical address output by the MMU. This
address translation is similar to indexed addressing, where the contents of the
MMU register that holds the starting address for the segment is used as a base
address and the offset portion of the logical address is added to that base to
yield the physical address.
156 The Z801 0 Memory Management Unit Chap. 9
L.Q~ PHYSICAL
ADDRESSING ADDRESSING
SPACE SPACE
r----. OOOOOOH
SEGMENT 0 I
I
D
OOOOH
0
I t-
Z
w
I ::;
(!)
UPTO w
FFFFH I <n
I
SEGMENT 1
--L
D
OOOOH
I ~
I ffi::;
~
(!)
UPTO r---W<n
FFFFH
----/===4 I
t---
o
SEGMENT2
----------
OOOOH I w
(,) I
I ~ I
UPTO -+--i~
~ ~ I
I ~ I
I I
Jt
....
N
I I ~w I t-
Z
I I ::;
w
::;
I &3
I I <n
B:/
SEG # -
z
t-
ELEMENT I ffi
15 -- ADDRESSED I I ::;
&3
~/-- ~~F~~
I OFFSET I I
--r-
<n
I
I I I
SEGMENT 127 I I
D
OOOOH
I I
I I
L __ ...J
UPTO FFFFFFH
MEMORY PROTECTION
Once the program has been partitioned into separate memory segments, it is
highly desirable to assign attributes to each segment. For example, attributes
have been associated with each segment in Fig. 9.2 based on how that seg-
ment is to be used during task execution; segments that hold program code
are designated "execute only," and segments that hold data are "read/write"
segments. Since the MMU is between the CPU and memory, it can block il-
legal memory accesses based on the attributes assigned to each segment. Thus
Memory Protection 157
users A and B are prevented from executing a data segment or writing into a
code segment.
More specifically, memory protection by the Z8010 MMU is accom-
plished by memory attribute checking. Attributes are assigned on a segment-
by-segment basis. A segment's attributes determine who can access that seg-
ment and what types of accesses are allowed. Each memory reference is
checked to ensure that the task has the right to access the data in that fashion.
A number of attributes can be associated with a segment and checked
during accesses to that segment. The length of a segment can be designated
in the MMU, and references to each segment are checked to ensure that they
fall within the boundaries of that segment. Segments can be assigned a "read-
only" attribute; this is used to prevent modification of data elements or to
protect the integrity of program code that is not self-modifying. The "exe-
cute-only" attribute means that the segment can be accessed only during in-
struction fetch cycles (including loads that use the relative addressing mode)
and is useful for guarding proprietary software. The "system-only" attribute
prevents normal-mode programs from accessing segments that are reserved
for operating system code or data. To check these attributes, the MMU must
sample the status lines from the Z8001 CPU that define the type of the cur-
rent transaction.
The Z8010 MMU stores each logical segment's attributes in an internal
register (one per segment) and checks those attributes each time the segment
is accessed. If a memory access that violates the attributes for a segment is
detected, the MMU notifies the CPU by making a segmentation trap request
on the Z8001's SEGT input. The segmentation trap service routine can read
status registers in the MMU to determine the exact cause of the trap. When
asserting a segment trap request, the MMU also generates a signal to memory
(SUP) that can be used by memory control logic to inhibit an erroneous mem-
ory write.
The MMU stores other status information together with the attributes
for each segment. This information includes flags that indicate if a segment
has been referenced or modified while resident in main memory. If a seg-
ment is to be written to a secondary storage device, such as a disk, in order
to make room in main memory for another task, these flags will indicate if
that segment was modified since the last time it was read into memory from
the disk. If the segment was modified, the updated version of that segment
must be written to the disk; if not, the copy of the segment's contents on
the disk is still valid and rewriting the segment to the disk is not necessary.
Obviously, such status information can improve the performance of the en-
tire system.
In summary, memory management involves the allocation and protection
of the system's memory resources. In Z8001-based systems, a memory man-
agement system can be implemented using operating system software and the
Z8010 Memory Management Unit. The Z8010 MMU controls memory allo-
158 The Z8010 Memory Management Unit Chap. 9
cation by translating logical addresses from the CPU into physical addresses
for the memory devices. Memory protection is provided by attribute check-
ing in the MMU.
The segmented address translation mechanism with attribute checking
provides all the benefits of an efficient memory management system. Mem-
ory can be allocated dynamically during task execution; that is, a task may be
located anywhere in physical memory and even moved when its execution is
suspended. Moving tasks to different locations requires only changing the
address mapping within the MMU. This flexibility is possible since the pro-
gram deals exclusively with logical addresses that are independent from the
physical addresses accessed during execution. Furthermore, sharing of com-
mon memory areas by different tasks is accomplished easily by mapping each
task's logical addresses to the same physical address.
Obvious execution errors can be avoided through the assignment of at-
tributes to memory segments. The MMU will notify the CPU when illegal
accesses are attempted, such as exceeding the boundaries of a segment or
writing to read-only memory. The segregation of the operating system from
the users' applications programs is facilitated by the "system-only" attribute.
Segmentation and memory management support the development of
large, complex programs and systems. The concept of segmentation corre-
sponds to the concept of structured programming, where each procedure and
data structure is associated with a distinct segment of memory and each seg-
ment is assigned its own attributes that govern its use. A task accesses a par-
ticular procedure or data structure by referring to its logical segment number;
that segment could be relocated into any appropriate area of physical mem-
ory. Access to each segment is restricted through the attribute-checking
mechanism of the MMU, thereby protecting system integrity.
The Z8010 Memory Management Unit is a 48-pin LSI device that operates
from a single +5-Vpower supply; 4 MHz, 6MHz, and 10 MHz versions are
available. The MMU is used in conjunction with the Z8001 CPU to provide
dynamic segment relocation and memory protection features within a micro-
computer system. A single MMU can manage 64 segments of memory; pairs
of MMUs support the full 128 segments available in a Z8001 memory address
space. Any number of MMUs may be included in one system. For example,
a system might include two MMUs to support 128 segments for normal-mode
users and another two MMUs to support 128 segments for operating system
software. Physically, the MMU is placed between the CPU and memory within
a system; logical addresses are input to the Z8010 and physical addresses
are output to memory. Figure 9.4 shows a simple, single-MMU system.
Only memory addresses are translated by the MMU; I/O addresses and data
bypass this component.
Z8010 MMU Architecture 159
A DATA ~
\
K~ I
"
MEMORY
Z8001 A ~ A ~ Z8010 A ~
) \
CPU
< K
r
I MMU ( )
~
Z·BUS
1/0
CONTROLLER
Z8016
DTC
A
!( \I (E.G., I
A ~
PERIPHERALS
< > ~ r
SCC, UPC,
CIO, OR
FlO)
\
~
"
The MMU translates the 23-bit logical address (7 -bit segment number
and 16-bit offset) from the CPU into a 24-bit physical address. Thus the 8M
bytes of logical addresses in a Z8001 memory space can be mapped into 16M
bytes of addresses in physical memory. Address translation and attribute
checking take place on a segment-by-segment basis. A translation table with
one entry per segment is used to perform the address translation. The at-
tributes for each segment also are stored in a table, with one entry per seg-
ment. As the address translation occurs, the attributes are checked against
the status information for the memory access from the CPU. If a violation
of the attributes is detected, the MMU notifies the Z8001 via the segmenta-
tion trap (SEGT) signal.
Figure 9.5 shows the functional pin-out and pin assignments for the
Z8010. The MMU receives the upper half of the address/data bus (AD8-
ADI5), the segment number, the status signals, and the bus timing signals
from the CPU. The remaining signals are control lines, including a chip se-
lect (CS), DMA synchronization strobe (DMASYNC), reset, and the clock.
The MMU is not a Z-Bus-compatible part, but instead is considered an ex-
tension of the processor. As such, it must receive the same clock as the CPU
in order to synchronize the address translation process with the CPU's mem-
ory access timing. MMU outputs include 16 bits of physical address informa-
160 The Z801 0 Memory Management Unit Chap. 9
---
AD15 A23
AD14 A22
cs
-
48 N/S
AD13 A2l
DMASYNC 47 R/W
AD12 A20
ADDRESSI SEGT 46 55
DATA A19
SUP 45 AS
Ala
RESET 44 STo
A17
A23 43 STl
A16
PHYSICAL
A22 42 ST2
A15 ADDRESS
A2l 41 ST3
A14
A20 40 ADa
A13
A19 10 39 ADg
A12
Z8010 Vee 11 38 AD10
All
MMU AlB 12 Z8010 37 ADll
Al0
A17 13 MMU 36 ClK
Ag
A16 14 35 GND
As
A15 15 34 AD12
I
SEGT SUP SUPPRESS
TRAP A13 17 32 AD14
A12 18 31 AD15
~
DMAISEGMENT _
=
DMASYNC R/IN
All 19 30 SNo
N/S
Al0 20 29 SNl
AS ST3
21 28 SN2
BUS TIMING { Ag
55 ST2
STATUS As 22 27 SN3
STl
RESERVED 23 26 SN4
CHIP SELECT _ cs STo
SNs 24 25 SNs
tion (A8-A23), the segmentation trap request line (SEGT), and a memory
suppress signal (SUP).
For each bus transaction initiated by the CPU or a DMA device, the
Z8010 MMU will enter one of three functional states. The first is the mem-
ory management state; for a certain subset of memory transactions, the MMU
will translate the logical address to a physical address and check the attributes
for that access. The second state is a command state; the MMU will interpret
special I/O transactions as commands if the MMU's chip select (CS) input is
active. These commands allow the CPU to read from and write to the MMU's
registers. The third state is a quiescent state wherein the MMU ignores the
transaction and tri-states its address outputs. The MMU ignores all standard
I/O, internal, and refresh cycles and a subset of all memory transactions. The
MMU also ignores special I/O transactions if CS is not active. While in the
command or quiescent state, the MMU address outputs are tri-stated.
Figure 9.6 illustrates the interface between the Z8001 CPU and the
Z8010 MMU. The MMU selects which of the three states it should enter for
a given transaction based on the bus status information on the STO-ST3, R/W,
and N /8 signals during T1 of a CPU or DMA cycle. If an address translation
is to be performed, the MMU uses the segment number to access an internal
Z8010 MMU Architecture 161
tI.
00- 0 7 )
OS-O'I
l '\
-V~
AiJ-A7 '\
i(--;00-A07
+cs -V
~
1/ AOs-AO'1
~ As-An
~ MEMORY
CONTROL
~
K SNo-SN6
r') SUP
v'
r
Z8001
CPU ~
Z8010
\
n>
MMU
STo-ST] STo-ST] )
SEGT
I-- ASV'
AS ~
I--
OS
I-- ~
RfW
f----- 8'r!--
NfS
f--
~w
6 0 15 87 0
1 SEGMENT NUMBER 1 1
....._ _ _ _ _ _ _ _OF....L~S_E_T_ _ _ _ _ _-----11 LOGICAL ADDRESS
c../1
r--
23
..
_ _ _ _ _ _ _ _ _ _ _ _ _---,8? _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
SE ADDRESS I' • • • • • • .,
• _ .1. _ .1. _ .1. _ .1. _ .1. _ .1. _ .1.
~
_.J
STARTING ADDRESS
OF SEGMENT
IN MEMORY
+
23 87 o
ment descriptor register during the address translation process. The segment
number is output by the CPU earlier than the offset address during a memory
access. This allows the MMU to access its internal segment descriptor regis-
ter for that segment and select the base address before the offset appears,
thereby minimizing the delay between a valid offset address at the MMU's
inputs and a valid physical address at the MMU's outputs.
The rising edge of AS indicates that the offset address and status sig-
nals are valid at the MMU's inputs. AS and DS provide the bus timing for
data transactions between the CPU and MMU during special I/O transactions
that access the MMU's registers and during interrupt acknowledge cycles re-
sulting from segmentation traps.
The chip select (CS) is used to select an MMU during a special I/O in-
struction. The CPU uses special I/O transactions to read from and write to
the MMU's internal registers.
The DMA synchronization strobe (DMASYNC) input signals whether the
current cycle was initiated by the CPU or a DMA controller. A low indicates
that a DMA device has control of the bus.
When the MMU enters the memory management state during a memory
transaction, the segment's attributes are checked against the current bus sta-
tus. If a violation occurs (for example, the R/W line is low, indicating a write
transaction, but the segment is assigned the "read-only" attribute), the MMU
pulls the segment trap (SEGT) signal low , forcing a segmentation trap at the
CPU. The suppress (SUP) signal also is pulled low; suppress can be used in the
memory control logic to block illegal memory accesses.
The MMU contains a number of internal registers that are used to con-
trol MMU operation and to implement the address translation and attribute
checking processes. There are three types of registers: segment descriptor
registers, control registers, and status registers. A segment descriptor register
determines the base address, size, and attributes for a particular segment.
There are 64 segment descriptor registers-one for each segment handled by
the MMU. One control register, the mode register, determines which memory
accesses, if any, will put the MMU in the memory management state. Two
Segment Descriptor Registers 163
other control registers are used to access the segment descriptor registers, the
segment address register (SAR), and the descriptor selection counter register
(DSC). Six status registers can be read by the CPU when a segmentation trap
occurs to determine the cause of the trap. The violation-type register identi-
fies the type of violation caused by the attempted memory access. The vio-
lation segment and violation offset registers hold the segment number and
upper byte of the offset address of the memory access that caused the viola-
tion. The instruction segment number and instruction offset registers hold
the segment number and upper byte of the offset address of the first word in
the instruction that was executing when the violation occurred. The bus cycle
status register holds the bus status conditions at the time of the violation.
The MMU is controlled via 22 commands issued as special I/O instruc-
tions by the Z8001 CPU. With these commands, system software can read
from or write to the MMU's registers. Data are transferred between the CPU
and MMU one byte at a time on the AD8-AD15 bus lines.
There are 64 segment descriptor registers in the MMU, one for each segment
whose access is controlled by the MMU. Two MMUs are required to handle
all 128 possible segment numbers from the Z8001. The mode register is pro-
grammed so that an MMU handles segment numbers 0-63 or segment numbers
64-127.
Each of the 64 segment descriptor registers contains information related
to the address translation and protection attributes for one segment. A seg-
ment descriptor register is 32 bits wide and has three fields: a 16-bit base ad-
dress field, an 8-bit limit field, and an 8-bit attribute field (Fig. 9.8).
The base address field holds the upper 16 bits of the 24-bit physical ad-
dress that is the starting address in physical memory for that segment. The
low-order byte of the base address is always all O's (Fig. 9.9). During a mem-
ory access, the logical offset address from the CPU is added to this base ad-
31 16 15
'--------....y-.---------" "'-----..y------
BASE ADDRESS FIELD LIMIT FIELD
'-----.'V.------"
ATTRIBUTE FIELD
dress to yield the corresponding physical address in memory. The two bytes
of the base address in the segment descriptor register are read or written one
byte at a time when these registers are accessed.
The limit field is an 8-bit field that determines the size of the memory
segment. Segments may be any length from 256 bytes to 64K bytes, in in-
crements of 256 bytes. If the limit field contains the number N, then the
segment contains either N + 1 blocks of 256 bytes or 256~ N blocks of 256
bytes, depending on the DIR W bit in the segment descriptor's attribute
field, as explained below. Each time an address translation occurs, the upper
byte of the logical offset address is compared to this limit field to ensure
that the access falls within the limits of that segment; if not, a segment-length
violation is detected.
Each of the 8 bits in the attribute field is a flag for a particular attribute
or status condition. Five bits determine the protection attributes assigned to
the segment, one bit specifies the orientation of the segment, and two bits
hold status information recording the types of accesses that have been made
in that segment.
Bit 0 of the attribute field is the read-only (RD) bit. When this bit is
set, the segment may be accessed only by memory reads (instruction fetches
or data reads). Writes are prohibited and an attempted write access will cause a
violation condition. This attribute is useful for protecting executable code
from inadvertent writes. It is also used to protect critical data that is not to
be modified by a particular user.
Bit 1 of the attribute field is the system-only (SYS) bit. When this bit
is set, the segment may be accessed only when the CPU is in the system mode;
normal-mode accesses are prohibited. This attribute is useful when an MMU
receives logical addresses from both the operating system and users' programs.
Normal-mode users are prevented from accessing segments containing code or
data reserved for the operating system, even if the normal-mode programs
generate the correct logical addresses for those segments. For example, I/O
routines might be in a segment with the system-only attribute and normal-
mode users would be unable to access them directly.
Bit 2, the CPU-inhibit (CPUI) bit, indicates that the segment cannot be
referenced by the CPU. When set, all CPU accesses to the segment are pro-
hibited, but DMA controllers can still access the segment. This flag is useful
for preventing programs from accessing segments that are being altered by a
DMA operation. For example, a DMA controller may be filling a segment
with data from a disk drive, interleaving its operation with the CPU. The seg-
ment being loaded by the DMA device should not be accessed by the CPU until
the DMA operation is complete.
Bit 3 of the attribute field is the execute-only (EXC) bit. When this bit
is set, the segment may be referenced only during instruction fetch cycles
(including PC-relative loads). Access during any other type of cycle, such as
Segment Descriptor Registers 165
DIRW 0 DIRW 1
r------..., WORD 32766
WORD 128(N+1)
WRITE-WARNING
AREA
t---,..".,...,.,..".,...,..--",--,-...,. WORD 128N
segment. This allows stack areas to be allocated dynamically as the need arises
while executing tasks. Of course, an access beyond the limits of the segment
still causes a violation condition.
Bits 6 and 7 of the attribute field are status bits that indicate the type of
accesses made to the segment. Bit 6 is the changed (CRG) bit and is set if
the segment has been modified by a CPU or DMA controller access. The CRG
bit is set if any write access is made, provided that the access did not cause a
violation condition. This flag is useful for indicating when a segment has been
modified in the case where the segment must be written to a secondary stor-
age device such as a disk. Segments that have not been changed need not be
copied back to the disk if a copy already exists on the disk; this may occur
when a task is suspended and removed from memory to make room for
another task.
Bit 7 is the referenced (REF) flag and indicates that an access has been
made to the segment. This bit is set whenever the segment is read or written
by a CPU or DMA device, provided that the access did not cause a violation
condition. This flag is useful in determining which segments have not been
used in cases where the operating system must select segments to be swapped
out of physical memory.
CONTROL REGISTERS
Three 8-bit control registers direct the functioning of the MMU. The mode
register controls the enabling of the MMU and the address translation function.
The segment address register and descriptor selection counter are pointers
into the table of segment descriptor registers.
The mode register contains a 3-bit identification code and five control
bits, as illustrated in Fig. 9.11. The identification code (ID code) is used
during an acknowledge of a segmentation trap to indicate which MMU or
MMUs generated the trap in systems with eight or fewer MMUs. During the
acknowledge cycle for a segmentation trap, the MMU uses the ID field in the
mode register to select one of the AD8-AD15 lines on the address/data bus;
an ID code of 000 corresponds to AD8, an ID code of 001 corresponds to
AD9, and so on. Each enabled MMU should have a unique ID code. If an
MMU requests a trap, it outputs a 1 on the appropriate line on the address/
data bus as determined by the ID code during the acknowledge cycle; other-
wise, it outputs a a on that line during the acknowledge cycle. The other
address/data bus lines are not driven by this MMU, but might correspond to
the ID field of another MMU in th,e system. Thus the upper byte of the identi-
fier word read by the CPU during the segmentation trap acknowledge cycle
7 32
will indicate which MMUs generated the trap. One memory access could re-
sult in multiple violations in different MMUs, so the segment trap service rou-
tine may have to deal with several MMUs when processing the trap.
The control bits in the MMU mode register provide a means for select-
ively enabling MMUs in a mUltiple MMU system. As mentioned previously,
an MMU will enter the memory management state for some memory trans-
actions, but remain in the quiescent state for other memory accesses; the
mode register determines the subset of memory accesses that the MMU will
handle.
Bit 7 of the mode register is a master enable (MSEN) bit. When set to
a 1, the MMU can perform address translation and attribute-checking func-
tions. When cleared to 0, the MMU is disabled and its A8-A23 outputs are
tri-stated.
Bit 6, the translate (TRNS) bit, enables the MMU's address translation
capability. When this bit is 0 and the MSEN bit is 1, the MMU does not per-
form address translations or attribute checking, but instead passes the logi-
cal address unchanged to physical memory without protection checking.
The AD8-AD15 logical address inputs are passed directly to the A8-A15 MMU
outputs; the SNO-SN6 segment number inputs are passed to the A16-A22
outputs; A23 is set to O. This is called the transparent mode for the MMU,
since the system now operates as if the MMU were not present. When the
TRNS bit is set to 1, the MMU performs address translation and attribute
checking for some memory transactions, as determined by the other control
bits.
Bit 5 of the mode register is the upper range select (URS) bit. When
this bit is cleared, the MMU handles segments 0-63; when set, the MMU han-
dles segments 64-127. Thus for the MMU to enter the memory management
state during a given memory transaction, the most significant bit of the seg-
ment number, SN6, must match the URS bit. If not, the MMU remains in
the quiescent state with its address outputs tri-stated.
Bit 4, the multiple segment table (MST) bit, and bit 5, the normal-mode
select (NMS) bit, work together to allow an MMU to be dedicated only to
system-mode or normal-mode operation. If separate MMUs are used for the
system and normal modes, the MST bit is set in the MMUs. If the MST bit is
a 1, the NMS bit determines if the MMU responds to system-mode or normal-
mode memory accesses, as indicated by the N /S signal from the CPU. When
MST is set, the N /S MMU input must match the NMS bit in order for the
MMU to enter the memory management state; otherwise, the MMU remains
in the quiescent state with its address outputs tri-stated. Thus an MMU with
MST set and NMS cleared would handle address translation for system-mode
memory accesses and another MMU with the MST and NMS set would handle
the translation for normal-mode memory accesses. When the MST bit is 0,
the MMU responds to all appropriate memory transactions regardless of the
operating mode; in this configuration, the system-mode-only attribute can be
168 The Z8010 Memory Management Unit Chap. 9
65 0
Figure 9.12 Segment address regis-
ter.
DSC
Figure 9.13 Descriptor selection
! counter register.
used to protect operating system code and data segments from normal-mode
users.
During a memory access, an MMU enters the memory management state,
wherein it performs address translation and attribute checking if the MSEN
and TRNS bits are both 1 's, the URS bit is the same as the SN6 input, and
the MST bit is 0 or the MST bit is 1 and the NMS bit is the same as the N /S
input. For all other memory transactions, the MMU is in the quiescent state.
In multiple MMU systems, a given memory transaction should cause only one
MMU in the system to enter the memory management state, with all other
MMUs remaining in the quiescent state.
The segment address register (SAR) is a pointer into the table of 64
segment descriptor registers. Bits 6 and 7 of the SAR are not used (Fig.
9.12). Commands to the MMU that access the segment descriptor registers
use the SAR to select one of the 64 descriptors.
The descriptor selection counter register (DSC) points to one of four
bytes in a segment descriptor register during accesses to the descriptors. Only
bits 0 and 1 of the DSC are used (Fig. 9.13). A value of 00 (binary) in the
DSC indicates the high byte of the descriptor's base address field, a 01 in the
DSC indicates the low byte of the base address field, a 10 indicates the limit
field, and an 11 indicates the attribute field.
Commands to the MMU can read or write only one byte at a time, since
the MMU is connected to only one half of the address/data bus. Together,
the SAR and nsc point to one byte in the table of 64 segment descriptor
registers. For example, if the SAR and DSC are both 0 and the URS bit in the
mode register is aI, the selected byte is the high-order byte in the base address
for segment 64. The SAR and nsc are automatically incremented for several
MMU commands, allowing the descriptor registers to be accessed as a block
using the Z8001 's automatically repeating special I/O instructions.
ADDRESS TRANSLATION
When the MMU enters the memory management state, two operations occur
simultaneously: the logical address is translated to a physical address and the
status information for the memory access is compared to the segment's attri-
butes in the appropriate segment descriptor register.
The address translation process involves using the segment number in
the logical address to select one of 64 segment descriptor registers in the MMU.
Address Translation 169
15
LOGICAL ADDRESS
1.------- ----,
I ~!~2~~MENT r---~-......, I
I UNIT BASE I
I ~ggl~~~~ I
I FILE I
I I
I I
I I
I I
I
I
I
I
I
I
I
I
L ______ _ Figure 9.14 Address translation in
the MMU.
The contents of the chosen descriptor register's base address field determines
the starting address in physical memory for that segment. The MMU's SNO-
SN5 segment number inputs are used as a pointer into the bank of segment
descriptor registers to select one segment descriptor. (SN6 is used
in conjunction with the URS bit in the mode register to select the MMU, as
described previously.) The high-order byte of the offset address (emitted by
the CPU on AD8-AD15) is then added to the base address in the selected seg-
ment descriptor register to yield physical address bits A8-A23. This result is
concatenated to the low-order byte of the logical offset address to form the
24-bit physical address (Fig. 9.14). The low-order byte of the offset address
is not processed by the MMU.
This address translation process is equivalent to adding the offset por-
tion of the logical address to the starting physical address of the segment (Fig.
9.15). The eight least significant bits of the base address for each segment are
6 0 15 6 0 15 K 7 0
0 \1 I
5 !
2 !
8 I 0 [~~
\ \
\ \
8 7 0 2J 8
\ \
23
\
I 2 ! 3 ! 1 !
1 I ~ -~ ~
_..l_..J ~~
\
I I
I I
+ + I I
2.1 0 11 --:-17 of
I 2 !
3 !
2 !
6 ! 2 I 8 I ~~~ Figure 9.15 Example of address
(a) FULL ADDITION (b) ADDITION OF HIGH ORDER
BVTES ONLY translation process illustrated in two
NOTES: BASE ADDRESS FOR SEGMENT 5 IS 231100 ways.
170 The Z8010 Memory Management Unit Chap. 9
assumed to be all O's and are not stored in the segment descriptor registers.
Thus the low-order byte of the physical address is always the same as the low-
order byte of the offset portion of the corresponding logical address.
While the address translation process is occurring, the MMU also compares
the attributes in the selected segment descriptor register with the status sig-
nals from the CPU. If a violation occurs, such as an attempted write to a
segment with the read-only attribute, an active segmentation trap and/or
suppress signal is output by the MMU. Furthermore, the offset portion of
the logical address is compared to the limit field in the segment's descriptor
register and a trap and suppress is generated if the access violates the limits
of the segment. The translated physical address is output regardless of whether
or not a violation is detected.
The MMU will generate a segmentation trap request to the CPU by pul-
ling its SEGT output low for one of two reasons: detection of an access
violation or detection of a write warning in a segment whose DIR W bit is set.
In the event of an access violation, the MMU's suppress (SUP) output is
pulled low also; this signal can be used as part of the memory control logic
to inhibit the memory transaction, thereby preserving the integrity of mem-
ory contents during illegal accesses.
When the MMU detects an access violation or write warning, it stores
status information about the transaction in six 8-bit status registers. These
registers can be read by the CPU when servicing segmentation traps to deter-
mine the cause of the trap. Five registers indicate the memory address, bus
status, and current instruction being executed when the violation occurred.
The sixth status register, the violation-type register (VTR), contains eight
flags that describe the violation type (Fig. 9.16).
Five flags in the VTR signal violations during memory accesses. Bit 0
of the VTR is the read-only violation (RDV) flag. The RDV flag is set if a
write is attempted to a segment having the read-only attribute. Bit 1 is the
system violation (SYSV) flag and is set if a normal-mode program attempts
to access a segment with the system-only attribute. Bit 2 of the VTR, the
segment-length violation (SLV) flag, is set when an attempt is made to access
a location outside the legal limits of the segment. This violation is detected
by comparing the offset in the logical address to the limit field of the seg-
ment descriptor register. Bit 3 is the CPU-inhibit violation (CPUIV) flag
and is set if the CPU attempts to access a segment whose CPU-inhibit bit is
set. Bit 4 of the VTR is the execute-only violation (EXCV) flag; this flag
7 0
UPPER OFFSET
~~~~--~~~~~
I VIOLATION
OFFSET
7 0
Figure 9.17 Violation segment num-
ber and violation offset registers.
172 The Z8010 Memory Management Unit Chap. 9
CPU STATUS
Figure 9.18 Bus cycle status regis-
! !
ter.
UPPER OFFSET
~~~~!--~!~!~~~~ I INSTRUCTION
OFFSET
7 0
Figure 9.19 Instruction offset and
instruction segment number regis-
ters.
in the instruction's opcode that was being accessed; otherwise, they hold the
logical address of the data item that was being accessed.
The bus cycle status register holds the bus status information at the
time of the violation or write warning, including the state of the STO-ST3
status lines, the RjW line, and the Nj8 line (Fig. 9.18).
The last two status registers hold the logical address of the first word of
the last instruction fetched before the violation or write warning occurred.
The instruction segment number register holds the segment number and the
instruction offset register holds the upper byte of the offset address (Fig.
9.19). External circuitry is required if the lower byte of the offset is to be
saved. If the violation occurred while fetching the first word of an instruc-
tion, these two registers would hold the first word of the previous instruc-
tion. Otherwise, these registers will contain the logical address of the first
word of the instruction that specified the access that caused the violation.
Status information is stored in the six status registers only for viola-
tions or write warnings resulting from an attempted memory access by the
CPU. Violations that occur while a DMA device accesses memory will cause
SUP to be asserted, but no trap is generated and the status registers are not
altered. Thus if DMA and CPU operations are interleaved and a DMA trans-
action causes a violation while the CPU is executing a segmentation trap ser-
vice routine, the MMU's status registers retain the status information being
used by the CPU's service routine.
The MMU responds to violations and write warnings with two different out-
put signals: segmentation trap (SEGT) and suppress (SUP). An active SEGT
signal causes the CPU to service a segmentation trap. The SUP signal is used
to block illegal memory accesses; for example, SUP can be used to gate the
DS signal to memory so that accesses attempted while SUP is low will not be
completed. SUP also can be used to trigger external hardware that saves the
low-order byte of the offset address for the access that caused the violation.
Both SEGT and SUP are open-drain signals; the SEGT and SUP outputs from
Traps and Suppresses 173
CPU DMA
several different MMUs can be tied together to form one signal to the CPU or
memory control logic.
An MMU activates the SEGT and/or SUP outputs depending on the de-
vice that is making the access and the type of violation that occurred, as out-
lined in Table 9.1. Suppress is not asserted during write warnings, since
write warnings only indicate a potential stack overflow problem in the fu-
ture, not an illegal access now. DMA-generated memory accesses do not
generate segmentation traps, since traps interrupt the CPU and not the DMA
controller. DMA write warnings are not signaled at all; DMA devices rarely
access memory segments that are being used as stacks.
The SEGT and SUP signals both are asserted during T2 of the memory
access cycle, if appropriate (Fig. 9.20). The SEGT signal stays low until a
segmentation trap acknowledge signal is detected on the STO-ST3 status
lines. SUP is asserted throughout the data transfer portion of the transac-
tion that caused the violation and for all subsequent CPU memory accesses
until the end of the current instruction. Intervening DMA transactions will
not be suppressed, however, unless they also generate a violation. Violations
during DMA transactions cause SUP to be active only during that transaction.
If the F ATL flag in the MMU's VTR is set, indicating that a violation
was detected before a previous violation was processed, SEGT will not be
asserted for subsequent violations until F ATL is reset; SUP, however, is gen-
erated for each violation even if F ATL is set.
If the SWW (secondary write warning) flag in the VTR is set, subse-
quent write warnings while accessing system stack memory do not generate
an active SEGT signal. This prevents the system from repeated interruptions
while trying to process the initial write warning.
MMU COMMANDS
The CPU can access the MMU's registers via special I/O instructions. When
an MMU detects special I/O status on the STO-ST3 status lines and the
MMU's chip-select (CS) input is active, it accepts and processes a command.
These commands allow the CPU to read all MMU registers, write to the seg-
ment descriptor, mode, segment address, and descriptor selection counter
registers, or reset the violation-type register. Data read from or written to
the MMU are transferred one byte at a time on the AD8-AD15 bus lines.
When a special I/O instruction is used to send a command to the MMU,
the MMU interprets the high-order byte of the port address output by the
CPU during T1 of the I/O machine cycle as a command opcode. The low-
order byte of the special I/O port address can be decoded to generate the
chip-select signals to the system's MMUs (Fig. 9.21). The MMU's CS input is
MMU Commands 175
. - - - - - - . JA,L---::--___-.J~\ cs
K AD1-AD7 ) DECODE
"'-..r----'V/
L...r-r-T,......
'------10.-. cs
A 11.
Z8001 K ADa-AD15
r--r--r----'r/
) ADa-AD15
'I
Z8010
#1
'-----I
..... cs
) ADa-AD15
r-r----,yl
Z8010
#2
-
'-------1~... CS
I ADa-AD15
'-------,yl
Z8010
#n Figure 9.21 Decoding address lines
to generate chip selects for MMUs.
used only to send commands to the MMU and is not involved in the MMU's
address translation process during memory accesses. Any data associated
with the MMU command are transferred between the CPU and MMU during
T3 of the I/O cycle, just as if the CPU were talking to a peripheral device.
In other words, the upper byte of the special I/O address is the MMU com-
mand opcode that enters the MMU on AD8-AD15. The chip-select signal to
the appropriate MMU or MMUs is generated from the low-order byte of the
I/O address (Fig. 9.22). ADO must be 0, since any byte data transfer for the
command occurs on the upper half of the address/data bus (see Chapter 4).
Thus ADI-AD7 are decoded to generate CS signals to the MMUs.
For systems with seven or fewer MMUs, the simplest encoding method
is to assign ADi (i = 1 to 7) as the chip select for MMU #i (Fig. 9.23). With
this scheme, more than one MMU can be selected to receive a given com-
mand. This configuration is assumed in subsequent programming examples
in this chapter.
Table 9.2 lists all the MMU commands. These commands fall into two
basic categories: read/write commands and set/reset commands.
The read/write MMU commands are used to read or write the MMU's
internal registers. Special input instructions are used to read MMU register
15 8 7
Figure 9.22 Format of a special
I/O address used as an MMU com-
I !
OPCODE
! ! ! mand.
176 The Z801 0 Memory Management Unit Chap. 9
Opcode Operation
Read/Write commands
Segment descriptor registers
08 Read/Write Base Field in Descriptor
09 Read/Write Limit Field in Descriptor
OA Read/Write Attribute Field in Descriptor
OB Read/Write Descriptor (all fields)
OC Read/Write Base Field and Increment SAR
OD Read/Write Limit Field and Increment SAR
OE Read/Write Attribute Field and Increment SAR
OF Read/Write Descriptor and Increment SAR
Control registers
00 Read/Write Mode Register
01 Read/Write Segment Address Register
20 Read/Write Descriptor Selector Counter Register
Status registers
02 Read Violation Type Register
03 Read Violation Segment Number Register
04 Read Violation Offset (high-byte) Register
05 Read Bus Cycle Status Register
06 Read Instruction Segment Number Register
07 Read Instruction Offset (high-byte) Register
Set/Reset commands
Segment descriptor registers
15 Set All CPU -Inhi bi t Flags
16 Set All DMA-Inhibit Flags
Violation status registers
11 Reset Violation Type Register
13 Reset SWW Flag in VTR
14 Reset FATL Flag in VTR
Reserved
10 Not assigned
12 Not assigned
17-1F Not assigned
21-FF Not assigned
contents to the CPU; special output instructions are used to write into MMU
registers from the CPU. The mode register, segment address register, descrip-
tor selection counter register, and all the segment descriptor registers can be
read or written with these commands. The status registers can be read only.
For example, the instruction
will load the contents of CPU register RHO into the mode register of the
MMU that is chip selected when ADI is low (MMU #1 in Fig. 9.22). Several
of these instructions automatically increment the SAR and DSC pointers
MMU Commands 177
A ADO-AD7 >}
tI.
Z8001
CPU
f:L-_--'--_..-.--JL.----'._---l.-C-...I:\1 TO Z-BUS
AD8-AD15 ~ MMU
1....-_ _ _.... " A_D1_ + - - l _ - - I C S #1
L-
MMU
V
'---_ _ _AD_7_ _ _ _-tCS #7
Figure 9.23 Simple chip select en-
coding for seven MMUs.
into the bank of segment descriptor registers, allowing use of repeating block
move special I/O instructions to fill the 64 descriptors. For example, the
Read/Write Descriptor and Increment SAR command (opcode %OF) accesses
the four bytes of a descriptor register and then increments the SAR to point
to the next descriptor. If the data to be loaded into all 64 descriptor regis-
ters in an MMU are stored in memory as shown in Fig. 9.24, the descriptors
could be initialized in the MMU with the following code:
CLR RO
SOUTB %01 FC, RHO I clear the SAR in MMU #1 !
LDA RR4, DESCRIPTORS ! segmented mode; DESCRIPTORS is symbolic name
for starting address of table in memory!
LD RO, #256 ! count register!
LD R1, #%OFFC ! I/O port address is MMU command to load de-
scriptors of MMU #1 I
SOTIRB @R1, @RR4, RO I Load all descriptors in MMU #1 !
Note that the six status registers are read-only, with the exception of the
VTR, which can be reset.
The set/reset commands are used to set or reset certain fields in MMU
registers. For these commands, special output instructions are used, and no
data are transferred:
LOW ADDRESS
LOCATION BASE ADDRESS
DESCRIPTORS - HIGH BYTE
BASE ADDRESS
LOW BYTE DESCRIPTOR 0
LIMIT
ATTRIBUTES
BASE ADDRESS
HIGH BYTE
BASE ADDRESS
LOW BYTE DESCRIPTOR 63
The destination address is the MMU command word, and the source can be
any arbitrary CPU register. The contents of the source register are placed
onto the bus during T3 of the I/O cycle but are ignored by the MMU.
RESETS
The Z8010 MMU is reset by pulling its RESET input low. A reset clears the
mode, descriptor selection counter, and violation-type registers. The con-
tents of all other registers are undefined after a reset. If CS is high while
RESET is asserted, the master enable flag (MSEN) in the mode register is
cleared and the MMU is disabled. The address outputs are tri-stated and the
SUP and SEGT open-drain outputs are not driven. To enable the MMU, the
CPU must write to the mode register and set the MSEN bit.
If CS is low while RESET is asserted, the MSEN bit in the mode regis-
ter is set and the translate bit (TRNS) is cleared, thereby enabling the MMU
but putting it in the transparent mode. The logical address inputs are passed
directly through to the physical address outputs without translation. One
MMU in a system should be reset in this manner so the CPU can access mem-
ory and execute an initialization routine. The initialization routine would be
in absolute memory locations in memory (that is, the initialization routine is
not relocatable). The initialization routine should include commands to pro-
gram the system's MMUs.
Z BUS
16
~" ........
RESET 24
-~- 16 ADo-AD15 8 ADa-AD15 BAa-BS15
BUSACK
7 SNo-SNs
Z8001
CPU 4 STo-ST3
4 I CNTL
r-- SEGT
BUSREQ
8 ADo-AD7 -;:z BAo-BA7
I
BRQ
16 ADo-~AD15 BAa ~BA15
BAI
7 SNo-SNs
8 ADa-AD15
Z8016 Z8010
DMA 4 STo-ST3
7 SNo-SNs MMU
16
K BA16-BA23
4 CNTL #1
EOP 4 STo-ST3
r - - MMU SYNC
~
4 CNTL
SUP
-
RESET -- CS
RESET
DMASYNC
SEGT I--
I'
8 ADa-AD15
f Z8010 16
7 SNo-SNa MMU
4 , STo-ST3
#2 ~-
4 CNTL
SUP
AD2
CS
RESET
SEGT
-
DMASYNC
During a memory access, the Z8001 CPU outputs the segment-number por-
tion of the logical address early in the machine cycle. (In fact, the segment
number is emitted during the last timing state of the preceding cycle, as dis-
cussed in Chapter 5.) This allows the MMU to use the segment number to
select the appropriate segment descriptor register before the offset portion
of the address is available. Later, in T1 of the memory access cycle, the CPU
outputs the offset address. The MMU adds the upper byte of this offset to
the base address in the segment descriptor register to yield the physical ad-
dress while checking the status lines with the segment's assigned attributes.
This addition process does take some time, of course, so there is some delay
between when the CPU issues the logical offset address and the MMU out-
puts a valid physical address. This delay shortens the memory access time
for the transaction. Furthermore, the rising edge of AS from the CPU no
longer indicates a valid physical memory address; a "delayed" address strobe
may be needed to indicate a valid address at the memory control logic and
the hardware to generate this delayed address strobe added to the system.
When a system has a physical memory address space that is smaller than its
logical address space it is called a virtual memory system. In a virtual mem-
ory system, operating system software, memory management hardware, and
a secondary storage device, such as a disk, are used to make physically ad-
dressable memory appear larger than it really is for users' programs. All the
segments for a particular users' program might not fit into memory at any
one time. Segments that are "missing" in memory are so marked in the
memory manager; for the Z8010 MMU, the CPU-inhibit flag could be used.
MMUs and Virtual Memories 181
A reference to such a segment would cause a trap; the trap service routine
would move the "missing" segment from the disk to memory, swapping out
some segment already in memory by writing it to the disk. The MMU is re-
programmed to reflect this change, and the users' program is restarted at
the instruction that caused the trap. All of this memory manipulation would
be transparent to the user executing an applications program; thus the sys-
tem would appear to each user as having a physical memory address space as
large as the logical address space.
In a virtual memory system, the operating system must keep track of
which segments have been used, how often, and in what way. A segment
that has not been referenced at all since last being loaded into memory is a
likely candidate for removal from physical memory when another segment
must be swapped into memory from the disk. The most frequently accessed
segments should be kept in memory at all times if possible. The REF and
CHG flags in the MMU's segment descriptor registers can aid in this process.
However, the Z8001-Z8010 combination does not completely support
virtual memory implementations. If the Z8001 references a segment that
does not exist in physical memory, the MMU will respond with active SEGT
and SUP signals. In the case of a memory write, the SUP signal can be used
to block the memory access, thereby protecting the integrity of memory
contents. However, the Z8001 will complete the execution of the current
instruction before recognizing the segmentation trap request. The critical
case occurs when the CPU is executing an arithmetic or logical instruction
where the source is in memory but the destination is a CPU register, such as
where DATA is the symbolic name for some memory location. If the fetch
to the location called DATA causes an MMU violation and trap request, the
instruction will be completed before the trap is recognized and processed.
Even though a suppress is sent to .memory, the CPU will read something on
the bus during T3 of the data memory access and add whatever is read to the
contents of register RO. Thus the contents of CPU registers can be corrupted.
However, true virtual memory systems can be implemented with the
Z8001 and Z8010 by adding additional hardware to the system. This extra
hardware would need to force a predetermined value on the bus whenever an
MMU violation occurs, as indicated by the SUP signal. The value placed on
the bus would depend on the type of instruction being executed. For ex-
ample, if all O's were forced on the bus during the data fetch for the ADD in-
struction described above, the contents of RO would not be corrupted, and
the service routine could force a restart at that instruction after making the
appropriate changes to physical memory and the disk. In the case of a viola-
tion during an IF1 cycle, the extra logic could force the opcode for a NOP
instruction onto the bus.
182 The Z80l 0 Memory Management Unit Chap. 9
Additions can be made to the basic instruction set of the Z8000 micropro-
cessors through the use of Extended Processor Units (EPUs). An Extended
Processor Unit is an LSI device dedicated to performing complex, time-con-
suming tasks in order to unburden the CPU. Typical tasks suited for imple-
mentation in EPUs include floating-point arithmetic, data base management,
graphics support, networking, and communications interfaces-in short, any
computing task that might be performed in dedicated hardware. Up to four
EPUs can be included in a Z8000-based system.
EPUs perform their tasks on data resident in their internal registers.
The CPU is responsible for moving data into and out of the EPUs and for in-
structing the EPUs as to what operations are to be performed. Special in-
structions called extended instructions are processed by the EPUs; when the
CPU encounters an extended instruction it performs any specified data trans-
actions, but otherwise assumes that the instruction will be recognized and
handled by an EPU. Thus by adding EPUs to a system, the instruction set is
expanded to include the extended instructions applicable to the EPUs used,
thereby boosting the processing power of the whole system.
183
184 Exte'1,ded Prqcessor l..}pits Chap. 10
STOP LINE
DEDICATED DEDICATED
EPU Z8000 EPU
MEMORY CPU MEMORY
PERIPHERAL PERIPHERAL
MEMORY
EXTENDED INSTRUCTIONS
Instructions with an opcode whose first word has an upper byte of OE, OF,
4E, 4F, BE, or 8F (hexadecimal) are extended instructions reserved for use
by an EPU. All extended instru,ctipns have opcodes that are two words long.
Extended Instructions 185
If the EPA bit in the CPU's flag and control word (FCW) is a 1 and an ex-
tended instruction opcode is encountered, the CPU will assume that there
are EPUs in the system and treat the instruction accordingly, as described
below. If the EPA bit in the FCW is 0, indicating that there are no EPUs in
the system, encountering an extended instruction opcode will cause an ex-
tended instruction trap. If desired, the action of an EPU can be simulated in
software in the extended instruction trap service routine. This software trap
mechanism facilitates the design of systems in which EPUs are not present
initially but may be added later. The "extended" function is included in the
operating system software as the extended instruction trap service routine;
this routine can be deleted when the EPU is added to the system and the
EPA bit set to a 1. This change would be transparent to users' applications
executing on the system.
If EPUs are present in the system and the EPA bit in the CPU is a 1, the
CPU is responsible for delivering instructions and data to the EPUs. There
are four kinds of extended instructions: instructions that transfer data be-
tween an EPU and memory, instructions that transfer data between an EPU
and the CPU, instructions that transfer status information between an EPU
and the CPU's flag and control word, and instructions that specify internal
operations in an EPU.
In order to determine which transactions to participate in, an EPU must
monitor the address/data bus and its associated status and control signals.
When the CPU fetches the first word of an instruction, as indicated by IF1
status on the STO-ST3 lines, each EPU examines the instruction's opcode.
If an extended instruction is found, each EPU checks a 2-bit identification
field in the opcode to see if the instruction is intended for that particular
EPU. Thus up to four EPUs can be interfaced to a single CPU. The EPU
selected must also capture the second word of the extended instruction's op-
code; the fetch of the second word of the opcode is the next nonrefresh CPU
transaction. From this two-word opcode, the EPU determines if it will parti-
cipate in any subsequent data transactions and, if so, how many transactions
are involved.
If the extended instruction calls for a data transfer between an EPU and
memory, the CPU supplies the address, status, and control information for
each transfer. During the memory accesses, the CPU will tri-state its ADO-
AD15 lines while DS is low, so that the EPU can send or receive data on the
bus. The CPU can use the indirect register, direct address, or indexed ad-
dressing modes to calculate the memory addresses for the transactions, as
specified by the instruction. The EPU must supply the data (if the R/W line
is low, indicating a memory write) or capture the data (if the R/W line is
high, indicating a memory read) just as if it were part of the CPU. EPU-to-
memory data transactions are always word transfers (B/W is low). Up to 16
words can be transferred between an EPU and memory as the result of a
single extended instruction, as specified in the instruction's opcode.
186 Extended Processor Units Chap. 10
If the instruction involves a data transfer between the EPU and the
CPU's general-purpose registers, the CPU controls the transaction and a 1110
code (CPU-EPU transfer status) is emitted on the STO-ST3 lines. The timing
of the transaction is identical to a three-clock-cycle memory access, except
that no address is emitted by the CPU. CPU-EPU transactions are always
word transfers; up to 16 words can be transferred as a result of an extended
instruction.
Similarly, status information can be transferred between an EPU and
the lower byte of the CPU's FCW (the CPU flags). CPU-EPU status transfers
are always byte transfers and occur on the ADO-AD7 bus lines. The con-
tents of CPU register RO are destroyed during this transaction. This type of
transaction is useful when the program must branch on the results of an EPU
operation.
Extended instructions can also specify internal operations for EPUs,
wherein the EPU operates on data in its internal registers. No data trans-
actions are involved in the execution of such an instruction. The CPU can
continue to fetch and execute subsequent instructions while the EPU is in-
volved with an internal operation. Thus processing can proceed simulta-
neously in both the CPU and the EPUs. If a second extended instruction for
a particular EPU is fetched before an earlier instruction for that EPU has
completed execution, the EPU must activate the STOP line, stopping the
CPU. The EPU releases the STOP signal when it completes execution of the
first instruction, and execution proceeds as if the CPU were not temporarily
halted. The STOP line provides synchronization between the CPU and the
EPUs, preventing EPUs from missing instructions because they were busy
executing earlier instructions. Of course, all the EPUs in a system may be
executing their own internal operations simultaneously.
In order to monitor instruction fetches and participate in data trans-
fers, the EPUs must also monitor the BUSACK CPU output to verify that
transactions are initiated by the CPU. EPUs will ignore all bus transactions
while BUSACK is low.
Thus EPU instructions are processed "in-line" with Z8000 instructions,
providing parallel processing capability while eliminating the system software
and bus contention problems inherent in other multiprocessor and co-proces-
sor schemes, such as master-slave arrangements. The processing power of a
Z8000-based system can be extended in an upward-compatible manner by
the addition of EPUs.
STOP TIMING
The STOP input to the CPU is used to synchronize EPU and CPU execution,
as described above. A low level on the STOP input forces the CPU into a
state wherein it continuously executes refresh machine cycles. The STOP in-
I
~
~
",,,,
u.O
wO
"'«
cil
s::
:§-+->
:!:
I~
":;: C\1
c:;)
~
~
~
~
0..
Q
I~ l:g I~ I~
Ii ~
~
II)
ill ;;:
I~
187
188 Extended Processor Units Chap. 10
put is sampled by the CPU on the falling edge of the clock in the clock
period preceding an IF1 cycle, as shown in Fig. 10.2. If STOP is low, a
continuous stream of refresh cycles is entered after T3 of the instruction
fetch. During each of the refresh cycles, STOP is sampled again on the falling
edge of the clock in the middle of T3. When STOP is found to be high, one
more refresh cycle is executed and then any remaining T states in the IF1
cycle are completed. From there, execution proceeds normally. Bus re-
quests are honored while STOP is active.
If the EPA bit in the CPU's FCW is set, the STOP input also is sampled
on the falling edge of the clock preceding the fetch of the second word of an
extended instruction. (The CPU recognizes that it is processing an extended
instruction after the first word of the instruction is fetched.) Thus the STOP
line can be activated by an EPU if the CPU fetches an extended instruction
for that EPU before the EPU has finished processing an earlier extended
instruction.
The continuous refresh operation while STOP is low does not use the
rate counter in the CPU's refresh register. The row counter is incremented
by two after each refresh cycle. Thus refreshes do not occur on demand;
instead, a new refresh is emitted every three clock cycles. Therefore, higher-
than-normal heat dissipation may occur in dynamic memories while STOP is
low. Long and frequent stops can be avoided by writing program code so
that extended instructions for a given EPU are not closely spaced.
STOP
>-----.----i 0 al------~D a
AS
AS
STOP
CLOCK - - - - - - '
I--T-'-.;"",;H~
Figure 10.3 Z8000 single-step circuit using the STOP input.
Stop Timing 189
CLOCK GENERATION
The Z8001 and Z8002 require a continuously running clock with a fre-
quency between 500 kHz and 4 MHz; the Z8001A and Z8002A require a
190
WAIT
1
WAIT
LAo,LA,s
DECODER
2K x 8
ROMs rV RAS
CAS 16K DYNAMIC
RAMs
OR
EPROMs (32K BYTES)
,IT
LA'2- LA
LA,- LA 11
.. (4K 10 32K BYTES)
--y
~,~:~ II
LA,-LA'4
iii -]
WAIT
A ....
16-BIT BIDIRECTIONAL DATA BUS
1/0
DECODER
il rc-l..H,.
4_
• ODD PORTS
STATUS
DECODER
,
Z80A PERIPHERALS
WITH DAISY-CHAINED INTERRUPT PRIORITY
INTERRUPT
r
iCiCniC tll!l!t r u-
+5V ---J\,f\I\r-_---.--~-___1I..-.-...._-___,
ENT ENP A B C 0
CARRY OUT
9316 OR
74161
ClK [0
Os
3.9-MHz CLOCK
74lS74
o °
' - - - - - - - - - 1 > 0 - - - - - 1 1 : > ClK
19.6608·MHz CLOCK
Q a (COUNTER)
Q FF (FLlP.FLOP)
L
Figure 11.2 Generation of a 3.9-MHz clock from a 19.6608-MHz oscil-
lator.
clock frequency between 500 kHz and 6 MHz. Most Z8000 applications call
for a high-performance system with a clock frequency approaching the
maximum limit. Clocks usually are generated by dividing the output of a
crystal oscillator using flip-flops (as in Fig. 1.14) and/or TTL counter chips.
For example, a divide-by-5 circuit can be used to generate a 3.93-MHz clock
from a 19.6608-MHz crystal, as illustrated in Fig. 11.2. (19.6608 MHz is a
frequency commonly used to generate baud clocks for serial channels.) The
Z8000 CPU's clock input is not TTL compatible because of its level, rise-
time, and fall-time requirements. An active driver circuit such as the one il-
lustrated in Fig. 1.14 is required for the CPU clock.
As with most MOS devices, the Z8000 CPU outputs have limited drive capa-
bility. The Z8000 microprocessors sink a maximum of 2.0 rnA for output
signals and source a maximum of 250 J.1A for input signals while maintain-
ing standard TTL levels (0.4 V maximum for a logical 0, 2.4 V minimum for
CPU Bus Buffering 193
a logical 1). Thus a Z8000 CPU output can drive only one standard TTL
load or five LS-TTL loads. Output delays are specified for a 50-pF load and
increase by approximately 0.1 ns/pf for additional capacitive loading. Since
the address/data bus and its control and status signals usually are propagated
to several memory and I/O control devices, all but the simplest of systems re-
quire buffering of the CPU outputs.
The 16 address/data bus signals are bidirectional. Address and data in-
formation are CPU outpllts during write operations; addresses are CPU out-
puts and data are CPU inputs during read operations. Thus buffers for the
address/data bus must be bidirectional. Two approaches are possible: have
the buffers for the bus point away from the CPU as a default (that is, treat
the CPU pins as outputs and drive the system bus with the buffer), with the
buffer direction reversed (that is, pointing toward the CPU) only during data
reads, or have the buffers point toward the CPU as a default and drive the
system bus only when the CPU outputs addresses and during data writes.
The first choice, with the buffers pointing away from the CPU as a default,
is preferable for two reasons. First, the CPU pins will not have to sink cur-
rent from the buffer as often, since the buffer will normally treat the CPU
pins as outputs, thereby minimizing heat dissipation in the CPU. Second,
possible bus contention problems when using an in-circuit emulation device
for system debug will be avoided. (Bus contention problems occur when
both the emulation hardware and target system's bus buffers are simulta-
neously driving the address/data bus lines to the CPU.) Thus the bidirec-
tional driver for the address/data bus should drive the CPU signals onto the
system's bus except during data reads, as indicated by a high on the R/W pin
and an active DS signal.
If bus sharing is allowed in the system, the CPU must relinquish control
of the bus when a bus request is made. The bus buffer must provide for
other devices, such as a DMA controller, driving the address/data bus when-
ever BUSACK is low. Therefore, a bus buffer whose outputs can be tri-
stated is required.
Possible choices for address/data bus buffering include the SN74LS243
Quad Non-Inverting Transceiver (Fig. 11.3) and the SN74LS245 Octal Non-
Inverting Transceiver (Fig. 11.4). The transceivers are controlled by the
AD O-AD 15 (TO/FROM CPU)
55
888
R/W-----I
E2
LS243
BUSACK------~------~~
os---l> DR
H H L Enable Receiver
(input Data into CPU)
H H H
Enable Transmitter
H L H
(output Address or Data from CPU)
H L L
L X X Disable Transceiver
AS
os R/W
MREQ N/S B/iN
INTERNAL OPERATION
MEMORY REFRESH
1/0 REQUEST
'"OM
CPU I STo
ST1
ST2
ST3
Ao
A1
A2
A3
LS42
SPECIAL 1/0
RESERVED
NMI
NVI
j'N","""
ACKNOWLEDGE
VI
DATA
} MEMORY
STACK ACCESS
The STO-ST3 status lines typically drive only one circuit-a decoder
that generates the status signals for memory and I/O accesses. A 4-to-16
decoder such as the SN74154 or two 3-to-8 decoders such as the SN74LS138
can be used to decode all 16 possible status conditions. For simple systems
without EPUs, only the first 10 status codes need to be decoded. An SN74-
LS42 l-of-l0 decoder can be used, as in Fig. 11.6. If none of the SN74LS42
decoder outputs are active during a transaction, a program memory access is
assumed.
If bus sharing is allowed, the STO-ST3 status signals may originate
from devices other than the CPU. Several decoding schemes are possible.
For example, entirely separate decoders might be used for CPU and DMA
operations, and the BUSACK signal used to enable the appropriate decoder.
Alternatively, the STO-ST3 status signals from the CPU can be driven by a
tri-state buffer that is disabled when BUSACK is active, allowing DMA
devices to control those status lines before they are decoded.
The remaining CPU outputs, BUSACK and MO, need to be buffered if
they are to drive more than one TTL load. Any unidirectional driver is ade-
quate. For the Z8001, the segment number outputs require a unidirectional
driver that can be tri-stated when BUSACK is low.
ADDRESS LATCHING
AS-I> LE
LS373 LS373
for memory and I/O controllers. Transparent latches that propagate their in-
puts to their outputs when the control signal is low but hold the outputs
fixed when the control signal goes high are a better choice. The rising edge
of AS could then still be used to signal valid address information at the mem-
ory and I/O controllers themselves.
Figure 11.7 shows two SN74LS373 Octal Transparent Latches used for
address latching. Depending on the system configuration, these latches
might be tri-stated when BUSACK goes low. The latched address (LAO-
LA15) is propagated to all memory and I/O control logic.
MEMORY INTERFACING
LA 8 1 9 2 10 3 11 4 12 5 13 6 14 7
CLOCK
clock after MREQ is active). The second seven address lines are routed to
the memory inputs at the same time. During writes, CAS is delayed until DS
goes low, guaranteeing that the data to be output are valid before CAS is
active. The SN7 4LS7 4 Flip-Flop stretches CAS during write operations, as
required by slower memories. The timing of RAS and CAS for read and
write operations using this circuit is illustrated in Fig. 11.10. CAS is gener-
ated only during memory accesses (that is, only when MREQ is active).
PERIPHERAL INTERFACING
....
T1
.. .. T2
.. .. . ..
T3
...
CLO CK
- I I l
STATUS
(B/W , N/5,
5To -5T3)
-
AS
M --
REQ
DS READ \ \ WRITE
RAS
Q2
/
MU x-S
\ /
CAS READ\ \WRIT~ V
I I
Figure 11.10 Timing of the RAS and CAS signals for dynamic RAM memory ac-
cesses.
AO A15
WAIT
1.. _ _ _ _ _ _
DBO DB7~~--------+-----~
CLOCK
AO A7
lORD
RD
} Read
Cycle
DATA BUS
WAIT
=,..---c~
WR
} Write
Cycle
DATA BUS OUT
CLOCK
INT
AO - A15
MI
MREO
lOAD
DATA BUS
AD
200
Peripheral I nterfaci ng 201
+5V
YO CEO
G2A Yl CEl
G2B Y2 CE2
LS138
C Y3 CE3
LA4 ---------+-----+-f Y4
LS08
sw
RETI
lA3 ---------+-----+-f A Y5
Mi
TO
Z80A
PERIPHERALS
LS32
os
lORa'
AS
LAs
+5V
FROM
Z8000
BUS lS08
lS10
PRE
AD
lORa a a
LS74 LS74 LS32
CLOCK CLK Q ClK Q
CLR CLR
Riw
VIACK
CLOCK
AOO-AD1!1~
AS ~
\~ ______r
DS
\_____1
R/W
____I
___...J/
Q11LS741
'--
'--
\~----~/
\ /
\~--------------~/
I/O Read
R/W
\
CE
\ r-
iORG'
\ r-
RD
I/0Wrile
addressed when LA5 is low in this example.) The timing diagram for Z80
peripheral reads and writes using this circuit is illustrated in Fig. 11.13.
Some additional logic is needed to make the Z80 peripherals compat-
ible with the Z8000 interrupt structure. The interrupt outputs from the
Peripheral I nterfaci ng 203
peripherals are used to drive a Z8000 CPU interrupt request line; priority
among the peripherals is determined by an lEI-lEO hardware daisy chain
similar to that of Z8000 peripherals. The Z80 CPU has no dedicated inter-
rupt acknowledge output. Z80 peripherals are acknowledged when 10RQ is
active during an M1 cycle (Fig. 11.11).
The circuit of Fig. 11.12 generates the M1, 10RQ', and RD signals re-
quired by the Z80 peripherals during an interrupt acknowledge cycle. VIACK
is the appropriate interrupt acknowledge signal from the STO-ST3 status
decoder. A timing diagram for the acknowledge cycle using this circuit is
given in Fig. 11.14.
At the end of the service routine for an interrupt generated by a Z80
peripheral, the interrupt-under-service flag in the peripheral must be reset.
The Z80 CPU's interrupt return instruction (RETI) has an opcode of ED4D
(hex); a Z80 fetch of this instruction takes two consecutive instruction fetch
cycles. A Z80 peripheral will monitor the data bus while under service and
recognize when the RETI instruction is fetched from memory. When the
"ED4D" code is sensed, the interrupt-under-service latch in the peripheral is
reset.
In a Z8000 system with Z80 peripherals, the Z80's RETI instruction
fetch sequence must be simulated at the end of the peripheral's service rou-
tine with a combination of hardware and software. The necessary hardware
is part of the circuit of Fig. 11.12. A special I/O port address, the "RETI"
T1 T2 Tw Tw Tw Tw Tw T3
CLOCK
AS
\J
VIACK
~ ;-
R/W
I
DS \\...._____~I
MI \~_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _~;_
'---
IORQ'
\'------~;-
RD
port, is used to place an "ED" and "4D" code on the peripherals data inputs
while manipulating the MI and RD lines to simulate Z80 instruction fetches.
The software routine is as follows:
The two simulated instruction fetches for the Z80 RETI must be consecutive
operations at the peripheral and, therefore, interrupts of the Z8000 CPU
should be disabled while this sequence is executed, as shown. The timing of
the signals to the Z80 peripherals during this simulated RETI sequence is il-
lustrated in Fig. 11.15. (In a system with bus sharing, bus requests also must
11 12 1w 13 11 12 1w 13
~~--------------
-----------~;- ~~--------I
__----II '--- '-
'---1
\\-____-..JI
'--
'--------1
'---___----JI \ I
~ _____I \\-____~I
Z80 peripheral interface return from interrupt (RETI) timing.
Peripheral I nterfaci ng 205
be disabled between the two output operations that simulate the Z80 RETI
sequence. This might require some additional hardware to gate the BUSREQ
input to the CPU.)
The address/data bus can be connected directly to the DO-D7 data lines
of the Z80 peripherals. In the system of Fig. 11.1, latched address lines LA1
and LA2 are used as the Port Select (A/B) and Control/Data (C/D) signals
for the PIO and SIO, and as Channel Select (CSO and CS1) for the CTC. The
interrupt outputs are all connected to the appropriate interrupt request in-
put of the Z8000 CPU. The lEI-lEO daisy chain is used to establish inter-
rupt priorities among the Z80 peripherals.
The Z8420 PIO needs an active M1 pulse to enable its internal interrupt
circuitry . This is accomplished by writing O's to the "RETI" port used to
simulate the Z80 RETI instruction fetch after the PIO interrupts have been
enabled.
In summary, a small, powerful microcomputer system can be imple-
mented with a Z8000 CPU, memory, peripheral devices, and a small amount
of TTL logic. Buffering of the CPU outputs is necessary in all but the small-
est systems. Interfacing the Z8000 CPU to nonvolatile memory is straight-
forward; interfacing to dynamic RAMs requires the generation of the proper
timing strobes. If peripherals from other microprocessor families are used,
the control signals for those peripherals must be generated from the Z8000
CPU's bus control and status signals. Z80 family peripherals interface easily
to Z8000 systems, largely due to the similarity in the Z80 and Z8000 inter-
rupt structures.
12
The Z8001 and Z8002 CPUs are just two members of a family of devices de-
signed to interact over the Z-Bus. Other members of the Z8000 family include
several Z-Bus-compatible peripherals, a DMA controller, and a Z-Bus memory.
The Z-Bus peripheral chips are powerful, multifunction devices that can
be configured under program control for a particular application. All of the
Z-Bus peripherals share a common interrupt structure and can be used in a
priority interrupt or polled environment. The functions of each device are
controlled by using I/O commands to access the peripheral's internal registers;
each register has its own I/O port address. The Z8036 Counter/Timer and
Parallel I/O Unit (CIO) contains three parallel ports and three counter/timers;
it also can be used as a priority interrupt controller. The Z8038 FIFO Input/
Output Unit (FlO) is a byte-wide first-in/first-out buffer for interfacing asyn-
chronous devices in a single or multiprocessor system. The buffer depth is
expandable with the Z8060 FIFO Buffer Unit. The Z8030 Serial Communi-
cations Controller (SCC) is a dual-channel serial I/O unit that supports all
popular synchronous and asynchronous communications protocols. The
Z8065 Burst Error Processor (BEP) provides error correction and detection
capabilities for high-speed data transfers. The Z8068 Data Ciphering Proces-
sor (DCP) encrypts or decrypts data using the National Bureau of Standards
encryption algorithms. The Z8052 CRT Controller (CRTC) can be used to
control a variety of CRT displays. These peripherals each perform compli-
cated interfacing tasks, thereby unburdening the CPU and increasing system
throughput.
The Z8016 Direct Memory Access Transfer Controller (DTC) is both a
206
Z-BUS Peripheral Interface 207
Z-Bus requester and a Z-Bus peripheral. The DrC is prpgrammeq by the CPP
via I/O operations and can interrupt-
the CPU li);{e a. peripheral
- -
devke, bllt, ~cts
as a bus master when executing DMA transfers.
The Z6132 Quasi-Static RAM is a 4K X 8Z"lllJ.~-QQll}patigl~ memory
device that is easily interfaced to Z8000 systems,
[Two other Z-Bus components, the Z8 single-chipmicroGomputerand the
Universal Peripheral Controller (Upe), a slave miQfQOOmputer, ~re describ~d
in Chapter 13.]
All of the Z-Bus peripherals are byte peripherwf'? with the ex;ception qf the
Z8052 CRT controller. Figure 12.1 illustrates the ~ignws useq tq interface
a byte peripheral to the Z~Bus. One·half of the ~dctr~~s/dat~ b'Y,s provides up
to 8 bits of address information for direotly addf@.ssing the peripheral '8 inter-
nal registers and an 8-bit data path for data transfers between the peripheral
and the CPU. (Typically, the lower half gf the address/data bus js used, since
interrupt vectors must be placed on the lower half of the bw, when w:jing vec-
tored interrupts.) Timing of the data transfers ifl coptrolled by the address
strobe (AS) and data strobe (DS). and the direction of tra,nsf@!p is determined
by the R/W signal (Fig. 12.2). The chip seleQt (CS) for a peripheral is decoded
from the I/O port address during I/O accessefii and is latched interI).ally by the
peripheral on the rising edge of AS. Resets are implemented when both the AS
and DS inputs to the peripheral are low siffi-ultaneously. (In normal operation,
AS active and DS active are mutually exoluaive events.) The INT, INTACK,
lEI, and lEO signals interface the peripheral to the Z-Bus interrupt structure.
Other signals, such as WAIT, also might be part of the peripheral-to-Z-
Bus interface, depending on the application. Some of the Z-Bus peripherals
A. J\
8-BIT ADDRESS/DATA
<'i r
NOTES:
INT
~SET=AS AND os I.QW
S IS LATCHED BY AS
CLOCK TO PERIPHERAL DOES NOT HAVE TO BE
INTACK CPU CLOCK
lEI
MINIMUM CPU
INTERFACE lEO
-----
PERIPHERAL
DEPENDENT
Z·BUS TIMING
AS
CS
R/W
DS
\~---/
READ CYCLE
cs
R/Vii
\~--------------
\'--___1
Figure 12.2 Z-Bus to peripheral in-
WRITE CYCLE terface timing.
have a clock input; the peripheral's clock does not have to be syn0hroni~ed
with the CPU clock in any way.
(Most of these peripherals also are available in a version that etl$ily inter-
faces to systems with separate, nonmultiplexed address and data buses~ such
as Z80-based systems.)
Each Z-Bus peripheral implements several functions and is programmable
for a particular application. A peripheral may have up to 128 internal reg-
isters that can be read or written by the CPU using lIO instructions. Each
register has its own I/O port address; thus each peripheral occupies a block
of port addresses in the system. The' addreaa of the register being accessed
is sampled on the peripheral's address/data bus inputs on the rising edge of
AS. A programmable option allows the user to decide if the least signficant
bit of the register address is an the ADO or AD! bus line. For byte transfers
in Z8000-based systems, the value of ADO when the CPU emits the address
determines which half of the bus will be used to transfer the byte of data.
For example, byte peripherals connected to the lower half of the bus always
have odd addresses. Therefore, in Z8000 systems, the least significant bit of
the peripheral's register address should be on the ADlline, not ADO.
PERIPHERAL INTERRUPT STRUCTURE
If several Z-Bus peripherals share a common interrupt request line to the CPU,
the lEI-lEO daisy chain is used to establish the relative priority of those pe-
ripherals. When one or more peripherals request the CPU's attention via an
interrupt, the interrupt acknowledge cycle is used to select the peripheral
whose interrupt is to be serviced and to obtain a vector or identifier word,
as described in Chapter 6.
Each of the Z-Bus peripheral devices can have several sources of inter-
rupt internal to that chip. For peripherals with multiple interrupt sources
on one chip, priority is established with an lEI-lEO daisy chain internal to the
device. This prioritization order is fixed and cannot be altered by the user.
Figure 12.3 illustrates the Z-Bus interrupt structure for several peripherals
sharing an interrupt line, and for one peripheral with several sources of inter-
rupts internal to that device.
For every interrupt source on a Z-Bus peripheral there are three bits
within the device's internal registers that control the interrupt logic. The
Interrupt Enable (IE) bit is 'Set to enable or reset to disable that particular
interrupt source. The Interrupt Pending (IP) bit is set when the device re-
quires servicing and reset when the interrupt is serviced. The Interrupt Under
Service (IUS) bit indicates when the interrupt is being serviced and must be
reset by the programmer upon completion of the service routine.
A Z-Bus peripheral has one or more registers that hold an interrupt vec-
tor that is read by the CPU during the interrupt acknowledge cycle. Each in-
terrupt source on a device is associated with a vector and each vector can have
one or more interrupt sources associated with it. If more than one interrupt
source is associated with a single vector, some bits in the vector can be encoded
to identify which source caused the interrupt. A bit called the Vector Includes
Status (VIS) bit is used to enable or disable this encoding function.
Each peripheral also has three programmable bits that control the inter-
rupt logic for all interrupt sources on the device. The Master Enable (MIE) bit
is used to enable or disable all interrupt sources on the chip. The Disable
Lower Chain (DLC) bit is used to force the peripheral's lEO output to 0,
thereby disabling interrupts from peripherals of lower priority on the daisy
chain. The No Vector (NV) bit is set if a vector is not to be placed on the bus
during the interrupt acknowledge sequence.
Figure 12.4 illustrates the interrupt daisy-chain protocol as it applies
to the Z-Bus peripherals. An interrupt source with an interrupt pending (IP =
1) requests an interrupt by pulling INT low if the IE bit for that source and
the MIE bit for that device are both set, that interrupt source is not already
under service (IUS = 0), no higher-priority device's interrupt sources are being
serviced (lEI = 1), and an interrupt acknowledge cycle is not currently being
executed (INT ACK = 1). After the CPU samples the active interrupt request,
an interrupt acknowledge cycle is executed, as indicated by INT ACK going
209
N
INTERRUPT
VECTOR
INTERRUPT
VECTOR
o
... ~
....10
~
o
~ ~
I ( (
:;I -'.~.
I I
1\.
HIGHEST PRIORITY
I~------'
.
~
LOWEST PRIORITY
INTERRUPT SOURCE INTERRUPT SOURCE
• • •
lEI
HIGHE~~
PRIORI~~ _ _ _ _ _ _ _ _ _ _ _ _.....,
LOWEST
PRIORITY
•
ADO-AD7\\.
:1 : · 1I
gJJ
)
+.
~ ,"
,
Z·BUS
CPU
004 I • 111
STATUS 1------0/1
lEI OR
IN'i'ACKLOW
])SLOW HIGHER·PRIORITY
'-------i~ DEVICE ACKNOWLEDGED
lEI HIGH
LET IEO=IEI
low. When INTACK is active, all interrupt sources with an interrupt pending
(the IP, IE, and MIE bits are alII's) or under service (the IUS bit = 1) hold
their lEO outputs low. When DS goes low during the acknowledge cycle,
only the highest-priority interrupt source with an interrupt pending (lP = 1)
should have a high lEI input; this is the interrupt being acknowledged. The
IP bit is reset for that interrupt source, the IUS bit is set, and, if the NV bit =
0, the appropriate vector is placed on the bus to be read by the CPU. If the
NV bit is 1, the peripheral's ADO-AD7 pins are left floating, allowing external
circuitry to place a vector on the bus, if so desired. While servicing of that
interrupt is in progress, as indicated by IUS = 1, lEO is held low, thereby dis-
abling interrupts from lower-priority devices. When servicing is completed,
the IUS bit must be reset. The CPU resets the IUS bit by an explicit I/O
write to the register in the peripheral that contains the IUS bit; this I/O write
operation usually is executed immediately preceding the interrupt return in
the service routine. (In most cases, the IP bit is not reset automatically during
the acknowledge sequence, and also must be reset via an explicit write to the
appropriate register in the peripheral.)
A polled interrupt scheme can be implemented by disabling interrupts
using the MIE bit in each peripheral. The registers containing the IP bits are
212 Z8000 Family Devices Chap. 12
read by the CPU via I/O read operations to detect pending interrupts. The
IP bits must be reset by writes to the same registers.
Z8036 CIO
The Z8036 Counter/Timer and Parallel I/O Unit (CIO) contains three paral-
lel ports and three programmable counter/timers, satisfying most parallel I/O
and counter/timer needs in Z8000 systems. There are five distinct interrupt
sources in the CIO, and three separate interrupt vectors. The configuration
of the CIO is controlled by 48 directly addressable read/write registers. The
pin assignments for this 40-pin device are given in Fig. 12.5. The CIO oper-
ates from a single +5-V power supply and draws a maximum of 250 mAo Fig-
ure 12.6 is a block diagram of the CIO.
The CIO's parallel I/O capabilities consist of two 8-bit general-purpose
ports and one 4-bit special-purpose port. The two 8-bit ports, ports A and B,
can be linked together to form a single 16-bit port. Either port can be con-
figured as a byte port (that is, an entire byte of input or output) or as a bit
port (the direction of each bit is programmable). Figure 12.7 shows a block
diagram of these ports. Optionally, port B pins can be used to provide external
access to counter/timers 1 and 2. With this exception, ports A and Bare
identical.
When configured as byte ports, ports A and B can be input, output, or
bidirectional ports. I/O operations can be interrupt driven; both port A and
_ ADl PAl _
PA _ AD4
_ ADs
s
ADs
_ ADs PAs _
PA ADs
_ AD4 _
4 ADo
ADDRESS/DATA PORTA ADl
BUS _ADa
PAa - OS
_ AD2
PA2
R/W
_ADI PAl
_ ADo GND
PAo _
PBo
~
:~; :=: }
BUS TIMING { - PBI
AND RESET _ DS
Z8036 PORT C PB2
_R/W Z·CIO PC
I
_
PB3
CONTROL - CSO PC o - PB4
{ _ CSI PB _
l
PBs _ PBs
iNT
PBs
_ INTACK PBs _
INTERRUPT _ lEI PB _ PBl
{ PB 4 _ PORT B PCLK INTACK
lEO 3
lEI iNT
PB 2 - lEO +5V
PB _
I
PCo PC3
PB o - PCI PC2
PCLK +5 V GND
INTERRUPT
< INTE:RUPT
CONTROL
>
CONTROL
LOGIC
INTERNAL BUS
PORT A
1/0 >
< ADDRESSI
INPUTS
INTERNAL
CONTROL
LOGIC
< PORT B
1/0
>
TO COUNTERITIMERS 1 AND 2
(PORT B ONLy)
INTl:flNAL
BUS\
INPUT
BUFFERI
OUTPUT INVERTERS
fll"QlilTER AND
PULSE
CATCHER
PATTEflN
RECOGNITION PORT
LOgiC 1/0
OUTPUT
INPUT
BUFFERI
flEGISTEfl
INVERTERS
H ....
PQRT
cONTROL
LqglC
~~. U
I.HMIDSHA!<E CONT.ROL
TO PORT C
when a specific pattern is detected at the port. The pattern can be specified
for each bit as a 1, 0, rising edge, falling edge, or any transition. Individual
bits can be masked if they are not to be included in the pattern match. Three
pattern-match modes are available: AND, OR, and OR-Priority Encoded Vec-
tor. In the AND mode, a pattern match is defined as the simultaneous satis-
faction of all nonmasked bit specifications. In the OR and OR-Priority En-
coded Vector modes, the satisfaction of anyone nonmasked bit specification
constitutes a pattern match.
The OR-Priority Encoded Vector mode allows the CIO to be used as an
interrupt priority controller. In this mode, the IP bit is set when a pattern
match occurs and cannot be cleared until a match is no longer present. If the
interrupt vector is allowed to include status information (VIS = 1), the vec-
tor returned during the interrupt acknowledge cycle indicates the highest pri-
ority bit matching its pattern-match specification at the time of the acknowl-
edge; this mayor may not be the bit that originally caused the pattern-match
interrupt. Bit 7 has the highest priority and bit 0 the lowest. Thus a CIO
port could accept interrupt inputs from other devices on an input port and
Z8036 CIO 215
STROBED
HANDSHAKE - . . . , - - - INTERLOCKID
'U'D ¥HANDSHAKI
' -_ _ _--'~_ _..J - - ~1~~~~~~~D '\.._--
I
STROBED
DATA LATCHID
IN BUFFE" "EO liTE" BUFFER REGISTER HANDSHAKf
"EMPTIED"
NIXT IYTI
SHIFTED 1'1'10'>1
OUTPUT REGISTER TO
BUFFER REGISTER
DAV "I'D
INPUT INPUT
RFD DAC
OUTPUT INPUT
DAC DAY
OUTPUT OUTPUT
3-Wire Handshake
INPUT PORT
TRIGGER COUNTER
ACKIN
INPUT OUTPUT
CIT 3
OUTPUT PORT
CIT 3
Pulsed Handshake
act as an interrupt priority controller for those devices. For example, if a low
level indicates an interrupt request from devices #0 through #7 in Fig. 12.9,
the pattern match logic for CIO port A would be set to match on O's in OR-
Priority Encoded Vector mode. An active INT from any device would cause
the CIO to interrupt the CPU. The vector returned to the CPU would indi-
216 zaooo Family Devices Chap. 12
- -
INT INT INT
- iNT
7 I
- INTACt<
<Co
6
-
I-
a: 0
0
lEI a. 0 0
- lEO
Z8036
CIO
0
cate the highest-priority device with an active INT signal at the time of the
acknowledge. \;v'hen desired, interrupts from selected devices could be disabled
by masking the appropriate bits in the CIa's pattern match logic. Thus the
CIa is used as an interrupt controller. Furthermore, this provides an easy
method for interfacing non-Z8000 family peripherals to the Z-Bus interrupt
structure.
The function of the 4-bit special-purpose port, port C, depends on the
configuration of ports A and B (Table 12.1 and Fig. 12.10). Port C provides
the handshake lines for ports A and B and the data direction line for a bidi-
rectional port. One bit of port C can be programmed as a WAIT signal to the
CPU or a REQUEST signal to a DMA controller, thereby allowing block
Ports A and B: bit ports Bit I/O Bit I/O Bit I/O Bit I/O
Port A: input or output port RFD or DAV ACKIN REQUEST/WAIT Bit I/O
(interlocked, strobed, or or bit I/O
pulsed handshake)a
Port B: input or output port REQ UEST /W AIT Bit I/O RFD or DAV ACKIN
(interlocked, strobed, or or bit I/O
pulsed handshake)a
Port A or B: input port RFD (output) DAV (input) REQUEST/WAIT DAC (output)
(three-wire handshake) or bit I/O
Port A or B: output port DA V (output) DAC (input) REQUEST/WAIT RFD (input)
(three-wire handshake) or bit I/O
Port A or B: bidirectional RFD or DAV ACKIN REQUEST/WAIT IN/OUT
port (interlocked or or bit I/O
strobed handshake)
aBoth ports A and B can be specified input or output with interlocked, strobed, or pulsed handshake at the same
time if neither uses REQUEST m-A-F'r.
Z8036 CIO 217
DD HANDSHAKE
AND
REQUEST/WAIT
....:~
LOGIC
ft
NTERNAL INPUT
BUS BUFFER!
'---
INVERTERS
AND
I
.L. r--
PULSE
..J
.... .........,,, CATCHERS
~
~
OUTPUT
REGISTER
==J DATA
MUX
~'(:>.
~PORT
4
r--YI!O
~
INPUT
A
/
REGISTER \
'4
~ OUTPUT
) BUFFER!
INVERTERS
"
?:nNTE'"AL
H PORT
CONTROL
LOGIC
<
pO",
CONTROL LINES
.... ;r
transfers to or from the CIO. Any port C pins not used for those functions
can be used as I/O lines with programmable data direction and polarity. Op-
tionally, inputs can be "one's catchers" and outputs can be open-drain or
active. The port C pins also can be used to provide external access to counter/
timer 3.
The three programmable counter/timers are 16-bit down counters (see
Fig. 12.11). Up to four external I/O lines can be used to control each counter/
timer: counter input, gate input, trigger input, and counter/timer output.
These external access lines are provided by port B and port C pins (Table 12.2).
Optionally, the device's clock input (PCLK/2) can be used to drive any count-
er/timer. If the counter/timer output is routed to an external pin, three out-
put waveforms are available: pulse, one-shot, and square wave (Fig. 12.12).
The end-of-count condition can be used to generate an interrupt. The counter/
timers can be run in single-cycle or continuous ~odes; if a trigger input is
employed, retriggerable or nonretriggerable operation can be specified. The
current count can be read at any time. Typical applications for the counter/
218 Z8000 Family Devices Chap. 12
INTERNAL
BUS
TIME CURRENT
CONSTANT COUNT
REGISTER REGISTER
(MSB's) (MSB's)
16·BIT
DOWN
COUNTER
TIME CURRENT
CONSTANT COUNT
REGISTER REGISTER
(LSB's) (LSB's)
COUNTER
CONTROL
\,..-_ _ _----1 LINES
COUNTERI
TIMER
CONTROL
LOGIC
TO PORT
timers include event counters, pulse train generators, event duration timers,
watchdog timers, and baud-rate clock generators.
The five interrupt sources for the CIO are, in priority order, counter/
timer 3, port A, counter/timer 2, port B, and counter/timer 1. Each source
has its own IE, IP, and IUS bits to control that interrupt. Three interrupt vec-
tors can be specified: one for port A, one for port B, and one shared by all
three counter/timers. The vectors can be encoded with status information to
identify further the event that caused the interrupt. For polled operations a
PCLKl2 OR
COUNTER INPUT _
TRIGGER - '
GATE U ,,/
ONE SHOT ,~
OUTPUT _ _---' L--
SQUARE WAVE
OUTPUT ~
------------i/r----J
FIRST HALF
special register, called the current vector register, holds the vector that would
have been returned if hardware interrupts were used.
Figure 12.13 shows all 48 CIO registers. Programming the CIO involves
loading the registers with the appropriate bit pattern to implement the desired
operation. Addressing of the registers is determined by the Right Justify Ad-
dress (RJA) bit in the Master Interrupt Control register. If RJA is 0, the ad-
dress bits on AD1-AD6 during AS active in an I/O cycle are decoded as the
register address if the CIO is chip selected. When RJA is 1, the register address
is decoded on ADO-AD5. The 6-bit register addresses are given in Fig. 12.13.
A typical Z-Bus to CIO interface is diagrammed in Fig. 12.14. The CIO's
address/data pins are connected to the lower half of the Z-Bus address/data
bus. The address bit on ADO should always be a 1 for byte transfers on the
lower half of the bus, so the RJA bit should be a 0 and AD1-AD6 provide
the register addresses. AD7 -AD15 are ,decoded to provide chip selects during
I/O transactions (with I/O STATUS decoded from the STO-ST3 lines). The
CIO is chip selected by I/O port address %FF80 to %FFFF; however, only
odd addresses are used and only 48' of those addresses actually access a CIO
register. An active RESET signal resets the CIO by pulling AS and DS low
simultaneously.
Z8038 FlO
The Z8038 FIFO Input/Output Interface Unit (FlO) contains a 128-byte first-
in/first-out buffer that provides an asynchronous CPU-to-CPU or CPU-to-pe-
ripheral interface. One side of the FlO, the port 1 side, can be configured as
a Z-bus or general-purpose nonmultiplexed bus interface to a microprocessor;
Master Interrupt Control Register Master Configuration Control Register
Address: 000000 Address: 000001
(Read/W rite) (Read/Write)
10,1 0, ! 0,1 0,1 0, ! 0,1 0, IDo I
MASTER INTERRUPT
ENABLE (MIE)
J
10 1000 Port B 10 100 1 Port B
(Read/Write) (Read/Write)
1~1~1~1~1~1~1~1~1
~ -------=
1
1
SELECTS
PDRTTYPE
PTS1 PTSo.
o
(PTS)
0 BIT PORT
o 1 INPUT PORT
0 OUTPUT PORT
1 BIDIRECTIONAL
PORT
L LATCH ON PATTERN MATCH (LPM)
(BIT MODE)
DESKEW TIMER ENABLE (DTE)
(HANDSHAKE MODES)
PATTERN MODE SPECIFICATION
BITS (PMS)
PMS1 PMSO
o DISABLE PATTERN MATCH
HANDSHAKE TYPE SPECIFICATION
HST1 HSTO
1
1
0
1
BITS (HST)
g ~ ~~~~R~~DC~i~~:~f:~AKE
PULSED HANDSHAKE
THREE· WIRE HANDSHAKE
DESKEW TIME SPECIFICATION
BITS
SPECIFIES THE MSB's OF
~~~~~~ci~~~~ i.IME CONSTANT.
~
INTERRUPT UNDER
SERVICE (IUS)
I L INTERRUPT ON ERROR (IOE)
220
Data Path Polarity Registers Data Direction Registers
Addresses: 100010 Port A Addresses: 100011 Port A
101010 Port B 101011 Port B
000101 Port C (4 LSBs only) 000110 Port C (4 LSBs only)
(Read/Write) (Read/Write)
I~I~I~I~I~I~I~I~I
4 MSBs
0= WRITING OF CORRESPONDING LSB ENABLED
1 =WRITING OF CORRESPONDING LSB INHIBITED
(READ RETURNS ')
221
222 Z8000 Family Devices Chap. 12
COU~TERfTlMEI!!;T~U!'l
02 01
o 0 CIT 3
o 1 CIT 2
1 0 CIT 1
1 1 ERROR
the other side (port 2 side) can be configured as a Z-Bus interface, nonmulti-
plexed bus interface, two-wire handshake I/O interface, or three-wire hand-
shake I/O interface. Thus dissimilar CPUs or CPUs and peripherals running
with different speeds or protocols can be linked, allowing asynchronous data
transfers and improving I/O overhead. The FlO is a 40-pin device that requires
a single +5-V supply and draws a maximum of 250 rnA.
A block diagram of the FlO is given in Fig. 12.15. The port 1 side is
always a processor interface and can be configured as a Z-Bus interface (con-
nected to either the lower or upper half of the bus) or a nonmultiplexed bus
interface. The nonmultiplexed bus is a general-purpose microprocessor inter-
face with eight data lines, chip enable (CE), read (RD), write (WR), and con-
trol/data (C/D) signals. The timing for data transfers on this bus is illustrated
in Fig. 12.16. The C/D signal determines if the current bus transfer involves
a control register in the FlO or the FIFO data buffer itself. This bus config-
uration easily interfaces to microprocessors with separate, nonmultiplexed
address and data buses, such as the Z80, 8080, and 6800. The configuration
of the port 1 side is determined by the condition of two pins, MO and M1
(Table 12.3). The port 2 side can be a Z-Bus, nonmultiplexed bus, two-wire
handshake, or three-wire handshake interface, as determined by two bits (BO
and B1) in an internal register that is programmed from the port 1 side. Fig-
Z8038 FlO 223
~ I I
E~
'N","U" UNO" SERV'C' (IUS) COUNT IN PROGRESS (CIP)
(READ ONLy)
INTERRUPT ENABLE (IE) TRIGGER COMMAND BIT (TCB)
I I (WRITE ONLY· READ RETURNS 0)
INTERRUPT PENDING (lP) I I GATE COMMAND BIT (GCB)
IUS, IE, AND IP ARE WRITTEN USING READ COUNTER CONTROL (RCC)
THE FOLLOWING CODE: (READ/SET ONLY -
NULL CODE 0 0 0 CLEARED BY READING CCR LSB)
CONTINUOUS sm.
GLE CYCLE (C/SC) ~~J L OUTPUT DUTY CYCLE
SELECTS (DCS)
ure 12.17 shows the pin-out of the FlO and Table 12.4 describes the pin assign-
ment for each possible type of interface.
Pattern recognition logic is included for both sides of the FlO and is
capable of generating an interrupt when a specific data pattern is written to
or read from the FIFO buffer. The pattern can be specified for each bit as a 1
or a 0; individual bits can be masked off, if so desired.
Special message registers, also called mailbox registers, can be used to
pass information between CPUs if the FlO is used as a CPU-to-CPU interface.
Counter/Timer Current Count Registers
Addresses: 010000 Counter/Timer l's MSB
010001 CounterlTimer l's LSB
010010 Counter/Timer 2's MSB
010011 Counter/Timer 2's LSB
010100 Counter/Timer 3' s MSB
010101 Counter/Timer 3's LSB
(Read Only)
ID,I D61 D51 D.I D31 D21 D, IDo ID,I D61 D51 D41 D31 D21 D, IDo I
MOST - - - - - ' L....----lEAST
SIGNIFICANT SIGNIFICANT
BYTE BYTE
Counter/Timer Registers
224
110 STATUS
AD1S +SV
AD14
AD13
AD12
ADll
AD10
AD9
ADS CSl PA7
CSO PA6
PAS
AD7 AD7 PA4
AD6 AD6 PA3
ADS ADS PA2
~
« AD4 AD4 PAl
z
(!l
u; AD3 AD3 PAO
en AD2 AD2
::l ZS036
CD
N ADl ADl CIO PB7
ADO ADO PB6
PBS
AS
AS PB4
RESET
OS PB3
PB2
RIW PBl
OS
PBO
RIW INT
INT INTACK PC3
INTACK lEI PC2
lEI lEO PCl
lEO
Figure 12.14 Typical Z-Bus to CIa
interface.
CPU
INTERFACE
CPU OR
INTERFACE 110 PORT
PATTERN PATTERN
MATCH MATCH
LOGIC LOGIC
DATA
128 X 8 DATA
DATA BUFFER
FIFO BUFFER BUS
BUS \ .....---./----1 REGISTER
225
226 Z8000 Family Devices Chap. 12
CID
X C
00-07 ( TO cPU )
ci \ I
RD \ I
Non-Z-BUS Read Cycle Timing
CID _ _ _ _ X'-____________-'X____
00-07 ------c('-__________~----
ci
\_----------------
Non-Z-BUS Write Cycle Timing
INT
---------------- /
-- 07 I 07 [AJ +5V
I
06 I [AJ
lID
DATA
BUS
---
Os
04
I
I
I
03 PORT I PORT 0 3
04
- DATA
BUS
19
[Q]
ffiI
lID
19
[Q]
-- 02
~
00
1 I 2 O2
0 1 SIDE: SIDE 0 1
I
~
00
-
[f)
[g]
[ill
ffiI
[f)
[g]
~
I
~}
OJ [ill
I @]
@] I QJ OJ
@] I @] 00 QJ
Z8038 CONTROL
CONTROLl @] FI,O
@] 01 00
l~ [K] 02 01
[IJ [IJ 03 02
@] @]
~
04 03
[E] [E] Os 04
INTERRUPT { IT] IT] : : } INTERRUPT 06 Os
CONFIGURATION { -- CD
M1
Me
CD
GNO
07
M1
06
07
Me
t
+5V
t
GNO
Control
Signal Z-BUS Z-BUS Interlocked 3-Wire
Pins Low Byte High Byte Non-Z-BUS HS Port* HS Port*
[K] REQIWT REQIWT REQ/WT RFD/DAV RFD/DAV
[i] DMASTB DMASTB DACK ACKIN DAV/DAC
@] DS DS RD FULL DAC/RFD
~ R/W R/W WR EMPTY EMPTY
~ CS CS CE CLEAR CLEAR
[!] AS AS c/i5 DATA DIR DATA DIR
@] INTACK Aa INTACK INa INa
~ IEO Al IEO OUTI OUTI
ITJ IEI A2 IEI OE OE
W INT A3 INT OUT3 OUT3
*2 side only.
and the system's memory. A special control register, the Byte Count Com-
parison register, can be used to send a request to the DMA device when a
given number of bytes is in the FIFO buffer. For the input side of the FIFO
buffer, the request (REQ) signal to the DMA controller becomes active when
the number of bytes in the FIFO buffer is equal in value to the Byte Count
Comparison register and stays active until the buffer is full (Fig. 12.18). For
TABLE 12.4 Z8038 FlO PIN FUNCTIONS
Pin
Pin signals names Pin numbers Mode Signal description
N Pins Common to Both Sides
N
(;X)
Mo Mo 21 M 1 and Mo program port 1 side CPU interface
Ml Ml 19
+5 V dc +5 V dc 40 Dc power source
GND Gnd 20 Dc power ground
Non-Z-Bus Mode
Do-D7 (data) Do-D7 11-18 29-22 Bidirectional data bus
REQ/WT (request/wait) A 1 39 Output, active low, REQUEST (ready) line for
DMA transfer; WAIT line (open-drain) out-
put for synchronized CPU and FlO data
transfer
DACK(DMA B 2 38 Input, active low; DMA acknowledge
II.)
acknowledge)
II.)
(.0 RD (read) C 3 37 Input, active low; signals CPU read from FlO
TABLE 12.4 28038 FlO PIN FUNCTIONS Continued
Pin
Pin signals names Pin numbers Mode Signal description
N
eN Non-Z-Bus Mode Continued
o
WR (write) D 4 36 Input, active low; signals CPU write to FlO
CE (chip select) E 5 35 Input, active low; used to select FlO
c/n (control/data) F 6 34 Input, active high; identifies control byte on
Do-D7; active low identifies data byte on
Do-D7
INTACK (interrupt G 7 33 Input, active low; acknowledges an interrupt
acknowledge)
lEO (interrupt H 8 32 Output, active high; sends interrupt enable to
enable out) lower priority device lEI pin
lEI (interrupt 9 31 Input, active high; receives interrupt enable
enable in) from higher-priority-device lEO signal
INT (interrupt) J 10 30 Output, open drain, active low; signals FlO in-
terrupt to CPU
aHS, handshake.
N
W
~
232 Z8000 Family Devices Chap. 12
REO
CD CD
INACTIVE .......:::~----+..;;;..- ....---+..... NUMBER OF BYTES IN FIFO
EMPTY FULL
NOTES:
1. FIFO empty.
2. REQUEST enabled, FlO requests DMA transfer.
3. DMA transfers data into the FlO.
4. FIFO full, REQUEST inactive.
5. The FIFO empties from the opposite port until the number
of bytes in the FIFO buffer is the same as the number pro- Figure 12.18 DMA-controlled
grammed in the Byte Count Comparison register. writes to a FlO.
the output side of the FlO, the REQ pin is inactive until the number of bytes
in the FIFO buffer equals the value in the Byte Count Comparison register.
REQ then goes active and stays active until the buffer is empty (Fig. 12.19).
A WAIT signal can be programmed to synchronize CPU-controlled block
transfers.
Special control signals can be used to clear the FIFO buffer or change
the direction of data flow in the buffer. The clear and data direction functions
are controlled by the port 1 side as a default, but control of these functions
can be passed to the port 2 side if desired. For CPU-to-CPU interfaces, if the
controlling CPU changes the direction of the buffer, the other CPU is notified
via an interrupt.
CD CD
ACTIVE -+----1-----....-04-
INACTIVE
CD
---=--f----....----+-__1r-----
EMPTY FULL
I
NUMBER IN BYTE COUNT COMPARISON REGISTER
NOTES:
1. FIFO empty.
2. CPUlDMA fills FIFO buffer from the opposite port.
3. Number of bytes in FIFO buffer is the same as the number
of bytes programmed in the Byte Count Comparison register.
4. REQUEST goes active. Figure 12.19 DMA-controlled
5. DMA transfers data out of FIFO until it is empty. reads from an FlO.
Z8038 FlO 233
Each side of the FlO has seven sources of interrupt. They are, in pri-
ority order, the mailbox register, change in data direction, pattern match,
status match (number of bytes in the FIFO buffer equals the value in the
Byte Count Comparison register), overflow/underflow error, buffer full, and
buffer empty. Each interrupt source has its own IE, IP, and IUS bits for con-
trolling that interrupt. Each side of the FlO has one interrupt vector; that
vector can include encoded status information identifying the interrupt
source.
Each side of the FlO has 16 addressable read/write registers. One of
these, Control Register 2, is not used on the port 2 side. The RJA bit in
Control Register 0 determines how the registers are addressed. When RJA = 0,
address bus bits ADI-AD4 are used for register addressing; when RJA = 1,
address bus bits ADO-AD3 are used. Figure 12.20 shows all the FlO registers.
lli§~
(Read/Write) ' L PORT 2 SIDE-INPUT LINE' (PIN 33)"
L PORT 2 SIDE-OUTPUT LINE (PIN 32)"
10 , ; 0 6 ! 0 5 : 0, : 0 3 : 0,\ 0, : Do I NOT USED (MUST BE PROGRAMMED 0)
~
I ~; ~ ;~~:::'WA" ,...'"
PORT 2 SIDE-OUTPUT LINE (PIN 30)"
DATA DIRECTION BIT
1 = INPUT TO CPU
Control Registers
II I
o 0 0
IUS, IE, AND IP ARE WRITTEN USING
THE FOLLOWING COMMAND:
NULL CODE
o 0 1 CLEAR IP & IUS
o 1 0 SET IUS
o 1 1 CLEAR IUS
1 0 0 SET IP
1 0 1 CLEAR IP
1 1 0 SET IE
1 1 1 CLEAR IE
III
IUS, IE, AND IP ARE WRITTEN USING
THE FOLLOWING COMMAND: (MUST BE PROGRAMMED 0)
III
IUS, IE, AND IP ARE WRITTEN USING
NULL CODE o 0 0 THE FOLLOWING COMMAND:
CLEAR IP & IUS o 0 1
o 0 0 NULL CODE
SET IUS o 1 0
o 0 1 CLEAR IP & IUS
CLEAR IUS o 1 1
0 1 0 SET IUS
SET IP 1 0 0
o 1 1 CLEAR IUS
CLEAR IP 1 0 1
1 0 0 SET IP
SET IE 1 1 0
1 0 1 CLEAR IP
CLEAR IE 1 1 1
1 1 0 SET IE
1 1 1 CLEAR IE
"READ·ONLY BITS
Both the depth and width of FIFO buffers in a system can be expanded easily
with the Z8038 FlO and an auxiliary part, the Z8060 FIFO. The Z8060 FIFO
is a 128 X 8 FIFO buffer with a two-wire interlocked handshake interface on
both sides of the buffer (Fig. 12.21).
FIFO Buffer Expansion 235
I
~~
'HE CO""' COMP.,,,,,,""",, JI I L UNDERFLOW ERROR'
UNDER SERVICE (IUS)
I
L ERROR INTERRUPT PENDING (10)
BYTE COUNT COMPARE INTERRUPT I ERROR INTERRUPT ENABLED (IE)
ENABLE (IE) I I
I I _ ERROR INTERRUPT UNDER SERVICE (IUS)
BYTE COUNT COMPARE INTERRUPT I I , I I
PENDING (IP) OVERFLOW ERROR'
IUS, IE, AND IP ARE WRITTEN USING
THE FOLLOWING COMMAND:
NULL CODE o
III I I I
0 0 o 0 0
IUS, IE, AND IP ARE WRITTEN USING
THE FOLLOWING COMMAND:
NULL CODE
CLEAR IP & IUS o 0 1 o 0 1 CLEAR IP & IUS
SET IUS o 1 0 0 1 0 SET IUS
CLEAR IUS o 1 1 o 1 1 CLEAR IUS
SET IP 1 0 0 1 0 0 SET IP
CLEAR IP 1 0 1 1 0 1 CLEAR IP
SET IE 1 1 0 1 1 0 SET IE
CLEAR IE 1 1 1 1 1 1 CLEAR IE
'READ·ONLY BITS
II I
NULL CODE 0 0 IUS, IE, AND IP ARE WRITTEN USING
CLEAR IP & IUS o 0 1 THE FOLLOWING COMMAND:
SET IUS o 1 0 o 0 0 NULL CODE
CLEAR IUS o 1 1 o 0 1 CLEAR IP & IUS
SET IP 1 0 0 0 1 0 SET IUS
CLEAR IP 1 0 1 o 1 1 CLEAR IUS
SET IE 1 1 0 1 0 0 SET IP
CLEAR IE 1 1 1 1 0 1 CLEAR IP
1 1 0 SET IE
1 1 1 CLEAR IE
'READ·ONLY BITS
The buffer depth is expanded by cascading Z8038 FIOs and Z8060 FIFOs.
Communication between these devices is via the two-wire interlocked hand-
shake. For example, Fig. 12.22 illustrates a 512-byte CPU-to-CPU FIFO buf-
fer interface consisting of two Z8038's and two Z8060's.
Byte Count Register Interrupt Vector Register
Address: 0111 Address: 0110
(Read Only) (Read/Write)
I I I I I I I I I I I I I I I I
STORES BYTE COMPARED WITH IF SET, BITS 0·7 MASK BITS 0·7
BYTE I" DATA BUFFER REGISTER IN PATTERN MATCH REGISTER.
MATCH OCCURS WHEN ALL
NON·MASKED BITS AGREE.
I I I I I I I I I I I I I I I I
CONTAINS THE BYTE TRANSFERRED CONTAINS VALUE COMPARED TO BYTE COUNT
TO OR FROM FIFO BUFFER RAM REGISTER TO ISSUE INTERRUPTS ON MATCH
(BIT 7 ALWAYS 0.)
236
Z8030 see 237
I
I RFD/DAVA +5 V
I RFD/DAVB
ACKIN A
: B 05
FULL ACKIN B
DATA I 04 DATA
BUS I 03 BUS EMPTY CLEAR
:~~~N
D2A D3B
COMMON { - D2B
D'A
CONTROL EMPTY
DOA D'B
- CLEAR
GND DOB
t
+5V GNO
Z8030 see
TO Z·BUS TO Z·BUS
OR GENERAL OR GENERAL
MICROPROCESSOR MICROPROCESSOR
~
' - - - - - - - ' INTERRUPT
fJ J
Ml MO
AD8-15 AD8-15
8038
FlO
l ADl-4
(BO=O)
(Bl=O)
A
ADl-4
I
y ~
C"S CS
L
FROM FROM
~~L'::CT- r--~~L'::CT
LOGIC LOGIC
CS CS
ADO-1S ADO-1S
8038
FlO
ADO-7 (BO=O) ADO-7
(B10)
Ml MO
••
Figure 12.23 I6-bit-wide buffer between two Z-Bus processors using
Z8038's.
to 1 megabit/second. Each channel has its own crystal oscillator, baud rate
generator, and digital phase-locked-loop circuitry for clock generation and re-
covery. Asynchronous, byte-oriented synchronous, and bit-oriented synchro-
nous protocols are supported. Facilities are included for data integrity check-
ing and modem controls. Thus the SCC is suitable for virtually any serial
data communications application. The SCC is a 40-pin device that requires a
single +5-V power supply and draws a maximum of 250 rnA (Fig. 12.24 and
12.25).
When used for asynchronous communications, the SCC can be program-
med for anywhere from 5 to 8 data bits per character (plus, optionally, a par-
ity bit). The transmitter can supply one, one-and-a-half, or two stop bits per
character and can provide a break output at any time. Automatic odd- or even-
parity generation and checking can be specified. Framing and overrun errors
are automatically detected. The transmit and receive clocks need not be
symmetric, and data rates of 1, 1~ , l2' or 6~ of the clock rate are allowed.
For synchronous communications, both byte-oriented and bit-oriented
protocols are supported. Cyclic Redundancy Codes (CRC) are used for error
detection to assure data integrity. Both the CRC-16 (X I6 + XIS + x 2 + 1)
and CRC-CCITT (X 16 + XI2 + X S + 1) error-checking polynomials are sup-
ported. The CRC generator (for transmit operations) and CRC checker (for
receive operations) may be preset to alII's or all O's.
Z8030 see 239
---
TxDA } SERIAL
RxDA _ DATA ADl ADo
AD6
AD3 AD2
ADs TRxCA - } CHANNEL
CONTROL 1- CSl
RxDB _ DATA
SYNCA
RTxCA
W/REQB
SYNCB
_CSo TRxCB - l CHANNEL RxDA RTxCB
iNT RTxCB _I CLOCKS
INTERRUPTI _l _ INTACK
lEI
SYNCB
W/REQB
_
CHANNEL CH·B
TRxCA
TxDA
DTR/REQA
RxDB
TRxCB
TxDB
l lEO DTR/REQB CONTROLS
FOR MODEM, RTSA DTR/REQB
RTSB DMA,OR
CTSB _ CTSA RTSB
Z8030 OTHER
DCDA CTSB
Z·SCC DC DB _
PCLK DCDB
+5 V
t tGND PCLK
BAUD RATE
GENERATOR
A
-I SERIAL DATA
DISCRETE
CONTROL
& STATUS
::===} MODEM,DMA,OR
OTHER CONTROLS
ADDRESSI ~-"~j A
DATA~
CPU INTERNAL BUS
BUS 1/0
CONTROL
DISCRETE
CONTROL
& STATUS
B
-} MODEM, DMA, OR
OTHER CONTROLS
INTERRUPT INTERRUPT
CONTROL CHANNEL B
CONTROL REGISTERS
LINES LOGIC
ttt
+5 V GND PCLK
CHANNEL B
BAUD RATE
GENERATOR
B
DATA
NRZ
\ / \
NRZI
\ / \
FM1
FM
MANCHESTER
FMO and FMl encoding, a transition occurs at the beginning of every bit cell.
In FMO encoding, a 0 is represented by another transition at the center of
the cell and a 1 is represented by no additional transfers in the cell. FMl en-
coding is the inverse; a 1 is represented by another transition at the center of
the cell and a 0 is represented by no further transitions in the cell. For NRZ
encoding, a 1 is represented by a high level and a 0 by a low level. In NRZI en-
coding, a 1 is represented by no change in level and a 0 by a change in level.
In addition, the SCC can decode Manchester (biphase level) encoded data.
Manchester data encoding always produces a transition in the center of the
cell. If the transition is from 0 to 1, the bit is a 0; if the transition is from]
to 0, the bit is a 1.
Each channel has its own baud rate generator consisting of a 16-bit pro-
grammable down counter. The output of the baud rate generator can be used
as a transmit clock, receive clock, or the input to the phase-Iocked-Ioop circuit.
The digital phase-Iocked-Ioop circuitry can be used to recover clock informa-
tion from NRZI, FMO, or FMl encoded data. This clock can then be used as
a transmit or receive clock.
Each SCC channel has three sources of interrupts: receive interrupts,
transmit interrupts, and external/status condition interrupts (in that priority
order). Channel A interrupts have priority over channel B interrupts. Each
interrupt has its own IP, IUS, and IE control bits. One interrupt vector is pro-
vided; that vector can be encoded with status information to identify the
interrupt source. A receiver can interrupt the CPU in three ways: interrupt
on the first received character or special receive conditions, interrupt on all
received characters or special receive conditions, or interrupt only on special
receive conditions. The special receive conditions include overrun, parity,
and framing errors and the end-of-frame condition (SDLC mode). The trans-
242 Z8000 Family Devices Chap. 12
mit interrupt is activated when the transmit buffer becomes empty. External/
status interrupts are caused by active levels on the CTS, DCD, or SYNC pins,
transmit underruns, a break condition (asynchronous modes), an abort se-
quence (SDLC mode), an end-of-poll sequence (SDLC loop mode), or a zero
count in the baud rate generator. Support is provided for DMA or CPU-con-
trolled high-speed data transfers.
Receive data are routed through a 3-byte FIFO buffer, providing ad-
ditional time for the CPU to service a receive interrupt. For each character
received, status information indicating if an error was detected while receiv-
ing that character is available; this status information is stored in its own 3-
byte FIFO. The transmit buffer is 20 bits long.
The SCC contains 14 write registers and nine read registers per channel.
Two other write registers are shared by both channels. The register configu-
rations are given in Fig. 12.27.
Z8065 BEP
The Z8065 Burst Error Processor (BEP) provides error correction and de-
tection for applications involving high-speed data transfers, such as high-per-
formance disk systems. The BEP can detect errors in data streams up to 585K
bits long and at data rates up to 20 megabits/second. The pin assignments for
the BEP are given in Fig. 12.28.
The BEP uses anyone of four different cyclic redundancy codes, called
Fire codes, to detect and locate errors (Table 12.5). Three different operations
can be performed: writing data, reading data, and correcting data. During
writes, the BEP computes a check word by dividing the data stream by the
selected polynomial; the remainder is a check code that is appended to the
data stream. When reading, the stream of data and check bytes is divided by
the polynomial to get a syndrome. If the syndrome is not 0, an error is de-
tected. Two read modes are provided, normal and high speed; the read mode
determines the correction methodology if an error is found. For all but the
48-bit polynomial, an error in the data stream can be located using one of two
methods, the "full-period clock around" method (normal reads) or the "Chi-
nese remainder theorem" method (high-speed reads). The "reciprocal poly-
56-bit 56 585,442 11
32-bit 32 42,987 11
35-bit 35 94,185 12
48-bit 48 13 X (2 35 - 1) 7
Addre ..es: 10000 Part A
00000 Part B
Write Regist er 3
10 7 10 .1
I ir . ,. .
0 5 10 I
r~ "M•• _ ~:: ;:~:
SYNC CHARACTER
ADDRESS SEARCH LOAD INHIBIT
Rx CRC ENABLE MODE (SOL C)
ERROR RESET
Addresses: 10100 Part IJ
RESET HIGHEST IUS 00100 Part B
NULL CODE
RESET Rx CRC
RESET Tx CRC CHECKER
RESET T U GENERATOR
x NDERRU
• B CHANNEL N/EOM LATCH
ONLY
W·
rite Register 1 Addresses: ~ 0001Part A
8 BIT SYNC CHARA
0001 Part B
I~I~I~I~I~I~I~I~I 16 BIT SYN CTER
o SDLC M C CHARACTER
~
Rx INT ON FIRST
OINT ON AL CHARACTER OR SP
Rx INT ON Rx CHARACTERS OR SPEECIAL
CIAL CONDITION
PECIAL CONDITION ONLy CONDITION
WAIT/DMA REQUEST ON
WAIT/DMA REQUEST RECEIVE/TRANSMIT
Write Register 5
DTR
Write Register 6
Addresses: 10110 Part A
~::t('IO'IO'IO'IO'1
00111 Part B
I I
"'~!i~~ ".!~~ !;=~~~l~
".: :g:- ~~. !::1:
•
I, I
;:1: :::1'
""e: :::1'
"".e,
....
I
:::1:
A~R AD..
ADR4
".
x 3 ADR2
x .1
'''0,
::'0,
NCo
ADRo
1
IF?~~~
SYNC,
SYNCs
SYNC,s
SYNC.
SYNC.
SYNC,.
SYNCs
SYNC,
SYNC"
SYNC.
SYNC,
SYNC"
SYNC,
SYNC,
SYNC"
SYNC,
SYNCo
SYNClO
SYNC,
x
SYNC.
SYNCo
x
SYNC.
MONOSYNC, 8 BITS
MONOSYNC, 6 BITS
BISYNC, 16 BITS
SYNC" SYNC,O SYNC. SYNC. SYNC, SYNC. SYNC, SYNC. BISYNC, 12 BITS
o 1 1 1 1 1 1 o SDLC
o
o
0
1
~ ~L """'' "'
NO RESET
CHANNEL RESET B
CO,
~!i:
' - - - - - - - - - TC,
LOWER BYTE OF
TIME CONSTANT
1 0 CHANNEL RESET A
1 1 FORCE HARDWARE RESET Write Register 13 Addresses: 11101 Part A
01101 Part B
~
I ~
L 6 BIT/8 Bll SYNC
LOOP MODE
ABORT~F=All ON UNDERRUN
UPPER BYTE OF
TIME CONSTANT
MARK/FLAll IDLE
GO ACTIVE ON POLL L.-_ _ _ _ _ _ _ TC,.
o 0 NRZ
o 1 NRZI
1 0 FMl (TRANSITION = 1)
Write Register 14
Addresses: 11110 Part A
1 1 FMO (TRANSITION = 0) 10,1 0.1 Os I 0.1 OJ I 0 10, I I
2 Do
01110 Part B
~~
' - - - - - - - - - - CRC PRESET I/O
L BR GENERATOR ENABLE
Write Register 11
L BR GENERATOR SOURCE
Addresses: 11011 Part A DTA/REQUEST FUNCTION
I0] 0 6 0.., 0 4 0] O2 0, Do I 01011 Pa,' B
AUTO ECHO
LOCAL LOOPBACK
o
o
1
0
1
0
1 0
o
1
1
0
1
0
1
TRxC OUT = XTAL OUTPUT
TRxC OUT = TRANSMIT CLOCK
TRxC OUT = BR GENERATOR OUTPUT
TRxC OUT = OPLL OUTPUT
TRxC 011
~
II ~ :'"000"''''
o 1 RECEIVE CLOCK = TAxc PIN
1 0 RECEIVE CLOCK = BR GENERATOR OUTPUT
~DCDIE
1 1 RECEIVE CLOCK = DPLL OUTPUT
SYNC/HUNT IE
CTS IE
Tx UNDERRUN/EOM IE
' - - - - - - - - - BREAK/ABORT IE
244
Z8065 BEP 245
~~
I ~ Rx CHARACTER AVAILABLE
~ !~ ~ : : " "
L ZERO COUNT
Tx BUFFER EMPTY
DCD
SYNC/HUNT
CTS
Tx UNDERRUN/EOM
' - - - - - - - - - BREAK/ABORT ' - - - - - - - - - ONE CLOCK MISSING
I0, . 0, ;0
5 : 0, i0 0, : 0, : Do I
3 :
00001 Part B
I0, !0,1 0, )0.1 0
3 : 0,1 0, ;Do I
01100 ParI B
~~llli
L
~1!:
ALL SENT
RESIDUE CODE 2
RESIDUE CODE 1
RESIDUE CODE 0
LOWER BYTE OF
PARITY ERROR TIME CONSTANT
Rx OVERRUN ERROR
CRC/FRAMING ERROR
' - - - - - - - - END OF FRAME (SDLC) ' - - - - - - - - - TC,
~::
' - - - - - - - - V,
'MODIFIED IN B CHANNEL
INTERRUPT VECTOR'
' - - - - - - - - TC,s
UPPER BYTE OF
TIME CONSTANT
I~!~I~I~!~!~!~I~I
00011 ParI B 01111 ParI B
I~!~I~I~I~!~!~!~I
~~~
~ CHANNELBEXT/STATIP'
~~
L CHANNEL B Tx IP'
CHANNEL B Rx IP'
CHANNEL A EXT/STAT IP' CDCDIE
~:"o""m"
CHANNEL A Tx IP' SYNC/HUNT IE
CHANNEL A Rx IP' CTS IE
o Tx UNDERRUN/EOM IE
o ' - - - - - - - - BREAK/ABORT IE
'ALWAYS 0 IN B CHANNEL
nomial" error-correction method is used with the 48-bit Fire code. These
correction algorithms extract the error pattern in the data stream for external
correction.
The major sections of the BEP are illustrated in Fig. 12.29. Data are input
to the BEP one byte at a time and divided by the appropriate polynomial in
the Polynomial Divide Matrix. The Register Array contains 56 flip-flops used
INPUT
DATA 1
LPo
ao
a,
a2
a3
a,
as
a6
a,
I DATA OUT-
CHECK BITS
+5V
a,
a3
a,
as
a6
a,
REP
Po
POL YNOMIAL {
SELECT ZB065 LP, P,
BEP } 'OCATED ERRO'
LP2 PATTERN SO
LP3 5,
FUNCTION {
SELECT ER ERROR
Co
C,
AE ALIGNMENT EXCEPTION
READ ERROR P,
PATTERN EP ERROR PATTERN
P3
Po PM2 C,
PM3 } PATTERN MATCH
POLY NO. . .' { Do
SHIFT CONTROL PM,
0,
02
+5 V GND CP MR
+5V
~
STATUS LOGIC
RESET(MR)
1
ALIGNMENT MONITOR ALIGNMENT EXCEPTION (A E)
CLOCK (CP)
t ERROR PATTERN DETECTOR ERROR PATTERN (EP)
.... ....
FUNCTION
SELECT (C2-CO) I 3 -\ PATTERN MATCH MONITORS 3 PATTERN MATCH (PM,-PM2)
-y Y y
READ ERROR
PATTERN (REP)
1- - - - -lI- ---- "I
I
~
CONTROL I DATA OUT
LOGIC B
j.. I ~ -y (a,-ao)
POLYNOMIAL SHIFT
CONTROL (P3-PO)
[ 4
REGISTER
ARRAY I ....
-y -y LOCATED ERROR
I 4 ) PATTERN (LP3-LPo)
A I -y
n
POLYNOMIAL
I 2 I
SELECT (5,-50)
-y I I
I I
11
I I
I ~ I
DATA IN
Ir POLYNOMIAL
DIVIDE MATRIX
I
I
I
(0,-00) I B
I'" I
SELECTABLE POLYNOMIAL I
I DIVIDERS I
L ___________ -.J
246
Z80680CP 247
for check bit computation and error pattern extraction. The Control Logic
contains the timing, gating, and reset circuitry for the device.
Z8068 DCP
- Z8068 SPo
AUXILIARY { ASTB DCP .
CONTROL AFlG SPI
AUXo SLAVE
PORT
AUXI
(DATA)
AUX2
AUXILIARY AUX3
PORT AUX4
AUX5
AU X6 C/K CONTROL/KEY
AUX7 PAR PARITY
+5 V GND ClK
M Po-M P7
,,8
---+a- MASTER
PORT
~1
"
MCS •
AS
MDS
t
MASTER
PORT
CONTROL f- -
t
MODE STATUS
AND
COMMAND
,,8
r---- MUX f-
11
IVE
REG.
IVD
REG.
MICRO·
PROGRAMMED
MACHINE
CLK
LOGIC REGISTERS
MPLG
""-~ --
MR/W
+ ~
J-
SPa.LSP7 INPUT
SLAVE
PORT REGISTER
8
I
j
SCS
~
SLAVE
SDS PORT ALGORITHM
CONTROL PROCESSOR
SFLG LOGIC
~ I I
AUXO-~UX7
8
AUXILIARY
PORT
"
8
OUTPUT
REGISTER
MASTER
KEY
II It D
KEY
E
KEY
t
ASTB AUXILIARY
I
t tt t
PORT
AFLG CONTROL
LOGIC
ing device in a single-port configuration (the master port is used for both clear
and encrypted data) or a dual-port configuration (the master port is used for
clear data and the slave port for encrypted data, or vice versa). Input, output,
and ciphering of data are performed concurrently, thereby maximizing data
throughput. The input and output registers each hold 8 bytes and data are
encrypted or decrypted in 64-bit blocks.
Z8052 CRTC
acters and their attributes are stored in a 132 X 22 buffer. Simple line graphics
also can be implemented with the line attributes provided. The CRTC can be
operated in a slave mode that allows expansion of the character buffer using
multiple CR TCs.
Z8016 DTC
BAI 48 lEO
BUSRQ 47 iNf
i3AO 46 lEI
Vee 45 CLOCK
ADO 44 AS
AD1' 43 OS
AD2 42 CS/WAl'f
AD3 41 R/W
AD4 40 DACK2
ADS 10 39 DACKl
AD6 11 38 EOP
AD7 12 37 DREQ2
Z8016
AD8 13 DTC 36 DREQl
AD9 14 35 B/W
15 34 ST3
AD11 16 33 ST2
AD12 17 32 STl
AD13 18 31 STO
AD14 19 30 N/S
20 29 SNO
SN6 21 28 SNl
22 27 SN7/MMU SYNC
23 26 Vss
grammed via I/O commands from the CPU; these signals are outputs when the
DTC has control of the bus so that the DTC can control data transfers on the
bus. The BAI, BAO, and BUSRQ signals are used to interface the DTC to a
bus request daisy chain, as described in Chapter 7. lEI, lEO, and INT signals
are available for attaching to an interrupt daisy chain; interrupt acknowledges
are decoded internally from the STO-ST3 inputs. The DMA request signals
(DREQ1 and DREQ2, one for each channel) are inputs that can be used to
initiate a DMA operation with an external signal. The DMA acknowledge sig-
nals (DACK1 and DACK2) indicate when a channel is performing a DMA op-
eration. The end-of-process (EOP) signal is a bidirectional line that the DTC
uses to signal the end of a DMA operation. An external device (such as the
MMU's SUP signal) also can terminate a DMA operation by pulling the EOP
line low. The CS /W AIT pin is used as a chip select when the DTC does not
control the bus for sending commands to the DTC. When the DTC does con-
trol the bus, this pin is a WAIT input for controlling the timing of memory
and I/O accesses initiated by the DTC.
In a system containing Z8010 MMUs, the Z8016 DTC can be used in two
different manners. The DTC can be connected directly to the memory con-
trol logic and deal with physical memory addresses (Fig. 12.33) or the DTC
can be interfaced to memory through the MMUs and use logical memory ad-
dresses (Fig. 12.34). For logical addresses, the DTC uses the SNO-SN6 and
ADO-AD15 lines for the 23-bit logical address; the MMU Sync signal is sent
t. r---
CPU MMU
r-
~ MEMORY
-
OTC
-
Figure 12.33 System with the DTC
using physical memory addresses.
CPU
-
r-
1'\
~
I'"
MMU
. MEMORY
-
OTC
-
Figure 12.34 System with the DTC
using logical memory addresses.
Z6132 RAM 251
to the MMU's DMA Sync input to allow the MMU to differentiate between
CPU- and DTC-controlled memory accesses. For physical addresses, the ADO-
AD15 lines hold the 16 least significant bits and the SNO-SN7 lines hold the
8 most significant bits of the physical memory address.
DTC-controlled data transfers can be byte or word oriented. The DTC
can be programmed to perform byte/word funneling for transfers between
byte or word peripherals and/or memory. For transfers between a byte source
and a word destination, two bytes are read in consecutive accesses from the
source and sent as a word to the destination. For transfers between a word
source and a byte destination, the word is read from the source and sent to
the destination with two consecutive byte writes.
Pattern match capability is included in the Z8016, allowing search and
transfer-and-search operations. Search operations read data from the source
until a match to the specified pattern is found. Transfer-and-search operations
transfer data between a source and destination until the specified data pattern
is encountered.
The DTC provides for wait states during transactions with slow memories
or peripherals under both hardware and software control. In addition to the
hardware WAIT signal, the DTC can be programmed to automatically insert
zero, one, two, or four wait states when accessing a particular source or des-
tination device.
The Z8016 contains 20 status and control registers in each DMA chan-
nel. Three additional registers are used to control the overall operation of the
device. To minimize CPU overhead, the DTC can be programmed to load
many of its own registers from memory via DMA operations; the CPU only
has to load the memory address of the control parameter table and issue a
command to start this operation. This operation also can be performed at the
end of some other DMA process, allowing the DTC to automatically chain its
own operations without CPU intervention. Alternatively, the DTC can be
programmed to interrupt the CPU at the termination of a DMA operation.
Z6132 RAM
26 22 27 20
~ os~
AC WE
~
cs
BUSY
V BB
10 Ao
A7
BUSY _ 1 A6
As
A4
V BB
A3
Z6132 A2
RAM
A1
A7 +5V _ 2 8
Ao
25 As
Do
01
GND _ 1 4
21 A 10 O2
23 A11 GND
Do 0 1 O2 0 3 0 4 05 0 6 0 7
11 12 13 15 16 17 18 19
accesses, address input AO selects one of the two blocks; meanwhile, the other
block is refreshed using the refresh counter.
The timing of Z6132 memory accesses is described briefly in Chapter 3.
A memory cycle starts on the rising edge of address clock (AC); this edge
+ t
CLOCK
,;
MUX
INPUT
ADDRESS
BUFFERS
- ROW
DECODER
(1 OF 128)
128 SENSE AMPLIFIERS
- ~
>-----
- MEMORY ARRAY r----
.--....
~ 1-
~
SENSE
COLUMN DECODER AMPLI-
DATA
7 (1 OF 16)
x8 DATA BUS
FIERS
AND
1/0
DRIVERS
¢~ 1/0
BUFFERS R
t
~
MEMORY ARRAY -
AO-
~
MUX
INPUT
ADDRESS
BUFFERS
- ROW
DECODER
(1 OF 128)
128 SENSE AMPLIFIERS
CLOCK
GENERATOR
- MEMORY ARRAY
REFRESH
DEMAND
LOGIC
(CYCLE
COUNTER)
latches the chip select (CS), write enable (WE), and AD signals. If the chip is
not selected (CS high), all other inputs are ignored for the remainder of the
cycle and both memory blocks in the chip are refreshed using the 7 -bit refresh
counter. If the chip is selected (CS low), the AD-All inputs are latched in-
ternally, where AD determines the block addresses by A1-A11. If WE is high,
indicating a read cycle, a subseqent low level on the data strobe (DS) input
activates the DD-D7 data outputs after a specified delay from the rising edge
of AC or falling edge of DS, whichever comes later. Thus DS is used as an
output enable during read operations. If WE is low, indicating a write cycle,
the falling edge of DS loads the data on the DD-D7 inputs into the addressed
memory location (Figure 12.37).
Every dynamic memory cell in the Z6132 must be refreshed at least
every 2 ms. Each of the two memory blocks contains 16,384 cells and requires
AC
CS
WE
00-07
___7
_ _ _ _ TRI.STATED _ _ _-( D'V:LI~UT
'---
»)-___
os
\-----1
Z6132 READ TIMING
AC \ I
CS \ /
WE \ I
00-07 ----------------~(~_ _
DC_It_16_N_ _)~-----
os
\-----1
Z6132 WRITE TIMING Figure 12.37 Z6132 timing.
254 Z8000 Family Devices Chap. 12
128 refresh cycles to completely refresh the block. Two user-selectable refresh
modes are provided, the long-cycle-time mode and the short-cycle-time mode.
The long-cycle-time mode is selected by pulling the BUSY pin low. In
this mode, every memory cycle is followed by a refresh operation on both
blocks of memory in the Z6132. There must be at least 128 address clock
(AC) signals in any 2-ms period. The long-cycle-time mode is most practical
in applications where the cycle time exceeds 700 ns.
The short-cycle-time refresh mode is selected by pulling the BUSY pin
high through a pull-up resistor. In this mode, the Z6132 performs a refresh
operation on the memory block that is not being accessed. If the chip is not
selected (CS high), both blocks are refreshed. If the chip is selected, only the
block that is not addressed by AO is refreshed; the refresh occurs simulta-
neously with the access of the other block. This scheme takes advantage of the
sequential nature of most memory addressing; normally, this odd/even refresh
scheme will provide 128 refresh operations to each block within 2 ms. In the
unlikely event of 17 consecutive all odd (AO = 1) or all even (AO = 0) acces-
ses, the refresh operation will automatically request one long memory cycle
to append a refresh operation to the appropriate block. The BUSY line is
pulled low during this cycle; the BUSY pins from all the system's Z6132's
can be OR-tied together and fed into the CPU's WAIT input. This is the re-
fresh method appropriate for most Z8000-based systems.
Thus the Z6132 is well suited for microprocessor applications where its
byte-wide organization, self-refresh capability, and Z-Bus interface logic serve
to simplify design and reduce system's parts count.
13
Z-Bus M;crocolf1puters
Z8 ARCHITECTURAL OVERVIEW
Figure 13.1 shows the pin-out of the Z8601, one member of the Z8 family of
single-chip microcomputers. The Z8601 has four 8-bit I/O ports (ports 0, 1,
2, and 3), address strobe (AS), data strobe (DS), and read/write (R/W signals
for interfacing to memory external to the Z8, and two pins (XTAL1 and
XTAL2) for connecting a series-resonant crystal or single-phase clock (8 MHz
maximum) to an on-chip oscillator. The processor runs at one-half the speed
of the external crystal or clock (that is, 4-MHz maximum internal clock).
A block diagram of the Z8601 is given in Fig. 13.2. On-board memory
consists of 2K bytes of mask-programmable ROM and 144 byte registers,
including 124 general-purpose registers, 4 I/O port registers, and 16 status
255
RESET +5V
+5V P3 6
R/W GND
XTAL2 P3,
OS XTALl
XTALl P2,
AS XTAL2
P3, P2 6
POO P2 0
P3 0 P2 5
PO, P2,
RESET P2,
P0 2 P2 2
PORT 2 R/W P2 3
P0 3 P2 3 (BIT PRO· OS P2 2
PO, P2, GRAMMABLE)
AS P2,
P0 5 P2 5
Z8601 P3, P2 0
P0 6 MCU P2 6
GND P3 3
PO, P2,
P3 2 P3.
Pl 0 P30
POO Pl,
Pl, P3,
PO, P1 6
P1 2 P3 2
P0 2 P1 5
P1 3 P3 3
P0 3 Pl.
Pl. P3.
PO. P1 3
P1 5 P3 5
P0 5 P1 2
P1 6 P3 6
P0 6 Pl,
Pl, P3,
PO, Pl 0
M/L.o----!-!-----'\~~
UART
FLAGS
TIMER/
COUNTERS
(2)
REG. POINTER
INTERRUPT
CONTROL
PORT 2
It!lt!!!I/O
(BIT PROGRAMMABLE)
ADDRESS OR I/O
(NIBBLE PROGRAMMABLE)
ADDRESS/DATA OR I/O
~YTEPROGRAMMABL~
256
Z8 Architectural Overview 257
41/0 PORTS
NO EXTERNAL MEMORY
OJ
OJ
31/0 PORTS
program memory and 256 bytes of data memory external to the ZS. For a
more memory intensive application, the lower 4 bits of port 0 can provide 4
more bits of address to external memory; when combined with port 1, 12
address lines to external memory allow an interface to 4K bytes of program
memory and 4K bytes of data memory external to the ZS (Fig. 13.5). Ports
2, 3, and one-half of port 0 are still available as I/O pins. In a very memory
intensive application, all of ports 0 and 1 can be used to access external mem-
ory. This results in 16-bit addresses to external memory, allowing 62K bytes
2110 PORTS
of program memory and 62K bytes of data memory external to the Z8 (Fig.
13.6). (The first 2K of addresses, 0 to 7FF hexadecimal, are reserved for the
on-board ROM.) Thus the Z8 can handle a wide range of both memory-
intensive and I/O-intensive applications.
Z8 MEMORY SPACES
5535
EXTERNAL
ROM OR RAM
2048
2047
ON·CHIP
Location of ROM
first byte of
Instruction
~ ~------------
executed
atter reset
11 IR05
10 IROs
9 IR04
8 IR04
7 IROa
Interrupt
Vector 6 IR03
(Lower Byte)
s~ IR02
4p.o- IR02
Interrupt
Vector a IR01
(Upper Byte)
2 IR01
1 IROO
0 IROO
Figure 13.7 Z8 program memory.
Data memory, on the other hand, can hold only data; instruction fetches
access only program memory. Data memory is always external to the ZS chip
(Fig. 13.S); up to 62K bytes of data memory can be included in a system,
depending on the configuration of ports 1 and O. Separate program and data
areas in external memory are implemented by programming bit 4 of port 3 to
be the data memory select (DM) signal. When the line is low, data memory
is being accessed; when DM is high, program memory is being accessed. Thus
the DM signal can be used as part of the chip select logic to external memory
to segregate the program and data memory areas (Fig 13.9). The state of the
65535 r__----------,
EXTERNAL
DATA
MEMORY
~g:~ J - - - - - - - - - - - I
NOT ADDRESSABLE
~
A
PORTS PROGRAM DATA
0+1
'l
ADDRESS/DATA BUS
, MEMORY MEMORY
Z8 cs cs
NOT
IMPLEMENTED
127
GENERAL·PURPOSE
REGISTERS
PORT 3 P3
PORT 2 P2
PORT 1 P1
PORT 0 PO
Figure 13.10 Z8 registers.
262 Z-Bus Microcomputers Chap. 13
127
--1
-~1
-~1
-~1 The lower
nibble 01
the register
file address
SPECIFIED WORKING·
REGISTER GROUP "'-r-- provided by
1 the Instruction
points to the
specified
-~1
register.
-~1 15
-~1 r--------------3
110 PORTS
Figure 13.11 Z8 register pointer.
cumulators, address pointers, or index registers. The status and control regis-
ters are used to configure the Z8 's programmable options and to hold status
information, such as the state of the ALU flags.
Z8 registers can be accessed directly or indirectly using 8-bit register ad-
dresses. However, one of the control registers (R253, the Register Pointer) al-
lows 4-bit register addresses, resulting in shorter and faster instructions. The
registers are divided into nine groups of 16 registers each (Fig. 13.11). The Reg-
ister Pointer holds the starting address of one of these nine groups; the 16
registers in the specified group are called "working registers" and can be ac-
cessed with 4-bit register addresses.
Either the internal register file or external data memory can be used to
hold the Z8's stack. An 8-bit stack pointer (R255) is used if the stack is in
the registers; a 16-bit stack pointer (R254 and R255) is used if the stack is in
data memory.
The Z8 's flags consist of carry, zero, sign, overflow , half-carry, and deci-
mal-adjust flags, just as in the Z8000. These flags are held in register R252.
Z8 I/O PORTS
The Z8 's 32 I/O lines are configured as four 8-bit parallel I/O ports, called
ports 0, 1, 2, and 3. The ports also can be programmed to provide an inter-
Z8 I/O Ports 263
face to external memory, serial I/O, handshakes for parallel I/O, status sig-
nals, access to the counter/timers, or interrupt request inputs.
Port 1 can be configured as a byte I/O port or as a time-multiplexed
address/data bus to external memory. As an I/O port, port 1 can be a byte of
input or a byte of output. Optionally, transfers with this port can be con-
trolled by a two-wire interlocked handshake; bits 3 and 4 of port 3 provide
the handshake signals. The port is accessed via reads and writes to register R 1.
To interface to external memory, port 1 must be configured as an 8-bit
time-multiplexed address/data bus. The AS, DS, and R/W signals are used to
control data transfers on this bus. Port 1 and these control signals can be
placed in a high-impedance state to allow bus sharing in Z8 systems.
Port 0 can be used as a nibble-programmable I/O port or as additional
address lines for interfacing to external memory. When configured as an I/O
port, the two nibbles of port 0 can be independently programmed as inputs
or outputs. Optionally, bits 2 and 5 of port 3 can provide an interlocked
handshake for port 0 I/O operations; the direction of the handshake is the di-
rection of port O's upper nibble.
For external memory interfacing, port 0 can provide four additional ad-
dress lines (lower nibble only) or eight address lines (both nibbles). If only
the lower nibble is required for memory addressing, the upper nibble still can
be used for I/O. The port 0 lines defined as address bits can be placed in the
high-impedance state along with the port 1 pins for bus-sharing applications.
The configuration of ports 0 and 1 is controlled by register R248, the
Port 0-1 Mode register (Fig. 13.12).
When external memory is included in a Z8 system, ports 1 and 0 are con-
figured to provide the desired number of address bits. The timing for external
memory accesses is the standard Z-Bus timing, as illustrated in Fig.13.13. The
clock shown is the external clock (8 MHz maximum); the processor runs at
one-half that speed. During Tl, the address is emitted and AS is pulsed; the
R248 POIM
Port 0 and I Mode Register
(F8H; Write Only)
OUTPUT = 00
INPUT = 01
~
PO,-P0 7 MODE:]_
I [ "80P~,~u",~~,
01 = INPUT
A 12 -A 15 = 1X 1X = A.-An
EXTERNAL MEMORY TIMING STACK SELECTION
NORMAL = 0 o = EXTERNAL
EXTENDED = 1 1 = INTERNAL
P1 o-P1 7 MODE
00 = BYTE OUTPUT
01 = BYTE INPUT
10 = ADo-AD7
11 = HIGH-IMPEDANCE ADo-AD7,
AS, Os, R/Vi, Aa-A11, A12-A15
IF SELECTED
I· MACHINE CYCLE ·1
I Tl T2 T3
I
CLOCK
PO
X As-AI5
x=
P1
X Ao-A7 ) ~
AS
'---l '----
DS
\ I
R/v.;
7
I' READ CYCLE
PO
X As-AI5
x=
P1
X Ao-A7
X Do-D 7OUT
x=
'--I '--
DS
\ /
R/W
\
f.---------WRITE CYCLE---------I
address and R/W signal are guaranteed valid on the rising edge of AS. During
T2, the multiplexed portion of the bus (the port 1 pins) is cleared of the ad-
dress. For reads, DS is lowered in anticipation of receiving data from mem-
ory; for writes, the data are emitted before DS goes active. During T3, the
data are read into the CPU or the write is completed. The rising edge of DS
marks the end of the data transfer. For a 4-MHz system, the worst-case mem-
ory access time would be 320 ns. As an option, extended memory timing can
be selected by setting bit 5 of the Port 0-1 Mode register. With extended mem-
ory timing, one wait state is inserted between T2 and T3 of each external
28 Counter/Timers 265
R246 P2M
Port 2 Mode Register
(F6H ; Write Only)
R247 P3M
Port 3 Mode Register
(F7H; Write Only)
~~
O1 PORT
PORT 2 PULL·UPS OPEN DRAIN
2 PULL·UPS ACTIVE
RESERVED
o P32 INPUT P35= OUTPUT
1 P32 DAVO/RDYO P35 = RDYOIDAVO
o 0 P33 INPUT P34 = OUTPUT
~ ~} P33 INPUT P34 • OM
1 1 P33 DAV1/RDY1 P34 ~ RDY1/DAVj
memory access, thereby increasing the access time by a full clock period of
the internal processor clock.
Port 2 is always a bit-programmable I/O port wherein each bit can be in-
dividually programmed as an input or output line using R246, the Port 2
Mode register (Fig. 13.14). Any pins defined as outputs can be active or open-
drain outputs. Optionally, bits 1 and 6 of port 3 can provide an interlocked
handshake for port 2; the direction of the handshake is the direction of bit
7 in port 2.
Port 3 consists of four input pins (bits 0-3) and four output pins (bits
4-7). These pins can be used as I/O lines or control signals, as determined by
R247, the Port 3 Mode register (Fig. 13.15). Port 3 pins can provide the hand-
shake signals for the other ports, serial I/O lines (bit 0 for serial in, bit 7 for
serial out), timer input and output signals, four external interrupt requests,
and the data memory select (DM) signal.
Z8 COUNTER/TIMERS
R242 TI R244 TO
Counter Timer 1 Register Counter/Timer 0 Register
(F2H ; Read/Write) (F4H; Read/Write)
I0 7 t 0 6 t Os t D. t 0 3 t O2 t 0, t Do I I0 7 t 0 6 t Os t D. t 0 3 t O2 t 0, t Do I
T, INITIAL VALUE (WHEN WRITTEN) To INITIAL VALUE (WHEN WRITTEN)
~--- (RANGE 1 256 DECIMAL 01 00 HEX) ' - - - - ( R A N G E : 1 256 DECIMAL 01 00 HEX)
T, CURRENT VALUE (WHEN READ) To CURRENT VALUE (WHEN READ)
I0 7 \ I I
0 6 \ Os \ 0.1 0 3 10 2 1 0, Do I 0 7 /0 6 / Os 0./ 0 3 / O2 / 0, / Do
t I
[ C~~NJ, ~~~ELE.PASS
l
COUNT MODE
o = To SINGLE·PASS
1 = T, MODULO·N 1 = To MODULO·N
CLOCK SOURCE
1 _c T, INTERNAL
o T, EXTERNAL TIMING INPUT RESERVED
(T,N) MODE
R241 TMR
Timer Mode Register
(FI H ; Read/Write)
NOT TOUT
~~ 0
1 = NO FUNCTION
LOAD To
DISABLE To COUNT
1 - ENABLE To COUNT
0 = NO FUNCTION
EXTERNAL CLOCK INP'OT = 00 1 = LOAD T,
GATE INPUT = 01 0 = DISABLE T, COUNT
TRIGGER INPUT = 10 1 = ENABLE T, COUNT
(NON·RETRIGGERABLE)
TRIGGER INPUT = 11
(RETRIGGERABLE)
driven by the internal processor clock divided by 4 (that is, a I-MHz clock if
an 8-MHz external crystal is used); Tl can be driven by this internal clock or
an external signal from port 3, bit 1. Bit 1 of port 3 can be used as a gate or trig-
ger for Tl, also. Either counter/timer can generate an interrupt at the end-of-
count condition and/or have its output routed to bit 6 of port 3, which tog-
gles at the end-of-count. Thus the counter/timers can be used for a variety
of applications, including event counters, watch-dog timers, delay timers, and
square-wave generators.
The 6-bit prescaler is a clock divider that can divide the input clock to
the counter/timer by any value from 1 to 64. The output of the prescaler
Z8 Interrupts 267
drives the down-counter, decrementing the count. The current count can be
read at any time without disturbing the counting process. Either single-cycle
mode (counter stops upon reaching zero) or modulo-n mode (the counter
reloads the initial count value upon reaching end-of-count) can be specified.
Z8 SERIAL 1/0
Z8 INTERRUPTS
The Z8 provides for six different interrupts from eight possible sources: the
four port 3 inputs, the two counter/timers, the UART's receiver, and the
UART's transmitter (Table 13.1). Three registers control the interrupt
structure: the Interrupt Priority, Interrupt Request, and Interrupt Mask reg-
isters (Fig. 13.17). The Interrupt Mask register globally or individually enables
or disables the six interrupt requests. When more than one interrupt is pend-
ing, the contents of the Interrupt Priority register determines which interrupt
request is serviced first.
The Z8's interrupt processing mechanism is diagrammed in Fig. 13.18.
The appropriate bit in the Interrupt Request register is set when the event
corresponding to that interrupt request occurs. If that interrupt is enabled
in the Interrupt Mask register, interrupt processing begins at the end of the
current instruction's execution. The Interrupt Priority register is used to de-
termine priority in the case of simultaneous requests. The current program
counter and flags (R252) are pushed onto the stack, interrupts are disabled,
and the service routine pointed to by the appropriate interrupt vector is exe-
cuted. The six interrupt vectors are in the first 12 bytes of program memory.
TABLE 13.1 Z8 INTERRUPT REQUESTS
Vector location
Name Source in program memory Comments
R2491PR
Interrupt Priority Register
(F9 H ; Write Only)
"',"VEO
IR03, IROS PRIORITY (GROUP A)
=:J I INTERRUPT GROUP PRIORITY
RESERVED c 000
C > A :> B 001
o = IROS :> IR03 A;> B :> C ' 010
1 = IR03 > IROS A> C > B = 011
B > C > A = 100
IROO, IR02 PRIORITY (GROUP B) C> B :> A = 101
o = IR02 :> IROO - - - - - - - ' B > A :.> C ~, 110
1 = IROO > IR02 RESERVED = 111
IR01, IR04 PRIORITY (GROUP C)
o = IROl :> IR04 ---------1
1 ~. IR04 > IROl
R250 IRQ
Interrupt Request Register
(FAH; Read/Write)
I~I~I~I~I~I~I~I~I
RESERVED ==r- ,'----- IROO
IROl
= P32 INPUT (Do = IROO)
= P33 INPUT
IR02 = P3l INPUT
IR03 = P30 INPUT, SERIAL INPUT
IR04 = To, SERIAL OUTPUT
IROS = Tl
R25IIMR
Interrupt Mask Register
(FBH ; Read/Write)
Il------- 1 ENABLES
(Do = IROO) IROO-IROS
RESERVED
268
Z8 I nstruction Set 269
r------------------------------------l
I INTERRUPT SOURCES I
I
IR03 IR04
I IROO
(P3 2)
IR01
(P3 3)
IR02
(P3 1) I
(P3.
s,Nf
(To.
Sour)
IR05
(T 1)
I I
I I
I I
I I
I INTERRUPT MASK REGISTER
IL ____________________________
.
II
~~RUPTLOGI~
64Kr----""'I
SELECT
INTERRUPT
VECTOR
INTERRUPT
SERVICE
ROUTINE
0'---_ _.....
Z8 PROGRAM MEMORY
Z8 INSTRUCTION SET
The Z8's assembly language instruction set is optimized for high code den-
sity and fast execution time. The Z8 features 43 instruction types and six
operand addressing modes.
270 Z-Bus Microcomputers Chap. 13
Load
CLR dst Clear
LD dst, src Load
LDC dst, src Load Constant
LDE dst, src Load External Data
TABLE 13.2 Z8 Instruction Set (Continued)
271
272 Z-Bus Microcomputers Chap. 13
Z8 CONFIGURATIONS
typing version of the Z8611 with all memory external to the chip; the Z8613
is the 40-pin Protopak version of the Z8611.
The Z8681 is a "ROMless" version of the Z8 with no program memory
on board the device. Port 1 is always configured as an address/data bus to
external memory; port 0 is still nibble-programmable as I/O or additional ad-
dress lines. Therefore, the Z8681 can address up to 64K of program memory
and 64K of data memory.
The Z8671 microcomputer is a Z8601 with a BASIC interpreter and de-
bugger already programmed into the 2K bytes of mask-programmable ROM.
The BASIC language used is a subset of Dartmouth BASIC.
Z8000-Z8 INTERFACING
MEMORY
en
~
m
N
CIO
OR ONE
,, _ _ _-', PORT
FlO OTHER 6~ ~gMORY
PORTS " - _ _~I DEVICES
Z8
OTHER
110
DEVICES
A
Z8000
CPU
'I
BUSREQ BUSAK
MEMORY
Y
en
~
m
N
... OTHER
110
y DEVICES
PORT 3
A
Z8 PORTS
0+1
'l
274
UPC Architectural Overview 275
one port 3 input bit is the bus acknowledge. Ports 0 and 1 are defined as an
address/data bus to external memory; these are normally held in the tri-state
mode. When the Z8 gains control of the bus via a bus request, it can make byte
access to the Z8000's memory using LDC, LDE, PUSH, or POP instructions.
When the Z8 is not using the Z8000's bus, the Z8 still can be executing from
its internal ROM.
-- AD7 P17
---
----
AD6 P16
ADs P1s
TIM~~: J -
-
-ADO
AD2
AD,
AS
P10-
Z8090
AND RESET \ - os Z·UPC ::: - } PORT 3
f -R/W P3,_
CONTROL I- cs P36
WAIT P27_
iNT OR P35 P26-
MASTER _ INTACK OR P32 P2s-
+5V_
PCLK_
GND_
---
'"m HOST CPU
Z·UPC MICROCOMPUTER
INTERFACE
---
INTERFACE
PROGRAM
MEMORY
PORT
1
1-}1I0
REGISTERS 2K x 8
ADO-AD7
(PART OF REGISTER
FILE)
-
AS-
RP
OS BUS 110
Z·BUS TO TIMING
R/W_ AND
MASTER IRP
CS CONTROL
CPU
WAIT
REGISTER
FILE
256 x 8
L. _ _ _ _ _ - ,
INT P3 5
-
INTACK
lEO 3 1/2
P32 PORT
I E I _ P30
P37
3
(I/O FUNCTION
IS OPTIONAL)
+5 V GND PCLK
clock input. Optionally, one-half of port 3 can be used as the interrupt signals
(INT, INTACK, lEI, and lEO) for the Z-Bus interface. The maximum clock
frequency is 4 MHz; the UPC's clock does not need to be synchronized to the
master CPU's clock.
A block diagram of the Z8090 is given in Fig. 13.23. The Z8090's mem-
ory consists of 2K bytes of mask-programmable ROM and 256 byte registers,
including 234 general-purpose registers, 19 status and control registers, and 3
I/O port registers. Ports 1 and 2 are bit-programmable; port 3 consists of 4
input bits and 4 output bits. Port 3 pins can be used for special control func-
tions, including an interrupt interface to the master CPU, handshakes for ports
1 and 2, and interrupt request inputs for the UPC. Unlike the Z8, no mech-
anism is provided for in terfacing to memory external to the Z8090. The UPC's
two programmable counter/timers are identical to those in the Z8. The UPC's
instruction set also is identical to that of the Z8.
Two different memory address spaces are available in the UPC, program mem-
ory and the registers.
The Z8090 UPC contains 2K bytes of mask-programmable ROM for pro-
gram memory (that is, memory for holding program code). The UPC's pro-
gram counter is 16 bits long; however, performance at program addresses
above 2K is not defined. The first 12 bytes of program memory are reserved
for six 16-bit interrupt vectors (Fig. 13.24). Resetting the UPC forces the pro-
gram counter to location 12, the first program memory location available for
user's code.
The UPC's 256-byte register file consists of 234 general-purpose regis-
ters, 3 I/O port registers, and 19 status/control registers (Fig. 13.25). I/O
ports are accessed via reads and writes to registers 1, 2, and 3. The general-
20 47
LOCATION OF USER
FIRST BYTE OF ROM
INSTRUCTION
EXECUTED AFTER .........
RESET r---....
12
11
" IROS LOWER BYTE
10 IR05 UPPER BYTE
9 IR04 LOWER BYTE
8 IR04 UPPER BYTE
7 IR03 LOWER BYTE
6 IR03 UPPER BYTE
5 IR02 LOWER BYTE
4 IR02 UPPER BYTE
3 IR01 LOWER BYTE
2 IR01 UPPER BYTE
1 IROO LOWER BYTE Figure 13.24 UPC program mem-
0 IROO UPPER BYTE
ory.
278 Z-Bus Microcomputers Chap. 13
IDENTIFIER
LOCATION (UPC Side)
FFH STACK POINTER SP
FEH MASTER CPU INTERRUPT CONTROL MIC
FDH REGISTER POINTER RP
FCH PROGRAM CONTROL FLAGS FLAGS
FBH UPC INTERRUPT MASK REGISTER IMR
FAH UPC INTERRUPT REQUEST REGISTER IRQ
F9H UPC INTERRUPT PRIORITY REGISTER IPR
F8H PORT 1 MODE P1M
F7H PORT 3 MODE P3M
F6H PORT 2 MODE P2M
F5H To PRESCALER PREO
F4H TIMER/COUNTER 0 To
F3H T1 PRESCALER PREl
F2H TIMER/COUNTER 1 T1
F1H TIMER MODE TMR
FOH MASTER CPU INTERRUPT VECTOR REG. MIV
EFH
GENERAL-PURPOSE REGISTERS
6H
5H DATA INDIRECTION REGISTER DIND
4H LIMIT COUNT REGISTER LC
3H PORT 3 P3
2H PORT 2 P2
lH PORT 1 Pl
OH DATA TRANSFER CONTROL REGISTER DTC
Figure 13.25 UPC register file.
The UPC's 24 I/O lines are organized as three 8-bit parallel ports, ports 1, 2,
and 3. Their configuration is determined by the three I/O port mode registers
CPU-UPC Communication 279
II L: :: : :::~~::: ::::::::
P1o-P17 I/O DEFINITION
' - - - - - 0 DEFINES BIT AS OUTPUT
1 DEFINES BIT AS INPUT
1 PORT 1 PULL·UPS ACTIVE
o P35 = OUTPUT
R246 P2M 1 P35 =
INT
RESERVED
Port 2 Mode Register
' - -_ _ _ 0 P33 = INPUT P34 = OUTPUT
Z- UPC register address (Hex): F6 1 P33 = DAV1/RDY1 P34 = RDY1IDAV1
ID71 0 6 10 10 1D31 0 210, IDo I
5 4 '------ ~ ~~: ~ ~:V~iR~~J
P36 = OUTPUT (TOUT)
P36 = RDY2IDAV2
I
L - .- - -
P2o-P27 I/O DEFINITION
0 DEFINES BIT AS OUTPUT
' - - - - -_ _ ~ ~~~ ~ :~tUT P37 = OUTPUT
P37 = lEO
1 DEFINES BIT AS INPUT
'-------- ~ ~~~ ~ :~~~6K
Figure 13.26 Port Mode registers.
(Fig. 13.26). Ports 1 and 2 are bit-programmable ports wherein each bit can
be individually programmed as an input or output. Each bit specified as an
output can be an active or open-drain output. Optionally, bits 3 and 4 of
port 3 can be interlocked handshake signals for port 1 and bits 1 and 6 of
port 3 can be the handshake signals for port 2.
Port 3 always has 4 input and 4 output bits. Bits 0, 2, 5, and 7 can be
used as the interrupt interface to the master Z8000 CPU (the lEI, INT ACK,
INT, and lEO signals, respectively). The other bits in port 3 can be handshake
lines for ports 1 and 2, external access for the counter/timers, or bits of I/O.
Input bits 0, 1, and 3 of port 3 can be used as UPC interrupt requests regard-
less of their configuration.
UPC INTERRUPTS
The UPC provides for six different interrupts from eight different sources,
as listed in Table 13.4: three port 3 inputs (bits 0, 1, and 3), the two counter/
timers, and three master CPU data transfer status bits called end-of-message
(EOM), transfer error (XERR), and limit error (LERR). The interrupt mech-
anism is identical to that of the Z8, with three registers controlling the inter-
rupt structure: the Interrupt Priority, Interrupt Mask, and Interrupt Request
registers.
CPU-UPC COMMUNICATION
The UPC is a peripheral for Z8000 systems; the master Z8000 CPU uses I/O
operations to read or write to the UPC's register file. All communication be-
280 Z-Bus Microcomputers Chap. 13
Vector location
Name Source in memory Comments
tween the master CPU and the UPC is initiated by the CPU; the CPU can ex-
ecute reads and writes to the UPC but the UPC cannot read or write to the
master CPU. However, the UPC can issue an interrupt request to gain the
CPU's attention.
The master CPU can access the UPC's registers in two ways, direct access
and block access. Access by the master CPU is controlled by the UPC, though,
in that the UPC determines when a CPU access is allowed, providing soft-
ware independence between the master CPU and the UPC. The UPC sets
the transfer enable (EDX) bit in the Master Interrupt Control register (Fig.
13.27) to enable the CPU to access the UPC register file and resets that bit
to disable CPU accesses. Only the UPC can write to the EDX bit. When the
CPU completes a transaction with the UPC, the CPU notifies the UPC by set-
ting the end-of-message (EOM) bit in the same register.
The master CPU can directly access 19 of the UPC's registers. Three reg-
isters-the Master Interrupt Control, Master Interrupt Vector, and Data Trans-
fer Control registers-are mapped directly into the CPU's I/O address space.
R254 MIC
Master CPU Interrupt Control Register
z- UPC register address (Hex): FE
I0 10 10 10.1 0 10 1D, IDo I
7 6 5 3 2
ug~
o-
1 END OF MESSAGE
o WAIT ENABLE WHEN WRITE
1 WAIT DISABLE WHEN WRITE
o ENABLE LOWER CHAIN
1 DISABLE LOWER CHAIN
o DISABLE DATA TRANSFER
1 ENABLE DATA TRANSFER
'----- ~ ~~CJ~~Tg~T6~+PUT
L...-_ _ _ _ ~ ~~S~~~Tg~UCI~~~~1~~~u:~:D~~gING
L...-_ _ _ _ _ ~ ~~~~~~~~u~~DUE~D~~~~~~ICE
Figure 13.27 Master Interrupt Con-
L...-_ _ _ _ _ _ ~ :~i~::~~i :~g~~~i ~~S::LL:g trol register.
CPU-UPC Communication 281
RODTC
Data Transfer Control Register
Z-UPC register address (Hex): 00
I~I~I~I~I~I~I~I~I
I(EOM) 0 -
1 END OF MESSAGE
(LERR) 0 NO LIMIT ERROR
"----'-- 1 LIMIT ERROR
In other words, each of these registers has a unique port address in the ZSOOO
system. The Master Interrupt Control register (Fig. 13.27) contains the inter-
rupt enable (IE), interrupt pending (IP), interrupt under service (IUS), no
vector (NV), and disable lower chain (DLC) bits that control this interrupt
source according to the Z-Bus protocols described in Chapter 12. The Master
Interrupt Vector register holds the vector that is read by the CPU during an
interrupt acknowledge cycle. The Data Transfer Control register (Fig. 13.2S)
holds an I/O register pointer and four status bits.
The other 16 registers that can be directly accessed by the master CPU
are the 16 contiguous registers designated by the I/O register pointer in the
upper nibble of the Data Transfer Control register. The I/O register pointer,
like the Register Pointer, selects a group of 16 contiguous registers in the
UPC's register file. The actual register address accessed is determined by con-
catenating the 4-bit I/O register pointer with the four least significant bits of
the port address emitted by the master CPU. Thus these 16 registers each
have a unique I/O port address in the ZSOOO system.
The master CPU also can access UPC registers indirectly using the block
access method. This transfer method is controlled by the Data Indirection
and Limit Count registers in the UPC (Fig. 13.29). The block access method
allows the master CPU to access an entire block of UPC registers using one
port address. The address of the first UPC register in the block to be accessed
is held in the Data Indirection register and the number of registers in the
block is in the Limit Count register. After each master CPU read or write using
block access mode, the contents of the Data Indirection register are incre-
mented automatically (so that it points to the next register in the block) and
the contents of the Limit Count register are decremented. Thus a ZSOOO
block I/O instruction can access an entire block of UPC registers.
If the master CPU attempts to access the UPC's registers when the trans-
fer enable (EDX) bit in the Master Interrupt Control register is reset or if
the CPU attempts a block access when the Limit Count register is zero, the
access is not completed. The transfer error (XERR) bit in the Data Transfer
Control register (Fig. 13.2S) indicates that if a CPU access was attempted
UPC Product Configurations 283
interrupt by accessing the UPC, using either the direct access or block access
method. When this access is completed, the CPU sets the end-of-message bit
via a write to the Master Interrupt Control register in the UPC. This, in turn,
interrupts the UPC, thereby informing the UPC that the CPU-UPC transfer is
completed.
FFFH r-------------.
;~~ t - - - - - - - - - - - - I }
BOOTSTRAP ROM INTERNAL
ROM
~~t-----------~ }
Z·UPC INTERRUPT EXTERNAL
VECTORS RAM
Figure 13.31 Z8092 UPC RAM
memory map.
~---------~
284 Z-Bus Microcomputers Chap. 13
Z8091 can access 4K bytes of program memory external to the chip. The
Z8093 Protopak is a combination of the Z8090 and Z8091-a 40-pin package
with program memory external to the chip. The Z8093 carries a 24-pin socket
in "piggyback" manner for an EPROM that holds the program code (Fig.
13.19).
The Z8092 is a 64-pin UPC with an interface to 4K bytes of external
RAM. Thirty-six bytes of ROM are retained on board the chip; this ROM
contains a program that allows the user to download code from the master
CPU into the UPC's RAM. The internal ROM occupies addresses OC-2F hexa-
decimal (Fig. 13.31). The Z8094 is a 40-pin protopak version of the Z8092
wherein the socket for the RAM device is "piggybacked" onto the 40-pin
package.
Thus the Z8000 family of components includes processors, memory
management devices, peripherals, memories, and single-chip microcomputers.
These components are linked via a set of signals called the Z-Bus, providing
powerful solutions to a wide variety of applications.
APPENDIX A
Absolute Voltages on all inputs and outputs Stresses greater than those listed under Absolute Maxi-
Maximum with respect to GND .......... -0.3 V to + 7.0 V mum Ratings may cause permanent damage to the device.
This is a stress rating only; operation of the device at any
Ratings Operating Ambient condition above those indicated in the operational sections
Temperature .................. 0 °e to + 70 °e of these specifications is not implied. Exposure to absolute
maximum rating conditions for extended periods may affect
Storage Ternperature ........ -65 °e to + 150 °e device reliability.
Standard
Test
Conditions
The characteristics below apply for the
following standard test conditions, unless
otherwise noted. All voltages are referenced to
GND. Positive current flows into the refer-
UNDER TEST
FROMourpur =m". +sv
'·"1
enced pin. Standard conditions are as follows:
• +4.75 V =:; Vee =:; +5.25 V ~!~ ~
• GND =0 V
• ooe =:; TA =:; +70
oe All ac parameters assume a load capacilance of 100 pF max ex
cept for parameter 6 (50 pI' max). Timing references between two
output signals assume a load dIfference of 50 pF max.
VeL Clock Input Low Voltage -0.3 0.45 V Driven by External Clock
Generator
285
COMPOSITE AC TIMING DIAGRAM
SEGT =x ~ '-x=
i-----..1-2;--·-;-_-1.,-..1
i-.5v---1 :-\~-1
this diagram only for the
detailed timing relationships
of individual edges, Use the
preceding illustrations as an
explanation of the various
timing sequences
MO
!IX, ... K
Timing measurements are
made at the foHowing
STOP
__________-'-_ _ _ _ _ _...j!-+II
I, '~~)-I !~'~-i
voltages;
4.0V
Low
O.SV
.
I Output 2.0V O.SV
t$
!
:~::::----------':b--
I-"-6-Y--!-~~"' Ii
Input 2.0V O.SV
Float V ±O.5V
'/,
j
~__~_II
i i i
i
I--(~
!
I
CLOCK
SHo-SHe
---"
ADDRESS
DATA IN
DATA OUT
MEMORY READ
MEMORY WRITE
INPUT/OUTPUT
! I
INTERRUPT
ACKNOWLEDGE A 1\...-,.;.;
II
------II~ r--.
_ 1---i,~8/'--
-4/t---1
REA~~Rf~t:------~~~,I"------------------------------------------~!
NORM:~~~~~E:D-------', __________________________ ~
AC CHARACTERISTICS
Z8001/Z8002 Z8001 A/Z8002A Z80018/180028
No. Sy.bul Para.atar Min(ns) Max(na) Min(na) Max(na) Min(na) Max(na)
TcC Clock Cycle Time 250 2000 165 2000 100 2000
TwCh Clock Width (High) 105 2000 70 2000 40
3 lwCl Clock Width (Low) 105 2000 70 2000 40
4 TfC Clock Fall Time 20 10 10
5 TrC Clock Rise Time 20 15 10
6 TdC(SNv) Clock t to Segment Number Valid 130 110 70
(50 pF load)
7 TdC(SNn) Clock t to Segment Number Not Valid 20 10
8 TdC(8z) Clock t to Bus flost 65 55 40
9 TdC(A) Clock t to Address Valid 100 7S SO
10 TdC(Az) Clock t to Address float 65 S5 40
11 TdA(DR) Address Valid to Read Data Required 475 305* 180
Valid
12 TsDR(C) Read Data to Clock + Setup Time 30 20 10
13 TdDS(A) ~ t t a Address Act i ve 80 45 20*
14 TdC(DW) Clock t to Write Data Valid 100 75 50
15 ThDR(DS) Read Data to DS t Hold Time 0 0 0
16 TdDW(DS) Write Data Valid to 55 t Delay 295* 195* 110*
17 TdA(MR) Address Valid to MREQ +Delay (55)* (}5)* 20*
18 TdC(MR) Clock + to MREQ + Delay 80 70 40
19 TwMRh MREQ Width (High) 210* 13 5* 80*
20 TdMR(A) MREQ t to Address Not Active 70* 35* 20*
21 TdDW(DSW) Write Data Valid to OS + (Write) Delay 55* 35* 15*
22 TdMR(DR) mrn + to Read Oats Required Valid 375 230 140*
23 TdC(MR) Clock + MREQ t Delay 80 60 45
24 TdC(ASf) Clock t to AS + Delay 60 60 40
25 TdA(AS) Address Valid to AS t Delay 55* 35* 20*
26 TdC (ASr) Clock + to AS t De lay 90 80 40
27 TdAS(DR) AS t to Read Data Required Valid 360 220 140*
28 TdDS(AS) OS t to AS t Delay 70· 35· 15*
29 TwAS As Width (Low) 85* 55* 30*
30 TdAS(A) As t to Address Not Active Delay 70 45 20·
31 TdAz(DSR) Address float to DS (Read)+ Delay 0 0 0
32 TdAS(DSR) As t to OS (Read) + Delay 80 55 30*
D TdDSR(DR) OS (Read) + to Read Data Required Valid 205 130 70*
34 TdC(DSr) Clock + to OS t Delay 70 65 45
}5 TdDS(DW) OS t to Write Data Not Valid 75* 45* 2S*
36 ldA(DSR) Address Valid to OS ( Read') + Delay 180* 110· 65*
N 37 TdC(DSR) Clock t to DS (Read) + Delay 120 85 60
00
...., 36 TwDSR Os (Read) Width (Low) 275* 18 S· 110·
I\)
CO 39 TdC(DSW) Clock -t to OS (Write) -t Delay 95 80 60
CO OS- (Write) Width (Low) 185- 110 75-
40 TwDSW
41 TdDSI(DR) [)"S (I/O) -t to Read Data Required Valid 330 210 120-
42 TdC(DSf) Clock -t to OS (I/O) -t Delay 120 90 60
43 TwOS Os (I/O) Width (Low) 410- 255- 160-
44 TdAS(DSA) AS t to OS (Acknowledge) -t Delay 1065- 690- 410-
45 TdC(DSA) Clock t to OS (Acknowledge)t Delay 120 85 65
46 TdDSA(DR) l)S (Acknowledge) -t to Read Data 455 295 165-
Required Delay
47 TdC(S) Clock t to Status Valid Delay 110 85 60
48 TdS(AS) Status Valid to AS t Delay 50 30- 10-
49 TsH(C) 'lft'SEf to Clock t Setup Time 180 70 50
50 ThR(C) Rf SET t 0 CI 0 c k t Hold Time 0 0 0
51 TwNHI lfM-I Width (Low) 100 70 50
52 TaNHI(C) NMi to Clock t Setup Time 140 70 50
53 TsVI(C) VT,NVl to Clock t Setup Time 110 50 40
54 ThVI(C) Vf,NVI to Clock t Hold Time 0 20 0
55 TsSGT(C) SEGT to Clock t Setup Time 70 55 40
56 ThSGT(C) sE];f to Clock t Hold Time 0 0 0
57 TaHI(C) MY to Clock t Setup Time 180 110 80
58 ThHl(C) HI to Clock t Hold Time 0 0 0
59 TdC(HO) Clock t to HO Delay 120 85 70
60 TsSTP(C) ~ to Clock -t Setup Time 140 80 50
61 ThSTP(C) STop to Clock -t Hold T iDle 0 0 0
62 TsW(C) WAIT to Clock -t Setup Time 50 30 20
63 ThW(C) -WA ITt 0 CI 0 c k -t Hal d Till e 10 10
64 TaBRQ(C) ~ to Clock t Setup Time 90 80 60
6') ThBRQ(C) ~ to Clock t Hold T lme 10 10
66 TdC(BAKr) Clock t to BUSACK t Delay 100 75 60
67 TdC(BAKf) Clock .,. to EiUSACK -t Delay 100 75 60
6B TwA Address Valid Width 150- 95- 50·
69 TdDS(S) ost to STATUS Not Valid BO· 55· JO·
289
APPENDIX B
Glossary
Access time: The time required to read or write data to a device (memory
or a peripheral), measured from when the address of the device is avail-
able until when the data are actually read from or written into the device.
Accumulator: A register within a central processing unit (CPU) that can
hold the result of an arithmetic or logical operation.
Acknowledge cycle: A CPU machine cycle entered as a response to an in-
terrupt or trap. The Z8000 CPUs read an identifier word from the
interrupting device during this cycle.
Address: A number that identifies a particular register, memory location,
or peripheral device.
Address space: A set of addresses that are accessed in a similar manner.
The Z8000 CPUs can access six memory address spaces (normal-mode
program, normal-mode data, normal-mode stack, system-mode pro-
gram, system-mode data, and system-mode stack) and two I/O address
spaces (standard I/O and special I/O).
Addressing modes: The method used to specify the address of an operand
within an instruction.
Applications programs: A program designed to do a task other than con-
trolling the resources within a computer system. Applications programs
typically run in the normal mode on a Z8000 system.
Arithmetic and logical unit (ALU): The part of the central processing unit
that contains the logic for performing arithmetic and logical operations
on data.
290
Glossary 291
Interrupt vector: Data read from the interrupting device during an ac-
knowledge cycle that determine the location of the service routine.
(See vectored interrupts.)
Label: An optional field within a statement in a program that allows a
symbolic name (the label) to be associated with the memory address of
the code generated by that statement.
Logical address: A memory address that is manipulated by the programmer,
used in instructions, and output by the CPU during program execution.
Long offset address: A segmented address given in an instruction that oc-
cupies two words in the instruction's opcode, one word for the segment
number and one word for the offset.
Long word: A field of 32 contiguous bits that is operated on as a unit.
Machine cycle: One basic CPU operation involving a single transaction on
the bus. For Z8000 CPUs, one machine cycle is the time from the fall-
ing edge of AS to the next falling edge of AS.
Machine language: Binary code that can be read directly and used by a
computer.
Main memory: Memory within a system that can be directly accessed using
memory access cycles. Main memory is typically made up of semicon-
ductor memories such as ROMs and RAMs.
Mask-programmable ROM: Read-only memory whose contents are deter-
mined by a photolithographic mask used to manufacture the part.
Memory: A device into which information can be written and then re-
trieved at a later time; an information storage device.
Memory access time: (See access time.)
Memory cycle time: The time between the start of one memory access and
the start of the next memory access.
Memory management: The process of controlling memory allocation and
protection by mapping physical addresses to logical addresses and per-
forming attribute checking.
Memory manager: The hardware and software in a system that controls
memory management.
Memory-mapped I/O: A technique that allows peripheral devices to be ac-
cessed as if they were memory locations in main memory.
Memory refresh cycle: A CPU machine cycle dedicated to performing a re-
fresh operation on dynamic RAMs.
Memory segment: (See segment.)
Memory transaction: A transaction involving a transfer of data between
the CPU and main memory.
Microprocessor: A central processing unit built with large-scale integrated
circuits and usually contained on one chip.
296 Appendix B
Segment number: In Z8001 CPUs, the portion of the memory address that
is output on the SNO-SN6 lines during a memory access. Each segment
number specifies a particular memory segment.
Semaphore: A storage location used as a Boolean variable to synchronize
the use of resources among multiple programming tasks. A semaphore
ensures that a shared resource is allocated to only one task at any given
time.
Service routine: Program code that is executed in response to an interrupt
or trap.
Short offset address: A segmented address given within an instruction that
occupies only one word in the instruction's opcode. Short offset ad-
dresses can be used to access the first 256 bytes of a memory segment.
Single-chip microcomputer: An entire computer including CPU, memory,
and I/O devices on a single integrated-circuit chip.
Source: The register, memory location, or device from which data are
being read.
Stack: An area of memory used for temporary storage and subroutine link-
ages. A stack uses the first-in-Iast-out method for storing and retrieving
data; the last data written onto the stack will be the first data read from
the stack.
Stack pointer: A register that holds the address of the top of the stack.
Static RAM: Random access memory that retains its contents without the
need for refresh cycles.
Stop request: A request made by activating the STOP line to a Z8000 in
order to suspend CPU activity.
Strobed handshake: A handshake protocol for transferring data between
two devices using two control signals. Short pulses on the two signals
are used to control the data transfer.
Synchronous: Related to or dependent on a specific clock signal; having a
fixed relationship in time.
System call trap: A trap that is caused by the execution of a System Call
instruction.
System mode: An operating mode of the Z8000 CPUs in which all instruc-
tions, including privileged instructions, can be executed. Operating sys-
tems software typically runs in system mode.
Task: (See programming task.)
Three-wire handshake: A handshake protocol for transferring data between
two or more devices using three control signals. A change in level on
one signal requires the appropriate response on the other signals for the
transfer to be completed.
300 Appendix B
Bibliography
LEVENTHAL, LANCE, ADAM OSBORNE, and CHUCK COLLINS, Z8000 Assembly Lan-
guage Programming, Osborne/McGraw-Hill, Berkeley, CA, 1980.
MATEOSIAN, RICHARD, Programming the Z8000, Sybex, Inc., Berkeley, CA, 1980.
SIPPL, CHARLES J., and ROGER J. SIPPL, Computer Dictionary, Howard W. Sams & Co.,
Indianapolis, Ind., 1980.
ZARELLA, JOHN, Operating Systems Concepts and Principles, Microcomputer Applica-
tions, 1979.
ZARELLA, JOHN, System Architecture, Microcomputer Applications, 1980.
301
Index
302
Index 303