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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [xilinx/] [s3adsp1800/] [rtl/] [verilog/] [xilinx_s3adsp_ddr2/] [xilinx_s3adsp_ddr2.v] - Blame information for rev 733

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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