OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [xilinx/] [ml501/] [rtl/] [verilog/] [xilinx_ddr2/] [xilinx_ddr2.v] - Blame information for rev 439

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 412 julius
/*
2
 * Wrapper for Xilinx MIG'd DDR2 controller, allowing 3 masters
3
 * to contol the single interface.
4
 */
5
 
6
module xilinx_ddr2
7
  (
8
   // Inputs
9
    input [31:0] wbm0_adr_i,
10
    input [1:0]  wbm0_bte_i,
11
    input [2:0]  wbm0_cti_i,
12
    input        wbm0_cyc_i,
13
    input [31:0] wbm0_dat_i,
14
    input [3:0]  wbm0_sel_i,
15
 
16
    input        wbm0_stb_i,
17
    input        wbm0_we_i,
18
 
19
   // Outputs
20
    output       wbm0_ack_o,
21
    output       wbm0_err_o,
22
    output       wbm0_rty_o,
23
    output [31:0] wbm0_dat_o,
24
 
25
 
26
   // Inputs
27
    input [31:0]  wbm1_adr_i,
28
    input [1:0]   wbm1_bte_i,
29
    input [2:0]   wbm1_cti_i,
30
    input         wbm1_cyc_i,
31
    input [31:0]  wbm1_dat_i,
32
    input [3:0]   wbm1_sel_i,
33
 
34
    input         wbm1_stb_i,
35
    input         wbm1_we_i,
36
 
37
   // Outputs
38
    output        wbm1_ack_o,
39
    output        wbm1_err_o,
40
    output        wbm1_rty_o,
41
    output [31:0] wbm1_dat_o,
42
 
43
 
44
 
45
   // Inputs
46
    input [31:0]  wbm2_adr_i,
47
    input [1:0]   wbm2_bte_i,
48
    input [2:0]   wbm2_cti_i,
49
    input         wbm2_cyc_i,
50
    input [31:0]  wbm2_dat_i,
51
    input [3:0]   wbm2_sel_i,
52
 
53
    input         wbm2_stb_i,
54
    input         wbm2_we_i,
55
 
56
   // Outputs
57
    output        wbm2_ack_o,
58
    output        wbm2_err_o,
59
    output        wbm2_rty_o,
60
    output [31:0] wbm2_dat_o,
61
 
62
    input         wb_clk,
63
    input         wb_rst,
64
 
65
    output [12:0] ddr2_a,
66
    output [1:0]  ddr2_ba,
67
    output        ddr2_ras_n,
68
    output        ddr2_cas_n,
69
    output        ddr2_we_n,
70
    output [1:0]  ddr2_cs_n,
71
    output [1:0]  ddr2_odt,
72
    output [1:0]  ddr2_cke,
73
    output [7:0]  ddr2_dm,
74
 
75
    inout [63:0]  ddr2_dq,
76
    inout [7:0]   ddr2_dqs,
77
    inout [7:0]   ddr2_dqs_n,
78
    output [1:0]  ddr2_ck,
79
    output [1:0]  ddr2_ck_n,
80
 
81
    input         ddr2_if_clk,
82
    input         clk200,
83
    input         ddr2_if_rst
84
 
85
   );
86
 
87
   // Internal wires to actual RAM
88
   wire [31:0]     wbs_ram_adr_i;
89
   wire [1:0]      wbs_ram_bte_i;
90
   wire [2:0]      wbs_ram_cti_i;
91
   wire           wbs_ram_cyc_i;
92
   wire [31:0]     wbs_ram_dat_i;
93
   wire [3:0]      wbs_ram_sel_i;
94
   wire           wbs_ram_stb_i;
95
   wire           wbs_ram_we_i;
96
 
97
   wire           wbs_ram_ack_o;
98
   wire [31:0]     wbs_ram_dat_o;
99
 
100
   reg [2:0]       input_select, last_selected;
101
   wire           arb_for_wbm0, arb_for_wbm1, arb_for_wbm2;
102
   // Wires allowing selection of new input
103
   assign arb_for_wbm0 = (last_selected[1] | last_selected[2] |
104
                          !wbm1_cyc_i | !wbm2_cyc_i) & !(|input_select);
105
   assign arb_for_wbm1 = (last_selected[0] | last_selected[2] |
106
                          !wbm0_cyc_i | !wbm2_cyc_i) & !(|input_select);
107
   assign arb_for_wbm2 = (last_selected[0] | last_selected[1] |
108
                          !wbm0_cyc_i | !wbm1_cyc_i) & !(|input_select);
109
 
110
   // Master select logic
111
   always @(posedge wb_clk)
112
     if (wb_rst)
113
       input_select <= 0;
114
     else if ((input_select[0] & !wbm0_cyc_i) | (input_select[1] & !wbm1_cyc_i)
115
              | (input_select[2] & !wbm2_cyc_i))
116
       input_select <= 0;
117
     else if (!(&input_select) & wbm0_cyc_i & arb_for_wbm0)
118
       input_select <= 3'b001;
119
     else if (!(&input_select) & wbm1_cyc_i & arb_for_wbm1)
120
       input_select <= 3'b010;
121
     else if (!(&input_select) & wbm2_cyc_i & arb_for_wbm2)
122
       input_select <= 3'b100;
123
 
124
   always @(posedge wb_clk)
125
     if (wb_rst)
126
       last_selected <= 0;
