Hi, I'm trying to make a frequency counter with displaying the result on LCD. I've been breaking my head on this one for almost a month now, can anybody take a look at it "from the side" and maybe see what mistakes I made. I shortened the program a bit so only 3 digits are supposed to be displayed(without the units), and this one does not work still.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
library UNISIM;
use UNISIM.VComponents.all;
entity fr_counter is
Port (
fr_in: in std_logic;
clkin:in std_logic;
EN

ut std_logic;
LCD: out std_logic_vector (9 downto 0) );
end fr_counter;
architecture Behavioral of fr_counter is
signal fr_in:std_logic;
type mem_data_init is array (0 to 5) of std_logic_vector (9 downto 0);
type mem_data_out is array (0 to 9) of std_logic_vector (9 downto 0);
type mem_show is array (0 to 11) of std_logic_vector (9 downto 0);
constant init: mem_data_init :=
( ("0000110000"),
("0000110000"),
("0000111000"),
("0000001100"),
("0000000110"),
("0000000001"));
constant num1: mem_data_out:=
(("1000110000"),--0
("1000110001"),--1
("1000110010"),--2
("1000110011"),--3
("1000110100"),--4
("1000110101"),--5
("1000110110"),--6
("1000110111"),--7
("1000111000"),--8
("1000111001") --9
);
constant num2: mem_data_out:=
(("1000110000"),--0
("1000110001"),--1
("1000110010"),--2
("1000110011"),--3
("1000110100"),--4
("1000110101"),--5
("1000110110"),--6
("1000110111"),--7
("1000111000"),--8
("1000111001") --9
);
constant num3: mem_data_out:=
(("1000110000"),--0
("1000110001"),--1
("1000110010"),--2
("1000110011"),--3
("1000110100"),--4
("1000110101"),--5
("1000110110"),--6
("1000110111"),--7
("1000111000"),--8
("1000111001") --9
);
-----------------------------------------------------------
signal count_bin:integer range 0 to 11;
signal timer: integer range 0 to 1011;
signal count_init: integer range 0 to 5;
signal count_ones: integer range 0 to 9;
signal count_tens: integer range 0 to 9;
signal count_hundreds: integer range 0 to 9;
signal count_show: integer range 1 to 3;
------------------------------------------------------------
signal CLK_COUNT : std_logic_vector(15 downto 0);
signal INT_CLK : std_logic;
signal clk:std_logic;
constant CLK_STOP : std_logic_vector(15 downto 0) := X"C350";
-------------------------------------------------------------
signal bin:mem_show;
begin
clk <= INT_CLK;
DIVIDE_CLOCK: process (CLKIN,count_bin)
begin
if rising_edge(CLKIN) then
-- Check to see if the count value has been met
if (CLK_COUNT = CLK_STOP) then
-- Flip the output clock signal
INT_CLK <= not INT_CLK;
-- Reset the count
CLK_COUNT <= X"0000";
else
-- Add 1 to the count
CLK_COUNT <= CLK_COUNT + X"0001";
end if;
end if;
if (count_bin=11) then
INT_CLK<='0';
end if;
end process DIVIDE_CLOCK; --Clock div 1KHz
process (clk,timer,count_show,count_bin)
begin
if rising_edge(clk) then
if (timer=1011) then
timer<=timer;
if (count_show=3) then
count_show<=1;
if (count_bin=11) then
count_bin<=11;
else count_bin<=count_bin+1;
end if;
else count_show<=count_show+1;
end if;
else timer<=timer+1;
end if;
case count_show is
when 1=> EN<='0';
when 2=> EN<='1';
when 3=>
LCD<=bin(count_bin);
end case;
end if;
end process;
process (fr_in,timer,count_ones,count_tens,count_hundreds)
begin
if rising_edge(FR_IN) then
if (timer=1000) then
count_ones<=count_ones;
count_tens<=count_tens;
count_hundreds<=count_hundreds;
end if;
if (count_ones=9 and count_tens=9 and count_hundreds=9) then
count_hundreds<=0;
count_tens<=0;
count_ones<=1;
elsif (count_ones=9) then
count_tens<=count_tens+1;
count_ones<=0;
elsif (count_tens=9) then
count_hundreds<=count_hundreds+1;
count_tens<=0;
else count_ones<=count_ones+1;
end if;
end if;
end process;
process (timer)
begin
if (timer=1000)then
bin(0)<= "0000110000";
bin(1)<= "0000110000";
bin(2)<= "0000111000";
bin(3)<= "0000001100";
bin(4)<= "0000000110";
bin(5)<= "0000000001";
bin(6)<= "0010000000";
bin(7)<= num1(count_hundreds);
bin(8)<= "0010000001";
bin(9)<=num2 (count_tens);
bin(10)<= "0010000010";
bin(11)<=num3 (count_ones);
end if;
end process;
end Behavioral;