stewij
Newbie level 5
error (10344): vhdl
Hello all,
I am looking for a solution for my problem.
I have 2 inputs, CLK_IN and SYNC, and 1 output, CLK_OUT
What I want is a clockdivider with a variable divide.
My CLK_IN is 24 MHz
My SYNC is between 1 and 200 Hz
My CLK_OUT must give 4096 pulses between 2 rising edges of the SYNC signal. So maybe someone can help me with that. This is what I already created but doesn't seem to work.
Thanks in advance
Stefan Wijdeven
Hello all,
I am looking for a solution for my problem.
I have 2 inputs, CLK_IN and SYNC, and 1 output, CLK_OUT
What I want is a clockdivider with a variable divide.
My CLK_IN is 24 MHz
My SYNC is between 1 and 200 Hz
My CLK_OUT must give 4096 pulses between 2 rising edges of the SYNC signal. So maybe someone can help me with that. This is what I already created but doesn't seem to work.
Thanks in advance
Stefan Wijdeven
Code:
LIBRARY IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY DIVIDER IS
PORT(
CLK_IN : IN std_logic;
SYNC : IN std_logic;
CLK_OUT : OUT std_logic
);
END DIVIDER;
-- START DIVIDER
ARCHITECTURE RTL of DIVIDER is
signal i : integer range 0 to 24000000; -- 25 bit
signal j : integer range 0 to 5860; -- max divide at 1 hz
signal k : integer range 0 to 5860;
begin
process(CLK_IN) begin
if rising_edge(CLK_IN) then
i <= i +1;
end if;
end process;
process(CLK_IN, SYNC) begin
if rising_edge(SYNC) then
j <= i / 4096;
-- RESET i
end if;
end process;
process(CLK_IN) begin
if rising_edge(CLK_REF) then
if k = 0 then
CLK_OUT <= '1';
k <= j;
-- RESET j
else
CLK_OUT <= '0';
k <= k -1;
end if;
end if;
end process;
end RTL;