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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_21/] [or1200/] [rtl/] [verilog/] [or1200_wb_biu.v] - Blame information for rev 504

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's WISHBONE BIU                                       ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Implements WISHBONE interface                               ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - add support for wb_err_i                                 ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47
// Revision 1.12  2001/11/22 13:42:51  lampret
48
// Added wb_cyc_o assignment after it was removed by accident.
49
//
50
// Revision 1.11  2001/11/20 21:28:10  lampret
51
// Added optional sampling of inputs.
52
//
53
// Revision 1.10  2001/11/18 11:32:00  lampret
54
// OR1200_REGISTERED_OUTPUTS can now be enabled.
55
//
56
// Revision 1.9  2001/10/21 17:57:16  lampret
57
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
58
//
59
// Revision 1.8  2001/10/14 13:12:10  lampret
60
// MP3 version.
61
//
62
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
63
// no message
64
//
65
// Revision 1.3  2001/08/09 13:39:33  lampret
66
// Major clean-up.
67
//
68
// Revision 1.2  2001/07/22 03:31:54  lampret
69
// Fixed RAM's oen bug. Cache bypass under development.
70
//
71
// Revision 1.1  2001/07/20 00:46:23  lampret
72
// Development version of RTL. Libraries are missing.
73
//
74
//
75
 
76
// synopsys translate_off
77
`include "timescale.v"
78
// synopsys translate_on
79
`include "or1200_defines.v"
80
 
81
module or1200_wb_biu(
82
        // RISC clock, reset and clock control
83
        clk, rst, clmode,
84
 
85
        // WISHBONE interface
86
        wb_clk_i, wb_rst_i, wb_ack_i, wb_err_i, wb_rty_i, wb_dat_i,
87
        wb_cyc_o, wb_adr_o, wb_stb_o, wb_we_o, wb_sel_o, wb_cab_o, wb_dat_o,
88
 
89
        // Internal RISC bus
90
        biu_dat_i, biu_adr_i, biu_cyc_i, biu_stb_i, biu_we_i, biu_sel_i, biu_cab_i,
91
        biu_dat_o, biu_ack_o, biu_err_o
92
);
93
 
94
parameter dw = `OR1200_OPERAND_WIDTH;
95
parameter aw = `OR1200_OPERAND_WIDTH;
96
 
97
//
98
// RISC clock, reset and clock control
99
//
100
input                   clk;            // RISC clock
101
input                   rst;            // RISC reset
102
input   [1:0]            clmode;         // 00 WB=RISC, 01 WB=RISC/2, 10 N/A, 11 WB=RISC/4
103
 
104
//
105
// WISHBONE interface
106
//
107
input                   wb_clk_i;       // clock input
108
input                   wb_rst_i;       // reset input
109
input                   wb_ack_i;       // normal termination
110
input                   wb_err_i;       // termination w/ error
111
input                   wb_rty_i;       // termination w/ retry
112
input   [dw-1:0] wb_dat_i;       // input data bus
113
output                  wb_cyc_o;       // cycle valid output
114
output  [aw-1:0] wb_adr_o;       // address bus outputs
115
output                  wb_stb_o;       // strobe output
116
output                  wb_we_o;        // indicates write transfer
117
output  [3:0]            wb_sel_o;       // byte select outputs
118
output                  wb_cab_o;       // consecutive address burst
119
output  [dw-1:0] wb_dat_o;       // output data bus
120
 
121
//
122
// Internal RISC interface
123
//
124
input   [dw-1:0] biu_dat_i;      // input data bus
125
input   [aw-1:0] biu_adr_i;      // address bus
126
input                   biu_cyc_i;      // WB cycle
127
input                   biu_stb_i;      // WB strobe
128
input                   biu_we_i;       // WB write enable
129
input                   biu_cab_i;      // CAB input
130
input   [3:0]            biu_sel_i;      // byte selects
131
output  [31:0]           biu_dat_o;      // output data bus
132
output                  biu_ack_o;      // ack output
133
output                  biu_err_o;      // err output
134
 
135
//
136
// Registers
137
//
138
reg     [1:0]            valid_div;      // Used for synchronization
139
`ifdef OR1200_REGISTERED_OUTPUTS
140
reg     [aw-1:0] wb_adr_o;       // address bus outputs
141
reg                     wb_cyc_o;       // cycle output
142
reg                     wb_stb_o;       // strobe output
143
reg                     wb_we_o;        // indicates write transfer
144
reg     [3:0]            wb_sel_o;       // byte select outputs
145
reg                     wb_cab_o;       // CAB output
146
reg     [dw-1:0] wb_dat_o;       // output data bus
147
`endif
148
`ifdef OR1200_REGISTERED_INPUTS
149
reg                     long_ack_o;     // normal termination
150
reg                     long_err_o;     // error termination
151
reg     [dw-1:0] biu_dat_o;      // output data bus
152
`else
153
wire                    long_ack_o;     // normal termination
154
wire                    long_err_o;     // error termination
155
`endif
156
 
157
//
158
// WISHBONE I/F <-> Internal RISC I/F conversion
159
//
160
 
161
//
162
// Address bus
163
//
164
`ifdef OR1200_REGISTERED_OUTPUTS
165
always @(posedge wb_clk_i or posedge wb_rst_i)
166
        if (wb_rst_i)
167
                wb_adr_o <= #1 {aw{1'b0}};
168
        else if ((biu_cyc_i & biu_stb_i) & ~wb_ack_i)
169
                wb_adr_o <= #1 biu_adr_i;
170
`else
171
assign wb_adr_o = biu_adr_i;
172
`endif
173
 
