Complete the code to declare a memory block of 8 bits wide and 16 words deep.
reg [7:0] memory [0:[1]];
The memory block has 16 words, indexed from 0 to 15, so the highest index is 15.
Complete the code to read data from memory at address 'addr'.
assign data_out = memory[[1]];The address 'addr' is used to index the memory to read the data.
Fix the error in the code to write data to memory on the rising edge of clock.
always @(posedge clk) begin if (write_enable) memory[[1]] <= data_in; end
The address 'addr' is needed to specify where to write the data in memory.
Fill both blanks to create a memory block and initialize it with zeros.
reg [7:0] memory [0:[1]]; initial begin integer i; for (i = 0; i [2] 16; i = i + 1) memory[i] = 8'b0; end
The memory has 16 words indexed 0 to 15, and the loop runs while i is less than 16 (i < 16), so the last index is 15.
Fill all three blanks to implement a synchronous read and write memory block.
reg [7:0] memory [0:[1]]; always @(posedge clk) begin if (write_enable) memory[[2]] <= data_in; data_out <= memory[[3]]; end
The memory has 16 words indexed 0 to 15. 'addr' is used for writing, and 'read_addr' is used for reading.