Posts

Showing posts from November, 2013

ALU Design: Condition Registers

Image
This post covers the design of the ALU Condition Registers which along with the 3-to-8 Function Decoder and Zero Detect circuit (both covered in my previous posts) make up the ALU Control Card. There are three Condition Registers in this computer:
Carry: set when a bit is carried in the Arithmetic Unit (which can also indicate arithmetic overflow depending on the interpretation of the numbers being added).Zero: set when the ALU result is zero (all bits are off).Sign: set when the most significant bit is set (which would indicate a negative result for signed values). This condition has no direct meaning for unsigned numbers (other than indicating the number has a value of 128 or more). When the ALU performs an operation the current values of these three conditions are stored in the condition registers so that they can be referred to in other operations. An example of this would be where given two numbers the first is negated and then added to the second ... if the two numbers are equal…

ALU Design: Zero Detect

Image
This post covers the design of the Zero Detect circuit which along with the 3-to-8 Function Decoder (covered in my last post) and the Condition Registers (next post) make up the ALU Control Card. The Zero Detect circuit ... wait for it ... detects when a value is zero. The value in question is taken from the data bus so in effect we're detecting when no bits are set. The output from this circuit is then passed to the Condition Registers so that the current value can be stored for future operations. The circuit itself is nice and simple:
If all inputs are off then the output Z is on otherwise, if any input is on, then Z is off. This design is taken from the Harry Porter Relay Computer as usual but this is one of the rarer cases where my translating the design to use DPDT relays doesn't increase the physical relay count:
To save space and wire links this design places the relays in alternating orientations so that the switches line up as required and all the inter-relay connect…

ALU Design: Function Decoder

Image
This post covers the design of a 3-to-8 Function Decoder which along with the Zero Detect circuit and Condition Registers will all go in to the ALU Control Card. The Decoder takes a 3-bit ALU Function code as its input and activates 1 of 8 control lines accordingly. The function codes are as follows:
000 CLR (Clear/No Operation)001 ADD (B+C)010 INC (Increment B)011 AND (B AND C)100 OR  (B OR C)101 XOR (B XOR C)110 NOT (NOT C)111 SHL (Shift Left B) The control lines which are fed to the Arithmetic and Logic Units via the Ctrl-Z bus are:
ADD : ALU Add Output EnableINC : ALU Increment Output EnableAND : ALU AND Output EnableORR : ALU OR Output EnableXOR : ALU XOR Output EnableNOT : ALU NOT Output EnableSHL : ALU Shift Left Output Enable Note that there's only 7 lines here as the control line for CLR produced by the 3-to-8 decoder is left unconnected — this is because if no other control lines are active the ALU will be effectively disconnected from the data bus therefore if the 'r…

ALU Design: 8-bit Arithmetic Unit

Image
In the last post I introduced the design for the 1-bit Arithmetic Unit. This post covers connecting eight of these units together to make an 8-bit Arithmetic Unit along with result gating and increment functionality.
So, diving straight in, here is what eight of the 1-bit Arithmetic Units look like all together on the usual 55 x 40 hole pad board (excluding wire lines):
As before (with the Logic Unit card) things are a bit on the tight side but everything fits within the 40 hole horizontal confines of the pad board (as if by magic). Each of the 1-bit Arithmetic Units produces a 1-bit output and these need gating back on to the data bus so that the result doesn't conflict with any other Logic Unit output (or any future outputs from places like the Registers etc). With these additional relays added we get the following (this time including internal wire links in the 1-bit Arithmetic Units and result links between the Arithmetic Units and the gating relays):
This would now be enough…

ALU Design: 1-bit Arithmetic Unit

Image
This post covers the design of a 1-bit Arithmetic Unit that can add two input bits together (B and C) with carry in and out. Here's a schematic of the 1-bit Arithmetic Unit (based directly on the one used in the Harry Porter Relay Computer):
The diagram shows two 4PDT relays (just as before for the 1-bit Logic Unit) but this time the second relay has been rotated 180 degrees to make the diagram simpler to draw. B and C are the two 1-bit inputs that drive the relay coils, V is a permanent connection to the power supply and R is the resulting bit. CI is the carry in signal along with its inverted partner ~CI. Similarly CO is the carry output and ~CO is its inverted partner. It's the use of these regular and inverted carry signals that makes this design so neat ... and actually this isn't one of Harry's ... this design goes back a lot further.

