Forums - Open Redstone Engineers
I feel stupid - Printable Version

+- Forums - Open Redstone Engineers (https://forum.openredstone.org)
+-- Forum: ORE General (https://forum.openredstone.org/forum-39.html)
+--- Forum: Build Discussion (https://forum.openredstone.org/forum-50.html)
+--- Thread: I feel stupid (/thread-4761.html)



I feel stupid - greatgamer34 - 09-23-2014

I just realized, to check if a number is odd on a cpu, shift the number down. If the shift underflow flag is true, the number is odd....

i just had to write this down somewhere, i feel completely stupid.

<3
-GG34


RE: I feel stupid - Xray_Doc - 09-23-2014

I feel like that everyday when I come on this site.


RE: I feel stupid - tokumei - 09-23-2014

HOORAY EVERYONE LETS CLAP FOR GG!


RE: I feel stupid - tokumei - 09-23-2014

Side note: I didn't know you could do that either. Thanks for that tip Big Grin


RE: I feel stupid - greatgamer34 - 09-23-2014

I was working on a new CPU last night, and it just hit me. Literally was a slap to my face, i screamed out loud in my dorm room that im a fucking idiot, the decided to share my new found knowledge here, because if i posted it on 4chan, it could wind up in the wrong hands.


RE: I feel stupid - Legofreak - 09-23-2014

I dont know much about CPU logic, but cant you just check if there's a 1 in the 1s column without the shift?


RE: I feel stupid - redstonewarrior - 09-24-2014

(09-23-2014, 03:22 AM)greatgamer34 Wrote: I just realized, to check if a number is odd on a cpu, shift the number down. If the shift underflow flag is true, the number is odd....

i just had to write this down somewhere, i feel completely stupid.

<3
-GG34

:3


RE: I feel stupid - greatgamer34 - 09-24-2014

(09-23-2014, 11:33 PM)RekcirBrickeR Wrote: I dont know much about CPU logic, but cant you just check if there's a 1 in the 1s column without the shift?

that would require more hardware. Im just reusing hardware that i already have Big Grin


RE: I feel stupid - jxu - 09-25-2014

I believe in most CPUs, shifting and checking a flag takes more cycles than a conditional flag AND with 1. Shifting also requires more memory


RE: I feel stupid - TSO - 10-05-2014

Also, you could already have a 1 bit even/odd register already setup that automatically fills with the lowest digit, which you just call for in the program. That knocks out running a conditional check and is faster than the shift technique.

I guess I'll clarify, it's not like a true register, the last line just has a duplicate that goes to it's own read address.

You can also call a bit mask of 00000001 (assuming 8 bit) and if you get a zero, you have an even number.


RE: I feel stupid - greatgamer34 - 10-06-2014

(10-05-2014, 10:07 PM)TSO Wrote: Also, you could already have a 1 bit even/odd register already setup that automatically fills with the lowest digit, which you just call for in the program. That knocks out running a conditional check and is faster than the shift technique.

I guess I'll clarify, it's not like a true register, the last line just has a duplicate that goes to it's own read address.

You can also call a bit mask of 00000001 (assuming 8 bit) and if you get a zero, you have an even number.

I was trying to accomplish any easy way of branching if it was odd. I didnt want to add any extra hardware like you first said, and the bit mask would then take another cycle to jump.

I have an OP code call BSU(Branch if Shift Underflow), which will allow me to branch when i get a SU.


RE: I feel stupid - TSO - 10-06-2014

If you already have that code, things are easy, but otherwise the other two methods are your best option, especially if you combine your bit mask into your multiplier and happen to be multiplying.


RE: I feel stupid - greatgamer34 - 10-06-2014

(10-06-2014, 01:35 AM)TSO Wrote: If you already have that code, things are easy, but otherwise the other two methods are your best option, especially if you combine your bit mask into your multiplier and happen to be multiplying.


i do not have a hardware based multiplier, or a mult isntruction.... -.-


RE: I feel stupid - TSO - 10-06-2014

Oh... Yeah... I kinda do prefer to have one of those on hand.
I've got a really good design if you want one.


RE: I feel stupid - greatgamer34 - 10-06-2014

... you dont get it do you?


RE: I feel stupid - TSO - 10-06-2014

Yeah, I get that your computer doesn't have one, and I don't know what the computer is for or if it even needs it, and you probably decided it didn't. I was just saying if you want one I've got one I'm rather fond of.


RE: I feel stupid - greatgamer34 - 10-06-2014

(10-06-2014, 04:00 AM)TSO Wrote: Yeah, I get that your computer doesn't have one, and I don't know what the computer is for or if it even needs it, and you probably decided it didn't. I was just saying if you want one I've got one I'm rather fond of.

i appreciate it, but i prefer to use a sequential multiplier designed by guy1234567890. not much can beat his for the size of it.


RE: I feel stupid - TSO - 10-06-2014

I personally prefer speed, so I use 3-2 compressor trees to a final adder. You can get that going really fast.


RE: I feel stupid - greatgamer34 - 10-06-2014

the sequential is probably much faster, i think 15 ticks or so for a 4bit mult.


RE: I feel stupid - TSO - 10-06-2014

I think it's at eight or so for eight bit (I would have to go check), ten for 16 bit, twelve for 32 bit. It uses lattice multiplication to find all the partial sums and add them simultaneously.
Basically you just add two ticks for each doubling in size.

Here is how you build it.
http://en.m.wikipedia.org/wiki/Dadda_multiplier