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 27

Go to most recent revision | 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
  status_crc_error, status_fragment_error, status_txdfifo_ovflow,
48
  status_txdfifo_udflow, status_rxdfifo_ovflow, status_rxdfifo_udflow,
49 23 antanguay
  status_pause_frame_rx, status_local_fault, status_remote_fault,
50 24 antanguay
  stats_tx_octets, stats_tx_pkts, stats_rx_octets, stats_rx_pkts
51 2 antanguay
  );
52
 
53
 
54
input         wb_clk_i;
55
input         wb_rst_i;
56
 
57
input  [7:0]  wb_adr_i;
58
input  [31:0] wb_dat_i;
59
input         wb_we_i;
60
input         wb_stb_i;
61
input         wb_cyc_i;
62
 
63
output [31:0] wb_dat_o;
64
output        wb_ack_o;
65
output        wb_int_o;
66
 
67
input         status_crc_error;
68
input         status_fragment_error;
69 20 antanguay
 
70 2 antanguay
input         status_txdfifo_ovflow;
71
 
72
input         status_txdfifo_udflow;
73
 
74
input         status_rxdfifo_ovflow;
75
 
76
input         status_rxdfifo_udflow;
77
 
78
input         status_pause_frame_rx;
79
 
80
input         status_local_fault;
81
input         status_remote_fault;
82
 
83 24 antanguay
input  [31:0] stats_tx_octets;
84 23 antanguay
input  [31:0] stats_tx_pkts;
85 24 antanguay
 
86
input  [31:0] stats_rx_octets;
87 23 antanguay
input  [31:0] stats_rx_pkts;
88
 
89 2 antanguay
output        ctrl_tx_enable;
90
 
91 27 antanguay
output        clear_stats_tx_octets;
92
output        clear_stats_tx_pkts;
93
output        clear_stats_rx_octets;
94
output        clear_stats_rx_pkts;
95 2 antanguay
 
96
/*AUTOREG*/
97
// Beginning of automatic regs (for this module's undeclared outputs)
98 27 antanguay
reg                     clear_stats_rx_octets;
99
reg                     clear_stats_rx_pkts;
100
reg                     clear_stats_tx_octets;
101
reg                     clear_stats_tx_pkts;
102 2 antanguay
reg [31:0]              wb_dat_o;
103
reg                     wb_int_o;
104
// End of automatics
105
 
106 27 antanguay
reg [31:0]              next_wb_dat_o;
107
reg                     next_wb_int_o;
108
 
109 2 antanguay
reg  [0:0]              cpureg_config0;
110 27 antanguay
reg  [0:0]              next_cpureg_config0;
111
 
112 2 antanguay
reg  [8:0]              cpureg_int_pending;
113 27 antanguay
reg  [8:0]              next_cpureg_int_pending;
114
 
115 2 antanguay
reg  [8:0]              cpureg_int_mask;
116 27 antanguay
reg  [8:0]              next_cpureg_int_mask;
117 2 antanguay
 
118
reg                     cpuack;
119 27 antanguay
reg                     next_cpuack;
120 2 antanguay
 
121
reg                     status_remote_fault_d1;
122
reg                     status_local_fault_d1;
123
 
124
/*AUTOWIRE*/
125
 
126
wire [8:0]             int_sources;
127
 
128
 
129
//---
130
// Source of interrupts, some are edge sensitive, others
131
// expect a pulse signal.
132
 
133
assign int_sources = {
134
                      status_fragment_error,
135
                      status_crc_error,
136
 
137
                      status_pause_frame_rx,
138
 
139
                      status_remote_fault ^ status_remote_fault_d1,
140
                      status_local_fault ^ status_local_fault_d1,
141
 
142
                      status_rxdfifo_udflow,
143
                      status_rxdfifo_ovflow,
144
                      status_txdfifo_udflow,
145
                      status_txdfifo_ovflow
146
                      };
147
 
148
//---
149
// Config Register 0
150
 
151
assign ctrl_tx_enable = cpureg_config0[0];
152
 
153
//---
154
// Wishbone signals
155
 
156
assign wb_ack_o = cpuack && wb_stb_i;
157
 
158 27 antanguay
always @(/*AS*/cpureg_config0 or cpureg_int_mask or cpureg_int_pending
159
         or int_sources or stats_rx_octets or stats_rx_pkts
160
         or stats_tx_octets or stats_tx_pkts or wb_adr_i or wb_cyc_i
161
         or wb_dat_i or wb_dat_o or wb_stb_i or wb_we_i) begin
162 2 antanguay
 
163 27 antanguay
    next_wb_dat_o = wb_dat_o;
164 2 antanguay
 
165 27 antanguay
    next_wb_int_o = |(cpureg_int_pending & cpureg_int_mask);
166 2 antanguay
 
167 27 antanguay
    next_cpureg_int_pending = cpureg_int_pending | int_sources;
168 2 antanguay
 
169 27 antanguay
    next_cpuack = wb_cyc_i && wb_stb_i;
170 2 antanguay
 
171 27 antanguay
    //---
172
    // Registers
173 2 antanguay
 
174 27 antanguay
    next_cpureg_config0 = cpureg_config0;
175
    next_cpureg_int_mask = cpureg_int_mask;
