Which of the following best describes the primary use of Verilog?
Think about hardware and electronics.
Verilog is mainly used to describe and simulate digital electronic circuits.
What will be the output of this Verilog module when input a is 1 and b is 0?
module simple_and(input a, input b, output y); assign y = a & b; endmodule
AND gate outputs 1 only if both inputs are 1.
The AND operation outputs 1 only when both inputs are 1. Here, a=1 and b=0, so output y=0.
What error will this Verilog code produce?
module error_example(input a, output reg y); always @ (a) begin if (a == 1) y = 1; else y = 0; end endmodule
Check the lines carefully for punctuation.
The else statement line is missing a semicolon at the end, causing a syntax error.
Which option shows the correct syntax to declare a Verilog module named my_module with inputs clk, rst and output out?
Modern Verilog allows declaring input/output types in the module header.
Option A uses the correct modern syntax with input and output declared in the module header.
Consider this Verilog code snippet:
module adder(input [3:0] a, input [3:0] b, output [4:0] sum); assign sum = a + b; endmodule
How many bits wide is the output sum and why?
Think about what happens when adding two 4-bit numbers.
Adding two 4-bit numbers can produce a 5-bit result to include carry out, so output sum is 5 bits wide.
