You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.8 KiB

  1. -- This design implements a register file which can
  2. -- be accessed by an UART with 9600 baud
  3. --
  4. -- See into uart_ctrl.vhd for documentation of the protocol
  5. -- used to read / write the register file.
  6. library ieee ;
  7. use ieee.std_logic_1164.all;
  8. use ieee.numeric_std.all;
  9. library gatemate;
  10. use gatemate.components.all;
  11. entity uart_loop is
  12. port (
  13. clk_i : in std_logic; -- 10 MHz clock
  14. rst_n_i : in std_logic; -- SW3 button
  15. uart_rx_i : in std_logic; -- PMODA IO3
  16. uart_tx_o : out std_logic -- PMODA IO5
  17. );
  18. end entity uart_loop;
  19. architecture rtl of uart_loop is
  20. signal s_pll_clk : std_logic;
  21. signal s_pll_lock : std_logic;
  22. signal s_rst_n : std_logic;
  23. signal s_cfg_end : std_logic;
  24. signal s_uart_rx_tdata : std_logic_vector(7 downto 0);
  25. signal s_uart_rx_tvalid : std_logic;
  26. signal s_uart_rx_tready : std_logic;
  27. signal s_uart_tx_tdata : std_logic_vector(7 downto 0);
  28. signal s_uart_tx_tvalid : std_logic;
  29. signal s_uart_tx_tready : std_logic;
  30. begin
  31. pll : CC_PLL
  32. generic map (
  33. REF_CLK => "10",
  34. OUT_CLK => "1",
  35. PERF_MD => "ECONOMY"
  36. )
  37. port map (
  38. CLK_REF => clk_i,
  39. CLK_FEEDBACK => '0',
  40. USR_CLK_REF => '0',
  41. USR_LOCKED_STDY_RST => '0',
  42. USR_PLL_LOCKED_STDY => open,
  43. USR_PLL_LOCKED => s_pll_lock,
  44. CLK270 => open,
  45. CLK180 => open,
  46. CLK0 => s_pll_clk,
  47. CLK90 => open,
  48. CLK_REF_OUT => open
  49. );
  50. cfg_end_inst : CC_CFG_END
  51. port map (
  52. CFG_END => s_cfg_end
  53. );
  54. uart_rx : entity work.uart_rx
  55. generic map (
  56. CLK_DIV => 104
  57. )
  58. port map (
  59. -- globals
  60. rst_n_i => s_rst_n,
  61. clk_i => s_pll_clk,
  62. -- axis user interface
  63. tdata_o => s_uart_rx_tdata,
  64. tvalid_o => s_uart_rx_tvalid,
  65. tready_i => s_uart_rx_tready,
  66. -- uart interface
  67. rx_i => uart_rx_i
  68. );
  69. axis_fifo : entity work.axis_fifo
  70. generic map (
  71. DEPTH => 64,
  72. WIDTH => 8
  73. )
  74. port map (
  75. -- globals
  76. rst_n_i => s_rst_n,
  77. clk_i => s_pll_clk,
  78. -- uart rx interface
  79. tdata_i => s_uart_rx_tdata,
  80. tvalid_i => s_uart_rx_tvalid,
  81. tready_o => s_uart_rx_tready,
  82. -- uart tx interface
  83. tdata_o => s_uart_tx_tdata,
  84. tvalid_o => s_uart_tx_tvalid,
  85. tready_i => s_uart_tx_tready
  86. );
  87. -- s_uart_tx_tdata <= s_uart_rx_tdata;
  88. -- s_uart_tx_tvalid <= s_uart_rx_tvalid;
  89. -- s_uart_rx_tready <= s_uart_tx_tready;
  90. uart_tx : entity work.uart_tx
  91. generic map (
  92. CLK_DIV => 104
  93. )
  94. port map (
  95. -- globals
  96. rst_n_i => s_rst_n,
  97. clk_i => s_pll_clk,
  98. -- axis user interface
  99. tdata_i => s_uart_tx_tdata,
  100. tvalid_i => s_uart_tx_tvalid,
  101. tready_o => s_uart_tx_tready,
  102. -- uart interface
  103. tx_o => uart_tx_o
  104. );
  105. s_rst_n <= rst_n_i and s_pll_lock and s_cfg_end;
  106. end architecture;