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

Subversion Repositories xge_mac

[/] [xge_mac/] [tags/] [initial/] [rtl/] [verilog/] [wishbone_if.v] - Blame information for rev 7

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

powered by: WebSVN 2.1.0

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