---------------------------------------------------------------------------------- -- Company: -- Engineer: -- -- Create Date: 16:04:58 09/23/2009 -- Design Name: -- Module Name: UARTDriver - beh -- Project Name: -- Target Devices: -- Tool versions: -- Description: -- -- Dependencies: -- -- Revision: -- Revision 0.01 - File Created -- Additional Comments: -- ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.NUMERIC_STD.all; -- clk and reset needed for UART state machine. tx_wire is output wire to UART connector. -- rx_wire is input wire from UART connector. entity UARTDriver is Port ( clk : in std_logic; reset : in std_logic; enter_pb_not : in std_logic; LED_0_not : out std_logic; LED_1_not : out std_logic; LED_2_not : out std_logic; LED_3_not : out std_logic; rx_wire : in std_logic; tx_wire : out std_logic); end UARTDriver; -- This is just to demonstrate that the UART works. -- NOTE: Move Switch 3 DOWN to reset -- leave in UP position -- for normal operation architecture beh of UARTDriver is signal tx_full, rx_empty : std_logic; signal trans_data: std_logic_vector(7 downto 0); signal enter_pb, enter_pb_stable, button_level : std_logic; signal tx_go : std_logic; begin -- Invert button value for proper operation of debounce circuit enter_pb <= not enter_pb_not; UARTComponent: entity work.UARTUnit(beh) port map ( clk=>clk, reset=>reset, rd_uart=>tx_go, wr_uart=>tx_go, rx_wire=>rx_wire, tx_loc_sys_data=>trans_data, tx_full=>tx_full, rx_empty=>rx_empty, rx_loc_sys_data=>trans_data, tx_wire=>tx_wire); -- Take the bounce out of the pushbutton (only works for buttons normally at 0 and then go to 1 when pressed!) DebounceInst: entity work.DEBOUNCE(beh) port map (clk=>clk, reset=>reset, button=>enter_pb, button_level=>button_level, button_stable=>enter_pb_stable); -- Pushbutton ENTER used to send byte back to computer serial port tx_go <= '1' when enter_pb_stable = '1' else '0'; -- Echo mode -- tx_go <= not rx_empty; -- LED is on when '0' is written. If rx_empty is '1' (NO DATA), then it writes a 0 turning ON the led. LED_0_not <= not rx_empty; LED_1_not <= not reset; LED_2_not <= not button_level; LED_3_not <= not tx_go; end beh;