Line 37... |
Line 37... |
signal bits_write_reg : std_logic_vector(3 downto 0);
|
signal bits_write_reg : std_logic_vector(3 downto 0);
|
signal data_write_reg : std_logic_vector(8 downto 0);
|
signal data_write_reg : std_logic_vector(8 downto 0);
|
signal delay_read_reg : std_logic_vector(9 downto 0);
|
signal delay_read_reg : std_logic_vector(9 downto 0);
|
signal bits_read_reg : std_logic_vector(3 downto 0);
|
signal bits_read_reg : std_logic_vector(3 downto 0);
|
signal data_read_reg : std_logic_vector(7 downto 0);
|
signal data_read_reg : std_logic_vector(7 downto 0);
|
signal data_save_reg : std_logic_vector(8 downto 0);
|
signal data_save_reg : std_logic_vector(17 downto 0);
|
signal busy_write_sig : std_logic;
|
signal busy_write_sig : std_logic;
|
signal read_value_reg : std_logic_vector(7 downto 0);
|
signal read_value_reg : std_logic_vector(7 downto 0);
|
signal uart_read2 : std_logic;
|
signal uart_read2 : std_logic;
|
|
|
begin
|
begin
|
Line 65... |
Line 65... |
delay_write_reg <= ZERO(9 downto 0);
|
delay_write_reg <= ZERO(9 downto 0);
|
read_value_reg <= ONES(7 downto 0);
|
read_value_reg <= ONES(7 downto 0);
|
data_read_reg <= ZERO(7 downto 0);
|
data_read_reg <= ZERO(7 downto 0);
|
bits_read_reg <= "0000";
|
bits_read_reg <= "0000";
|
delay_read_reg <= ZERO(9 downto 0);
|
delay_read_reg <= ZERO(9 downto 0);
|
data_save_reg <= ZERO(8 downto 0);
|
data_save_reg <= ZERO(17 downto 0);
|
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
|
|
--Write UART
|
--Write UART
|
if bits_write_reg = "0000" then --nothing left to write?
|
if bits_write_reg = "0000" then --nothing left to write?
|
if enable_write = '1' then
|
if enable_write = '1' then
|
Line 112... |
Line 112... |
end if;
|
end if;
|
else
|
else
|
delay_read_reg <= delay_read_reg - 1; --delay
|
delay_read_reg <= delay_read_reg - 1; --delay
|
end if;
|
end if;
|
|
|
|
--Control character buffer
|
if bits_read_reg = "0000" and delay_read_reg = COUNT_VALUE then
|
if bits_read_reg = "0000" and delay_read_reg = COUNT_VALUE then
|
data_save_reg <= '1' & data_read_reg;
|
if data_save_reg(8) = '0' or
|
|
(enable_read = '1' and data_save_reg(17) = '0') then
|
|
--Empty buffer
|
|
data_save_reg(8 downto 0) <= '1' & data_read_reg;
|
|
else
|
|
--Second character in buffer
|
|
data_save_reg(17 downto 9) <= '1' & data_read_reg;
|
|
if enable_read = '1' then
|
|
data_save_reg(8 downto 0) <= data_save_reg(17 downto 9);
|
|
end if;
|
|
end if;
|
elsif enable_read = '1' then
|
elsif enable_read = '1' then
|
data_save_reg(8) <= '0'; --data_available
|
data_save_reg(17) <= '0'; --data_available
|
|
data_save_reg(8 downto 0) <= data_save_reg(17 downto 9);
|
end if;
|
end if;
|
end if; --rising_edge(clk)
|
end if; --rising_edge(clk)
|
|
|
uart_write <= data_write_reg(0);
|
uart_write <= data_write_reg(0);
|
if bits_write_reg /= "0000"
|
if bits_write_reg /= "0000"
|