Line 4... |
Line 4... |
|
|
--! Use CPU Definitions package
|
--! Use CPU Definitions package
|
use work.pkgDefinitions.all;
|
use work.pkgDefinitions.all;
|
|
|
entity uart_control is
|
entity uart_control is
|
Port ( rst : in STD_LOGIC; -- Global reset
|
Port ( rst : in std_logic; -- Global reset
|
clk : in STD_LOGIC; -- Global clock
|
clk : in std_logic; -- Global clock
|
WE : in STD_LOGIC; -- Write enable
|
WE : in std_logic; -- Write enable
|
reg_addr : in STD_LOGIC_VECTOR (1 downto 0); -- Register address
|
reg_addr : in std_logic_vector (1 downto 0); -- Register address
|
start : in std_logic; -- Start (Strobe)
|
start : in std_logic; -- Start (Strobe)
|
done : out std_logic; -- Done (ACK)
|
done : out std_logic; -- Done (ACK)
|
DAT_I : in STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0); -- Data Input (Wishbone)
|
DAT_I : in std_logic_vector ((nBitsLarge-1) downto 0); -- Data Input (Wishbone)
|
DAT_O : out STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0); -- Data output (Wishbone)
|
DAT_O : out std_logic_vector ((nBitsLarge-1) downto 0); -- Data output (Wishbone)
|
baud_wait : out STD_LOGIC_VECTOR ((nBitsLarge-1) downto 0); -- Signal to control the baud rate frequency
|
baud_wait : out std_logic_vector ((nBitsLarge-1) downto 0); -- Signal to control the baud rate frequency
|
data_byte_tx : out std_logic_vector((nBits-1) downto 0); -- 1 Byte to be send to serial_transmitter
|
data_byte_tx : out std_logic_vector((nBits-1) downto 0); -- 1 Byte to be send to serial_transmitter
|
data_byte_rx : in std_logic_vector((nBits-1) downto 0); -- 1 Byte to be received by serial_receiver
|
data_byte_rx : in std_logic_vector((nBits-1) downto 0); -- 1 Byte to be received by serial_receiver
|
tx_data_sent : in STD_LOGIC; -- Signal comming from serial_transmitter
|
tx_data_sent : in std_logic; -- Signal comming from serial_transmitter
|
rx_data_ready : in STD_LOGIC); -- Signal comming from serial_receiver
|
rst_comm_blocks : out std_logic; -- Reset Communication blocks
|
|
rx_data_ready : in std_logic); -- Signal comming from serial_receiver
|
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);
|
Line 115... |
Line 116... |
controlStates <= idle;
|
controlStates <= idle;
|
baud_configured := '0';
|
baud_configured := '0';
|
clk_configured := '0';
|
clk_configured := '0';
|
div_result_baud_wait := (others => '0');
|
div_result_baud_wait := (others => '0');
|
done <= '0';
|
done <= '0';
|
|
sigDivRst <= '1';
|
|
rst_comm_blocks <= '1';
|
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 173... |
Line 176... |
controlStates <= rx_tx_state;
|
controlStates <= rx_tx_state;
|
done <= '1';
|
done <= '1';
|
|
|
-- Control the serial_receiver or serial_transmitter block
|
-- Control the serial_receiver or serial_transmitter block
|
when rx_tx_state =>
|
when rx_tx_state =>
|
|
rst_comm_blocks <= '0';
|
controlStates <= rx_tx_state;
|
controlStates <= rx_tx_state;
|
if (WE = '1') and (start = '1') then
|
if (WE = '1') and (start = '1') then
|
if reg_addr = "10" then
|
if reg_addr = "10" then
|
controlStates <= tx_state_wait;
|
controlStates <= tx_state_wait;
|
done <= '0';
|
done <= '0';
|