hey i was given an assignment to write 3 test for a single port memory and was wondering if anyone has some good example on how to write tests and could help the memory will be copied and pasted below so if anyone with a similar code can help.
Moderators note: please use code tags for pieces of code
Code:
module single_port_ram (data, addr, we, clk, q);
parameter WIDTH = 16;
parameter ADDR_BITS = 4;
parameter DEPTH = 2ˆADDR_BITS;
input [WIDTH-1:0] data;
input [ADDR_BITS-1:0] addr;
input we, clk;
output [WIDTH-1:0] q;
// Declare the RAM variable
reg [WIDTH-1:0] ram [DEPTH-1:0];
// Variable to hold the registered read address
reg [ADDR_BITS-1:0] addr_reg;
always @ (posedge clk)
begin
// Write
if (we)
ram[addr] <= data;
addr_reg <= addr;
end
// Read
assign q = ram[addr_reg];
endmodule
Last edited by a moderator: