2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
4 --use work.gen_pkg.all;
7 -- type STATE_UART_TX is (IDLE, STARTBITS, PAYLOAD, PARITY, STOP, DONE);
8 -- type PARITY_TYPE is (ODD, EVEN, NONE);
9 --end package int_types;
13 sys_clk : in std_logic;
14 sys_res : in std_logic;
16 tx_data : in std_logic_vector(7 downto 0); -- map this to a larger register with containing input
17 tx_new : in std_logic;
18 tx_done : out std_logic
22 architecture beh of uart_tx is
23 signal timer : integer range 0 to 65535;
24 signal timer_next : integer range 0 to 65535;
25 constant timer_max : integer := 35;
26 signal counter : integer range 0 to 15;
27 signal counter_next : integer range 0 to 15;
28 signal txd_next : std_logic;
30 process (sys_clk, sys_res)
37 elsif rising_edge(sys_clk) then
38 counter <= counter_next;
46 if (timer = timer_max) then
49 timer_next <= timer + 1;
53 process (timer, counter, tx_new)
55 if (tx_new = '1') then
56 if (timer = timer_max) then
57 if (counter > 10) then
60 counter_next <= counter + 1;
63 counter_next <= counter;
72 -- TODO: this is always 8N1 and anything but optimal
77 txd_next <= tx_data(0);
79 txd_next <= tx_data(1);
81 txd_next <= tx_data(2);
83 txd_next <= tx_data(3);
85 txd_next <= tx_data(4);
87 txd_next <= tx_data(5);
89 txd_next <= tx_data(6);
91 txd_next <= tx_data(7);
103 end architecture beh;