Mikro Komputer
Mikro Komputer
Dosen Pembimbing:
ISRAM RASYAL, ST.,MMSI,MSc
Anggota
UNIVERSITAS GUNADARMA
FAKULTAS ILMU KOMPUTER DAN TEKNOLOGI INFORMASI
SISTEM KOMPUTER
2014
University of Technology Introduction to Computer &
Department of Electrical & Electronic Eng. Microcomputers
Fourth Year-Microprocessor Eng. II Lecture One-Page 1 of 11
Dr. Hadeel Nasrat
What is a Computer?
An electronic device that accepts input, stores large quantities of data, execute
complex instructions which direct it to perform mathematical and logical operations
and outputs the answers in a human readable form.
Computers are not very intelligent devices, but they handle instructions
flawlessly and fast. They must follow explicit directions from both the user and
computer programmer. Computers are really nothing more than a very powerful
calculator with some great accessories. Applications like word processing and games
are just a very complex math problem.
Computer Generations
From the 1950’s, the computer age took off in full force. The years since then
have been divided into periods or generations based on the technology used.
1. First Generation Computers (1945-1954): Vacuum Tubes
These machines were used in business for accounting and payroll applications.
Valves were unreliable components generating a lot of heat. They had very limited
memory capacity. Magnetic drums were developed to store information and tapes
were also developed for secondary storage. They were initially programmed in
machine language (binary). A major breakthrough was the development of
assemblers and assembly language.
2. Second Generation (1955-1964): Transistors
The development of the transistor revolutionized the development of
computers. Invented at Bell Labs in 1948, transistors were much smaller, more
rugged, cheaper to make and far more reliable than valves. Core memory was
introduced and disk storage was also used. The hardware became smaller and more
reliable, a trend that stills continues. Another major feature of the second generation
University of Technology Introduction to Computer &
Department of Electrical & Electronic Eng. Microcomputers
Fourth Year-Microprocessor Eng. II Lecture One-Page 2 of 11
Dr. Hadeel Nasrat
was the use of high-level programming languages such as Fortran and Cobol. These
revolutionized the development of software for computers.
3. Third Generation (1965-1974): Integrated Circuits (ICs)
IC’s were again smaller, cheaper, faster and more reliable than transistors.
Speeds went from the microsecond to the nanosecond (billionth) to the picosecond
(trillionth) range. ICs were used for main memory despite the disadvantage of being
volatile. Minicomputers were developed at this time. Terminals replaced punched
cards for data entry and disk packs became popular for secondary storage. IBM
introduced the idea of a compatible family of computers, 360 family easing the
problem of upgrading to a more powerful machine. Operating systems were
developed to manage and share the computing resources and time-sharing operating
systems were developed. These greatly improved the efficiency of computers.
Computers had by now pervaded most areas of business and administration. The
number of transistors that be fabricated on a chip is referred to as the scale of
integration (SI). Early chips had SSI (small SI) of tens to a few hundreds. Later chips
were MSI (Medium SI): hundreds to a few thousands. Then came LSI chips (Large
SI) in the thousands range.
Types of Computers
Computer now comes in a variety of shapes and sizes, which could be roughly
classified according to their processing power into five sizes: super large, large,
medium, small, and tiny.
Microcomputers are the type of computers that we are most likely to notice and use in
our everyday life. In fact there are other types of computers that you may use directly
or indirectly:
Supercomputers-super large computers: supercomputers are high- capacity
machines with hundreds of thousands of processors that can perform more than
1 trillion calculations per second. These are the most expensive but fastest
computers available. "Supers," as they are called, have been used for tasks
requiring the processing of enormous volumes of data, such as doing the U.S.
census count, forecasting weather, designing aircraft, modeling molecules,
breaking codes, and simulating explosion of nuclear bombs.
Mainframe computers - large computers: The only type of computer available
until the late 1960s, mainframes are water- or air-cooled computers that vary in
size from small, to medium, to large, depending on their use. Small
mainframes are often called midsize computers; they used to be called
minicomputers. Mainframes are used by large organizations such as
banks, airlines, insurance companies, and colleges-for processing millions of
transactions. Often users access a mainframe using a terminal, which has a
display screen and a keyboard and can input and output data but cannot by
itself process data.
Workstations - medium computer: Introduced in the early 1980s,
workstations, are expensive, powerful computers usually used for complex
scientific, mathematical, and engineering calculations and for computer-aided
design and computer-aided manufacturing. Providing many capabilities
comparable to midsize mainframes, workstations are used for such tasks as
designing airplane fuselages, prescription drugs, and movie special effects.
Workstations have caught the eye of the public mainly for their graphics
capabilities, which are used to breathe three-dimensional life into movies such
as Jurassic Park and Titanic. The capabilities of low-end workstations overlap
those of high-end desktop microcomputers.
Microcomputer - small computers: Microcomputers, also called personal
computers (PC), can fit next to a desk or on a desktop, or can be carried
around. They are either stand-alone machines or are connected to a computer
network, such as a local area network. A local area network (LAN) connects,
usually by special cable, a group of desktop PCs and other devices, such as
printers, in an office or a building. Microcomputers are of several types:
Desktop PCs: are those in which the case or main housing sits on a
University of Technology Introduction to Computer &
Department of Electrical & Electronic Eng. Microcomputers
Fourth Year-Microprocessor Eng. II Lecture One-Page 5 of 11
Dr. Hadeel Nasrat
When you use a program, the computer loads a portion of the program from
the hard drive to the much faster memory (RAM). When you "save" your work or
quit the program, the data gets written back to the hard drive.
Computer Architecture
In computer engineering, computer architecture is the conceptual design and
fundamental operational structure of a computer system. It is a blueprint and
functional description of requirements (especially speeds and interconnections) and
design implementations for the various parts of a computer — focusing largely on the
way by which the central processing unit (CPU) performs internally and accesses
addresses in memory.
Computer architecture comprises at least three main subcategories
Instruction set architecture, or ISA, is the abstract image of a computing
system that is seen by a machine language (or assembly language)
programmer, including the instruction set, memory address modes, processor
registers, and address and data formats.
Microarchitecture, also known as Computer organization is a lower level,
more concrete, description of the system that involves how the constituent
parts of the system are interconnected and how they interoperate in order to
implement the ISA. The size of a computer's cache for instance, is an
organizational issue that generally has nothing to do with the ISA.
System Design which includes all of the other hardware components within a
computing system such as:
system interconnects such as computer buses and switches
memory controllers and hierarchies
CPU off-load mechanisms such as direct memory access issues like
multi-processing.
Once both ISA and microarchitecture has been specified, the actual device needs to
be designed into hardware. This design process is often called implementation.
Implementation is usually not considered architectural definition, but rather hardware
design engineering.
Computer Organization deals with the advances in computer architecture right from
the Von Neumann machines to the current day super scalar architectures.
as they were "designed". "Reprogramming", when it was possible at all, was a very
manual process, starting with flow charts and paper notes, followed by detailed
engineering designs, and then the often-arduous process of implementing the physical
changes.
The idea of the stored-program computer changed all that. By creating an
instruction set architecture and detailing the computation as a series of instructions
(the program), the machine becomes much more flexible. By treating those
instructions in the same way as data, a stored-program machine can easily change the
program, and can do so under program control.
The von Neumann architecture is a computer design model that uses a
processing unit and a single separate storage structure to hold both instructions and
data as shown in Fig. (2). It is named after mathematician and early computer
scientist John von Neumann. Such a computer implements a universal Turing
machine, and the common "referential model" of specifying sequential architectures,
in contrast with parallel architectures. The term "stored-program computer" is
generally used to mean a computer of this design, although as modern computers are
usually of this type, the term has fallen into disuse. All general-purpose computers
are now based on the key concepts of the von Neumann architecture.
Hardvard Architecture
A Harvard Architecture as shown in Fig. (3) has one memory for instructions
and a second for data. The name comes from the Harvard Mark 1, an
electromechanical computer which pre-dates the stored-program concept of von
Neumann, as does the architecture in this form. It is still used for applications which
run fixed programs, in areas such as digital signal processing, but not for general-
purpose computing. The advantage is the increased bandwidth available due to
having separate communication channels for instructions and data; the disadvantage
is that the storage is allocated to code and data in a fixed ratio.
2.1 Microprocessor
A microprocessor is a computer processor on a microchip. It's sometimes called
a logic chip. It is the "engine" that goes into motion when you turn your computer on.
A microprocessor is designed to perform arithmetic and logic operations that make
use of small number-holding areas called registers. Typical microprocessor operations
include adding, subtracting, comparing two numbers, and fetching numbers from one
area to another. These operations are the result of a set of instructions that are part of
the microprocessor design. When the computer is turned on, the microprocessor is
designed to get the first instruction from the basic input/output system (BIOS) that
comes with the computer as part of its memory. After that, either the BIOS, or the
operating system that BIOS loads into computer memory, or an application program
is "driving" the microprocessor, giving it instructions to perform.
Microprocessor
CCR CL
ACC IR
PC
Fig. (2.1): Central processing unit main components and interactions with the
memory and I/O.
University of Technology Microprocessors Architecture
Department of Electrical & Electronic Eng. Lecture Two-Page 4 of 10
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
The execution cycle is repeated as long as there are more instructions to execute. A
check for pending interrupts is usually included in the cycle. Examples of interrupts
include I/O device request, arithmetic overflow, or a page fault.
When an interrupt request is encountered, a transfer to an interrupt handling routine
takes place. Interrupt handling routines are programs that are invoked to collect the
state of the currently executing program, correct the cause of the interrupt, and restore
the state of the program. The actions of the CPU during an execution cycle are
defined by micro-orders issued by the control unit. These micro-orders are individual
control signals sent over dedicated control lines. For example, let us assume that we
want to execute an instruction that moves the contents of register X to register Y.
Let us also assume that both registers are connected to the data bus, D. The control
unit will issue a control signal to tell register X to place its contents on the data bus D.
After some delay, another control signal will be sent to tell register Y to read from
data bus D. The activation of the control signals is determined using either hardwired
control or microprogramming. These concepts are explained later.
Similarly, to perform a memory read operation, the MDR and MAR are used as
follows:
1. The address of the location from which the word is to be read is loaded into the
MAR.
2. A read signal is issued by the CPU.
3. The required word will be loaded by the memory into the MDR ready for use by
the CPU.
3. Stack Pointer:
A stack is a data organization mechanism in which the last data item stored is
the first data item retrieved. Two specific operations can be performed on a stack.
These are the Push and the Pop operations. A specific register, called the stack pointer
(SP), is used to indicate the stack locationm that can be addressed. In the stack push
operation, the SP value is used to indicate the location (called the top of the stack).
After storing (pushing) this value, the SP is incremented (in some architectures, e.g.
X86, the SP is decremented as the stack grows low in memory).
80386 Registers
The Intel basic programming model of the 386, 486, and the Pentium consists
of three register groups. These are the general-purpose registers, the segment
registers, and the instruction pointer (program counter) and the flag register. Fig. (2.2)
shows the three sets of registers. The first set consists of general purpose registers A,
B, C, D, SI (source index), DI (destination index), SP (stack pointer), and BP (base
pointer). The second set of registers consists of CS (code segment), SS (stack
segment), and four data segment registers DS, ES, FS, and GS. The third set of
registers consists of the instruction pointer (program counter) and the flags (status)
register. Among the status bits, the first five are identical to those bits introduced as
early as in the 8085 8-bit microprocessor. The next 6 – 11 bits are identical to those
introduced in the 8086. The flags in the bits 12 – 14 were introduced in the 80286
while the 16 – 17 bits were introduced in the 80386. The flag in bit 18 was introduced
in the 80486.
Fig. (2.2): The main register sets in 80X86 (80386 and above
extended all 16 bit registers except segment registers).
University of Technology Microprocessors Architecture
Department of Electrical & Electronic Eng. Lecture Two-Page 7 of 10
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
2.6 Datapath
The CPU can be divided into a data section and a control section. The data
section, which is also called the datapath, contains the registers and the ALU. The
datapath is capable of performing certain operations on data items. The control
section is basically the control unit, which issues control signals to the datapath.
Internal to the CPU, data move from one register to another and between ALU and
registers.
Internal data movements are performed via local buses, which may carry data,
instructions, and addresses. Externally, data move from registers to memory and I/O
devices, often by means of a system bus. Internal data movement among registers and
University of Technology Microprocessors Architecture
Department of Electrical & Electronic Eng. Lecture Two-Page 8 of 10
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
between the ALU and registers may be carried out using different organizations
including one-bus, two-bus, or three-bus organizations. Dedicated datapaths may also
be used between components that transfer data between themselves more frequently.
For example, the contents of the PC are transferred to the MAR to fetch a new
instruction at the beginning of each instruction cycle. Hence, a dedicated datapath
from the PC to the MAR could be useful in speeding up this part of instruction
execution.
two different registers to the input point of the ALU at the same time. Therefore, a
two-operand operation can fetch both operands in the same clock cycle. An additional
buffer register may be needed to hold the output of the ALU when the two buses are
busy carrying the two operands. Figure (2.4a) shows a two-bus organization. In some
cases, one of the buses may be dedicated for moving data into registers (in-bus),
while the other is dedicated for transferring data out of the registers (out-bus). In this
case, the additional buffer register may be used, as one of the ALU inputs, to hold one
of the operands. The ALU output can be connected directly to the in-bus, which will
transfer the result into one of the registers. Figure (2.4b) shows a two-bus
organization with in-bus and out-bus.
(a)
(b)
Fig. (2.4): Two-bus organizations. (a) An Example of Two-Bus Datapath.
(b) Another Example of Two-Bus Datapath with in-bus and out-bus
.
University of Technology Microprocessors Architecture
Department of Electrical & Electronic Eng. Lecture Two-Page 10 of 10
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
3. As a result of a memory read operation, the instruction is loaded into the MDR.
4. The contents of the MDR are loaded into the IR.
Let us consider the one-bus datapath organization shown in Fig. (2.3). We will
see that the fetch operation can be accomplished in three steps as shown in the table
below, where t0 < t1 < t2 . Note that multiple operations separated by “;” imply that
they are accomplished in parallel.
Step Micro-Operation
t0 MAR ← (PC); A ← (PC)
t1 MDR ← Mem MAR; PC ← (A)+4
t2 IR ← (MDR)
using the three-bus datapath shown in Fig. (2.5), the following table shows the steps
needed.
Step Micro-Operation
t0 MAR ← (PC); A ← (PC)+4
t1 MDR ← Mem MAR;
t2 IR ← (MDR)
Step Micro-Operation
t0 A ← (R1)
t1 B ← (R2)
t2 R0 ← (A)+(B)
Using the two-bus datapath shown in Fig. (2.4a), this addition will take two steps as
shown in the following table, where t0 < t1 .
Step Micro-Operation
t0 A ← (R1) + (R2)
t1 R0 ← (A)
Using the two-bus datapath with in-bus and out-bus shown in Fig. (2.4b), this
addition will take two steps as shown in the following table, where t0 < t1 .
Step Micro-Operation
t0 A ← (R1)
t1 R0 ← (A) + (R2)
Using the three-bus datapath shown in Fig. (2.5), this addition will take one steps as
shown in the following table.
Step Micro-Operation
t0 R0 ← (R1) + (R2)
University of Technology Microprocessors Architecture
Department of Electrical & Electronic Eng. Lecture Three-Page 4 of 10
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
Using the one-bus datapath shown in Fig. (2.3), this addition will take five steps as
shown in the following table, where t0 < t1 < t2 < t3 < t4.
Step Micro-Operation
t0 MAR ← X
t1 MDR ← Mem[MAR]
t2 A ← (R0)
t3 B ← (MDR)
t4 R0 ← (A)+(B)
Using the two-bus datapath shown in Fig. (2.4a), this addition will take four steps as
shown in the following table, where t0 < t1< t2 < t3 .
Step Micro-Operation
t0 MAR ← X
t1 MDR ← Mem[MAR]
t2 A ← (R0) + (MDR)
t3 R0 ← (A)
University of Technology Microprocessors Architecture
Department of Electrical & Electronic Eng. Lecture Three-Page 5 of 10
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
Using the two-bus datapath with in-bus and out-bus shown in Fig. (2.4b), this
addition will take four steps as shown in the following table, where t0 < t1< t2 < t3 .
Step Micro-Operation
t0 MAR ← X
t1 MDR ← Mem[MAR]
t2 A ← (R0)
t3 R0 ← (A) + (MDR)
Using the three-bus datapath shown in Fig. (2.5), this addition will take three steps as
shown below, where t0 < t1< t2.
Step Micro-Operation
t0 MAR ← X
t1 MDR ← Mem[MAR]
t2 R0 ← (R0) + (MDR)
The following table shows the sequence of events, where t1< t2< t3.
Step Micro-Operation
t1 MDR ← PC
MAR ← Address1 (where to save PC);
t2
PC ← Address 2 (interrupt handling routine)
t3 Mem[MAR] ← (MDR)
Instruction Control
Step Micro-operation
Type
t0 Ins-x R0 ← (R1) + (R2) Select R1 as source 1 on out-bus1 (R1 out-bus1)
Select R2 as source 2 on out-bus2 (R2 out-bus2)
Select R0 as destination on in-bus (R0 in-bus)
Select the ALU function Add (Add)
Fig. (3.3) shows the signals generated to execute Inst-x during time period t0. The
AND gate ensures that these signals will be issued when the op-code is decoded into
Inst-x and during time period t0. The signals (R1out-bus 1), (R2out-bus2), (R0in-bus),
and (Add) will select R1 as a source on out-bus1, R2 as a source on out-bus2, R0 as
destination on in-bus, and select the ALUs add function, respectively.
University of Technology Microprocessors Architecture
Department of Electrical & Electronic Eng. Lecture Three-Page 9 of 10
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
Example 2 :
Let us repeat the operation in the previous example using the one-bus datapath
shown in Fig. (2.3). We have shown earlier that this operation can be carried out in
three steps using the one-bus datapath. Suppose that the op-code field of the current
instruction was decoded to Inst-x type. The following table shows the needed steps
and the control sequence.
Instruction Control
Step Micro-operation
Type
t0 Inst-x A ← (R1) Select R1 as source (R1 out)
Select A as destination (A in)
t1 Inst-x A ← (R2) Select R2 as source (R2 out)
Select B as destination (B in)
t2 Inst-x R0 ← (R1) + (R2) Select the ALU function Add (Add).
Select Ro as destination (R0 in)
University of Technology Microprocessors Architecture
Department of Electrical & Electronic Eng. Lecture Three-Page 10 of 10
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
Fig. (3.4) shows the signals generated to execute Inst-x during time periods t0 , t1, and
t2. The AND gates ensure that the appropriate signals will be issued when the op-code
is decoded into Inst-x and during the appropriate time period. During t0, the signals
(R1out) and (A in) will be issued to move the contents of R1 into A. Similarly during
t1, the signals (R2 out) and (B in) will be issued to move the contents of R2 into B.
Finally, the signals (R0in) and (Add) will be issued during t2 to add the contents of A
and B and move the results into R0.
3.1 Introduction
The 80386 microprocessor is a full 32-bit version of the earlier 8086/80286 16-
bit microprocessors, and represents a major advancement in the architecture, a switch
from a 16-bit architecture to a 32-bit architecture. Along with this larger word size are
many improvements and additional features. The 80386 microprocessor features
multitasking, memory management, virtual memory (with or without paging),
software protection, and a large memory system. All software written for the early
8086/8088 and the 80286 are upward-compatible to the 80386 microprocessor. The
amount of memory addressable by the 80386 is increased from the 1M bytes found in
the 8086/8088 and the 16M bytes found in the 80286, to 4G bytes in the 80386.
Before the 80386 or any other microprocessor can be used in a system, the
function of each pin must be understood. Figure (3-1a) illustrates the pin-out of the
80386DX microprocessor. The 80386DX is packaged in a 132-pin PGA (pin grid
array). Two versions of the 80386 are commonly available: the 80386DX, which is
illustrated and described in this section; the other is the 80386SX, which is a reduced
bus version of the 80386. A new version of the 80386-the 80386EX-incorporates the
AT bus system, dynamic RAM controller, programmable chip selection logic, 26
address pins, 16 data pins, and 24 I/O pins. Figure (3-1b) illustrates the 80386SX
embedded PC.
The 80386DX addresses 4G bytes of memory through its 32-bit data bus and
32-bit address. The 80386SX, more like the 80286, addresses 16M bytes of memory
with its 24-bit address bus via its 16-bit data bus. The 80386SX was developed after
the 80386DX for applications that didn't require the full 32-bit bus version. The
80386SX is found in many personal computers that use the same basic motherboard
design as the 80286. At the time that the 80386SX was popular, most applications,
including Windows, required fewer than 16M bytes of memory, so the 80386SX is a
popular and a less costly version of the 80386 microprocessor.
University of Technology The 80386 Microprocessors
Department of Electrical & Electronic Eng. Lecture Four-Page 2 of 8
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
A31-A2: Address bus connections address any of the 1Gx32 memory locations found
in the 80386 memory system. Note that A0 and A1 are encoded in the bus
enable ( BE 3 BE 0 ) to select any or all of the four bytes in a 32-bit wide
memory location. Also note that because the 80386SX contains a 16-bit data
bus in place of the 32-bit data bus found on the 80386DX, A1 is present on the
80386SX, and the bank selection signals are replaced with BHE and BLE .
The BHE signal enables the upper data bus half; the BLE signal enables the
lower data bus half.
University of Technology The 80386 Microprocessors
Department of Electrical & Electronic Eng. Lecture Four-Page 3 of 8
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
D31-D0: Data bus connections transfer data between the microprocessor and its
memory and I/O system. Note that the 80386SX contains D15-DO.
BE 3 BE 0 : Bank enable signals select the access of a byte, word, or double word
of data. These signals are generated internally by the microprocessor from
address bits A1 and A0. On the 80386SX, these pins are replaced by BHE ,
BLE , and A1.
M / IO : Memory/IO selects a memory device when a logic 1 or an I/O device when a
logic 0. During the I/O operation, the address bus contains a 16-bit I/O address
on address connections A15-A2.
W / R : Write/read indicates that the current bus cycle is a write when a logic 1 or a
read when a logic 0.
ADS : The address data strobe becomes active whenever the 80386 has issued a
valid memory or I/O address. This signal is combined with the W / R signal to
generate the separate read and write signals present in the earlier 8086-80286
microprocessor-based systems.
RESET: Reset initializes the 80386, causing it to begin executing software at
memory location FFFFFFF0H. The 80386 is reset to the real mode, and the
leftmost 12 address connections remain logic 1s (FFFH) until a far jump or far
call is executed. This allows compatibility with earlier microprocessors.
CLK2: Clock times 2 is driven by a clock signal that is twice the operating frequency
of the 80386. For example, to operate the 80386 at 16 MHz, we apply a 32
MHz clock to this pin.
READY : Ready controls the number of wait states inserted into the timing to
lengthen memory accesses. .
LOCK : Lock becomes a logic 0 whenever an instruction is prefixed with the
LOCK:prefix. This is used most often during DMA accesses.
University of Technology The 80386 Microprocessors
Department of Electrical & Electronic Eng. Lecture Four-Page 4 of 8
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
D / C : Data/control indicates that the data bus contains data for or from memory or
I/O when a logic 1. If D / C is a logic 0, the microprocessor is halted or
executes an interrupt acknowledge.
BS 16 : Bus size 16 selects either a 32-bit data bus ( BS 16 = 1) or a 16-bit data bus
( BS 16 =0). In most cases, if an 80386DX is operated on a 16-bit data bus, we
use the 80386SX that has a 16-bit data bus.
NA : Next address causes the 80386 to output the address of the next instruction or
data in the current bus cycle. This pin is often used for pipelining the address.
HOLD: Hold requests a DMA action.
HLDA: Hold acknowledge indicates that the 80386 is currently in a hold condition.
PEREQ : The coprocessor request asks the 80386 to relinquish control and is a
direct connection to the 80387 arithmetic coprocessor.
BUSY : Busy is an input used by the WAIT or FWAIT instruction that waits for the
coprocessor to become not busy. This is also a direct connection to the 80387
from the 80386.
ERROR : Error indicates to the microprocessor that an error is detected by the
coprocessor.
INTR: An interrupt request is used by external circuitry to request an interrupt.
NMI: A non-maskable interrupt requests a non-maskable interrupt as it did on the
earlier versions of the microprocessor.
has a dedicated function and they operate at the same time. The more the parallel
processing, the higher the performance of the microprocessor.
The 8086 microprocessor contains just two processing units: the bus interface
unit and execution unit. In the 80286 microprocessor, the internal architecture was
further partitioned into four independent processing elements: the bus unit, the
instruction unit, the execution unit, and the address unit. This additional parallel
processing provided an important contribution to the higher level of performance
achieved with the 80286, architecture.
The 80386DX's internal architecture: is illustrated in Fig. (3.2). Here we see
that to enhance the performance, more parallel processing elements are provided.
Notice that now there are six functional units: the execution unit, the segment unit,
the page unit, the bus unit, the prefetch unit, and the decode unit. Let us now look
more closely at each of the processing units of the 80386DX.
The bus unit is the 80386DX's interface to the outside world. By interface, we
mean the path by which it connects to external devices. The bus interface provides a
32-bit data bus, a 32-bit address bus, and the signals needed to control transfers over
the bus. In fact, 8-bit, l6-bit, and 32-bit data transfers are supported. These buses are
demultiplexed like those of the 80286. That is, the 80386DX has separate pins for its
address and data bus lines. This demultiplexing of address and data results in higher
performance and easier hardware design. Expanding the data bus width to 32 bits
further improves the performance of the 80386DX's hardware architecture as
compared to that of either the 8086 or 80286.
The bus unit is responsible for performing all external bus operations. This
processing unit contains the latches and drivers for the address bus, transceivers for
the data bus and control logic for signaling whether a memory, input/output or
interrupt-acknowledg bus cycle is being performed. Looking at Fig. (3.2), we find
that for data accesses, the address of the storage location that is to be accessed is input
University of Technology The 80386 Microprocessors
Department of Electrical & Electronic Eng. Lecture Four-Page 6 of 8
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
from the paging unit, and for code accesses the address is provided by the prefetch
unit.
The prefetch unit implements a mechanism known as an instruction stream
queue. This queue permits the 80386DX to prefetch up to 16 bytes of instruction
code. Whenever the queue is not full-that is, it has room for at least 4 more bytes and,
at the same time, the execution unit is not asking it to read or write operands from
memory-the prefetch unit supplies addresses to the bus interface unit and signals it to
look ahead in the program by fetching the next sequential instructions. Prefected
instructions are held in the FIFO queue for use by the instruction decoder. Whenever
bytes are loaded at the input end of the queue, they are automatically shifted up
through the FIFO to the empty locations near the output. With its 32-bit data bus. the
80386DX fetches 4 bytes of instruction code in a single memory cycle. Through this
prefetch mechanism, the fetch time for most instructions is hidden. If the queue in the
prefetch unit is full and the execution unit is not requesting access to operands in
memory the bus interface unit does not need to perform any bus cycle.
The execution unit includes the arithmetic/logic unit (ALU), the 80386DX's
registers, special multiply, divide, and shift hardware, and a control ROM. By
registers, we mean the 80386DX's general-purpose registers, such as EAX, EBX, and
ECX. The control ROM contains the microcode sequences that define the operation
performed by each of the 80386DX's machine code instructions. The execution unit
reads decoded instructions from the instruction queue and performs the operations
that they specify. It is the ALU that performs the arithmetic, logic, and shift
operations required by an instruction. If necessary, during the execution of an
instruction, it requests the segment and page units to generate operand addresses and
the bus interface unit to perform read or write bus cycles to access data in memory or
I/O devices. The extra hardware that is provided to perform multiply, divide, shift,
and rotate operations improves the performance of instructions that employ these
University of Technology The 80386 Microprocessors
Department of Electrical & Electronic Eng. Lecture Four-Page 7 of 8
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
functions.
The segment and page units provide the memory-management and protection
services for the 80386DX. They off-load the responsibility for address generation,
address translation, and segment checking from the bus interface unit, thereby further
boosting the performance of the MPU. The segment unit implements the
segmentation model of the 80386DX's memory management. That is, it contains
dedicated hardware for performing high-speed address calculations, logical-to-linear
address translation, and protection check. For instance, when in the real mode, the
execution unit requests the segment unit to obtain the address of the next instruction
to be fetched by adding an appended version of the current contents of the code
segment (CS) register with the value in the instruction pointer (IP) register to obtain
the 20-bit physical address that is to be output on the address bus. This address is
passed on to the bus unit.
For protected mode, the segment unit performs the logical-to-linear address
translation and various protection checks needed when performing bus cycles. It
contains the segment registers and the 6-wordx64-bit cache that is used to hold the
current descriptors within the 80386DX.
The page unit implements the protected mode paging model of the 80386DX's
memory management. It contains the translation lookaside buffer that stores recently
used page directory and page table entries. When paging is enabled, the linear address
produced by the segment unit is used as the input of the page unit. Here the linear
address is translated into the physical address of the memory or I/O location to be
accessed. This physical memory or I/O address is output to the bus interface unit.
University of Technology The 80386 Microprocessors
Department of Electrical & Electronic Eng. Lecture Four-Page 8 of 8
Fourth Year-Microprocessor Eng. II Dr. Hadeel Nasrat
University of Technology Software Model of the 80386DX
Department of Electrical & Electronic Eng. Microprocessor
Fourth Year-Microprocessor Eng. II Lecture Five-Page 1 of 8
Dr. Hadeel Nasrat
With the flat memory model (see Figure 4-1), memory appears to a program as a
single, continuous address space, called a linear address space. Code (a program’s
instructions), data, and the procedure stack are all contained in this address space.
The linear address space is byte addressable, with addresses running contiguously
University of Technology Software Model of the 80386DX
Department of Electrical & Electronic Eng. Microprocessor
Fourth Year-Microprocessor Eng. II Lecture Five-Page 2 of 8
Dr. Hadeel Nasrat
from 0 to 232 - 1. An address for any byte in the linear address space is called a
linear address.
`
With the segmented memory model, memory appears to a program as a group
of independent address spaces called segments. When using this model, code, data,
and stacks are typically contained in separate segments. To address a byte in a
segment, a program must issue a logical address, which consists of a segment selector
and an offset. (A logical address is often referred to as a far pointer.) The segment
selector identifies the segment to be accessed and the offset identifies a byte in the
address space of the segment. The programs running on an Intel Architecture
University of Technology Software Model of the 80386DX
Department of Electrical & Electronic Eng. Microprocessor
Fourth Year-Microprocessor Eng. II Lecture Five-Page 3 of 8
Dr. Hadeel Nasrat
processor can address up to 16,383 segments of different sizes and types, and each
segment can be as large as 232 bytes.
The real-address mode model uses the memory model for the Intel 8086 processor,
the first Intel Architecture processor. It was provided in all the subsequent Intel
Architecture processors for compatibility with existing programs written to run on the
Intel 8086 processor. The real address mode uses a specific implementation of
segmented memory in which the linear address space for the program and the
operating system/executive consists of an array of segments of up to 64K bytes in
size each. The maximum size of the linear address space in real-address mode is 220
bytes.
4.2. REGISTERS
The processor provides 16 registers for use in general system and application
programing. These registers can be grouped as follows:
1. General-purpose data registers. These eight registers are available for storing
operands and pointers.
2. Segment registers. These registers hold up to six segment selectors.
3. Status and control registers. These registers report and allow modification of
the state of the processor and of the program being executed.
The 32-bit general-purpose data registers EAX, EBX, ECX, EDX, ESI, EDI, EBP,
and ESP are provided for holding the following items:
• Operands for logical and arithmetic operations
• Operands for address calculations
• Memory pointers.
Although all of these registers are available for general storage of operands, results,
and pointers, caution should be used when referencing the ESP register. The ESP
register holds the stack pointer and as a general rule should not be used for any other
purpose. Many instructions assign specific registers to hold operands. For example,
string instructions use the contents of the ECX, ESI, and EDI registers as operands.
When using a segmented memory model, some instructions assume that pointers in
certain registers are relative to specific segments. For instance, some instructions
assume that a pointer in the EBX register points to a memory location in the DS
segment.
The following is a summary of these special uses:
• EAX—Accumulator for operands and results data.
• EBX—Pointer to data in the DS segment.
University of Technology Software Model of the 80386DX
Department of Electrical & Electronic Eng. Microprocessor
Fourth Year-Microprocessor Eng. II Lecture Five-Page 4 of 8
Dr. Hadeel Nasrat
The segment registers (CS, DS, SS, ES, FS, and GS) hold 16-bit segment
selectors. A segment selector is a special pointer that identifies a segment in memory.
When using the segmented memory model, each segment register is ordinarily loaded
with a different segment selector so that each segment register points to a different
segment within the linear-address space (as shown in Figure 4-3).
Code segment (CS) is a 16-bit register containing address of 64 KB segment
with processor instructions. The processor uses CS segment for all accesses to
instructions referenced by instruction pointer (IP) register. CS register cannot be
changed directly. The CS register is automatically updated during far jump, far call
and far return instructions.
The 32-bit EFLAGS register contains a group of status flags, a control flag, and a
group of system flags. Figure (4-4) defines the flags within this register. Some of the
flags in the EFLAGS register can be modified directly, using special-purpose
instructions (described in the following sections). There are no instructions that allow
the whole register to be examined or modified directly.
When a call is made to an interrupt or exception handler procedure, the processor
automatically saves the state of the EFLAGS registers on the procedure stack. When
University of Technology Software Model of the 80386DX
Department of Electrical & Electronic Eng. Microprocessor
Fourth Year-Microprocessor Eng. II Lecture Five-Page 6 of 8
Dr. Hadeel Nasrat
an interrupt or exception is handled with a task switch, the state of the EFLAGS
register is saved in the TSS for the task being suspended.
STATUS FLAGS
The status flags (bits 0, 2, 4, 6, 7, and 11) of the EFLAGS register indicate the
results of arithmetic instructions, such as the ADD, SUB, MUL, and DIV
instructions. The functions of the status flags are as follows:
Control Flags
DF (bit 10) Direction flag: Controls the string instructions (MOVS, CMPS, SCAS,
LODS, and STOS). Setting the DF flag causes the string instructions to auto
decrement (that is, to process strings from high addresses to low addresses). Clearing
the DF flag causes the string instructions to auto-increment (process strings from low
addresses to high addresses). The STD and CLD instructions set and clear the DF
flag, respectively.
TF (bit 8) Trap flag: Set to enable single-step mode for debugging; clear to disable
single-step mode.
IF (bit 9) Interrupt enable flag: Controls the response of the processor to maskable
interrupt requests. Set to respond to maskable interrupts; cleared to inhibit maskable
interrupts.
The system flags and IOPL field in the EFLAGS register control operating-
system or executive operations. They should not be modified by application
programs. The functions of the status flags are as follows:
IOPL (bits 12 and 13) I/O privilege level field: Indicates the I/O privilege level of
the currently running program or task. The current privilege level (CPL) of the
currently running program or task must be less than or equal to the I/O privilege level
to access the I/O address space. This field can only be modified by the POPF and
IRET instructions when operating at a CPL of 0.
NT (bit 14) Nested task flag: Controls the chaining of interrupted and called tasks.
Set when the current task is linked to the previously executed task; cleared when the
current task is not linked to another task.
University of Technology Software Model of the 80386DX
Department of Electrical & Electronic Eng. Microprocessor
Fourth Year-Microprocessor Eng. II Lecture Five-Page 8 of 8
Dr. Hadeel Nasrat
RF (bit 16) Resume flag. Controls the processor’s response to debug exceptions.
VM (bit 17) Virtual-8086 mode flag. Set to enable virtual-8086 mode; clear to
return to protected mode.
AC (bit 18) Alignment check flag: Set this flag and the AM bit in the CR0 register
to enable alignment checking of memory references; clear the AC flag and/or the AM
bit to disable alignment checking.
VIF (bit 19) Virtual interrupt flag: Virtual image of the IF flag. Used in
conjunction with the VIP flag. (To use this flag and the VIP flag the virtual mode
extensions are enabled by setting the VME flag in control register CR4.)
VIP (bit 20) Virtual interrupt pending flag: Set to indicate to that an interrupt is
pending; clear when no interrupts are pending. (Software sets and clears this flag. The
processor only reads it.) Used in conjunction with the VIF flag.
ID (bit 21) Identification flag: The ability of a program to set or clear this flag
indicates support for the CPUID instruction.
Microcomputer Block Diagram
A dd re ss Bu s
CPU
Da ta Bus
Co n tro l Bu s
In t e rf a ce Circ uit r y
RAM ROM
Perip h er a l D e vice s
F1-1
TM-1
CPU Functional Units
CPU
Re g ist e r 0
Inst r u ct io n De co d e
an d C on t r o l U nit
Re g ist e r 1
A r it h m et ic an d
Lo g ic Un it ( A LU )
Reg ist er n - 1
F1-2
TM-2
Opcode Fetch
CPU
A d dr e ss Bu s
Pr o g ram
Co u n t e r
D a t a Bu s
Op c od e RA M
Inst ru ct io n
Re g ist e r N+2
N+1
Co nt ro l
Bus Op co d e N
Clo ck N-1
Re ad
F1-3
TM-3
Memory Maps
1 Byte
F FFF 7 6 5 4 3 2 1 0 6 5 ,5 3 5 FF FF
4 K ROM
F0 0 0
EFFF
4 4 K Em pt y
H exa d ec im al De cim a l
A d dr esse s A dd re sse s
.
4000
. 3 FFF
.
0004 4
1 6 K RA M
0003 3
0002 2
0001 1
0000 0 0000
F1-6/7
TM-4
16-Bit Addresses
Bit 1 5 =
B it 0 =
m os t -sig n if ican t b it
lea st -sig n if ica nt bit
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
(a )
9 C F 3
1 0 0 1 1 1 0 0 1 1 1 1 0 0 1 1
(b )
F1-8
TM-5
The Development Cycle
Int egrate
Concept and Product
verify
1-11
TM-6
Steps in
the Development Cycle
Sou rc e Ob je ct A b so lut e
L in ke r/ So f t ware
Edit o r f ile A sse m b le r f ile o b je ct Sim ula t o r
lo ca t o r sim u lat io n
(. SRC) (. OBJ) f ile
Ha rdw are
Em u lat o r
em u lat io n
He x Do wn lo ad /
Le g e nd : OBJHEX
f ile t e rm in al RA M
c o nv er sio n
(. HEX) e m ula t e
Ut ilit y p ro g ram o r
d ev elo p m e nt t o o l
Use r f ile
EPROM
EPROM
Pro g ram m er
Ex ec ut io n e nv iro nm e n t
Fact o ry
m ask ROM
p ro ce ss
1-13
TM-7
Motorola S-records
S00900006D796E616D656F
S11320003C3C000A327C201661000020534666F4F2
S11320101E3C00E44E4E53636F7474204D61634B59
S10C2020656E7A6965200D0A0061
S113202A1E3C00F81019670000064E4E60F64E7505
S9030000FC
(a)
S1 1 3 2 0 0 0 3 C3 C0 0 0 A 3 2 7 C2 0 1 6 6 1 0 0 0 0 2 0 5 3 4 6 6 6 F4 F2
Che ck sum
Da t a By t es
Lo ad A d d r ess
Byt e Co u n t
Re co r d T y pe
(b)
1-14
TM-8
68000 Programmer's Model
31 16 15 8 7 0
D0
D1
D2
D3 D at a
D4 Re g is t e rs
D5
D6
D7
31 16 15 0
A0
A1
A2 A dd re ss
A3
Reg ist ers
A4
A5
A6
31 16 15 0
31 24 23 0
PC Pro g ra m Co un t er
15 8 7 0
SR St a t u s Re g ist e r
123
CCR
F2-1
TM-9
68000 Status Register
U ser By t e
Syst e m Byt e ( Co nd it io n Co d e Re gist er )
15 13 10 9 8 4 3 2 1 0
T S I2 I1 I0 X N Z V C
123
Carry
Ove rf lo w
Ze ro
Ne g at ive
Sig n Ex t e nd
Int er rup t M ask
Sup e rviso r St a t e
Trac e Mo d e
F2-4
TM-10
Condition Code Computation
1 1 1
00011001 C = Sm D m + Rm D m + Sm Rm
= 0 0 + 0 0 + 0 0
+ 01110000 = 0
10001001 Z = 0 V = Sm Dm Rm + Sm D m Rm
= 0 0 0 + 1 1 1
N = 1 = 1
X = C = 0
Rm = 1
Dm = 0
Sm = 0
F2-5
TM-11
68000 Memory Map
-- Byte View --
1 By t e
( 8 b it s)
F FFFF F
0 000 04
0 000 03
0 000 02
0 000 01
00 000 0
F2-7
TM-12
68000 Memory Map
-- Word View --
1 W ord ( 1 6 b it s)
FFF FFE
N ot e :
Ev e n b y t e s co r re spo n d
t o u p pe r b yt es o n t h e
ex t e rn al d at a b us. Od d
b yt es c o r r esp o n d t o lo w e r
b yt es o n t h e e xt er n al
d at a b us.
By t e 4 By t e 5
By t e 2 Byt e 3
By t e 0 By te 1
0 000 04
0 000 02
00 000 0
F2-8
TM-13
68000 Memory Map
-- Longword View --
1 L o ng w or d ( 3 2 b it s )
W or d a dd re ss: n + 4
B yt e n + 4 et c.
n + 8
n + 4
L o ng w o rd s
n
ca n b e at a ny
e ve n a dd re ss
B yt e n B yt e n + 1 B y te n + 2 B y te n + 3
1 2 3 1 2 3
Wo rd ad d ress: n W o rd ad dr ess: n + 2
F2-9
TM-14
68000 Addressing Modes
Assembler Effective Address
Mode Syntax Generation
Data Register Direct Dn EA = Dn
Address Register Direct An EA = An
Absolute Short xxx.W or <xxx EA = (next word)
Absolute Long xxx.L or >xxx EA = (next two words)
Register Indirect (An) EA = (An)
Postincrement Register Indirect (An)+ EA = (An), An ` An + N
Predecrement Register Indirect -(An) An ` An - N, EA = (An)
Register Indirect with Offset d16(An) EA = (An) + d16
Register Indirect with Index & Offset d8(An,Xn) EA = (An) + (Xn) + d8
PC Relative with Offset d16(PC) EA = (PC) + d16
PC Relative with Index and Offset d8(PC,Xn) EA = (PC) + (Xn) + d8
Immediate #data DATA = next word(s)
Implied Register CCR, SR, USP, EA = CCR, SR, USP, SSP, PC
SSP, PC
Notes:
EA = effective address PC = program counter
An = address register ( ) = contents of
Dn = data register d8 = 8-bit offset (displacement)
Xn = address or data register used as index register d16 = 16-bit offset (displacement)
CCR = condition code register N = 1 for byte, 2 for word, 4 for longword. (If An is the
SR = status register stack pointer and the operand size is byte, N = 2 to
USP = user stack pointer keep the stack pointer on a word boundary.)
SSP = supervisor stack pointer ` = is replaced by
T2-1
TM-15
Data Register Direct
Register Contents
Before:....D0.....10204FFF
...........D3.....1034F88A
On ly b it s 0 -7
af f ec t e d
After:.....D0.....10204FFF
...........D3.....1034F8FF
F2-10
TM-16
Address Register Direct
Register Contents Mo ve t o
a d dr e ss r e g ist e r
Before: A0.....00200000
A3.....0004F88A
3 2 bit s are
After: A0.....0004F88A m ov e d
A3.....0004F88A
F2-11
TM-17
Absolute Short
So urc e a dd re ssin g
m o d e is im m e d ia t e
Instruction: MOVE.L #$1E,$800
F2-13
TM-18
Absolute Long
F2-14
TM-19
Register Indirect
F2-17
TM-20
Postincrement Address
Register Indirect
F2-18
TM-21
Predecrement Address
Register Indirect
F2-19
TM-22
Register Indirect
With Offset
F2-20
TM-23
Register Indirect
With Index and Offset
A d dr ess r e g ist e r
Ind e x r eg ist er , 3 2 b it s
Instruction: MOVEA $10(A0,D0.L),A1
00101D 10 A1 FFFFEF10
D0 00000002
No t e:
EA = $ 1 0 + $ 1 0 0 A + $ 2 = $ 1 0 1 C
F2-22
TM-24
PC-Relative
With Offset
F2-23
TM-25
PC-Relative
With Index and Offset
F2-26
TM-26
Immediate
Im m e dia t e d at a
f ollo w
Instruction: MOVE.L #$1FFFF,D0
F2-28
TM-27
68000 Signals
Vc c (2 )
A d dr ess Bu s A1 -A 2 3
GND (2 )
68000
D at a Bu s D0 -D1 5
CL K
AS
R/ W A syn ch ro n o us
FC0 UDS Bu s
Pro ce ssor Co n t ro l
FC1 L DS
St a t u s
FC2 D TA CK
MC 6 8 0 0 E BR Bu s
Perip h era l V MA BG A rb it ra t io n
Co n t ro l VPA BGAC K Co n t ro l
B ERR IPL0
Sy st e m In t e rrup t
RESET IPL1
Co n t r ol Co n t ro l
HA L T IPL2
F2-33
TM-28
Upper Data Strobe and
Lower Data Strobe
Int er n a l Bu s
Sig n als Sig n als
A2 3 A2 3
A1 A1
A0 WORD / BYT E A0 U DS L DS
UD S
( ev en b yt e) 1 X 0 0
0 0 0 1
LD S 0 1 1 0
WORD / BYT E
( o dd b yt e )
( a) (b )
F2-34
TM-29
Decoding with
-UDS and -LDS
68 0 00
A 1 -A2 3 A d d r e ss B us
D 8 -D 1 5 D a t a B us ( u pp e r b y t e)
D 0 -D7 D a t a B us ( l ow er b y t e )
A d dre ss
Up p er Lo wer
De co d ing RA M RAM
CS CS
UD S
L DS
F2-36
TM-30
Generation of -DTACK
A d dre ss Bu s
6 80 0 0
A dd re ss RA M Ad d re s s RA M
De co d ing D e co d ing
CS CS
74 07 740 7
+5 V
10 K
Fro m o t h e r RA Ms ,
DT A CK
ROM s, I/ O De v ic es , et c.
F2-36
TM-31
Function Code Outputs
Function Code
0 0 0 (Undefined, reserved)
0 0 1 User Data
0 1 0 User Program
0 1 1 (Undefined, reserved)
1 0 0 (Undefined, reserved)
1 0 1 Supervisor Data
1 1 0 Supervisor Program
1 1 1 CPU Space (Interrupt Acknowledge)
T2-3
TM-32
Read Cycle Timing
DT AC K m u st b e D at a lat ch e d in t o
asse rt ed b ef o r e t h e e n d CPU at be g in nin g
o f S4 , ot h erw ise w ait o f S7
st at es ar e in sert ed
S0 S1 S2 S3 S4 S5 S6 S7
CLK
FC0 -FC2
A1 -A2 3
AS
UDS
L DS
R/ W
DT A CK
D8 - D1 5
D0 - D7
F2-39
TM-33
Write Cycle Timing
S0 S1 S2 S3 S4 S5 S6 S7
CL K
FC0 -FC2
A1 -A2 3
AS
UDS
L DS
R/ W
DT A CK
D8 - D1 5
D0 - D7
F2-40
TM-34
Data Movement Instructions
Instruction Operation
TM-35
Integer Arithmetic Instructions
Instruction Operation
ADD Add source to destination
ADDA Add source to address register
ADDI Add immediate data to destination
ADDQ Add short data to destination
ADDX Add with extend bit to destination
CLR Clear operand
CMP Compare source to destination
CMPA Compare source to address register
CMPM Compare memory
DIVS Signed divide
DIVU Unsigned divide
EXT Sign extend
EXTB Sign extend byte
MULS Signed multiply
MULU Unsigned multiply
NEG Negate
NEGX Negate with extend
SUB Subtract source from destination
SUBA Subtract source from address register
SUBI Subtract immediate from destination
SUBQ Subtract short from destination
SUBX Subtract with extend bit from destination
T3-4
TM-36
CMP Example
After: D7 FFFFFF7A D7 d o e s n o t
ch an g e
SR 0014
Notes: 01111010
- 01111010
00000000
12 3
Z= 1
N = 0
V = 0 ( sig n b it d oe s n ot ch an g e)
C = 0 ( b o rro w no t re q u ir ed )
X = 1 (n o ch an g e)
F3-5
TM-37
DIVS Example
Register Contents
D ivid en d , 1 4
Before: D7 0000000E
SR 001F
After: D7 0002FFFC Qu o t ie n t , -4
SR 0018
Re m ain d er , 2
TM-38
Boolean Instructions
Instruction Operation
OR OR source to destination
T3-5
TM-39
EOR Example
Notes: ABCDEF10
+ 12345678
B9F9B968
1 2 3
Z= 0
N = 1
V = C = 0 ( alw a ys)
X = n ot af f e ct e d ( assu m e 0 )
F3-10
TM-40
Shift and Rotate Instructions
Instruction Operation Bit Movement
Op er a nd C
ASR Arithmetic shift right
X
C Ope ra nd 0
LSL Logical shift left
X
0 Op e ran d C
LSR Logical shift right
X
1 6 b it s 1 6 b it s
SWAP Swap words of a longword
T3-6
TM-41
ASR Example
A rit hm e t ic shif t
Instruction: ASR.B D3,D2 righ t : sig n b it
d o es n o t ch an g e !
Register Contents
Sh if t c o un t in D3
Before: D3 00000002
D2 00000068
SR 001F Sh if t d at a in D 2
After: D3 00000002
D2 0000001A
SR 0000
Notes: 01101000
00110100
00011010 0
1 2 3
C = X = 0
Z= 0
N = 0
V = 0 ( alw ay s)
F3-11
TM-42
Bit Manipulation Instructions
Instruction Operation
TM-43
BTST Example
Register Contents
Bit 7 = 0
Before: D5 FFFFFF7F
SR 0000
After: D5 FFFFFF7F
SR 0004 Z = 1
F3-12
TM-44
Binary-Coded Decimal Instructions
Instruction Operation
TM-45
ABCD Example
O p e r an d siz e
alw a ys b y t e
Instruction: ABCD -(A3),-(A4)
SR 001F
Bot h a d dr ess r e g ist e r s
After: 00200E 98 A3 0000200E d e cr e m en t ed b y o n e
00210E 53 A4 0000210E
SR 0011
1 ---XNZVC
Notes: 10011000 00010001
01010100
+ 1 (X = 1 ) 98 + 54 + 1 = 15 3
1 1 ( t h e h u nd r e d s d ig it
11101101 is st o r e d in C & X)
+ 00000110 ( ad d 0 6 )
11 1
11110011
+ 01100000 ( ad d 6 0 )
01010011
1 2 3
Z= 0
C = X = 1
N = V = u nd e f ine d ( a ssum e 0 )
F3-13
TM-46
Program Flow Instructions
Instruction Operation
NOP No operation
+privileged instruction
T3-9
TM-47
BRA Example
F3-15
TM-48
BSR/RTS Example
BSR $ 4 0 F2
BEFO RE A FT ER
RE GIS T ERS: RE GIS T ERS:
PC 0 0 5 0 16 PC 0 0 4 0 F2
A7 0 000 305 0 A7 0 000 304 C
MA IN MA IN
00 501 A PROGRA M 00 50 1A PROGRA M
0 0 5 0 1 8 F0 DA 0 0 5 0 1 8 F0 DA
BSR $ 4 0 F2 BSR $ 4 0 F2
00 501 6 6 1 0 0 00 50 16 6 1 00
0 0 4 0 F A 4 E7 5 RTS 0 0 4 0 F A 4 E7 5 RTS
SU BROU TIN E SU BROU TIN E
0 0 4 0 F2 0 0 4 0 F2
00 3 05 0 1 234 A7 00 3 05 0 1 234
00 3 04 E 5 678 STA CK 00 3 04 E 5 01A STA CK
0 0 3 0 4 C 9 A BC 00 3 04 C 0 000 A7
a dd re ss o f
ins t ru ct ion
f o llo w in g BSR
RT S
BEFORE A FT ER
REGIST ERS: REGIST E RS:
PC 0 0 4 0 FA PC 0 05 01A ret u r n t o
A7 0 00 0 3 04 C A7 0 00 0 30 5 0 in st r u ct io n
f o llo w in g BSR
MEMORY: MEMORY:
MA IN MA IN
00 5 01 A PROGRA M 00 5 01 A PROGRA M
0 0 5 0 1 8 F0 DA 0 0 5 0 1 8 F0 DA
BSR $ 4 0 F2 BSR $ 4 0 F2
00 5 01 6 61 00 00 5 01 6 61 00
0 0 4 0 FA 4 E7 5 RT S 0 0 4 0 FA 4 E7 5 RT S
SU BROU TINE SU BROU TINE
0 0 4 0 F2 0 0 4 0 F2
F3-16
TM-49
System Control Instructions
Instruction Operation
+privileged instruction
TM-50
TRAP Example
Instruction: TRAP #5
000095 01
000096 80
PC sav ed o n
000097 F0 sy st e m st a ck
TM-51
68000 Instruction Format
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Operation Word
Immediate Operand
F3-19
TM-52
Effective Address Encoding
T3-11
TM-53
68000 Condition Code Encoding
TM-54
Opcode Map
Bits
15 through 12 Operation
0100 Miscellaneous
0101 ADDQ/SUBQ/Scc/DBcc
0110 Bcc/BSR
0111 MOVEQ
1000 OR/DIV/SBCD
1001 SUB/SUBX
1010 (Unassigned)
1011 CMP/EOR
1100 AND/MUL/ABCD/EXG
1101 ADD/ADDX
1110 Shift/Rotate
1111 (Unassigned)
T3-13
TM-55
Assembler Operation
PROG.OBJ
L eg e nd :
Ut ilit y p ro g ram
PRO G.SRC A68 K
Use r f ile
PROG.L ST
( a)
Inp u t
C o m m an d f ile Lis t ing O b je ct co d e
o ut ut f ile o ut p ut f ile A ssem ble r
op t ion s
F4-1
TM-56
Assembler Files
La b el Mn e m o nic Op er an d C om m en t
f ield f ie ld f ie ld f ield (e m p t y )
ORG.....$1000
PROG LEA.....$800,A0
MOVE.B..#50,D0
CLR.W...D7
Sou r ce
LOOP ADD.W...(A0)+,D7 f ile
SUBQ.B..#1,D0
BRA.....*
END
( a)
L ine nu m b e r
A d d re ss Co n t e n t s So u rce f ile
1 00001000.................ORG.....$1000
2 00001000.41F80800.PROG...LEA.....$800,A0
3 00001004.103C0032........MOVE.B..#50,D0
4 00001008.4247............CLR.W...D7 L ist in g
5 0000100A.DE58.....LOOP...ADD.W...(A0)+,D7 f ile
6 0000100C.5300............SUBQ.B..#1,D0
7 0000100E.60FE............BRA.....*
8 00001010.................END
(b )
F4-2
TM-57
Listing Examples
1 00001000 ORG $1000
2 00001000 6006 BRA *+8 ;"*" location counter
3 00001002 60FE BRA * ;branch to itself
4 00001004 6000FFFE HERE BRA HERE ;branch to itself
5 00001008 181B MOVE.B (A3)+,D4 ;indirect addressing
6 00000064 COUNT EQU 100 ;equate symbol to value
7 0000100A 3A3C0064 MOVE.W #COUNT,D5 ;symbol as immed. data
8 0000100E 3A3C0064 MOVE.W #100,D5 ;decimal
9 00001012 3A3C0064 MOVE.W #$64,D5 ;hexadecimal
10 00001016 3A3C0064 MOVE.W #144Q,D5 ;octal (A68K format)
11 0000101A 3A3C0064 MOVE.W #%01100100,D5 ;binary
12 0000101E 3E3CFFFB MOVE.W #-5,D7 ;negative number, decimal
13 00001022 3E3CFFFB MOVE.W #$FFFB,D7 ;negative number, decimal
14 00001026 3A390000 MOVE $F000,D5 ;data address
0000102A F000
15 0000F000 PORT EQU $F000 ;equate symbol as address
16 0000102C 3A390000 MOVE PORT,D5 ;data address (symbol)
00001030 F000
17 00001032 4E71 BACK NOP ;code address (NOP =
18 00001034 4E71 NOP ; no operation)
19 00001036 67FA BEQ BACK
20 00001038 END
F4-4
TM-58
Assemble-Time Operators
TM-59
Examples of
Assemble-Time Operators
F4-5
TM-60
Assembler Directives
T4-2
TM-61
Listing Examples
F4-8
TM-62
Linker Operation
P ROG .H EX
F ILE 1 . OB J Le g en d :
FIL E 2 .O BJ Ut i lit y pr o g r a m
X LIN K
F ILE 3 . OB J
Us er f ile
F ILE 4 . O BJ
PRO G. MA P
( a)
O pt i o ns
Co m m an d
f o llo w A bso l u t e
CPU o u t p u t f i le
In p ut f o r m at t e d L ist in g
f ile s in S- r ec o r d s f ile
F4-10
TM-63
User Mode vs. Supervisor Mode
FC2 = 0 1
SR access
Read: Entire SR Entire SR
Write: CCR bits only Entire SR
T6-1
TM-64
Changing Between
User Mode and Supervisor Mode
T ra ns it io n m a y o cc ur o n ly
d ur in g ex ce pt io n p r o ce ssing
U ser Su pe rv isor
M o de Mo d e
F6-1
TM-65
Exception Tree
Exc ep t ion
Ext e r n al Int e r na l
Exec ut io n
In t er r u p t In st r uc t io n
Er r o r
T RA P A - lin e o r
Use r A ut o Bu s D iv id e- Pr iv ileg e A d dr ess Ille g al
Re s e t T RA PV T r a ce F- line
V e ct o r V e ct o r Er r o r b y - ze r o V io la t io n Er r o r In s t r uc t io n
CH K Em ula t io n
F6-2
TM-66
Exception Processing Sequence
St art e xc ep t ion
Ma ke in t ern al
c op y of SR
S = 1, T = 0
y es Up d at e in t e rru p t
Int err up t
? m a sk lev el
no
Ob t a in v ec t o r
n um be r
V ec t o r a dd re ss =
ve ct or n u m b er x 4
Pus h PC an d c o pie d
SR o n t o st ac k
( V ec t o r ad d re ss)
-----> PC
C on t in u e e xe cu t io n
F6-3
TM-67
Stack Frame for Exceptions
Hig h -Me m o r y
15 0
n+6 SP ( old )
n+4 Pro g r am Co u nt e r ( lo w )
n+2 Pr o g ra m C o un t e r (h ig h )
n St at u s Re g ist e r SP ( n ew )
Lo w -Mem or y
F6-4
TM-68
Exception Vector Address
A3 1 A 10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
all ze r o s V7 V6 V5 V4 V3 V2 V1 V0 0 0
1 4 4 4 2 4 4 4 3
V e ct o r n u m b er
F6-5
TM-69
Reset and Exception
Vector Assignments
Vector Hexadecimal
Number Address Assignment
0 000 Reset SSP†
– 004 Reset PC†
2 008 Bus Error
3 00C Address Error
4 010 Illegal instruction
5 014 Divide-by-zero
6 018 CHK instruction
7 01C TRAPV instruction
8 020 Privilege violation
9 024 Trace
10 028 Line 1010 emulator
11 02C Line 1111 emulator
12 030 (reserved)
13 034 (reserved)
14 038 Format error (68010)
15 03C Uninitialized interrupt vector
16-23 040-05C (reserved)
24 060 Spurious interrupt††
25 064 Level 1 interrupt autovector
26 068 Level 2 interrupt autovector
27 06C Level 3 interrupt autovector
28 070 Level 4 interrupt autovector
29 074 Level 5 interrupt autovector
30 078 Level 6 interrupt autovector
31 07C Level 7 interrupt autovector
32-47 080-0BC TRAP instruction vectors†††
48-63 0C0-0FC (reserved)
64-255 100-3FC User interrupt vectors
† The reset vector is four words and resides in the supervisor program (SP)
space. All other vectors reside in the supervisor data (SD) space.
†† The spurious interrupt vector is taken when there is a bus error during an
interrupt acknowledge cycle.
††† Trap #n uses vector number 32 + n. See Table 6-5.
T6-2
TM-70
Exception Grouping and Priority
T6-3
TM-71
Traps vs. Subroutines
Features Traps Subroutines
T6-4
TM-72
Vector Assignments for
TRAP Instructions
Instruction Vector Vector
Number Address
TRAP #0 32 $000080
TRAP #1 33 $000084
TRAP #2 34 $000088
TRAP #3 35 $00008C
TRAP #4 36 $000090
TRAP #5 37 $000094
TRAP #6 38 $000098
TRAP #7 39 $00009C
TRAP #8 40 $0000A0
TRAP #9 41 $0000A4
TRAP #10 42 $0000A8
TRAP #11 43 $0000AC
TRAP #12 44 $0000B0
TRAP #13 45 $0000B4
TRAP #14 46 $0000B8
TRAP #15 47 $0000BC
T6-5
TM-73
Stack Frame for
Bus Error and Address Error
Hig h - Me m o ry
15 0
n+1 4 SP (o ld )
n+1 2 Prog r a m Co u nt er ( lo w )
n+1 0 Pr o g ram Co u n t e r ( h ig h)
n+ 8 St at us Re g ist e r
n+ 6 In st ruc t io n Re g is t e r
n+ 4 Ac ce s s ad d r es s ( lo w )
n+ 2 A c c ess a dd re ss (h ig h )
n A cc es s t yp e SP ( ne w )
Lo w -M em o ry
( a)
15 5 4 3 2 1 0
u n de f in ed R/ W I/ N FC 2 FC1 FC 0
142 4 3
Fu nc t io n C o de
I/ N
0 = in s t r uc t io n
1 = n o t a n in st r u ct io n
R/ W
0 = w r it e c yc le
1 = re ad cy cle
( b)
TM-74
F6-6
TM-75
Power-on Reset Timing
...
CL K
+5V
Vcc
0V
> 100 ms
RESET
H A LT
< 4 c lo c ks 1
B u s Cyc les SS P H SSP L PC H PC L
14 42 44 3 1 44 24 43 144244
In it ializ e SSP In it ializ e P C E xec ut e 1 st
in st ru c t io n
L eg e nd :
Bus s t at e u n kn ow n Bu s c y cle ( m e m o ry r e ad o r m em o r y w r it e )
F6-7
TM-76
A Switch as an Input Device and an
LED as an Output Device
+5 V
Sw it c h L ED
Re sist o r
OPEN OF F
Sw it c h LED 22 0 Ω
CL OSED ON
W ir e
( a)
+5 V
Sw it c h L ED
Re sis t o r
OPEN ?
Sw it c h L ED 22 0 Ω
CL OSED ?
Co m p u t e r
( b)
F7-1
TM-77
Interface to Switches and LEDs
(conceptual)
D at a Bu s
Ad d re ss Bus
L ED # 7
+5 V
D15 D1 5
D Q
6 800 0
D14 D1 4
D Q
D13 D1 3
D Q
A23 A2 3
D12 D1 2
A22 A2 2 D Q
0 A21
A20
D11 0 A2 1
A2 0
D1 1
D Q
A19 D10 A1 9 D1 0
D Q
0 A18
A17
A16
D9 0 A1 8
A1 7
A1 6
D9
D Q
D8 D8
A15 A1 5 D Q
A14 A1 4
C A13
A12
C A1 3
A1 2 WRIT E LED S
L ED # 0
D T A CK
Co n t ro l Bu s
F7-2
TM-78
Timing for MOVE.B $00C000,D0
Hig h- w o rd o f Lo w - w o rd o f Me m o ry
Op co d e a d dr ess ad d re ss lo ca t io n
f et ch ( $0 000 ) ( $ C0 0 0 ) $ 0 0 C0 0 0
Mem or y M em o ry Me m o r y M em or y
r e ad r e ad r ea d r e ad
CPU clo ck :
123
One clo ck
t im e
p er io d
t hre e - st a t e
b uf f ers e na b led
D a t a f r o m sw it ch e s
lat ch ed int o r eg ist er
S0 S1 S2 S3 S4 S5 S6 S7
D 0 , b it s 0 -7 , a t
t h e st ar t of S7
CL K
F C0 -FC2
A1 - A 2 3 $ 0 0 C0 0 0
AS
UDS
LD S
R/ W
DT A CK
D 8 -D1 5 sw it c h d at a
D 0 -D7
F7-3
TM-79
Example of Partial Decoding
A 23 A 23
A 22 A 22
0 A 21
A 20
0 A 21
A 20
A 19 A 19
0 A 18
A 17
A 16
0 A 18
A 17
A 16
REA D SW IT CH ES W RIT E L ED S
A 15 A 15
A 14 A 14
C A 13
A 12
C A 13
A 12
UDS UDS
AS AS
R/ W R/ W
( a)
A d dr e ss:
0 0 C X X XXX0
(b )
F7-5
TM-80
Flowcharts for
Program-Conditional I/O
In pu t F lo w c h ar t : O ut p ut Flo w c h a r t :
E nt er En t e r
Rea d D e v ic e Re ad D ev ice
S t a t u s Flag S t at us F la g
NO D e vic e NO De v ic e
Re ad y Rea d y
? ?
YE S Y ES
In p ut Ou t p u t
D at a Da t a
Ex it Exit
( a) (b )
F7-7
TM-81
Keyboard Interface
D a ta Bu s
D8
Ke yb o ard
D1 5
KBD D Q
D A TA D1 4
D Q
D1 3
D Q
D1 2
D Q
D1 1
D Q
D1 0
D Q
D Q D9
D8
D Q
F L AG
K EYH IT
S
Q
R
REA D K BD D A T A
REA D KBD ST A T U S
( a)
Da t a ar e st o re d
A k ey is in lat ch an d
pr ess e d f la g is se t
KBD DA T A V alid D at a
K EYH IT
( b)
F7-6
TM-82
Interface Using a
Peripheral Interface IC
Da t a B us
CPU A d dr ess Bu s
Co nt ro l Bus
Pe r ip h e r al In t er f a ce IC
A1 Re ad W rit e
A0
St at us C o nt ro l
R/ W e t c. etc .
e t c. etc .
A d d r e ss
CS In p u t Ou t p u t
D ec o din g
Pe ri p h er a l Dev ic e
F7-9
TM-83
Program Execution
Without Interrupts or
With Interrupts
t im e
M ain P r o g r am
( a)
Int er r up t - le v el
ISR ISR ISR
exe c u t io n
* ** * ** * **
Base - lev el
M ain Ma in M ain Ma in
exe c u t io n
* Int er r up t
** Ret ur n f r o m int e r r up t in s t r uc t io n
( b)
F7-11
TM-84
Interrupt Priority Conditions on -
IPL2, -IPL1, and -IPL0
Signal
1 1 1 0 No interrupt - -
0 0 0 7 Interrupt No Highest
T7-3
TM-85
Autovectors for
Automatic IACK Cycles
Vector Address
Interrupt (Autovector)
0 -
1 $000064
2 $000068
3 $00006C
4 $000070
5 $000074
6 $000078
7 $00007C
T7-4
TM-86
Vector Addresses for
User IACK Cycles
0 $000000
1 $000004
2 $000008
etc. etc.
255 $0003FC
T7-5
TM-87
Interrupt Circuitry
+5 V
74 07
1 0K
V PA
680 00 7 4 HC 1 3 8
A3 C 7 IA C K 7
A2 B 6 IA C K 6
N o n - Mas k ab le
A1 A 5 IA C K 5
In t er r u p t ( NM I)
4 IA C K 4
+5 V
3 IA C K 3
E1 2 IA C K 2
E2 1 IA C K 1
+5 V 7 4 H C1 4 8 E3 0
IN T 7 7 A2 IPL 2
IN T 6 A1 7 4 H C1 3 8
6 IPL 1
IN T 5 5 A0 IPL 0 FC 2 C 7 IA ( In t e rr up t Ac k n o w led g e )
IN T 4 4 FC 1 B 6 S P ( Sup e r v is o r P r og r a m )
IN T 3 3 FC 0 A 5 S D ( Su p e r v is o r Da t a )
IN T 2 2 4
IN T 1 1 +5 V 3
+5 V 0 E1 2 UP ( Us er P ro g ram )
AS E2 1 UD ( Us er D at a)
E1 E3 0
F7-12
TM-88
Bus Connections for DMA Interface
Da t a Bu s
CPU
A dd re ss Bu s
C o nt ro l Bu s
DMA
Me m o r y Dev ic e
Co n t r o lle r
F7-13
TM-89
Device-to-Memory
Transfer Using DMA
D at a Bu s
A dd re ss Bu s
Co n t r o l Bus
DMA
Me m o r y Dev ic e
Co n t ro l le r
F7-14
TM-90
68000 Bus Arbitration
Control Signals
68 000
CPU D MA
Co nt ro lle r
BR BR
BG BG
BGA CK BGA CK
F7-15
TM-91
Bus Arbitration
6 8 0 0 0 CPU DMA Co n t r ol le r
Re qu e st t he Bus
1 . A ssert b us r e q ue st
( BR = 0 )
Gr an t t he Bus
1 . A sse r t b u s g ran t ( BG = 0 )
1 . A ssert b us g r a nt
a ck no w le d ge (B GA CK = 0 )
2 . Ne g at e b u s req u e st
( BR = 1 )
1 . Ne g at e b u s gr an t ( BG = 1 )
a nd w a it f o r BGA CK t o be
n e ga t e d
Op er a t e as Bu s Mast e r
t im e 1 . Pe r f o r m d at a t r an sf e rs
acc o r d in g t o sam e r u les
t h e CPU u se s
1 . Ne g at e b u s g ran t
ack no w le d g e ( BGA CK = 1 )
Resu m e N o rm a l Pr o ce ssing
F7-16
TM-92
Timing for Bus Arbitration
t im e
BR
BG
BGA CK
1 2 3 1 4 4 2 4 4 3 1 2 3
CPU DM A C PU
cy cles cy cles cy cle s
F7-17
TM-93
Block Diagram of the 68KMB
Sy st e m
Cloc k 6 8 6 8 1 DUA RT
Re s e t
Sy st e m Bu ses
Cir c uit
Ext e rn al
Int err u p t s
F8-3
TM-94
68000 CPU
52
A2 3
A2 2 51
A2 1 50
14, 49 48
+5 V V cc A2 0
A1 9 47
16, 53 46
G ND A1 8
A1 7 45
68000 A1 6 44
43
15
CPU A1 5
A1 4 42
C LK
A1 3 41
A1 2 40 A d d r es s
+5 V 39 Bu s
A1 1
20 38
E A1 0
19 A9 37
V MA
21 A8 36
V PA
A7 35
13 A6 34
BR
11 33
BG A5
12 A4 32
B G A CK
A3 31
6 A2 30
AS
9 29
R/ W A1
Co n t r o l 7
U DS
Bu s 8 L DS
10 54
D T A CK D1 5
D1 4 55
28 56
F CO D1 3
27 57
F C1 D1 2
26 D1 1 58
F C2
D1 0 59
25 D9 60
IPL 0
24 61
IPL 1 D8 D at a
23 62
IPL 2 D7 Bu s
D6 63
22 64
B ERR D5
18 RESET D4 1
17 D3 2
H A LT
D2 3
7 X D1 4
1 0 KΩ 5
D0
F8-4
TM-95
68KMB Clock Circuit
7 4 HC 1 4
0 . 0 1 µF 47 Ω
1 2 3 4 5 6
C LK to
680 00
1K 1K
10
3.68 64 13 12
pF to
MHz BA U D CL K
686 81
F8-6
TM-96
68KMB Reset Circuit
+5 V +5 V
1N 1 0K
7 4 HC1 4 7 407
9 14
9 8 10
11 3 4
RESET
to
100 Ω 2
68 000
+ 1
2 2 µF H A LT
RESET
F8-7
TM-97
68KMB Interrupt Circuit
M ON IT OR
+ 2 2 µF
+5V 7 x 7 4 HC1 4 8
10K
4 6
IN T 7 7 A2 IPL 2
3 7
IN T 6 6 A1 IPL 1
9
Ext er na l IN T 5
2
5 A0 IPL 0 to
1 68 000
In t e r ru pt s IN T 4 4 740 7
13
IN T 3 3
12 15 13 12
IN T 2 2 E0 V PA
11 14
IN T 1 1 GS
10
+5 V 0 11 10
X1 6 5
E1
5 6
7 4 H C1 3 8
3 7
A3 C 7 IA CK7
2 9
A2 B 6 10 IA CK6
1
A1 A 5 IA CK5
11
4 12 IA CK4
+5V
7 4 H C1 3 8 6
3 IA CK3 to
13
E1 2 IA CK 2
f ro m 3 7 IA 4 14 686 81
FC 2 C 7 E2 1 IA CK1
680 00 2 9 5 15
FC 1 B 6 SP E3 0
1 10
FC 0 A 5 SD
11
4 12
+5 V 3
6 13
E1 2 UP
4 14
AS E2 1 UD
5 15
E3 0
F8-8
TM-98
68KMB Address Decoding
1 19
A20 I0 O8 EPROM 0 U
2 18
A19 I1 O7 EPROM 0 L
3 17
A18 I2 O6 EPROM 1 U t o EPRO M,
4 16
A17 I3 1 6 L8 O5 EPROM 1 L RA M , & D UA RT
5 15
A16 I4 O4 RA M0 U c hip se le ct inp u t s
f ro m 6 14
A15 I5 O3 RA M0 L
68 000 7 13
A14 I6 O2 D UA RT
8 12
UD S I7 O1
9
LDS I8 9 8
11
AS I9 D T A CK t o 6 800 0
20
+5 V Vc c 7 407
10
GN D
F8-9
TM-99
68KMB Memory Map
FFFFFE
Re f le ct ed 7 M w o rd s
200000
1FFFFE
Ex pa ns io n 9 9 2 K w o rd s
010000
8 M w o rd s
00FFFE ( 1 6 M b y t e s)
8 K w or d s
D UA RT
( I/ O)
00C000
1 M w o rd s
00BFFE
( 2 M b y t e s)
RA M0 U RA M 0 L 8 K w or d s
008000 ( syst e m / u ser )
007FFE
EPROM1 U EPROM1 L 8 K w or d s
( u ser )
004000
003FFE
8 K w o rd s
EPROM0 U EPROM0 L
( MON 6 8 K)
000000
F8-10
TM-100
Monitor EPROMs
2 19
A13 A1 2 D7 D15
23 18
A12 A1 1 D6 D14
A11
21 A1 0 2764A D5
17
D13
A10 24 A9 D4 16
25
EPROM 15
D12
A9 A8 D3 D11
3 A7 13
A8 D2 D10
f r om 4 ( m o nit or ) 12
A7 A6 D1 D9
68 000 A6
5 A5 D0
11
D8
6
A5 A4
7 + 5V
A4 A3
8 28
A3 A2 V cc
9 1
A2 A1 Vpp
10 A0 27
A1 PGM
22 t o / f ro m
OE
680 00
f ro m A d dr ess 20 14
EPROM0 U CS GN D
D ec od e Cir cu it
2 19
A13 A1 2 D7 D7
23 18
A12 A1 1 D6 D6
A11
21 A1 0 2764A D5
17
D5
24 16
A10 A9 EPROM D4 D4
25 15
A9 A8 D3 D3
3 A7 13
A8 D2 D2
4 12
f ro m A7 A6 ( m o nit or ) D1 D1
5 A5 11
680 00 A6 D0 D0
6
A5 A4
7 + 5V
A4 A3
8 28
A3 A2 V cc
9 1
A2 A1 Vpp
10 A0 27
A1 PGM
22
OE
f ro m A dd r e ss 20 14
EPROM0 L CS GN D
De co d e C ir cu it
F8-12
TM-101
User EPROMs
2 19
A13 A12 D7 D1 5
23 18
A12 A11 D6 D1 4
A11
21 A10 2764A D5
17
D1 3
24 16
A10 A9 EPROM D4 D1 2
25 15
A9 A8 D3 D1 1
3 A7 13
A8 (u se r ) D2 D1 0
f ro m 4 12
A7 A6 D1 D9
6 800 0 5 A5 11
A6 D0 D8
6
A5 A4
7 +5 V
A4 A3
8 28
A3 A2 Vc c
9 1
A2 A1 Vp p
10 A0 27
A1 PGM
22 t o/ f ro m
OE
68 000
f ro m A d d r ess 20 14
EPROM 1 U CS GND
D ec o de Cir cu it
2 19
A13 A12 D7 D7
23 18
A12 A11 D6 D6
A11
21 A10 2764A D5
17
D5
24 16
A10 A9 EPROM D4 D4
25 15
A9 A8 D3 D3
3 A7 13
A8 D2 D2
f ro m A7 4 A6 ( use r ) D1 12
D1
680 00 5 A5 11
A6 D0 D0
6
A5 A4
7 +5 V
A4 A3
8 28
A3 A2 Vc c
9 1
A2 A1 Vp p
10 A0 27
A1 PGM
22
OE
f ro m A d dr ess 20
CS 14
EPROM1 L GND
D ec od e Cir cu it
F8-13
TM-102
System/User RAM
2 19
A13 A12 D7 D1 5
23 18
A12 A11 D6 D1 4
A11
21 A10 6264 D5
17
D1 3
A10 24 A9 D4 16
25
RA M 15
D1 2
A9 A8 D3 D1 1
3 A7 13
A8 D2 D1 0
A7 4 A6 D1 12
D9
f ro m 5 A5 11
A6 D0 D8
6 800 0 6
A5 A4
7 +5V
A4 A3
8 28
A3 A2 Vcc
9 26
A2 A1
10 A0
A1
27 W
22 t o / f ro m
R/ W OE
68 000
f r o m A d dr ess 20 14
RA M0 U CS GND
D ec od e Cir cu it
2 19
A1 3 A12 D7 D7
23 18
A1 2 A11 D6 D6
A1 1
21 A10 6264 D5
17
D5
24 16
A1 0 A9 RA M D4 D4
25 15
A9 A8 D3 D3
3 A7 13
A8 D2 D2
4 12
A7 A6 D1 D1
f ro m 5 A5 11
A6 D0 D0
6 800 0 6
A4
A5 +5V
7
A4 A3
8 28
A3 A2 Vcc
9 26
A2 A1
10 A0
A1
27 22
R/ W W OE
f ro m A d dr e ss 20 14
RA M0 L CS GND
D ec od e Cir cu it
F8-14
TM-103
68681 DUART
J3
D B2 5 S
25 30 11 2 3
D7 D7 TxD A T1 I T1 O
16
D6 D6
24
D5 D5 31 12 2
17 14 T e r m ina l/
D4 D4 Rx DA R1 0 R1 I
23 7 H os t Co m p u t e r
D3 D3
18
D2
22
D2 68681 MA X
D1
19
D1
DUA RT 232 J8
D0 D0
t o / f ro m D B2 5 S
68 000 34 11 10 7 3
RESET RESET TxD B T2 I T2 O
8
R/ W R/ W
9 O p t io n al
D T AC K D T A CK 10 9 8 2
R2 0 R2 I Ser ia l
Rx DB
6 7 Por t
A4 RS4 +5V
5
A3 RS3 1 16
3
A2 RS2 + C1 + Vcc +
1
A1 RS1 3 2
4 X C1 - V+
t o / f ro m 21
IN T 2
37
IRQ 1 0 µF 4 6
In t e r r u pt Cir cu it IA CK 2 IA CK C2 + V-
+ +
f r om A d d r e ss 35 5 15
D UA RT CS C2 - G ND
D e co d e Cir c uit
f r o m Clo ck BA UD
32
C LK/ X1 J1
Cir cu it CL K
33 15 8
X2 O P7 26 7
O P6
14 9
O P5 27 3
O P4
13 17
O P3 28 4
40 O P2 12 11
+ 5V V cc O P1
29 5
O P0 Mis c ellan e ou s
20
G ND Inp u t / Ou t pu t
38 14
IP5 D ev ic e s
39 15
IP4 16
2
IP3 36 12
IP2 13
4
IP1
7 6
IP0
20
+5V
10
F8-15
TM-104
Expansion to 6800 Peripherals
J2
1
D7
2
D6
3
D5
4
D4
5
D3 6
D2
7
D1
8
D0
11
t o / f ro m A 16
680 00
14
A3
15
A2 Exp an sion t o
16 6 8 0 0 Pe rip he r a ls
A1
13
RESET
18
V PA
17
E
19
R/ W
t o / f ro m 12
IN T3
In t e r ru pt 9
SD
Circu it
20
+5V
10
2 0 - pin
h ea de r
F8-16
TM-105
68681 Interface to
LEDs and Switches
686 81
8 × +5 V
DU ART J1 7 4 LS2 4 4 220 Ω
15 8 17 3
OP7
26 7 15 5
OP6
14 9 13 7
OP5
27 3 11 9
OP4
13 17 8 12
OP3
28 4 6 14
OP2
12 11 4 16
OP1
29 5 2 18
OP0
20
1, 19
+5V
10
+5 V
38 14
IP5
39 15
IP4
2 16
IP3
36 12
IP2
4 13
IP1
7 6
IP0
6 ×
1 0 kΩ
F9-3
TM-106
Interface to Switches and
7-Segment LED
686 81
DU ART J1 +5 V
7 4 LS2 4 4
15 8 17 3 7 ×
OP7 22 0 Ω 14, 3
26 7 15 5 1
OP6 a
14 9 13 7 13 a
OP5 b
27 3 11 9 10
OP4 c f b
13 17 8 12 8 g
OP3 d
28 4 6 14 7
OP2 e e c
12 11 4 16 2 d
OP1 f
29 5 2 18 11
OP0 g
MA N 7 2 A
1, 19
20 7 -s eg m e nt
+5V
co m m o n
10
an od e LED
+5 V
2 16
IP3
36 12
IP2
4 13
IP1
7 6
IP0
4 ×
1 0 kΩ
F9-4
TM-107
4-Digit 7-Segment Display
+5 V
6 86 8 1 J1 18
V cc
28 4 5 8 × 4 × MA N 4 7 4 0 A
O P2 DA TA
47 Ω
12 11 13 4 14
O P1 CL OCK a aa
29 5 12 3 13
O P0 ENA BL E a a a a
b bb
2 8
20 c cc
+5 V MC1 4 4 9 9 f b f b f b f b
1 7 g g g g
10 d dd
17 6
e ee e c e c e c e c
16 1 d d d d
6 f ff
O SC
15 2 dp dp dp dp
0 .0 1 5 g g
µF 9
14 4
GN D h (d p ) dp
4 ,1 2 4,12 4 ,1 2 4 ,1 2
D4 D3 D2 D1
7 8 10 11 4 ×
2 N3 9 0 4
F9-6
TM-108
MC14499 Timing
t im e
ENA BL E ( OP0 )
CL OCK ( OP1 )
d1 d2 d3 d4 d1 9 d20
D AT A ( OP2 )
F9-7
TM-109
MC14499 Digit and Bit Sequence
t im e
Bit N o . 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 4 2 4 3 1 42 4 3 1 4 2 4 3 1 4 2 4 3 1 4 2 4 3
De cim a l Dig it D ig it D igit Dig it
Poin t s 1 2 3 4
F9-8
TM-110
8-Digit 7-Segment Display
MC1 4 4 9 9 MC1 4 4 9 9
DA TA h D A TA h
CL OCK C LO CK
EN ABL E EN AB LE et c.
F9-9
TM-111
68681 Input Expansion
Using 74LS165s
Ex t e r n al Inp u t s
J1
L SB MSB
6 868 1 20
D UA RT + 5V
10 6 4 3 14 13 12 11 6 5 4 3 14 13 12 11
5
H G F E D C B A H G F E D C B A
7 6 9 D AT A DA T A 1 0 9 D AT A DA T A 10
IP0 7 4 L S1 6 5 7 4 L S1 6 5
O UT IN O UT IN
G ND Vcc L O AD CL K G ND Vc c L O AD CL K
8, 1 5 16 7 1 2 8, 1 5 16 7 1 2 etc .
+ 5V nc +5V nc
12 11
O P1
29 5
O P0
F9-10
TM-112
6821 Interface to the 68000
J2
6 821
1 26 39
PIA CA 2
D7 D7
2 27 40
D6 D6 CA 1
3 28
D5 D5
4 29 9
D4 D4 PA 7
5 30 8
D3 D3 PA 6
6 31 7
D2 D2 PA 5
7 32 6
D1 D1 PA 4
8 33 5
D0 D0 PA 3
4
PA 2
9 23 3
PA 1
SD CS2
24 2
11 PA 0
A16 CS1
22
1 2 +5 V CS0
7 4 HC 0 0 17
3 PB 7
4
16
18 6 PB 6
VPA 5 15
34 PB 5
13
RESET RESET 14
21 PB 4
19
R/ W R/ W 13
PB 3
17 25
E E 12
PB 2
12 38
INT 3 IRQA 11
PB 1
14 37
A3 nc 10
IRQB PB 0
15 35
A2 RS1
16 36 19
A1 RS0 CB2
20 18
+5V 20 CB1
+5 V V cc
10
1
GN D
F9-11
TM-113
Keypad Interface to the 6821
68 21
2
PIA PA 0
3
PA 1
4
PA 2
5
PA 3
J H G F
0 1 2 3
6 N
PA 4
4 5 6 7
7 M
PA 5
8 9 A B
8 L
PA 6
C D E F
9 K
PA 7
Gra yh ill PN 8 8 BA 2
F9-12
TM-114
Output to a MC1408L8 DAC
68 21 M C1 4 0 8 L 8
+5V
9 5 1 kΩ
PA 7 D7 1 50 Ω
14
8 6 V r ef +
PA 6 D6
7 7 10 0 Ω
PA 5 D5
1 kΩ
6 8 15
PA 4 D4 V r ef -
5 9
PA 3 D3
4 10 1
PA 2 D2 nc 4 .7 k Ω
3 11
PA 1 D1
2 12 + 1 2 V -1 2 V
PA 0 D0
7
4 4
2
13 IO 6
+5 V V CC
VO
3
16
COMP 8 L M3 0 1
1
2
1 5 pF GND
V EE
3 3 3 pF
-1 2 V
F9-13
TM-115
Low-Pass Filter and Audio Output
0 .0 4 4 µ F
VO
( f ilt er ed )
2 .4 k Ω
A ux ilia r y
Jack
+12V -12V + 1 2 V -1 2 V
7 7
2 4
2
4
2 5 µF
1 .2 k Ω 1 .2 k Ω
6 6
VO
3 3 +
8 L M3 0 1 8 LM 3 0 1
5 kΩ Sp ea k e r
0 .0 2 2 µ F 1 ( lo w - pa ss 1
( vo lt ag e
f ilt e r ) f o llo w e r )
33 pF 3 3 pF
F9-15
TM-116
Interface to ADC0804
Analog-to-Digital Converter
AD C0 8 0 4
682 1 20
V cc +5V
19 3
C B2 WR 6
10 k Ω
Vin ( + ) t r im p o t
18 5 Di f f e re nt ial In p ut s
C B1 IN TR V in( - ) ( t r an sd uc er)
7
1
CS
2
RD
9
Vr ef nc
17 11 19
PB7 D7 C LK R
16 12
PB6 D6
15 13 1 5 kΩ
PB5 D5
14 14 4
PB4 D4 CL K IN
13 15
PB3 D3
12 16 1 5 0 pF
PB2 D2
11 17 10
PB1 D1 D GN D
10 18 8
PB0 D0 A GN D
F9-16
TM-117
Timing for ADC0804 Conversions
Clea r St a r t o f En d o f C le ar St ar t Ne xt
INT R Co n ve rsio n Co nv er sion IN TR Co nv er sio n
WR
≈ 1 0 0 µs
IN T R
F9-17
TM-118
Microphone Input to the ADC0804
+
+ 1 2 V -1 2 V
1 0 µF + 1 2 V -1 2 V
7 47 Ω 7 47 Ω
1 kΩ 2 4 2 4
6 6
Mic rop h o ne
1% 2 2 kΩ
3 3
200 Ω LM 3 0 1 +5V LM 3 0 1
8 8
( p r e -am p ) (a m p )
1 0 0 kΩ
1 1
2 2 kΩ
1%
33 pF 33 pF
+5 V
1N914
1 .2 k Ω
0 .0 4 4 µF
L F3 9 8
A DC0 8 0 4
( sa m p le an d h o ld )
2 .4 k Ω
+12V -1 2 V
1 .2 k Ω
+ 1 2 V -1 2 V 18 k Ω 5 . 6 kΩ 20
V cc +5 V
V 1
7 C 4
2 4
8
6 3
5
V
3 D
L M3 0 1
0 .0 2 2 µ F 8 6
1 ( lo w -p a ss f ilt e r ) 7
0 .0 0 1 µ F
6
1
V in (+ ) CS
7 2
33 pF V in (- ) RD
6 821
19 3
CB2 WR
18 5 9
CB1 IN T R V re f nc
19
17
CL K R
11
PB7 D7
16 12 15 k Ω
PB6 D6
15 13 4
PB5 D5 CL K IN
14 14
PB4 D4
13 15 1 50 pF
PB3 D3
12 16 10
PB2 D2 D GND
11 17 8
PB1 D1 A GND
10 18
PB0 D0
TM-119
F9-19
TM-120
Sample-and-Hold Waveforms
1 0 0 µ s m in im un
Sign a l a t V C
Sig n al at V D
V o lt a ge
T im e
F9-20
TM-121
68000-Family Features
48-pin 52-pin
68008 68008 68000 68010 68020 68030 68040
T10-1
TM-122
Comparison of Five Recent
Microprocessors †
Alpha
68040 80486 PowerPC Pentium 21064
Width (bits) 32 32 32 32 64
T10-10
TM-123
1
SPECIFICATION AND IMPLEMENTATION OF A MICROCOMPUTER
• ARCHITECTURE
• IMPLEMENTATION
• PROCESSOR;
• MEMORY SUBSYSTEM;
Memory I/O
subsystem subsystem
I/O devices
Virtual memory
(Disk) 2 Gbyte
Faster Larger
Main memory size
(Dynamic devices) 16 Mbyte
Cache memory
(Static devices) 64 Kbyte
Processor
11 IOAddr MemAddr 24
1 IOLength MemLength 1
1 IORd MemRd 1
1 IOWr MemWr 1
I/O I/O Memory
1 IOEnable
Processor MemEnable 1
devices subsystem subsystem
IORdy 1 1 MemRdy
32 IOData MemData 32
LIBRARY ieee;
USE ieee.std_logic_1164.all;
PACKAGE comp_pkg IS
SUBTYPE WordT IS STD_LOGIC_VECTOR(31 DOWNTO 0);
SUBTYPE MAddrT IS STD_LOGIC_VECTOR(23 DOWNTO 0);
SUBTYPE IOAddrT IS STD_LOGIC_VECTOR(10 DOWNTO 0);
SUBTYPE ByteT IS STD_LOGIC_VECTOR( 7 DOWNTO 0);
TYPE StatusT IS (undef, p_reset, fetch, execute, memop, ioop);
BEGIN
-- description of carry generation included here
RETURN(cy);
END get_carry;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE WORK.ALL, WORK.comp_pkg.ALL;
ENTITY Computer IS
PORT (Reset, Clk : IN STD_LOGIC);
END Computer;
BEGIN
U1: ENTITY Memory
PORT MAP (MemAddr, MemLength, MemRd, MemWr, MemEnable,
MemRdy, MemData);
U2: ENTITY IO
PORT MAP (IOAddr, IOLength, IORd, IOWr, IOEnable,
IORdy, IOData);
24
Addr
Word 0 Byte 3 Byte 2 Byte 1 Byte 0
Length Word 4 Byte 7 Byte 6 Byte 5 Byte 4
32
Rd Memory Data
Wr Word 224 -4
Enable Rdy 32 bits
(a) (b)
Addr
Enable
Rd
Rdy
tdv
(c)
Figure 15.4: MEMORY SUBSYSTEM. (a) EXTERNAL SIGNALS. (b) INTERNAL ORGANIZATION. (c) TIMING DIAGRAM
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE WORK.comp_pkg.ALL;
ENTITY Memory IS
PORT (Addr : IN MAddrT ; -- memory address bus
Length : IN STD_LOGIC; -- byte/word operand
Rd, Wr : IN STD_LOGIC; -- access control signals
Enable : IN STD_LOGIC; -- enable signal
Rdy : OUT STD_LOGIC; -- access completion signal
Data : INOUT WordT ); -- memory data bus
END Memory;
LIBRARY ieee;
USE ieee.std_logic_unsigned.ALL;
BEGIN
tCtrls:= Rd & Wr & Enable; -- group signals for simpler decoding
CASE tCtrls IS
-- output to tri-state
WHEN "000" => Data <= (OTHERS => ’Z’) AFTER Td;
-- timing verifications
ASSERT NOT (Rd’EVENT AND Rd=’1’ AND NOT Addr’STABLE(Tsu))
REPORT "Read address setup time violation";
END behavioral;
I/O Port 0
11 I/O Port 1
Addr
Length
I/O 32
Rd Data
subsystem
Wr
I/O Port 2047
Enable Rdy
32 bits
(a) (b)
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE WORK.comp_pkg.ALL;
ENTITY IO IS
PORT (Addr : IN IOAddrT ; -- I/O address bus
Length : IN STD_LOGIC; -- byte/word control
Rd, Wr : IN STD_LOGIC; -- I/O access control
Enable : IN STD_LOGIC; -- I/O enable control
Rdy : OUT STD_LOGIC; -- I/O completion signal
Data : INOUT WordT ); -- I/O data bus
END IO;
Processor state
• 32 general-purpose registers (32-bits wide), called R0, R1, ..., R31;
CR Z N C V
R31
Clk
MemEnable
Fetch instruction
MemRd
MemRdy
Execute Memory
Fetch Execute Fetch (Addr. access
calc.)
(a) (i) (ii)
Figure 15.7: BEHAVIOR OF THE PROCESSOR. (a) INSTRUCTION LOOP. (b) MEMORY BUS BEHAVIOR FOR REGISTER
OPERATION. (c) MEMORY BUS BEHAVIOR FOR LOAD OPERATION.
R1
addr.gen.
+4
R5
PC PC
R7
add R7,R1,R5 branch 2000
conds.
Memory Memory
CR
(a) (b)
+4 addr.gen.
selector cond?
PC
branch cond,2000
Memory
(c)
Figure 15.8: BEHAVIOR OF INSTRUCTIONS. (a) ADD instruction. (b) UNCONDITIONAL BRANCH INSTRUCTION. (c) CON-
DITIONAL BRANCH INSTRUCTION.
• SEQUENTIAL UNLESS
1. UNCONDITIONAL BRANCH
2. CONDITIONAL BRANCH
31 25 20 15 10 0
RT:= op(RA) Opcode RT RA --
RT:= RA op RB Opcode RT RA RB --
RT:= RA op SI Opcode RT RA SI
RT:= RA op UI Opcode RT RA UI
PC:= PC + 4 + D Opcode -- D
PC:= RA Opcode -- RA --
Figure 15.9: INSTRUCTION FORMATS.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE WORK.comp_pkg.ALL;
ENTITY processor IS
PORT (MemAddr : OUT MAddrT ; -- memory address bus
MemData : INOUT WordT ; -- data bus to/from memory
MemLength: OUT STD_LOGIC; -- memory operand length
MemRd : OUT STD_LOGIC; -- memory read control signal
MemWr : OUT STD_LOGIC; -- memory write control signal
MemEnable: OUT STD_LOGIC; -- memory enable signal
MemRdy : IN STD_LOGIC; -- memory completion signal
IOAddr : OUT IOAddrT ; -- I/O address bus
IOData : INOUT WordT ; -- data bus to/from I/O
IOLength : OUT STD_LOGIC; -- I/O operand length
IORd : OUT STD_LOGIC; -- I/O read control signal
IOWr : OUT STD_LOGIC; -- I/O write control signal
IOEnable : OUT STD_LOGIC; -- memory enable signal
IORdy : IN STD_LOGIC; -- I/O completion signal
Status : OUT StatusT ; -- processor status signal
Reset : IN STD_LOGIC; -- reset signal
Clk : IN STD_LOGIC); -- clock signal
END processor;
LIBRARY ieee;
USE ieee.std_logic_arith.all; -- use definitions and operations
USE ieee.std_logic_signed.all; -- on signed values
-- other declarations
CONSTANT delay : TIME := 200 ps; -- register delay
CONSTANT Reset_delay: TIME := 5 ns;
CONSTANT Exec_delay : TIME := 10 ns; -- Execute delay
CONSTANT Mdelay : TIME := 600 ps; -- MemEnable signal delay
CONSTANT Pulse_Width: TIME := 2.6 ns; -- memory signals width
CONSTANT Fetch_delay: TIME := 3 ns; -- disable memory after
-- access completed
BEGIN
PROCESS -- transition function
-- working variables
VARIABLE RS_data, RA_data, RB_data : WordT;
VARIABLE RT_addr, RA_addr, RB_addr, RS_addr : Natural;
BEGIN
WAIT ON Clk,Reset;
FOR i IN 0 TO 31 LOOP
GPR(i) <= (OTHERS => ’0’);
END LOOP;
-- instruction execution
Status <= Execute;
Phase <= Execute;
RA_addr := CONV_INTEGER(’0’ & RA); RB_addr := CONV_INTEGER(’0’ & RB);
-- ’0’ to force bit-vector to positive value
RA_data := GPR(RA_addr) ; RB_data := GPR(RB_addr) ;
RT_addr := CONV_INTEGER(’0’ & RT);
RS_addr := CONV_INTEGER(’0’ & RS); -- source reg. for store
RS_data := GPR(RS_addr) ; -- or I/O write
WAIT FOR Exec_delay;
CASE Opcode IS
WHEN "000000" =>
null; -- nop
WHEN "000010" =>
GPR(RT_Addr)<= not(RA_data); -- not
WHEN "000100" =>
GPR(RT_Addr)<= RA_data(30 DOWNTO 0) & ’0’; -- lshift
WHEN "000110" =>
GPR(RT_Addr)<= ’0’ & RA_data(31 DOWNTO 1); -- rshift
-- lrotate
WHEN "001000" => GPR(RT_Addr)<= RA_data(30 DOWNTO 0) & RA_data(31);
-- rrotate
WHEN "001010" => GPR(RT_Addr)<= RA_DATA(0) & RA_data(31 DOWNTO 1);
-- memory declaration
CONSTANT MaxMem: NATURAL:= 16#FFF#; -- 4Kbytes
TYPE MemArrayT IS ARRAY(0 to MaxMem-1) OF ByteT;
VARIABLE Mem : MemArrayT:=
(-- program
3=>"01100000", 2=>"00000000", 1=>"00000000", 0=>"00000000",
7=>"01000100", 6=>"00100000", 5=>"00000000", 4=>"00110010",
11=>"10000110", 10=>"10000001", 9=>"00000000", 8=>"00000000",
15=>"10000110", 14=>"10100001", 13=>"00000000", 12=>"00000100",
19=>"01000100", 18=>"01000000", 17=>"00000000", 16=>"00111111",
23=>"10001000", 22=>"01000001", 21=>"00000000", 20=>"00000000",
-- data
51=>"00110011", 50=>"00001111", 49=>"11110000", 48=>"11001100",
55=>"00110011", 54=>"00001111", 53=>"11110000", 52=>"11001100",
OTHERS => "00000000");
where the memory contents corresponds to the following instructions:
0x000000: xor R0,R0,R0 ; R0 = 0
0x000004: adi R1,R0,50 ; R1 = 50
0x000008: ldw R20,0(R1) ; R20= Mem(50,4)= Mem(48,4)
0x00000C: ldw R21,4(R1) ; R21= Mem(54,4)= Mem(52,4)
0x000010: adi R2,R0,63 ; R2 = 63
0x000014: stb R2,0(R1) ; Mem(50,1) = 63
0x000048: 0x330FF0CC
0x000052: 0x330FF0CC
• MEMORY SUBSYSTEM
• PROCESSOR
1. DATA SUBSYSTEM
2. CONTROL SUBSYSTEM
Rd
222 x1 bits
Wr Controller MRdy
Enable
Controls
Address 22
8 8 8 8
Length Selector/Distributor
32
Data
Condition signals
MemRdy
IORdy
Data Instr 32
signals ZE,NG,CY,OV 4
24
MemAddr
MemData 32 Data Control
subsystem subsystem
11
IOAddr
IOData 32
MemRd
MemWr
MemLength
MemEnable
IORd
IOWr
IOLength
IOEnable
Sin_Sout
Mem_ALU
MemData
0
Switch
MemData
DataB
1 0 1
Mux1 B MemAddr
AddrB WrIR
DataC Clk
DataA IR Reset
AddrC C A
WrC AddrA Instr
Extndr.
Register SE_ZE
file 0 1 1 0
PC_RA Mux2 Mux3 IR_RB
ALU
ALUOp WrCR
C
Cond
ALUdata Clk
Z N C V Reset
WrPC PCin
Clk ZE,NG,CY,OV
Reset PC
PCout
1 0 ALU_PC
Mux4
ALUop Operation
0000 Zero 32
0001 A+B
0010 A-B
0011 -B
0100 A and B
0101 A or B
0110 A xor B
0111 not(B)
1000 unused
1001 B
1010 shiftl(A)
1011 shiftr(A)
1100 rotl(A)
1101 rotr(A)
1110 A+4
1111 unused
2
Mem_ALU
2 MemData
DataB
Mux1 MemAddr
AddrB
4 DataC 2
DataA IR
2 3 1
AddrC AddrA Instr
2 3
WrC 2
Register 2
file
2 Mux2 Mux3 2
PC_RA IR_RB
Clk
2
4 2
ALUOp
Cond WrCR
Clk
Z N C V
ZE,NG,CY,OV
PC
ALU_PC
Clk
AddrA
AddrB
AddrC
ALUop
WrC
WrCR
DataA
DataB
DataC
Cond
1 2 3 4
instruction register ALUop register
decode read delay delay setup
AddrA
AddrB
AddrC
State ALUOp
Combinational
reg. ...
logic
...
ALU_PC
Clk
Reset
Fetch
ALU_PC <- 1 ALU_Op <- 1110
Memop
MemRd <- 1, 0 Sin_Sout <- 1 Mem_ALU <-
MemLength <- 1, 0 WrIR <- 1, 0 WrC <-
MemEnable <- 1, 0 WrPC <- 1, 0
PC_RA <- 0
(Op < 100000) (Op >= 100000)
and (Op > 100111) and (Op <= 100111)
Execute
AddrA <- Instr(20 downto 16) IR_RB <- Mem_ALU <-
AddrB <- Instr(15 downto 11) ALUOp <- ALU_PC <-
AddrC <- Instr(25 downto 21) MemLength <-
WrPC <- MemRd <-
PC_RA <- WrCR <- MemWr <-
ZE_SE <- WrC <- MemEnable <-
Sin_Sout <-
Clk
Register
operations Fetch Execute Fetch
Memory
operations Fetch Execute Memop Fetch
Figure 15.16: STATE DIAGRAM AND TIMING FOR CONTROL SUBSYSTEM OF THE PROCESSOR.
t6
Clk State Register
t0
NS= Execute
Control logic
t1 t1
t1
PC_RA=0 ALU_PC=1
t2 PC t2 MemAddr
t3 t4 MemData
WrPC=1 MemRdy=1
PC+4
Switch
t5
Instruction
t13 t12
t9 ALU
ALUData t14
t9 Mux1
DataC t15
t25
Clk State Register
t15 t20 t18
NS= Fetch
Memory Control logic
t21 MemRdy t19 t19
WrC=1
Switch
t22
Mux1
t23 DataC
Clk
Reg. File (t24)
t25
BEGIN
P1: ENTITY Data_Subsystem
PORT MAP (MemAddr, MemData, IOAddr, IOData,
Instr, ZE, NG, CY, OV, AddrA, AddrB, AddrC, ALUOp,
WrC, WrPC, WrCR, WrIR, Mem_ALU, PC_RA, IR_RB, ALU_PC,
ZE_SE, SinSout, Clk, Reset);
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE WORK.comp_pkg.ALL, WORK.ALL;
ENTITY Data_Subsystem IS
PORT(MemAddr : OUT MAddrT ;
MemData : INOUT WordT ;
IOAddr : OUT IOAddrT ;
IOData : INOUT WordT ;
Instr : OUT WordT ;
ZE, NG, CY, OV : OUT STD_LOGIC ;
AddrA, AddrB, AddrC : IN STD_LOGIC_VECTOR(4 DOWNTO 0);
ALUOp : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
WrC, WrPC, WrCR, WrIR : IN STD_LOGIC ;
Mem_ALU, PC_RA, IR_RB : IN STD_LOGIC ;
ALU_PC, ZE_SE, Sin_Sout: IN STD_LOGIC ;
Clk, Reset : IN STD_LOGIC);
END Data_Subsystem;
BEGIN
ALU1: ENTITY ALU
PORT MAP(Ain,Bin,ALUop,ALUdata,Cond);
GPR: ENTITY Reg_File
PORT MAP(AddrA,AddrB,AddrC,DataA,DataB,DataC,
WrC,Reset,Clk);
PC: ENTITY Reg
PORT MAP(ALUdata(23 DOWNTO 0),PCout(23 DOWNTO 0),
WrPC,Reset,Clk);
CR: ENTITY Reg
PORT MAP(Cond,CRout,WrCR,Reset,Clk);
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.ALL;
USE WORK.comp_pkg.ALL;
ENTITY Reg_File IS
PORT(AddrA, AddrB, AddrC : IN STD_LOGIC_VECTOR(4 DOWNTO 0);
DataA, DataB : OUT WordT;
DataC : IN WordT;
WrC : IN STD_LOGIC ;
Reset, Clk : IN STD_LOGIC);
END Reg_File;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_signed.ALL;
USE WORK.comp_pkg.ALL;
ENTITY ALU IS
PORT(A, B: IN STD_LOGIC_VECTOR(31 DOWNTO 0);
Op : IN STD_LOGIC_VECTOR( 3 DOWNTO 0);
C : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
Cond: OUT STD_LOGIC_VECTOR( 3 DOWNTO 0));
END ALU;
ENTITY Reg IS
PORT(Data_in : IN STD_LOGIC_VECTOR;
Data_out: OUT STD_LOGIC_VECTOR;
Wr : IN STD_LOGIC ;
Reset : IN STD_LOGIC ;
Clk : IN STD_LOGIC);
END Reg;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY Mux IS
PORT(A_in,B_in: IN STD_LOGIC_VECTOR;
Sel : IN STD_LOGIC ;
Data_out : OUT STD_LOGIC_VECTOR);
END Mux;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY Extender IS
PORT(X_in : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
ZE_SE : IN STD_LOGIC ;
X_out : OUT STD_LOGIC_VECTOR(31 DOWNTO 0));
END Extender;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY Switch IS
PORT(A : INOUT STD_LOGIC_VECTOR;
B_out: OUT STD_LOGIC_VECTOR;
C_in : IN STD_LOGIC_VECTOR;
Sel : IN STD_LOGIC );
END Switch;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE WORK.comp_pkg.ALL;
ENTITY Ctrl_Subsystem IS
PORT(Instr : IN WordT ;
ZE, NG, CY, OV : IN STD_LOGIC ;
AddrA, AddrB, AddrC : OUT STD_LOGIC_VECTOR(4 DOWNTO 0);
ALUOp : OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
WrC, WrPC, WrCR, WrIR : OUT STD_LOGIC ;
Mem_ALU, PC_RA, IR_RB : OUT STD_LOGIC ;
ALU_PC, ZE_SE, Sin_Sout: OUT STD_LOGIC ;
MemRd,MemWr : OUT STD_LOGIC ;
MemLength : OUT STD_LOGIC ;
MemEnable : OUT STD_LOGIC ;
MemRdy : IN STD_LOGIC ;
IORd, IOWr : OUT STD_LOGIC ;
IOLength : OUT STD_LOGIC ;
IOEnable : OUT STD_LOGIC ;
IORdy : IN STD_LOGIC ;
Status : OUT StatusT ;
Clk, Reset : IN STD_LOGIC );
END Ctrl_Subsystem;
LIBRARY ieee;
USE ieee.std_logic_signed.ALL;
16=> (’0’, ’0’, ’1’, ’1’, ’1’, ’0’, ’1’, ’0’, "0001"), -- add
17=> (’0’, ’0’, ’1’, ’0’, ’1’, ’0’, ’1’, ’1’, "0001"), -- adi
18=> (’0’, ’0’, ’1’, ’1’, ’1’, ’0’, ’1’, ’0’, "0010"), -- sub
19=> (’0’, ’0’, ’1’, ’0’, ’1’, ’0’, ’1’, ’1’, "0010"), -- sbi
20=> (’0’, ’0’, ’1’, ’1’, ’1’, ’0’, ’1’, ’0’, "0100"), -- and
21=> (’0’, ’0’, ’1’, ’0’, ’1’, ’0’, ’1’, ’0’, "0100"), -- ani
22=> (’0’, ’0’, ’1’, ’1’, ’1’, ’0’, ’1’, ’0’, "0101"), -- or
23=> (’0’, ’0’, ’1’, ’0’, ’1’, ’0’, ’1’, ’0’, "0101"), -- ori
24=> (’0’, ’0’, ’1’, ’1’, ’1’, ’0’, ’1’, ’0’, "0110"), -- xor
25=> (’0’, ’0’, ’1’, ’0’, ’1’, ’0’, ’1’, ’0’, "0110"), -- xri
32=> (’1’, ’0’, ’0’, ’0’, ’1’, ’0’, ’0’, ’1’, "0001"), -- ldb
33=> (’1’, ’0’, ’0’, ’0’, ’1’, ’0’, ’0’, ’1’, "0001"), -- ldw
34=> (’1’, ’1’, ’0’, ’0’, ’0’, ’0’, ’0’, ’1’, "0001"), -- stb
35=> (’1’, ’1’, ’0’, ’0’, ’0’, ’0’, ’0’, ’1’, "0001"), -- stw
36=> (’1’, ’0’, ’0’, ’1’, ’1’, ’0’, ’0’, ’0’, "1001"), -- irb
37=> (’1’, ’0’, ’0’, ’1’, ’1’, ’0’, ’0’, ’0’, "1001"), -- irw
38=> (’1’, ’1’, ’0’, ’1’, ’0’, ’0’, ’0’, ’0’, "1001"), -- iwb
39=> (’1’, ’1’, ’0’, ’1’, ’0’, ’0’, ’0’, ’0’, "1001"), -- iww
56=> (’0’, ’0’, ’1’, ’0’, ’0’, ’1’, ’0’, ’1’, "0001"), -- br
57=> (’0’, ’0’, ’1’, ’0’, ’0’, ’1’, ’0’, ’1’, "1000"), -- bri
48=> (’0’, ’0’, ’1’, ’0’, ’0’, ’1’, ’0’, ’1’, "0001"), -- brp
49=> (’0’, ’0’, ’1’, ’0’, ’0’, ’1’, ’0’, ’1’, "0001"), -- brn
50=> (’0’, ’0’, ’1’, ’0’, ’0’, ’1’, ’0’, ’1’, "0001"), -- bnz
51=> (’0’, ’0’, ’1’, ’0’, ’0’, ’1’, ’0’, ’1’, "0001"), -- brz
52=> (’0’, ’0’, ’1’, ’0’, ’0’, ’1’, ’0’, ’1’, "0001"), -- bnc
53=> (’0’, ’0’, ’1’, ’0’, ’0’, ’1’, ’0’, ’1’, "0001"), -- brc
54=> (’0’, ’0’, ’1’, ’0’, ’0’, ’1’, ’0’, ’1’, "0001"), -- bnv
55=> (’0’, ’0’, ’1’, ’0’, ’0’, ’1’, ’0’, ’1’, "0001"), -- brv
OTHERS => (’0’, ’0’, ’1’, ’1’, ’0’, ’0’, ’0’, ’1’, "0000")
);
BEGIN
IF (State’EVENT) THEN
CASE State IS
WHEN undef => NULL;
WHEN p_reset => ALUOp <= "0000";
MemRd <= ’0’; MemWr <= ’0’;
MemEnable <= ’0’; MemLength <= ’0’;
IORd <= ’0’; IOWr <= ’0’;
IOEnable <= ’0’; IOLength <= ’0’;
WHEN fetch =>
-- disable write signals from previous cycle
WrCR <= ’0’ AFTER Ctrl_delay;
WrC <= ’0’ AFTER Ctrl_delay;
-- fetch instruction
ALU_PC <= ’1’ AFTER Ctrl_delay;
MemLength<= ’1’ AFTER Ctrl_delay;
MemEnable<= ’1’ AFTER Ctrl_delay;
MemRd <= ’1’ AFTER MemRd_delay, ’0’ AFTER MemRd_pulse;
Sin_Sout <= ’0’ AFTER Ctrl_delay; -- switch in
-- increment PC
PC_RA <= ’0’ AFTER Ctrl_delay;
ALUop <= "1110" AFTER Ctrl_delay; -- PC + 4
WrIR <= ’1’ AFTER Ctrl_delay;
WrPC <= ’1’ AFTER Ctrl_delay;
-- decode registers
AddrA <= Instr(20 DOWNTO 16) AFTER Dec_delay;
IF (Ctrl_Line.RS_RB = ’0’) THEN
AddrB <= Instr(25 DOWNTO 21) AFTER Dec_delay;
ELSE
AddrB <= Instr(15 DOWNTO 11) AFTER Dec_delay;
END IF;
AddrC <= Instr(25 DOWNTO 21) AFTER Dec_delay;