@@ -67,7 +67,7 @@ end component;
6767
6868-- FIFO
6969type FIFO_RAM is array (0 to FIFO_SIZE - 1 ) of std_logic_vector (8 downto 0 );
70- signal FIFO : FIFO_RAM;
70+ signal FIFO : FIFO_RAM := ( others => "000000000" ) ;
7171signal FIFO_WP : unsigned (integer (ceil (log2 (real (FIFO_SIZE)))) - 1 downto 0 ) := (others => '0' );
7272signal FIFO_RP : unsigned (integer (ceil (log2 (real (FIFO_SIZE)))) - 1 downto 0 ) := (others => '0' );
7373
@@ -101,10 +101,14 @@ begin
101101 tx => tx
102102 );
103103
104- uart_rx : process (uart_rx_enable, uart_rx_data, rx_resetvalid, FIFO_RP, FIFO_WP)
104+ uart_rx : process (uart_rx_enable, uart_rx_data, rx_resetvalid, FIFO_RP, FIFO_WP, reset )
105105 begin
106- if rx_resetvalid = '1' then
107- FIFO(to_integer (FIFO_RP))(8 ) <= '0' ;
106+ if rx_resetvalid = '1' or reset = '1' then
107+ if reset = '1' then
108+ FIFO(0 )(8 ) <= '0' ;
109+ else
110+ FIFO(to_integer (FIFO_RP))(8 ) <= '0' ;
111+ end if ;
108112 else
109113 if rising_edge (uart_rx_enable) then
110114 FIFO(to_integer (FIFO_WP))(7 downto 0 ) <= uart_rx_data;
@@ -113,23 +117,31 @@ begin
113117 end if ;
114118 end process ;
115119
116- uart_inc_wp : process (uart_rx_enable, FIFO_WP)
120+ uart_inc_wp : process (uart_rx_enable, FIFO_WP, reset )
117121 begin
118- if falling_edge (uart_rx_enable) then
119- FIFO_WP <= FIFO_WP + 1 ;
122+ if reset = '1' then
123+ FIFO_WP <= (others => '0' );
124+ else
125+ if falling_edge (uart_rx_enable) then
126+ FIFO_WP <= FIFO_WP + 1 ;
127+ end if ;
120128 end if ;
121129 end process ;
122130
123- uart_inc_rp : process (rx_resetvalid, FIFO_RP)
124- begin
125- if falling_edge (rx_resetvalid) then
126- FIFO_RP <= FIFO_RP + 1 ;
131+ uart_inc_rp : process (rx_resetvalid, FIFO_RP, reset)
132+ begin
133+ if reset = '1' then
134+ FIFO_RP <= (others => '0' );
135+ else
136+ if falling_edge (rx_resetvalid) then
137+ FIFO_RP <= FIFO_RP + 1 ;
138+ end if ;
127139 end if ;
128140 end process ;
129141
130142 uart_cts_controller : process (FIFO_RP, FIFO_WP)
131143 begin
132- if abs (signed (FIFO_RP) - signed (FIFO_WP)) > 4 then
144+ if abs (signed (FIFO_RP) - signed (FIFO_WP)) > (FIFO_SIZE / 4 ) then
133145 cts <= '1' ;
134146 cts_led <= '1' ;
135147 else
@@ -177,5 +189,7 @@ begin
177189 end if ;
178190 end process ;
179191
192+
193+
180194end beh;
181195
0 commit comments