Complete the code to declare a 4-bit register named 'reg_out'.
reg [1] reg_out;The declaration reg [3:0] reg_out; creates a 4-bit register named reg_out.
Complete the always block sensitivity list to trigger on the positive edge of clock 'clk'.
always @([1] clk) begin
// register logic
endThe sensitivity list posedge clk triggers the always block on the rising edge of the clock signal.
Fix the error in the register assignment inside the always block.
always @(posedge clk) begin
reg_out [1] data_in;
endNon-blocking assignment <= is used inside clocked always blocks to model flip-flops correctly.
Fill both blanks to complete the reset logic for the register (active high synchronous reset).
always @(posedge clk) begin if ([1]) begin reg_out [2] 4'b0000; end else begin reg_out <= data_in; end end
The reset signal is checked in the if condition, and the register is assigned zero using non-blocking assignment '<=' inside the always block.
Fill all three blanks to complete a parameterized register module with width 'WIDTH'.
module register #(parameter WIDTH = [1]) ( input wire clk, input wire reset, input wire [WIDTH-1:0] data_in, output reg [WIDTH-1:0] reg_out ); always @(posedge clk) begin if (reset) begin reg_out [2] [3]'b0; end else begin reg_out <= data_in; end end endmodule
The parameter WIDTH is set to 8 by default. The register uses non-blocking assignment '<=' to assign zero of WIDTH bits on reset.