0
0
Verilogprogramming~20 mins

When to use blocking (combinational) in Verilog - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Blocking Assignment Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of combinational logic with blocking assignments
What is the output of the following Verilog code snippet when inputs a=1 and b=0?
Verilog
module test(input a, input b, output reg y);
  always @(*) begin
    y = a & b;
    y = y | a;
  end
endmodule
Ay = 1
By = 0
Cy = x (unknown)
DCompilation error
Attempts:
2 left
💡 Hint
Remember blocking assignments (=) execute statements in order inside always blocks.
Predict Output
intermediate
2:00remaining
Effect of blocking vs non-blocking in combinational logic
Given the following Verilog code, what is the value of y after execution if a=1 and b=0?
Verilog
module test(input a, input b, output reg y);
  always @(*) begin
    y <= a & b;
    y <= y | a;
  end
endmodule
Ay = 0
By = 1
CSimulation error
Dy = x (unknown)
Attempts:
2 left
💡 Hint
Non-blocking assignments (<=) update variables at the end of the time step.
🧠 Conceptual
advanced
2:00remaining
Why use blocking assignments for combinational logic?
Which reason best explains why blocking assignments (=) are preferred for combinational logic in Verilog?
ABecause blocking assignments automatically infer flip-flops.
BBecause blocking assignments delay updates until the end of the time step.
CBecause blocking assignments execute sequentially, reflecting combinational logic behavior accurately.
DBecause blocking assignments prevent race conditions in sequential logic.
Attempts:
2 left
💡 Hint
Think about how combinational logic works in hardware and how blocking assignments execute.
🔧 Debug
advanced
2:00remaining
Identify the problem with using non-blocking assignments in combinational logic
What issue arises if non-blocking assignments (<=) are used inside a combinational always block?
AThe output may hold old values causing incorrect combinational behavior.
BThe code will not compile due to syntax errors.
CThe synthesis tool will infer latches instead of combinational logic.
DThe simulation will run faster but produce correct results.
Attempts:
2 left
💡 Hint
Consider when non-blocking assignments update variables during simulation.
🚀 Application
expert
3:00remaining
Determine the number of items in the resulting dictionary after combinational blocking assignments
Consider the following Verilog-like pseudocode representing combinational logic with blocking assignments: always @(*) begin for (int i = 0; i < 3; i++) begin out[i] = in[i] & enable; end end If in = {1,0,1} and enable = 1, how many elements in out will be 1 after execution?
A3
B2
C1
D0
Attempts:
2 left
💡 Hint
Check each bit of in ANDed with enable=1.