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

Subversion Repositories or1k

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

Go to most recent revision | 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 1575 jcastillo
// Revision 1.1.1.1  2004/12/13 17:16:09  jcastillo
46
// Firt import of OR1200 over Celoxica RC203 platform
47
//
48 1327 jcastillo
 
49
// synopsys translate_off
50
`include "timescale.v"
51
// synopsys translate_on
52
 
53
module wb_zbt_controller(clk,reset,
54
 
55
                         wb_stb_i,wb_dat_o,wb_dat_i,
56
                         wb_ack_o,wb_adr_i,wb_we_i,
57
                         wb_cyc_i,wb_sel_i,
58
 
59
                         nRW,address,data,
60
                         nBW,nCS
61
                        );
62
 
63
input         clk;
64
input         reset;
65
//
66
// WISHBONE INTERFACE
67
//
68
input         wb_stb_i;
69
output [31:0] wb_dat_o;
70
input  [31:0] wb_dat_i;
71
output        wb_ack_o;
72
input  [31:0] wb_adr_i;
73
input         wb_we_i;
74
input         wb_cyc_i;
75
input  [3:0]  wb_sel_i;
76
 
77
//
78
// RAM PINS
79
//
80
output        nRW;
81
output [19:0] address;
82
inout  [31:0] data;   //INOUT
83
output [3:0]  nBW;
84
output        nCS;
85
 
86
reg  [31:0]   wb_dat_o;
87
reg           wb_ack_o;
88
reg           nRW;
89
reg  [19:0]   address;
90
reg  [3:0]    nBW;
91
wire [31:0]   data;
92
wire          nCS;
93
 
94
reg   next_reading;
95
reg   reading;
96
reg   next_writing;
97
reg   writing;
98
 
99
assign nCS = 1'b0;
100
 
101
assign data = writing ? wb_dat_i : 32'hZ;
102
 
103
//read_data:
104
always @(posedge clk or posedge reset)
105
begin
106
   if(reset==1)
107
   begin
108
     wb_ack_o<=#1 1'b0;
109
     wb_dat_o<=#1 1'b0;
110
   end
111
   else
112
   begin
113
     wb_dat_o <= #1 1'b0;
114
     wb_ack_o <= #1 1'b0;
115
     if (reading)
116
     begin
117
       wb_ack_o <= #1 1'b1;
118
       wb_dat_o <= #1 data;
119
     end
120
     else if(writing)
121
     begin
122
      wb_ack_o  <= #1 1'b1;
123
     end
124
  end
125
end
126
 
127
 
128
reg [31:0] addr_var;
129
 
130
always @(wb_adr_i or wb_stb_i or wb_we_i or wb_cyc_i or
131
         wb_sel_i or reading or writing or wb_ack_o)
132
 
133
   begin
134
 
135
   next_reading  = 1'b0;
136
   next_writing  = 1'b0;
137
 
138
   addr_var = wb_adr_i ;
139
   addr_var = addr_var>>2;
140
   address  = addr_var[19:0];
141
 
142
   nRW  = 1;
143
 
144
   nBW = ~wb_sel_i ;
145
 
146
   if(~reading && ~writing && ~wb_ack_o)
147
   begin
148
 
149
     if (wb_cyc_i && wb_stb_i && !wb_we_i)
150
     begin
151
//     Single memory read 
152
       addr_var = wb_adr_i ;
153
       addr_var = addr_var>>2;
154
       address  = addr_var[19:0];
155
       nRW  = 1'b1;
156
       next_reading  = 1'b1;
157
     end
158
     else if (wb_cyc_i && wb_stb_i && wb_we_i)
159
     begin
160
//     Single memory write
161
       addr_var = wb_adr_i ;
162
       addr_var = addr_var >> 2;
163
       address  = addr_var[19:0];
164
       next_writing  = 1'b1;
165
       nRW = 0;
166
     end
167
   end
168
   if(reading)
169
     next_reading=1'b0;
170
   if(writing)
171
   begin
172
     next_writing=1'b0;
173
     nRW=1;
174
   end
175
 end
176
 
177
 
178
//register_proc:
179
always @(posedge clk or posedge reset)
180
 
181
   begin
182
 
183
   if (reset )
184
      begin
185
      reading  <= #1 1'b0;
186
      writing  <= #1 1'b0;
187
      end
188
   else
189
      begin
190
      writing  <= #1 next_writing;
191
      reading  <= #1 next_reading;
192
      end
193
   end
194
 
195
endmodule

powered by: WebSVN 2.1.0

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