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

Subversion Repositories uart6551

[/] [uart6551/] [trunk/] [trunk/] [rtl/] [uart6551BaudLUT.sv] - Diff between revs 2 and 6

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 6
Line 1... Line 1...
// ============================================================================
// ============================================================================
//        __
//        __
//   \\__/ o\    (C) 2005-2019  Robert Finch, Waterloo
//   \\__/ o\    (C) 2005-2022 Robert Finch, Waterloo
//    \  __ /    All rights reserved.
//    \  __ /    All rights reserved.
//     \/_//     robfinch@finitron.ca
//     \/_//     robfinch@finitron.ca
//       ||
//       ||
//
//
//
//
// This source file is free software: you can redistribute it and/or modify
// BSD 3-Clause License
// it under the terms of the GNU Lesser General Public License as published
// Redistribution and use in source and binary forms, with or without
// by the Free Software Foundation, either version 3 of the License, or
// modification, are permitted provided that the following conditions are met:
// (at your option) any later version.
//
//
// 1. Redistributions of source code must retain the above copyright notice, this
// This source file is distributed in the hope that it will be useful,
//    list of conditions and the following disclaimer.
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// 2. Redistributions in binary form must reproduce the above copyright notice,
// GNU General Public License for more details.
//    this list of conditions and the following disclaimer in the documentation
//
//    and/or other materials provided with the distribution.
// You should have received a copy of the GNU General Public License
//
// along with this program.  If not, see .
// 3. Neither the name of the copyright holder nor the names of its
 
//    contributors may be used to endorse or promote products derived from
 
//    this software without specific prior written permission.
 
//
 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
// ============================================================================
// ============================================================================
//
//
module uart6551BaudLUT(a, o);
module uart6551BaudLUT(a, o);
 
parameter CLK_FREQ = 100;
parameter pCounterBits = 24;
parameter pCounterBits = 24;
input [4:0] a;
input [4:0] a;
output reg [pCounterBits-1:0] o;
output reg [pCounterBits-1:0] o;
 
 
 
/*
// table for a 50.000MHz reference clock
// table for a 50.000MHz reference clock
// value = 50,000,000 / (baud * 16)
// value = 50,000,000 / (baud * 16)
always @(a)
always_comb
        case (a)        // synopsys full_case parallel_case
        case (a)        // synopsys full_case parallel_case
        5'd0:   o <= 0;
        5'd0:   o <= 0;
        5'd1:   o <= 24'd62500; // 50 baud
        5'd1:   o <= 24'd62500; // 50 baud
        5'd2:   o <= 24'd41667; // 75 baud
        5'd2:   o <= 24'd41667; // 75 baud
        5'd3:   o <= 24'd28617; // 109.92 baud
        5'd3:   o <= 24'd28617; // 109.92 baud
Line 53... Line 68...
        5'd19:  o <= 24'd14;    // 230400 baud
        5'd19:  o <= 24'd14;    // 230400 baud
        5'd20:  o <= 24'd7;     // 460800 baud
        5'd20:  o <= 24'd7;     // 460800 baud
        5'd21:  o <= 24'd3;     // 921600 baud
        5'd21:  o <= 24'd3;     // 921600 baud
        default:        o <= 24'd326;   // 9600 baud
        default:        o <= 24'd326;   // 9600 baud
        endcase
        endcase
 
*/
 
 
 
// table for a 40.000MHz reference clock
 
// value = 40,000,000 / (baud * 16)
 
 
 
always_comb
 
if (CLK_FREQ==40)
 
        case (a)        // synopsys full_case parallel_case
 
        5'd0:   o <= 0;
 
        5'd1:   o <= 24'd50000; // 50 baud
 
        5'd2:   o <= 24'd33333; // 75 baud
 
        5'd3:   o <= 24'd22744; // 109.92 baud
 
        5'd4:   o <= 24'd18576; // 134.58 baud
 
        5'd5:   o <= 24'd16667; // 150 baud
 
        5'd6:   o <= 24'd8333;  // 300 baud
 
        5'd7:   o <= 24'd4167;  // 600 baud
 
        5'd8:   o <= 24'd2083;  // 1200 baud
 
        5'd9:   o <= 24'd1389;  // 1800 baud
 
        5'd10:  o <= 24'd1042;  // 2400 baud
 
        5'd11:  o <= 24'd694;   // 3600 baud
 
        5'd12:  o <= 24'd521;   // 4800 baud
 
        5'd13:  o <= 24'd347;   // 7200 baud
 
        5'd14:  o <= 24'd260;   // 9600 baud
 
        5'd15:  o <= 24'd130;   // 19200 baud
 
 
 
        5'd16:  o <= 24'd65;    // 38400 baud
 
        5'd17:  o <= 24'd43;    // 57600 baud
 
        5'd18:  o <= 24'd22;    // 115200 baud
 
        5'd19:  o <= 24'd11;    // 230400 baud
 
        5'd20:  o <= 24'd5;     // 460800 baud
 
        5'd21:  o <= 24'd3;     // 921600 baud
 
        default:        o <= 24'd260;   // 9600 baud
 
        endcase
 