176 2 antanguay
 
177 27 antanguay
    //---
178
    // Clear on read signals
179 2 antanguay
 
180 27 antanguay
    clear_stats_tx_octets = 1'b0;
181
    clear_stats_tx_pkts = 1'b0;
182
    clear_stats_rx_octets = 1'b0;
183
    clear_stats_rx_pkts = 1'b0;
184 2 antanguay
 
185 27 antanguay
    //---
186
    // Read access
187 2 antanguay
 
188 27 antanguay
    if (wb_cyc_i && wb_stb_i && !wb_we_i) begin
189 2 antanguay
 
190 27 antanguay
        case ({wb_adr_i[7:2], 2'b0})
191 2 antanguay
 
192 27 antanguay
          `CPUREG_CONFIG0: begin
193
              next_wb_dat_o = {31'b0, cpureg_config0};
194
          end
195 2 antanguay
 
196 27 antanguay
          `CPUREG_INT_PENDING: begin
197
              next_wb_dat_o = {23'b0, cpureg_int_pending};
198
              next_cpureg_int_pending = int_sources;
199
              next_wb_int_o = 1'b0;
200
          end
201 2 antanguay
 
202 27 antanguay
          `CPUREG_INT_STATUS: begin
203
              next_wb_dat_o = {23'b0, int_sources};
204
          end
205 20 antanguay
 
206 27 antanguay
          `CPUREG_INT_MASK: begin
207
              next_wb_dat_o = {23'b0, cpureg_int_mask};
208
          end
209 2 antanguay
 
210 27 antanguay
          `CPUREG_STATSTXOCTETS: begin
211
              next_wb_dat_o = stats_tx_octets;
212
              clear_stats_tx_octets = 1'b1;
213
          end
214 2 antanguay
 
215 27 antanguay
          `CPUREG_STATSTXPKTS: begin
216
              next_wb_dat_o = stats_tx_pkts;
217
              clear_stats_tx_pkts = 1'b1;
218
          end
219 2 antanguay
 
220 27 antanguay
          `CPUREG_STATSRXOCTETS: begin
221
              next_wb_dat_o = stats_rx_octets;
222
              clear_stats_rx_octets = 1'b1;
223
          end
224 24 antanguay
 
225 27 antanguay
          `CPUREG_STATSRXPKTS: begin
226
              next_wb_dat_o = stats_rx_pkts;
227
              clear_stats_rx_pkts = 1'b1;
228
          end
229 23 antanguay
 
230 27 antanguay
          default: begin
231
          end
232 24 antanguay
 
233 27 antanguay
        endcase
234 23 antanguay
 
235 27 antanguay
    end
236 2 antanguay
 
237 27 antanguay
    //---
238
    // Write access
239 2 antanguay
 
240 27 antanguay
    if (wb_cyc_i && wb_stb_i && wb_we_i) begin
241 2 antanguay
 
242 27 antanguay
        case ({wb_adr_i[7:2], 2'b0})
243 2 antanguay
 
244 27 antanguay
          `CPUREG_CONFIG0: begin
245
              next_cpureg_config0 = wb_dat_i[0:0];
246
          end
247 2 antanguay
 
248 27 antanguay
          `CPUREG_INT_PENDING: begin
249
              next_cpureg_int_pending = wb_dat_i[8:0] | cpureg_int_pending | int_sources;
250
          end
251 2 antanguay
 
252 27 antanguay
          `CPUREG_INT_MASK: begin
253
              next_cpureg_int_mask = wb_dat_i[8:0];
254
          end
255 20 antanguay
 
256 27 antanguay
          default: begin
257
          end
258 2 antanguay
 
259 27 antanguay
        endcase
260 2 antanguay
 
261 27 antanguay
    end
262 2 antanguay
 
263 27 antanguay
end
264 2 antanguay
 
265 27 antanguay
always @(posedge wb_clk_i or posedge wb_rst_i) begin
266 2 antanguay
 
267 27 antanguay
    if (wb_rst_i == 1'b1) begin
268
 
269
        cpureg_config0 <= 1'h1;
270
        cpureg_int_pending <= 9'b0;
271
        cpureg_int_mask <= 9'b0;
272
 
273
        wb_dat_o <= 32'b0;
274
        wb_int_o <= 1'b0;
275
 
276
        cpuack <= 1'b0;
277
 
278
        status_remote_fault_d1 <= 1'b0;
279
        status_local_fault_d1 <= 1'b0;
280
 
281 2 antanguay
    end
282 27 antanguay
    else begin
283 2 antanguay
 
284 27 antanguay
        cpureg_config0 <= next_cpureg_config0;
285
        cpureg_int_pending <= next_cpureg_int_pending;
286
        cpureg_int_mask <= next_cpureg_int_mask;
287
 
288
        wb_dat_o <= next_wb_dat_o;
289
        wb_int_o <= next_wb_int_o;
290
 
291
        cpuack <= next_cpuack;
292
 
293
        status_remote_fault_d1 <= status_remote_fault;
294
        status_local_fault_d1 <= status_local_fault;
295
 
296
    end
297
 
298 2 antanguay
end
299
 
300
endmodule

powered by: WebSVN 2.1.0

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