summaryrefslogtreecommitdiffstats
path: root/fpga/xilinx/digilent/spartan_6/s6_remotefpga_test/data_storage.v
blob: 60c1dff15ad0d8743536b4661b1623f86ca9c10a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
//
// (c) 2013 Timothy Pearson, Raptor Engineering
// Released into the Public Domain
//
//////////////////////////////////////////////////////////////////////////////////

module data_storage(
	input clka,
	input [7:0] dina,
	input [13:0] addra,
	input wea,
	output reg [7:0] douta);

	parameter RAM_ADDR_BITS = 14;
	parameter RAM_WIDTH = 8;
	
	// Xilinx specific directive
	(* RAM_STYLE="BLOCK" *)
	
	reg [RAM_WIDTH-1:0] data_storage_ram [(2**RAM_ADDR_BITS)-1:0];
	
	always @(posedge clka) begin
	if (wea) begin
			data_storage_ram[addra] <= dina;
			douta <= dina;
	end else begin
			douta <= data_storage_ram[addra];
		end
	end

endmodule