Game of Life & Mandelbrot

We’ve managed to do some more work on the display and I’m really happy to say we’ve got two bits of code running on it, the game of life and the Mandelbrot generator.

We do have a problem with the display, currently sending data faster than 500KHz causes random junk to appear, we also get corrupt memory, we think some of this is due to the long ribbon cable (~500mm in length) so we need to do more investigation on this. So we’ve been using the speed switching capability of the CPU so that the calculations can be done at 2MIPS and then switch to the slower 500KIPS for writing to the display. The calculations are being done at 2MIPS to decrease the corruption in RAM, at 4MIPS with the display attached a lot of corruption happens, even at 2MIPS you can still see some.

I’ve also built a second set of main boards and tested them, so we should soon be able to have two of these CPUs, one at my house and one at Jons. We need to rework the bus board, the clock and the code memory boards which shouldn’t take long, but work is starting on planning the peripherals now.

Advertisement

It’s been a while, an update

Things have been a little hectic for both Jon and myself lately, we both work for Space Forge and as you may be aware we had our first Launch with Virgin Orbit from Cornwall earlier in January and sadly it didn’t go well.

But, we’re back doing various bits and bobs. Jon has made a programmer and tester for his TL311 compatible “chips”.

You can see one of his TIL311 replacements in the ZIF socket. As you may be aware TIL311s aren’t easily available, they’re also red in colour, Jon wants his to be the same orange as the LEDs on our PCBs, so that’s what he’s done. They work really well and look great. He may chose to open source them and perhaps even make a few to sell. The challenge though is the resin casting, I’m not sure how we’ll accomplish that, if at all.

I’ve also been working on the display as you can see from previous posts, and I’m happy to report that after a bit of debugging we managed to get a picture up.

And yes, it’s our fox, but it’s a bit of a mess, this we traced down to a dodgy “amazon” socket, when Jon puts his finger on the board we get the correct colours. Lesson learned, cheap on amazon means it’s not going to be 100%. The timing isn’t quite right so we are getting some artefacts which we’ll look at and hopefully resolved. But for now I need to make another PCB with decent quality connectors!

So, we’re going to finish doing all the mods to the various boards and then we’re going to figure out what peripherals we want on the peripheral section, we know we want a joystick interface, a sound card and also a true random number generator, I’m sure there will be more bits (possibly UART?) but more on that at a later date.

Display & 2nd board builds

The display board arrived and I built it up, and I’m really happy to say that the picture is now rock solid and stable, no ghosting or jittering, I knew that breadboard was the cause 🙂

Here are some pictures, starting with a colour palette showing all 256 colours, and then how it looks with the filter on.

I have to say the filter just makes this display look utterly stunning. The next steps are for me to finish the display board and then hook it up to the hardware and run some tests on it, exciting!

Currently only one PJ5 CPU exists and it’s at Jons house, so I’ve begun assembling my set of boards (register board, special register, program counter, instruction decode and divider currently) and as I build them I’ll be testing them with the system at Jons and then begin assembling my own PJ5.
It’s going to live on my kitchen wall as a kind of art installation, and once completed I’ll post some pictures.

Delays and progress

We’ve not been quite so busy of late, Work for me has been busy and also for Jon, so we’ve kind of slipped a bit. The chip shortage also isn’t helping as we need to remake a couple of boards to remove mod wires but until we can get parts again, it’s sort of difficult.

In the meantime I have been working on the 64×64 256 colour display and have managed to get it displaying something from it’s RAM. Yes it’s our fox 🙂

It’s not quite correct as the length of the wires and also the breadboard are causing problems, so I need to make a PCB that will interface directly with the display, but I’m happy to see the fox there 🙂

Jon has also made some major improvements to the emulator, including a significant boost in speed and some extra debug features. I made a little video here.

So we haven’t abonded the project we are still working on it but all be it slightly slower due to a lot of other things going on in our day to day lives.

Clock PCB and Hellorld!

I finished modifying the Clock board and we finally had a chance to test it. It all works aside from one feature.
The counters we use for the program counter are synchronous, and so is the reset, so when you press preset you need to send a clock pulse to get them to go to zero. Currently that’s not happening.

We also implemented a Hellorld (knight rider edition) in homage the excellent work that Usagi electric is doing on his channel with his centurion mini computer.

Here’s a video, enjoy 🙂

