HOME VHDL CODES C PROGRAMS SOCCER BUZzz TECH INFO


--code for counting no of 1's using loop method:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity onesusingloop is
 port(d:in std_logic_vector(9 downto 0);
 count:out integer);
 end onesusingloop;

 architecture beh of onesusingloop is
 begin
 process(d)
 variable x:integer;
 begin
 x:=0;
 for i in 0 to 9 loop
 if(d(i)='1')then
 x:=x+1;
 end if;
 end loop;
 count<=x;
 end process;
 end beh;

The above code has been executed and has been found to have no errors..!  
plz do comment..!
thank u..!! :) :)

0 comments:

Post a Comment

Total Pageviews

About this blog

Contributors

Followers

Powered by Blogger.

Labels