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

Subversion Repositories uart16550

[/] [uart16550/] [trunk/] [rtl/] [verilog/] [uart_wb.v] - Blame information for rev 64

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

Line No. Rev Author Line
1 27 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3 33 gorban
////  uart_wb.v                                                   ////
4 27 mohor
////                                                              ////
5
////                                                              ////
6
////  This file is part of the "UART 16550 compatible" project    ////
7
////  http://www.opencores.org/cores/uart16550/                   ////
8
////                                                              ////
9
////  Documentation related to this project:                      ////
10
////  - http://www.opencores.org/cores/uart16550/                 ////
11
////                                                              ////
12
////  Projects compatibility:                                     ////
13
////  - WISHBONE                                                  ////
14
////  RS232 Protocol                                              ////
15
////  16550D uart (mostly supported)                              ////
16
////                                                              ////
17
////  Overview (main Features):                                   ////
18
////  UART core WISHBONE interface.                               ////
19
////                                                              ////
20
////  Known problems (limits):                                    ////
21
////  Inserts one wait state on all transfers.                    ////
22
////  Note affected signals and the way they are affected.        ////
23
////                                                              ////
24
////  To Do:                                                      ////
25
////  Nothing.                                                    ////
26
////                                                              ////
27
////  Author(s):                                                  ////
28
////      - gorban@opencores.org                                  ////
29
////      - Jacob Gorban                                          ////
30 29 mohor
////      - Igor Mohor (igorm@opencores.org)                      ////
31 27 mohor
////                                                              ////
32
////  Created:        2001/05/12                                  ////
33
////  Last Updated:   2001/05/17                                  ////
34
////                  (See log for the revision history)          ////
35
////                                                              ////
36
////                                                              ////
37
//////////////////////////////////////////////////////////////////////
38
////                                                              ////
39 29 mohor
//// Copyright (C) 2000, 2001 Authors                             ////
40 27 mohor
////                                                              ////
41
//// This source file may be used and distributed without         ////
42
//// restriction provided that this copyright statement is not    ////
43
//// removed from the file and that any derivative work contains  ////
44
//// the original copyright notice and the associated disclaimer. ////
45
////                                                              ////
46
//// This source file is free software; you can redistribute it   ////
47
//// and/or modify it under the terms of the GNU Lesser General   ////
48
//// Public License as published by the Free Software Foundation; ////
49
//// either version 2.1 of the License, or (at your option) any   ////
50
//// later version.                                               ////
51
////                                                              ////
52
//// This source is distributed in the hope that it will be       ////
53
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
54
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
55
//// PURPOSE.  See the GNU Lesser General Public License for more ////
56
//// details.                                                     ////
57
////                                                              ////
58
//// You should have received a copy of the GNU Lesser General    ////
59
//// Public License along with this source; if not, download it   ////
60
//// from http://www.opencores.org/lgpl.shtml                     ////
61
////                                                              ////
62
//////////////////////////////////////////////////////////////////////
63
//
64
// CVS Revision History
65
//
66
// $Log: not supported by cvs2svn $
67 64 mohor
// Revision 1.11  2001/12/06 14:51:04  gorban
68
// Bug in LSR[0] is fixed.
69
// All WISHBONE signals are now sampled, so another wait-state is introduced on all transfers.
70
//
71 50 gorban
// Revision 1.10  2001/12/03 21:44:29  gorban
72
// Updated specification documentation.
73
// Added full 32-bit data bus interface, now as default.
74
// Address is 5-bit wide in 32-bit data bus mode.
75
// Added wb_sel_i input to the core. It's used in the 32-bit mode.
76
// Added debug interface with two 32-bit read-only registers in 32-bit mode.
77
// Bits 5 and 6 of LSR are now only cleared on TX FIFO write.
78
// My small test bench is modified to work with 32-bit mode.
79
//
80 48 gorban
// Revision 1.9  2001/10/20 09:58:40  gorban
81
// Small synopsis fixes
82
//
83 33 gorban
// Revision 1.8  2001/08/24 21:01:12  mohor
84
// Things connected to parity changed.
85
// Clock devider changed.
86
//
87 29 mohor
// Revision 1.7  2001/08/23 16:05:05  mohor
88
// Stop bit bug fixed.
89
// Parity bug fixed.
90
// WISHBONE read cycle bug fixed,
91
// OE indicator (Overrun Error) bug fixed.
92
// PE indicator (Parity Error) bug fixed.
93
// Register read bug fixed.
94
//
95 27 mohor
// Revision 1.4  2001/05/31 20:08:01  gorban
96
// FIFO changes and other corrections.
97
//
98
// Revision 1.3  2001/05/21 19:12:01  gorban
99
// Corrected some Linter messages.
100
//
101
// Revision 1.2  2001/05/17 18:34:18  gorban
102
// First 'stable' release. Should be sythesizable now. Also added new header.
103
//
104
// Revision 1.0  2001-05-17 21:27:13+02  jacob
105
// Initial revision
106
//
107
//
108
 
