aboutsummaryrefslogtreecommitdiffstats
path: root/tests/arch/ice40/spram.v
blob: 4e1aef2c60160554d156140e2e2559dacf60213b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module top (clk, write_enable, read_enable, write_data, addr, read_data);
parameter DATA_WIDTH = 8;
parameter ADDR_WIDTH = 8;
parameter SKIP_RDEN = 1;

input clk;
input write_enable, read_enable;
input [DATA_WIDTH - 1 : 0] write_data;
input [ADDR_WIDTH - 1 : 0] addr; 
output [DATA_WIDTH - 1 : 0] read_data;

(* ram_style = "huge" *)
reg [DATA_WIDTH - 1 : 0] mem [2**ADDR_WIDTH - 1 : 0];

always @(posedge clk) begin
	if (write_enable)
		mem[addr] <= write_data;
	else if (SKIP_RDEN || read_enable)
		read_data <= mem[addr];
end

endmodule