Omnimaga

General Discussion => Technology and Development => Other => Topic started by: Ashbad on April 08, 2011, 03:16:49 pm

Title: 4 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 03:16:49 pm
Me and my friend spent last weekend making a 2 bit computer out of ONLY household items.

What we used:

-6 nails
-3 miniature cardboard boxes
-6 low charge magnets
-tons of wire

:)

anyways, no picture yet, my friend is gonna give me a few pictures on monday -- hopefully by then we can allow for writing of programs in nibble hex :) using switches :P

Here's the plan on what the possible opcode table will be:

0 - NOP
1 - ADD O, A, B
2 - SUB O, A, B
3 - ADD A, B
4 - SUB A, B
5 - OUT A
6 - OUT B
7 - IN A
8 - IN B
9 - AND A, B
A - LD A, PC$ + 1
B - LD B, PC$ + 1
C - OUT PC$ + 1
D - AND A, B
E - IN PC$
F - RET

To do this program writing however, we'll need more materials -- we'll try to find the cheapest switches available ;D and more copper wire, we already use a full roll :P
Title: Re: 2 Bit Homemade Computer
Post by: aeTIos on April 08, 2011, 03:20:14 pm
Sounds freakin' awesome!
and haha, your avatar reminds me of one of my teachers O.x
Title: Re: 2 Bit Homemade Computer
Post by: Binder News on April 08, 2011, 03:20:39 pm
Ohhh. Sounds like fun! I just spent half my math class diagnosing the problems with 4 of the schools "broken" calcs. 1 had battery acid. 3 had messed up LCDs, and one of those was still usable w/o getting the LCD replaced. :)

EDIT: And I still got 3 problems on my homework done! :) :)
Title: Re: 2 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 03:24:21 pm
lol O.X

yeah it's pretty awesome.  I actually think it's possible that the calculations are considered really fast compared to other microprocessors -- you hook up the right wires, and then turn on the power wire, then BOOM! you hear a click of the bits setting to the result in the O register.

Right now we only have addition and subtraction "machines", but and AND one will be even easier :) the harder one was the SUB one x.x took an hour of figuring out a diagram.  Though, with 2 bit, it's possible that we can use the ADD operator for AND operations -- but then ADD will have no overload looping.  We still are figuring out how to do that.

I think Xeda will like the opcode table :D
Title: Re: 2 Bit Homemade Computer
Post by: Freyaday on April 08, 2011, 04:00:01 pm
This isn't a microprocessor. It's a macroprocessor.
Title: Re: 2 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 04:04:49 pm
O.o good point :P

Anyways, I found the schematic for an earlier design of this, which formed the basis for the AND machine (my friend called and said it's now working)

this was going to be an ADD machine, but now since we're gonna try to deal with overflow, we'll use it instead for AND operations ;)

And, we're discussing to see if going from 4 bit instructions (hex) to 5 bit instructions (base 32) will make this more awesome and allow for things such as conditionals and such.  those will be hard to make though x.x

Well, schematic: ;D

EDIT: and yes it's much more complex now :P this was like the very first edition XD
Title: Re: 2 Bit Homemade Computer
Post by: Freyaday on April 08, 2011, 04:07:30 pm
So this is a circuitous diagram?
Title: Re: 2 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 04:10:22 pm
somewhat ;) I suck at making those, so many symbols, so I kinda just represented things with pictures and such. 

Also, apparently, jumping around the program WILL be possible -- but I have no idea about conditionals -- I know how to wire up to the logic machines themselves, but how I'll make them DO the operations will be harder x.x
Title: Re: 2 Bit Homemade Computer
Post by: Freyaday on April 08, 2011, 04:33:19 pm
What's the power source?
Title: Re: 2 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 04:35:44 pm
at the moment, simple AAA's ;)

