# ALU Struggle Classic List Threaded 7 messages Open this post in threaded view
|

## ALU Struggle

 Hello, I am new to the project and just started few weeks ago. So far I really enjoy it and i have learned a lot already. I was able to go through all assignments until i got to ALU.  When I look at the table I see times where both zx and nx are 1 or zy and ny are both 1 For example, lets say input x is 1 and zx and nx are 1 therefore if zx = 1 then x = 0 and if nx = 1 then x = !x how x can be 0 and not !x at the same time? my though process is to manipulate the input first based on nx zx ny zy bits and then do f an no bits. thx
Open this post in threaded view
|

## Re: ALU Struggle

 Administrator bwspot wrote ... For example, lets say input x is 1 and zx and nx are 1 therefore if zx = 1 then x = 0 and if nx = 1 then x = !x how x can be 0 and not !x at the same time? my though process is to manipulate the input first based on nx zx ny zy bits and then do f an no bits. Mostly correct. It's not the case that x is both 0 and !x; rather, it is x=0 THEN x=!x. This is explained in the text in chapter 2: For example, let us consider the twelfth row of figure 2.6, where the ALU is instructed to compute the function x-1. The zx and nx bits are 0, so the x input is neither zeroed nor negated. The zy and ny bits are 1, so the y input is first zeroed, and then negated bit-wise. Bit-wise negation of zero, (000 . . . 00), gives (111 . . . 11), the 2’s complement code of -1. Thus the ALU inputs end up being x and -1. Since the f-bit is 1, the selected operation is arithmetic addition, causing the ALU to calculate x+(-1). Finally, since the no bit is 0, the output is not negated but rather left as is. To conclude, the ALU ends up computing x-1, which was our goal. --Mark
Open this post in threaded view
|

## Re: ALU Struggle

 cadet1620 wrote bwspot wrote ... For example, lets say input x is 1 and zx and nx are 1 therefore if zx = 1 then x = 0 and if nx = 1 then x = !x how x can be 0 and not !x at the same time? my though process is to manipulate the input first based on nx zx ny zy bits and then do f an no bits. Mostly correct. It's not the case that x is both 0 and !x; rather, it is x=0 THEN x=!x. This is explained in the text in chapter 2: For example, let us consider the twelfth row of figure 2.6, where the ALU is instructed to compute the function x-1. The zx and nx bits are 0, so the x input is neither zeroed nor negated. The zy and ny bits are 1, so the y input is first zeroed, and then negated bit-wise. Bit-wise negation of zero, (000 . . . 00), gives (111 . . . 11), the 2’s complement code of -1. Thus the ALU inputs end up being x and -1. Since the f-bit is 1, the selected operation is arithmetic addition, causing the ALU to calculate x+(-1). Finally, since the no bit is 0, the output is not negated but rather left as is. To conclude, the ALU ends up computing x-1, which was our goal. --Mark thx for clarification,  somehow i missed that and created nonsense logic. Now i just need to keep staring at the table until i get it. My idea is to first make decisions based on zx , nx, zy, ny bits followed f an no.
Open this post in threaded view
|

## Re: ALU Struggle

 Administrator This worksheet by ybakos may be helpful. Also, this test I wrote that only tests the computation part of the ALU so that you don't need to worry about the status outputs until after you get the computation part working. --Mark
Open this post in threaded view
|

## Re: ALU Struggle

 This post was updated on . cadet1620 wrote This worksheet by ybakos may be helpful. Also, this test I wrote that only tests the computation part of the ALU so that you don't need to worry about the status outputs until after you get the computation part working. --Mark So i looked at the worksheet and i am not sure what should i see there.  It proves that simple operations can yield the results, but it does not help me with starting implementing the ALU.  I must be blind but I don't see it yet.  My though process is just to do what the table shows or the worksheet. Based on the input bits zero or not zero x,y ,  negate or not negate x,y , then or or and x,y , then not out or leave it alone.  I feel like i need to use dmux to start with above,  but still cannot see the whole picture. Edit:I am trying to start making the table work piece by piece with the smallest elements i can and then i will try to combine it.  I start seeing that i might not need any dmuxes but simple or and and.