F
fl
Guest
Hi,
I remember that it is said that if must have an else to avoid latch in the
synthesis process. I just begin working on a new, would-be large project.
In order to do it gradually, I do a pure functional simulation first.
The following code works for the simulation, but I don't find a way to add
else for the if loop having '**' lines.
The intention is to make the counter begins after an external signal 'start'
changes to '1', which is expected the pulse width is just one clock cycle.
When 'start' is '1', the last cnt <= cnt+1 runs. Then, 'start' is '0', but
cnt /= x"00". The first cnt <= cnt+1 will run.
Perhaps you expects have better idea to write this, even if my code works.
I would rather to hear from you.
Thanks,
............................
type START01 is range 0 to 1 ;
signal start_var : START01 := 0;
signal cnt : unsigned(7 downto 0) := (others => '0');
start_var <= start;
p_start: process (clk, reset)
begin
if (clk'event and clk = '1') then
if reset = '1' then
cnt <= x"00";
elsif start_var = 0 then
** if cnt /= x"00" then
cnt <= cnt + 1;
** end if;
else
cnt <= cnt + 1;
end if;
end if;
end process;
I remember that it is said that if must have an else to avoid latch in the
synthesis process. I just begin working on a new, would-be large project.
In order to do it gradually, I do a pure functional simulation first.
The following code works for the simulation, but I don't find a way to add
else for the if loop having '**' lines.
The intention is to make the counter begins after an external signal 'start'
changes to '1', which is expected the pulse width is just one clock cycle.
When 'start' is '1', the last cnt <= cnt+1 runs. Then, 'start' is '0', but
cnt /= x"00". The first cnt <= cnt+1 will run.
Perhaps you expects have better idea to write this, even if my code works.
I would rather to hear from you.
Thanks,
............................
type START01 is range 0 to 1 ;
signal start_var : START01 := 0;
signal cnt : unsigned(7 downto 0) := (others => '0');
start_var <= start;
p_start: process (clk, reset)
begin
if (clk'event and clk = '1') then
if reset = '1' then
cnt <= x"00";
elsif start_var = 0 then
** if cnt /= x"00" then
cnt <= cnt + 1;
** end if;
else
cnt <= cnt + 1;
end if;
end if;
end process;