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

Subversion Repositories or1k

[/] [or1k/] [tags/] [arelease/] [rc203soc/] [rtl/] [verilog/] [rc203/] [rc203_zbtcontroller.v] - Blame information for rev 1765

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

powered by: WebSVN 2.1.0

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