Complete the code to declare a 4-bit register named 'data_reg'.
reg [[1]:0] data_reg;
The register is 4 bits wide, so the index goes from 3 down to 0.
Complete the code to assign the sum of 'a' and 'b' to 'result' using a shared adder.
assign result = a [1] b;The '+' operator adds the two inputs 'a' and 'b'.
Fix the error in the always block sensitivity list to optimize resource sharing.
always @([1]) begin
sum <= a + b;
endUsing 'posedge clk' ensures the block triggers on clock edge, enabling synchronous resource sharing.
Fill both blanks to create a shared multiplier module instance with inputs 'x' and 'y'.
multiplier mul_inst(.[1](x), .[2](y));
The multiplier module expects inputs named 'a' and 'b' to connect to 'x' and 'y'.
Fill all three blanks to implement a resource sharing logic that selects between addition and subtraction.
assign result = sel ? a [1] b : a [2] b; always @(posedge clk) begin stored_result <= result [3] 1; end
The code uses '+' when sel is true, '-' when false, and increments stored_result with '+'.
