Advertisement
Guest User

uart_interface

a guest
Sep 4th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.63 KB | None | 0 0
  1. LIBRARY ieee;
  2. use ieee.numeric_std.all;
  3. use IEEE.std_logic_1164.all;
  4.  
  5. ENTITY uart_interface IS
  6.     generic (
  7.             g_CLKS_PER_BIT : integer     -- fpga clock freq / baudrate = 133E6/115200 ~= 1155
  8.         );
  9.     PORT(  
  10.             rst                     :   in  std_logic;
  11.             clk                     :   in  std_logic;
  12.            
  13.             rx_serial               :   in  std_logic;
  14.            
  15.             ready                   :   out std_logic;
  16.            
  17.             byte0                   :   out std_logic_vector(7 downto 0);
  18.             byte1                   :   out std_logic_vector(7 downto 0);
  19.             byte2                   :   out std_logic_vector(7 downto 0);
  20.             byte3                   :   out std_logic_vector(7 downto 0);
  21.             byte4                   :   out std_logic_vector(7 downto 0);
  22.             byte5                   :   out std_logic_vector(7 downto 0)
  23.         );
  24. END ENTITY uart_interface;
  25.  
  26. ARCHITECTURE behavioural OF uart_interface IS
  27.     component uart_receiver
  28.         generic (
  29.             g_CLKS_PER_BIT : integer     -- fpga clock freq / baudrate = 133E6/115200 ~= 1155
  30.         );
  31.        
  32.             port (
  33.         rst         : in    std_logic;
  34.         clk         : in    std_logic; -- fpga clock
  35.         rx_serial   : in    std_logic; -- RX signal coming from the serial-communication cable
  36.        
  37.         rx_dv       : out   std_logic; -- data valid signal
  38.         rx_byte     : out   std_logic_vector(7 downto 0) -- 8 bit data
  39.         );
  40.     end component;
  41.    
  42.     component uart_byte_collector
  43.         PORT(  
  44.             rst                     :   in  std_logic;
  45.             clk                     :   in  std_logic;
  46.            
  47.             rx_dv                   :   in  std_logic;
  48.             rx_byte                 :   in  std_logic_vector(7 downto 0);
  49.            
  50.             ready                   :   out std_logic;
  51.            
  52.             byte0                   :   out std_logic_vector(7 downto 0);
  53.             byte1                   :   out std_logic_vector(7 downto 0);
  54.             byte2                   :   out std_logic_vector(7 downto 0);
  55.             byte3                   :   out std_logic_vector(7 downto 0);
  56.             byte4                   :   out std_logic_vector(7 downto 0);
  57.             byte5                   :   out std_logic_vector(7 downto 0)
  58.         );
  59.     end component;
  60.    
  61.     signal rx_dv : std_logic;
  62.     signal rx_byte : std_logic_vector(7 downto 0);
  63.    
  64. begin
  65.  
  66.  
  67.     inst_uart_receiver : uart_receiver      generic map (
  68.                                                             g_CLKS_PER_BIT => g_CLKS_PER_BIT
  69.                                                     )
  70.                                             port map (
  71.                                                             rst => rst,
  72.                                                             clk => clk,
  73.                                                             rx_serial => rx_serial,
  74.                                                             rx_dv => rx_dv,
  75.                                                             rx_byte => rx_byte
  76.                                                     );
  77.    
  78.     inst_uart_byte_collector : uart_byte_collector
  79.                                             port map (
  80.                                                                     rst => rst,
  81.                                                                     clk => clk,
  82.                                                                     rx_dv => rx_dv,
  83.                                                                     rx_byte => rx_byte,
  84.                                                                    
  85.                                                                     ready => ready,
  86.                                                                    
  87.                                                                     byte0 => byte0,
  88.                                                                     byte1 => byte1,
  89.                                                                     byte2 => byte2,
  90.                                                                     byte3 => byte3,
  91.                                                                     byte4 => byte4,
  92.                                                                     byte5 => byte5
  93.                                                                     );
  94.    
  95. end architecture behavioural;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement