V
Volker
Guest
Hi,
following entity should divide a 50 MHz clock into 8khz, 2Hz and 1 Hz. In
principle it would work, but 2 Hz clock is 1 Hz and the duty cycle ist about
30/70. If I check Q23 is OK but Q24 and Q25 not. In RTL view the
implementation of Q24 and Q25 looks a little bit strange. Did anyone know
how the design ist not working well?
Thanks
Volker
Code:
-- DIV_COUNTER is a VHDL Design
--
-- Author: V.Meiss
--
-- Version 1.0 from 13.08.2008
-- Altera QuartusII 8.0 SP1
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
entity DIV_COUNTER is
port(CLK : in STD_LOGIC;
CLK1, CLK2, CLK8k : out STD_LOGIC);
end DIV_COUNTER;
architecture BEHAVIOR of DIV_COUNTER is
signal Q : std_logic_vector(25 downto 0);
signal LOAD : STD_LOGIC;
begin
process(CLK, LOAD)
constant PRESET : NATURAL :=50000000; -- input 50 MHz
begin
if (LOAD = '0') then
Q <= CONV_STD_LOGIC_VECTOR(PRESET, 26);
LOAD <= '1';
elsif (CLK'EVENT and CLK='1') then
Q <= Q - 1;
end if;
if (Q = "00000000000000000000000000") then
LOAD <= '0';
end if;
CLK1 <= Q(25); -- 1HZ CLK
CLK2 <= Q(24); -- 2HZ CLK
CLK8k <= Q(12);-- 8 kHZ CLK
end process;
end BEHAVIOR;
following entity should divide a 50 MHz clock into 8khz, 2Hz and 1 Hz. In
principle it would work, but 2 Hz clock is 1 Hz and the duty cycle ist about
30/70. If I check Q23 is OK but Q24 and Q25 not. In RTL view the
implementation of Q24 and Q25 looks a little bit strange. Did anyone know
how the design ist not working well?
Thanks
Volker
Code:
-- DIV_COUNTER is a VHDL Design
--
-- Author: V.Meiss
--
-- Version 1.0 from 13.08.2008
-- Altera QuartusII 8.0 SP1
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
entity DIV_COUNTER is
port(CLK : in STD_LOGIC;
CLK1, CLK2, CLK8k : out STD_LOGIC);
end DIV_COUNTER;
architecture BEHAVIOR of DIV_COUNTER is
signal Q : std_logic_vector(25 downto 0);
signal LOAD : STD_LOGIC;
begin
process(CLK, LOAD)
constant PRESET : NATURAL :=50000000; -- input 50 MHz
begin
if (LOAD = '0') then
Q <= CONV_STD_LOGIC_VECTOR(PRESET, 26);
LOAD <= '1';
elsif (CLK'EVENT and CLK='1') then
Q <= Q - 1;
end if;
if (Q = "00000000000000000000000000") then
LOAD <= '0';
end if;
CLK1 <= Q(25); -- 1HZ CLK
CLK2 <= Q(24); -- 2HZ CLK
CLK8k <= Q(12);-- 8 kHZ CLK
end process;
end BEHAVIOR;