Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   VHDL (http://www.velocityreviews.com/forums/f18-vhdl.html)
-   -   golomb code (http://www.velocityreviews.com/forums/t806097-golomb-code.html)

s.arthi 11-20-2011 01:33 PM

golomb code
 
how to write the vhdl code for run's of zeroes end with 1...

eg:0001
should written as 3

the code which i ve tried is,

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity sample is
port( b0: inout std_logic_vector(13 downto 0):="10110000000010";
count0: out std_logic_vector(13 downto 0);
count1: out bit;
reset,clk: in std_logic);
end sample;

architecture beh of sample is
signal a0: std_logic_vector(13 downto 0);
--constant c: integer := 1;

begin
process(clk,reset)
variable cnt0 : std_logic_vector(13 downto 0);--:=(others=>'0');
variable cnt1 : std_logic;

begin
if reset='0' then
a0<=(others=>'0');
elsif clk='1' and clk'event then
a0<=b0;

end if;
cnt0:=(others=>'0');
for i in 0 to 13 loop
if a0(i) = '0' then
cnt0:= cnt0 + 1;
end if;
if a0(i) ='1' then
cnt1 := '1';
end if;
end loop;
count0 <= cnt0;
count1 <= '1';
end process;
end;


All times are GMT. The time now is 01:41 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.