Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a module named ALU.
Verilog
module [1] (input [3:0] A, input [3:0] B, input [2:0] Op, output reg [3:0] Result); endmodule
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different module name than ALU.
✗ Incorrect
The module name must be ALU as specified.
2fill in blank
mediumComplete the code to instantiate the adder module inside the ALU.
Verilog
adder add1(.A(A), .B(B), .Sum([1]));Attempts:
3 left
💡 Hint
Common Mistakes
Connecting to a non-existent signal like Sum or Output.
✗ Incorrect
The adder output should connect to the ALU's Result signal.
3fill in blank
hardFix the error in the always block sensitivity list.
Verilog
always @([1]) begin case(Op) 3'b000: Result = A + B; 3'b001: Result = A - B; default: Result = 4'b0000; endcase end
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'or' or logical AND operators instead of commas.
✗ Incorrect
The sensitivity list must use commas to separate signals: A, B, Op.
4fill in blank
hardFill both blanks to complete the ALU operation selection using case statement.
Verilog
always @([1]) begin case([2]) 3'b000: Result = A + B; 3'b001: Result = A - B; 3'b010: Result = A & B; 3'b011: Result = A | B; default: Result = 4'b0000; endcase end
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong signals in sensitivity list or case expression.
✗ Incorrect
The always block sensitivity list must include A, B, Op, and the case statement must switch on Op.
5fill in blank
hardFill all three blanks to define the ALU module ports correctly.
Verilog
module ALU(input wire [3:0] [1], input wire [3:0] [2], input wire [2:0] [3], output reg [3:0] Result); endmodule
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or inconsistent port names.
✗ Incorrect
The ALU inputs are named A, B, and Op as per convention.
