📜 ⬆️ ⬇️

A fistful of relays. Part 2 - Register File

More than a year has passed since I started writing about developing a computer with electromagnetic relays . Today I finished work on the second module of the computer - the register file.



Now it has become clear that the computer will consist of 4 blocks: an ALU , a register file, a control block, a memory block and peripherals.

The block of registers is the easiest to organize - in each register there are 8 relays for storing bits, a relay for resetting and several relays for connecting the register to the bus.
')


But nevertheless I was the first to do the ALU in order to understand the construction of logic circuits on the relay. In addition, this immediately turned out to be an 8-bit calculator, which now sometimes includes colleagues (for quite some time now the computer has moved to my place of work).

How the relay saves data


Usually, the relay is not used for data storage, but only switches signals. But if you add feedback to his work, the result may be an RS trigger. So that once the relay does not turn off, but retains this on state, it is necessary to apply a voltage to the winding through its normally open contacts. When the contacts close, this voltage will keep the relay on:



Now to turn off this relay, it is necessary to break the connection between the power source and the winding. To do this, use an additional relay responsible for resetting the trigger:



Why bother dropping a relay at all? The fact is that the easiest way to write a given value there is to reset the old one and to apply (or not to apply) the voltage to save the new state.
Since the register is always reset entirely, the same reset relay is used for all its bits.

The contacts of all the switches in the data storage relay are paralleled. This is done to improve reliability - if one contact fails, the current will go through the other.

Computer architecture


Initially, I planned that the address bus at the computer would be 12-bit. So you can easily split the entire address space into several 8-bit groups and connect different devices to them. At the same time, address arithmetic will be simplified to 8-bit (almost like working with memory segments in 8086).

Therefore, there were 2 types of registers in the register file - 4 pieces of 8-bit GPR, 2 pieces of “segment” 4 bits each, and 2 pieces with 8-bit offsets. In this case, from the “segment” and “offsets” it was possible to form 2 full addresses, since the registers were added into fixed pairs, such as HL, DE, or BC in Z80. But at the same time, any of the registers could be used as an input or output for an ALU.

The changes began with the fact that I "suddenly" made the segment registers 8-bit. This did not fundamentally change the architecture (the address bus remained 12-bit), but it gave more possibilities for calculations.

Then I figured that even a simple summation of 256 memory cells would take several tens of minutes. So I decided to narrow the address bus to 8 bits. Because of this, the system of commands greatly simplified:
  1. There is no need for separate commands 12-bit increment, 12-bit transfer, 12-bit load values.
  2. The transition, subroutine and load 8-bit values ​​are combined into one with minor differences.
    As a side effect, the value load command got the option of conditional execution.
  3. Memory management teams have options with an immediate address value.


Thanks to all this, the control module circuit also became easier. The number of relays that will be required for it has greatly decreased. Including due to the fact that it is not necessary to separately implement an instruction counter (since it moved to the register module in the form of an almost ordinary register).

The result was something similar to the ARM processor's Thumb mode, but even simpler - 8 registers of 8 bits each. One register serves as a return address, and the other serves as an instruction counter. Any register can be used as any of the command arguments.
The only exception is that only 4 out of 8 registers can be used as an address for reading (or writing) from memory.

The buses to which the registers are connected, it turned out 3 pieces - 2 for transferring data (for example, an instruction code or operands to an ALU) and one for transmitting an address.

Design


The most difficult (or rather, tedious) was to make the plates with the names of registers. Last time I ordered a laser engraving. But the devices used for this purpose have a very small work area and this was not enough for my tablets. Therefore, I took up photolithography. I studied for a long time to glue / spray, exhibit and show a photoresist, until I got at least something acceptable. The ideal is still far away, but this is not the last block in the computer.



I did not embed toggle switches to load values ​​into registers in this block. After all, the register module can immediately be connected to the ALU and use its toggle switches.

Another feature of this module is that there are no additional LEDs for displaying signals. All stored data can be monitored using control LEDs built into the relay. Therefore, to remove the dump registers enough to have a camera.



Today I already have two blocks of the future computer - a register file and an ALU. But both of them are controlled by external signals and therefore can make calculations only in the calculator mode. The housing for the control module is almost ready, so soon it will be possible to start launching circuits that make ticking sounds on their own.

What could be done better


Due to the fact that I abandoned the paired registers, the need for a double data bus disappeared.
Now it is really needed only in one place - when retrieving instructions. The size of all instructions is 16 bits, so a 16-bit bus is needed to load the entire instruction code in one clock cycle. To connect the second argument to the ALU could use the address bus. Due to this, it would be possible to save 8 relays in a block of registers (and, perhaps, a couple more in the control unit).

I used bolts for a Phillips screwdriver to fasten the caption plates, since the old school version was over. Does anyone know where you can get brass bolts with straight slot? Last time I bought them in a hobby shop in Helsinki. But it is quite expensive, and again I will not get there in the near future.



Still need to somehow improve the negative mask printed on a laser printer. Now black-flooded fields turned out to be slightly transparent. Therefore, on some plates because of this, small points appeared. Maybe someone knows how to win it?

Bonus


The following video is a working prototype clock generator. I’ll probably increase the frequency a bit to get about 5 clocks per second.



Project page on github: github.com/Dovgalyuk/Relay

Source: https://habr.com/ru/post/258337/


All Articles