This full adder circuit was actually invented by Konrad Zuse for his Z3 computer. The Z3 was also built out of relays just like t…

ALU Design: 8-bit Logic Unit

Image
In the last post I introduced the design for a 1-bit Logic Unit. This post covers the design effort to cram 8 of these on to a single pad board complete with connectors, status LEDs and gating relays thereby forming a complete 8-bit Logic Unit.

Sticking with the same diagram style I introduced in the last post here is what 8 of the 1-bit Logic Units look like all crammed on to the 55 x 40 hole pad board (excluding wire links):
Things are a bit tight but as I often find when using these pad boards things magically seem to fit after trying a couple of permutations ... it's almost like the pad boards were designed with this sort of thing in mind ;)

Each of the 1-bit Logic Unit produces five results simultaneously (AND, OR, XOR, NOT and SHL) but only one of these can be selected/gated back on to the data bus at a time and so gating relays are needed. Each result requires 4 relays for a total of 8 switches to gate the 8 bits of the result. With these additional relays added we get the…

ALU Design: 1-bit Logic Unit

Image
This post covers the design of a 1-bit Logic Unit that can produce AND, OR, XOR, NOT and SHL (Shift Left) outputs from two input bits B and C. Here's a schematic of the 1-bit Logic Unit (based directly on the one used in the Harry Porter Relay Computer):
The diagram shows two 4PDT (4 pole double toggle) relays with the coils of each shown as a striped box at the top. The four double toggle switches are also shown on each relay and the current position of each switch is as when the relay is off. When power is applied to the relay coil all four switches change over simultaneously. The two relays together with all the various connections form the 1-bit Logic Unit. Inputs to the unit are shown with 'cupped' line ends: B and C are the two 1-bit inputs; V is a permanent connection to the power supply. Outputs from the unit are shown with an arrowed line end: the outputs AND, OR, XOR, NOT and SHL. Wire joins are shown with a dot (otherwise the wire is passing over but not connec…

Relay Rumination

Image
If there's one thing a relay computer needs a lot of it's ... erm ... relays (of course) ... which happens to be a bit unfortunate as relays, compared to the other parts of the computer, are rather expensive. The Dr Harry Porter Relay Computer (which my computer is based on) uses 415 x 4PDT (4 pole double toggle) relays in total. A comparable part is the Omron MY4-DC12(S) relay and a quick check online with Mouser (other suppliers are available ;) prices them around £3.20 a piece (excluding UK VAT @ 20%) ... that's just under £1600 including VAT which is a bit eye watering for a hobby project (the Harry Porter computer came to just over $5000 in total for everything). Also of note is that the MY4 relays are sized 28 x 21.5 x 36mm ... not huge but big enough when you've got 415 of them wired together (again, see the Harry Porter computer to see exactly how big these machines can be). Here's a scaled diagram of the MY4 relay showing the coil and four sets of double t…

Instruction Set

In the last post I promised to reveal the planned instruction set for the computer so here it is (pdf file shared via Google Docs).

This should be viewed alongside the architecture diagram which can be found in my previous architecture posts ... and to be fair if you've been following along through my recent posts then just close your eyes ... you'll probably find it's been burnt on to your eye balls given the amount of times I've posted it ;)
I'll avoid going into depth on the instruction set for now but suffice to say it's based on the instruction set used by the Dr Harry Porter Relay Computer so it all works with the architecture it was designed for (the same architecture I'm building against).
So, it's now time to move on from the architecture and theory side of things (which is all looking sound) and start thinking about how to actually construct the computer. For now though I've got a nice long weekend away :)

Architectural breakdown: Programming and Control 2

Image
So, the last post didn't quite wrap up this 'mini-series' but hopefully this one will. Continuing on with how the Programming and Control of the computer happens here again, for the last time (really last time), is the architecture I'll be building against (from the Harry Porter Relay Computer):
In the last post I covered an example of the steps required to subtract 6 from 10 (with 6 placed in register B and 10 in register C beforehand) and also that each step is represented by an opcode which is placed in the Instruction register so the computer can work out the sequence of actions to take to perform the step. The collection of program steps are stored in the memory along with any data required and so a full program to subtract 6 from 10 would look as follows in memory:

