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.

Give me some advice about this circuit

Status
Not open for further replies.

owen_li

Full Member level 3
Joined
Jul 22, 2007
Messages
150
Helped
17
Reputation
34
Reaction score
15
Trophy points
1,298
Activity points
2,301
Now, give you an input. It is 32 bit width. Ask you give the zero count from the beginning of the data. For example. If the input is 32'b0000_0001xxxxxx, then the
output is 7. If the input is 32'b0000_00001xxxxx, then the output is 8. Please give me some advice. Thank you!
 

Code:
process(data)
variable count_var : std_logic_vector(4 downto 0);
begin
count_var := (others => '0');
for i in 31 downto 0 loop
  if(data(i) = '0') then
    count_var := count_var + 1
  else
    exit
  end if;
end loop;
count_sig <= count_var;
end process;

Hope It helps,
Kr,
Avi
http://www.vlsiip.com
 

Hi ..

Excellent code from Amit.

But I am making a small change to the above code.

Insted of " for i in 31 downto 0 loop;

i make it as "for i in 0 to 31 loop;"

Hope it helps.

Thanks
 

Hi,
what if all the zeroes in the input are to be counted?
I think removing 'exit' will do.
Whats say?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top