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 12

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

powered by: WebSVN 2.1.0

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