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

Subversion Repositories xge_mac

[/] [xge_mac/] [trunk/] [rtl/] [verilog/] [wishbone_if.v] - Blame information for rev 28

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 antanguay
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  File name "wishbone.v"                                      ////
4
////                                                              ////
5
////  This file is part of the "10GE MAC" project                 ////
6
////  http://www.opencores.org/cores/xge_mac/                     ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - A. Tanguay (antanguay@opencores.org)                  ////
10
////                                                              ////
11
//////////////////////////////////////////////////////////////////////
12
////                                                              ////
13
//// Copyright (C) 2008 AUTHORS. All rights reserved.             ////
14
////                                                              ////
15
//// This source file may be used and distributed without         ////
16
//// restriction provided that this copyright statement is not    ////
17
//// removed from the file and that any derivative work contains  ////
18
//// the original copyright notice and the associated disclaimer. ////
19
////                                                              ////
20
//// This source file is free software; you can redistribute it   ////
21
//// and/or modify it under the terms of the GNU Lesser General   ////
22
//// Public License as published by the Free Software Foundation; ////
23
//// either version 2.1 of the License, or (at your option) any   ////
24
//// later version.                                               ////
25
////                                                              ////
26
//// This source is distributed in the hope that it will be       ////
27
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
28
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
29
//// PURPOSE.  See the GNU Lesser General Public License for more ////
30
//// details.                                                     ////
31
////                                                              ////
32
//// You should have received a copy of the GNU Lesser General    ////
33
//// Public License along with this source; if not, download it   ////
34
//// from http://www.opencores.org/lgpl.shtml                     ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
 
38
 
