entity uart is
+ generic(
+ OUTPUTS : integer := 1
+ );
port(
CLK : in std_logic;
RESET : in std_logic;
- UART_RX : in std_logic;
- UART_TX : out std_logic;
+ UART_RX : in std_logic_vector(0 to OUTPUTS-1);
+ UART_TX : out std_logic_vector(0 to OUTPUTS-1);
DATA_OUT : out std_logic_vector(31 downto 0);
DATA_IN : in std_logic_vector(31 downto 0);
signal rx_ready : std_logic;
signal tx_send : std_logic;
signal tx_ready : std_logic;
+signal out_sel : integer range 0 to 15 := 0;
+signal uart_sel_rx : std_logic;
+signal uart_sel_tx : std_logic;
signal clk_div : integer := 100000000/57600;
CLK_DIV => clk_div,
CLK => CLK,
RST => RESET,
- RX => UART_RX,
+ RX => uart_sel_rx,
DATA_OUT => rx_data,
DATA_WAITING => rx_ready
);
DATA_IN => tx_fifo_out(7 downto 0),
SEND => tx_send,
READY => tx_ready,
- TX => UART_TX
+ TX => uart_sel_tx
);
elsif ADDR_IN(3 downto 0) = x"1" then
clk_div <= to_integer(unsigned(DATA_IN));
ACK_OUT <= '1';
+ elsif ADDR_IN(3 downto 0) = x"2" then
+ out_sel <= to_integer(unsigned(DATA_IN(3 downto 0)));
+ ACK_OUT <= '1';
else
UNKWN_OUT <= '1';
end if;
elsif ADDR_IN(3 downto 0) = x"1" then
DATA_OUT <= std_logic_vector(to_unsigned(clk_div,32));
ACK_OUT <= '1';
+ elsif ADDR_IN(3 downto 0) = x"2" then
+ DATA_OUT(3 downto 0) <= std_logic_vector(to_unsigned(out_sel,4));
+ ACK_OUT <= '1';
else
UNKWN_OUT <= '1';
end if;
end if;
end process;
-
+
+proc_io : process begin
+ wait until rising_edge(CLK);
+ UART_TX <= (others => '1');
+ UART_TX(out_sel) <= uart_sel_tx;
+ uart_sel_rx <= UART_RX(out_sel);
+end process;
end architecture;