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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [system/] [uart.v] - Diff between revs 2 and 13

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

Rev 2 Rev 13
Line 51... Line 51...
//                                                              //
//                                                              //
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
 
 
`include "system_config_defines.v"
`include "system_config_defines.v"
 
 
 
// Normally AMBER_UART_BAUD is defined in the system_config_defines.v file.
 
`ifndef AMBER_UART_BAUD
 
`define AMBER_UART_BAUD 230400
 
`endif
 
 
module uart (
module uart (
input                       i_clk,
input                       i_clk,
 
 
input       [31:0]          i_wb_adr,
input       [31:0]          i_wb_adr,
input       [3:0]           i_wb_sel,
input       [3:0]           i_wb_sel,
Line 94... Line 99...
                 TXD_STOP3 = 4'd12;
                 TXD_STOP3 = 4'd12;
 
 
localparam [3:0] RXD_IDLE      = 4'd0,
localparam [3:0] RXD_IDLE      = 4'd0,
                 RXD_START     = 4'd1,
                 RXD_START     = 4'd1,
                 RXD_START_MID = 4'd2,
                 RXD_START_MID = 4'd2,
                 RXD_DATA0     = 4'd3,
                 RXD_START_MID1 = 4'd3,
                 RXD_DATA1     = 4'd4,
                 RXD_DATA0      = 4'd4,
                 RXD_DATA2     = 4'd5,
                 RXD_DATA1      = 4'd5,
                 RXD_DATA3     = 4'd6,
                 RXD_DATA2      = 4'd6,
                 RXD_DATA4     = 4'd7,
                 RXD_DATA3      = 4'd7,
                 RXD_DATA5     = 4'd8,
                 RXD_DATA4      = 4'd8,
                 RXD_DATA6     = 4'd9,
                 RXD_DATA5      = 4'd9,
                 RXD_DATA7     = 4'd10,
                 RXD_DATA6      = 4'd10,
                 RXD_STOP      = 4'd11;
                 RXD_DATA7      = 4'd11,
 
                 RXD_STOP       = 4'd12;
 
 
 
 
localparam RX_INTERRUPT_COUNT = 24'h3fffff;
localparam RX_INTERRUPT_COUNT = 24'h3fffff;
 
 
 
 
Line 114... Line 120...
// Baud Rate Configuration
// Baud Rate Configuration
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
 
 
`ifndef Veritak
`ifndef Veritak
localparam real UART_BAUD         = `AMBER_UART_BAUD;            // Hz
localparam real UART_BAUD         = `AMBER_UART_BAUD;            // Hz
 
 
 
`ifdef XILINX_VIRTEX6_FPGA
 
localparam real CLK_FREQ          = 1000.0 / `AMBER_CLK_DIVIDER ; // MHz
 
`else
localparam real CLK_FREQ          = 800.0 / `AMBER_CLK_DIVIDER ; // MHz
localparam real CLK_FREQ          = 800.0 / `AMBER_CLK_DIVIDER ; // MHz
 
`endif
 
 
localparam real UART_BIT_PERIOD   = 1000000000 / UART_BAUD;      // nS
localparam real UART_BIT_PERIOD   = 1000000000 / UART_BAUD;      // nS
localparam real UART_WORD_PERIOD  = ( UART_BIT_PERIOD * 12 );    // nS
localparam real UART_WORD_PERIOD  = ( UART_BIT_PERIOD * 12 );    // nS
localparam real CLK_PERIOD        = 1000 / CLK_FREQ;             // nS
localparam real CLK_PERIOD        = 1000 / CLK_FREQ;             // nS
localparam real CLKS_PER_WORD     = UART_WORD_PERIOD / CLK_PERIOD;
localparam real CLKS_PER_WORD     = UART_WORD_PERIOD / CLK_PERIOD;
localparam real CLKS_PER_BIT      = CLKS_PER_WORD / 12;
localparam real CLKS_PER_BIT      = CLKS_PER_WORD / 12;
Line 563... Line 575...
 
 
        RXD_START :
        RXD_START :
            // Filter out glitches and jaggedy transitions
            // Filter out glitches and jaggedy transitions
            if ( rx_start )
            if ( rx_start )
                begin
                begin
                rxd_state               <= RXD_START_MID;
                rxd_state               <= RXD_START_MID1;
                restart_rx_bit_count    <= 1'd1;
                restart_rx_bit_count    <= 1'd1;
                end
                end
            else
            else
                restart_rx_bit_count    <= 1'd0;
                restart_rx_bit_count    <= 1'd0;
 
 
 
        // This state just delays the check on the
 
        // rx_bit_pulse_count value by 1 clock cycle to
 
        // give it time to reset
 
        RXD_START_MID1 :
 
            rxd_state               <= RXD_START_MID;
 
 
        RXD_START_MID :
        RXD_START_MID :
            if ( rx_bit_pulse_count == RX_HALFPULSE_COUNT )
            if ( rx_bit_pulse_count == RX_HALFPULSE_COUNT )
                begin
                begin
                rxd_state               <= RXD_DATA0;
                rxd_state               <= RXD_DATA0;
                restart_rx_bit_count    <= 1'd1;
                restart_rx_bit_count    <= 1'd1;
Line 930... Line 948...
                         txd_state == TXD_STOP3     ? "TXD_STOP3"  :
                         txd_state == TXD_STOP3     ? "TXD_STOP3"  :
                                                      "UNKNOWN"    ;
                                                      "UNKNOWN"    ;
 
 
assign xRXD_STATE      = rxd_state == RXD_IDLE      ? "RXD_IDLE"      :
assign xRXD_STATE      = rxd_state == RXD_IDLE      ? "RXD_IDLE"      :
                         rxd_state == RXD_START     ? "RXD_START"     :
                         rxd_state == RXD_START     ? "RXD_START"     :
 
                         rxd_state == RXD_START_MID1 ? "RXD_START_MID1":
                         rxd_state == RXD_START_MID ? "RXD_START_MID" :
                         rxd_state == RXD_START_MID ? "RXD_START_MID" :
                         rxd_state == RXD_DATA0     ? "RXD_DATA0"     :
                         rxd_state == RXD_DATA0     ? "RXD_DATA0"     :
                         rxd_state == RXD_DATA1     ? "RXD_DATA1"     :
                         rxd_state == RXD_DATA1     ? "RXD_DATA1"     :
                         rxd_state == RXD_DATA2     ? "RXD_DATA2"     :
                         rxd_state == RXD_DATA2     ? "RXD_DATA2"     :
                         rxd_state == RXD_DATA3     ? "RXD_DATA3"     :
                         rxd_state == RXD_DATA3     ? "RXD_DATA3"     :

powered by: WebSVN 2.1.0

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