0
0
Verilogprogramming~10 mins

Why flip-flops are the basis of memory in Verilog - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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 [1]) begin
    if (rst)
      q <= 0;
    else
      q <= d;
  end
endmodule
Drag options to blanks, or click blank then click option'
Arst
Bclk
Cd
Dq
Attempts:
3 left
💡 Hint
Common Mistakes
Using clock signal instead of reset in sensitivity list.
Forgetting to include reset in sensitivity list.
2fill in blank
medium

Complete the code to assign the output of the flip-flop.

Verilog
always @(posedge clk) begin
  q <= [1];
end
Drag options to blanks, or click blank then click option'
Arst
Bclk
Cd
Dq
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning clock or reset to output.
Assigning output to itself inside always block.
3fill in blank
hard

Fix the error in the sensitivity list to make the flip-flop work correctly.

Verilog
always @([1]) begin
  if (rst)
    q <= 0;
  else
    q <= d;
end
Drag options to blanks, or click blank then click option'
Anegedge clk or posedge rst
Bnegedge rst
Cposedge clk
Dposedge clk or posedge rst
Attempts:
3 left
💡 Hint
Common Mistakes
Using only clock or only reset in sensitivity list.
Using negative edge for reset instead of positive edge.
4fill in blank
hard

Fill both blanks to create a flip-flop that stores data on the rising clock edge and resets asynchronously.

Verilog
always @([1] or [2]) begin
  if (rst)
    q <= 0;
  else
    q <= d;
end
Drag options to blanks, or click blank then click option'
Aposedge clk
Bnegedge clk
Cposedge rst
Dnegedge rst
Attempts:
3 left
💡 Hint
Common Mistakes
Using falling edge for clock or reset.
Not including both signals in sensitivity list.
5fill in blank
hard

Fill all three blanks to create a module that stores data on clock edge, resets asynchronously, and outputs the stored value.

Verilog
module dff (input [1], input [2], input d, output reg [3]);
  always @(posedge clk or posedge rst) begin
    if (rst)
      q <= 0;
    else
      q <= d;
  end
endmodule
Drag options to blanks, or click blank then click option'
Aclk
Brst
Cq
Dd
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing input and output names.
Using data input name as output.