lbdcdrc
Newbie level 5

Hi all !
It's my first post here, so many thanks in advancy for any kind of help that you'll give =)
I working on a project based on an FPGA. One of the goals is to check a frequency (wich is different and lower than the main clock).
By surfing on this forum, I've decided to use 3 different entity the first, called "HundredusCounter" is written to get a a high level each 100us during one main clock period. Here is the code :
The second one is there to count the number of clock rising edge between two reset made by the previous bloc. Here is the code :
I then have putted a 12-bits D latch to keep the value between the 100 us. Here is the code :
At the end, I 've connected the blocks alltogether like this :

I really don't know why, but it doesn't work =/
I always have a 0 on Q...
I would be soooooo thanks-full if one of you could help me !
Cedric
It's my first post here, so many thanks in advancy for any kind of help that you'll give =)
I working on a project based on an FPGA. One of the goals is to check a frequency (wich is different and lower than the main clock).
By surfing on this forum, I've decided to use 3 different entity the first, called "HundredusCounter" is written to get a a high level each 100us during one main clock period. Here is the code :
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity HundredusCounter is
Port( clk : in STD_LOGIC;
nCEN : out STD_LOGIC);
end HundredusCounter;
architecture Behavioral of HundredusCounter is
signal timer : STD_LOGIC_VECTOR(11 downto 0) := "000000000000";
signal reset: STD_LOGIC;
begin
process (clk, reset)
begin
if clk='1' and clk'event then
if reset = '1' then
timer <= timer + 1;
reset <= '0';
elsif timer = "111110100000" then --111110100000 means 4000
timer <= "000000000000";
reset <= '1';
else
timer <= timer + 1;
end if;
end if;
end process;
nCEN <= reset;
end Behavioral;
The second one is there to count the number of clock rising edge between two reset made by the previous bloc. Here is the code :
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity FreqCounter is
Port( rf_in : in STD_LOGIC;
rst : in STD_LOGIC;
freqOut : out STD_LOGIC_VECTOR(10 downto 0):= "00000000000");
end FreqCounter;
architecture Behavioral of FreqCounter is
signal counter : STD_LOGIC_VECTOR(10 downto 0) := "00000000000";
begin
process (rf_in, rst)
begin
if rst='1' then
counter <= "00000000000";
elsif rf_in='1' and rf_in'event then
counter <= counter + '1';
end if;
freqOut <= counter;
end process;
end Behavioral;
I then have putted a 12-bits D latch to keep the value between the 100 us. Here is the code :
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity d_latch_12_top is
Port ( EN : in STD_LOGIC;
D : in STD_LOGIC_VECTOR(10 downto 0);
Q : out STD_LOGIC_vector(10 downto 0));
end d_latch_12_top;
architecture Behavioral of d_latch_12_top is
begin
process (EN, D)
begin
if (EN = '1') then
Q <= D;
end if;
end process;
end Behavioral;
At the end, I 've connected the blocks alltogether like this :

I really don't know why, but it doesn't work =/
I always have a 0 on Q...
I would be soooooo thanks-full if one of you could help me !
Cedric