<s>
Contended	B-Device
memory	I-Device
is	O
Sinclair	O
's	O
name	O
for	O
a	O
portion	O
of	O
the	O
ZX	B-Operating_System
Spectrum	I-Operating_System
's	O
64	O
KB	O
addressable	O
memory	B-General_Concept
space	O
.	O
</s>
<s>
With	O
the	O
full	O
64	O
KB	O
,	O
the	O
Z80	B-General_Concept
microprocessor	I-General_Concept
is	O
the	O
exclusive	O
bus	O
master	O
,	O
so	O
it	O
reads	O
and	O
writes	O
operate	O
at	O
its	O
full	O
bus	O
speed	O
,	O
but	O
contended	B-Device
memory	I-Device
space	O
is	O
shared	O
between	O
the	O
ULA	O
and	O
the	O
Z80	B-General_Concept
,	O
with	O
the	O
ULA	O
having	O
higher	O
priority	O
.	O
</s>
<s>
Contended	B-Device
memory	I-Device
occupies	O
addresses	O
0x4000	O
..	O
0x7FFF	O
of	O
the	O
Z80	B-General_Concept
memory	B-General_Concept
map	I-General_Concept
.	O
</s>
<s>
This	O
is	O
the	O
first	O
16	O
KB	O
of	O
RAM	B-Architecture
in	O
the	O
48	O
KB	O
machine	O
and	O
the	O
entire	O
RAM	B-Architecture
of	O
the	O
16	O
KB	O
machine	O
.	O
</s>
<s>
Contention	O
occurs	O
as	O
a	O
result	O
of	O
the	O
ULA	O
reading	O
the	O
display	O
and	O
attributes	O
data	O
in	O
this	O
RAM	B-Architecture
to	O
produce	O
the	O
TV	B-Device
video	I-Device
display	I-Device
.	O
</s>
<s>
Accesses	O
to	O
I/O	B-General_Concept
also	O
contend	O
if	O
the	O
ULA	O
must	O
read	O
contended	B-Device
memory	I-Device
while	O
the	O
Z80	B-General_Concept
accesses	O
a	O
ULA	O
I/O	B-General_Concept
port	O
.	O
</s>
<s>
ULA	O
I/O	B-General_Concept
ports	O
are	O
those	O
with	O
an	O
even	O
address	O
(	O
address	O
bit	O
0	O
is	O
a	O
0	O
)	O
.	O
</s>
<s>
The	O
Z80	B-General_Concept
must	O
wait	O
whenever	O
the	O
ULA	O
needs	O
to	O
access	O
contended	B-Device
memory	I-Device
before	O
proceeding	O
with	O
its	O
own	O
contended	B-Device
memory	I-Device
read	O
or	O
write	O
.	O
</s>
<s>
The	O
effect	O
to	O
the	O
user	O
is	O
that	O
programs	B-Application
that	O
make	O
use	O
of	O
contended	B-Device
memory	I-Device
or	O
contended	O
I/O	B-General_Concept
run	O
slower	O
than	O
those	O
that	O
avoid	O
it	O
.	O
</s>
<s>
The	O
ULA	O
must	O
wait	O
for	O
a	O
Z80	B-General_Concept
read	O
or	O
write	O
to	O
complete	O
before	O
it	O
can	O
stop	O
the	O
Z80	B-General_Concept
's	O
clock	O
and	O
access	O
the	O
memory	B-General_Concept
;	O
it	O
will	O
stop	O
the	O
Z80	B-General_Concept
's	O
clock	O
only	O
during	O
the	O
first	O
clock	O
cycle	O
of	O
a	O
machine	B-General_Concept
cycle	I-General_Concept
.	O
</s>
<s>
Early	O
Spectrums	O
make	O
the	O
assumption	O
that	O
at	O
most	O
one	O
contended	B-Device
memory	I-Device
access	O
will	O
occur	O
in	O
a	O
machine	B-General_Concept
cycle	I-General_Concept
:	O
this	O
is	O
n't	O
true	O
in	O
instruction	B-General_Concept
fetch	I-General_Concept
cycles	O
if	O
the	O
programmer	B-Application
has	O
configured	O
the	O
interrupt	B-General_Concept
vector	I-General_Concept
table	I-General_Concept
to	O
fall	O
within	O
the	O
contended	O
area	O
.	O
</s>
<s>
In	O
that	O
case	O
the	O
ULA	O
will	O
decline	O
to	O
load	O
its	O
video	O
address	O
and	O
the	O
video	O
byte	B-Application
displayed	O
will	O
be	O
whatever	O
the	O
processor	O
was	O
reading	O
.	O
</s>
<s>
The	O
consequence	O
of	O
this	O
is	O
random	O
noise	B-Algorithm
on	O
the	O
display	O
,	O
or	O
'	O
snow	O
 '	O
.	O
</s>
<s>
Since	O
this	O
effect	O
did	O
not	O
occur	O
under	O
normal	O
operation	O
—	O
it	O
required	O
a	O
programmer	B-Application
's	O
deliberate	O
intervention	O
—	O
it	O
was	O
very	O
seldom	O
seen	O
,	O
being	O
used	O
only	O
in	O
some	O
games	O
[	O
which	O
ones	O
?	O
]	O
</s>
<s>
Later	O
versions	O
of	O
the	O
Spectrum	O
,	O
including	O
all	O
128kb	O
versions	O
,	O
correct	O
the	O
bug	B-Error_Name
.	O
</s>
<s>
The	O
ULA	O
does	O
not	O
use	O
the	O
Z80	B-General_Concept
's	O
bus	O
request/grant	O
mechanism	O
to	O
become	O
bus	O
master	O
during	O
its	O
contended	B-Device
memory	I-Device
accesses	O
.	O
</s>
<s>
Instead	O
,	O
it	O
extends	O
the	O
high	O
period	O
of	O
the	O
Z80	B-General_Concept
clock	O
input	O
to	O
stop	O
all	O
microprocessor	B-Architecture
activity	O
.	O
</s>
<s>
While	O
this	O
is	O
less	O
elegant	O
than	O
performing	O
a	O
bus	O
request	O
,	O
it	O
does	O
gain	O
contended	B-Device
memory	I-Device
access	O
to	O
fewer	O
Z80	B-General_Concept
clocks	O
.	O
</s>
<s>
The	O
ULA	O
connects	O
directly	O
to	O
the	O
memory	B-General_Concept
system	O
ICs	O
while	O
the	O
Z80	B-General_Concept
connects	O
to	O
them	O
through	O
isolating	O
series	O
current-limit	O
resistors	O
.	O
</s>
<s>
This	O
allows	O
the	O
ULA	O
and	O
memory	B-General_Concept
to	O
drive	O
each	O
other	O
while	O
the	O
Z80	B-General_Concept
is	O
also	O
driving	O
the	O
memory	B-General_Concept
.	O
</s>
<s>
Using	O
resistors	O
instead	O
of	O
tristate	O
bus	O
driver	O
ICs	O
reduces	O
the	O
expense	O
of	O
the	O
circuit	O
but	O
does	O
take	O
a	O
higher	O
average	O
I/O	B-General_Concept
pin	O
current	O
from	O
the	O
Z80	B-General_Concept
,	O
ULA	O
and	O
memory	B-General_Concept
ICs	O
.	O
</s>
