golomb code

Joined
Nov 18, 2011
Messages
1
Reaction score
0
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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top