Complete the code to declare a 4-bit register in Verilog.
reg [[1]:0] my_reg;
In Verilog, a 4-bit register is declared as reg [3:0] because counting starts from 0.
Complete the code to assign a value to a wire in Verilog.
assign my_wire = [1];The assign statement connects a wire to a value or expression. Here, 5'b10101 is a 5-bit binary constant.
Fix the error in the always block sensitivity list.
always @([1]) begin
q <= d;
endThe sensitivity list should use or to separate signals, and include edge keywords like posedge or negedge.
Fill both blanks to create a combinational always block that triggers on any input change.
always @([1]) begin y = a [2] b; end
The always @(*) block triggers on any input change, and y = a + b; adds the inputs combinationally.
Fill all three blanks to create a simple synchronous counter.
always @([1]) begin if ([2]) begin count <= 0; end else begin count <= count [3] 1; end end
The always block triggers on the positive edge of the clock. If reset (rst) is active, the counter resets to 0; otherwise, it increments by 1.
