Concept Flow - D flip-flop with asynchronous reset
Start
Check Reset
Set Q=0
Q <= D input
End
The flip-flop first checks if reset is active; if yes, output Q is cleared immediately. Otherwise, on the rising clock edge, Q takes the value of D.
process(clk, reset) begin if reset = '1' then Q <= '0'; elsif rising_edge(clk) then Q <= D; end if; end process;
| Step | reset | clk | D | Condition Checked | Action | Q (Output) |
|---|---|---|---|---|---|---|
| 1 | 0 | 0 | 0 | reset='1'? No | No reset, wait clock | Q=initial (unknown) |
| 2 | 0 | 1 (rising) | 1 | reset='1'? No; rising_edge(clk)? Yes | Q <= D (1) | Q=1 |
| 3 | 1 | 1 | 0 | reset='1'? Yes | Q <= 0 (async reset) | Q=0 |
| 4 | 0 | 0 | 1 | reset='1'? No; rising_edge(clk)? No | Hold Q | Q=0 |
| 5 | 0 | 1 (rising) | 0 | reset='1'? No; rising_edge(clk)? Yes | Q <= D (0) | Q=0 |
| 6 | 0 | 0 | 1 | reset='1'? No; rising_edge(clk)? No | Hold Q | Q=0 |
| 7 | 0 | 1 (rising) | 1 | reset='1'? No; rising_edge(clk)? Yes | Q <= D (1) | Q=1 |
| 8 | 0 | 0 | 0 | reset='1'? No; rising_edge(clk)? No | Hold Q | Q=1 |
| 9 | 1 | 0 | 1 | reset='1'? Yes | Q <= 0 (async reset) | Q=0 |
| 10 | 0 | 1 (rising) | 1 | reset='1'? No; rising_edge(clk)? Yes | Q <= D (1) | Q=1 |
| Variable | Start | After 1 | After 2 | After 3 | After 4 | After 5 | After 6 | After 7 | After 8 | After 9 | After 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| reset | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
| clk | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 1 |
| D | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 1 |
| Q | unknown | unknown | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
D flip-flop with asynchronous reset in VHDL:
process(clk, reset)
begin
if reset = '1' then
Q <= '0'; -- async reset
elsif rising_edge(clk) then
Q <= D; -- capture D on clock
end if;
end process;D flip-flop?process(clk, reset)
begin
if reset = '1' then
q <= '0';
elsif rising_edge(clk) then
q <= d;
end if;
end process;reset is '0', d is '1', and a rising edge on clk occurs, what will be the value of q?process(clk)
begin
if reset = '1' then
q <= '0';
elsif rising_edge(clk) then
q <= d;
end if;
end process;q to '0' immediately when reset is '1', and otherwise updates q with d on the rising edge of clk. Which VHDL process correctly implements this behavior and avoids unintended latches?Pass the test and this pattern moves unknown