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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [rtl/] [verilog/] [rc203/] [rc203_zbtcontroller.v] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1327 jcastillo
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  ZBT RAM Controller for RC203 board                          ////
4
////                                                              ////
5
////                                                              ////
6
////  Description                                                 ////
7
////  Manages access from Wishbone to ZBT external RAM            ////
8
////                                                              ////
9
////  To Do:                                                      ////
10
////   - nothing really                                           ////
11
////                                                              ////
12
////  Author(s):                                                  ////
13 1575 jcastillo
////      - Javier Castillo, javier.castillo@urjc.es              ////
14 1327 jcastillo
////                                                              ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                              ////
17
//// Copyright (C) 2004 OpenCores                                 ////
18
////                                                              ////
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 source file is free software; you can redistribute it   ////
25
//// and/or modify it under the terms of the GNU Lesser General   ////
26
//// Public License as published by the Free Software Foundation; ////
27
//// either version 2.1 of the License, or (at your option) any   ////
28
//// later version.                                               ////
29
////                                                              ////
30
//// This source is distributed in the hope that it will be       ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
33
//// PURPOSE.  See the GNU Lesser General Public License for more ////
34
//// details.                                                     ////
35
////                                                              ////
36
//// You should have received a copy of the GNU Lesser General    ////
37
//// Public License along with this source; if not, download it   ////
38
//// from http://www.opencores.org/lgpl.shtml                     ////
39
////                                                              ////
40
//////////////////////////////////////////////////////////////////////
41
//
42
// CVS Revision History
43
//
44
// $Log: not supported by cvs2svn $
45 1587 jcastillo
// Revision 1.2  2005/09/16 00:39:04  jcastillo
46
// no message
47
//
48 1575 jcastillo
// Revision 1.1.1.1  2004/12/13 17:16:09  jcastillo
49
// Firt import of OR1200 over Celoxica RC203 platform
50
//
51 1327 jcastillo
 
