Introduction: MP-4 Simplest 4 Bit TTL CPU
only 12 TTL chips and 3 eeproms and magic :)
Step 1: CPU Architecture
MP-4 is simplest CPU that you can build and run your programs, including conditional branches and a few arithmetic logical operations. As you can see in block diagram, MP-4 is an harvard architecture microcontroller.
In this very first version there is only one register (accumulator). General purpose RAM not implemented yet.
This CPU design is very helpful to understand how CPU's work.
You can easily modify it to add RAM, add more registers or add more instructions.
Step 2: Byte Structure
instruction and operand combined in MP-4 bus. This makes possible less hardware and single instruction in single cycle. Most significant 3 bits are for instruction and lower 5 bits for operand.
Total 8 instructions and 32 bytes of memory awailable with this configuration.
MP-4 is a MIPS class CPU
Step 3: ALU and Accumulator
74ls181 ALU used for arithmetic and logical operations. 74hc574 used as accumulator.
With this configuration seen in diagram, every results can be stored in accumulator again.
Do not confuse in schematic, it seems there is no direct acces to Acc but its not true,
If you arrange 74181's B input to pass data directly out; data stores in acc directly by passing through 74ls181
74ls181 may be seen very useful in first look but unfortunately this is not true (its a big mess)
To understand work of this CPU; I recommend setup an 74ls181 circuit first and play with it a few days. (I did)
74ls181 have two 4 bit inputs, one 4 bit output and 6 control inputs.
this control inputs determines output function.
Step 4: Clock, Program Counter and Phases
The main philosophy of MP-4 is simplicity so, I used ne555 as clock generator and its working about 1Hz to understand timing. 555 produces clock signal and 74hct4017 decade counter produces phases.
(DO NOT USE CD4017 !)
In first phase, CPU fetches instruction to microcode and puts data to bus.
in second phase instruction executing and accumulator refreshing with new value.
MP-4 can run reliably up to 8 Mhz
Step 5: Microcode and Control
MP-4 have low encoded horizontal microcode. This mean, we need tons of control pins.
So, I used two 8 bit eeproms. Microcode sequencer directly reads instruction from ROM data output and produces necessary control signals.
Bit 0 and 5-6-7 of microcode1 not used. also LDA,M and LDM,A instructions not implemented in this published version.
PcLoad/ signal is producing by zero flag and JP, JPZ signals.
Step 6: Conditional Jump
Conditional jump is one of important part of this system.
Acc output goes to 4 input OR gates and generates Zero flag.
Zero signal, JP signal and JPZ signal determines conditional or unconditional jumps.
Step 7: Complete Circuit
Im putting here pdf version to view and realise your MP-4 also DSN files for Proteus ISIS design suit
in ISIS you can simulate your own CPU design. simply right click on ROM and put your own hex program to run
But please note that Proteus-isis cannot simulate 74ls181 properly
Step 8: Instructions and Usage
00 : NOP You have only 8 instructions and you waste one of them with "no operation" command !
NOP instruction is very important for upgrade to multicycle CPU. When upper microcode fetching instruction, operand or adress bytes, lower microcode must run NOP command.
We will see this in next version of MP-4E ( E: enchanced, multicycle CPU)
20: LDA,n (2 for command, lower nibble is operand: 20,2f, 2a etc all loads acc with low nibble)
40: ADD,n : adds operand to acc
60: DEC : decrements accumulator operand ignored
80 IN A : gets data from input port to acc
A0: OUT A :puts acc content to out port
for in or out commands you may use 4.th bit as adress decoder to add one more port
then BX command puts data to second out port
C0: JP : unconditional jump to adress n (4 bit adress)
Dn: JP unconditional jump to 5 bit adress
En: JPZ : conditional jump to adress n (4 bit adress): jump if zero
Fn: JPZ : conditional jump to 5 bit adress
HACK1: If you want to add RAM, install LDA,M (load acc with adress content) and LDM,A (load memory with acc) instructions.
Also you must add MAR register, then remove instructions NOP and DEC (ADD ,0e is same with DEC)
dont forget to modify in microcode CS/, WE/ and RD/ signals. In this setup, you may use unused PCload/ signal in microcode ;)
HACK2: you may add 8 more instructions by sacrifying 16 bytes of memory then, upper four bits goes for code and lower four bits for operand ;)
Step 9: Microcode and Test Programs for ROM
I used 28c16's for microcodes and 28c64 for main ROM unfortunately proteus design suit cant recognized so that I published circuit with 2764 eproms here is microcodes and test programs
25 Comments
1 year ago
Just wondering why you wrote "(DO NOT USE CD4017 !)"? Does it have to do with driving LEDs?
Reply 1 year ago
This is a TTL circuit and cd4017 is a CMOS chip. So for stable operation (level compatibility) you must use 74hct4017, other option is using totaly CMOS chips, also in this circuit no driven LED's by 4017 ;)
6 years ago
This is very cool! Great stuff! Thanks for sharing with us. I think I am going to build this CPU in an FPGA. It will be interesting.
Reply 6 years ago
Please do it and share with us, MP-4E (multicycle separate adress and data bus, 4 bit, 16 instructions and 2k memory) and MP-8 (64k 8-bit Von Neumann machine) are in process !
Reply 2 years ago
Hi mkpeker - did you complete the MP-4E and MP-8?
Reply 1 year ago
I passed MP-4E and completed mostly MP-8. Since I am a doctor, I worked very hard during the pandemic period. As soon as I get the chance, I will be happy to share the MP-8 with you. Thank you for your attention.
Question 3 years ago
Cool! This project is really nice but is there an reset instruction?
Answer 2 years ago
simply Jp $00 lol :)
3 years ago on Step 5
ne hi, i hope you are fine can you send me the proteous file of this project?
3 years ago
excellent project
OK.COLOMBIA
Reply 3 years ago
Nope :) Im a surgeon. its just a homemade fun project
4 years ago
And BTW, since I was using the /C input, I changed the Decrement opcode to the more flexible "SUB,n"
5 years ago on Introduction
can you please post a parts list? oh hey can isis make a pcb from the schematic? that way it would be easier to build amd would look nicer.
Reply 5 years ago
Thanx for your interest, you can take it from published dsn file.
Please share pcb files if you realise it !
5 years ago
Hi! Just wanted to greet you for this project! It's a bit hard for me to understand everything, since I'm starting to dig into computer architecture, but I hope I will give this a second look in a while and try to build it. Thanks for sharing!
5 years ago
Can you post codes to program the rom with arduino or C?
I can't understand how to load .bin files
Reply 5 years ago
There is arduino projects on web to program parallel eeproms and flashes. After a bit googling you can find them. Actually Im using this programmer;
http://www.datahardware.co.uk/mini-pro-usb-tl866a-...
With this programmer you must select your device and .bin or .hex file then directly sends via USB
Reply 5 years ago
But I have a already a Arduino Programmer and the USB programmer is expansive...
There's a way to convert .BIN files in uncopilated code (Hex or Binary Number) that i can load with arduino?
Reply 5 years ago
you can use arduino itself as programmer here is the way;
https://forum.arduino.cc/index.php?topic=163682.0
Reply 5 years ago
Thanks for the help :)