|
发表于 2011-11-9 17:29:04
|
显示全部楼层
module sram(
CLK,
WREN,
DATA,
WRADDRESS,
READDRESS,
Q);
parameter DATA_WIDTH = 8;
parameter ADDR_WIDTH = 9;
input CLK;
input WREN;
input [DATA_WIDTH-1:0] DATA;
input [ADDR_WIDTH-1:0] WRADDRESS;
input [ADDR_WIDTH-1:0] READDRESS;
output [DATA_WIDTH-1:0] Q;
wire [DATA_WIDTH-1:0] Q;
reg [DATA_WIDTH-1:0] buffer[0: (1<<ADDR_WIDTH)-1];
reg [ADDR_WIDTH-1:0] READDRESS_r;
always @( posedge CLK )
begin
READDRESS_r <= READDRESS;
if( WREN ) begin
buffer[ WRADDRESS ] <= DATA;
end
end
assign Q = buffer[ READDRESS_r ];
endmodule |
|