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 16

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

powered by: WebSVN 2.1.0

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