Complete the code to declare a 256x8 single-port RAM memory array.
reg [7:0] memory_array [0:[1]];
The memory array has 256 locations indexed from 0 to 255, so the highest index is 255.
Complete the code to write data into the RAM on the rising edge of the clock when write enable is high.
always @(posedge clk) begin if ([1]) begin memory_array[address] <= data_in; end end
The write operation happens only when the write enable signal is high.
Fix the error in the code to correctly read data from the RAM asynchronously.
assign data_out = memory_array[[1]];The output data is read from the memory at the given address.
Fill both blanks to complete the synchronous write and asynchronous read logic.
always @(posedge clk) begin if ([1]) begin memory_array[address] <= data_in; end end assign data_out = memory_array[[2]];
Write happens when write_enable is high on clock edge, and read uses the address signal.
Fill all three blanks to complete the single-port RAM module with input and output ports.
module single_port_ram( input wire clk, input wire [1], input wire [7:0] data_in, input wire [7:0] [2], output wire [7:0] [3] ); reg [7:0] memory_array [0:255]; always @(posedge clk) begin if (write_enable) begin memory_array[address] <= data_in; end end assign data_out = memory_array[address]; endmodule
The module ports include write_enable signal, address input, and data_out output.