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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 627 stekern
/*
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 [2:0]  ddr2_ba,
67
    output            ddr2_ras_n,
68
    output            ddr2_cas_n,
69
    output            ddr2_we_n,
70
    output        ddr2_rzq,
71
    output        ddr2_zio,
72
 
73
    output        ddr2_odt,
74
    output        ddr2_cke,
75
    output        ddr2_dm,
76
    output        ddr2_udm,
77
 
78
    inout [15:0]  ddr2_dq,
79
    inout         ddr2_dqs,
80
    inout         ddr2_dqs_n,
81
    inout         ddr2_udqs,
82
    inout         ddr2_udqs_n,
83
    output        ddr2_ck,
84
    output        ddr2_ck_n,
85
 
86
    input         ddr2_if_clk,
87
    input         clk100,
88
    input         ddr2_if_rst
89
 
90
   );
91
 
92
   // Internal wires to actual RAM
93
   wire [31:0]     wbs_ram_adr_i;
94
   wire [1:0]      wbs_ram_bte_i;
95
   wire [2:0]      wbs_ram_cti_i;
96
   wire           wbs_ram_cyc_i;
97
   wire [31:0]     wbs_ram_dat_i;
98
   wire [3:0]      wbs_ram_sel_i;
99
   wire           wbs_ram_stb_i;
100
   wire           wbs_ram_we_i;
101
 
102
   wire           wbs_ram_ack_o;
103
   wire [31:0]     wbs_ram_dat_o;
104
 
105
   reg [2:0]       input_select, last_selected;
106
   wire           arb_for_wbm0, arb_for_wbm1, arb_for_wbm2;
107
   // Wires allowing selection of new input
108
   assign arb_for_wbm0 = (last_selected[1] | last_selected[2] |
109
                          !wbm1_cyc_i | !wbm2_cyc_i) & !(|input_select);
110
   assign arb_for_wbm1 = (last_selected[0] | last_selected[2] |
111
                          !wbm0_cyc_i | !wbm2_cyc_i) & !(|input_select);
112
   assign arb_for_wbm2 = (last_selected[0] | last_selected[1] |
113
                          !wbm0_cyc_i | !wbm1_cyc_i) & !(|input_select);
114
 
115
   // Master select logic
116
   always @(posedge wb_clk)
117
     if (wb_rst)
118
       input_select <= 0;
119
     else if ((input_select[0] & !wbm0_cyc_i) | (input_select[1] & !wbm1_cyc_i)
120
              | (input_select[2] & !wbm2_cyc_i))
121
       input_select <= 0;
122
     else if (!(&input_select) & wbm0_cyc_i & arb_for_wbm0)
123
       input_select <= 3'b001;
124
     else if (!(&input_select) & wbm1_cyc_i & arb_for_wbm1)
125
       input_select <= 3'b010;
126
     else if (!(&input_select) & wbm2_cyc_i & arb_for_wbm2)
127
       input_select <= 3'b100;
128
 
129
   always @(posedge wb_clk)
130
     if (wb_rst)
131
       last_selected <= 0;
132
     else if (!(&input_select) & wbm0_cyc_i & arb_for_wbm0)
133
       last_selected <= 3'b001;
134
     else if (!(&input_select) & wbm1_cyc_i & arb_for_wbm1)
135
       last_selected <= 3'b010;
136
     else if (!(&input_select) & wbm2_cyc_i & arb_for_wbm2)
137
       last_selected <= 3'b100;
138
 
139
   // Mux input signals to RAM (default to wbm0)
140
   assign wbs_ram_adr_i = (input_select[2]) ? wbm2_adr_i :
141
                            (input_select[1]) ? wbm1_adr_i :
142
                            (input_select[0]) ? wbm0_adr_i : 0;
143
   assign wbs_ram_bte_i = (input_select[2]) ? wbm2_bte_i :
144
                            (input_select[1]) ? wbm1_bte_i :
145
                            (input_select[0]) ? wbm0_bte_i : 0;
146
   assign wbs_ram_cti_i = (input_select[2]) ? wbm2_cti_i :
147
                            (input_select[1]) ? wbm1_cti_i :
148
                            (input_select[0]) ? wbm0_cti_i : 0;
149
   assign wbs_ram_cyc_i = (input_select[2]) ? wbm2_cyc_i :
150
                            (input_select[1]) ? wbm1_cyc_i :
151
                            (input_select[0]) ? wbm0_cyc_i : 0;
152
   assign wbs_ram_dat_i = (input_select[2]) ? wbm2_dat_i :
153
                            (input_select[1]) ? wbm1_dat_i :
154
                            (input_select[0]) ? wbm0_dat_i : 0;
155
   assign wbs_ram_sel_i = (input_select[2]) ? wbm2_sel_i :
156
                            (input_select[1]) ? wbm1_sel_i :
157
                            (input_select[0]) ? wbm0_sel_i : 0;
158
   assign wbs_ram_stb_i = (input_select[2]) ? wbm2_stb_i :
159
                            (input_select[1]) ? wbm1_stb_i :
160
                            (input_select[0]) ? wbm0_stb_i : 0;
161
   assign wbs_ram_we_i  = (input_select[2]) ? wbm2_we_i  :
162
                            (input_select[1]) ? wbm1_we_i  :
163
                            (input_select[0]) ? wbm0_we_i : 0;
164
 
165
   // Output from RAM, gate the ACK, ERR, RTY signals appropriately
166
   assign wbm0_dat_o = wbs_ram_dat_o;
167
   assign wbm0_ack_o = wbs_ram_ack_o & input_select[0];
168
   assign wbm0_err_o = 0;
169
   assign wbm0_rty_o = 0;
170
 
171
   assign wbm1_dat_o = wbs_ram_dat_o;
172
   assign wbm1_ack_o = wbs_ram_ack_o & input_select[1];
173
   assign wbm1_err_o = 0;
174
   assign wbm1_rty_o = 0;
175
 
176
   assign wbm2_dat_o = wbs_ram_dat_o;
177
   assign wbm2_ack_o = wbs_ram_ack_o & input_select[2];
178
   assign wbm2_err_o = 0;
179
   assign wbm2_rty_o = 0;
180
 
181
 
182
    xilinx_ddr2_if xilinx_ddr2_if0
183
     (
184
 
185
      .wb_dat_o                         (wbs_ram_dat_o),
186
      .wb_ack_o                         (wbs_ram_ack_o),
187
      .wb_adr_i                         (wbs_ram_adr_i[31:0]),
188
      .wb_stb_i                         (wbs_ram_stb_i),
189
      .wb_cti_i                         (wbs_ram_cti_i),
190
      .wb_bte_i                         (wbs_ram_bte_i),
191
      .wb_cyc_i                         (wbs_ram_cyc_i),
192
      .wb_we_i                          (wbs_ram_we_i),
193
      .wb_sel_i                         (wbs_ram_sel_i[3:0]),
194
      .wb_dat_i                         (wbs_ram_dat_i[31:0]),
195
 
196
      .ddr2_a                           (ddr2_a[12:0]),
197
      .ddr2_ba                          (ddr2_ba),
198
      .ddr2_ras_n                       (ddr2_ras_n),
199
      .ddr2_cas_n                       (ddr2_cas_n),
200
      .ddr2_we_n                        (ddr2_we_n),
201
      .ddr2_rzq                 (ddr2_rzq),
202
      .ddr2_zio                         (ddr2_zio),
203
      .ddr2_odt                         (ddr2_odt),
204
      .ddr2_cke                         (ddr2_cke),
205
      .ddr2_dm                          (ddr2_dm),
206
      .ddr2_udm                         (ddr2_udm),
207
      .ddr2_ck                          (ddr2_ck),
208
      .ddr2_ck_n                        (ddr2_ck_n),
209
      .ddr2_dq                          (ddr2_dq),
210
      .ddr2_dqs                         (ddr2_dqs),
211
      .ddr2_dqs_n                       (ddr2_dqs_n),
212
      .ddr2_udqs                        (ddr2_udqs),
213
      .ddr2_udqs_n                      (ddr2_udqs_n),
214
 
215
      .ddr2_if_clk                      (ddr2_if_clk),
216
      .idly_clk_100                     (clk100), //SJK this can be removed, not needed
217
      .ddr2_if_rst                      (ddr2_if_rst),
218
      .wb_clk                           (wb_clk),
219
      .wb_rst                           (wb_rst));
220
 
221
 
222
 
223
 
224
endmodule
225
 

powered by: WebSVN 2.1.0

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