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 the index starts at 0.
Complete the code to assign a value to a register inside an always block for simulation.
always @(posedge clk) begin
[1] <= data_in;
endInside an always block, you assign values to registers directly by their name, here my_reg.
Fix the error in the code to make it synthesizable: a combinational always block.
always @([1]) begin
out = a & b;
endFor combinational logic, the sensitivity list must include all inputs, here a or b.
Fill both blanks to complete a synthesizable flip-flop with asynchronous reset.
always @([1] or [2]) begin if (!reset) out <= 0; else out <= d; end
The flip-flop triggers on the rising edge of the clock and the falling edge of the asynchronous reset.
Fill all three blanks to create a dictionary-like mapping using a case statement for synthesis.
always @(*) begin
case (addr)
2'b00: data = [1];
2'b01: data = [2];
default: data = [3];
endcase
endThe case statement assigns different 8-bit hex values based on the address input.