The emulator is now running at around 640Khz in real time, which will make debugging and testing code a little easier.

Next steps, fix the clock on reset bug, then remove the mod wires on various boards with redesigns and then work on the 64 x 64 RGB display.

Clock Board

The new clock board arrived and, well, I made a few mistakes. But over all it functions as expected. So lets run through it

The big difference you’ll notice is that we’ve gone for a simpler select of speed. Rather than having a low/hi switch and 16 sub divisions, we’ve picked 10 speeds, ranging from 0.3Hz up to 4MHz. Now we have two speeds and you can select between them by pushing the speed button (the speed changes once the result has been stored, so there’s no risk of corruption). We’ve also added CPU control of the speed, the original idea was to be able to drop to a lower speed when writing to certain peripherals and then switch back to a high speed for the maincalculations.

We’ve also implemented the “Boot Pause” function, as our SRAM based program memory takes a second or so to copy from flash to RAM the main clock has to be paused whilst this is happening, so a line comes in from the program memory board which does this.

The “suspend” instruction now drops the clock from RUN mode to pause mode, from where you can single step. This should help with debugging code, particularly where you only get a problem after a long portion of code or number of loop iterrations.

We also improved the debouncing of the switches using a simple transistor monostable circuit.

There are a few mod wires on this board as you can see, but the board now functions as we wanted. The next step will be to hook it up to the hardware and try it 🙂

Part supplies and Game of life

Well, things were going so well, but sadly the part shortages have caught up with us.

Let’s explain where we are, we now have a fully functioning PJ5 CPU, however starting it requires a bit of jiggery pokery as you have to let the Fast Rom boot first before you can excute code, this is do-able on the existing one, but far from practical.
We also added the ability for the CPU to switch CPU clock speed, in case we have slow peripherals and we also added a suspend command, which puts the CPU into pause mode, handy for debugging.

So we designed a new Clock board with all these wizzy new features;

New improved clock board

Now we’ve hit a supply problem, I’m struggling to find some of the gates we use (1G57, 1G58 and 1G74), all of which seem to be out of stock and on lead times that reach to November, so at this stage I’m unsure what to do next. I might be able to salvage some of these from old boards, but is there enough? Do we redesign the board using quad logic gates?

Whilst I’m well aware of the part shortages in the world, I wasn’t expecting it in such low level logic parts.

I’ve taken a picture of PJ5 as it stands from above and then annotated it for everyone who’s interested.

Annotated PJ5

The plan is to redo the bus board and move the Bus displays back on it, then move the instruction decode, program counters, etc up giving us a nice even form factor again.

In other news I have managed to complete game of life in assenbly on the PJ5 emulator which I’m really pleased about, here are some pictures;
Green = new life
Red = cell died
White = Cell remained

Starting image
1st generation
2nd generation
3rd Generation

We’ll post updates when we find a solution to the chip shortages which are preventing us from making the clock boards, stay tuned!

Fast Rom Board, Programmer and Emulator

My apologies for the late posting, it’s been a busy few months. But we have been busy.

First up we got the Fast ROM board and programmer working, which is wonderful.
A quick demo is here in the video

Fast Rom board and programmer

The board works by having a piece of flash which holds the code when powered off, there are then 3 fast 8bit SRAMs which are filled when you power up.
We can store 10 programs (0 to 9) in the flash.

Now Jon decided that the programmer we needed should also be a TTL based CPU. So we have a USB to parallel chip from FTDI and from there Jons code allows us to upload to the flash and read from the flash.

The other really nice thing is that it seems to run faster than the FPGA based ROM we were using before, it’s also a lot more convenient to write code, assemble it, then upload it (rather than having to wrap it in VHDL and build the FPGA files and program it).

We’ve also been busy with the emulator!

Jon has done a superb job of reworking it and added a whole bunch of features.

PJ5 Emulator

Firstly we can now see the disassembled code, with labels.
We’ve also got a “t minus” count, which shows how many steps ago that instruction was ran (goes to 4095).
We can see the RAM contents
We have break points, shown with “BP” and highlighted in red.
And the green line shows the next instruction to be run.
We can see when a jump has been taken or not
We can of course single step, BUT we can also undo and redo steps, so we can go back and forward in time which is great.

All of these make the emulator really great for debugging complex programs (i’ve been battling with game of life).

