Hint: Output width matches submodule port width [OK]
Common Mistakes:
Assuming output width equals input width
Ignoring declared wire width in top module
Confusing bit ranges like [4:0] as 4 bits
4. Identify the error in this top module integration code:
module adder(input [3:0] a, input [3:0] b, output [4:0] sum);
assign sum = a + b;
endmodule
module top();
wire [4:0] result;
wire [3:0] x = 4'b0011;
wire [3:0] y = 4'b0101;
adder add_inst(.a(x), .b(y), .sum(sum));
endmodule
medium
A. Incorrect bit width for 'result'
B. Module 'adder' is missing ports
C. Signal 'sum' is not declared in top module
D. Instance name 'add_inst' is invalid
Solution
Step 1: Check port connections in top module
The instance connects .sum(sum), but sum is not declared in top module.
Step 2: Verify declared signals
Only result is declared as 5-bit wire, but not sum.
Final Answer:
Signal 'sum' is not declared in top module -> Option C
Quick Check:
Port connection must match declared signals [OK]
Hint: Check all connected signals are declared in top module [OK]
Common Mistakes:
Using undeclared signals in port connections
Assuming instance names affect correctness
Ignoring port width mismatches
5. You want to integrate two modules, counter and display, in a top module. The counter outputs a 4-bit count signal, and display takes a 4-bit input to show the count. Which of the following top module code snippets correctly connects these modules?