Also, I think I'll think about thinking about using both 4 bit registers (not THAT much more work thinking wise) and 8 bit RISC instructions, with a prefix and suffix nibble :)
Title: Re: 2 Bit Homemade Computer
Post by: Freyaday on April 08, 2011, 04:36:29 pm
Wait-that's three nibbles!
Title: Re: 4 Bit Homemade Computer
Post by: AngelFish on April 08, 2011, 04:37:30 pm
If he's using a 4 bit word size, that's not a problem ;)

EDIT: Topic name change  :P
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 04:37:49 pm
3 nibbles would be nice, but there's only one prefix and one suffix nibble == 2 nibbles ;)

maybe I should've said "Prefix and fields nibble" :P my bad
Title: Re: 4 Bit Homemade Computer
Post by: Freyaday on April 08, 2011, 04:38:27 pm
That seems to be the case, given the new title of this topic.
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 04:40:03 pm
yep ;)

I realized that since it wouldn't be horribly hard to up the bit number (past a certain extent), I might as well ;)

I wonder if I should also make an assembler that changes stuff from mnemonics to a diagram of bits... :) though for right now, construction and such.
Title: Re: 4 Bit Homemade Computer
Post by: Freyaday on April 08, 2011, 04:42:26 pm
Are you going to make your own keyboard or are you going to use a standard PS/2 interface?
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 04:44:01 pm
no, that stuff is too complex for my point in this -- think of a PC from 1950, with 64 bytes of RAM and 2-4 bit ALU's.  That's what this is like ;)

The goal is to make it completely out of household products ;)
Title: Re: 4 Bit Homemade Computer
Post by: Freyaday on April 08, 2011, 04:45:54 pm
Does that include blue lobsters?
Lobster Abacus!
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 04:49:34 pm
I should look in my fridge :) hmm, maybe to store data I can have lobster chunks and setting bits adds lemons to the lobster "bits" and to reset them you eat them.

I think I'll write up a decent ALU design later today, so I can do 4 bit math fast and with little wire ;)

EDIT: and that "AND" machine is actually an "OR" machine -- sorry, I had my foot in my mouth ;)
Title: Re: 4 Bit Homemade Computer
Post by: Freyaday on April 08, 2011, 04:51:44 pm
What are you going to do with the rest of the wire? Maybe you could use the lobsters for power?
Title: Re: 128 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 04:52:37 pm
I bet they give off more electricity than the electric eels I tried, so that would actually be a good idea :)
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 08, 2011, 09:05:10 pm
Well, after some fabulous input from runer, I have ideas for tons of different instructions and registers.  The opcode table is still far from complete, but I can explain the registers:

A - the primary arithmetic register.  Used in tons of instructions involving math and logic.  4 bit.
B - fulfills the role of A, less instructions support it, but its good for when A is tied up.  4 bit.
C - General use register, connected closely to the O output register for quicker transport of values for shipping.  4 bit.
D - General use register, connected closely to the I input register for quicker transport of values in shipping.  4 bit.
E - general use register, can be used to complement other registers to make 8 bit values. 4 bit.
F - flag register -- includes the C, Z, N bit flags and another general use bit used in more complex instructions.  4 bit.
G - (proposed, unsure if I'll keep it) includes more flags such as parity/overflow, and a few extra bits for really complex instructions.  4 bit.
I - input register, directly deals with the input received from a port in 4 wire form, transfers data quickly to D and slower to other registers.  4 bit.
O - output register, directly deals without the output sent out to a port in 4 wire form, transfers data quickly to C and slower to other registers.  4 bit.
PC$ - the program counter register, determines where in a 2048 bit program the instructions are to be read from.  8 bit.
PG$ - the page counter register, determines what page of a 256 page (each page 2048 bits) program instructions are to be read from.  Used in calculations and for easy management of pages without many ports -- however it relies on a port to actually swap pages. 8 bit.
N - the frequency register.  Directly deals with the speed at which a program can run.  The higher the number, the slower the program goes.  4 bit.
U8 - no use specified 8 bit register.
U16 - no use specified 16 bit register.
U32 - no use specified 32 bit register.
U64 - no use specified 64 bit register.

The no use ones can be accessed with a few more complex instructions, and can be used if you wanna use large numbers for some unknown reason.  Keep in mind, these would be very slow (unlike the other less used registers, which are really fast -- these are accessed in a different way than the others due to their size, with exception of A8 being connected like PC$ (fast) and PG$ (medium fast))

:)

