ZXSpectrum Diags User Manual
ZXSpectrum Diags User Manual
They are designed for use with Dylan Smith's diagnostic board but can be utilised with any device that can replace the
Spectrum's built in ROM with this image. These interfaces (diag boards) usually plug into the Spectrum edge connector.
On the Sinclair ZX Spectrum (Rubber Key model), the board can be modi ed, to replace the Sinclair ROM, with a
standard 28 pin DIL (Duel In Line) EPROM, such as a 16K, 27C128 or 32K 27C256.
The EPROM can then be programmed with the Diags software, and ran when the Spectrum boots. This is useful if you
have made a dedicated test board, with IC sockets etc, as in the picture below.
If using a 32K EPROM, the EPROM can be programmed with both the diags software, and the Sinclair BASIC ROM, or
a replacement, such as the excellent GOSH wonderful ROM, or Looking Glass ROM, by Geof Wearmouth.
A switch can added to switch between the two ROM images (duel boot).
There are two main types of diag boards are available, One with LED’s for the data lines D0-D7, Which can also
indicate the location of faulty RAM chips, (as well as the software), very useful, if there are too many faulty RAM chips,
in the lower RAM, to display a readable picture.
The other type of diag board, run the diagnostic program only, and don’t have the Data line LED’s. These carry out
exactly the same diagnostic tests, just don’t display potential errors on the Data lines D0-D7 LED’s.
PAGE 1
CHAPTER 1 - COMPATIBLE DEVICES
https://www.bytedelight.com/?product_cat=zxdiagcarts
J2
Data Lines
Status LED’s
D0-D7
ROM1/OE Jumper
ON ZX Spectrum J1
OFF Brazillian
clone Spectrum
Power Lines
Status LED’s ROM
Contains the
Diagnostic
software
PAGE 2
CHAPTER 1 - COMPATIBLE DEVICES
D0 D1 D2 D3 D4 D5 D6 D7
https://www.retroleum.co.uk/spectrum-peripherals
A simple external plug in ROM board which can be handy for running diagnostics etc.
MAIN FEATURES
Simply plugs into the Spectrum’s edge connector.
Holds four 16K ROMs, selectable with DIP Switches
By default, it’s programmed with 3 diagnostic ROM programs (DiagROM, ZX Diagnostics, Sinclair ZX test) plus
GWROM BASIC. However, they can all be anything that's freely available for download on the net
(let me know when ordering) or the chip (W27C512) can be removed and reprogrammed in a standard
EPROM burner.
Has a ROM Disable switch, so the ROM can be disabled without removing the interface.
Has a button to reset the Spectrum and LED indicators for main power (+5 volts) +12v and -5v and the M1 signal.
Works with all standard Sinclair and Amstrad era Spectrums.
ROM Disable
Switch
MODEL SELECT
Currently Selected
Spectrum 48K.
Move jumper to
Right for 128K,
+2A, +2B or +3
PAGE 4
CHAPTER 1 - COMPATIBLE DEVICES
https://www.retroleum.co.uk/spectrum-peripherals
The SMART Card is a Spectrum plug in interface, game loader with kempston compatible joystick interface. aimed at
Spectrum users who want a simple plug and play method of loading games quickly from micro SD Card. Supports
.sna and .tap les. It is intended primarily as a simple low-cost game loader, freezer and diagnostics tool.
Also functions as an external ROM board, and comes pre-loaded with Retroleum’s DiagROM diagnostics software
stored in slot B, and can be replaced with the ZX Spectrum diagnostics ROM.
MAIN FEATURES
Can work as a Diag board, has switch on the back, to boot the Diags software in slot B, or boot the games loader.
Built in Kempston compatible joystick port.
Works as a games loader supporting .sna and .tap les stored on microSD card. No games are included.
Multi-ROM switcher – The onboard ashRAM can hold fteen, 16K ROMs and these can be selected from a menu
NMI button acts as a game freezer and allows Pokes to be entered, snapshots (.sna les) to be saved,
code to be disassembled etc.
For more Information, please navigate to the link below
Reset button. https://blog.retroleum.co.uk/smart-card-for-zx-spectrum/
EXAMPLE GAMES LOADER MENU NMI MENU
PAGE 5
CHAPTER 1 - COMPATIBLE DEVICES
MAIN FEATURES
Can work as a Diag board. ZX Spectrum Diagnostics ROM pre-loaded. Press R from menu, or Press the SW1 button
whilst powering on to run the diagnostics.
512k of fast access memory, enabling multilevel game development that o er a console-like experience.
Instant load of games by a simple menu.
Games & Programs can be changed from the PC with no extra hardware via audio or with a serial connection or by using a divide/
divmmc.
V2.0, Kempston Joystick interface onboard
No need for con guration. It works in any Spectrum computer, from 48k to +3 and most of the clones, including ZXNext and
Harlequin.
Supports 48k and 128k SNA & Z80 snapshots compressed/uncompressed as well as 16k ROM images. Also supports TAP les
and MLD multiload games with progress-save in the cartridge.
POK compatible trainer library for included games. Games can be launched with any number of enabled or disabled trainers as
selected by a spectrum menu.
Option to freeze loading screen until a keypress or for some seconds
EDGE connector pass-through allowing to connect other peripherals (yes, Dandanators mini can be stacked
It can stay plugged and deactivated. No need to unplug it to use your Spectrum for something di erent.
Automatic shutdown if another peripheral wants to take control of the ROM space.
Management software for Windows, MacOS y Linux to create, transfer and organize your games.
Emulated as peripheral in release 4.2 of ZesarUX and in Es.pectrum newest version
Can be used as a CP/M plug&play system and “Hard Disk” of 460Kb+ for any +2A/B or +3 Model
You can pause any game by pressing a button
You can create your own game snapshots from the spectrum
PAGE 6
USING THE ZX DIAGNOSTICS ROM
You will nd a ready to program version of the diagnostic rmware provided in the release package, named
'testrom.bin'. https://github.com/brendanalford/zx-diagnostics/releases/download/v0.37/Release-v0.37.zip
Since there are many di erent hardware devices capable of providing the ability to replace the Spectrum's ROM image
with the diagnostic rmware, that process will not be outlined and is left as an exercise for the reader. To be fair, if you
own any of these devices and are attempting a Spectrum repair, it's assumed you know what you are doing :)
Plug in the device containing the diagnostic rmware and power on the machine.
You should hear eight short beeps (about half a second apart) followed by two distinct tones (and see a blue, then
green border if the display is active) - this con rms that the machine is running, at least the CPU and ULA are working
and that there are no issues with the address or data buses on the machine under test that prevent code execution.
If running with a Diagnostic Board (henceforth referred to as a DiagBoard), the eight LED's will light brie y then go out
one by one in time with the short beeps - this con rms that the DiagBoard I/O is working correctly.
If the display is active, you should see a line of text in the middle brie y, outlining hot keys and their purpose. The
various areas of functionality are described in following sections. At the end of this period the border will cycle through
all available colours as part of a very basic ULA test.
The rmware will then execute some memory tests on the lower 16K of RAM which are described below.
If instead, you see a tight rainbow-coloured rolling border along with an unpleasant high pitched shriek from the beeper,
then the rmware checksum operation has failed. This is designed to ensure that the diagnostics code is completely
accessible, not corrupt and fully addressable by the CPU. If the checksum fails, then either the diagnostic image is
corrupt, or (more likely) an address line is stuck low or high. In this case, manual investigation is required that is outside
the scope of these tests.
PAGE 7
16K - LOWER RAM TESTS
As the lower RAM of a Spectrum is used for display, we cannot assume that the machine can produce a correct display
nor rely on it for output. Therefore lower RAM testing will produce some test patterns on the display that exercise the
RAM in various ways, and if a failure is found, will report the result by way of a series of stripes in the border.
There will be eight of these stripes, representing bits 0 to 7 in downward order. These correspond to memory IC's IC6
to IC13 (which are 4116 IC's) in that order. A green stripe indicates a healthy IC, and a red one that a fault was
encountered.
In the screen area, the rmware will attempt to display a message 'RAM FAIL' along with the failing bit positions.
Depending on the overall health of the lower RAM in the system, this display may be quite clear or barely legible, but
should be visible to some extent on machines in which there is at least one working lower RAM IC. The computer will
then halt. In the example below, faulty RAM IC’s have been detected at locations BIT 1 (D1) and BIT 3 (D3)
BIT O
BIT 1
BIT 2
BIT 3
BIT 4
BIT 5
BIT 6
BIT 7
If a DiagBoard is being used, then the LEDs (Data 0-7) will be lit to re ect failed memory IC's in the same pattern.
NOTE 1: If testing a 128K machine, these tests will by default exercise page 5 of RAM. In this case, the memory IC's
corresponding to bits 0-7 (data lines), are as follows:
See next page for ZX Spectrum issue one board RAM IC locations.
PAGE 8
NOTE 2: If testing an Issue 1 Spectrum, the lower RAM IC's do not have IC designations on the PCB, nor are they in
the same layout as in later issues. The layout is as follows:
D7 D6 D5 D4 D3 D0 D2 D1
BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 0 BIT 2 BIT 1
Further tests
If the lower RAM tests pass, then we have usable RAM in which to produce a display and store some workspace. The
machine will then clear to a white screen where results of further tests will be displayed.
If running on a DiagBoard, SMART card or ZXC3/ZXC4 cartridge, the rmware will try to identify the ROM on the
computer by checksumming the content. If this is successful, the rmware con rms the checksum and type on the
screen, then proceeds with testing appropriate to that machine.
If the ROM is corrupt or missing, then this test will fail with the message 'Unknown or corrupt ROM' and the user will be
prompted to select the type of machine being tested.
If another non-supported ROM device is being used, or the system ROM has been replaced by an EEPROM containing
the diagnostic image, the message 'Diagnostic hardware not found' will be displayed and the user will be prompted to
select the machine type. If no input is made for approximately 20 seconds, the rmware will assume 48K mode and
continue with testing.
Note: This autodetection currently does not work on +2A/+3 machines due to the /ROMOE1 and /ROMOE2 lines on
these machines not being handled by the DiagBoard hardware - one will need to choose the +2A/+3 test option
manually. This is not an issue when using the SMART card or a +2A/+3 xer device.
On 128 machines, if the rst ROM checksum passes but subsequent checksums do not match, then this will be
indicated along with the IC designation to check.
PAGE 9
48K - UPPER RAM TESTS
The upper 32K of memory is then tested using the same test routines that were used for the lower 16K. Any failures for
a particular test are noted, and the IC's responsible for the failure are displayed.
If the machine has been identi ed via the ROM check as a clone, then the failing bit positions are displayed instead.
If all 8 upper RAM IC's are found to be faulty, the machine is either a 16K model or has a problem with the upper RAM
multiplexer IC's. Information to this e ect will be displayed if this occurs.
Note: If testing an Issue 1 with Sinclair 32K daughterboard, this board again has no IC designations. The diagnostics
will identify IC15-IC22 as being faulty, representing bits 0-7 in the same order. These bits map to the physical IC's on
the daughterboard as marked below:
D3 D4
BIT 3 BIT 4 D2 D5
BIT 5 D0 D7 D6 D1
BIT 2
BIT 0 BIT 7 BIT 6 BIT 1
PAGE 10
128K TESTS
All memory banks are tested in turn by paging them in to the C000-FFFF address range, except bank 5 which
represents the lower 16K of memory on 128K machines. Failures are noted against each bank, and again the IC's
responsible for failure are displayed when testing is concluded.
Memory paging is also tested and is agged if a failure is detected. This is almost always due to a misdetection of a
48K machine as a 128K, or an issue with the PAL/HAL/ULA IC's, depending on model.
Interrupt Testing
When memory testing is complete, the results are displayed and then an attempt is made to verify correct interrupt
generation and handling. This is indicated by a message 'Testing interrupts...' accompanied by a (hopefully) increasing
counter, and if running on a DiagBoard the LED's should be ashing in a pattern that re ects the LSB of the counter.
PAGE 11
TEST CARD
If the SPACE key is held down when the machine is powered on, following the initialisation tones a colour test card
will be displayed, accompanied by a repeating tone. This is intended to facilitate tuning of VR1/VR2 pots on Issue 1 or 2
machines.
The test card can also be displayed by holding a joystick attached to either a Kempston compatible interface, or an
Interface 2 (Port 1) compatible interface to the left.
Holding down the Break key (or Caps Shift/Space) will reset to BASIC (on supported hardware) or restart the
rmware (other devices).
If the repeating tone is not desired, holding down the Q key silences the tone.
Holding down the 'A' key will switch tone generation to the AY chip if present. All three channels are exercised by
this test (which is based on BLITS). Black & Lane's Ident Tones for Surround
PAGE 12
SOAK TEST
If the 'S' key is held down when the machine is powered on, the rmware enters soak test mode (signi ed by a third
high pitched tone immediately after the initialisation tones). This performs repeated memory testing, looping back to the
start after each successful test.
The soak test can also be launched by holding down the FIRE button of a joystick attached to either a Kempston
compatible interface, or an Interface 2 (Port 1) compatible interface.
When testing upper RAM (48K) or 128K memory, soak test mode is indicated as a counter at the bottom of the screen
of the form 'Soak test: iteration xxxxx'. This may be used as a guide to how long soak testing has been running for.
All tests are executed identically and in the same order as in normal test mode, except for the interrupt count test.
Following each successful test iteration, a message 'Soak test iteration complete' is displayed and the rmware
commences the next test iteration after a short delay.
If a lower RAM failure is detected, soak test mode is indicated by a narrow yellow border stripe at the bottom of the
screen.
A failure detected during soak testing will halt testing (except where no upper memory is found working; this will be the
case if testing a 16K Spectrum). Repeated tones will also sound to alert an absent operator of the failure.
If the ROM checksum test fails (and therefore the machine type cannot be determined), the rmware assumes 48K
hardware and continues testing as such.
PAGE 13
ULA TEST
If the 'U' key is held down when the machine is powered on, following the initialisation tones the ULA Test screen
will be shown. This is a rudimentary facility to allow basic ULA functionality to be veri ed.
The ULA test can also be launched by holding a joystick attached to either a Kempston compatible interface, or an
Interface 2 (Port 1) compatible interface to the right.
The ULA type is autodetected and displayed at the top of the screen, if this is not as expected there may be an issue
with your ULA, transistor TR6, or the machine's timing in general.
The CPU type is also determined (NMOS being the type to be found as standard in all Spectrum models, CMOS a
newer, lower powered implementation). A CMOS CPU may display software incompatibilities in very rare cases, also
replacement CMOS Z80's sold on certain auction sites may be remarked NMOS parts. This test is useful for
determining this fact for de nite.
The values read from Port 0xFE are displayed following the 'ULA Read' message, set bits are rendered as white ink on
black paper, reset bits as the inverse. The EAR bit is also rendered in the border as black and white loading stripes, and
may be used to check azimuth adjustment on a connected or built-in cassette recorder.
Pressing keys on the keyboard in uences the values of bits 0-4 as you would expect, and allow the full keyboard to be
veri ed.
Holding down the 1 key will output a tone via the MIC port of the ULA, accompanied by red/cyan stripes. This can
be used to verify tape saving output.
Holding down the 2 key will output a tone via the EAR port of the ULA, accompanied by blue/yellow stripes. This
can be used to verify speaker output (a little redundant perhaps)
Holding down the 3 key will output all possible colours as a rainbow border pattern, and to verify that this
functionality is operating successfully.
Holding down the 4 key will, on 128K machines, test the shadow screen switching functionality by overlaying the
screen with green bars on the screen and in the border. A problem with screen switching would result in the entire
screen becoming green, or stripes in the border only (which is what 48K users will see if selecting this test). If the
stripes continue to move a couple of seconds after the 4 key is held, then this indicates an issue with paging port
contention (the stripes should move a little but then settle into a non-moving display).
Holding down the 5 key will test the ULA addressing - this works by writing values to the ULA port 254 (0xFE) and
to port 255 (0xFF) alternately. If all is well you should see a ashing green/white border. However if the ULA is
responding to OUT's not meant for it, then you should see a red and white ashing border, or some other indeterminate
state which will be dependent on the speci c failure encountered.
A moving multicolour stripe is displayed to allow veri cation of interrupt functionality and frequency. If the rmware
detects missed interrupts or too many interrupts, then the words 'FAIL FAIL FAIL' will be displayed in the middle of the
line that the stripe occupies. If this occurs, you may also observe a thin red stripe in the border (this would ordinarily
appear immediately after vertical sync and is only visible by adjusting the vertical hold control, if you have a suitably
aged TV).
When holding down keys 1,2 or 3, interrupts are disabled and the multicolour stripe will be paused until the key
is released.
If a tape is played back during this test, then black and white loading stripes will appear in the border. This will allow the
azimuth angle of the tape deck to be adjusted to achieve more uniform stripes, and therefore more reliable loading,
As with the test card, holding down the Break key (or Caps Shift/Space) will reset to BASIC (on appropriate
diagnostic hardware) or restart the rmware (other devices).
PAGE 14
ULA TEST (CONTINUED)
Keyboard Tester
The rmware includes a simple keyboard test so that the membrane in the machine under test can be veri ed. It is
activated by either holding down the K key on startup, or by triggering an NMI at any point during testing (this
can be done using the NMI button on the Retroleum SMART card, or by any supported interface that includes such a
button).
A representation of the Spectrum's keyboard is displayed, and when a key is pressed, the corresponding key on the
on-screen keyboard will light up, accompanied by a short beep.
Holding down Caps Shift/Space or BREAK will exit the test and return to BASIC (supported devices) or restart
testing (unsupported devices).
PAGE 15
MEMORY BROWSER
Holding down the 'M' key on startup enters memory browser mode, which allows the ROM/RAM space to be
examined, browsed and modi ed. All available ROM and RAM banks can be paged in for inspection, and entering
hexadecimal values directly will immediately modify the byte upon which the cursor is positioned.
ROM space is highlighted in red to indicated that it cannot be modi ed, RAM space is displayed in blue.
The cursor keys can be used to move the highlighted memory location, or you can go directly to an address by pressing
G followed by its 4-digit hexadecimal address (e.g. G 5B00). Z and X move the display up or down a page respectively.
Keys 0-9 and A-F can be used to alter data if the cursor is currently pointing at RAM address space.
R followed by a number will page the given ROM number in (if on a 128k machine), and P followed by a number will
page that given RAM bank into location C000-FFFF on 128k machines.
Pressing H if a ZX Printer or compatible unit is connected will produce a hard copy of the memory browser
screen. A warning tone will be emitted if such a device is not connected or working.
On the ZXC3 and ZXC4 cartridges, the memory space between 0x3FC0 and 0x3FFF cannot be read or modi ed and
will be displayed as all FF's. This is due to the way the ZXC3/ZXC4 cartridges perform their memory mapping.
Holding down Caps Shift/Space or BREAK will exit the browser and return to BASIC (supported devices) or
restart testing (unsupported devices).
Firmware Details
These can be accessed by holding down the Symbol Shift key on startup, and display version information and other
build information. In the event that the rmware malfunctions or does something unexpected, please note the
information represented here and provide it to me along with your bug report.
PAGE 16
MEMORY TESTING DETAILS
There are four distinct types of memory test performed on each block of memory, these are described below.
Walk Test
This is a very simple test - all it does is set each bit and reset each bit in memory, checking the memory holds the
desired value on each iteration. If the test fails here, it means the failed RAM chip simply isn't reliably (or at all) able to
be set to a given value. This can be caused by a failed chip or a bad solder joint or broken PCB track. (When testing
lower RAM, you can often see this once tests halt, by vertical lines 1 pixel wide running down the screen being visible)
This test will also show up failures in logic caused by data bus lines being shorted together.
Inversion Test
Many faulty chips can pass the rst test sequence. This test looks for faults where setting or resetting a bit in memory
causes another bit to erroneously be set or reset. The tests consist of setting all of the memory bank to zero, and then
writing 1s in all even memory addresses, and then checking the pattern is as expected. The test is run again - memory
is blanked, then odd addresses are written to, and the pattern checked. Then, all of the ememory bank is set to 1, and
even addresses are reset and tested. Finally, memory is all set to 1 again and odd addresses are reset and tested.
If the memory fails the inversion test, you can often get some insight into what is happening by watching the screen if
it's lower RAM that has failed (and if your Spectrum won't boot normally at all, this is highly likely). You should see
alternating black and white vertical stripes appear on the screen. If a set of stripes is anything other than black or white,
setting the bit in the failed memory likely sets the entire contents of the chip to that value. It's likely the row/column
select circuitry in the failed chip has a fault in that case. Other failures can be simply one or two adjacent bits getting
ipped in the wrong place. This may not be visible by the screen even if it's happened in lower RAM (the portion of RAM
that the frame bu er occupies might be working ne).
March Test
This test aims to shake out simple failures caused by addressing a memory location that causes adjacent locations to
be written erroneously. The algorithm used works as follows:
The routine uses a 16 bit pseudo random number generator to ll the memory bank with values, and then restarts the
random number generator with the starting seed, and compares the output of the random number generator with what
is held in memory. Memory is lled from bottom to top with one pattern, veri ed, then top to bottom with another pattern
and veri ed again.
When lower RAM is tested, you should see a scrambled pattern of random pixels and attributes on the screen.
During soak testing, there is a delay between writing the random pattern and reading back the values. This is intended
to catch situations where memory may not be refreshed properly and begins to degrade after time.
Memory failures in this test are most likely problems with the chip's row/column select circuitry. For example, if the most
signi cant bit gets stuck on for column access, setting a bit at location 0 in the chip will also set location 8192 in the
case of a 4116.
PAGE 17
FINDING A FAULTY RAM CHIP - MANUAL METHOD
Typed in from pages 4.8 - 4.9 of the original Sinclair Spectrum service manual
Where a Spectrum has initialised correctly but a RAM memory fault is suspected, it is possible to nd the faulty address
and relate it to a faulty IC by carrying out the following procedure:
The value printed in each instance is the last valid memory location, and in a serviceable unit would be as set out
above. Therefore, if a di erent value, n, is printed the faulty location will be n + 1. If the value returned is less than
32767 the fault lies in the original 16k of RAM. The following example illustrates the method of relating a faulty
location to a faulty IC
Example
Assume the answer displayed is 43200, therefore the faulty location is 43201 (stops at last valid location).
Key-in:
If answer B is anything other than 170 look up in following table which IC to change (e.g. if answer B is 234
change IC21). Similarly, if answer A is other than 85 refer to the table below, to nd the faulty IC.
If there is more than one faulty RAM location the rst fault identi ed will have to be repaired before it is
possible to proceed.
PAGE 18
DIAGNOSTIC BOARD HARDWARE MANUAL
Introduction
First things rst: the Spectrum isn't hot pluggable. To avoid killing your machine even harder (or killing a working
machine if you're making other uses of the board), make sure you do the following before plugging the board into the
Spectrum. This may seem like old hat, but just some reminders:
Make sure that the power really is turned o on the Spectrum. The best way to to this is to make sure the 9v supply is
physically unplugged from the machine.
Ensure that all the jumper blocks on the diagnostics board are actually jumpered, otherwise inputs they control will be
left oating and odd things will happen.
Observe anti static precautions, especially if the relative humidity is low - the risk is highest in the winter. Be especially
cautious if you regularly experience static shocks! Both the Spectrum and the diagnostic board use chips with
MOSFETs, whose gate oxide is easily destroyed by a shock you can't even feel. Handling the board by the edges is
helpful, and avoid wearing clothing made from synthetics, because they turn you into a pretty good Whimshurst
machine.
Double check that the chips in the diagnostic board are all connected the right way around, especially ones you may
remove frequently like the ash memory. While the ash chip can survive reverse orientation, it will short the Spectrum's
7805 voltage regulator but leave the switch mode power supply working - meaning the Spectrum's 4116 RAM will have
some supply rails working and others not. This sort of thing kills 4116 RAM.
If you've constructed the board yourself - don't forget to test the board for shorts and open circuits before using it for the
rst time, even if you got the board made by a PCB factory.
How To Use
The board is very simple to use. For diagnostics work, check that:
Once you power the machine up with the board plugged in, so long as the Z80 is working, all LED's should turn on then
o brie y, signifying the tests are about to start. If the ULA is functioning, you should see the screen showing a blue,
then green border and black paper on start up (assuming you're using the Diagnostics ROM from this site also).
PAGE 19
Hardware Details
The board is commanded by two Z80 I/O ports - port 31 to change the selected ash ROM memory page (and map in
and out the Spectrum's ROM), and port 63 to light up the LEDs. To describe how this actually works on the hardware
level, we'll start from the address decoding and work inwards from there.
The board senses an OUT instruction with the chip U1 - a 74HC138. This is a 3-to-8 line decoder. Address lines A5, A6
and A7 are connected to the three address lines on the '138. You can count from 0 to 7 with three binary bits, and what
the '138 does is activate output 0 to 7 depending on what 3 bit number arrives on its inputs. So really - what's important
is what the Z80's address lines A5, A6 and A7 are outputting during an I/O cycle.
We're only using 2 outputs on this chip - output 0 for the memory bank selection, and output 1. So if the pattern on A5,
A6, A7 from the Z80 is 000, then the memory is selected. If the pattern on these three address lines is 001, then the
LED register is selected.
As well as the right pattern being on the address bus, we've got to be able to determine that the Z80 is making an I/O
request, and not a memory request or an interrupt acknowledge. The '138 has three Enable pins for this purpose.
Indeed, it doesn't matter what the state is on the three address pins on this chip if the enable pins aren't set to the right
levels - all outputs will remain inactive.
To tell whether the Z80 is making an I/O request, two pins must be monitored - IORQ and M1. IORQ must be low and
M1 must be high. (Why must M1 be monitored? This is because the Z80 acknowledges a maskable interrupt by a
special M1 cycle, with IORQ low and M1 low.
Spurious address decodes can occur if only IORQ is used for an enable). Additionally, we also look at the state of WR
to make sure we're getting an OUT instruction, not an IN instruction, since this board only requires I/O writes and not
reads.
Of course, it would be simple if large numbers of Spectrums hadn't shipped with Z80s with faulty M1 lines. A faulty M1
line doesn't seem to a ect a Spectrum at all if it's used stand alone, but it can stop some peripherals from working
properly. Therefore, a jumper is provided on the board to ignore M1, so that the I/O decoding relies just on IORQ and
WR being active together (which is also only the case during an OUT instruction, not an interrupt acknowledge).
If you change the jumper so that M1 is used, you can write a short BASIC program to test the functioning of M1:
If the data lines D0-D7 LEDs all rapidly blink on and o in a stable and consistent manner, M1 works. However, if
the blinking is somewhat erratic, then M1 is faulty.
So all being well, the 74HC138 looks for an instruction for the board by monitoring the state of IORQ, WR and M1 to
recognise an I/O write instruction, and uses the state of A5, A6 and A7 to select either the memory page register or the
LED register. The output of the '138 goes low when it's selected.
The 74HC273 is not level triggered - rather, it latches the contents of the data bus on the rising edge of the signal on the
CP pin. When the Z80 de-asserts IORQ, the active low output of the 74HC138 will return high. The Z80 keeps the
contents of the address bus live for about half a clock cycle after it has de-asserted IORQ - this is to allow edge
triggered devices to read the contents of the data bus without needing any additional glue logic. This timing means the
rising edge of the 74HC138's output can be used to latch the value being sent by the OUT instruction that's running on
the CPU.
PAGE 20
Memory Paging
The 74HC273 octal ip op, U5, performs the function of being the memory page register. The board can take ash
ROMs from 128K to 512K, which is far larger than the address space that a Z80 can access. Therefore, this chip
controls the state of address lines A14 to A18 on the ash memory. This chip also has a reset pin, so on power up or
when the reset button is pressed, A14 to A18 are all at logic low, so the rst 16K page of ROM is selected. Additionally,
bit 5 of this chip is used to control whether the Spectrum's ROM is paged in, or whether the ash is paged in.
The Spectrum provides a line called ROMCS at the edge connector. There is a resistor between the ULA's ROM chip
select decoding logic and the ROM itself, and ROMCS is connected on the ROM's side of this resistor. Since the
Spectrum's ROM is enabled when ROMCS is low, holding this line high will prevent it from being selected.
This is accomplished on the diagnostics board by bit 5 of the rom page register U5 being connected to the gate of a P-
channel MOSFET. The MOSFET connects the +5v line to ROMCS when it is turned on. It is turned on by bit 5 of U5
being set to logic low with the jumper on J1 on pins 1 and 2.
If the jumper on J1 is on pins 2 and 3, the output of bit 5 is inverted before being sent to the gate of this transistor, which
means bit 5 needs to be set to logic 1 for the ash to be paged in.
This allows the board also to be used as a general purpose ROM board, so that di erent ROMs can be paged in at will.
Also, programs can be written to copy a program to RAM, for example, a snapshot taken on an emulator and written to
the ash chip.
PAGE 21
NOTES