Your Spectrum
Issue 2, March 1984 - SoftROM
Home Contents KwikPik
SOFT
R O M
.
Developing a range of software 'goodies', Timedata's Mike Lord divulges the secret of the SoftROM - the circuit which made it all possible.
.



 
.

As anyone who has used machine language will understand, it's a darn sight easier to find out what a machine code routine is doing if you can make temporary changes to it; by adding breakpoints for example, or by jumping into the middle of a routine, or returning prematurely from it. And so, from a desire to change the contents of the Spectrum's ROM, combined with the knowledge that the contents of a ROM are fixed for ever when the chip is manufactured, came the idea for SoftROM - a hardware add-on containing 16K bytes of RAM which can be controlled
by a switch to operate in two modes.
In the 'normal' mode, the RAM is located in the low 16K bytes of the Spectrum's address space - where the ROM resides - but only appears when data is written to it. Any data that is read from this area will come from the ROM, so the Spectrum will behave normally. In SoftROM mode, however, the Spectrum's ROM is disabled completely, and any read or write to locations in the first 16K will be to the added RAM.
With this add-on in the 'normal' mode, you can copy the contents of the ROM into the corresponding RAM locations. This done, you can then switch to SoftROM mode, and the Spectrum should carry on running exactly as it does normally, except that the Basic interpreter, operating system, character dot patterns, and all of the other intriguing routines are now in RAM - there for you to mess with as you will! You might even care to try correcting the known 'bugs' in the Spectrum ROM!
Another use of SoftROM would be in developing large machine code programs that entirely replace the Spectrum's ROM and which would eventually be put into EPROM or even a cartridge that plugs into the Interface II unit. Or alternatively, for the really ambitious who are also able to add a floppy disk drive to their Spectrum,
SoftROM could be used to implement the CPM operating system, which needs RAM in the area normally occupied by the Spectrum's ROM.
But for those of more modest means, the SoftROM circuit can also be used as a normal memory extension add-on, hoisting the 16K Spectrum up to 48K. To do this, all that's necessary is to fit 64K x 1 RAM ICs (4164s) in place of the 16K x 1 types (8118, 4816) and connect pin 6 of IC11 to the Spectrum's address line A15 instead of to 0V. The SoftROM board will then contain 64K bytes of RAM, 16K of which are used for the SoftROM function, 32K to extend the Spectrum's RAM, and 16K which will not be used at all. Do this and the 32K bytes extension will always be present, regardless of the position of the SoftROM mode switch.
One other 'enhancement' is the addition of a push-button Reset switch. Operating this triggers the Spectrum's power-on reset circuit and is guaranteed to get you out of the most horrendous 'crashes' without having to cut the power.

BUILDING THE BEAST
.

Because of the large number of connections to be made and the potential
The Spectrum SoftROM Circuit
Mike Lord's favourite method of construction for this type of circuit is to build everything on a piece of veroboard to which a 28+28-way Spectrum edge connector can be Araldited.

. SOFT
R O M
.

 
 
difficulty in tracing faults (it either works properly or not at all!), this project is only really suitable for the experienced constructor. Which means that if you are at all doubtful about your 'hot rod' skills with a soldering iron, then find a friend who is both willing and able - 'nuff said!
One peculiarity of dynamic memory ICs is that they draw large, fast, spikes of current from the supply rails when they are strobed. If the supply rails are not 'solid' and thoroughly decoupled, then the voltages developed by these current spikes flowing along even an inch or two of wire can be enough to upset things. For this reason, the RAM ICs should be mounted as close together as possible to minimise the lengths of the supply lines, and a small (10nf to 100nF) decoupling capacitor should be connected directly between pins 8 and 16 of each RAM IC, again keeping the lead lengths as short as possible. Another two or three capacitors should be fitted between the supply rails near ICs 9-14.
The author's favourite method of construction for this type of circuit is to build everything on a piece of bar veroboard to which a 28+28-way Spectrum edge connector socket can be Araldited. This socket must be fitted with a polarising key in position 5 to prevent the possible disaster of mis-mating when the board is plugged in to the Spectrum. A matching double-sided edge connector plug strip can be fitted to the rear of the board so that other add-ons like printers can hop aboard, piggyback fashion.
IC sockets, preferably with sturdy pins, are then glued on to the veroboard, then the 0V and +5V supply lines wired in using a reasonably heavy gauge wire. To keep noise to a minimum, the 0V line should be laid out in the form of a 'grid' so that the 0V connections between ICs are kept short.
The signal wiring can then be carried out by way of the 'verowire' system. This uses thin enamelled copper wire fed from a handy pen-type tool. To make a connection you wrap the wire two or three times round the IC socket pin, then apply solder and a fine-tipped iron in the normal way. The heat of the molten solder will melt through the enamel insulation on the wire to make a good joint. This may sound like a rather dubious way of wiring up a circuit, but the author has used it successfully for many years, and it must be the cheapest and most compact way of making a 'one-off' board. It's also surprisingly reliable and not too difficult to correct errors or make changes to a board wired in this way.
Finally, before plugging it in to your precious Spectrum, make absolutely sure that there are no accidental short- circuits between the supply rails and any other of the Spectrum connector pins.
HOW IT ALL WORKS
.

The throbbing heart of the circuit is the bank of eight RAM chips, IC 1-8. These are 16K bit (or 64K if the board is also to act as a memory expansion unit) dynamic memories, so eight are needed to provide the full 16K (or 64K) bytes, one chip being connected to each of the Spectrum's eight data lines.
As with all dynamic RAM ICs, they need two strobe pulses, RAS and CAS, and their address inputs are 'multiplexed'. That is, the address signals needed to select one of the 16K (64K)
 
 

"For the really ambitious, SoftROM could be used to implement the CP/M operating system."


 
 
bits are fed to the address inputs of the chip in two stages; half when the RAS line is pulsed, then the remaining half when the CAS line is pulsed. The selection of which half of the Spectrum's address lines are to be connected to the RAM chips is done by the quad 2-input multiplexers, ICs 9 and 10.
Dynamic RAM ICs also need periodic 'refresh' cycles if they are to retain their data. Luckily, the Z80 processor used on the Spectrum can provide suitable refresh cycles automatically. The SoftROM circuit has been designed to take advantage of this, resulting in the odd- looking order of connection of the Spectrum's address lines to the input pins of ICs 9 and 10.
The RAS and CAS strobe pulses are generated by parts of ICs 11, 12 and 13 from the Spectrum's WR, MREQ and RD outputs whenever a read or write operation is to be done to the SoftROM. Part of the IC11 also pulls the Spectrum's ROMCS line high to disable the Spectrum ROM when the mode switch is in the SoftROM position and a location in the low 16K of memory space is being read from.
IC14 ensures a 'clean' operation of the mode switch by only letting the circuit change from one operating mode to the other during the dead time between memory accesses.

USING IT
.

The switch should be in the 'normal' position when the Spectrum is turned on, so that everything powers up normally. The next step is then to load the SoftROM with something sensible. Those wanting to experiment with the Spectrum ROM routines will find the easiest thing to do is to copy the ROM contents directly into RAM, which can
be done with a Basic program such as:

10 FOR=0 TO 16383
20 POKE A, PEEK A
30 NEXT A

(sic) - Note1

This takes a minute or two to run, so you impatient types may now try writing an equivalent machine code routine to do the job in a fraction of a second.
Once the data has been copied, then it's just a matter of flicking the switch over to run from RAM. And you could also load data into the SoftROM from tape, with a command such as:

LOAD "SUPERROM" CODE

and the switch in the 'normal' mode - provided that you had previously saved the data on to tape with:

SAVE "SUPERROM" CODE 0,16384

Once in SoftROM mode, you can examine and change values with the Basic PEEK and POKE statements, or even use a machine code monitor program such as Picturesque's to set break- points, modify, and run parts of the code. But some thought is needed when you do this. The routines you modify may be the very ones that are used to enter data or display the results and with bad luck it's possible to 'crash' the system in some really spectacular ways! Although it's impossible to do any damage to your Spectrum, it is easy to get into a position where the only way to recover is by switching to 'normal' mode and re-setting the system.

YOU'LL NEED ...
.

IC1-816K x 1 5V dynamic RAM : (4816 or 8118) or 64K x 1 (4164), see text. (Any speed RAM chips will work.)
IC9,1074LS158
IC1174LS02
IC1274LS32
IC1374LS08
IC1474LS74
 
10 off 16-pin IC sockets
4 off 14-pin IC sockets

2 off 100R 1/4W 5% resistors
1 off 330R 1/4W 5% resistors
3 off 4k7 1/4W 5% resistors

1 off diode 1N4148

1 off push button switch, single pole normally open.

1 off toggle or slide switch, single pole double throw.

10 off small decoupling capacitors, 10nF to 100nF.

28+28-way 0.1 inch double-sided edge connector socket with polarising key in position 5.

Veroboard, wire, solder, etc.

Note1:
These dubious lines of code have been reproduced exactly as printed in the magazine; the correct form should be reasonably apparent. ( back )
Note2:
Also see letter in issue 4.

Home Contents KwikPik