ALU operations

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

ALU operations

AndyGeo
I'm just having a bit of trouble going through the worksheet, here's what i'm doing;

for f(x,y)=1:

x is zero'd then negated. So i get 1111
y I do the same so i get 1111.

Then f=1 so i do x+y = 1111+1111 which gives me 1110

And n=1 so i negate that and get 0010. which is 2.

Any help much appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: ALU operations

cadet1620
Administrator
Be careful, you are mixing arithmetic negation and logical negation. You should be using the same type throughout the ALU.

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

Re: ALU operations

moarmango
I haven't started the ALU yet, but was also getting negation mixed up as well when observing the chart.  I am assuming for simplicity sake, that negation throughout the chart refers to logical negation?  Also regarding arithmetic negation, is this already built into the hardware simulator when running the ALU?  Observing the inputs and outputs in decimal notation on other tests, it seems negative and positive designation is already in place.
Reply | Threaded
Open this post in threaded view
|

Re: ALU operations

cadet1620
Administrator
moarmango wrote
I haven't started the ALU yet, but was also getting negation mixed up as well when observing the chart.  I am assuming for simplicity sake, that negation throughout the chart refers to logical negation?  Also regarding arithmetic negation, is this already built into the hardware simulator when running the ALU?  Observing the inputs and outputs in decimal notation on other tests, it seems negative and positive designation is already in place.
Yes, although the text only explicitly says "bit-wise" for ny, figure 2.5 is quite clear:
 * The ALU operation can be described using the following pseudocode:
 *     if zx=1 set x = 0       // 16-bit zero constant
 *     if nx=1 set x = !x      // Bit-wise negation
 *     if zy=1 set y = 0       // 16-bit zero constant
 *     if ny=1 set y = !y      // Bit-wise negation
 *     if f=1  set out = x + y // Integer 2's complement addition
 *     else    set out = x & y // Bit-wise And
 *     if no=1 set out = !out  // Bit-wise negation
 *
Data stored in memory doesn't inherently have a sign. In fact, it doesn't inherently have a numeric value. It's all a matter of how we choose to interpret it. The binary value 1010011100110010 could be interpreted as the unsigned number 42802, the signed number -22734, the characters "ยง2", or maybe none of the above. It might be part of the pixel pattern of a graphic character.

The Hardware Simulator can display values as signed decimal, binary or hexadecimal. The test script controls how values are displayed in the output file. There is a menu that controls how the simulator displays other values.

--Mark