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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [uart_control.vhd] - Diff between revs 16 and 19

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

Rev 16 Rev 19
Line 24... Line 24...
end uart_control;
end uart_control;
 
 
architecture Behavioral of uart_control is
architecture Behavioral of uart_control is
signal config_clk : std_logic_vector((nBitsLarge-1) downto 0);
signal config_clk : std_logic_vector((nBitsLarge-1) downto 0);
signal config_baud : std_logic_vector((nBitsLarge-1) downto 0);
signal config_baud : std_logic_vector((nBitsLarge-1) downto 0);
signal byte_to_receive : std_logic_vector((nBits-1) downto 0);
--signal byte_to_receive : std_logic_vector((nBits-1) downto 0);
signal byte_to_transmitt : std_logic_vector((nBits-1) downto 0);
signal byte_to_transmitt : std_logic_vector((nBits-1) downto 0);
signal controlStates : uartControl;
signal controlStates : uartControl;
 
 
signal sigDivRst : std_logic;
signal sigDivRst : std_logic;
signal sigDivDone : std_logic;
signal sigDivDone : std_logic;
Line 59... Line 59...
                divident => sigDivDividend,
                divident => sigDivDividend,
                done => sigDivDone
                done => sigDivDone
        );
        );
 
 
        -- Process that read uart control registers
        -- Process that read uart control registers
        process (rst, clk, reg_addr,WE)
        process (rst, reg_addr, WE, start, byte_to_transmitt, data_byte_rx, rx_data_ready, config_clk, config_baud)
        begin
        begin
                if rising_edge(clk) then
                if rst = '1' then
 
                        DAT_O <= (others => 'Z');
 
                else
                        if (WE = '0') and (start = '1') then
                        if (WE = '0') and (start = '1') then
                                case reg_addr is
                                case reg_addr is
                                        when "00" =>
                                        when "00" =>
                                                DAT_O <= config_clk;
                                                DAT_O <= config_clk;
                                        when "01" =>
                                        when "01" =>
Line 73... Line 75...
                                        when "10" =>
                                        when "10" =>
                                                -- Byte that will be transmitted
                                                -- Byte that will be transmitted
                                                DAT_O <= "000000000000000000000000" & byte_to_transmitt;
                                                DAT_O <= "000000000000000000000000" & byte_to_transmitt;
                                        when "11" =>
                                        when "11" =>
                                                -- Byte that will be received
                                                -- Byte that will be received
                                                DAT_O <= "000000000000000000000000" & byte_to_receive;
                                                if rx_data_ready = '1' then
 
                                                        DAT_O <= "000000000000000000000000" & data_byte_rx;
 
                                                        --DAT_O <= "000000000000000000000000" & byte_to_receive;
 
                                                else
 
                                                        DAT_O <= (others => 'Z');
 
                                                end if;
                                        when others =>
                                        when others =>
                                                null;
                                                DAT_O <= (others => 'Z');
                                end case;
                                end case;
 
                        else
 
                                DAT_O <= (others => 'Z');
                        end if;
                        end if;
                end if;
                end if;
        end process;
        end process;
 
 
        -- Process that populate the uart control registers
        -- Process that populate the uart control registers
Line 106... Line 115...
                        end if;
                        end if;
                end if;
                end if;
        end process;
        end process;
 
 
        -- Process to handle the next state logic
        -- Process to handle the next state logic
        process (rst, clk, reg_addr, WE)
        process (rst, clk, reg_addr, WE, start)
        variable baud_configured : std_logic;
        variable baud_configured : std_logic;
        variable clk_configured : std_logic;
        variable clk_configured : std_logic;
        variable div_result_baud_wait : std_logic_vector ((nBitsLarge-1) downto 0);
        variable div_result_baud_wait : std_logic_vector ((nBitsLarge-1) downto 0);
        begin
        begin
                if rst = '1' then
                if rst = '1' then
Line 120... Line 129...
                        div_result_baud_wait := (others => '0');
                        div_result_baud_wait := (others => '0');
                        done <= '0';
                        done <= '0';
                        sigDivRst <= '1';
                        sigDivRst <= '1';
                        rst_comm_blocks <= '1';
                        rst_comm_blocks <= '1';
                        tx_start <= '0';
                        tx_start <= '0';
 
                        --byte_to_receive <= (others => 'Z');
                elsif rising_edge(clk) then
                elsif rising_edge(clk) then
                        case controlStates is
                        case controlStates is
                                when idle =>
                                when idle =>
                                        done <= '0';
                                        done <= '0';
                                        -- Go to config state
                                        -- Go to config state
Line 191... Line 201...
                                        end if;
                                        end if;
 
 
                                        if (WE = '0') and (start = '1') then
                                        if (WE = '0') and (start = '1') then
                                                if reg_addr = "11" then
                                                if reg_addr = "11" then
                                                        controlStates <= rx_state_wait;
                                                        controlStates <= rx_state_wait;
                                                        done <= '0';
 
                                                end if;
                                                end if;
                                        end if;
                                        end if;
 
 
 
 
                                -- Send data and wait to transmit
                                -- Send data and wait to transmit
Line 210... Line 219...
                                        end if;
                                        end if;
 
 
                                -- Receive data and wait to receive
                                -- Receive data and wait to receive
                                when rx_state_wait =>
                                when rx_state_wait =>
                                        if rx_data_ready = '1' then
                                        if rx_data_ready = '1' then
                                                byte_to_receive <= data_byte_rx;
                                                -- Put an ack on the next cycle
                                                done <= '1';
                                                controlStates <= rx_state_ack;
                                                controlStates <= rx_tx_state;
 
                                        else
                                        else
                                                controlStates <= rx_state_wait;
                                                controlStates <= rx_state_wait;
 
                                                done <= '0';
                                        end if;
                                        end if;
 
 
 
                                -- Ack that we got a value
 
                                when rx_state_ack =>
 
                                        done <= '1';
 
                                        controlStates <= rx_tx_state;
                        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.