fblocks_Soloviev/chapter1.v
2026-07-10 23:39:28 +03:00

18 lines
460 B
Verilog

//single_port_ram_single_clk
module chapter1
#(parameter DATA_WIDTH=8, parameter ADDR_WIDTH=5)
(input clk, we,
input [DATA_WIDTH-1 : 0] data_in,
input [ADDR_WIDTH-1 : 0] address,
output reg [DATA_WIDTH-1 : 0] data_out);
// declaring the memory matrix
reg [DATA_WIDTH-1 : 0] ram[2**ADDR_WIDTH-1 : 0];
always @ (posedge clk)
begin
if (we)
ram[address] <= data_in; //write
data_out <= ram[address]; //read
end
endmodule