-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblock_ram.v
48 lines (43 loc) · 1.04 KB
/
block_ram.v
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 23:01:16 05/16/2015
// Design Name:
// Module Name: block_ram
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module block_ram
#(
parameter RAM_WIDTH = 8,
parameter RAM_ADDR_BITS = 4,
parameter INIT_FILE = "zeros.txt"
)
(
input wire clk, w_en,
input wire [RAM_ADDR_BITS-1:0] r_addr, w_addr,
input wire [RAM_WIDTH-1:0] in,
output wire [RAM_WIDTH-1:0] out
);
(* RAM_STYLE="auto" *)
reg [RAM_WIDTH-1:0] data [(2**RAM_ADDR_BITS)-1:0];
reg [RAM_WIDTH-1:0] out_reg;
initial $readmemh(INIT_FILE, data, 0, (2**RAM_ADDR_BITS)-1);
always @(posedge clk) begin
if (w_en)
data[w_addr] <= in;
out_reg <= data[r_addr];
end
assign out = out_reg;
endmodule