Root/lm32/logic/sakc/rtl/wb_ddr/dpram.v

1
2//----------------------------------------------------------------------------
3// Wishbone DDR Controller
4//
5// (c) Joerg Bornschein (<jb@capsec.org>)
6//----------------------------------------------------------------------------
7
8module dpram
9#(
10    parameter adr_width = 9,
11    parameter dat_width = 36
12) (
13    input clk,
14    // Port 0
15    input [adr_width-1:0] adr0,
16    input we0,
17    input [dat_width-1:0] din0,
18    output reg [dat_width-1:0] dout0,
19    // Port 1
20    input [adr_width-1:0] adr1,
21    input we1,
22    input [dat_width-1:0] din1,
23    output reg [dat_width-1:0] dout1
24);
25
26parameter depth = (1 << adr_width);
27
28// actual ram
29reg [dat_width-1:0] ram [0:depth-1];
30
31//------------------------------------------------------------------
32// Syncronous Dual Port RAM Access
33//------------------------------------------------------------------
34always @(posedge clk)
35begin
36    // Frst port
37    if (we0)
38        ram[adr0] <= din0;
39
40    dout0 <= ram[adr0];
41end
42
43
44always @(posedge clk)
45begin
46    // Second port
47    if (we1)
48        ram[adr1] <= din1;
49
50    dout1 <= ram[adr1];
51end
52
53//------------------------------------------------------------------
54// Initialize content to Zero
55//------------------------------------------------------------------
56integer i;
57
58initial
59begin
60    for(i=0; i<depth; i=i+1)
61        ram[i] <= 'b0;
62end
63
64endmodule
65

Archive Download this file

Branches:
master



interactive