RL4000: 4-Bit CPU trainer
Rayman
Posts: 14,589
in Propeller 1
Here's a Prop project that I've been working on...
I finally got to the point where all the LEDs are working.
Still have buttons and LCD to wire up...
For some reason (still to be determined), I decide to create a 4-bit CPU trainer.
The idea is that this could be used to teach people how CPU's work...
This is about the simplest CPU possible that can do anything fun.
This is actually going to be an RL4000 emulator, but it can also be constructed in real form from DIP chips.
The CPU design is shamelessly copied from the Nibbler:
http://www.bigmessowires.com/nibbler/
I asked Steve and he emailed the Nibbler design has a CC-BY-SA license.
He also asked that I not use the name "Nibbler". So, I'm calling this RL4000.
Here are some great things about Nibbler (AKA RL4000):
1. Super simple
2. Can be realized with DIP chips
3. Comes with an Assembler written in MFC (I love MFC)
4. Comes wiht a Simulator (also in MFC)
5. Comes with fairly complex games and other code
Hopefully this RL4000 Emulator will add
1. Lots of LEDS (everybody likes LEDs) for visual indication of inner workings
2. A way to easily change out programs
3. A way to escape Emulator and enter an interactive mode
I finally got to the point where all the LEDs are working.
Still have buttons and LCD to wire up...
For some reason (still to be determined), I decide to create a 4-bit CPU trainer.
The idea is that this could be used to teach people how CPU's work...
This is about the simplest CPU possible that can do anything fun.
This is actually going to be an RL4000 emulator, but it can also be constructed in real form from DIP chips.
The CPU design is shamelessly copied from the Nibbler:
http://www.bigmessowires.com/nibbler/
I asked Steve and he emailed the Nibbler design has a CC-BY-SA license.
He also asked that I not use the name "Nibbler". So, I'm calling this RL4000.
Here are some great things about Nibbler (AKA RL4000):
1. Super simple
2. Can be realized with DIP chips
3. Comes with an Assembler written in MFC (I love MFC)
4. Comes wiht a Simulator (also in MFC)
5. Comes with fairly complex games and other code
Hopefully this RL4000 Emulator will add
1. Lots of LEDS (everybody likes LEDs) for visual indication of inner workings
2. A way to easily change out programs
3. A way to escape Emulator and enter an interactive mode
Comments
1. Original design was done in Eagle (the PCB code I use). This was done just for the schematic. But, I've already figured out how to turn that into a PCB. (Note that the RAM chip had to be changed to an 8-bit version because 4-bit version no longer is sold). BTW: I think I can use a Propeller to make a low cost EEPROM programmer. We'll see how that goes... (Might use Flip module so everything stays DIP)
2. Someone posted a Verilog version of Nibbler. It is very simple. So, this could also be transitioned into an intro to Verilog and FPGA...
These labels look really really good, you would think they were professionally done. One tip though, you had to cut holes for your LEDs but I like to hide the LEDs behind the label and just make sure that it is blank there as the LED color shines through the thin white easily. Some black toners aren't so nice as they have a matte finish but HP and some others have a nice even glossy black. I use Avery L7067 labels. Once it goes into production I normally have polycarbonate labels made from the artwork or have it printed directly onto the metal (very nice).
Here's a picture of a simple label (all mine normally have customer logos on them) and there is the odg format file as a sample.
I probably could have done a better job there with my hole punch, but was in a hurry...
Keeping them below the surface would be easier.
BTW. I was really off in power requirements... I thought I'd need 20 mA for each of the LEDs.
But, these new Cree LEDs are so bright, each one was blinding at 20 mA. Had to swap out ~200 Ohm resistors with 5k resistors to make it so didn't hurt to look at it! I think it can be USB powered now...
The Bud plastic enclosure did turn out to be about perfect for this.
The PCB was designed to fit it and it seems to be right.
It has a nice cutout with small panel that can be customized in the back where USB, SD, audio connect.
If you mount your LCD so that the glass is level with the front of the case then you can easily slide in some 0.24mm thick clear presentation cover plastic as a window that protects the LCD glass nicely too.
I cheated with the ALU and ported the C++ simulator code for the 74181 to Spin.
That got me wondering if this is a simulator or emulator...
I think it is now a simulator, but once I had the real I/O it will be an emulator...
Anyway, this code runs through the Ram Test code provided with Nibbler.
I think it's doing the right things...
I suppose I could have copied more from the simulator, but this is fun
Like this, just started RISC V implementation by Robert Baruch
I'm tempted to see about building the RL4000 (Nibbler) using DIP chips and the Eagle schematic I have.
But, maybe it's good enough that it can and has been built before.
I'm thinking it's better to focus on FPGA implementation...
Personally I think the fun is is in the challenge. Can I design my own CPU? Without slavishly copying some other design? Do I understand the problem well enough to do that? Never mind if it's not very fast or capable.
I'm all for the FPGA idea. Traditionally the problem there was that FPGA's and dev boards are not cheap and that the development tools are a real pain. That situation has been remedied somewhat recently with the arrival of Yosys. Quick and easy HDL for the cheap Lattice FPGA's.
Next problem is that programming a CPUs in binary via switches or hex keypads and displays soon gets kind of tedious. One then needs to write an assembler or a compiler for ones weirdo instruction set.
The guy building the RISC V processor out of logic chips has an advantage there. All the assemblers and compilers you need for the RISC V instruction set exist already.
My little $25 FPGA eval board from Lattice isn't big enough to do P1V, but can certainly do RL4000 (AKA Nibbler). Maybe it could do a ZPU?
See, I cheated. Rather than build a CPU of my own I wrote a ZPU emulator for the Propeller. I did not know anything much of FPGA and Verilog/VHDL at the time, and FPGA was rare and expensive, else I might have gone that way instead.
Good old Zog. The first ever way to get C/C++ running on a Propeller !
Well, apart from my ZiCog Z80 emulator.
Speaking of minimal CPU implementations, I sometimes ponder the idea of building a SUBLEQ processor. The SUBLEQ architecture only has one instruction, "SUBtract and Branch if Less or EQual". Which means you don't need an opcode or an instruction decoder.
The SUBLEQ has the advantage that there is already a C compiler for it. Well, almost C like language.
https://esolangs.org/wiki/Subleq
Where did you find "heater", "GNU C" and "ZPU" if not on this forum?
https://opencores.org/project,zpu
Then, I did Wikipedia for ZPU (the CPU one) and came across a Parallax Forum thread in the references...
LDI is perhaps better, but then you have LD (load A from RAM) and LDI.
Have to think more about it, buy my first inclination is to rename LIT to LDI and LD to LDM...
https://en.wikipedia.org/wiki/ZPU_(microprocessor)
Not only that but in the same list of references that includes the Gods of the RISC architecture: David A. Patterson and John L. Hennessy
https://www.amazon.com/Computer-Organization-Design-RISC-V-Architecture/dp/0128122757/ref=sr_1_1?s=books&ie=UTF8&qid=1519245849&sr=1-1&keywords=Computer+Organization+and+Design+riscv
And the brains behind the RISC V architecture: Asanovic, Krste.
https://riscv.org/
How is that even possible?
Sorry, wasn't meant to be a slight...
After seeing the Parallax reference, I did think you must have wrote it...
I noticed that wikipedia page a year or so ago. What I did not notice was the hallowed names included in the list.
Anyway, it's good to know that the Parallax forums are an authoritative reference
The x86 instruction set is one of the most complex to implement. Even Intel implements it incorrectly. Even the humble MOV instruction is a nightmare of complexity. Did you know you know there is a C compiler that generates nothing but x86 MOV instructions? MOV is Turing complete.
Or do you mean the Intel 8080 instruction set?
Hmm....makes me think....How about building a single instruction computer that only implements the x86 MOV instruction, then we could use the
movfuscator to generate programs for it
https://github.com/xoreaxeaxeax/movfuscator
Was initially wishing there was room for a NOP here. Maybe the first four bits all zero would mean NOP and the lower nibble could say whether to make this for 1 byte instruction or 2 byte instruction.
The main issue there is it would probably break all the big example programs that come with Nibbler as I imagine they use all 16 instructions somewhere (but maybe I should check that).
I guess mnemonics like MOV, JMP, NOP and many others are commonly used all over the place, even if the instructions sets are not the same.
I have yet to manage even one. Even after pondering the idea for decades
That pondering started in the late 1970s/early 80's when I got hold of the data books for the AMD 2900 bit slice chips: http://www.cpu-world.com/CPUs/2901/index.html