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

Subversion Repositories m16c5x

[/] [m16c5x/] [trunk/] [RTL/] [Src/] [UART_BRG.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 MichaelA
////////////////////////////////////////////////////////////////////////////////
2
//
3
//  Copyright 2008-2013 by Michael A. Morris, dba M. A. Morris & Associates
4
//
5
//  All rights reserved. The source code contained herein is publicly released
6
//  under the terms and conditions of the GNU Lesser Public License. No part of
7
//  this source code may be reproduced or transmitted in any form or by any
8
//  means, electronic or mechanical, including photocopying, recording, or any
9
//  information storage and retrieval system in violation of the license under
10
//  which the source code is released.
11
//
12
//  The source code contained herein is free; it may be redistributed and/or
13
//  modified in accordance with the terms of the GNU Lesser General Public
14
//  License as published by the Free Software Foundation; either version 2.1 of
15
//  the GNU Lesser General Public License, or any later version.
16
//
17
//  The source code contained herein is freely released WITHOUT ANY WARRANTY;
18
//  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
19
//  PARTICULAR PURPOSE. (Refer to the GNU Lesser General Public License for
20
//  more details.)
21
//
22
//  A copy of the GNU Lesser General Public License should have been received
23
//  along with the source code contained herein; if not, a copy can be obtained
24
//  by writing to:
25
//
26
//  Free Software Foundation, Inc.
27
//  51 Franklin Street, Fifth Floor
28
//  Boston, MA  02110-1301 USA
29
//
30
//  Further, no use of this source code is permitted in any form or means
31
//  without inclusion of this banner prominently in any derived works.
32
//
33
//  Michael A. Morris
34
//  Huntsville, AL
35
//
36
////////////////////////////////////////////////////////////////////////////////
37
 
38
`timescale 1ns / 1ps
39
 
40
///////////////////////////////////////////////////////////////////////////////
41
// Company:         M. A. Morris & Associates
42
// Engineer:        Michael A. Morris
43
//
44
// Create Date:     13:28:23 05/10/2008 
45
// Design Name:     Synchronous Serial Peripheral (SSP) Interface UART 
46
// Module Name:     ../VerilogCoponentsLib/SSP_UART/UART_BRG.v
47
// Project Name:    Verilog Components Library
48
// Target Devices:  XC3S50A-4VQG100I, XC3S20A-4VQG100I, XC3S700AN-4FFG484I 
49
// Tool versions:   ISE 10.1i SP3 
50
//
51
// Description: This module implements the Baud Rate Generator for the SSP
52
//              UART described for the 1700-0403 MicroBridge Option Card.
53
//
54
//              The Baud Rate Generator implements the 16 baud rates defined
55
//              in Table 3 of the SSP UART Specification.
56
//
57
// Dependencies: 
58
//
59
// Revision History:
60
//
61
//  0.01    08E10   MAM     File Created
62
//
63
//  1.00    08E10   MAM     Initial Release
64
//
65
//  1.10    08E13   MAM     Changed interface so Prescaler and Divider values
66
//                          passed directly in by removing Baud Rate ROM.
67
//
68
//  1.11    08E14   MAM     Reduced width of divider from 10 to 8 bits.
69
//
70
//  1.20    08E15   MAM     Changed the structure of the PSCntr and Divider
71
//                          to use a multiplxer on the input to load or count
72
//                          which results in a more efficient implementation.
73
//                          Added a registered TC on the PSCntr which functions
74
//                          to break the combinatorial logic chains and speed
75
//                          counter implementations.
76
//
77
//  1.30    08G26   MAM     Corrected initial condition of the PSCntr, which
78
//                          caused the prescaler to always divide by two. 
79
//                          Removed FF in PSCntr TC path to remove the divide
80
//                          by two issue. CE_16x output remains as registered.
81
//
82
//  2.00    11B06   MAM     Converted to Verilog 2001.
83
//
84
// Additional Comments: 
85
//
86
///////////////////////////////////////////////////////////////////////////////
87
 
88
module UART_BRG(
89
    input   Rst,
90
    input   Clk,
91
 
92
    input   [3:0] PS,       // Baud Rate Generator Prescaler Load Value
93
    input   [7:0] Div,      // Baud Rate Generator Divider Load Value
94
 
95
    output  reg CE_16x      // Clock Enable Output - 16x Baud Rate Output 
96
);
97
 
98
///////////////////////////////////////////////////////////////////////////////    
99
//
100
//  Local Signal Declarations
101
//
102
 
103
    reg     [ 3:0] PSCntr;  // BRG Prescaler 
104
    reg     [ 7:0] Divider; // BRG Divider
105
 
106
    wire    TC_PSCntr;      // BRG Prescaler TC/Divider CE
107
    wire    TC_Divider;     // BRG Divider TC
108
 
109
///////////////////////////////////////////////////////////////////////////////
110
//
111
//  Implementation
112
//
113
 
114
//  BRG Prescaler Counter
115
 
116
always @(posedge Clk)
117
begin
118
    if(Rst)
119
        PSCntr <= #1 0;
120
    else if(TC_PSCntr)
121
        PSCntr <= #1 PS;
122
    else
123
        PSCntr <= #1 PSCntr - 1;
124
end
125
 
126
assign TC_PSCntr = (PSCntr == 0);
127
 
128
// BRG Divider
129
 
130
always @(posedge Clk)
131
begin
132
    if(Rst)
133
        Divider <= #1 0;
134
    else if(TC_Divider)
135
        Divider <= #1 Div;
136
    else if(TC_PSCntr)
137
        Divider <= #1 Divider - 1;
138
end
139
 
140
assign TC_Divider = TC_PSCntr & (Divider == 0);
141
 
142
// Output 16x Bit Clock/CE
143
 
144
always @(posedge Clk)
145
begin
146
    if(Rst)
147
        CE_16x <= #1 1'b0;
148
    else
149
        CE_16x <= #1 TC_Divider;
150
end
151
 
152
endmodule

powered by: WebSVN 2.1.0

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