@@ -27,11 +27,11 @@ use IEEE.STD_LOGIC_UNSIGNED.ALL;
2727
2828entity UART is
2929 Generic (
30- BAUD_RATE : integer := 9600 ; -- baud rate value, default is 9600
31- DATA_BITS : integer := 8 ; -- legal values: 5,6,7,8
32- --STOP_BITS : integer; -- TODO, now must be 1 stop bit
33- --PARITY_BIT : integer; -- TODO, now must be none parity bit
34- CLK_FREQ : integer := 50e6 -- set system clock frequency in Hz, default is 50 MHz
30+ BAUD_RATE : integer := 115200 ; -- baud rate value, default is 115200
31+ DATA_BITS : integer := 8 ; -- legal values: 5,6,7,8, default is 8 dat bits
32+ --STOP_BITS : integer; -- TODO, now must be 1 stop bit
33+ --PARITY_BIT : integer; -- TODO, now must be none parity bit
34+ CLK_FREQ : integer := 50e6 -- set system clock frequency in Hz, default is 50 MHz
3535 );
3636 Port (
3737 CLK : in std_logic ; -- system clock
@@ -118,15 +118,17 @@ begin
118118 -- OUTPUT REGISTER
119119 -- -------------------------------------------------------------------------
120120
121- TX_VALID <= rx_uart_vld;
122-
123121 output_reg : process (CLK)
124122 begin
125123 if (rising_edge (CLK)) then
126124 if (RST = '1' ) then
127125 TX_DATA <= (others => '0' );
128- elsif (rx_uart_vld = '1' ) then
129- TX_DATA <= rx_uart_data;
126+ TX_VALID <= '0' ;
127+ else
128+ if (rx_uart_vld = '1' ) then
129+ TX_DATA <= rx_uart_data;
130+ end if ;
131+ TX_VALID <= rx_uart_vld;
130132 end if ;
131133 end if ;
132134 end process ;
@@ -143,7 +145,7 @@ begin
143145 if (RST = '1' ) then
144146 tx_present_st <= idle;
145147 tx_uart_bit_count <= 0 ;
146- tx_uart_ready <= '0 ' ;
148+ tx_uart_ready <= '1 ' ;
147149 tx_uart_reg <= '1' ;
148150 else
149151 tx_present_st <= tx_next_st;
@@ -180,14 +182,17 @@ begin
180182 if (tx_uart_bit_count = DATA_BITS+ 1 ) then -- stop bit
181183 tx_uart_bit_count_next <= 0 ;
182184 tx_uart_reg_next <= '1' ;
185+ tx_uart_ready_next <= '1' ;
183186 tx_next_st <= idle;
184187 elsif (tx_uart_bit_count = 0 ) then -- start bit
185188 tx_uart_bit_count_next <= tx_uart_bit_count + 1 ;
186189 tx_uart_reg_next <= '0' ;
190+ tx_uart_ready_next <= '0' ;
187191 tx_next_st <= transmit_data;
188192 else -- data bits
189193 tx_uart_bit_count_next <= tx_uart_bit_count + 1 ;
190194 tx_uart_reg_next <= tx_uart_data(tx_uart_bit_count- 1 );
195+ tx_uart_ready_next <= '0' ;
191196 tx_next_st <= transmit_data;
192197 end if ;
193198 end if ;
@@ -234,8 +239,10 @@ begin
234239
235240 when idle =>
236241 if (uart_clk_en = '1' AND RX_UART = '0' ) then
242+ rx_uart_vld_next <= '0' ;
237243 rx_next_st <= receive_data;
238244 else
245+ rx_uart_vld_next <= '0' ;
239246 rx_next_st <= idle;
240247 end if ;
241248
0 commit comments