01/06/2019 at 15:56 •
For the simulator of #1 Square Inch TTL CPU, I used real graphics for the segments of the clock. Since the relay cpu can also control each segment of the display independently, I also added this feature to the simulator of the relay cpu ( Assembler and Simulator ). To use it, just press "Assemble" and then "RUN", and start making calculations on the calculator keyboard that is on the screen. Since the segments of the display are directly connected to the register bits, you will see the same wild patterns during calculation as you would on the real CPU. Trigonometric functions don't work yet, all others do. (After each button click, have some patience until the script halts and the number (hopefully) appears.) The calculator program does not give messages yet for overflow, or out-of-range input (including zero divide).
The off-by-one error in the return address of a subroutine (reported in a previous log) is now handled by a workaround: A NOP instruction should follow each CALL instruction.
Three small problems were found (but chasing them was a lot of work):
- The CL register can not be used in the DSUB DL,CL instruction (and similar instructions). But the assembler allowed it, causing the simulator to work correctly while the real cpu did give a wrong result. Solved by letting the assembler produce an error in this case.
- The AND instruction did not work with a zero-page operand. This had upper instruction byte pattern x010xxxx, and the cause was that all instructions with memory operand and this opcode pattern were decoded (on the clock & control pcb) as STORE instructions, so no read from memory was possible. It could simply be solved by changing the instruction pattern for zero-page-AND to x110xxxx, that was unused. No hardware modification was needed, because the decoder was not connected to the changed bit in the instruction (it was an unused, mirrorred code).
- The DL register can not be used as pointer in the ST [DL],CL instruction (and similar instructions). But the assembler allowed it, causing the simulator to work correctly while the real cpu did give a wrong result. The assembler should have given an error message in this case, but the STORE was handled differently because of the deviating operand sequence, and that part did not check the pointer. So the check was added there.
Main obstacle for finding these problems were that the design was done so long ago (between one and two years) that several details had slipped my mind and had to be reverse engineered from the schematics.
The relay calculator now sometimes gives a good calculation result for basic operations (digit entry, number display, addition, multiplication). More bug hunting is needed.
The "Architecture and Instruction list" in the file section was updated according to this log.
The online simulator-assembler was updated, but the source in the file section has not been updated yet.
11/08/2018 at 14:33 •
Since you are all Relay Computer builders or fans, you might be interested in the new extremely simple Relay ALU, that provides 10 functions with only 2 DPDT (or 3 SPDT) relays and a few diodes !
07/04/2018 at 20:47 •
The Risc Relay CPU is in the Homebuilt CPUs WebRing now !! Celebrate !!
In the last weeks I did build most remaining boards and did more testing. All registers are available now, and the second ALU board is ready, so the full 16 bit data handling is in place.
The new ALU and register cards were first tested with the test device, and the soldering problems that were found were corrected.
Then everything was put together. (Only the second Program Counter board, and the keyboard are still missing.) This was too much for my 2A benchtop power supply, it showed the LED's slightly dimming during operations. So I changed to a beefy 24V 10A supply.
This was tested:
- 32 bit decimal addition, working
- bit shift unit, working (after fix)
- load constant from code space, working (but not supported by assembler yet)
- subroutine call, problem !
All tests only worked after one or a few soldering issues were fixed. In the shift unit, one of the diodes (D609) was not connected on the schematic, so a short wire was needed. On the boards with 3 registers, 8 short wires were placed (this was planned), to enable register DH to receive input over the LINK bus (return address). The register pcb uses almost all 96 connector pins. Therefore, the link bus was connected to the output of register C (register C is not placed on these pcbs), and on the pcb there are wires from the register C outputs to the relay coils of register DH.
The subroutine call placed the return address in register DH, fine. But when, in the return instruction (LD PC,DH), the DH register is moved to the PC, the PC is incremented before the next instruction is fetched. That means that the instruction after the call is skipped ! A classic off-by-one error. I have not yet decided what to do about this, there are several possibilities.
05/21/2018 at 17:40 •
A few weeks ago, I connected a Raspberry Pi to the program flash memory of the computer. The Raspberry Pi runs the assembler-simulator in its webbrowser. The assembler-simulator has buttons for upload and download from/to the RPi. The RPi is connected with a 16-bit data connection to the Flash program memory, through a small pcb (containing resistors for level conversion). The PROG pcb, that contains the flash chips, also has two 74HC574 registers to store the address for writing the flash. The RPi has a small Phyton program that burns the generated binary in the two Flash memories of the relay CPU.
From that moment on, I could run real programs on the computer, although the cpu is only partially built: The data is only 8 bit wide (in stead of 16). Only 4 8-bit registers are present, and it does not run at full speed.
Then came several days of serious debugging. Several problems could be fixed by changing the instruction encoding or changing the simulator:
- In conditional branches, true and false were swapped
- After a branch or jump, the first instruction was skipped because the hardware first increments the PC and then fetches an instruction
- The 7-segment decoder had the two segment groups swapped. So the X register got the segment bits that were intended for the Y register and the other way around. So the single segment instruction was now split in two segment instructions, with the segment group specified in instruction bit 5 (this was an unused bit for zero page addressing). Small hardware change.
The architecture and instructions document was updated with the encoding changes.
Several instructions were working unreliable. All these problems were fixed by changing the hold resistor (2K on the schematics) to 1K5. One non-soldered diode was found.
Not all instructions are tested yet, but all tested instructions work now. I made a small demo program that calculates Fibonacci numbers.
This weekend, I gave the RISC Relay CPU its own website: RISC Relay CPU Website. Some things on the website might still be a bit quirky.
A video of the working computer is on the new website (including sound ;) !
05/05/2018 at 20:28 •
Annoying how slow the progress is if you can not spend enough time on your project....
Just a few days after the last update, I also connected the 8-bit ALU board and the 4x8 bit register board to the motherboard. This should make 8 of the 16 databits and half of the registers operational.
I could enter instructions manually with the buttons connected with a flatcable to the PROG pcb (described in previous log). And YES, I could execute several instructions successfully, like addition, saving to RAM, loading from RAM ! I did not test all instructions, but I do not remember an instruction go wrong (that may be selective memory, it's already a few months ago).
Anyway, testing branches can not be fully done in this way. The control system will not load the instruction that follows a branch, so that it executes as NOP. But it has no way to prevent me from entering instructions manually... So there is no escaping, it is time for a real program to be run from flash memory.
Then I switched from Chrome to FireFox, and suddenly the speed problem was gone... I don't know why. But I'm not interested in investigating it further. There are enough other things to do.
The SIMAS ( simulator-assembler ) had one of the first versions of the instruction set. So I updated it to the newest instruction set. It has two memory spaces now (program and data). To have initialized data, the assembler simply copies the first few hundred bytes of program space to the data space. This is something that a real program will have to do itself.
The layout of the program was also changed. The left side of the screen now has a textfield for entering your program. The center has a bigger textfield, that shows the source code together with the assembled machine code. And the nicest feature... in the center window, all program lines that were executed get a blue background, and the current line after the program halted is red. So the blue background shows you the execution path that the software has taken after the last keypress of the calculator.
The buttons that simulate the calculator were re-ordered, to be similar to the pcb that I designed for the keyboard a few months ago.
Finally, I worked on the calculator application. It will now do all functions, except the trigonometry functions. The latest code is now automatically loaded when you load the webpage. You can try it at www.enscope.nl/rrca Before operating the calculator, first press "Assemble" and then "Run".
I updated the HAD file section. The architecture and instruction listing are now in a single document. The schematics are updated and are according to the pcb's. Gerbers of the pcb's are also provided.
12/30/2017 at 19:16 •
Around two weeks ago I ordered all remaining pcb's and a lot of parts. They arrived just in time for some happy soldering in the days after Christmas. Each pcb was (sometimes partially) built and then it's main functions were tested, revealing soldering errors but also a few design errors. This is the state today (click it for bigger version):
1) clock and control pcb
2) program counter pcb (6 bits)
3) instruction decoder pcb (only it's LED's are visible)
4) program memory and instruction register pcb
5) RUN button
6) STOP button
The pcb's are connected to the main pcb with DIN41612 connectors.
I started with the program memory and instruction decoder. (All pcb's in this project were intended to have a white color, but apparently I forgot to select the color when I uploaded the gerbers of this pcb). The flash memory itself is not yet assembled. There is a connector (where the ribbon cable connects) that is intended to connect to a flash memory programmer. It is now connected to 16 pushbuttons, to control the contents of the instruction register manually. The instruction register worked (but several of the 2K2 resistors in the hold circuits had to be lowered in value, apparently the current was not enough to keep the relays attracted).
Next was the clock and control pcb. The clock circuit did not work as expected and had to be modified. Two 100uF elco's (visible on top of the pcb) set the clock to approx. 5 instructions per second, slow enough to have a sense of what is going on during testing. Asymmetry in the clock signal will have to be solved (and higher speed will be set at a later time). One of the board's input signals was not connected, a wire was needed to correct this. Another problem: The single-step button should start executing one instruction and then stop. Unfortunately, the stop function works too well, so much that pressing the single step a second time does not run a next instruction...
The program counter pcb also has decoders for reading and writing to the registers. Only the program counter section was mounted for now. After re-soldering a resistor, I started the clock and watched the PC counting... 0, 1, 2, 4, 8, 16 .... Oh what's wrong ? Did I build a shift register instead of a counter ? After following the signals on several wires, it occurred to me. The PC has a master and a slave section, they each have a CLR signal. If one of the registers is not cleared, the bits stay 1 and you get this behaviour. This is not visible on the LED's if the leds are connected to the slave section and the non-cleared part is the master section. Well, the CLR of the master could be interrupted by relay RL341, and that was not placed because it was considered part of the decoder section. After placing RL341, it was happy counting !
Now the instruction decoder. It has led's that show the addressing mode ( Memory, Zero page, Immediate, register, test-and-branch) and the instruction ( LD, ADD, AND, OR, XOR ) and a few other output signals. This was simply tested by letting the clock run and manually put something in the instruction register. Many instructions could be tested this way. It revealed an error in the decoding for the DMPY instruction, were inputs to a diode gate had to be connected to IR_Y0 instead of IR_Y0_N. This diode gate was on the pcb with the instruction register, leading to a small modification there. For a LD instruction, also the OR led was on, could be corrected with an extra diode. The led for the PC was connected to a wrong point, not changed yet.
Some changes were made in the schematics and pcb design files before they were ordered, so the file section is no longer uptodate. One of the changes was another change in the instruction set... New instructions to subtract two registers without storing the result, providing compare instructions. Logic instructions (and, or, xor) were removed from the register mode and added to the zero-page mode. Documentation will be updated soon.
A good 2018 to all of you !
10/14/2017 at 16:55 •
All schematics and pcb designs are finished now. But I will do several checks before I send the PCB's out for production. (I already found some mistakes, can you find them too ?)
Today I uploaded in the file section:
- The schematics of all pcb's
- A block diagram that clearly shows the main functions of the pcb's
- An accurate description of pcb interface signals
- Updated instruction list and architecture description
This info should be enough to understand the design.
I also posted the number of main components (327 relays). On the MEM pcb, I used BAW56 double-diodes because 1N4148 would cost me too much pcb area.
06/10/2017 at 20:43 •
Time to check the maximum reachable speed !
The CPU needs 4 clock signals:
- Phase 1 CLR
- Phase 1 Activate
- Phase 3 CLR
- Phase 3 Activate
There are also phase 2 and phase 4, but they have no clock signal, these phases are the relay 'layers' that follow the state of the relays that are switched by state 1 and 3.
As the name implies, a CLR pulse clears a relay, and an Activate pulse can set a relay (if its input signal is true). But the CLR only disables the hold circuit of the relay. At the same time, the activate signal can be busy setting the relay, and even the circuits that follow the relay can already start switching while the CLR is still active ! So the clearing of a relay does not take time because it takes place at the same time as the activation (see technology file in the file section). The phase 1 CLR pulse falls within the phase 1 Activate pulse (so CLR can only be active if Activate is also active). And also, the phase 3 CLR pulse falls within phase 3 Activate.
I did built a clock generator that has 4 relays (one for each clock signal), driven by a few transistors, and the transistors driven by a function generator. I attached the new clock to my test-setup (that has an ALU and a Register pcb). Phase 3 loads the ALU latch A with the data from register D, and phase 1 loads register D with the ALU output.
On the test pcb, setting function to ADD and loading 1 in ALU latch B. This lets the ALU increment at each clock pulse.
Well thats nice... what they call blinkenlights.... see the bytes incrementing at 3 places: at the ALU output, in register D, and at ALU input A.
Yes and that sound.... Ohhhh...
Cranking the frequency up, until errors begin to occur.... then a little bit down again where everything seems ok.... 136 Hz !!
Power consumption around 600mA at 24 Volt. It's not really optimized for watts per megahertz....
The other circuits in the CPU ( like instruction decoder, and PC incrementer ) will operate concurrently, and have the same technology as the ALU and registers (so they will reach the same speed). Most instructions use a single cycle, so the CPU could reach a speed of 136 instructions per second ! Probably will have to run it slightly slower for good reliability.
The used relays have 2 mSec operating time. Relays with 1 mSec exist ( like IM06N ) but I found these too expensive. These could double the speed....
05/13/2017 at 15:30 •
Still working on the schematics. A lot of little details must be handled:
- splitting clock signals, in order not to overstress relay contacts
- program counter is 12 bits, add 4 bits and a selector knob to switch between several programs in two 64K x 8 flash chips
- how to get the program in flash... provide connector for dedicated AVR-based programmer with RS232/USB connection to PC
- The dedicated programmer should have buttons for manually composing an instruction and execute it
- The clock signals must be made. Clock must be started and stopped.
- User input buttons must be handled
- The remaining pcb's (except main pcb) will be made smaller than the first ones, now I discovered that 10 x 10 cm boards are a lot cheaper than bigger ones (at certain pcb makers).
- How to distribute the remaining circuits over several pcb's, and how to allocate signals on the 96 pin connectors
The last point has great influence on the routing of the main board. So, the main board is routed first. The connector allocation can still be changed if needed (except for the existing register and ALU pcbs). Here is the current status:
There are two rows of 6 connectors. At the front, there are 12 displays. The yellow signals must still be routed. But there will be more to do, since the schematics are not complete yet. This will keep me busy for a while...
The ALU has now all 8 bits built, and is working after solving a few soldering issues.
04/16/2017 at 19:13 •
The first two PCB's have arrived ! This is the pcb for the registers:
The pcb implements four 8-bit registers (registers C, D, X, Y). Only 8 bits (4 bits in 2 registers) are mounted. At the topside of the PCB, you see that each register has its own 8 LED's to indicate the contents. The pcb is labeled "REG1710" (top left) meaning the design is from 2017 week 10.
The other PCB is the 8-bit ALU "ALU1710":
Only 4 bits of the 8-bit ALU are mounted. The 4x4 relay section is the basic ALU, that includes two input registers (latches, to be honest). The sections with 2 relays are for the ADD-6 section and decimal correction. On the top of the pcb you see LEDs for input data, output data, function selection and flags. The ALU has the normal Load, AND, OR, XOR, binary ADD, but can also ADD decimally and convert BCD data to 7-segment display code. Subtraction needs help from outside of the ALU. It is done by inverting one of the register outputs (and setting the CY-input).
The placement system is all diodes and relays on top, and the resistors on the bottom. Relays are surface mount types, this gives more space for routing at the bottom. Diodes are through-hole 1N4148. I did not use BAV99 or other SOT23 types (otherwise I could be accused of using transistors secretly ;). Mini-Melf were also avoided since they tend to roll away when you try to solder them. Some signal wires drive many circuits, in that case the diode is 1N4004 or similar.
Of course, something was wrong. The connector DIN41612 was not close enough to the edge of the pcb (placement was based on the silkscreen of the footprint, I interpreted one of the silkscreen lines as the edge of the pcb, but that was wrong). I had to remove about 1mm of the pcb to make it fit. This destroyed only a few traces, that must be replaced by a wire.
Schematics and gerbers of REG1710 and ALU1710 are in the Hackaday files section.
I did built a simple test device. The ALU and REG pcb's can be connected to it. The 3x4 buttons transfer data from a register to the input A of the ALU and from the ALU to a register. The 8 buttons on top control data on input B (next to it are a CLR input B button and a CY-input button). The big knob selects one of the ALU functions, the function is displayed by one of the green LEDs.
For the curious readers, here is the bottom side of the test device:
And of couse, I tested my new pcb's. Found a small problem:
It was intended that all diodes point in the same direction. But a few diodes on the ALU picked an older diode footprint, that had the silkscreen in the other direction. The result was a few diodes had to be reversed.
After that was done, all assembled functions were working ! (But the tester does not test the second output ports of the registers).
Some new instructions were added to the instruction set:
- An instruction to load data from the program memory. The simulator has a unified memory, so the instruction was not needed there.
- Added XOR with immediate value
- Added a powerful instruction: Test a bit and branch. Within a single instruction, a single bit from a register pair can be tested, and a branch forward is done if the bit is 1 (or 0). In each register pair, the bits that can be tested are 0, 1, 2, 3, 4, 7, 15, 31. So this also replaces the clumsy sequence that was needed to test the upper bit of a value in a register. Instead of adding to the PC, this instruction can also conditionally add to register C. The branch forward has a reach of 31. In the instruction space, some space in the register-mode was sacrificed to make the test-and-branch possible.
Work will continue with the details of the control functions, and planning the "backplane".