Complete the code to declare the SPI clock signal.
reg [1]; // SPI clock signalThe SPI clock signal is commonly named spi_clk for clarity.
Complete the code to assign the SPI clock output to the internal clock signal.
assign spi_sck = [1];clk directly.The SPI clock output spi_sck should be assigned from the internal SPI clock signal spi_clk.
Fix the error in the always block sensitivity list to trigger on the positive edge of the system clock.
always @(posedge [1] or negedge rst_n) begin
spi_clk instead of system clock clk.The always block should trigger on the positive edge of the system clock clk and asynchronous reset rst_n.
Fill both blanks to complete the SPI shift register update and bit counter increment.
shift_reg <= {shift_reg[6:0], mosi};
bit_count <= bit_count [1] 1;The shift register shifts left by adding the new bit at the right, and the bit counter increments by 1.
Fill all three blanks to complete the SPI controller state machine transitions.
case(state) IDLE: if(start) state <= [1]; TRANSFER: if(bit_count == 8) state <= [2]; DONE: state <= [3]; endcase
The state machine moves from IDLE to TRANSFER on start, then to DONE after 8 bits, and back to IDLE after done.
