diff --git a/terminal.vhd b/terminal.vhd index 854ad20..2ee85e4 100644 --- a/terminal.vhd +++ b/terminal.vhd @@ -46,6 +46,9 @@ architecture syn of terminal is signal rowlen_we: std_logic; signal rowlen_wa: std_logic_vector(5 downto 0); signal rowlen_di: std_logic_vector(6 downto 0); + + signal last_written_char: std_logic_vector(7 downto 0); + signal last_cursor_col: unsigned(6 downto 0); begin -- writes the next character, advances the cursor and saves the length of @@ -83,6 +86,10 @@ begin end if; if write_enable = '1' then + -- save last written char and column for correct CR, LF handling + last_written_char <= write_data; + last_cursor_col <= cursor_col; + -- backspace if write_data = x"08" then cursor_col <= previous_col; @@ -97,6 +104,12 @@ begin cursor_row <= next_line; rowlen_we <= '1'; -- save row length + -- write the row length with was valid before CR reset the + -- cursor (for consecutive CR, LF) + if last_written_char = x"0d" then + rowlen_di <= std_logic_vector(last_cursor_col); + end if; + -- normal characters else charbuf_we <= '1'; -- write normal characters