Challenge - 5 Problems
Continuous Logic Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of continuous assignment with bitwise AND
What is the output of the following Verilog code snippet when a = 4'b1101 and b = 4'b1011?
Verilog
module test; reg [3:0] a = 4'b1101; reg [3:0] b = 4'b1011; wire [3:0] c; assign c = a & b; initial begin $display("c = %b", c); end endmodule
Attempts:
2 left
💡 Hint
Remember bitwise AND compares each bit of a and b.
✗ Incorrect
The bitwise AND of 1101 and 1011 is 1001 because only bits where both are 1 remain 1.
❓ Predict Output
intermediateContinuous assignment with ternary operator
What will be the value of wire y after the following code runs with sel = 1, in1 = 1'b0, and in2 = 1'b1?
Verilog
module mux_test; reg sel = 1'b1; reg in1 = 1'b0; reg in2 = 1'b1; wire y; assign y = sel ? in2 : in1; initial begin $display("y = %b", y); end endmodule
Attempts:
2 left
💡 Hint
The ternary operator chooses in2 when sel is 1.
✗ Incorrect
Since sel is 1, y is assigned in2 which is 1.
🔧 Debug
advancedIdentify the error in continuous assignment
What error will this Verilog code produce?
Verilog
module error_test; reg a = 1'b1; wire b; assign b = a + 1'b1; endmodule
Attempts:
2 left
💡 Hint
Check the width of the result of addition compared to wire b.
✗ Incorrect
Adding 1'b1 and 1'b1 results in 2 bits (2'b10), but b is only 1 bit wide, causing a width mismatch warning or error.
❓ Predict Output
advancedOutput of continuous assignment with concatenation
What is the output of wire z after this code runs with a = 2'b10 and b = 2'b01?
Verilog
module concat_test; reg [1:0] a = 2'b10; reg [1:0] b = 2'b01; wire [3:0] z; assign z = {a, b}; initial begin $display("z = %b", z); end endmodule
Attempts:
2 left
💡 Hint
Concatenation joins bits from left to right.
✗ Incorrect
Concatenating a=10 and b=01 results in 1001.
❓ Predict Output
expertValue of wire after continuous assignment with reduction operator
Given a = 4'b1011, what is the value of wire y after this code runs?
Verilog
module reduction_test; reg [3:0] a = 4'b1011; wire y; assign y = &a; initial begin $display("y = %b", y); end endmodule
Attempts:
2 left
💡 Hint
The & operator reduces all bits by ANDing them together.
✗ Incorrect
The bits of a are 1,0,1,1. ANDing all bits results in 0 because one bit is 0.
