Guest
Hello,
the clock divider from the FAQ is:
architecture Behavior of ClockDivider is
begin
process (ClkIn, Reset)
variable Count: Natural range 0 to Modulus-1;
begin
if Reset = '1' then
Count := 0;
ClkOut <= '0';
elsif ClkIn = '1' and ClkIn'event then
if Count = Modulus-1 then
Count := 0;
else
Count := Count + 1;
end if;
if Count >= Modulus/2 then
ClkOut <= '0';
else
ClkOut <= '1';
end if;
end if;
end process;
end Behavior;
In my simulation (ModelSim) the first '1' cycle of ClkOut is too short
by one ClkIn cycle.
Fixes for that:
- Initialize count with Modulus-1 in reset OR
- Count up _after_ ClkOut is set
I wonder why nobody came accross this problem. It's there quite
a long time.
I don't have information who is maintaining the FAQ and who could
fix this.
Bye,
Y
the clock divider from the FAQ is:
architecture Behavior of ClockDivider is
begin
process (ClkIn, Reset)
variable Count: Natural range 0 to Modulus-1;
begin
if Reset = '1' then
Count := 0;
ClkOut <= '0';
elsif ClkIn = '1' and ClkIn'event then
if Count = Modulus-1 then
Count := 0;
else
Count := Count + 1;
end if;
if Count >= Modulus/2 then
ClkOut <= '0';
else
ClkOut <= '1';
end if;
end if;
end process;
end Behavior;
In my simulation (ModelSim) the first '1' cycle of ClkOut is too short
by one ClkIn cycle.
Fixes for that:
- Initialize count with Modulus-1 in reset OR
- Count up _after_ ClkOut is set
I wonder why nobody came accross this problem. It's there quite
a long time.
I don't have information who is maintaining the FAQ and who could
fix this.
Bye,
Y