else if (CLK_FREQ==60)
 
// table for a 60.000MHz reference clock
 
        case (a)        // synopsys full_case parallel_case
 
        5'd0:   o <= 0;
 
        5'd1:   o <= 24'd75000; // 50 baud
 
        5'd2:   o <= 24'd50000; // 75 baud
 
        5'd3:   o <= 24'd34116; // 109.92 baud
 
        5'd4:   o <= 24'd27864; // 134.58 baud
 
        5'd5:   o <= 24'd25000; // 150 baud
 
        5'd6:   o <= 24'd12500; // 300 baud
 
        5'd7:   o <= 24'd6250;  // 600 baud
 
        5'd8:   o <= 24'd3125;  // 1200 baud
 
        5'd9:   o <= 24'd2083;  // 1800 baud
 
        5'd10:  o <= 24'd1563;  // 2400 baud
 
        5'd11:  o <= 24'd1042;  // 3600 baud
 
        5'd12:  o <= 24'd781;   // 4800 baud
 
        5'd13:  o <= 24'd521;   // 7200 baud
 
        5'd14:  o <= 24'd391;   // 9600 baud
 
        5'd15:  o <= 24'd195;   // 19200 baud
 
 
 
        5'd16:  o <= 24'd98;    // 38400 baud
 
        5'd17:  o <= 24'd65;    // 57600 baud
 
        5'd18:  o <= 24'd33;    // 115200 baud
 
        5'd19:  o <= 24'd16;    // 230400 baud
 
        5'd20:  o <= 24'd8;     // 460800 baud
 
        5'd21:  o <= 24'd4;     // 921600 baud
 
        default:        o <= 24'd391;   // 9600 baud
 
        endcase
 
else if (CLK_FREQ==100)
 
// 100MHz
 
        case (a)        // synopsys full_case parallel_case
 
        5'd0:   o <= 0;
 
        5'd1:   o <= 24'd125000;        // 50 baud
 
        5'd2:   o <= 24'd83333; // 75 baud
 
        5'd3:   o <= 24'd56860; // 109.92 baud
 
        5'd4:   o <= 24'd46441; // 134.58 baud
 
        5'd5:   o <= 24'd41667; // 150 baud
 
        5'd6:   o <= 24'd20833; // 300 baud
 
        5'd7:   o <= 24'd10417; // 600 baud
 
        5'd8:   o <= 24'd5208;  // 1200 baud
 
        5'd9:   o <= 24'd3472;  // 1800 baud
 
        5'd10:  o <= 24'd2604;  // 2400 baud
 
        5'd11:  o <= 24'd1736;  // 3600 baud
 
        5'd12:  o <= 24'd1302;  // 4800 baud
 
        5'd13:  o <= 24'd868;   // 7200 baud
 
        5'd14:  o <= 24'd651;   // 9600 baud
 
        5'd15:  o <= 24'd326;   // 19200 baud
 
 
 
        5'd16:  o <= 24'd163;   // 38400 baud
 
        5'd17:  o <= 24'd109;   // 57600 baud
 
        5'd18:  o <= 24'd54;    // 115200 baud
 
        5'd19:  o <= 24'd27;    // 230400 baud
 
        5'd20:  o <= 24'd14;    // 460800 baud
 
        5'd21:  o <= 24'd7;     // 921600 baud
 
        default:        o <= 24'd651;   // 9600 baud
 
        endcase
 
 
 
 
endmodule
endmodule
 
 
 
 

powered by: WebSVN 2.1.0

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