Advertisement
Guest User

Untitled

a guest
May 16th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.22 KB | None | 0 0
  1. LIBRARY ieee;
  2.     USE ieee.std_logic_1164.all;
  3.     use ieee.numeric_std.ALL;
  4.    
  5. entity TX is
  6.     port (
  7.         clk_in: in STD_LOGIC;
  8.         start: in STD_LOGIC;
  9.         data: in STD_LOGIC_VECTOR(7 downto 0);
  10.        
  11.         tx: out STD_LOGIC;
  12.         txIdle: out STD_LOGIC
  13.     );
  14. end entity;
  15.  
  16. architecture Test of TX is
  17.     signal idle: STD_LOGIC;
  18. begin
  19.     process (clk_in)
  20.         variable bitIndex : integer range 0 to 9;
  21.         variable clkDividerCounter : integer range 0 to 260;
  22.        
  23.         variable dataFrame : STD_LOGIC_VECTOR(9 downto 0);
  24.         variable dataFrameCurrentIndex : integer range 0 to 9;
  25.     begin
  26.         if (rising_edge(clk_in)) then
  27.             if (start = '1' and idle = '1') then
  28.                 dataFrame(0) := '0';
  29.                 dataFrame(8 downto 1) := data;
  30.                 dataFrame(9) := '1';
  31.            
  32.                 dataFrameCurrentIndex := 0;
  33.                
  34.                 idle <= '0';
  35.             end if;
  36.    
  37.             if (idle = '0') then               
  38.                 if (clkDividerCounter < 260) then
  39.                     clkDividerCounter := clkDividerCounter + 1;
  40.                 else
  41.                     if (dataFrameCurrentIndex <= 9) then
  42.                         tx <= dataFrame(dataFrameCurrentIndex);
  43.                         dataFrameCurrentIndex := dataFrameCurrentIndex + 1;
  44.                     else
  45.                         idle <= '1';
  46.                     end if;
  47.                    
  48.                     clkDividerCounter := 0;
  49.                 end if;
  50.             end if;
  51.    
  52.             txIdle <= idle;
  53.         end if;
  54.     end process;
  55. end Test;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement