2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
6 entity pc_communication is
8 sys_clk : in std_logic;
9 sys_res_n : in std_logic;
15 tx_data : out std_logic_vector(7 downto 0);
16 tx_new : out std_logic;
17 tx_done : in std_logic;
20 rx_data : in std_logic_vector(7 downto 0); --not really required
21 rx_new : in std_logic;
25 d_spalte : out hspalte;
26 d_get : out std_logic;
27 d_done : in std_logic;
30 end entity pc_communication;
32 architecture beh of pc_communication is
33 signal push_history, push_history_next : std_logic;
35 signal spalte, spalte_next : hspalte;
36 signal zeile , zeile_next : hzeile;
37 signal spalte_up, spalte_up_next : std_logic;
39 signal char, char_next : hbyte;
40 signal char_en : std_logic;
41 type STATE_PC is (IDLE, FETCH, FORWARD, DONE);
42 signal state, state_next : STATE_PC ;
46 sync: process (sys_clk, sys_res_n)
48 if sys_res_n = '0' then
52 spalte_next <= "0000000";
54 zeile_next <= "0000000";
57 tx_data <= "00000000";
58 elsif rising_edge(sys_clk) then
59 push_history <= push_history_next;
60 spalte <= spalte_next;
63 if (char_en = '1') then
70 variable spalte_tmp, zeile_tmp : integer;
71 variable spalte2_tmp, zeile2_tmp : std_logic_vector(7 downto 0);
73 if (spalte_up = '1') then
74 if (spalte > X"45") then
75 spalte_next <= "0000000";
76 zeile_tmp := to_integer(unsigned(zeile)) + 1;
77 zeile2_tmp := std_logic_vector(to_unsigned(zeile_tmp,8));
78 zeile_next <= hzeile(zeile2_tmp(6 downto 0));
80 spalte_tmp := to_integer(unsigned(spalte)) + 1;
81 spalte2_tmp := std_logic_vector(to_unsigned(spalte_tmp,8));
82 spalte_next <= hspalte(spalte2_tmp(6 downto 0));
90 async_push_history : process (rx_new, rx_data, btn_a)
93 if rx_data = X"41" then
94 push_history_next <= '1';
96 push_history_next <= '0';
98 elsif btn_a = '1' then
99 push_history_next <= '1';
101 push_history_next <= '0';
103 end process async_push_history;
105 output_pc : process (state, zeile, spalte, char)
108 spalte_next <= "0000000";
109 zeile_next <= "0000000";
114 d_zeile <= zeile_next;
115 d_spalte <= spalte_next;
118 -- wait for timer overflow
126 -- be there for a single cycle and then
128 end process output_pc;
130 next_state_pc : process (rx_new, btn_a, d_done, tx_done)
135 if rx_new = '1' or btn_a = '1' then
137 char <= d_char; --latch
140 if (d_done = '1') then
141 state_next <= FORWARD;
144 if (tx_done = '1') then
149 -- be there for a single cycle and then
152 end process next_state_pc;
154 end architecture beh;