I wrote a quick test bench - I've got no detail of what the two input signals tclk and clkMCU run at, or what baud rate RX is running at. If you can tell me I'll update my test bench.
My simulation throws an error.
run 20 ms
ERROR: Index 8 out of bound 7 downto 0
Time: 938255 ns Iteration: 1 Process: /tb_uart_tx_rx/uut/rx_process
HDL Line: uart.vhd:96
This is the code from lines 94 to 96:
if (indexUartRx_UART >0) then
UARTBufferRx_UART(indexUartRx_UART-1) <= RX;
indexUartRx_UART <= indexUartRx_UART + 1;
Here it is the test bench, in case it proves useful:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity tb_uart_tx_rx is
end tb_uart_tx_rx;
architecture Behavioral of tb_uart_tx_rx is
component uart_tx_rx is
port (
tclk : in std_logic;
clkMCU : in std_logic;
RX : in std_logic;
tx : out std_logic;
debug_pin : out std_logic:= '1';
debug_pin2 : out std_logic;
sync : out std_logic;
sample_clk : out std_logic
);
end component;
signal tclk : std_logic;
signal clkMCU : std_logic;
signal RX : std_logic;
signal tx : std_logic;
signal debug_pin : std_logic:= '1';
signal debug_pin2 : std_logic;
signal sync : std_logic;
signal sample_clk : std_logic;
signal rx_sr : std_logic_vector(39 downto 0) := "1" & x"42" & "0" -- STOP BIT, ASCII C, START BIT
& "1" & x"42" & "0" -- STOP BIT, ASCII B, START BIT
& "1" & x"41" & "0" -- STOP BIT, ASCII A, START BIT
& "1" & x"FF" & "1"; -- all ones - idle period
begin
------------
-- CLOCKS - both 100 MHz
------------
process
begin
tclk <= '0';
wait for 5 ns;
tclk <= '1';
wait for 5 ns;
end process;
process
begin
clkMCU <= '0';
wait for 5 ns;
clkMCU <= '1';
wait for 5 ns;
end process;
---------------------------------
-- Generate 9600 baud serial data
---------------------------------
rx <= rx_sr(0);
process
begin
rx_sr <= rx_sr(0) & rx_sr(rx_sr'high downto 1);
wait for (1000000000/9600) * 1ns;
end process;
-----------------------
-- Unit under test
-----------------------
uut: uart_tx_rx port map (
tclk => tclk,
clkMCU => clkMCU,
RX => rx,
tx => tx,
debug_pin => debug_pin,
debug_pin2 => debug_pin2,
sync => sync,
sample_clk => sample_clk
);
end Behavioral;