0
0
Verilogprogramming~10 mins

When to use blocking (combinational) in Verilog - Interactive Code Practice

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

Complete the code to assign the output as the AND of inputs using blocking assignment.

Verilog
always @(*) begin
  out = [1] & b;
end
Drag options to blanks, or click blank then click option'
Aa
Bout
Cc
Dd
Attempts:
3 left
💡 Hint
Common Mistakes
Using the output variable on the right side causes incorrect logic.
Using non-input variables in the expression.
2fill in blank
medium

Complete the code to use blocking assignment for combinational logic that sums two inputs.

Verilog
always @(*) begin
  sum = [1] + b;
end
Drag options to blanks, or click blank then click option'
Aa
Bc
Cd
Dsum
Attempts:
3 left
💡 Hint
Common Mistakes
Using the output variable on the right side.
Using a variable not declared as input.
3fill in blank
hard

Fix the error in the combinational block by choosing the correct blocking assignment variable.

Verilog
always @(*) begin
  [1] = a & b;
  c = [1] | d;
end
Drag options to blanks, or click blank then click option'
Ad
Bc
Ca
Dtemp
Attempts:
3 left
💡 Hint
Common Mistakes
Using output variable c on the left side before it is assigned.
Using input variables incorrectly.
4fill in blank
hard

Fill both blanks to create a combinational block that calculates sum and carry using blocking assignments.

Verilog
always @(*) begin
  [1] = a ^ b;
  [2] = a & b;
end
Drag options to blanks, or click blank then click option'
Asum
Bcarry
Ctemp
Dresult
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up sum and carry variables.
Using non-blocking assignments in combinational logic.
5fill in blank
hard

Fill all three blanks to write a combinational block that computes max, min, and mid values using blocking assignments.

Verilog
always @(*) begin
  [1] = (a > b) ? a : b;
  [2] = (a < b) ? a : b;
  [3] = (a != b) ? ([1] + [2]) >> 1 : a;
end
Drag options to blanks, or click blank then click option'
Amax_val
Bmin_val
Cmid_val
Dtemp
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-blocking assignments in combinational blocks.
Mixing variable names or forgetting to assign all outputs.