Edit: I just realized I should have some more, but I'm sure people will point out things like a double word one like HL and an offset one.  Give any suggestions :)
Edit2: and maybe another more general use one or two?
Title: Re: 4 Bit Homemade Computer
Post by: Juju on April 09, 2011, 12:41:11 am
I love this idea to make a processor out of household items :P
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 09, 2011, 10:34:35 am
Well apparently after telling my friend about the new and complex opcode table, he lost interest in making this completely out of household items x.x

So, instead, I told him about logism, so we're gonna just fool around with that for now ;)

So.... He says that if we just draw stuff up for logism, it should be around 64 bits... I said we should make a 4 bit processor first ;) what do you guys think?
Title: Re: 4 Bit Homemade Computer
Post by: ztrumpet on April 09, 2011, 10:39:26 am
Sounds like a cool project!  Good luck. ;D
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 09, 2011, 10:41:10 am
Thanks zTrumpet!  We'll try to make it the fastest 4 bit processor ever ;)
Title: Re: 4 Bit Homemade Computer
Post by: Happybobjr on April 10, 2011, 02:34:25 pm
will you explain what you use for switches. Is it the magnets?
What are you using as a power supply?
Title: Re: 4 Bit Homemade Computer
Post by: AngelFish on April 10, 2011, 02:43:17 pm
*Cough* 64 bit is a pain to wire *cough*

You could shoot for 8 bit, though.

Also, completely ignore my tutorial if you'd like to make the next 4 bit i7 ;)
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 10, 2011, 02:44:58 pm
Thanks for that tutorial qwerty, it helped :)
Title: Re: 4 Bit Homemade Computer
Post by: willrandship on April 10, 2011, 03:37:39 pm
Interesting. I'm currently working on a base-4 2 bit processor, so it also has 16 commands. I have 4 addressing bits, though, so I can do a lot more with said commands :P BTW, 4 quaternary bits = up to 256 options :)

Sounds like a cool project! Mine's still in the design phase :P I've only managed some of the base circuits, like a multiplexer to choose the command, the memory, and the three base logic gates. XOR is not happening :P
Title: Re: 4 Bit Homemade Computer
Post by: Freyaday on April 10, 2011, 05:04:05 pm
If it's in base 4, shouldn't they be quits? ;)
Title: Re: 4 Bit Homemade Computer
Post by: willrandship on April 10, 2011, 06:07:54 pm
Meh, I don't really care about the naming convention. I got first place in the state science fair for it, though, and I  go to nationals in May! :w00t:
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 10, 2011, 06:10:50 pm
I think there's a way to make an XOR gate with the three others once you have them made -- and I think it only uses one of each :). Though then again, wiring that IRL will still be tricky :P

Good luck will :)
Title: Re: 4 Bit Homemade Computer
Post by: willrandship on April 10, 2011, 06:22:17 pm
not in quaternary, the making that is. The easiest gate to make is OR, but NAND is pretty simple too. The real trouble with XOR is, how exactly will it work? The AND, OR and NOT are pretty simple, but XOR in base 4 gets a little tricky.

AND - Lesser input ex 2 and 1 = 1
OR - Greater input ex 1 or 3 = 3
NOT - Inverse of input ex not 0 = 3, not 1 = 2
XOR = ???

The real trouble comes with the expansion to a higher range of numbers.

And thanks :)
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 10, 2011, 06:25:41 pm
Yeah, an OR machine is by far the simplest -- you know all you need is a few wires tied together?  :) NOT is actually possible with tons if wires and rudimentary midway bits, but my friend got it to work (only like twice) with 2 bit operations :P
Title: Re: 4 Bit Homemade Computer
Post by: willrandship on April 10, 2011, 06:30:19 pm
Well, you need diodes.....otherwise you can get messed up signals behind the OR, and bad stuff happpens. :P Not only needs a few transistors....