127
     else if (!(&input_select) & wbm0_cyc_i & arb_for_wbm0)
128
       last_selected <= 3'b001;
129
     else if (!(&input_select) & wbm1_cyc_i & arb_for_wbm1)
130
       last_selected <= 3'b010;
131
     else if (!(&input_select) & wbm2_cyc_i & arb_for_wbm2)
132
       last_selected <= 3'b100;
133
 
134
   // Mux input signals to RAM (default to wbm0)
135
   assign wbs_ram_adr_i = (input_select[2]) ? wbm2_adr_i :
136
                            (input_select[1]) ? wbm1_adr_i :
137
                            (input_select[0]) ? wbm0_adr_i : 0;
138
   assign wbs_ram_bte_i = (input_select[2]) ? wbm2_bte_i :
139
                            (input_select[1]) ? wbm1_bte_i :
140
                            (input_select[0]) ? wbm0_bte_i : 0;
141
   assign wbs_ram_cti_i = (input_select[2]) ? wbm2_cti_i :
142
                            (input_select[1]) ? wbm1_cti_i :
143
                            (input_select[0]) ? wbm0_cti_i : 0;
144
   assign wbs_ram_cyc_i = (input_select[2]) ? wbm2_cyc_i :
145
                            (input_select[1]) ? wbm1_cyc_i :
146
                            (input_select[0]) ? wbm0_cyc_i : 0;
147
   assign wbs_ram_dat_i = (input_select[2]) ? wbm2_dat_i :
148
                            (input_select[1]) ? wbm1_dat_i :
149
                            (input_select[0]) ? wbm0_dat_i : 0;
150
   assign wbs_ram_sel_i = (input_select[2]) ? wbm2_sel_i :
151
                            (input_select[1]) ? wbm1_sel_i :
152
                            (input_select[0]) ? wbm0_sel_i : 0;
153
   assign wbs_ram_stb_i = (input_select[2]) ? wbm2_stb_i :
154
                            (input_select[1]) ? wbm1_stb_i :
155
                            (input_select[0]) ? wbm0_stb_i : 0;
156
   assign wbs_ram_we_i  = (input_select[2]) ? wbm2_we_i  :
157
                            (input_select[1]) ? wbm1_we_i  :
158
                            (input_select[0]) ? wbm0_we_i : 0;
159
 
160
   // Output from RAM, gate the ACK, ERR, RTY signals appropriately
161
   assign wbm0_dat_o = wbs_ram_dat_o;
162
   assign wbm0_ack_o = wbs_ram_ack_o & input_select[0];
163
   assign wbm0_err_o = 0;
164
   assign wbm0_rty_o = 0;
165
 
166
   assign wbm1_dat_o = wbs_ram_dat_o;
167
   assign wbm1_ack_o = wbs_ram_ack_o & input_select[1];
168
   assign wbm1_err_o = 0;
169
   assign wbm1_rty_o = 0;
170
 
171
   assign wbm2_dat_o = wbs_ram_dat_o;
172
   assign wbm2_ack_o = wbs_ram_ack_o & input_select[2];
173
   assign wbm2_err_o = 0;
174
   assign wbm2_rty_o = 0;
175
 
176
 
177
    xilinx_ddr2_if xilinx_ddr2_if0
178
     (
179
 
180
      .wb_dat_o                         (wbs_ram_dat_o),
181
      .wb_ack_o                         (wbs_ram_ack_o),
182
      .wb_adr_i                         (wbs_ram_adr_i[31:0]),
183
      .wb_stb_i                         (wbs_ram_stb_i),
184 439 julius
      .wb_cti_i                         (wbs_ram_cti_i),
185
      .wb_bte_i                         (wbs_ram_bte_i),
186 412 julius
      .wb_cyc_i                         (wbs_ram_cyc_i),
187
      .wb_we_i                          (wbs_ram_we_i),
188
      .wb_sel_i                         (wbs_ram_sel_i[3:0]),
189
      .wb_dat_i                         (wbs_ram_dat_i[31:0]),
190
 
191
      .ddr2_a                           (ddr2_a[12:0]),
192
      .ddr2_ba                          (ddr2_ba[1:0]),
193
      .ddr2_ras_n                       (ddr2_ras_n),
194
      .ddr2_cas_n                       (ddr2_cas_n),
195
      .ddr2_we_n                        (ddr2_we_n),
196
      .ddr2_cs_n                        (ddr2_cs_n),
197
      .ddr2_odt                         (ddr2_odt),
198
      .ddr2_cke                         (ddr2_cke),
199
      .ddr2_dm                          (ddr2_dm[7:0]),
200
      .ddr2_ck                          (ddr2_ck[1:0]),
201
      .ddr2_ck_n                        (ddr2_ck_n[1:0]),
202
      .ddr2_dq                          (ddr2_dq[63:0]),
203
      .ddr2_dqs                         (ddr2_dqs[7:0]),
204
      .ddr2_dqs_n                       (ddr2_dqs_n[7:0]),
205
 
206
      .ddr2_if_clk                      (ddr2_if_clk),
207
      .idly_clk_200                     (clk200),
208
      .ddr2_if_rst                      (ddr2_if_rst),
209
      .wb_clk                           (wb_clk),
210
      .wb_rst                           (wb_rst));
211
 
212
 
213
 
214
 
215
endmodule
216
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.