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 23

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

powered by: WebSVN 2.1.0

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