1

I'm angling this as a general question on the assumption that it doesn't differ significantly with architecture - at least at the level I'm asking.

I'm curious how - in terms of hardware, not the obvious 'result is zero' - the zero flag/status bit is set (or cleared for that matter).

It never really occurred to me before, but it seems a fairly intensive task, at least relative to say, a carry or overflow flag. Am I correct in thinking there's no way to know the result is zero, other than to check each bit?

Unless I'm missing something obvious, it seems that it must take 'a lot' (if that's sensible to say in \$\text{ns}\$) longer than determining the overflow, and the carry status of course is 'already there' as a consequence of the operation.

My question, really, is just how is it 'usually' implemented?

OJFord
  • 267
  • 1
  • 11
  • N-input OR gate followed by a NOT gate? Checking each bit isn't very intensive when you can check all the bits in parallel. – Rocketmagnet May 30 '14 at 22:20
  • I see that, but that's not '*that*' parallel - all the bits have to be OR'd together ultimately, so the number of ops increases with N!. I realise it's still fast in an absolute sense, but it's a lot slower than determining C/V flags isn't it? – OJFord May 30 '14 at 22:25
  • Sorry, [this question](http://electronics.stackexchange.com/questions/4194/how-to-find-out-if-a-binary-number-is-zero?rq=1) is not only related, but wholly the same. I couldn't find it before I posted, and wasn't suggested from my title, but I just saw it in the sidebar. Sorry! – OJFord May 30 '14 at 22:30
  • 2
    An N-input gate is still a single gate delay up to something like 8 inputs. If you needed two stages, that would be sufficient for 64 bits parallel, so it's increasing with log2(N)/K, where K is log2 of the maximum number of inputs for one gate delay, not N and certainly not N!. – Spehro Pefhany May 30 '14 at 22:35
  • @Spehro Pehfhany - I wasn't aware of that until the question I linked/your comment. It makes sense now, I just had a 'I must be missing something' feeling.. – OJFord May 30 '14 at 22:38
  • Also I meant sum of the n terms to n, not n!. So n^2 I suppose. But anyway, I was wrong. :) – OJFord May 30 '14 at 22:47
  • @dave-tweed - thanks for marking as dupe. I'm a relative SE noob, but I've never seen these options, does it require certain rep? And OP can't do if (like I did) later discovers a duplicate? – OJFord Jun 02 '14 at 19:16
  • 1
    It's one of the options that you get when you click the "close" button under the question. Normally, the decision to close is arrived at via voting by the community, but since you identified the dupe yourself, I went ahead and "short circuited" the process and did it directly. I'm a moderator (that's what the diamond means), so my votes take effect imeediately. I'm very careful about when I take such actions, but in this case, it seemed entirely appropriate. – Dave Tweed Jun 02 '14 at 19:29

1 Answers1

2

An n input NOR gate will do the hardware implementation.

nidhin
  • 8,197
  • 3
  • 28
  • 46