52
// synopsys translate_off
53
`include "timescale.v"
54
// synopsys translate_on
55
 
56
module wb_zbt_controller(clk,reset,
57
 
58
                         wb_stb_i,wb_dat_o,wb_dat_i,
59
                         wb_ack_o,wb_adr_i,wb_we_i,
60
                         wb_cyc_i,wb_sel_i,
61
 
62 1587 jcastillo
                         // Bank 0
63
                         nRW0,address0,data0,
64
                         nBW0,nCS0,
65
 
66
                         // Bank 1
67
                         nRW1,address1,data1,
68
                         nBW1,nCS1
69 1327 jcastillo
                        );
70
 
71
input         clk;
72
input         reset;
73
//
74
// WISHBONE INTERFACE
75
//
76
input         wb_stb_i;
77
output [31:0] wb_dat_o;
78
input  [31:0] wb_dat_i;
79
output        wb_ack_o;
80
input  [31:0] wb_adr_i;
81
input         wb_we_i;
82
input         wb_cyc_i;
83
input  [3:0]  wb_sel_i;
84
 
85
//
86 1587 jcastillo
// RAM PINS Bank 0
87 1327 jcastillo
//
88 1587 jcastillo
output        nRW0;
89
output [19:0] address0;
90
inout  [31:0] data0;   //INOUT
91
output [3:0]  nBW0;
92
output        nCS0;
93 1327 jcastillo
 
94 1587 jcastillo
// 
95
// RAM PINS Bank 1
96
//
97
output        nRW1;
98
output [19:0] address1;
99
inout  [31:0] data1;   //INOUT
100
output [3:0]  nBW1;
101
output        nCS1;
102
 
103 1327 jcastillo
reg  [31:0]   wb_dat_o;
104
reg           wb_ack_o;
105
 
106 1587 jcastillo
reg           nRW0;
107
reg  [19:0]   address0;
108
reg  [3:0]    nBW0;
109
wire [31:0]   data0;
110
wire          nCS0;
111
 
112
reg           nRW1;
113
reg  [19:0]   address1;
114
reg  [3:0]    nBW1;
115
wire [31:0]   data1;
116
wire          nCS1;
117
 
118
reg   next_bank_select;
119
reg   bank_select;
120 1327 jcastillo
reg   next_reading;
121
reg   reading;
122
reg   next_writing;
123
reg   writing;
124
 
125 1587 jcastillo
assign nCS0 = 1'b0;
126
assign nCS1 = 1'b0;
127 1327 jcastillo
 
128 1587 jcastillo
assign data0 = (writing && !bank_select) ? wb_dat_i : 32'hZ;
129
assign data1 = (writing && bank_select) ? wb_dat_i : 32'hZ;
130 1327 jcastillo
 
131
//read_data:
132
always @(posedge clk or posedge reset)
133
begin
134
   if(reset==1)
135
   begin
136
     wb_ack_o<=#1 1'b0;
137
     wb_dat_o<=#1 1'b0;
138
   end
139
   else
140
   begin
141
     wb_dat_o <= #1 1'b0;
142
     wb_ack_o <= #1 1'b0;
143
     if (reading)
144
     begin
145
       wb_ack_o <= #1 1'b1;
146 1587 jcastillo
       if(bank_select== 1)
147
         wb_dat_o <= #1 data1;
148
       else
149
         wb_dat_o <= #1 data0;
150 1327 jcastillo
     end
151
     else if(writing)
152
     begin
153
      wb_ack_o  <= #1 1'b1;
154
     end
155
  end
156
end
157
 
158
 
159
reg [31:0] addr_var;
160
 
161
always @(wb_adr_i or wb_stb_i or wb_we_i or wb_cyc_i or
162
         wb_sel_i or reading or writing or wb_ack_o)
163
 
164
   begin
165
 
166
   next_reading  = 1'b0;
167
   next_writing  = 1'b0;
168
 
169
   addr_var = wb_adr_i ;
170
   addr_var = addr_var>>2;
171 1587 jcastillo
   address0  = addr_var[20:1];
172
   address1  = addr_var[20:1];
173
 
174
   // We select bank using low bits so people with
175
   // non-expert versions of the rc20x boards can
176
   // use both RAM banks without changing any RTL.
177
   next_bank_select = addr_var[0];
178 1327 jcastillo
 
179 1587 jcastillo
   nRW0  = 1;
180
   nRW1  = 1;
181 1327 jcastillo
 
182 1587 jcastillo
   nBW0 = ~wb_sel_i ;
183
   nBW1 = ~wb_sel_i ;
184 1327 jcastillo
 
185
   if(~reading && ~writing && ~wb_ack_o)
186
   begin
187
 
188
     if (wb_cyc_i && wb_stb_i && !wb_we_i)
189
     begin
190 1587 jcastillo
       // Single memory read 
191 1327 jcastillo
       next_reading  = 1'b1;
192
     end
193
     else if (wb_cyc_i && wb_stb_i && wb_we_i)
194
     begin
195 1587 jcastillo
       // Single memory write
196
       if(next_bank_select == 1)
197
         nRW1 = 0;
198
       else
199
         nRW0 = 0;
200 1327 jcastillo
       next_writing  = 1'b1;
201
     end
202
   end
203
 end
204
 
205
 
206
//register_proc:
207
always @(posedge clk or posedge reset)
208
 
209
   begin
210
 
211
   if (reset )
212
      begin
213
      reading  <= #1 1'b0;
214
      writing  <= #1 1'b0;
215
      end
216
   else
217
      begin
218 1587 jcastillo
      bank_select <= #1 next_bank_select;
219 1327 jcastillo
      writing  <= #1 next_writing;
220
      reading  <= #1 next_reading;
221
      end
222
   end
223
 
224
endmodule

powered by: WebSVN 2.1.0

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