Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ALU: zero?

4,926 views
Skip to first unread message

Ramie Massri Chaarani

unread,
Oct 14, 2009, 5:48:48 PM10/14/09
to
I'm wondering if anyone could explain on page 8 chapter 4, how the
"Zero" value coming from the ALU works? I'm curious about how this works
with the signal "Branch", because, even if "Branch" is set to 1, the
zero from the ALU will always be 0 and thus the AND gate will always be
false.

Thanks

Ramie

Stephen Mann

unread,
Oct 14, 2009, 7:31:21 PM10/14/09
to
In article <hb5h00$nej$1...@rumours.uwaterloo.ca>,

The Zero output of the ALU is not always 0; instead, it will be high (1)
when the result of the operation in the ALU results in a 0 result.
Eg, the command sub $t1, $t1, $t1 will be 0, and the Zero output of
the ALU will be 1. This, of course, is not a particular useful
example (since we *know* that the Zero output will high); instead,
we normally use Zero to compare the value in two different registers.

In particular, the Branch signal will be high when the assembly
language instruction is beq. The beq instruction compares the values
in two registers, and if the values are equal, it branches to an offset
specified in the beq command. If the values are not equal, then
PC <- PC+4. For example, for beq $t1, $t2, 100 $t1 and $t2 are
inputs to the ALU and the ALU operation is 'sub'. If the values in $t1
and $t2 are equal, then the Zero output of the ALU will be high. And
for beq, the Branch signal is also set high (regardless of the values
in $t1 and $t2).

The result is that if $t1==$t2, then Zero=1 and Branch=1 (this last
is true since we're executing a beq command) and the program
branches. If $t1!=$t2, then Zero=0 and Branch=1, and the program
won't branch (since Zero AND Branch = 0).

Steve

alec....@gmail.com

unread,
Mar 11, 2015, 7:45:21 PM3/11/15
to
This explanation was amazing. A very belated thank you for posting. :)

vladi....@gmail.com

unread,
Apr 29, 2015, 3:23:27 PM4/29/15
to
Thanks a lot for your explanation, it was exactly what i've looked for!

paul.philip...@gmail.com

unread,
Dec 5, 2015, 12:30:01 PM12/5/15
to
Thank you for the answer, it is perfectly clear :)

fd...@hotmail.com

unread,
Mar 29, 2016, 9:40:04 PM3/29/16
to
Perfect explanation man, thank you.

dipu...@gmail.com

unread,
May 8, 2017, 5:45:48 AM5/8/17
to
Can you please explain about bne.
I also like to know about the content of ALUOp and output of ALU Control.

Thanks,

Dipu

0 new messages