aboutsummaryrefslogtreecommitdiff
path: root/rtl/src/ram.v
blob: fc1dc21f84dc57e3a574ed21218ed7ec6589eb97 (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
// ram:
// Contains data section of program and is used for stack/heap, etc.

module ram #( 
  parameter           SIZE = 1024
)(
    input             clk,
    input             rstn,
    input             we,
    input      [31:0] addr,
    input       [2:0] size,
    input      [31:0] wd,
    output reg [31:0] rd
);

`include "include/consts.vh"

//(* RAM_STYLE="BLOCK" *)
reg [31:0] mem [0:SIZE-1];


always @(posedge clk) begin
  if (we) mem[addr >> 2] <= wd;
  rd <= mem[addr >> 2];
end

endmodule