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
53 elsif rising_edge(sys_clk) then
54 push_history <= push_history_next;
55 spalte <= spalte_next;
58 if (char_en = '1') then
65 variable spalte_tmp, zeile_tmp : integer;
67 if (spalte_up = '1') then
68 if (spalte > X"45") then
69 spalte_next <= "0000000";
70 zeile_tmp := to_integer(unsigned(zeile));
71 zeile_tmp := zeile_tmp + 1;
72 zeile_next <= hbyte(to_unsigned(zeile_tmp,8));
74 spalte_tmp := to_integer(unsigned(spalte));
75 spalte_tmp := spalte_tmp + 1;
76 spalte_next <= hbyte(to_unsigned(spalte_tmp,8));
83 async_push_history : process (rx_new, rx_data, btn_a)
86 if rx_data = X"41" then
87 push_history_next <= '1';
89 push_history_next <= '0';
91 elsif btn_a = '1' then
92 push_history_next <= '1';
94 push_history_next <= '0';
96 end process async_push_history;
98 output_pc : process (zeile, spalte)
102 spalte_next <= "0000000";
103 zeile_next <= "0000000";
109 -- wait for timer overflow
117 -- be there for a single cycle and then
119 end process output_pc;
121 next_state_pc : process (rx_new, btn_a)
125 if rx_new= '1' or btn_a = '1' then
127 char <= d_char; --latch
130 if (d_done = '1') then
131 state_next <= FORWARD;
134 if (tx_done = '1') then
138 -- be there for a single cycle and then
141 end process next_state_pc;
143 end architecture beh;