Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a D flip-flop with asynchronous reset.
Verilog
module dff (input clk, input rst, input d, output reg q); always @(posedge clk or posedge rst) begin if ([1]) q <= 0; else q <= d; end endmodule
Attempts:
3 left
💡 Hint
Common Mistakes
Using clock signal instead of reset for reset condition.
✗ Incorrect
The asynchronous reset is triggered by the reset signal rst.
2fill in blank
mediumComplete the code to specify the setup time check in a timing constraint.
Verilog
specify
$setup(data, posedge clk, [1]);
endspecifyAttempts:
3 left
💡 Hint
Common Mistakes
Using signal names instead of time values.
✗ Incorrect
The setup time is specified as a delay value like 5ns.
3fill in blank
hardFix the error in the hold time check code below.
Verilog
specify
$hold(posedge clk, data, [1]);
endspecifyAttempts:
3 left
💡 Hint
Common Mistakes
Using signal or edge names instead of time values.
✗ Incorrect
The hold time is specified as a time value like 3ns, not a signal.
4fill in blank
hardFill both blanks to complete the timing check for setup and hold times.
Verilog
specify $setup(data, posedge clk, [1]); $hold(posedge clk, data, [2]); endspecify
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up setup and hold time values.
✗ Incorrect
Setup time is 5ns and hold time is 3ns in this example.
5fill in blank
hardFill all three blanks to create a D flip-flop with setup and hold time checks.
Verilog
module dff_timing (input clk, input d, output reg q);
always @(posedge clk) begin
q <= [1];
end
specify
$setup([2], posedge clk, 4ns);
$hold(posedge clk, [3], 2ns);
endspecify
endmoduleAttempts:
3 left
💡 Hint
Common Mistakes
Using output
q instead of input d for timing checks.✗ Incorrect
The flip-flop output q gets input d. Setup and hold checks are on d.
