Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare the D flip-flop module with synchronous reset.
Verilog
module dff_sync_reset(input clk, input reset, input d, output reg q); always @(posedge [1]) begin if (reset) q <= 0; else q <= d; end endmodule
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reset' instead of 'clk' in the sensitivity list.
Using 'd' or 'q' in the sensitivity list which is incorrect.
✗ Incorrect
The flip-flop triggers on the positive edge of the clock signal 'clk'.
2fill in blank
mediumComplete the code to assign the output 'q' when reset is active.
Verilog
always @(posedge clk) begin if (reset) q <= [1]; else q <= d; end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting 'q' to 1 instead of 0 on reset.
Assigning 'q' to 'd' or 'q' inside the reset condition.
✗ Incorrect
When reset is active, the output 'q' is set to 0 synchronously.
3fill in blank
hardFix the error in the sensitivity list to make the reset synchronous.
Verilog
always @([1]) begin if (reset) q <= 0; else q <= d; end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including reset in the sensitivity list, which makes reset asynchronous.
Using 'negedge reset' which is asynchronous.
✗ Incorrect
For synchronous reset, the always block triggers only on the clock's positive edge.
4fill in blank
hardFill both blanks to complete the module declaration and output definition.
Verilog
module dff_sync_reset([1], output reg [2]); input clk, reset, d; always @(posedge clk) begin if (reset) q <= 0; else q <= d; end endmodule
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Declaring 'q' as input instead of output.
Forgetting to declare inputs properly.
✗ Incorrect
The module inputs are declared as 'input clk, reset, d' and output 'q' is declared as 'output reg q'.
5fill in blank
hardFill all three blanks to complete the always block with synchronous reset and data assignment.
Verilog
always @([1]) begin if ([2]) q <= 0; else q <= [3]; end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'posedge reset' in sensitivity list which makes reset asynchronous.
Assigning 'q' to 'reset' or 'clk' instead of 'd'.
✗ Incorrect
The always block triggers on 'posedge clk', checks 'reset' condition, and assigns 'd' to 'q' otherwise.