D
Dave Dean
Guest
I'm investigating the synthesis results of several different coding
techniques for an asynchronous reset, and was hoping to get some feedback,
particularly regarding the last method, which seems to work but I've never
seen used before. Anyway...
Method 1:
process(clk, reset)
begin
if (reset = '1') then
Q(0) <= '0';
Q(1) <= '0';
elsif (rising_edge(clk)) then
Q(0) <= D(0);
Q(1) <= D(1);
end if;
end process;
This results in two identical flip-flops, each with an asynchronous CLEAR
input. Good!
Method 2:
process(clk, reset)
begin
if (reset = '1') then
Q(0) <= '0';
--no reset for Q(1);
elsif (rising_edge(clk)) then
Q(0) <= D(0);
Q(1) <= D(1);
end if;
end process;
For Q(0), this results in the same flip-flop as method 1. For Q(1),
however, I get a flip-flop with no CLEAR input, but instead /reset is used
as a CE input. This makes sense, considering how the reset was coded.
Also, this is a fairly harmless result. I want reset to clear Q(0), and
have no effect on Q(1). Even with my accidental CE, my result will work.
But suppose I want to get rid of the CE? This would work:
Method 3:
process(clk, reset)
begin
if (reset = '1') then
Q(0) <= '0';
elsif (rising_edge(clk)) then
Q(0) <= D(0);
end if;
end process;
process(clk)
begin
if (rising_edge(clk)) then
Q(1) <= D(1);
end if;
end process;
This gives me what I really want. The same flip-flop again for Q(0), and a
flip-flop for Q(1) with no CLEAR or CE inputs.
Now, suppose I've already written up a fairly complex state machine in a
single process. However, I only want an asynchronous reset for the state
itself and a small handfull of registered outputs. One soultion, of course,
is to seperate the process into two - one with a reset for the registers
that need them, and one with no reset (like Method 3). The problem is, I
don't want to do that. It would become messy and too succeptible to
mistakes. But what about this solution (the one that seems to work but I've
never seen anywhere else)...
Method 5:
process(clk, reset)
begin
if (rising_edge(clk)) then
Q(0) <= D(0);
Q(1) <= D(1);
end if;
if (reset = '1') then
Q(0) <= '0';
end if;
end process;
This gives me exactly what I want - Q(0) gets an asynchronous reset, and
Q(1) has no clear or ce inputs.
The issue is - this frightens me because I've never seen it done this way,
and if it was a good technique, I would probably have seen someone do it
before.
Has anyone else ever tried writing a reset like this before?
Thanks,
Dave
techniques for an asynchronous reset, and was hoping to get some feedback,
particularly regarding the last method, which seems to work but I've never
seen used before. Anyway...
Method 1:
process(clk, reset)
begin
if (reset = '1') then
Q(0) <= '0';
Q(1) <= '0';
elsif (rising_edge(clk)) then
Q(0) <= D(0);
Q(1) <= D(1);
end if;
end process;
This results in two identical flip-flops, each with an asynchronous CLEAR
input. Good!
Method 2:
process(clk, reset)
begin
if (reset = '1') then
Q(0) <= '0';
--no reset for Q(1);
elsif (rising_edge(clk)) then
Q(0) <= D(0);
Q(1) <= D(1);
end if;
end process;
For Q(0), this results in the same flip-flop as method 1. For Q(1),
however, I get a flip-flop with no CLEAR input, but instead /reset is used
as a CE input. This makes sense, considering how the reset was coded.
Also, this is a fairly harmless result. I want reset to clear Q(0), and
have no effect on Q(1). Even with my accidental CE, my result will work.
But suppose I want to get rid of the CE? This would work:
Method 3:
process(clk, reset)
begin
if (reset = '1') then
Q(0) <= '0';
elsif (rising_edge(clk)) then
Q(0) <= D(0);
end if;
end process;
process(clk)
begin
if (rising_edge(clk)) then
Q(1) <= D(1);
end if;
end process;
This gives me what I really want. The same flip-flop again for Q(0), and a
flip-flop for Q(1) with no CLEAR or CE inputs.
Now, suppose I've already written up a fairly complex state machine in a
single process. However, I only want an asynchronous reset for the state
itself and a small handfull of registered outputs. One soultion, of course,
is to seperate the process into two - one with a reset for the registers
that need them, and one with no reset (like Method 3). The problem is, I
don't want to do that. It would become messy and too succeptible to
mistakes. But what about this solution (the one that seems to work but I've
never seen anywhere else)...
Method 5:
process(clk, reset)
begin
if (rising_edge(clk)) then
Q(0) <= D(0);
Q(1) <= D(1);
end if;
if (reset = '1') then
Q(0) <= '0';
end if;
end process;
This gives me exactly what I want - Q(0) gets an asynchronous reset, and
Q(1) has no clear or ce inputs.
The issue is - this frightens me because I've never seen it done this way,
and if it was a good technique, I would probably have seen someone do it
before.
Has anyone else ever tried writing a reset like this before?
Thanks,
Dave