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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [serial_receiver.vhd] - Diff between revs 34 and 35

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

Rev 34 Rev 35
Line 7... Line 7...
use work.pkgDefinitions.all;
use work.pkgDefinitions.all;
 
 
entity serial_receiver is
entity serial_receiver is
    Port (
    Port (
                          rst : in STD_LOGIC;
                          rst : in STD_LOGIC;
                          baudClk : in  STD_LOGIC;
 
                          baudOverSampleClk : in  STD_LOGIC;
                          baudOverSampleClk : in  STD_LOGIC;
           serial_in : in  STD_LOGIC;
           serial_in : in  STD_LOGIC;
           data_ready : out  STD_LOGIC;
           data_ready : out  STD_LOGIC;
           data_byte : out  STD_LOGIC_VECTOR ((nBits-1) downto 0));
           data_byte : out  STD_LOGIC_VECTOR ((nBits-1) downto 0));
end serial_receiver;
end serial_receiver;
 
 
architecture Behavioral of serial_receiver is
architecture Behavioral of serial_receiver is
signal current_s: rxStates;
signal current_s: rxStates;
signal filterRx : rxFilterStates;
signal filterRx : rxFilterStates;
signal syncDetected : std_logic;
signal syncDetected : std_logic;
signal getPoint : std_logic;
 
 
 
begin
begin
        -- First we need to oversample(4x baud rate) out serial channel to syncronize with the PC
        -- First we need to oversample(4x baud rate) out serial channel to syncronize with the PC
        process (rst, baudOverSampleClk, serial_in, current_s)
        process (rst, baudOverSampleClk, serial_in, current_s)
        begin
        begin
