From 227dce66e968e7580b5540f8556ca27ee0e349bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20Sch=C3=B6lhorn?= Date: Mon, 4 Jun 2018 15:47:58 +0200 Subject: [PATCH] Implement backspace control character --- terminal.vhd | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/terminal.vhd b/terminal.vhd index 745dcf8..854ad20 100644 --- a/terminal.vhd +++ b/terminal.vhd @@ -52,6 +52,7 @@ begin -- the current row before jumping to the next one process(sys_clk) variable next_line: unsigned(5 downto 0); + variable previous_col: unsigned(6 downto 0); begin if rising_edge(sys_clk) then -- we write to the current cursor position and simply pass the data @@ -74,9 +75,20 @@ begin next_line := cursor_row + 1; end if; + -- calculate previous column (saturating) + if cursor_col = 0 then + previous_col := (others => '0'); + else + previous_col := cursor_col - 1; + end if; + if write_enable = '1' then + -- backspace + if write_data = x"08" then + cursor_col <= previous_col; + -- carriage return - if write_data = x"0d" then + elsif write_data = x"0d" then cursor_col <= (others => '0'); -- line feed (implicit CR)