In large Verilog designs, why is hierarchy important?
Think about how breaking a big task into smaller parts helps you understand it better.
Hierarchy breaks a large design into smaller modules, making it easier to develop, debug, and maintain.
What is the output of the following Verilog code when top module is simulated?
module adder(input wire a, input wire b, output wire sum); assign sum = a ^ b; endmodule module top; reg x = 1'b1; reg y = 1'b0; wire s; adder u1(.a(x), .b(y), .sum(s)); initial begin #1 $display("Sum = %b", s); end endmodule
Recall that XOR of 1 and 0 is 1.
The adder module outputs the XOR of inputs a and b. Since a=1 and b=0, sum=1.
What error will occur when compiling this Verilog code?
module child(input wire a, output wire b);
assign b = ~a;
endmodule
module parent;
wire w;
child u1(.a(x), .b(w));
endmoduleCheck if all signals used in module instantiations are declared.
The parent module instantiates child with input 'x' which is not declared anywhere, causing a compilation error.
Which option shows the correct way to instantiate a module foo with ports in and out inside another module?
Remember Verilog uses dot and parentheses for named port connections.
Option C uses correct named port mapping syntax: dot followed by port name and parentheses with signal.
A top-level module instantiates 3 submodules. Each submodule instantiates 2 sub-submodules. How many total modules are instantiated in the design?
3 submodules + 3*2 sub-submodules = 9.
The top-level instantiates 3 submodules, and each of those instantiates 2 sub-submodules, for a total of 3 + 6 = 9 instantiated modules. The top-level itself is not instantiated by any other module.
