fblocks_Soloviev/chapter1.v
pavel 11424be3d3 changed chapter1.v
single_port_ram_single_clk_v2
2026-07-11 00:05:38 +03:00

19 lines
474 B
Verilog

//single_port_ram_single_clk_v2
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
else
data_out <= ram[address]; //read
end
endmodule