Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

counting number of 1 s

Status
Not open for further replies.

ASIC_intl

Banned
Joined
Jan 18, 2008
Messages
260
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
0
Suppose a bitstream is coming. Can you think of a circuit that will be able to tell the number of logic '1' s in the bit stream?
 

if ( input == 1 )
counter = counter + 1
else
counter = counter
---
 

Suppose your first four bits are 1110 in your bitstream. The output of the desired circuit will be 3. Now you have done input ==1. Here the input remains 1 for the first three bits. So in this case you will count 1 instead of 3.

Can you please reply interms of architectures rather than codes?
 

Well.. you could use the data signal as a mask for the clock by logically ANDing your data signal with the clock and use the resulting signal as a "clock" for a counter. So, when the data signal is '1', the clock will pass (in your case, three '1's'), but when the data signal is low, it will mask the clock and provide no output, hence, the counter will not count up.
 

Hi Korgull

How will you decide about the frequency of the clock to detect the total number of '1' s in any bit pattern coming?
 

ASIC_intl said:
How will you decide about the frequency of the clock to detect/.../
if you have no clock validates bits or do not know the bit rate
[to create the clock on board]
there is no way to distinguish between a series of [let's say] two 1's
coming with 20MHz and ten 1's with 100MHz;
at least I don't know how this can be done;
---
 

ASIC_intl said:
Hi Korgull

How will you decide about the frequency of the clock to detect the total number of '1' s in any bit pattern coming?

It was my assumption that you were clocking in data to begin with, so I would just use that clock. If it is just a random signal with no clock associated with it, then I have no idea how you would do it as you need some frame of reference to begin with.
 

In case of asynchronous signals, I believe it is OK to count number of positive going edges of the input signal in order to count the number of ones (i.e. number of times the input goes high).

Any other thoughts?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top