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

Subversion Repositories mem_ctrl

[/] [mem_ctrl/] [trunk/] [rtl/] [verilog/] [mc_dp.v] - Blame information for rev 30

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

Line No. Rev Author Line
1 4 rudi
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  WISHBONE Memory Controller                                 ////
4
////  Data Path Module                                           ////
5
////                                                             ////
6
////                                                             ////
7
////  Author: Rudolf Usselmann                                   ////
8
////          rudi@asics.ws                                      ////
9
////                                                             ////
10
////                                                             ////
11
////  Downloaded from: http://www.opencores.org/cores/mem_ctrl/  ////
12
////                                                             ////
13
/////////////////////////////////////////////////////////////////////
14
////                                                             ////
15 22 rudi
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
16
////                         www.asics.ws                        ////
17
////                         rudi@asics.ws                       ////
18 4 rudi
////                                                             ////
19
//// This source file may be used and distributed without        ////
20
//// restriction provided that this copyright statement is not   ////
21
//// removed from the file and that any derivative work contains ////
22
//// the original copyright notice and the associated disclaimer.////
23
////                                                             ////
24
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
25
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
26
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
27
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
28
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
29
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
30
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
31
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
32
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
33
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
34
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
35
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
36
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
37
////                                                             ////
38
/////////////////////////////////////////////////////////////////////
39
 
40
//  CVS Log
41
//
42 22 rudi
//  $Id: mc_dp.v,v 1.6 2002-01-21 13:08:52 rudi Exp $
43 4 rudi
//
44 22 rudi
//  $Date: 2002-01-21 13:08:52 $
45
//  $Revision: 1.6 $
46 4 rudi
//  $Author: rudi $
47
//  $Locker:  $
48
//  $State: Exp $
49
//
50
// Change History:
51
//               $Log: not supported by cvs2svn $
52 22 rudi
//               Revision 1.5  2001/12/11 02:47:19  rudi
53
//
54
//               - Made some changes not to expect clock during reset ...
55
//
56 18 rudi
//               Revision 1.4  2001/11/29 02:16:28  rudi
57
//
58
//
59
//               - More Synthesis cleanup, mostly for speed
60
//               - Several bug fixes
61
//               - Changed code to avoid auto-precharge and
62
//                 burst-terminate combinations (apparently illegal ?)
63
//                 Now we will do a manual precharge ...
64
//
65 16 rudi
//               Revision 1.3  2001/09/24 00:38:21  rudi
66
//
67
//               Changed Reset to be active high and async.
68
//
69 12 rudi
//               Revision 1.2  2001/08/10 08:16:21  rudi
70
//
71
//               - Changed IO names to be more clear.
72
//               - Uniquifyed define names to be core specific.
73
//               - Removed "Refresh Early" configuration
74
//
75 8 rudi
//               Revision 1.1  2001/07/29 07:34:41  rudi
76
//
77
//
78
//               1) Changed Directory Structure
79
//               2) Fixed several minor bugs
80
//
81 4 rudi
//               Revision 1.2  2001/06/03 11:37:17  rudi
82
//
83
//
84
//               1) Fixed Chip Select Mask Register
85
//                      - Power On Value is now all ones
86
//                      - Comparison Logic is now correct
87
//
88
//               2) All resets are now asynchronous
89
//
90
//               3) Converted Power On Delay to an configurable item
91
//
92
//               4) Added reset to Chip Select Output Registers
93
//
94
//               5) Forcing all outputs to Hi-Z state during reset
95
//
96
//               Revision 1.1.1.1  2001/05/13 09:39:47  rudi
97
//               Created Directory Structure
98
//
99
//
100
//
101
//
102
 
103
`include "mc_defines.v"
104
 
105
module mc_dp(   clk, rst, csc,
106 16 rudi
                wb_cyc_i, wb_stb_i, wb_ack_o, mem_ack, wb_data_i, wb_data_o,
107
                wb_read_go, wb_we_i,
108
                mc_clk, mc_data_del, mc_dp_i, mc_data_o, mc_dp_o,
109 4 rudi
 
110
                dv, pack_le0, pack_le1, pack_le2,
111
                byte_en, par_err
112
                );
113
 
114
input           clk, rst;
115
input   [31:0]   csc;
116
 
117
input           wb_cyc_i;
118 16 rudi
input           wb_stb_i;
119
input           mem_ack;
120
input           wb_ack_o;
121 4 rudi
input   [31:0]   wb_data_i;
122
output  [31:0]   wb_data_o;
123
input           wb_read_go;
124 16 rudi
input           wb_we_i;
125 4 rudi
 
126 16 rudi
input           mc_clk;
127
input   [35:0]   mc_data_del;
128 4 rudi
input   [3:0]    mc_dp_i;
129
output  [31:0]   mc_data_o;
130
output  [3:0]    mc_dp_o;
131
 
132
input           dv;
133
input           pack_le0, pack_le1, pack_le2;   // Pack Latch Enable
134
input   [3:0]    byte_en;                        // High Active byte enables
135
output          par_err;
136
 
137
////////////////////////////////////////////////////////////////////
138
//
139
// Local Registers & Wires
140
//
141
 
142
reg     [31:0]   wb_data_o;
143
reg     [31:0]   mc_data_o;
144
wire    [35:0]   rd_fifo_out;
145
wire            rd_fifo_clr;
146
reg     [3:0]    mc_dp_o;
147
reg             par_err_r;
148
 
149
reg     [7:0]    byte0, byte1, byte2;
150
reg     [31:0]   mc_data_d;
151
 
152
wire    [2:0]    mem_type;
153
wire    [1:0]    bus_width;
154
wire            pen;
155
wire            re;
156
 
157
// Aliases
158
assign mem_type  = csc[3:1];
159
assign bus_width = csc[5:4];
160
assign pen       = csc[11];
161
 
162
////////////////////////////////////////////////////////////////////
163
//
164
// WB READ Data Path
165
//
166
 
167 16 rudi
always @(mem_type or rd_fifo_out or mc_data_d)
168
        if( (mem_type == `MC_MEM_TYPE_SDRAM) |
