How to count zeros in registers?
Electronics Forum Index Electronics
Circuits, theory, electrons and discussions.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web ElectronicsHelp.net
How to count zeros in registers?
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    Electronics Forum Index -> Basics
Author Message
Woody Brison
Guest





Posted: Thu Dec 01, 2005 1:35 am    Post subject: Re: How to count zeros in registers? Reply with quote

Jim Thompson wrote:
Quote:
On 29 Nov 2005 06:12:56 -0800, "Davy" <zhushenli@gmail.com> wrote:

Hi all,

reg[7:0] register;
The register contains data like
[0 0 0 1 0 1 0 1]
And I want to know the number of the zeros before the first 1
(in this example is 3 zeros).

How to do this in a combinational logic?

Best regards,
Davy

See...

http://www.analog-innovations.com/SED/HowManyOnes.pdf

You'll need to modify it for "zeroes" and to stop at the first
occurrence of a "one"

Holy Mole, that seems like a contest winner how to do the job
with the most gates possible (altho a modern compiler will
optimize it down some)

Just draw the K-map and loop the functions.

The problem tells us there are 8 bits, people

One thing, the problem doesn't specify: what is wanted when
the register contains 0 0 0 0 0 0 0 0

Wood

Back to top
Jim Thompson
Guest





Posted: Thu Dec 01, 2005 1:35 am    Post subject: Re: How to count zeros in registers? Reply with quote

On 30 Nov 2005 15:58:57 -0800, "Woody Brison" <woody_brison@yahoo.com>
wrote:

Quote:
Jim Thompson wrote:
On 29 Nov 2005 06:12:56 -0800, "Davy" <zhushenli@gmail.com> wrote:

Hi all,

reg[7:0] register;
The register contains data like
[0 0 0 1 0 1 0 1]
And I want to know the number of the zeros before the first 1
(in this example is 3 zeros).

How to do this in a combinational logic?

Best regards,
Davy

See...

http://www.analog-innovations.com/SED/HowManyOnes.pdf

You'll need to modify it for "zeroes" and to stop at the first
occurrence of a "one"

Holy Mole, that seems like a contest winner how to do the job
with the most gates possible (altho a modern compiler will
optimize it down some)

Just half-adders.

Quote:

Just draw the K-map and loop the functions.

If you have that luxury.

Quote:

The problem tells us there are 8 bits, people

One thing, the problem doesn't specify: what is wanted when
the register contains 0 0 0 0 0 0 0 0

Wood


...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona Voice:(480)460-2350 | |
| E-mail Address at Website Fax:(480)460-2142 | Brass Rat |
| http://www.analog-innovations.com | 1962 |

I love to cook with wine. Sometimes I even put it in the food.
Back to top
Jim Thompson
Guest





Posted: Thu Dec 01, 2005 1:35 am    Post subject: Re: How to count zeros in registers? Reply with quote

On 30 Nov 2005 15:58:57 -0800, "Woody Brison" <woody_brison@yahoo.com>
wrote:

Quote:
Jim Thompson wrote:
On 29 Nov 2005 06:12:56 -0800, "Davy" <zhushenli@gmail.com> wrote:

Hi all,

reg[7:0] register;
The register contains data like
[0 0 0 1 0 1 0 1]
And I want to know the number of the zeros before the first 1
(in this example is 3 zeros).

How to do this in a combinational logic?

Best regards,
Davy

See...

http://www.analog-innovations.com/SED/HowManyOnes.pdf

You'll need to modify it for "zeroes" and to stop at the first
occurrence of a "one"

Holy Mole, that seems like a contest winner how to do the job
with the most gates possible (altho a modern compiler will
optimize it down some)

[snip]


The OP (for HowManyOnes) wanted to count ALL 1's, not just leading.

...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona Voice:(480)460-2350 | |
| E-mail Address at Website Fax:(480)460-2142 | Brass Rat |
| http://www.analog-innovations.com | 1962 |

I love to cook with wine. Sometimes I even put it in the food.

Back to top
Rich Grise
Guest





Posted: Thu Dec 01, 2005 9:35 am    Post subject: Re: How to count zeros in registers? Reply with quote

On Wed, 30 Nov 2005 17:35:47 -0700, Jim Thompson wrote:

Quote:
On 30 Nov 2005 15:58:57 -0800, "Woody Brison" <woody_brison@yahoo.com
wrote:

Jim Thompson wrote:
On 29 Nov 2005 06:12:56 -0800, "Davy" <zhushenli@gmail.com> wrote:

Hi all,

reg[7:0] register;
The register contains data like
[0 0 0 1 0 1 0 1]
And I want to know the number of the zeros before the first 1
(in this example is 3 zeros).

How to do this in a combinational logic?

Best regards,
Davy

See...

http://www.analog-innovations.com/SED/HowManyOnes.pdf

You'll need to modify it for "zeroes" and to stop at the first
occurrence of a "one"

Holy Mole, that seems like a contest winner how to do the job
with the most gates possible (altho a modern compiler will
optimize it down some)

[snip]

The OP (for HowManyOnes) wanted to count ALL 1's, not just leading.


I thought "before the first 1" meant "leading". ;-)

Here's the part:
http://pdf.alldatasheet.co.kr/datasheet-pdf/view/53747/FAIRCHILD/74HC148.html

Might have to invert the bits - this chip actually counts '1's.
Or you could do it in Xilinx schematic mode. ;-)

Cheers!
Rich
Back to top
Jasen Betts
Guest





Posted: Thu Dec 01, 2005 4:59 pm    Post subject: Re: How to count zeros in registers? Reply with quote

["Followup-To:" header set to sci.electronics.basics.]
On 2005-11-29, Davy <zhushenli@gmail.com> wrote:
Quote:
Hi all,

reg[7:0] register;
The register contains data like
[0 0 0 1 0 1 0 1]
And I want to know the number of the zeros before the first 1
(in this example is 3 zeros).

How to do this in a combinational logic?

what output do you want?




--

Bye.
Jasen
Back to top
Jim Thompson
Guest





Posted: Fri Dec 02, 2005 1:35 am    Post subject: Re: How to count zeros in registers? Reply with quote

On 1 Dec 2005 13:48:52 -0800, "Woody Brison" <woody_brison@yahoo.com>
wrote:

Quote:

Jim Thompson wrote:
On 30 Nov 2005 15:58:57 -0800, "Woody Brison" <woody_brison@yahoo.com
wrote:

Just draw the K-map and loop the functions.

If you have that luxury.

Yes... and I think the original poster has that luxury, I concur
that this looks a lot like homework. So what he's needing to
do is draw a K-map. I just wanted to steer him in the right
direction without doing it for him

By the way, code to draw K-maps is not too hard to write.
Collecting minterms isn't too far beyond that.
Reducing 'em isn't too far beyond that.
Having tools like that cuts the time down, bringing such luxuries
into reach of even the humble compiler user

Wood

I can still do 'em by hand but, now-a-days, I use KarnaughMap v4.4.5,
by Russell Sasamori... http://www.puz.com/sw/karnaugh/index.htm

...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC's and Discrete Systems | manus |
| Phoenix, Arizona Voice:(480)460-2350 | |
| E-mail Address at Website Fax:(480)460-2142 | Brass Rat |
| http://www.analog-innovations.com | 1962 |

I love to cook with wine. Sometimes I even put it in the food.
Back to top
Woody Brison
Guest





Posted: Fri Dec 02, 2005 1:35 am    Post subject: Re: How to count zeros in registers? Reply with quote

Jim Thompson wrote:
Quote:
On 30 Nov 2005 15:58:57 -0800, "Woody Brison" <woody_brison@yahoo.com
wrote:

Just draw the K-map and loop the functions.

If you have that luxury.

Yes... and I think the original poster has that luxury, I concur
that this looks a lot like homework. So what he's needing to
do is draw a K-map. I just wanted to steer him in the right
direction without doing it for him

By the way, code to draw K-maps is not too hard to write.
Collecting minterms isn't too far beyond that.
Reducing 'em isn't too far beyond that.
Having tools like that cuts the time down, bringing such luxuries
into reach of even the humble compiler user

Wood
Back to top
 
Post new topic   Reply to topic    Electronics Forum Index -> Basics All times are GMT
Goto page Previous  1, 2, 3
Page 3 of 3

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Home & Living New Topics
Powered by phpBB