1 ------------------------------------------------------------------------------
3 ---- RS-232 simple Tx module ----
5 ---- http://www.opencores.org/ ----
8 ---- Implements a simple 8N1 tx module for RS-232. ----
14 ---- - Philippe Carton, philippe.carton2 libertysurf.fr ----
15 ---- - Juan Pablo Daniel Borgna, jpdborgna gmail.com ----
16 ---- - Salvador E. Tropea, salvador inti.gob.ar ----
18 ------------------------------------------------------------------------------
20 ---- Copyright (c) 2001-2003 Philippe Carton ----
21 ---- Copyright (c) 2005 Juan Pablo Daniel Borgna ----
22 ---- Copyright (c) 2005-2008 Salvador E. Tropea ----
23 ---- Copyright (c) 2005-2008 Instituto Nacional de TecnologĂa Industrial ----
25 ---- Distributed under the GPL license ----
27 ------------------------------------------------------------------------------
29 ---- Design unit: TxUnit(Behaviour) (Entity and architecture) ----
30 ---- File name: Txunit.vhdl ----
32 ---- Limitations: None known ----
33 ---- Errors: None known ----
34 ---- Library: zpu ----
35 ---- Dependencies: IEEE.std_logic_1164 ----
37 ---- Target FPGA: Spartan ----
38 ---- Language: VHDL ----
39 ---- Wishbone: No ----
40 ---- Synthesis tools: Xilinx Release 9.2.03i - xst J.39 ----
41 ---- Simulation tools: GHDL [Sokcho edition] (0.2x) ----
42 ---- Text editor: SETEdit 0.5.x ----
44 ------------------------------------------------------------------------------
47 use IEEE.std_logic_1164.all;
53 clk_i : in std_logic; -- Clock signal
54 reset_i : in std_logic; -- Reset input
55 enable_i : in std_logic; -- Enable input
56 load_i : in std_logic; -- Load input
57 txd_o : out std_logic; -- RS-232 data output
58 busy_o : out std_logic; -- Tx Busy
59 datai_i : in std_logic_vector(7 downto 0)); -- Byte to transmit
62 architecture Behaviour of TxUnit is
63 signal tbuff_r : std_logic_vector(7 downto 0); -- transmit buffer
64 signal t_r : std_logic_vector(7 downto 0); -- transmit register
65 signal loaded_r : std_logic:='0'; -- Buffer loaded
66 signal txd_r : std_logic:='1'; -- Tx buffer ready
68 busy_o <= load_i or loaded_r;
74 variable bitpos : integer range 0 to 10; -- Bit position in the frame
76 if rising_edge(clk_i) then
88 when 0 => -- idle or stop bit
90 if loaded_r='1' then -- start transmit. next is start bit
95 when 1 => -- Start bit
99 txd_r <= t_r(bitpos-2); -- Serialisation of t_r
102 if bitpos=10 then -- bit8. next is stop bit
105 end if; -- enable_i='1'
106 end if; -- reset_i='0'
107 end if; -- rising_edge(clk_i)
109 end architecture Behaviour;