169
            (mem_type == `MC_MEM_TYPE_SRAM)  )  wb_data_o = rd_fifo_out[31:0];
170
        else                                    wb_data_o = mc_data_d;
171 4 rudi
 
172 18 rudi
//assign rd_fifo_clr = !(rst | !wb_cyc_i | (wb_we_i & wb_stb_i) );
173
assign rd_fifo_clr = !wb_cyc_i | (wb_we_i & wb_stb_i);
174 16 rudi
assign re = wb_ack_o & wb_read_go;
175 4 rudi
 
176
mc_rd_fifo u0(
177
        .clk(   clk                     ),
178 18 rudi
        .rst(   rst                     ),
179
        .clr(   rd_fifo_clr             ),
180 4 rudi
        .din(   mc_data_del             ),
181
        .we(    dv                      ),
182
        .dout(  rd_fifo_out             ),
183
        .re(    re                      )
184
        );
185
 
186
////////////////////////////////////////////////////////////////////
187
//
188
// WB WRITE Data Path
189
//
190
 
191
always @(posedge clk)
192 16 rudi
        if(wb_ack_o | (mem_type != `MC_MEM_TYPE_SDRAM) )
193 4 rudi
                mc_data_o <= #1 wb_data_i;
194
 
195
////////////////////////////////////////////////////////////////////
196
//
197
// Read Data Packing
198
//
199
 
200
always @(posedge clk)
201 16 rudi
        if(pack_le0)                            byte0 <= #1 mc_data_del[7:0];
202 4 rudi
 
203
always @(posedge clk)
204 16 rudi
        if(pack_le1 & (bus_width == `MC_BW_8))  byte1 <= #1 mc_data_del[7:0];
205 4 rudi
        else
206 16 rudi
        if(pack_le0 & (bus_width == `MC_BW_16)) byte1 <= #1 mc_data_del[15:8];
207 4 rudi
 
208
always @(posedge clk)
209 16 rudi
        if(pack_le2)                            byte2 <= #1 mc_data_del[7:0];
210 4 rudi
 
211 16 rudi
always @(bus_width or mc_data_del or byte0 or byte1 or byte2)
212
        if(bus_width == `MC_BW_8)       mc_data_d = {mc_data_del[7:0], byte2, byte1, byte0};
213 4 rudi
        else
214 16 rudi
        if(bus_width == `MC_BW_16)      mc_data_d = {mc_data_del[15:0], byte1, byte0};
215
        else                            mc_data_d = mc_data_del[31:0];
216 4 rudi
 
217
////////////////////////////////////////////////////////////////////
218
//
219
// Parity Generation
220
//
221
 
222
always @(posedge clk)
223 16 rudi
        if(wb_ack_o | (mem_type != `MC_MEM_TYPE_SDRAM) )
224 4 rudi
                mc_dp_o <= #1   { ^wb_data_i[31:24], ^wb_data_i[23:16],
225
                                    ^wb_data_i[15:08], ^wb_data_i[07:00] };
226
 
227
////////////////////////////////////////////////////////////////////
228
//
229
// Parity Checking
230
//
231
 
232 16 rudi
assign  par_err = !wb_we_i & mem_ack & pen & (
233 4 rudi
                                (( ^rd_fifo_out[31:24] ^ rd_fifo_out[35] ) & byte_en[3] ) |
234
                                (( ^rd_fifo_out[23:16] ^ rd_fifo_out[34] ) & byte_en[2] ) |
235
                                (( ^rd_fifo_out[15:08] ^ rd_fifo_out[33] ) & byte_en[1] ) |
236
                                (( ^rd_fifo_out[07:00] ^ rd_fifo_out[32] ) & byte_en[0] )
237
                        );
238
 
239
endmodule
240
 

powered by: WebSVN 2.1.0

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