aboutsummaryrefslogtreecommitdiffstats
path: root/tests/xilinx_ug901/rams_init_file.v
blob: 046779af9f64bed328c7a8bae696321370f6a734 (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
// Initializing Block RAM from external data file
// Binary data
// File: rams_init_file.v 

module rams_init_file (clk, we, addr, din, dout);
input clk;
input we;
input [5:0] addr;
input [31:0] din;
output [31:0] dout;

reg [31:0] ram [0:63];
reg [31:0] dout;

initial begin
$readmemb("rams_init_file.data",ram);
end

always @(posedge clk)
begin
  if (we)
     ram[addr] <= din;
  dout <= ram[addr];
end endmodule