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 24

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

powered by: WebSVN 2.1.0

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