174
//
175
// Input data bus
176
//
177
`ifdef OR1200_REGISTERED_INPUTS
178
always @(posedge wb_clk_i or posedge wb_rst_i)
179
        if (wb_rst_i)
180
                biu_dat_o <= #1 32'h0000_0000;
181
        else if (wb_ack_i)
182
                biu_dat_o <= #1 wb_dat_i;
183
`else
184
assign biu_dat_o = wb_dat_i;
185
`endif
186
 
187
//
188
// Output data bus
189
//
190
`ifdef OR1200_REGISTERED_OUTPUTS
191
always @(posedge wb_clk_i or posedge wb_rst_i)
192
        if (wb_rst_i)
193
                wb_dat_o <= #1 {dw{1'b0}};
194
        else if ((biu_cyc_i & biu_stb_i) & ~wb_ack_i)
195
                wb_dat_o <= #1 biu_dat_i;
196
`else
197
assign wb_dat_o = biu_dat_i;
198
`endif
199
 
200
//
201
// Valid_div counts RISC clock cycles by modulo 4
202
// and is used to synchronize external WB i/f to
203
// RISC clock
204
//
205
always @(posedge clk or posedge rst)
206
        if (rst)
207
                valid_div <= #1 2'b0;
208
        else
209
                valid_div <= #1 valid_div + 'd1;
210
 
211
//
212
// biu_ack_o is one RISC clock cycle long long_ack_o.
213
// long_ack_o is one, two or four RISC clock cycles long because
214
// WISHBONE can work at 1, 1/2 or 1/4 RISC clock.
215
//
216
assign biu_ack_o = long_ack_o
217
`ifdef OR1200_CLKDIV_4_SUPPORTED
218
                & (valid_div[1] | ~clmode[1])
219
`ifdef OR1200_CLKDIV_2_SUPPORTED
220
                & (valid_div[0] | ~clmode[0])
221
`endif
222
`endif
223
                ;
224
 
225
//
226
// Acknowledgment of the data to the RISC
227
//
228
// long_ack_o
229
//
230
`ifdef OR1200_REGISTERED_INPUTS
231
always @(posedge wb_clk_i or posedge wb_rst_i)
232
        if (wb_rst_i)
233
                long_ack_o <= #1 1'b0;
234
        else
235
                long_ack_o <= #1 wb_ack_i;
236
`else
237
assign long_ack_o = wb_ack_i;
238
`endif
239
 
240
//
241
// biu_err_o is one RISC clock cycle long long_err_o.
242
// long_err_o is one, two or four RISC clock cycles long because
243
// WISHBONE can work at 1, 1/2 or 1/4 RISC clock.
244
//
245
assign biu_err_o = long_err_o
246
`ifdef OR1200_CLKDIV_4_SUPPORTED
247
                & (valid_div[1] | ~clmode[1])
248
`ifdef OR1200_CLKDIV_2_SUPPORTED
249
                & (valid_div[0] | ~clmode[0])
250
`endif
251
`endif
252
                ;
253
 
254
//
255
// Error termination
256
//
257
// long_err_o
258
//
259
`ifdef OR1200_REGISTERED_INPUTS
260
always @(posedge wb_clk_i or posedge wb_rst_i)
261
        if (wb_rst_i)
262
                long_err_o <= #1 1'b0;
263
        else
264
                long_err_o <= #1 wb_err_i;
265
`else
266
assign long_err_o = wb_err_i;
267
`endif
268
 
269
//
270
// WB cyc_o
271
//
272
`ifdef OR1200_REGISTERED_OUTPUTS
273
always @(posedge wb_clk_i or posedge wb_rst_i)
274
        if (wb_rst_i)
275
                wb_cyc_o <= #1 1'b0;
276
        else
277
                wb_cyc_o <= #1 biu_cyc_i & ~wb_ack_i | biu_cab_i;
278
`else
279
assign wb_cyc_o = biu_cyc_i | biu_cab_i;
280
`endif
281
 
282
//
283
// WB stb_o
284
//
285
`ifdef OR1200_REGISTERED_OUTPUTS
286
always @(posedge wb_clk_i or posedge wb_rst_i)
287
        if (wb_rst_i)
288
                wb_stb_o <= #1 1'b0;
289
        else
290
                wb_stb_o <= #1 (biu_cyc_i & biu_stb_i) & ~wb_ack_i;
291
`else
292
assign wb_stb_o = biu_cyc_i & biu_stb_i;
293
`endif
294
 
295
//
296
// WB we_o
297
//
298
`ifdef OR1200_REGISTERED_OUTPUTS
299
always @(posedge wb_clk_i or posedge wb_rst_i)
300
        if (wb_rst_i)
301
                wb_we_o <= #1 1'b0;
302
        else
303
                wb_we_o <= #1 biu_cyc_i & biu_stb_i & biu_we_i;
304
`else
305
assign wb_we_o = biu_cyc_i & biu_stb_i & biu_we_i;
306
`endif
307
 
308
//
309
// WB sel_o
310
//
311
`ifdef OR1200_REGISTERED_OUTPUTS
312
always @(posedge wb_clk_i or posedge wb_rst_i)
313
        if (wb_rst_i)
314
                wb_sel_o <= #1 4'b0000;
315
        else
316
                wb_sel_o <= #1 biu_sel_i;
317
`else
318
assign wb_sel_o = biu_sel_i;
319
`endif
320
 
321
//
322
// WB cab_o
323
//
324
`ifdef OR1200_REGISTERED_OUTPUTS
325
always @(posedge wb_clk_i or posedge wb_rst_i)
326
        if (wb_rst_i)
327
                wb_cab_o <= #1 1'b0;
328
        else
329
                wb_cab_o <= #1 biu_cab_i;
330
`else
331
assign wb_cab_o = biu_cab_i;
332
`endif
333
 
334
endmodule

powered by: WebSVN 2.1.0

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