How To Build Your Own Working 16 Bit Microcomputer
How To Build Your Own Working 16 Bit Microcomputer
How To Build Your Own Working 16 Bit Microcomputer
TAB BOOKS
BLUE RIDGE SUMMIT, PA. 17214
FIRST EDITION
1 Introduction to Microprocessors 9
The 12-Bit Microprocessor—The 16-Bit Machines—Why the
9900?—What Is In This Book
Appendix 80
Index 95
Introduction to
Microprocessors
10
that almost compensates for the primitive instruction set capability
of the IM-6100.
In languages alone it outstrips any other microprocessor (as
well as some much larger machines), having;
A) DIBOL DEC business language
B) ALGOL-60 the subroutine definition language
C) FORTRAN the most famous scientific language
D) SNOBOL string manipulation language
E) APL the mathematical language
F) LISP the artificial intelligence language
G)BASIC the most popular language of all
H) FOCAL a supercalculator language
I) LIBRA time-sharing FOCAL
J) MACRO a macro-assemblerfor machine language users
K)LINK-EDITOR for hooking everything together
L) DOS for developing systems
M)TSS time-sharing system
If the PDP-8 or IM6100 has all this power, then why, you may
ask, isn't this book written solely on the construction of this
machine? The main reason is that I feel that the TI TMS9900
microprocessor is fresh ground for the microcomputer user, with
even more potential than the PDP-8.
Other reasons include the most advanced architecture of any
true microprocessor is currently within the TMS9900; the
TMS9900 has the greatest flexibility of any microprocessor yet
developed; the TMS9900 has thebestinstruction set ofany microp
rocessor, exceeding many minicomputers; and the software de
velopment pace for the TMS9900 is increasing exponentially.
While there are so-called microprocessors with power just as
greatas the TMS9900 (theDECLSI-11 includes floating point as an
option) they are eithernotas cost-effective or not as flexible (e.g.,
the LSI-11 couldnever be used as economically to control a CRT or
other smart devices). The LSI-11/2 now consists of separate CPU,
memory, andinterface cards, but the CPUis not available as a chip
or chip group without the card.
11
ning to make themselves felt in the main stomping grounds of the
minicomputer field.
The 16-bit unit, unlike its cousin the 8-bit type, is not really a
microprocessor, but is in reality a minicomputer using large-scale
integration (LSI) technology. The main 16-bit machines are;
9440 by Fairchild
MicroNOVA by Data General
CP1600 by General Instruments
Pace by National Semiconductor
TMS9900 family by Texas Instruments
MC2 by Hewlett-Packard
LSI-11 by DEC
12
WHY THE 9900?
The TI 9900 was chosen for this book for several reasons; it is
an LSI minicomputer rather than a microcomputer chip (microp
rocessor) in the usual sense of the word. This means that, for the
hobbyist or professional, the instruction set and architecture are
simple and clean, with little to interfere with designing hardware or
software.
The minimum system (see Chapter 4 for a block diagram) is not
significantly more expensive than a minimum system using other
processors, and may even be less expensive, particularly when
compared to other 16-bit processors.
The 9900 is a 16-bit machine with byte addressing and a general
register bank (16 registers); it is a 64-pin chip with separate lines for
data and addresses, making complex interfaces unnecessary; and it
does not require the use of complex memory systems to operate,
allowing easy mixing of different memories.
The family of 9900 chips is complete, allowing powerful sys
tems to be designed with ease. There exists currently a version of
the TMS9900, called the TMS9980, which can use 8-bit modules and
is totally software compatible with the 9900.
The 9900, while still young in terms of software, has most of the
key software already available, such as:
13
WHAT IS IN THIS BOOK
The 9900 chipitself is obviously covered in detail, since this is
the central processing unit, the very nucleus of the computer sys
tem.
The 9901is a programmable systems interface, whichprovides
the 9900with anintervaltimer, an event timer, up to 16 I/O ports,
and up to 15 interrupt input lines.
The 9902is anasynchronous communication controller(ACC),
whichallows interfacing the 9900 to such devices as teletypewriters
of all kinds, CRT terminals, hard-copy terminals, paper tape read
ers, and punches and cassette tape interfaces.
The 9904 is a clock generator which generates all the syn
chronization signals for the 9900, the 9901, etc.
The 9903 is a synchronous communication controller which
eliminates the need for software for the protocols, such as binary
synchronous (often called bi-synch), synchronous data link control
(usually SDLC), and almost all other synchronous protocols, with
the linksynchronization andcontrol handled by this chip, the 9903.
14
The TMS9900
Processor Chip
15
r:HKHHiMJHHwm?yyft^^
*^
^HHHHHHHH}tfiH}O^LH}g^{HHHHHHH>WM
JJOO- 0030-
.125.
NOTE: A Each pin centerline Islocated within 0.010 of itstrue longitudinal position.
Fig. 2-1. The64-pin dual inline package oftheTMS9900 islarger than themore
familiar 40-pin DIP configuration used by8-bit microprocessors. Added 24 pins
make possible more system interconnections. (Courtesy ofTexas Instruments)
2-2 shows clock signal timing requirements. The times shown are
for maximum-frequency operation. For operation at slower speeds,
the duration ofindividual phases may be extended but the 5-ns guard
times between signals should remain unchanged.
Input lines totheTMS9900 all have high impedance tominimize
loading on signal sources. Outputs are all capable of driving two
i
H
U 83 ns J
/i-48 nsnA !
15 nsJ
I
'!I
L
l\ .
1bns-H r— '
ii 'i ii /J—
t
i i 1
d>2
5ns*l
i1^
r*-
\
<A3
/ \
M
A0001163
1 / \
Fig. 2-2. Clock waveforms required by TMS9900 when operating at maximum
3-MHz frequency are shown here. Dead space of 5 ns between phases is
essential to proper operation of processor. (Courtesy of Texas Instruments)
16
standard TTL inputs each, and no pull-up resistors are necessary.
Most standard memory devices can be connected directly to the
9900withoutinterveningbuffers. Ifan external circuitimposes more
thantheequivalent oftwoTTLloads (thatis, requires more than3.2
ma of driving signal), buffering is required.
VBB 1 64 HOLD
vcc 2 63 MEMEN
WAIT 3 62 READY
LOAD 4 61 We
HOLDA 5 60 CRUCLK
RESET 6 59 vcc
IAQ 7 58 NC
01 8 57 NC
02 9 56 D15
A14 10 55 D14
A13 11 54 D13
A12 12 S3 D12
A11 13 52 D11
A10 14 51 D10
A9 15 50 D9
A8 16 49 D8
A7 17 48 D7
A6 18 47 D6
AS 19 46 D5
A4 20 45 D4
A3 21 44 D3
A2 22 43 D2
A1 23 42 D1
AO 24 41 DO
04 25 40 Vss
vss 26 39 NC
VDD 27 38 NC
03 28 37 NC
DBIN 29 36 ICO
CRUOUT 30 135 IC1
CRUIN 31 134 IC2
Fig. 2-3. Pin connections for processor chip are grouped byfunction to simplify
PWA card layout. (Courtesy of Texas Instruments)
17
Pin assignments of the TMS9900 (Fig. 2-3) were made to
simplify thelayout ofacircuit board, bygrouping related signals into
sets andassigning each set to adjacent pins. Thus all signals of the
databusare together, andso forth. Thispermitsshorter conductor
runs and more compact circuit board layout.
Payclose attention to these critical points in layout:
The clock inputs must be located as close as possible to the
clock driver circuit, because these signals have fast rise and fall
times while driving relatively high capacitance through a wide vol
tage swing.
The 12-volt supply to the clock drivers should be decoupled
with both large (15-uf minimum) and small (0.05-uf maximum)
capacitors in order to remove both low-frequency and high-
frequency transients from the supply lines.
All power inputs must be decoupled as close to the chip as
possible. The+5 VDC power drain can vary bynearly 100 maovera
20-ns interval, ifall data and address lines simultaneously switch to
low level, and theresulting spike can interfere with system opera
tion unless decoupled at the 9900 socket.
DATA AND ADDRESS ORGANIZATION
The TMS9900 uses a 16-bitmemory word and 16-bit addres
ses. The 16bits ofthe memoryword (Fig.2-4)are referred to as DO
through D15, with DO being the most significant (leftmost) bit and
D15being the least significant. Similarly, the 16 bits of an address
are referred toas A0 through A15, with A0 being mostsignificant.
Each memory word canbe considered as being made upoftwo
8-bit bytes. In this case, DO through D7 form one byte, and D8
through D15 form the other.Mostdataoperations canbe performed
oneitherwords or bytes, depending upon a flag bitin the operation
command code.
The 16-bit memory addresses actually refer to bytes rather
than to words. Only 15 of the 16 address bits are brought out to
external addresslines; A15 is usedonly inside the chip, tosignify to a
byte operationwhichof the two bytes is to be affected. WhenA15is
0, the bytecomposed ofDO throughD7is addressed; whenA15is 1,
the affected byte is D8 through D15.
Since only 15address bitsare available externally, all memory
addresses involve full 16-bit words, and are on even-byte bound
aries. That is, memory location 0001 does not exist; the system
18
MSB LSB
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
3E V
MEMORY WORD (EVEN ADDRESS)
6 8 10 11 12 13 14 15
vffi. v—
JL —V/
EVEN BYTE ODD BYTE
Rg. 2-4. Bitdesignations which memory word are asshown at top here. Bytes of
word are as shown below. (Courtesy of Texas Instruments)
steps from 0000 to 0002, then to 0004, and so forth. Thus the
memory space directly addressible is 32,768 words, and any mem
ory transfer moves a full 16-bit word regardless of whether one or
both its bytes are to be modified.
INTERNAL ORGANIZATION
The advanced memory-to-memory architecture of the
TMS9900 isbest described bycomparing itto the moreconventional
register-oriented design exemplified by the popular 8080 microp
rocessor. Such a chip (Fig. 2-5) contains a number of registers, a
program counter, an arithmetic and logic unit (ALU), and a set of
status flags. Data may be transferred from register to register, or
between register and memory. Most arithmetic and logic operations
involve aspecial register (the accumulator) and either another regis
ter, immediate data, or a memory byte.
For controller applications, this is adequate. The control
parameters may be kept in the internal registers, and little com
munication with memory is required for data transfer.
However, when interrupt-driven input-output techniques are
employed (which means most ofthe time, in information processing
applications), all oftheinternal registers must besaved each time an
interrupt occurs. Subsequently, at the end ofthe interrupt service
routine, the registers must be restored. This continual saving and
restoration ofthe registers may occupy as much processor time and
program space as the interrupt service routine itself.
19
CPU TMS8080A
MEMORY
REGISTERS
PROGRAM
DATA
PC
ALU
a
FLAGS
CPU
MEMORY
PC REGISTERS
PROGRAM
DATA
WP
ALU
I
STATUS TMS9900
C
ti
NUMBER OF WORKSPACE REGISTERS
oKl9Q5ftM AND data LIMITED ONLY BY MEMORY SIZE
REGISTERS IN MEMORY • PROVIDES FAST CONTEXT SWITCHING
Fig. 2-5. Difference between TMS9900 organization (right) and more conven
tional approach of8080 (left) iskeyto9900's capability for rapid context switch
ing. (Courtesy of Texas Instruments)
20
TheTMS9900's memory-to-memory design differs inthatonly
three registers are actually contained within the chip, and allthree of
these are automatically saved or restored as required by single
program instructions or interrupt responses. The saving or restor
ingis called a "context switch."
The three actual registers in the TMS9900 (Fig. 2-5) are the
program counter, the status register, and the workspace pointer.
The firsttwoofthese correspond to their counterparts in the more
conventional design; the third is the key to the advantages of the
TMS9900.
Inaddition to the three actualregisters, the TMS9900 employs
16additional "workspace registers." These registers, identified as
WRO through WR15, may beused for the same purposes as any of
the additional data registers of the more conventional architecture
(with several exceptions). That is, any oftheregisters may beused
as an accumulator or as an address pointer.
The 16 workspace registers (Fig. 2-6) may be located any
where in memory, and you can have as many sets of themas you
like. Theonly requirements are thatthe 16registerwords inoneset
be in consecutively addressed locations, and that they not be in
read-only memory.
The workspace pointer register points to WRO inthe currently
active set ofworkspace registers; this givesthe processor accessto
all 16 of the registers in the set.
1 REGISTER USE I
MEMORY
AOORESS REGISTER
- OPTIONAL SHIFT
| WORKSPACE POINTER | Q KP.00 0
COUNT
HP* 02 1
MP.04 2
WP.OS 2
4
WP«OS
WP»0A 5
W?«OC S
7
*P»0E 0ATA IKL
HP* 10 8
9 ADDRESSES
WP* 12
HP* 14 10
11 - BL RETURN AOORESS
WP«tS
12 - CRU BASE AOORESS
IMP. IS
11 - SAVED HP
VHP. 1A
14 - SAVEO PC
HP« 1C
IS - SAVED ST
HP. IE
Fig. 2-6. The 16registers ofthe9900 are organized as shown here. All addres
ses arerelative to the workspace pointer. As many sets of registers as desired
can be defined. (Courtesy of Texas Instruments)
21
Ofthe 16 workspace registers, 10 are available for any applica
tion. Three are dedicated to the context-switching operations, but
their content maybeusedorchanged bythe same commands which
apply to the 10 general-usage registers. The reinaining three have
special uses in certain commands, butagain can bechanged orused
like any other workspace register (with one exception).
Registers WR1 through WR10 are thegeneral-usage registers.
Each can beused as an accumulator, amemory pointer, oran index
register, depending upon specific bits in the command used to
address the register.
The other registers can also beused as accumulators, memory
pointers, and (except for WRO) as index registers. Indexing involv
ing WRO is not allowed.
The registers dedicated to context switching are WR13,
WR14, and WR15. When acontext switch occurs, theold content of
the workspace pointer isstored in WR13 ofthe new workspace, the
old program counterinWR14, and the currentcontent ofthe status
register in WR15. Ifthese three registers are not modified bythe
program, thecontext switch can bereversed byreloading WP, PC,
and STfrom WR13, WR14, and WR15 respectively. This is done by
a single command, Return Workspace (RTWP).
Special uses of the remaining registers are as follows: WRO
contains an optional shift count used by all four shift instructions.
WR11 contains the return address stored automatically by the
Branch and Link (BL) command, which can be used to call a sub
routine without performing a context switch. To return from the
subroutine a Branch usingWR11(B11) is executed. WR12contains
the bit base address for communication-register unit (CRU) opera
tions.
In addition to the workspace-register feature, the memory-
to-memory organization of the 9900 has another unusual result.
Arithmetic and logical operations are not limited to actions involving
the registers; anymemorylocation can be altered, without the need
for moving its content into a register to make the change, then
moving it back after the change is complete. That is to say, any
memorylocation—not justthe workspace registers—can beusedas
anaccumulator, merely by addressing it appropriately in the com
mand.
At first glance, it might appear that this architecture would
result in an inordinate number of memory accesses in order to
22
accomplish any program action. In fact, the number of accesses is
not significantly larger than with the more conventional register-
oriented microprocessor designs, since they too must perform at
least one memory access per program instruction in order to fetch
the instruction for execution. By reducing the number of program
steps which must be accessed, the 9900's design permits more data
accesses without penalty.
CONTEXT SWITCHING
The process of switching from one set of registers to another,
by switching the pointer to the workspace, is known as context
switching. Acontext switch is performed when the LOAD signal
goes low, immediately after the RESET signal returns to high level
after being low, when any of the 15 maskable interrupts is recog
nized and allowed, whenever one of the 16 possible Extended
Operation (XOP) commands is executed, whenever aBranch and
Load Workspace Pointer (BLWP) command is executed, or when
the Return Workspace (RTWP) is executed.
All of these context switches, except that resulting from
executing RTWP, are performed in the same manner once the
necessity for the context switch is established. External signal lines
LOAD and RESET establishthe need for their context switches. An
allowable interrupt similarly establishes its need. Context switches
required by command execution are established by fetching and
decoding the command.
Once the need for a context switch is known, the existing
workspace pointer and status register are temporarily saved and a
new workspace pointer value is obtained from an appropriate mem
ory location. For all context switches except BLWP and RTWP, the
locationofthe new workspace pointervalue is builtinto the 9900chip
(Fig. 2-7). For LOAD the new value is at memory location FFFC
(16). For RESET, itis at 0000. For Interrupt 1, itis at 0004, and so
forth for the higher-numbered interrupts up to Interrupt 15, at003C
(60 decimal, or 4times 15). The values for XOP immediately follow
those for the interrupts, at memory locations 0040 (XOP 0) through
007C (XOP 15). The value, once obtained, is loaded into the work
space pointer register, which instantly changes the entire program
context to reflect the new workspace.
With the new workspace established, the saved value ofthe
status register is stored in new WR15. The content ofthe program
23
counterregister, which has notyetchanged, isstored innewWR14.
The savedvalue ofthe old workspace pointer isstored in WR13, and
finally the new value of the program counter is read from the
memory location immediately following that from which the new
workspace pointer was obtained (FFFE for LOAD, 0002 for RE
SET, and so forth). Program execution then continues, using the
new value of the program counter and the new workspace.
After any ofthese context switches is accomplished, the first
instruction (that addressed by the new program counter) will be
executed before any interrupt will berecognized. This permits the
interrupt facility to be locked out when desired.
Because the old WP, PC, and ST are pushed into WR13,
WR14, and WR15 ofthe new workspace, it is possible to restore
them and thus torestore theexact internal system conditions which
existed at the instant the context switch was performed. This is
functionally the equivalent of the stack push and pop (or pull) sequ
ences employed by many 8-bit microprocessors. The 9900, how
ever, does everything by asingle instruction, rather than requiring
an instruction sequence.
Restoring the previously used workspace, PC, and status is
accomplished by the RTWP instruction. Its action may also be
considered a context switch, but in the reverse direction. The
RTWP action is never performed automatically; it always results
from the program's fetching and decoding the RTWP command.
When the RTWP command isdecoded, the processor fetches
the old status from WR15 and stores itin the status register. Next, it
restores the program counter from WR14. Then it restores the
workspace pointer from WR13. Note that the values ofST, PC, and
WP which existed when the command was decoded have been lost;
none ofthem are necessary any longer. Finally, the restored prog
ram countercontent isloaded ontothe memoryaddress lines and the
nextinstruction is taken from the location thus addressed. Unlike
the other context switches, the interrupt facility remains active
when RTWP is executed (unless disabled by the restored interrupt
mask in the status register).
INTERRUPTS
24
MEMORY
AREA DEFINITION A0ORESS16 MEMORY CONTENT
0 IS
0002
PC LEVEL 0 INTERRUPT
<
0042 PC XOPO
007C WP XOP 15
007E PC XOP 15
0080
OR WORKSPACE
•
Fig. 2-7. Memory locations 0000 through 007E, plus FFFC and FFFE, are
dedicated to special uses as shown in this memory map. Allother addresses are
free for general use. (Courtesy of Tl)
25
high, and goes lowto signal an interruptrequest Theotherfour, ICO
through IC3, forma4-bitbinary codewhichindicates the levelof the
interrupt request ICO is the most significant, and IC3 the least
significant, bitof the code, and ahigh levelindicates a"1" bit Thus,
LLLH onIC0-IC3 (in that seauence) indicates 0001, orInterrupt 1.
When aninterrupt requestis recognized on the INTREQ line,
the TMS9900 compares the interrupt code on IC0-IC3 with the
interrupt mask contained instatus-register bits ST12 through ST15.
Ifthe interrupt code is less than orequal to the mask (indicating a
higher or equal priority interrupt), the interrupt is allowed and a
contextswitch isperformed afterthe currently executing instruction
has been completed. After thecontext switch, theinterrupt mask is
automatically reduced by one so thatno other interrupt of equal or
lower priority can be allowed.
When the interrupt mask is equal to zero (bits ST12 through
ST15 all zero), norequested interrupt can beofhigher priority, and
only theRESET interrupt can be equal. Thus all interrupts except
Interrupt 0(RESET) can bedisabled byforcing theinterruptmaskto
zero. One command, Load Interrupt Mask Immediate (LEVO), per
mitstheinterrupt masktobe set to anyvalue, and the first command
after any context switch will be executed before interrupts will be
examined again. Thus by making the first command of a critical
routine aLIM 0, thatroutine can turnoffinterrupt action. When the
routine is finished and control passes back to the interrupted action
via the RTWP command, the previous interrupt mask is restored
alongwith theother 12 bitsofthestatus register, and interrupts are
once again enabled.
This approach tointerrupt control makes priority determination
almost automatic. Each external circuit which can produce an inter
rupt request must also provide its interrupt code on lines ICO
through IC3. If each device has a separate code, no additional
hardware is necessary to determine which device requires service
or if response is permissible. Most systems can operate with no
morethan 15 different interrupts. Should more prove necessary,
several devices can be assigned the same code and the interrupt
serviceroutine canthen interrogate all of them to determinewhich
requires service. Alternatively, external hardware can be addedto
sortoutpriorities sothatthe 9900 sees only oneof 15requests, but
each request could have originated from any of several different
circuits.
26
INPUT/OUTPUT TECHNIQUES
Any orall ofthree widely different techniques may beused for
input/output data transfers between the TMS9900 processor and
memory onone side, and theexternal world onthe other. Thethree
techniques (Fig. 2-8) are direct memory access (DMA), memory-
mapped I/O, and the communications-register unit (CRU) capabili
ty-
DMA provides direct transfer of data between the peripheral
devices and memory, without involving the processor at all (except
to guarantee thatthe processor does not attempt to accessmemory
at the same time). With many processors, this is the cleanest way to
transfer data, but it always requires some external hardware to
control the DMA activity and to assure thatboth the processor and
the peripheral device wait their proper turns for memory access.
Because of its complexity, DMA I/O is outside the scope of this
volume.
Memory-mapped I/O assigns memory addresses tothevarious
peripheral ports, and "reads" from or"writes" totheperipheral port
just as though itwere actual memory. This approach makes atleast
one memory location per peripheral device unavailable for actual
data storage, but nevertheless isapopular technique. Several 8-bit
microprocessors (notably, the 6500 and 6800 families) use
memory-mapped I/O to meet all their requirements. Again,
memory-mapped I/O is outside the scope of this volume, because
Aoonioem
iz:
I/O
=7u
__nf
MEMORY t
dma m*
I \
ii . CONIROt JJ.
,/ 17
OMA COWTHOl
Fig. 2-8. These three types of input/output techniques may be used with the
9900. Only the CRU capability is unique to the 9900. (Courtesy of Texas
Instruments)
27
the technique used depends entirely upon the specific peripheral
involved.
The final technique, the CRU capability, is unique to the
TMS9900 family and is an extension of the idea used for direct
accumulator I/O in such processors as the 8080.
A communications registerunitis defined inthe 9900 system as
anyexternalunit makinguse of the processor's CRU capability. This
capability takes the form of three dedicated I/O pins (CRUIN,
CRUOUT, andCRUCLK), 12 bits (A3 through A13) of the address
bus, and five processor instructions which permit the program to
set, reset, or test any of 4096 addressable bits in the external
device, and to move data between memory and CRU data fields.
While the capability provides 12bits of CRUaddress, making it
possible to uniquely address upto 4096bitsinthe CRU, anyspecific
device used as a CRU need not have all these bits present. A
single-bit device such as a flip-flop couldbe used as a CRU. In amore
practical vein, the TMS9901, 9902, and 9903 peripherals are all
intended to be used as CRU's. If you prefer, any type of peripheral
controller canbe turnedintoa CRUby providing the properinterface
to make it compatiblewith the 9900's CRU-oriented commands and
bit addressing.
CRU INTERFACING
The CRU interface is a dedicated serial I/O capability which
permits transfer of from 1 to 16 bits at a time. Since bits are
individually addressed, nomasking instructions are necessary inI/O
service programs, and I/O fields need not be identicalin size to the
memory word (but must be no longer than 16 bits).
CRU interface signals from the TMS9900 consist of (1) the
CRU clock(CRUCLK, pin60)which, when high, means that the 15
address linescontain either an externally decoded operation (ifA0,
Al, orA2 is high) or a bitaddress inthe CRU(ifA0, Al, and A2 are
all low); (2) CRUOUT (pin 30)which contains the bit being output;
and (3) CRUIN (pin 31) which contains the bit beinginput.
The CRU can be considered to be a pair of addressable
memories of 4096 bits each (one memory for input, and one for
output). Five instructions access the CRU. They are:
• Test Bit (TB), which allows reading any single bit in the
CRU;
28
• Set Bit to One (SBO) and
• Set Bit to Zero (SBZ), which allow altering one bit in the
CRU; and
• Load Communications Register (LDCR) and
• Store Communications Register (STCR), which allow alter
ing orreading up to 16 bits ata time via amulti-bit CRU data
transfer.
Each of these five instructions first causes the address of a
single bit in the CRU address space tobeformed asshownin Fig. 2-9
byadding a displacement value (contained in theinstruction) to the
CRU baseaddress(contained inWR12), then placesthe resulting bit
address on address lines A3throughA14 while forcing AO, Al, and
A2 to 000. The bitappears on either CRUIN (forTB or STCR) or
CRUOUT (for SBO, SBZ, or LDCR), strobed by CRUCLK.
The three single-bit commands operate explicitly; TB places
the received bit value into ST2, where it may be tested by a
subsequent JEQ or JNE command. If the bit value was 1, the
EQUAL condition is set. SBO and SBZ set the CRU bitto 1 and 0,
respectively.
Only one bit permachine cycle isprocessed by any oftheCRU
commands. Multi-bitcommands LDCR and STCR perform as many
cycles asnecessary totransfer thespecified number ofbits, chang-
3 4 S 6 7 8 9 10 11 12 13 14 IS
O 1 2
X X X 1 1 1 X W12
DON'T CARE
+
B 9 10 11 12 13 14 IS
SIGNED
WW 11•
DISPLACEMENT
BIT 8 SIGN
EXTENDED
3 4 5 6 7 8 9 10 11 12 13 14
0 1 2
0 0 0
1 1 1 ADDRESS BUS
_ Jf
V
SET TOZ ERO EFFECTIVE CRU Bl TAD ORES.5
FOH ALL CRU
OPE RATI DNS
Fig. 2-9.The CRU address placedon the address bus (bottom) is developed by
adding an 8-bitsigneddisplacementcontainedinthe I/O command itself (center)
to the CRU base address held in workspace register 12 (top). This operation )s
repeated for each addressed bit. (Courtesy of Texas Instruments)
29
CRU CRU
INPUT OUTPUT
BITS BITS
N
N
N*1 N+1
INPUT (STCR)
OUTPUT (LDCR)
N+14 N+14
N*15 N+15
Fig. 2-10. Multi-bit CRU data transfers by the LDCR and STCR commands
operate as shown here. Oninput (STCR), the bithaving the lowest CRU address
moves Into therightmost bit oftheaddressed memory word. Onoutput (LDCR),
similarly, therightmost bit goestothelowest CRU address. (Courtesy ofTexas
Instruments)
ing the bit address after each cycle. Each bit is moved between
processor and CRU as shownin Fig. 2-10.
The 16-bit CRU shown in Fig. 2-11 illustrates thebasic princi
ples involved in CRU interfacing. Note that address lines AO through
AlO are ignored by this circuit; it will interpret any of the external
commands asa CRU action, and each ofits 16 input and output bits
has 256 possible addresses. That is, input bit INO and output bit
OUT0 can be addressed as CRU bit 0, bit 16, bit 32, and so forth up
to bit4080. Whenever address lines All through A14 contain the
0000 pattern, INO and OUT0 are addressed.
The TMS9901, 9902, and 9903 support chips (discussed in
detail in Chapter 3) are designed for use with the CRU interface.
Each ofthem has only 5address-line inputs, so each chip occupies 32
bits ofthe4096-bit CRU memory space. Each ofthese chips also has
a ChipEnable (CE) inputto permit the other seven address lines to
select one of several chips in a system.
If only one CRU device is to be used, the multiple-address
approach (simply grounding the CE line) would be enough. How
ever, let us suppose that we wish to connect 8 devices on the CRU
30
interface. We can divide the CRU address signal as follows;
1) 9901 for interrupts and interval timer, addressesd asbits
0-31
2) 9902 for master terminal, addresses 32-63
3) Four 9902s for remote terminals, modems, addresses
64-95
96-127
128-159
160-191
4) 9903 for a BI-SYNC terminal addresses 192-223
5) 9903 for anSDLC terminal addresses 224-255
Thecircuit asshown inFig. 2-12 would beused. This circuit usesan
74LS138 3-to-8 decoder. Line Z comes from the CRU clock.
Shouldwewish tofurther expand thesystem, wecould useFig.
2-13 to increase the number of circuits to 64. This requires 9
74LS138 decoders. Figure 2-14 shows decoding foryoursystem up
to128 devices, allowing up to127 terminals tobe connected tosuch
asystem. This circuitrequires 36 74LS138 decoders and some TTL
circuitry.
SN74LS2S1A
LSZ51A »-.
ITIM M06IB «-V
9 TO 1 C +->
MUX
,SN74LSS«A
LSStA «-^.
T MS 9900
'ITIMM06IB <-V
8 TO 1 5 f~L cruclk cpu
MUX
0SN74LS290
(TIM 99081O
SSIT * JfrH/4>l»WU
LATCH
B-
-/ »
"nwiwoei0
B-BIT A
LATCH
£r
<3
Rg 2-11 This 16-bit CRU can be constructed with only 5 IC chips, since
one-quarterof a74LS00 can be used instead ofthe 74LS04. It may be adequate
for small systems. (Courtesy of Texas Instruments)
31
SN74LS138
A7- -TMS9901 CE
A8- -9902 CE (MASTER)
A9-
>9902 CE
Z»- G2A
G2B
/tT :} 9903 CE
+5V«- G1
32
A7 A I •DEVICE 0(0-31)
A8 — B
A9 C
G2A
— DEVICE 7 (224-255)
A4 A
— DEVICE 8 (256-287)
As B G2A
C
A7 A
Ae B
A9 C
~ DEVICE 15(480-511)
A7 A
As B
A9 C
G2A
— DEVICE 63
Z (FIG. 8 CRU-CLOCK)
Fig. 2-14. Fora maximum system we can use this circuit with 36 decodersand
associated logic to select one of 128 CRU devices.
33
SELECT LINE N
• o
SELECT LINE N + 1 -•TO DEVICE CE
• o
A9»-
-• EXTENDED ADDRESS
• The use ofa 4-to-16 decoder will allow using address lines
AO through A3 todecode in groups of2K words (4K bytes),
up to a maximum of 32K words (64K bytes).
Several problems immediately arise from the use of this
technique.
• What happens ifwerequire an address boundary ofIK for a
4K range?
• The number of lines can get very cumbersome indeed.
• Therearetimeswhenwe wishto address as fewas2words
on the memory line (or memory mapped I/O).
These problems can be solved by circuits such as shown in Fig. 2-18.
This circuit can be set to select any 2K word boundary. Adding an
extra section would allow us toselect any Ik word boundary. Asan
example: closing switches A01, A12, A21 and A31 would cause
selection of addresses in the range 22528 thru 24575 inclusive.
LINE N
©-♦DEVICE 2
P-^DEVICE 1
Fig. 2-16. This circuit can split a 32-bit group into two 16-bit groups.
34
WORDS
,__# n. iinos
A 0
Ai - —• <inifi.ni oi
B 1
C 2 _.._ ...A 0100 1*V?fl7
3 # i'??nn.iRift'^
4 m 1ft1R/1.0n/17Cl
MLMfclN • G2A 5
. a '?4e;7ft,'?flfi71
G2B 6
,4.
/// • G1 7
+5V
74LS138
Fig. 2-17. A 3-to-8 decoder allows selection of any single 4K-word block of
memory, up to the maximum 32K of a 9900 system.
35
Sucha circuit canbe implemented withstandardlogic, with the
switches replaced by jumpers or plugs.
The circuit can be expanded to almost any level and requires
access only to the address lines and the memen line.
Using this approach, we can build modules of memory, select
ing the addresses when connecting these modules together. Note
that we havejust started the first section of the DMA requirement.
The modules would no longerdependon the 9900for addresses, but
would depend only on the contents of the address (and data) lines,
which could be generated by other devices.
Infact, exceptforthe IK boundary with 4Kmemory problems,
we havesolvedthe addressingproblems. The IK boundaryproblem
andothers of that nature can be solved with more complexversions
of Fig. 2-18.
For CRU utilization it is recommended that the multiline de
coderapproach be used, since these devicesare more closelytied to
the processor.
36
TO MEMORY AND CRU
INTERNALLY DEFINED
INTERNALLY DEFINED
G1 G2A GIB
AO Al Al
TT CKOF
CKON
H
H
H
L
L
Fig. 2-19. The external instruction decode logic shown here makes it possible to
use customized instructions, and also offers insurance against faulty CRU
operation. (Courtesy of Texas Instruments)
37
EXTERNAL INSTRUCTION AO Al A2
LREX H H H
CKOF H H L
CKON H L H
RSET L H H
IDLE L H L
Fig. 2-20. Bit patterns on address lines AO, A1, and A2 for the five external
instructions areshown here. (Courtesy of Texas Instruments)
Pin5 means that the 9900 has lifted off the address and-data,
buses and is allowing another device to access memory. A visual
indicator would show how much of the time (by brightness) is being
used by external devices on the line.
Pin3would have meaning, ifprobed with alamp indicator, only
ifmixed speed memories were used. Whenever this pinis active, the
TMS9900 must wait for memory. The brightness of the lamp would
indicate when aslow section of storage was being accessed.
Y2^>- •RUN
o ♦ WAIT
Y3^>- ♦ RESET
(9900)
32^>- ♦ INT PENDING
♦ DMA
♦INST FETCH
63^- ♦ DATA
{> ♦STORE
38
Interrupt Mask Values To Interrupt
Vector Location
Device Assignment Enable Respective Interrupts Codes
Interrupt Level (Memory Address
(ST12 thru ST15) ICO thru IC3
In Hex)
0 through F* 0000
(Highest priority) 0 00 Reset
External device 1 through F 0001
1 04
2 through F 0010
2 08
3 through F 0011
3 0C
4 through F 0100
4 10
5 through F 0101
5 14
6 through F 0110
6 18
7 through F 0111
7 1C
8 through F 1000
8 20
9 through F 1001
9 24
A through F 1010
10 28
B through F 1011
11 2C
C through F 1100
12 30
D through F 1101
13 34
EandF 1110
14 38
External device F only 1111
(Lowest priority) 15 3C
00
CO Fig. 2-22. Interrupt priorities and masking are listed here. (Courtesy ofTexas Instruments)
TMS9900
Family Support Chips
40
• TM9906 (74LS259) Octal Addressable Latch—Latches
single-line input signal into one of eight addressed output
stores.
• TIM9907 (74148) Priority Encoder—produces 3-bit code to
indicate highest-priority input signal which is active.
For the purposes of this volume, only the 9901 through 9904
are discussed, since the TMS9901 includes the functions provided
by the remaining three chips. The 9901, in fact, is the functional
equivalent of two each of the other three chips, although not all this
capability can be used at the same time.
RSTl 1[ u ] 40 vcc
CRUOUT 2 [ J 39 so
CRUCLK 3 [ J 38 PO
CRUIN 4 [ J 37 PI
CE 5 [ ] 38 SI
INT6 6[ ]3S S2
INT5 7 [ ] 34 INT7/P15
7NT4 8[ J 33 fiJTff/PM
INT3 9 C ] 32 INT9/P13
0* 10 [ ] 31 INT10/P12
IC2 13 [ ]» INT13/P9
IC1 14 C 3 27 INT14/P8
ICO 15 [ ]» P2
Vss 18 C S3
INT1 17 [ ]24 S4
P6 19 [ ] 22 P3
P5 20 [ ]21 P4
Fig. 3-1. The TMS9901 is supplied in a 40-pin DIP. These are the pin assign
ments. (Courtesy of Texas Instruments)
41
A
V
TIM
WOO
A
V >
CKOUT
C=^>'
42
Enable when address lines A3 through A9 inclusive contain the
correctvalue). This chip-enable circuit must be active low andwill
result inmaking the9901 relocatable from the zeroposition, aswell
as allowing multiple 9901 chips to be used.
The 9901 consists of three buffer groups: buffer group one
(normally used for interrupts) consists of six input-output buffers
(pins 9, through 17, and 18). They can also beused asinput buffers,
allowing up to 22 lines to be used as input.
Buffer group two, (pins 23 and 27through 34) consists ofnine
bidirectional bufferswhich can be individually set to behave as either
I/O ports or interrupt ports. Ifa portis predisabled as aninterrupt
port, then it can be used as an I/O port in safety.
Buffer group threebehaves as a series of1-bit I/O ports (pins
19 through 22, 26, 37, and 38).
Also included in the 9901 are a real-time clock, which can be
controlled and read through the use of CRU commands; a register
mask, holding theinterrupt masks; a prioritizer and encoder, which
converts 15-line code to 4 with latching to generate the interrupt
codes; and CRU logic to control the above devices.
The 9901 allows the 9900 to have additionalfeatures. One is a
true real-time clock, which has an interrupt priority of 3 (see Fig.
3-3). This clock, using the master clock that is usually crystal
controlled, can behave eitheras aninterval timer, generating inter-
na
CLOCK RtOtlTfB
•<=^>
1 i£
CLOCK OfCKEMtNTM
lz
«iAO ntaaTER
Fig. 3-3. Here isthereal-time clock portion ofthe9901 in block diagram form.
Clock can be set or read via CRU interface, and produces interrupt when
countdown reaches zero. (Courtesy of Texas Instruments)
43
<iKf 7
PRIORITIZE!!
ANO
INCOOCR
o£> u
44
The importance of this unit lies in thefact that the CRU logic,
including addressing, is already incorporated into the 9901. Note
that7 lines are dedicated to the I/O function and that a maximum of
16 lines may be so used.
TMS9902 ARCHITECTURE
The TMS9902 ACC device (Fig. 3-6) provides the ability to
connect to the 9900 anasynchronous device, such as teletypewrit
ersof any kind; ASCII compatible CRTs; keyboard-printer devices
such as the TI Silent 700 series or any device using Start-Stop
protocol, with a character length of 5 to 8 bits.
The 9902 will further generate any lateral parity option (even,
odd, or none) and detect incorrect parity conditions. Even parity
meansthe numberofon bitsis always kept even by turningan extra
biton and off. Odd parity means the number ofbits is always kept
odd. No parity means a parity bit is not added.
The transmit and receive rates are independently programma
ble from approximately 62 bits per second toapproximately 76,000
I/O
CONTROL
DATA
"--•J.
LATCH
y
s^
1
CRU
1
•C=^> LOOIC
1
I/O
CONTROL
DATA
LATCH
-<
Fig. 3-5. Up to 15 I/O ports configured like this are available to the CRU interface
in the 9901 chip. (Courtesy of Texas Instruments)
45
TMS 9902
18-PIN PACKAGE
X0UT 2 17 CE
—"*
RIN 3 16 ?
TMS 9902
CRUIN 4 15 CRUCLK
— —
RTS 5 14 SO
*
CTS 6 13 SI
OSR 7 12 - S2
—*
CRUOUT 8 11 S3
VSS 9 10 S4
bits per second. An interval timer is also provided within the 9902,
giving a resolution of64//.sec andan interval ofup to 16,320/usee.
If usedwithin a combination system (see Fig. 3-7)containing a
9901, the 9902 provides an extra interval timer. This extra timer
could be used for purposes other than that of the one in the 9901.
The 9902 provides four differentinterrupts, which are output
as oneinterrupt level(Fig.3-8). The actualcause ofthe interrupt can
be deciphered through the CRU interface.
Figure 3-9 shows how the 9900 and the 9902 (or the 9980 and
the 9902)are connected together. The decode logic consists of that
shown in Fig. 2-19 combined with a hardwired (or plug-alterable)
comparator for address lines A3 through A9.
The two chips communicate over the CRU, using 32 bits as
command words (see Figs. 3-10, 3-11, and 3-12). There are six
registers in the 9902 which are available to the 9900. One is the
control register, which is used to set the stop bit length (one, one
and a half or two); the parity (none, even or odd); the master clock
rate (dividethe input clockby either 3 or 4); and the character length
(5, 6, 7 or 8 bits). The others are the interval timer, and the receive
data rate, transmit data rate, transmit buffer, and receive buffer
registers.
46
TIM 9904
»3TTL
CLOCK
GENERATOR
5
INTERRUPT COOE
<
4 <S 3>
INTERRUPTS /"
~r
IMS 9900
L£ CPU
INTROL^N
SERIAL
ASYNCH
RONOUS
<3£>
>
Rg. 3-7. Use of the TMS9902 in a 9900 system is shown here. The 9901 is not absolutely necessary, but simplifies the interrupt signalling greatly.
§ (Courtesy of Texas Instruments)
DSCH
DSCINT
DSCENB
RBRL
RINT
RIENB
CRU
XBRE >- STATUS
XINT
XIENB
TIMELP
o LINES
TIMINT
TIMENB
INT
^£>M> OUTPUT
CRUCLK CRUCLK
CRUOUT CRUOUT
CRUIN CRUIN
SO A10
S1 A11
S2 A12
S3 A13
S4 A14
CE O DECODE
<C A0-A9
Fig. 3-9. Direct connections between a 9902 and the 9900 can be made as
shown in this diagram. Note that the chip enable decode is not shown; see text
for details. (Courtesy of Texas Instruments)
48
ADDRESS2 DESCRIPTION
ADDRESS10 NAME
SO S1 S2 S3 S4
10 0 0 1 17 BRKON Break On
Fig. 3-10. Output bit address assignments for the 9902 are shown in this listing. Internal conditions for the chip are established by writing data to
CO these bit addresses. (Courtesy of Texas Instruments)
31 30 29 28 27 26 25 24
10 9 8
Rg.3-11. This chart shows in greater detail how the9902 isset upbywriting to
specific output bit addresses. The *STCR command is used to set bits into
addresses 0 through 10, afterappropriate values are written intoaddresses 14
through 11. (Courtesy of Texas Instruments)
50
DSCENB | TIMENB XBIENB RIENB BRKON RTSONJ
CONTROL REGISTER
00 M/2 OX none 00 5
01 2 10 even f*/(3+CLK4MI 01 6
IX 1 11 odd 10 7
11 8
INTERVAL REGISTER
51
AOORESSa
AODRESS10 NAME DESCRIPTION
SO S1 S2 S3 84
1 1 1 t 1 31 INT Interrupt
1 1 t 1 0 30 FLAG Regiiter Load Control Flag Set
1 1 1 0 1 29 OSCH Dun Set Stotut Change
1 1 t 0 0 28 CTS Clear to Send
1 1 0 t 1 27 DSfl Deta Set Reedy
1 1 0 1 0 26 HTS Requett to Send
1 1 0 0 1 25 TIMELP Timer Elepted
1 1 0 0 0 24 TIMERR Timer Error
1 0 1 1 1 23 XSRE Trentmit Shift Regiiter Empty
1 0 1 1 0 22 XBRE Transmit Buffer Regiiter Empty
1 0 1 0 1 21 RBRL Receive Buffer Regiiter Loaded
t 0 1 0 0 20 DSCINT Data Set Statui Charge Interrupt (OSCH * OSCENBI
1 0 0 1 1 19 TIMINT Timer Interrupt (TIMELP • TIMENB)
1 0 0 1 0 18 — Not uied (elwayt • 0)
1 0 0 0 1 1? XBINT Transmitter Interrupt (XBRE ' XBIENB)
1 0 0 0 0 16 RBINT Receiver Interrupt (RBRL ' RIENB)
0 1 1 t 1 15 RIN Receive Input
0 1 1 1 0 14 RSBD Receive Start Bit Detect
0 1 1 0 1 13 RFBD Receive Full Bit Delect
0 1 1 0 0 12 RFER Receive Framing Error
0 1 0 1 1 11 ROVER Receive Overrun Error
0 1 0 1 0 10 RPER Receive Parity Error
0 1 0 0 1 9 RCVERR Rocolvo Error
0 1 0 0 0 8 — Not uied lalwayl - 0)
7-0 RBR7-RBR0 Receive Buffer Regiiter (Received Datal
Fig. 3-12. These are the input bitaddress assignments used to recoverstatus
and data information from the 9902. The listed status conditions are true ifthe bit
at the corresponding address is a "1". (Courtesy of Texas Instruments)
usingsucha unit. Mostofthe functions performedby this chip would
be beyond the needs of that user.
Basically the interfacing is identical with the 9902, already
discussed (see Fig. 3-14). The devices to which a 9903 are inter
faced are usually of a class outside the scope of this book.
Features of the 9903 include DC to 250,000 bits per second
processing rates; dynamic (programmable) character length selec-
+5V
WV
W- (TTL)
RS232 ••OUT
SN75189
+t>V
SN75188
RS232
OUT«- (TTL)
330pF -•IN
f
Fig. 3-13. These two circuits can be used to interface RS232 signal levels with
the TTL signal levels of the 9902 chip.
52
TtHtaoa
CLOCK
OIMIMTOM
2
mnnnurrcooi
en
c*
[NTCMturTS
c>
IMIU
1VNCH LEVEL
rtONOut
l/F
-
SHIFTERS
c <3n£>
HUEFmur'TCOOE
3\
3>
INTtRIIUFTS
t>
SERIAL * ,
SYNCH LEVEL
HONOUS
l/F
SHIFTERS
c
<s?>
:>J
Fig. 3-14. The TMS9903 interfaces much like the 9902. (Courtesy of Texas
Instruments)
53
Ill im uti
OWHI A ION
^z>r>
5
•J voi •
tiCIION
I 1
-O oi
mi
-0 Ji'rm
1141
-O *i
nti
O^itm
IISI
-O oj
III
•O «iiii
P 171
p;
•O <*
til
•O *J<th!
1 CK Q -
-£>—t
uaj ni| lin Mia
Pi vrc? cfco,
1VOII liVOtl
54
SN7419S VCC
SNKStl?. 113. OR 114
VCC J O SHIFT/LOAD
> »K
:16 MH/ L^ f |>
(NODU1Y
K O K CLEAR
CYCI E
RESTRICTION) °A Ob Qc qD
SJ> i*
:=0 £>?o O ** |
4*>o—o * 2
-O *1
^ Fig. 3-16. Discrete logic canbe usedinthiscircuit totakethe place of the 9904,butitcosts moreanddoes notperform so well. (Courtesy ofTexas
01 Instruments)
1.1 KS». T^>
d\
100 pF K 10 i>
Oh -A/WO
100 pF \S
4r
xs
1N914
PIMP - 2N3703
NPN-2N3704
56
9900 System Design
57
C 0015
EXTERNAL
INTERRUPT ' INTREO WE
ICO MEMFTi
ICI
_c-
IC2
IC3
CRUIN
rO CIRCLK
CRUOUT
ADDRESS
AL V.
V ABC G D ABC
00 07 00 Q7_
t-.—;—r~r
8 INPUTS '' 8 INPUTS
Fig. 4-1. A "minimum" system using the 9900 can be built by following this
diagram. Referto Fig. 2-3 for pinassignments ofthe 9900and to Rg. 3-15forpin
assignments of the 9904. Basing of the memory chips and support logiccan be
obtained from Tl data sheets available with the devices. Take special care to
observe decoupling requirements on all power lines and prevent noise and
crosstalkon signal lines. (Courtesy of Texas Instruments)
58
TMS4042 2
0ECE2
10ARWCEI I0ARWCE1 IOARWCE1 lO A R W CE1
7VA 7V~K A A I
V ±L
0 A OE1 OE2 0 A 0E1 OE2
TMS4700 TMS4700
59
memory to 1024 words, while allowing both field-programming and
alterability. The 74S472 PPOM allows field programming and 512
words.
For more I/O capability we could expand the system with the
9901. See Fig. 3-2 for basic couplinginformation. If combined with
the CRU-clock modification, this new modification would result in
dropping the 74LS151 and 74LS259. The I/O ports would replace
the chips (including programmable ports). The interrupt vector
structure would be usable by the system. A real-time-clock would
also be now available.
Another step would be to add the 9902; if we already have the
9901 in the circuit, we need some form of chip select to distinguish
between the two.units. Address line A9 will do this job well with one
inverter; see Fig. 4-2. Adding the 9902 has now increased our
capacity to handle a teletype or other terminal.
What do these changes buy us? We have, in our up-graded
system: external instruction decoding, 8K bytes of RAM, 2K bytes
of ROM, 6 masked interrupts (with up to 15 available, as separate
lines), 6 input/output ports with stable outputs to configure as
needed, a real-time-clock, and a programmable asynchronous inter
face.
Let us now start with the heavy-duty changes:
First, replace the circuit of Fig. 4-2 with that of Fig. 2-12. This
increases our CRU selection capacity to 8 devices.
Then, let us increase our storage capacity. Unfortunately, our
poor 9900 was not meant to handle more than two standard TTL
loads per line, so buffering is needed to boost the capacity further.
We use the circuit in Fig. 4-3 as a sample buffering technique. This
circuit has been designed for a maximum capacity of 1024 words.
However the 74LS139 has 4 more selector lines available, so we can
double the number of chip-selects. We can also boost capacity by
using the same technique we used in our original explanation of the
RAM. This gives us a total capacity, in RAM or ROM, of 32,768
words (or, if you wish, 65,536 bytes).
We can further subdivide any 4K word section into subsections,
using our chip-select techniques.
Any section of our storage can contain ROM or EPROM.
With memory size increased, let us now expand our I/O capac
ity by adding a second 9902 to handle a serial device, such as a
60
A9 •- TO PIN 17 OF 9902
PIN 15 OF 9900
TO PIN 5 OF 9901
Fig. 4-2. This single-inverter circuit permits use of address line A9 to switch the
chip-enable signal from a 9901 to a 9902 when your system includesone of
each.
cassette drive. We can use one of our I/O ports from the 9901 as an
on-off generator for the cassette deck.
We have now run into a terrible state of affairs. The ideal place
for ROM or PROM is at the top of storage, but the reset function,
which starts up the system, is in the wrong place (as far as Vectors
are concerned). Since the reset function is essential to clean'start
ups, but the interrupt is not, let us perform a little trick on the
system.
The load function should be activated as part of normal start-up
anyway, so let us force it to be activated automatically. Figure 4-4
showshowto accomplish this feat. Because the LOAD signalwill be
on before the reset signal is finished, the vector at location 0 is not
used and the one at FFFC (HEX) is used instead. ROM now
becomes part of the upper storage.
If we like, we can add memory mapped I/O; this technique of
I/O processing is particularly "sneaky" since it requires that an
external device detect the signals used for memory access and
simulate memory. Such devices are basically outside the scope of
this book, since they require peripheral controllers.
We can also add DMA; this technique allows an external device
to access memory whilethe 9900 goes off-line. The pins on the 9900
marked HOLD and HOLDA willallow this function to be performed.
Figures 4-5 and 4-6 show a circuit (the Xis must be interconnected)
whichallows up to 16 devices to seize the memory bus on a priority
basis, while Figs. 4-7 and 4-8 give an architectural view of this
techniqueand a timing diagram. Since this technique is highly device
dependent and,.therefore, outside the scope of this book, we leave
the rest to the reader.
As we saw earlier, DMA and memory mapped I/O are two
techniques for getting data through the system without using the
61
SN74LS241
•Il-C VS
A7B-A14B
2G 1Y-8Y ^
1A-8A
SN74LS139
Sela
I—\Aa—•-
<!ho-o—I*
Q
WEff
n—VW
2K
D
tr-
t—vw
2K
O
a:
2K
o-l..
Q
CRU. The DMA interfaces are very device dependent and outside
the control of the 9900. The result is a problem. How do we get the
data to the DMA device to allow it to perform its functions?
The answers are: via the CRU with interfacing, or via memory
mapped I/O. We now see one of the main reasons for this form of
I/O. Figure 4-9 is one such diagram of a simple 16 bit memory
mapping interface.
62
CS do-3 <—qcs O0-3 L-C CS DO-3 CS DO-3
AH A ri AH
n
CS 00-3 CS 00-3 CS DO-3 l—C|CS DO-3
AH AH AH AH
3=t
re 2G i 2G I 2C I 2G
Rg. 4-3. When expanding the system to include additional memory, buffering
and chip selection become essential. This circuit shows how to mix PROM and
ROM chips. (Courtesy of Tl)
63
9904/PIN4 -*—
TO "OLD" EXTERNAL
"NEW" EXTERNAL ' "^ LOAD
LOAD SIGNAL
Fig. 4-4. It's not always necessary to use both the LOAD and RESET vectors
provided in the 9900 design. This circuit provides an auto-load start-up capabili
ty, permitting the LOAD vector at FFFC to serve for both LOAD and RESET
actions.
64
p>
^_ HOLD SIGNAL 0
7 B
—
GS
" ^
74148
A2 •—Xi
—
Al > X2
> X3
0 EO *
< i XZ j SN7408^
L ^ PIN 64
7
—J
74148
A2 • X4
Al •^Xs
AO i—x«
o M
HOLD SIGNAL 15
Fig. 4-5. For direct memory access applications we must be able to recognize
requests to HOLD the 9900 off of the bus lines. This circuit prioritizes up to 16
different HOLD requests.
xz»- G2A
G2B
G1 -DEVICE 7
+5V
HOLDA
Yo -DEVICE 8
74LS138
G2A
G2B
+5V« G1 Y7 -DEVICE 15 MIN PRIORITY
Rg. 4-6. No DMA activity can be permitted until the HOLD request is acknow
ledged. This circuit provides prioritized HOLD acknowledgement, for use with
the circuit of Fig. 4-5. Together the two circuits permit up to 16 different DMA
activities in conjunction with normal processing.
65
A0A14
/ ~ 1
DGD1S ,
m£Me"W
obin
SYSTEM
MEMORY
WE
WAIT
READY
TMS9900
REQUEST
HOLO
A ODF(ESS . OATA
HOLDA
GRANT
ft mTmTTJ" dbin wl
Fig. 4-7. For DMA applications, each DMA controller must have access to the system memory just as does the 9900. This block diagram
summarizes bus control requirements fora single DMA controller. (Courtesy of Texas Instruments)
READY / / / / / //A \////A \u n / n n n pont cam / / n n / n j\\/ / /, / / / // ///////// n u // u
WAIT r V
HOLDA
HOLD
Fig. 4-8. Design of a DMA controller requires careful attention to system timing. All essentialsignalsare shownhereinrelation to the four system
clock signals. (Courtesyof Texas Instruments)
74LS347
Da-Di5
16
b
E LATCHED
> AND
tDo
BUFFERED
74LS347
OUTPUTS.
i
)
74LS5138
WE E
B 0 _i
DBIN
A 74L5241
fh
FROM ADDRESS /
—N
UfcCOUL G
16
16 2G •BUFFERED
i
I |
74L5241
INPUTS.
~>
16 26
.JX^
Fig. 4-9. Memory-mapped I/O is not difficult. This circuit providesa single 16-bit
word of memory-mapped I/O. When the assigned address is decoded (by
circuitry not shown), the data bus is connected to either the input or the output
port.
68
TIMSS04 *'
(SN741 „
Al •« A3 A4
un
Al A2 43 A4
DBIN
WE
MEMEN
READY
TMS9900
A9A14
Al AS
^)-
Fig. 4-10. Dynamic RAM is lesscostly than static ram, both interms of component cost and power consumption, but requires special refresh
CD
circuitry tokeepdata valid. This circuit demonstrates "cycle-stealing" refresh action for suchdynamic RAM devices asthe4051. (Courtesy ofTexas
CO Instruments)
j «">n
I
CNMima
1VIW
1L i5
-*—» 9 ,
imtihrutt
CONTROL
LOOK
OtCTI0M4JJ)
Fig. 4-11. Forbetter confidence in system reliability the parity of each memory
word can be checked at each access. This circuitgenerates and checks parity,
with no wait states. (Courtesy of Texas Instruments)
CN74LS74
B
CLR
<
KK
DATAO »-
DATA1 »-
DATA? »-
DATA INPUTS
FROM PAPER
TAPE READER
OATaJ »-
0ATA4 »-
DATA? »~
L^ DECODED PAPER
TAPE READER AOORESS
(DECODED FROM AO • Al II
DATAO »-
OATa7 »~
2-0-
ADDRESS BUS
70
ADDRESS
ADDRESS
DECODE
SLOMEM
r"i_ n
TMS 9900
READY
<T1
a |
WAIT
ADDRESS
ADDRESS
DECODE
TMS 9900
s~ b s LOMEM
P
READY 4
\ V_ : P—I
WAIT D Q
02TTL — >
L
Rg. 4-14. For even slower memory, two wait states may be necessary. This
circuit providesthem. (Courtesy of Texas Instruments)
71
CLOCK CYCLE 1 WAITSTATE(S) »4* -CLOCK CYCLE 2-
M JC
A0-A14
VALID ADDRESS
X J f ~ fc
DBIN •*F~
t ^iHit*
D0-D15
-ff VALID
i h
A0001116
Fig. 4-15. All memoryaccess calculations require accurate knowledge ofsystem timing. All essential signals are shown here, referenced to the time
ofone cycle ofthe 9900 clock frequency (that is, 0.333 us for a 3-MHz clock). (Courtesy ofTexas Instruments)
Hints About Peripherals
73
SYSTEM
MEMORY
DATA ADDRESS
DATA
tot
il 5^
BUFFER BUFFER
ADDRESS
0 SN74S241
ADDRESS
SN745241
ADDRESS
DISPLAY
TMS9900 CONTROL
7^> 7T
unit
CONTROL
0
<w>
RF
MODULATOR
2sZ
T.V.
Fig. 5-1. Designof a video I/Osystem requires detailed knowledge of both video
and digital signal requirements. This block diagramcan serve as a startingpoint
for design of a system using shared memory. Both the 9900 and the display
control unit have access to the common system memory.
74
character and graphics control, the74S472 as acharacter generator
PROM and control signal PROM, andthe 74LS241 for DMA control
buffers. We can go no further on this subject within this book.
DISC SYSTEMS
745241
ROW R1" -A6
-AS
BL0CK -A4
SELECT -A3
-A2
-Al
-A0
SPARE GND- -SPARE
HOLDA- -HOLDA
745241
+5V- -WE
+5V- -DBIN
-M£MEM
SPARE
HOLDA- •HOLDA
75
MASTER
II
CHARACTER
1LMntl
Hef
COUNTER GENERATOR output
COLUMNS IC) (PROMI omwtw
ROWSlRl tUWI>
~Z^~
<>
DATA
SHIFT
BUS VIDEO
BUFFER REGISTER JSZ_ BLANK
AND
LEVEL
GENERATOR
_sz_
a ADDRESS CONTROL
BUFFER CIRCUITRY
512-1K WORD
DYNAMIC/STATIC
RAM
(EXTRA FAST)
DATA
WAIT watt
Fig. 5-4. Cycle stealing can be used instead of DMA to interface the display
controller to memory. This diagram shows how.
76
INDEX TRACK 00
HOLE
TRACK 76
DRIVE HUB
OPENING
Fig. 5-5. Floppy disk layout looks like this. Disk itself is enclosed in protective
envelope and should never be removed from it. Total of 77 tracks are available
for storage of data.
Fig. 5-6. Typical floppy disk drive unit has slot with hinged lid. When disk (in
envelope) is inserted inslot and lidis closed, stored data is available for reading.
77
floppycapable of fittingyour 9900 system or will devise an interface.
Texas Instruments already has a pre-built floppyfor use with a 990
system, all 9900 systems and their TTL versions are called part of
the 990 series machines. Of course you can obtain a floppy with a
standard interface and modify it to fit. You will have to make these
basic modifications most likely; a memory mapping interface for
control and status. If the floppy delivers bytes and generates byte
address, then you willneed byte/word buffering for both data and
addresses. If you wish to use a CRU interface for control lines then
reread the section on CRU interfacing. Because of the variety of
options available at any stage of designing such a system, we must
leave this up to you to design. Once again, this project is outside the
scope of this book.
Should you wish to have more capacity than is available in a
floppy disc system, with higher access speeds, you may wish to look
at cartridge discs, such as the Texas Instruments DS31.
If even cartridge discs are insufficient, you may wish to lookat
even higher capacity systems. These are, usually, of the 2314-
compatible, 3330-compatible or "Winchester technology" drives,
with single drive capacities of:
• 2311 type drives, to 7.25 megabytes
• 2314 type drives, to 29.0 megabytes
• 3330 type drives, to 200 megabytes
• 3340 (Winchester), to 70 megabytes
• 3350 (Winchester), to 300 megabytes.
If you need such capacities, you should remember the price rises
with capacity and speed, though you do get more for your dollar as
the price rises. Interfacing becomes much more tricky and complex.
Devices of this calibertake up more space. Devices like this use up
more power. This book is about the hobbyist and home computer,
not your own versions of Colossus (and Guardian?).
OTHER PERIPHERALS
Plotters are now available, from several manufacturers, which
can interface through a standard asynchronous interface, as if they
were teletypes. This can allow you do your own graphs, drawings
and other plotter oriented functions.
Unless you wish to use these devices seriously, be warned that
they are still expensive in more ways than one. As an example, that
78
card reader might not be too expensive to purchase, but you willalso
need a keypunch....
Youmay also wish to add a line printer. These printers are far
faster than the typical10 to 40 characters per second printers used
by the hobbyists. These printers can reach speeds of up to 2000 lines
per minute (yes, two thousand), with up to 132 characters per line.
The equivalent speed in characters per second is around 4,000 CPS.
Once again, you can choose from several interface options. Youcan
use the CRU to output bytes and control. A 16-bit interface should
be adequate. You can use an ACC interface such as the 9902. Of
course you can always use memory mapped I/O, or perhaps you
would prefer to use the DMA and send full lines at a time, with a
buffer.
Should you wish you can add a card reader to read your prog
rams and data. When combined with a printer and some control card
capabilities in your software, a card reader will give you a batch
system, allowing unattended operation.
By using a 9903 SCC and a data-link you can hook up your
system to a larger computer, as if you had a "Remote Job Entry"
(RJE) system. Since there is nothing stopping you from making the
other computer another 9900 based system, you can start building
your own network.
We can use time-sharing to allow our friends access to the
machine. We might even charge for the time and resources (shades
of the service bureau).
Basically the 9900, like any well-designed computer, is limited
more by the ingenuityof the users and designers than anything else.
We have gone as far as we can in this book. The rest is up to you!
79
Appendix
Instruction Codes
80
TMS 9900 INSTRUCTION SET
A. 1 DEFINITION
Each TMS 9900 instruction performs one of the following operations:
• Arithmetic, logical, comparison, or manipulation operations on data
• Loading or storage of internal registers (program counter, workspace pointer,or status)
• Data transfer between memory and external devices via the CRU
• Control functions.
Register R
Workspace Register R contains the address of the operand. After acquiring the operand, the contents of workspace
register R are incremented.
Register R
The word following the instruction contains the address of the operand.
(PC)—» Instruction
The word following the instruction contains the base address. Workspace register R contains the index value. The
sum of the base address and the index value results in the effective address of the operand.
Register R
(PC)-
(PC)*2- Operand
^~
A.2.8 CRU RELATIVE ADDRESSING
The 8-bit signed displacement in the right byte of the instruction is added to the CRU base address (bits 3 through 14
of the workspace register 12). The result is the CRU address of the selected CRU bit.
(PCH OP CODE
7 8 15
CRU Bit
Register 12
S 0 23 1415
CO
A.3 TERMS AND DEFINITIONS
The following terms are used in describing the instructions of the TMS 9900:
TERM DEFINITION
B Byte Indicator (1-byte, 0 - word)
C Bit count
The status register contains the interrupt mask level and information pertaining to the instruction operation.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
STO ST1 ST2 ST3 ST4 ST5 ST6 not used (=01 ST12 ST13 ST14 ST15
L • A • C O P X Interrupt Mask
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
If B = 1 the operands are bytes and the operand addresses are byte addresses. If B = 0 the operands are words and the
operand addresses are word addresses.
The addressing mode for each operand is determined by the T field of that operand.
00 0. 1 15 Workspace register 1
10 0 Symbolic 4
NOTES: 1. When a workspace register is the operand ol a byte instruction (bit 3 1), tho loft byte (bits 0 through 7) is the operand and tho
right byte (bits 8 through 15) is unchanged.
2. Workspace register 0 may not be used for indexing.
3. The workspaco register is incremented by 1 for byte instructions (bit 3*1) and is incremented by 2 for word instructions (bit 3 * 0).
4. When Tg » Tq < 10. two words are roquired in addition to tho instruction word. The first word is the source operand base
00 address end tho second word is tho destination operand base address.
Ol
CO RESULT STATUS
OPCODE B
MNEMONIC MEANING COMPARED BITS DESCRIPTION
0 1 ? 3
TOO AFFECTED
A 1 0 1 0 Add Yes 04 (SA)+(DA) -*• (DA)
AB 1 0 1 1 Add bytes- Yes 0-5 (SA)+(DA)-MDA)
C 1 0 0 0 Compare No 0-2 Compare (SA) to (DA) and set
appropriate status bits
CB 1 0 0 1 Compare bytes No 0-2.5 Compare (SA) to (DA) and set
appropriate status bits
S 0 1 1 0 Subtract Yes 0-4 (DA)-(SA)-HDA)
SB 0 1 1 1 Subtract bytes Yes 0-5 (DA)-(SA)-*(DA)
SOC 1 1 1 0 Set ones corresponding Yes 0-2 (DA) OR ISA)-*-(DA)
SOCB 1 1 1 1 Set ones corresponding bytes Yes 0-2.5 (DA) OR (SA)-*(DA)
SZC 0 1 0 0 Set zeroes corresponding Yes 0-2 (DA) AND(§A")-MDA)
SZCB 0 1 0 1 Set zeroes corresponding bytes Yes 0-2,5 (DA) AND(SA)-MDA)
MOV 1 1 0 0 Move Yes 0-2 (SA) -+ (DA)
MOVB 1 1 0 1 Move bytes Yes 0-2,5 (SA)^(DA)
A.6 DUAL OPERAND INSTRUCTIONS WITH MULTIPLE ADDRESSING MODES FOR THE
SOURCE OPERAND AND WORKSPACE REGISTER ADDRESSING FORTHE DESTINATION
9 10 11 12 13 14
RESULT STATUS
OP CODE
MEANING COMPARED BITS DESCRIPTION
0 12 3 4 5
TOO AFFECTED
COC 0 0 10 0 0 Compare ones No 2 Test (D) to determine if 1's are in each bit
corresponding position where 1's are in (SA). If so. set ST2.
CZC 0 0 10 0 1 Compare zeros 2 Test (D) to determine if 0's are in each bit
corresponding position where 1's are in (SA). If so, set ST2.
XOR 0 0 1 0 1 0 Exclusive OR Yes 0-2 (D)© (SA) •* (D)
MPY 0 0 1 1 1 0 Multiply No Multiply unsigned (D) by unsigned (SA) and
place unsigned 32-bit product in D (most
significant) and D+1 (least significant). If WR15
is D, the next word in memory after WR15 will
be used for the least significant half of the
product.
General format: TS Zl
The Tg and S fields provide multiple mode addressing capability for the source operand. When the XOP is executed,
ST6 is set and the following transfersoccur: WOig +4D) —(WP)
CO (42i6 +4D)-(PC)
CO SA -*(newWR11)
CO
(oldWP)-(newWR13)
(oldPC)-MnewWR14)
(oldST)->(newWR15)
The TMS 9900does not test interrupt requests (INTREQ) upon completion of the XOP instruction.
The Tg and S fields provide multiple modeaddressing capability for the source operand.
RESULT STATUS
OP CODE
MNEMONIC MEANING COMPAREO BITS DESCRIPTION
0123456789
TOO AFFECTED
B 000001 0001 Branch No _
SA - (PC)
BL 0 0 0 0 0 1 10 10 Branch and link No -
(PC)-»(WR11);SA -*(PC)
BLWP 0000010000 Branch and load No (SA) -* (WP); (SA+2) -*• (PC):
workspace pointer (oldWP)-MnewWR13);
(old PC)"* (new WR 14);
(old ST >-MnewWR15);
the inti rrupt input (INTREQ) is not
FFFF16-(SA)
INV 0 0 0 0 0 10 10 1 Invert Yes 0-2 (SA)-MSA)
NEG 0000010100 Negate Yes 0-4 -ISA) "MSA)
ABS 0 0 0 0 0 1 1 10 1 Absolute value* No 0-4 i(SA)l-MSA)
SWPB 0 0 0 0 0 1 1 0 11 Swap bytes No -
(SA), bits 0 thru 7 -*• (SA), bits
RESULT STATUS
OP CODE
MNEMONIC MEANING COMPAREO BITS DESCRIPTION
0123456789
TOO AFFECTED
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
The C field specifies the number of bits to be transferred. If C = 0, 16 bits will be transferred. The CRU base register
(WR 12. bits 3 through 14) defines the starting CRU bit address. The bits are transferred serially and the CRU address is
incremented with each bit transfer, although the contents of WR12 is not affected. Tg and S provide multiple mode
addressing capability for the source operand. If 8 or fewer bits are transferred (C - 1 through 8), the source address is a
byte address. If 9 or more bits are transferred (C = 0,9 through 15). the source address is a word address. If the source
is addressed in the workspace register indirect auto increment mode, the workspace register is incremented by 1 if
C - 1 through 8, and is incremented by 2 otherwise.
RESULT STATUS
OP CODE
MNEMONIC MEANING COMPARED BITS DESCRIPTION
0 12 3 4 5
TOO AFFECTED
LDCR 0 0 1 10 0 Load communcation Yes 0-2.5* Beginning with LSB of (SA), transfer the
register specified number of bits from (SA) to
the CRU.
STCR 0 0 1 10 1 Store communcation Yes 0-2J5T Beginning with LSB of (SA), transfer the
register specified number of bits from the CRU to
(SA). Load unfilled bit positions with 0.
o i 11 12 13 14 15
SBO 0 0 0 1110 1 Set bit to one Set the selected CRU output bit to 1.
SBZ 0 0 0 11110 Set bit to zero Sot the selected CRU output bit to 0.
TB 0 0 0 11111 Test bit 2 If the selected CRU input bit» 1, set ST2.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 IS
If C = 0. bits 12 through 15 of WRO contain the shift count. If C =0 and bits 12 through 15 of WRO = 0, the shift
count is 16.
RESULT STATUS
OP CODE
MNEMONIC MEANING COMPAREO BITS DESCRIPTION
01234567
TOO AFFECTED
SLA 0 0 0 0 10 10 Shift left arithmetic Yes 0-4 Shift (W) left. Fill vacated bit
positions with 0.
SRA 0 0 0 0 10 0 0 Shift right arithmetic Yes 0-3 Shift (W) right. Fill vacated bit
positions with original MSB of (W).
SRC 0 0 0 0 10 1 1 Shift right circular Yes 0-3 Shift (W) right. Shift previous LSB
into MSB.
SRL 0 0 0 0 10 0 1 Shift right logical Yes 0-3 Shift (W) right. Fill vacated bit
CO positions with 0*s.
JP A.12 IMMEDIATE REGISTER INSTRUCTIONS
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
IOP
RESULT STATUS
OP CODE
MNEMONIC MEANING COMPARED BITS DESCRIPTION
0 1 2 3 4 5 6 7 8 9 10
TOO AFFECTED
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
IOP
OPCODE
MNEMONIC MEANING DESCRIPTION
0123456789 10
LWPI 0 0 0 0 0 0 10 11 1 Load workspace pointer immediate IOP -* (WP). no ST bits affected
LIMI 0000001 100 0 Load interrupt mask IOP, bits 12 thru 15"*ST12
thruST15
General format:
General format 0 0 0 0 0 o- 1 1 1 0 0 N
STATUS BITS
B M
Buffer chip 74 Machines, 16 bit 11
Maximum system 68
c Memory bank selection 32
Chip, buffer 74
Microprocessor, 12 bit 10
Clock generator 54
Minicomputer, LSI 13
Communication controller,
0
synchronous 51
Context switching 23
Organization, data & address 18
internal 19
CRT interface 73
CRU interfacing 28
P
Peripherals 78
D Programmable system interface 41
E S
External instructions 36 Selection, memory bank 32
Status display 36
Switching, context 23
G Synchronous communication
Generator, clock 54 controller 51
Systems, disc 75
1 maximum 68
Input/output techniques 27 upgrading minimum 57
Instructions, external 36
Interface, CRT 73 T
programmable system 41 Techniques, input/output 27
Interfacing, CRU 28
Internal organization 19 U
Interrupts 24 Upgrading minimum system 57
95