Order of operations and negating the 16 bit values.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Order of operations and negating the 16 bit values.

kingpinzs
the order I do things are
zero the x
and or negate the value

same with Y value then
add or and it
then negate the output.

The code doesn't work at all.

Here is what I have.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    Mux16(a=x,b=false,sel=zx,out=xZeroed);/ /can out put zeroed and not zeroed

   Not16(in=xZeroed,out=InvertX);
  Inc16(in=InvertX,out=IncX);//outputs only negtive numbers

   Mux16(a=xZeroed,b=IncX,sel=nx,out=NegX);//can out put Negtive or not Negtive X

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    Mux16(a=y,b=false,sel=zy,out=yZeroed);/ /can out put zeroed and not zeroed y

   Not16(in=yZeroed,out=Inverty);
  Inc16(in=Inverty,out=Incy);//outputs only negtive numbers

   Mux16(a=yZeroed,b=Incy,sel=nx,out=NegY);//can out put Negtive or not Negtive y
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Add16(a=NegX,b=NegY ,out=added);
And16(a=NegX,b=NegY,out=anded);

Mux16(a=anded,b=added,sel=f,out=addand);//first main output
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   Not16(in=addand,out=InvertOut);
  Inc16(in=InvertOut,out=IncOut);//outputs only negtive numbers

Mux16(a=addand,b=IncOut,sel=no,out=out);
///////////////////////////////////////////////////////////////////////////////////////////////////////

but all I get is zeros or ones.
Reply | Threaded
Open this post in threaded view
|

Re: Order of operations and negating the 16 bit values.

milythael
For each input (x, y) there are two bits which can affect them prior to their use together. This means we have a four value selector that chooses between:
zeronotresultbits
00original input101 => 101
01bitwise not the input101 => 010
10zero the input101 => 000
11bitwise not the zero101 => 111
I hope this helps clarify things a little.
Reply | Threaded
Open this post in threaded view
|

Re: Order of operations and negating the 16 bit values.

cadet1620
Administrator
In reply to this post by kingpinzs
There are two types of negation, logical and arithmetic. Read milythael 's response and the description of the ALU carefully and be sure you understand the type of negation required. Ybakos wrote a great worksheet that will help you understand how the ALU works.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Order of operations and negating the 16 bit values.

kingpinzs
Thanks that helped out a lot. I got it all to work. Thanks again