39
`include "defines.v"
40
 
41
module wishbone_if(/*AUTOARG*/
42
  // Outputs
43 27 antanguay
  wb_dat_o, wb_ack_o, wb_int_o, ctrl_tx_enable, clear_stats_tx_octets,
44
  clear_stats_tx_pkts, clear_stats_rx_octets, clear_stats_rx_pkts,
45 2 antanguay
  // Inputs
46 12 antanguay
  wb_clk_i, wb_rst_i, wb_adr_i, wb_dat_i, wb_we_i, wb_stb_i, wb_cyc_i,
47 28 antanguay
  status_crc_error, status_fragment_error, status_lenght_error,
48
  status_txdfifo_ovflow, status_txdfifo_udflow, status_rxdfifo_ovflow,
49
  status_rxdfifo_udflow, status_pause_frame_rx, status_local_fault,
50
  status_remote_fault, stats_tx_octets, stats_tx_pkts,
51
  stats_rx_octets, stats_rx_pkts
52 2 antanguay
  );
53
 
54
 
55
input         wb_clk_i;
56
input         wb_rst_i;
57
 
58
input  [7:0]  wb_adr_i;
59
input  [31:0] wb_dat_i;
60
input         wb_we_i;
61
input         wb_stb_i;
62
input         wb_cyc_i;
63
 
64
output [31:0] wb_dat_o;
65
output        wb_ack_o;
66
output        wb_int_o;
67
 
68
input         status_crc_error;
69
input         status_fragment_error;
70 28 antanguay
input         status_lenght_error;
71 20 antanguay
 
72 2 antanguay
input         status_txdfifo_ovflow;
73
 
74
input         status_txdfifo_udflow;
75
 
76
input         status_rxdfifo_ovflow;
77
 
78
input         status_rxdfifo_udflow;
79
 
80
input         status_pause_frame_rx;
81
 
82
input         status_local_fault;
83
input         status_remote_fault;
84
 
85 24 antanguay
input  [31:0] stats_tx_octets;
86 23 antanguay
input  [31:0] stats_tx_pkts;
87 24 antanguay
 
88
input  [31:0] stats_rx_octets;
89 23 antanguay
input  [31:0] stats_rx_pkts;
90
 
91 2 antanguay
output        ctrl_tx_enable;
92
 
93 27 antanguay
output        clear_stats_tx_octets;
94
output        clear_stats_tx_pkts;
95
output        clear_stats_rx_octets;
96
output        clear_stats_rx_pkts;
97 2 antanguay
 
98
/*AUTOREG*/
99
// Beginning of automatic regs (for this module's undeclared outputs)
100 27 antanguay
reg                     clear_stats_rx_octets;
101
reg                     clear_stats_rx_pkts;
102
reg                     clear_stats_tx_octets;
103
reg                     clear_stats_tx_pkts;
104 2 antanguay
reg [31:0]              wb_dat_o;
105
reg                     wb_int_o;
106
// End of automatics
107
 
108 27 antanguay
reg [31:0]              next_wb_dat_o;
109
reg                     next_wb_int_o;
110
 
111 2 antanguay
reg  [0:0]              cpureg_config0;
112 27 antanguay
reg  [0:0]              next_cpureg_config0;
113
 
114 28 antanguay
reg  [9:0]              cpureg_int_pending;
115
reg  [9:0]              next_cpureg_int_pending;
116 27 antanguay
 
117 28 antanguay
reg  [9:0]              cpureg_int_mask;
118
reg  [9:0]              next_cpureg_int_mask;
119 2 antanguay
 
120
reg                     cpuack;
121 27 antanguay
reg                     next_cpuack;
122 2 antanguay
 
123
reg                     status_remote_fault_d1;
124
reg                     status_local_fault_d1;
125
 
126
/*AUTOWIRE*/
127
 
128 28 antanguay
wire [9:0]             int_sources;
129 2 antanguay
 
130
 
131
//---
132
// Source of interrupts, some are edge sensitive, others
133
// expect a pulse signal.
134
 
135
assign int_sources = {
136 28 antanguay
                      status_lenght_error,
137 2 antanguay
                      status_fragment_error,
138
                      status_crc_error,
139
 
140
                      status_pause_frame_rx,
141
 
142
                      status_remote_fault ^ status_remote_fault_d1,
143
                      status_local_fault ^ status_local_fault_d1,
144
 
145
                      status_rxdfifo_udflow,
146
                      status_rxdfifo_ovflow,
147
                      status_txdfifo_udflow,
148
                      status_txdfifo_ovflow
149
                      };
150
 
151
//---
152
// Config Register 0
153
 
154
assign ctrl_tx_enable = cpureg_config0[0];
155
 
156
//---
157
// Wishbone signals
158
 
159
assign wb_ack_o = cpuack && wb_stb_i;
160
 
161 27 antanguay
always @(/*AS*/cpureg_config0 or cpureg_int_mask or cpureg_int_pending
162
         or int_sources or stats_rx_octets or stats_rx_pkts
163
         or stats_tx_octets or stats_tx_pkts or wb_adr_i or wb_cyc_i
164
         or wb_dat_i or wb_dat_o or wb_stb_i or wb_we_i) begin
165 2 antanguay
 
166 27 antanguay
    next_wb_dat_o = wb_dat_o;
167 2 antanguay
 
168 27 antanguay
    next_wb_int_o = |(cpureg_int_pending & cpureg_int_mask);
169 2 antanguay
 
170 27 antanguay
    next_cpureg_int_pending = cpureg_int_pending | int_sources;
171 2 antanguay
 
172 27 antanguay
    next_cpuack = wb_cyc_i && wb_stb_i;
173 2 antanguay
 
174 27 antanguay
    //---
175
    // Registers
176 2 antanguay
 
177 27 antanguay
    next_cpureg_config0 = cpureg_config0;
178
    next_cpureg_int_mask = cpureg_int_mask;
179 2 antanguay
 
180 27 antanguay
    //---
181
    // Clear on read signals
182 2 antanguay
 
183 27 antanguay
    clear_stats_tx_octets = 1'b0;
184
    clear_stats_tx_pkts = 1'b0;
185
    clear_stats_rx_octets = 1'b0;
186
    clear_stats_rx_pkts = 1'b0;
187 2 antanguay
 
188 27 antanguay
    //---
189
    // Read access
190 2 antanguay
 
191 27 antanguay
    if (wb_cyc_i && wb_stb_i && !wb_we_i) begin
192 2 antanguay
 
193 27 antanguay
        case ({wb_adr_i[7:2], 2'b0})
194 2 antanguay
 
195 27 antanguay
          `CPUREG_CONFIG0: begin