Don't forget this isn't binary.
Title: Re: 4 Bit Homemade Computer
Post by: AngelFish on April 10, 2011, 06:32:02 pm
not in quaternary, the making that is. The easiest gate to make is OR, but NAND is pretty simple too. The real trouble with XOR is, how exactly will it work? The AND, OR and NOT are pretty simple, but XOR in base 4 gets a little tricky.

AND - Lesser input ex 2 and 1 = 1
OR - Greater input ex 1 or 3 = 3
NOT - Inverse of input ex not 0 = 3, not 1 = 2
XOR = ???

The real trouble comes with the expansion to a higher range of numbers.

And thanks :)


XOR isn't exactly what it looks like. It's actually true when the number of true inputs is odd and false when the number of true inputs in even. Try using that ;)
Title: Re: 4 Bit Homemade Computer
Post by: Snake X on April 10, 2011, 06:35:40 pm
so how will this thing give any way of output? I'm assuming definitely not by monitor or graphics.. so then what will it be?
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 10, 2011, 06:37:56 pm
You mean mine?  Well, my friend lost interest and so did I after he did, but our old output system was literally just reading the magnets -- if they were on top, then that bit was 1, else 0.  Very rudimentary way of checking, but it worked :)
Title: Re: 4 Bit Homemade Computer
Post by: willrandship on April 10, 2011, 06:41:49 pm
Well, I've got a screen built into the assembly of mine. Remember when I was asking for 16x16 redscale sprites? It was for an emulator of this processor I wrote in python.

Right now, I can't actually think of a use for XOR anyways, and since the command set is full, I can't exactly fit it in. :P
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 10, 2011, 06:44:26 pm
True, I guess XOR isn't always as useful as the other logics... But it is a good and easy way of resetting registers :) (in z80 specifically XOR A) but other than that, I don't use it as much personally -- and there's a way to achieve it anyways with the other logic instructions :)
Title: Re: 4 Bit Homemade Computer
Post by: willrandship on April 10, 2011, 06:48:17 pm
Well, heck, I can just go SetMx 0000 when I want my mem banks cleared. Other than that, all the functions either use said banks or are defined in the program, so I guess there aren't any registers X(
Title: Re: 4 Bit Homemade Computer
Post by: Freyaday on April 10, 2011, 07:04:23 pm
What about attaching a xylophone or bells (metal version of a xylophone)?
Title: Re: 4 Bit Homemade Computer
Post by: Ashbad on April 10, 2011, 07:07:25 pm
What about attaching a xylophone or bells (metal version of a xylophone)?

That actually would be extremely possible.  You could just implement the classic doorbell circuit, except instead of a high rate fapping piece of metal, it would be attached to a mallet.

Hark, what is that I hear?  The A register is equal to B flat?  :)
Title: Re: 4 Bit Homemade Computer
Post by: ralphdspam on April 10, 2011, 07:15:00 pm
Bb? I heard A#.  :P

Anyways, this is a great project idea!  How would the programs be sent?  Would we have to manually set the bits?
Title: Re: 4 Bit Homemade Computer
Post by: Freyaday on April 10, 2011, 07:15:21 pm
You could play MIDIs!
Title: Re: 4 Bit Homemade Computer
Post by: willrandship on April 10, 2011, 11:13:37 pm
Mine will most likely have a binary processor, like, say, an arduino, that has at least 6 PWM outputs. It will then simply feed them, giving each function enough time to finish. The arduino is loaded with the program from the PC, and is basically an advanced HDD :P
Title: Re: 4 Bit Homemade Computer
Post by: z80man on April 10, 2011, 11:31:47 pm
Perhaps a 4 bit * 4 bit = 8 bit could be added. I have a diagram laying around somewhere so I will post that soon. At the first bit multiply is very simple, but doubles in size with every bit. I think overall that instruction is about 300 transistors if that in not too many

btw: I wonder how many transistors the 256 bit fpu square root instructions take on the sse5 set.