Update: Compiler Added
Intro
Hey guys. I have finally finished a project that I have been working on for months
now, my very own PowderToy computer! The C4C 1 8-bit Computer is now fully functional,
complete with detailed documentation and a block diagram of the internals. I am very proud
to join the community of people who develop complex electronics and computers on TPT.
I am probably the youngest person to finish such a project, being a 14 year old freshman
in high school. You guys are truly amazing, and the feats you accomplish together as a
community are incredible (60 hz computer, GPU, video game inside a video game, etc.)
I hope now to play my part in this incredible community.
Detailed Specifications
Before we get into the computer, here is a complete specification for further reading:
And here is the block diagram:
http://tinyurl.com/C4C-1-Spec-PDF
Features
Programming Instructions
Finally, we get to the programming refrence. You need technical knowledge for this section. It is taken from the reference. In the ROM, data is stored in filt. Filt uses a hex number which corresponds to a 30-bit wavelength in the CTYPE:
Instruction Bitfield:
Data Bitfield:
Register bitfield (for use in operands):
And an assembly instruction corresponding to instructions or data:
Update: Use the compiler linked at top, type assembly instruction, followed by binary operands
into compiler, then press compile instruction. When done with entire program, press create image
and copy that ROM.
To program the C4C 1 CPU in PowderToy, there are several steps you need to take:
Putting data into the ROM is similar. Simply convert the 8 bit byte to hex, put the 0x in front of it,
paste it into the PROP tool with it set to CTYPE, and click on the filt memory cell you want to write to.
Instruction Reference
HLT [NONE]
MOV a, b [REGISTER],[REGISTER]
STORE a, b [RAMADDR], [REGISTER]
LOADRAM a, b [REGISTER], [RAMADDR]
LOADROM a, b, [REGISTER], [ROMADDR]
DB a [CONSTANT]
JMP a [ROMADDR]
JZ a, b [ROMADDR], [REGISTER]
JNZ a, b [ROMADDR], [REGISTER]
OR a, b [REGISTER], [REGISTER]
AND a, b [REGISTER], [REGISTER]
NOT a [REGISTER]
SHL a [REGISTER]
SHR a [REGISTER]
ADD a, b [REGISTER], [REGISTER]
RECV a [REGISTER]
SEND a [REGISTER]
Example: Fibonnaci Sequence Program
DB 1 ;Store the value 1 in memory cell 0
SEND AX ;Since all registers are 0 at CPU start, I can output 0
LOADROM AX, 0 ;Load memory cell 0 (a value of 1) into AX
SEND AX ;Perform fibbonaci
MOV CX, AX
ADD AX, BX
MOV CX, BX
SEND AX ;Output fibonnaci
JZ 11, AX ;Jump to terminate if AX overflows
JMP 4 ;Jump back to fibonnaci
DB 0xEE ;Store 0xEE
LOADROM AX, 10 ;Retrieve 0xEE
SEND AX ;Print "EE" on display, signifies overflow
DB 0 ;Why the hell would I want to end my program in addr 13?
HLT ;Halt
Update: Virtual Machine Emulator for C4C 1
I made an emulator in C for the C4C 1 machine. The code is here:
Conclusion
I am very happy to finally be done with this. If you have any bugs, post them in this thread or
DM them to me using the PowderToy message system. Also post or send me any questions.
Awesome job dude! Welcome to the electronics community (which I'm not part of, yet). But I have been catching up on some subframe lately, so I'll see you soon on the electronic battlefield >: Also maybe I could help you build an in game compiler for the C4C?
In your instruction reference, you put "address" instead of "opcode" where it shows the binary for each instruction.
@Quantech Oh my god! I forgot was that was called! Well, that's kind of sad. I am really dumb for not knowing that. Anyways, in your compiler, I see you are missing DB. You could make a seperate input for only data, or you could use your operand A or B input.
Added DB instruction. Now I'll need to use PSTN and DTEC majicks to create a 16x16 block of FILT.
Two questions: do you input DB through the Operand A or Operand B panel? Also, you have a bug in your design where if I spam either the Operand A or B panel with spark the pstn overshoots the filt line. You need to change the maximum extension distance of the pstn to one by setting the tmp2 value. This also applies to spamming every button except DB, because they also connect to pstn.
Thanks for reporting the bug. Also I deleted the original save and made a new, published save so that it could get bumped to fp. Hopefully. For the DB instruction, you set operand A. Same goes for all 1-operand instructions.