0001  11000000    Set M-Register to 0x0016
0002  00000000
0003  00010110  
0004  10010010    Load Register C from Memory (Address in M)
0005  11000000    Set M-Register to 0x0017
0006  00000000
0007  00010111…

Architectural breakdown: Programming and Control

Image
In this post I'll wrap up this 'mini-series' of trying to explain away the various bits of the architecture that will make up my relay computer project — finally now we come on to Programming and Control of the computer. Here again, for the last time, is the architecture I'll be building against (from the Harry Porter Relay Computer):
With all the various parts of the architecture I've discussed so far — the busses, registers, memory and ALU — we have a computer that could be manually operated, albeit laboriously, to perform various tasks. Actually, in fact, this will be the first milestone in the construction of my computer ... that I can manually operate what I have built so far just as the computer will itself when it is able to execute programs. Just to give you a feel for exactly how labour intensive even a simple task would be here are the manual steps to subtract 6 from 10:
Enter the value 10 (in binary as 00001010) on to the data bus (there will be physical …

Architectural breakdown: the ALU

Image
In this post I'll continue to try and explain away the various bits of the architecture that will make up my relay computer project — this time it's the Arithmetic Logic Unit (ALU). Here (yet again) is the architecture I'll be building against (from the Harry Porter Relay Computer):
The Arithmetic Logic Unit (ALU) sits at the very heart of the computer and without it you wouldn't be able to do much at all ... you could certainly move data back and forth between the memory and registers but that'd be about it. As you might have guessed from the name it allows the computer to perform arithmetic and logic functions. Some ALUs have a myriad of functionality available but this architecture takes a good balance between simplicity and functionality — the idea being that you can perform more complex functions by using a combination of simpler ones (subtraction can be performed by negating a number then adding it and multiplication can be performed by repeated adding). This…

Architectural breakdown: Memory

Image
In this post I'll continue to try and explain away the various bits of the architecture that will make up my relay computer project — this time it's the memory. Here again is the architecture I'll be building against (from the Harry Porter Relay Computer):
In my last post I wrote about the computer registers, each of which can store a binary value — they're typically very fast although there's a fixed number of them (in this computer there's eight 'general registers' A, B, C, D, M1, M2, X and Y). Needless to say we wouldn't be able to do anything too exciting if we're limited to only 8 storage slots and that's where the memory comes in — it's not as fast (relatively) as the registers but it can hold many, many more values.

You can think of memory as a set of pigeon holes with a finite number of slots/holes that can each hold one value at a time. Each hole has a unique label on it so that we can refer back to it and find a value we placed…

Architectural breakdown: Buses and Registers

Image
In this post I'll continue to try and explain away the various bits of the architecture that will make up my relay computer project — this time it's buses and registers. Here again is the architecture I'll be building against (from the Harry Porter Relay Computer):
Buses are simply a set of wires that connect up the various parts of a computer. As each wire can carry 1 bit it therefore takes 8 wires to carry 8 bits. In this architecture the data bus is 8 bits wide and the address bus (which I'll go in to further in the next post on the memory) is 16 bits wide. You can only have a single value on a bus at the same time so any part of the computer that needs to talk to another part has to wait its turn for the bus to become free. It's worth noting though that because the data and address bus are physically separate you can have different values on each without problem. In the diagram above the data bus is shown as a thick line on the left and the address bus is the t…

Architectural breakdown: Binary

... and it all begins with binary. Binary is a 'base 2' numbering system which means it uses the numbers 0 and 1. In contrast humans tend to use decimal (base 10) for their day-to-day numerical needs which, of course, uses the numbers 0 to 9. Binary is particularly suitable for electronics as the numbers 0 and 1 can be represented by a circuit being on (1) or off (0), or more relevantly to this computer, a wire may be carrying power (1) or not (0). If you wanted to be able to carry a single decimal digit (0-9) on a wire you'd need to pull some fancy tricks - perhaps have a different level of power signifying the different digits or send pulses counting up the number. All this gets very complicated though - binary keeps it nice and simple.

So, given a single wire we can represent the numbers 0 and 1 - which isn't much use if you want a computer to hold, say, the number 107. So how do we store larger numbers? Well, we do it much the same way we do in our base 10 decimal …