Next up is the Clock PCB rework to include the interaction needed to work with the new fast ROM board.

Mandelbrot and Fast ROM

One of the two things we wanted to do with our PJ5 CPU is generate a Mandelbrot set, now keep in mind we don’t have a C compiler yet and this is an 8bit CPU.

So I speant a long time (many many evenings and weekends) trying to get the Mandebrot to generate on our emulator. I mean, a lot of time.

Image
Errr, not right

Some of the bugs where in the emulator and some in the code (oh the joy of debugging two bits of code that depend on the other!).
However, in the end I got it working!!

YAY! successful on on the emulator

So next up was getting it to run on the actual hardware, and after finding a small bug with the hardware (the busboard was missing a link as it was designed for the older Special register board) and it lived! and what a surprise, it’s blindingly fast, under 3 seconds at 2MIPS!!! I expected it to take like 10 minutes!
Neither of us was ready for that.

Youtube video

Now this was done in assembler rather than C or basic, and we’re not using floating point. But we are using 16bit signed math, without any lookup tables and this is still an 8bit processor built from discrete logic chips.

Why so fast compared to a 6502/Z80 ? several reasons really, firstly we have 16 registers, (though a large portion of thevariables where stored in RAM as we just didn’t have enough), secondly we run one instruction per clock cycle (for a 6502 there is at least 2 clock cycles per instruction) and thirdly we have a hardware 8×8 multiplier. I suspect the latter is the primary reason for the speed.

Fast ROM board

In the video we also show Fast ROM board, this uses a peice of flash and when the PJ5 is reset it copies the flash to RAM and then allows the CPU to run. Now it’s not quite working yet, but it’s a revision one board so that’s to be expected. So we’ll debug it, add mod wires and then spin a new version.

This is a really important board for us as it will remove the FPGA we’re currently using for the ROM.

Next steps

We’re busy working on the fast ROM board, we’re also going to respin the clock board, with a bigger knob and to include the extra functionality (pause until fast ROM is ready and speed switch).

We’re also looking at a better display, again using logic, but something with more consistant colour and brightness matching.

Then there’s things like audio, joystick, serial and so on to add in. So we have a way to go yet, but I’m super pleased with where we have gotten to in 18 months.

We did it, we got to 4MIPS!

Well, we did it… we cracked 4MIPS on our TTL CPU.

I have to admit I’m both relieved and surprised. The key parts to achieving this was to decrease the latency for the instruction decode and also the flag register writing. The time to decode an instruction, perform a bit of math and then write to the flags was at around 270nS.
With the changes we made, the instruction decode had a radical reworking and the flag writing had some big changes as well, means we go this down to under 200nS.
Which means we are able to run the CPU Core at 4MIPS!
Which we’re both super pleased with.

However (you knew there was a “but” coming didn’t you?) the external display (text and RGB dot matrix) does sometimes “glitch” at 4MIPS, but at 2MIPs is rock solid.
It’s a good thing we added that “speed” switch flag which will let us swap between speeds.
Whilst the boards themselves needed no modifications, we did make a couple of mistakes and had to swap some OR gates for AND gates, thankfully the same pin outs, so we’re happy.

PJ5 CPU running at 4MIPS

The new instruction board includes a few new commands, things like storeimm which stores an immediate value to a location in memory (rather than a regular store which stores the value of a register to memory) and also more branch options, things like branch if greater, branch if less than and so on.
I’m not sure if this is moving us out of RISC into CISC territory, but we’re happy we have a good set of instructions and everything is one clock cycle.

So the next bits we need to work on are;
The New fast ROM board and it’s programmer (which has been ordered)
A new Clock Board, one with a clearer speed selection and also two speed settings.
A new back plane, basically we want to move the register read and write bus displays on the main bus board, we also want the instruction decode to be in hex rather than binary.

After that, we need to look at the display and make it brighter, possibly see if we can improve it’s speed.

Then we need to build some more code (other than our test code).
I’m working on a Mandelbrot generator, which is proving a challenge in 8 bit assembly. And I know Jon is keen to put Tetris on here.
The latter means we need joystick inputs and also sound, so there’s a couple more pieces of the puzzle to be created.

it’s take us nearly 18 months to get here, and it’s been an adventure with lots of ups and downs, but it’s so wonderful to see it finally working at a speed we never imagined and with zero mod wires.