109
// UART core WISHBONE interface 
110
//
111
// Author: Jacob Gorban   (jacob.gorban@flextronicssemi.com)
112
// Company: Flextronics Semiconductor
113
//
114
 
115 33 gorban
// synopsys translate_off
116 27 mohor
`include "timescale.v"
117 33 gorban
// synopsys translate_on
118 50 gorban
`include "uart_defines.v"
119
 
120 48 gorban
module uart_wb (clk, wb_rst_i,
121 50 gorban
        wb_we_i, wb_stb_i, wb_cyc_i, wb_ack_o, wb_adr_i,
122
        wb_adr_int, wb_dat_i, wb_dat_o, wb_dat8_i, wb_dat8_o, wb_dat32_o, wb_sel_i,
123 27 mohor
        we_o, re_o // Write and read enable output for the core
124 48 gorban
);
125 27 mohor
 
126 48 gorban
input             clk;
127 27 mohor
 
128
// WISHBONE interface   
129 48 gorban
input             wb_rst_i;
130
input             wb_we_i;
131
input             wb_stb_i;
132
input             wb_cyc_i;
133
input [3:0]   wb_sel_i;
134 50 gorban
input [`UART_ADDR_WIDTH-1:0]     wb_adr_i; //WISHBONE address line
135
 
136 48 gorban
`ifdef DATA_BUS_WIDTH_8
137
input [7:0]  wb_dat_i; //input WISHBONE bus 
138
output [7:0] wb_dat_o;
139
reg [7:0]         wb_dat_o;
140
wire [7:0]        wb_dat_i;
141 50 gorban
reg [7:0]         wb_dat_is;
142 48 gorban
`else // for 32 data bus mode
143
input [31:0]  wb_dat_i; //input WISHBONE bus 
144
output [31:0] wb_dat_o;
145
reg [31:0]         wb_dat_o;
146
wire [31:0]   wb_dat_i;
147 50 gorban
reg [31:0]         wb_dat_is;
148
`endif // !`ifdef DATA_BUS_WIDTH_8
149
 
150
output [`UART_ADDR_WIDTH-1:0]    wb_adr_int; // internal signal for address bus
151 48 gorban
input [7:0]   wb_dat8_o; // internal 8 bit output to be put into wb_dat_o
152
output [7:0]  wb_dat8_i;
153
input [31:0]  wb_dat32_o; // 32 bit data output (for debug interface)
154
output            wb_ack_o;
155
output            we_o;
156
output            re_o;
157 27 mohor
 
158 48 gorban
wire                      we_o;
159
reg                       wb_ack_o;
160
reg [7:0]          wb_dat8_i;
161
wire [7:0]         wb_dat8_o;
162 50 gorban
wire [`UART_ADDR_WIDTH-1:0]      wb_adr_int; // internal signal for address bus
163
reg [`UART_ADDR_WIDTH-1:0]       wb_adr_is;
164
reg                                                             wb_we_is;
165
reg                                                             wb_cyc_is;
166
reg                                                             wb_stb_is;
167
reg [3:0]                                                wb_sel_is;
168
wire [3:0]   wb_sel_i;
169
reg                      wre ;// timing control signal for write or read enable
170 27 mohor
 
171 50 gorban
// wb_ack_o FSM
172
reg [1:0]         wbstate;
173
always  @(posedge clk or posedge wb_rst_i)
174
        if (wb_rst_i) begin
175 27 mohor
                wb_ack_o <= #1 1'b0;
176 50 gorban
                wbstate <= #1 0;
177 64 mohor
                wre <= #1 1'b1;
178 50 gorban
        end else
179
                case (wbstate)
180
                        0: begin
181
                                if (wb_stb_is & wb_cyc_is) begin
182
                                        wre <= #1 0;
183
                                        wbstate <= #1 1;
184
                                        wb_ack_o <= #1 1;
185
                                end else begin
186
                                        wre <= #1 1;
187
                                        wb_ack_o <= #1 0;
188
                                end
189
                        end
190
                        1: begin
191
                           wb_ack_o <= #1 0;
192
                                wbstate <= #1 2;
193
                                wre <= #1 0;
194
                        end
195
                        2,3: begin
196
                                wb_ack_o <= #1 0;
197
                                wbstate <= #1 0;
198
                                wre <= #1 0;
199
                        end
200
                endcase
201 27 mohor
 
202 50 gorban
assign we_o =  wb_we_is & wb_stb_is & wb_cyc_is & wre ; //WE for registers      
203
assign re_o = ~wb_we_is & wb_stb_is & wb_cyc_is & wre ; //RE for registers      
204 27 mohor
 
205 50 gorban
// Sample input signals
206
always  @(posedge clk or posedge wb_rst_i)
207
        if (wb_rst_i) begin
208
                wb_adr_is <= #1 0;
209
                wb_we_is <= #1 0;
210
                wb_cyc_is <= #1 0;
211
                wb_stb_is <= #1 0;
212
                wb_dat_is <= #1 0;
213
                wb_sel_is <= #1 0;
214
        end else begin
215
                wb_adr_is <= #1 wb_adr_i;
216
                wb_we_is <= #1 wb_we_i;
217
                wb_cyc_is <= #1 wb_cyc_i;
218
                wb_stb_is <= #1 wb_stb_i;
219
                wb_dat_is <= #1 wb_dat_i;
220
                wb_sel_is <= #1 wb_sel_i;
221
        end
222
 
223
assign wb_adr_int = wb_adr_is;
224
 
225 48 gorban
`ifdef DATA_BUS_WIDTH_8 // 8-bit data bus
226
always @(posedge clk or posedge wb_rst_i)
227
        if (wb_rst_i)
228
                wb_dat_o <= #1 0;
229
        else
230
                wb_dat_o <= #1 wb_dat8_o;
231
 
232 50 gorban
always @(wb_dat_is)
233
        wb_dat8_i = wb_dat_is;
234 48 gorban
 
235
`else // 32-bit bus
236
// put output to the correct byte in 32 bits using select line
237
always @(posedge clk or posedge wb_rst_i)
238
        if (wb_rst_i)
239
                wb_dat_o <= #1 0;
240
        else if (re_o)
241 50 gorban
                case (wb_sel_is)
242 48 gorban
                        4'b0001: wb_dat_o <= #1 {24'b0, wb_dat8_o};
243
                        4'b0010: wb_dat_o <= #1 {16'b0, wb_dat8_o, 8'b0};
244
                        4'b0100: wb_dat_o <= #1 {8'b0, wb_dat8_o, 16'b0};
245
                        4'b1000: wb_dat_o <= #1 {wb_dat8_o, 24'b0};
246
                        4'b1111: wb_dat_o <= #1 wb_dat32_o; // debug interface output
247
                        default: wb_dat_o <= #1 0;
248
                endcase // case(wb_sel_i)
249
 
250 50 gorban
always @(wb_sel_is or wb_dat_is)
251
        case (wb_sel_is)
252
                4'b0001 : wb_dat8_i = wb_dat_is[7:0];
253
                4'b0010 : wb_dat8_i = wb_dat_is[15:8];
254
                4'b0100 : wb_dat8_i = wb_dat_is[23:16];
255
                4'b1000 : wb_dat8_i = wb_dat_is[31:24];
256
                default : wb_dat8_i = wb_dat_is[7:0];
257 48 gorban
        endcase // case(wb_sel_i)
258
 
259
`endif // !`ifdef DATA_BUS_WIDTH_8
260
 
261 27 mohor
endmodule
262 48 gorban
 
263
 
264
 
265
 
266
 
267
 
268
 
269
 
270
 
271
 

powered by: WebSVN 2.1.0

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