Line 96... Line 94...
                if syncDetected = '0' then
                if syncDetected = '0' then
                        current_s <= bit0;
                        current_s <= bit0;
                        data_ready <= '0';
                        data_ready <= '0';
                        byteReceived := (others => '0');
                        byteReceived := (others => '0');
                        waitBestPoint := 0;
                        waitBestPoint := 0;
                        getPoint <= '0';
 
                elsif rising_edge(baudOverSampleClk) then
                elsif rising_edge(baudOverSampleClk) then
                        case current_s is
                        case current_s is
                                when bit0 =>
                                when bit0 =>
                                        data_ready <= '0';
                                        data_ready <= '0';
                                        if (waitBestPoint < numTicks) then
                                        if (waitBestPoint < numTicks) then
                                                waitBestPoint := waitBestPoint + 1;
                                                waitBestPoint := waitBestPoint + 1;
                                                getPoint <= '0';
 
                                        else
                                        else
                                                waitBestPoint := 0;
                                                waitBestPoint := 0;
                                                byteReceived(0) := serial_in;
                                                byteReceived(0) := serial_in;
                                                current_s <=  bit1;
                                                current_s <=  bit1;
                                                getPoint <= '1';
 
                                        end if;
                                        end if;
 
 
                                when bit1 =>
                                when bit1 =>
                                        data_ready <= '0';
                                        data_ready <= '0';
                                        if (waitBestPoint < numTicks) then
                                        if (waitBestPoint < numTicks) then
                                                waitBestPoint := waitBestPoint + 1;
                                                waitBestPoint := waitBestPoint + 1;
                                                getPoint <= '0';
 
                                        else
                                        else
                                                waitBestPoint := 0;
                                                waitBestPoint := 0;
                                                byteReceived(1) := serial_in;
                                                byteReceived(1) := serial_in;
                                                current_s <=  bit2;
                                                current_s <=  bit2;
                                                getPoint <= '1';
 
                                        end if;
                                        end if;
 
 
                                when bit2 =>
                                when bit2 =>
                                        data_ready <= '0';
                                        data_ready <= '0';
                                        if (waitBestPoint < numTicks) then
                                        if (waitBestPoint < numTicks) then
                                                waitBestPoint := waitBestPoint + 1;
                                                waitBestPoint := waitBestPoint + 1;
                                                getPoint <= '0';
 
                                        else
                                        else
                                                waitBestPoint := 0;
                                                waitBestPoint := 0;
                                                byteReceived(2) := serial_in;
                                                byteReceived(2) := serial_in;
                                                current_s <=  bit3;
                                                current_s <=  bit3;
                                                getPoint <= '1';
 
                                        end if;
                                        end if;
 
 
                                when bit3 =>
                                when bit3 =>
                                        data_ready <= '0';
                                        data_ready <= '0';
                                        if (waitBestPoint < numTicks) then
                                        if (waitBestPoint < numTicks) then
                                                waitBestPoint := waitBestPoint + 1;
                                                waitBestPoint := waitBestPoint + 1;
                                                getPoint <= '0';
 
                                        else
                                        else
                                                waitBestPoint := 0;
                                                waitBestPoint := 0;
                                                byteReceived(3) := serial_in;
                                                byteReceived(3) := serial_in;
                                                current_s <=  bit4;
                                                current_s <=  bit4;
                                                getPoint <= '1';
 
                                        end if;
                                        end if;
 
 
                                when bit4 =>
                                when bit4 =>
                                        data_ready <= '0';
                                        data_ready <= '0';
                                        if (waitBestPoint < numTicks) then
                                        if (waitBestPoint < numTicks) then
                                                waitBestPoint := waitBestPoint + 1;
                                                waitBestPoint := waitBestPoint + 1;
                                                getPoint <= '0';
 
                                        else
                                        else
                                                waitBestPoint := 0;
                                                waitBestPoint := 0;
                                                byteReceived(4) := serial_in;
                                                byteReceived(4) := serial_in;
                                                current_s <=  bit5;
                                                current_s <=  bit5;
                                                getPoint <= '1';
 
                                        end if;
                                        end if;
 
 
                                when bit5 =>
                                when bit5 =>
                                        data_ready <= '0';
                                        data_ready <= '0';
                                        if (waitBestPoint < numTicks) then
                                        if (waitBestPoint < numTicks) then
                                                waitBestPoint := waitBestPoint + 1;
                                                waitBestPoint := waitBestPoint + 1;
                                                getPoint <= '0';
 
                                        else
                                        else
                                                waitBestPoint := 0;
                                                waitBestPoint := 0;
                                                byteReceived(5) := serial_in;
                                                byteReceived(5) := serial_in;
                                                current_s <=  bit6;
                                                current_s <=  bit6;
                                                getPoint <= '1';
 
                                        end if;
                                        end if;
 
 
                                when bit6 =>
                                when bit6 =>
                                        data_ready <= '0';
                                        data_ready <= '0';
                                        if (waitBestPoint < numTicks) then
                                        if (waitBestPoint < numTicks) then
                                                waitBestPoint := waitBestPoint + 1;
                                                waitBestPoint := waitBestPoint + 1;
                                                getPoint <= '0';
 
                                        else
                                        else
                                                waitBestPoint := 0;
                                                waitBestPoint := 0;
                                                byteReceived(6) := serial_in;
                                                byteReceived(6) := serial_in;
                                                current_s <=  bit7;
                                                current_s <=  bit7;
                                                getPoint <= '1';
 
                                        end if;
                                        end if;
 
 
                                when bit7 =>
                                when bit7 =>
                                        data_ready <= '0';
                                        data_ready <= '0';
                                        if (waitBestPoint < numTicks) then
                                        if (waitBestPoint < numTicks) then
                                                waitBestPoint := waitBestPoint + 1;
                                                waitBestPoint := waitBestPoint + 1;
                                                getPoint <= '0';
 
                                        else
                                        else
                                                waitBestPoint := 0;
                                                waitBestPoint := 0;
                                                byteReceived(7) := serial_in;
                                                byteReceived(7) := serial_in;
                                                data_byte <= byteReceived;
                                                data_byte <= byteReceived;
                                                current_s <=  rx_stop;
                                                current_s <=  rx_stop;
                                                getPoint <= '1';
 
                                        end if;
                                        end if;
 
 
                                when rx_stop =>
                                when rx_stop =>
                                        data_ready <= '1';
                                        data_ready <= '1';
                                        data_byte <= byteReceived;
                                        data_byte <= byteReceived;
Line 205... Line 186...
 
 
                                when rx_idle =>
                                when rx_idle =>
                                        data_ready <= '1';
                                        data_ready <= '1';
                                        data_byte <= byteReceived;
                                        data_byte <= byteReceived;
                                        current_s <=  rx_idle;
                                        current_s <=  rx_idle;
 
 
                        end case;
                        end case;
                end if;
                end if;
        end process;
        end process;
 
 
end Behavioral;
end Behavioral;

powered by: WebSVN 2.1.0

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