196
              next_wb_dat_o = {31'b0, cpureg_config0};
197
          end
198 2 antanguay
 
199 27 antanguay
          `CPUREG_INT_PENDING: begin
200 28 antanguay
              next_wb_dat_o = {22'b0, cpureg_int_pending};
201 27 antanguay
              next_cpureg_int_pending = int_sources;
202
              next_wb_int_o = 1'b0;
203
          end
204 2 antanguay
 
205 27 antanguay
          `CPUREG_INT_STATUS: begin
206 28 antanguay
              next_wb_dat_o = {22'b0, int_sources};
207 27 antanguay
          end
208 20 antanguay
 
209 27 antanguay
          `CPUREG_INT_MASK: begin
210 28 antanguay
              next_wb_dat_o = {22'b0, cpureg_int_mask};
211 27 antanguay
          end
212 2 antanguay
 
213 27 antanguay
          `CPUREG_STATSTXOCTETS: begin
214
              next_wb_dat_o = stats_tx_octets;
215
              clear_stats_tx_octets = 1'b1;
216
          end
217 2 antanguay
 
218 27 antanguay
          `CPUREG_STATSTXPKTS: begin
219
              next_wb_dat_o = stats_tx_pkts;
220
              clear_stats_tx_pkts = 1'b1;
221
          end
222 2 antanguay
 
223 27 antanguay
          `CPUREG_STATSRXOCTETS: begin
224
              next_wb_dat_o = stats_rx_octets;
225
              clear_stats_rx_octets = 1'b1;
226
          end
227 24 antanguay
 
228 27 antanguay
          `CPUREG_STATSRXPKTS: begin
229
              next_wb_dat_o = stats_rx_pkts;
230
              clear_stats_rx_pkts = 1'b1;
231
          end
232 23 antanguay
 
233 27 antanguay
          default: begin
234
          end
235 24 antanguay
 
236 27 antanguay
        endcase
237 23 antanguay
 
238 27 antanguay
    end
239 2 antanguay
 
240 27 antanguay
    //---
241
    // Write access
242 2 antanguay
 
243 27 antanguay
    if (wb_cyc_i && wb_stb_i && wb_we_i) begin
244 2 antanguay
 
245 27 antanguay
        case ({wb_adr_i[7:2], 2'b0})
246 2 antanguay
 
247 27 antanguay
          `CPUREG_CONFIG0: begin
248
              next_cpureg_config0 = wb_dat_i[0:0];
249
          end
250 2 antanguay
 
251 27 antanguay
          `CPUREG_INT_PENDING: begin
252 28 antanguay
              next_cpureg_int_pending = wb_dat_i[9:0] | cpureg_int_pending | int_sources;
253 27 antanguay
          end
254 2 antanguay
 
255 27 antanguay
          `CPUREG_INT_MASK: begin
256 28 antanguay
              next_cpureg_int_mask = wb_dat_i[9:0];
257 27 antanguay
          end
258 20 antanguay
 
259 27 antanguay
          default: begin
260
          end
261 2 antanguay
 
262 27 antanguay
        endcase
263 2 antanguay
 
264 27 antanguay
    end
265 2 antanguay
 
266 27 antanguay
end
267 2 antanguay
 
268 27 antanguay
always @(posedge wb_clk_i or posedge wb_rst_i) begin
269 2 antanguay
 
270 27 antanguay
    if (wb_rst_i == 1'b1) begin
271
 
272
        cpureg_config0 <= 1'h1;
273 28 antanguay
        cpureg_int_pending <= 10'b0;
274
        cpureg_int_mask <= 10'b0;
275 27 antanguay
 
276
        wb_dat_o <= 32'b0;
277
        wb_int_o <= 1'b0;
278
 
279
        cpuack <= 1'b0;
280
 
281
        status_remote_fault_d1 <= 1'b0;
282
        status_local_fault_d1 <= 1'b0;
283
 
284 2 antanguay
    end
285 27 antanguay
    else begin
286 2 antanguay
 
287 27 antanguay
        cpureg_config0 <= next_cpureg_config0;
288
        cpureg_int_pending <= next_cpureg_int_pending;
289
        cpureg_int_mask <= next_cpureg_int_mask;
290
 
291
        wb_dat_o <= next_wb_dat_o;
292
        wb_int_o <= next_wb_int_o;
293
 
294
        cpuack <= next_cpuack;
295
 
296
        status_remote_fault_d1 <= status_remote_fault;
297
        status_local_fault_d1 <= status_local_fault;
298
 
299
    end
300
 
301 2 antanguay
end
302
 
303
endmodule

powered by: WebSVN 2.1.0

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