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.

118 lines
2.6 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_reg 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_reg;
  19. architecture rtl of uart_reg 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_usr_rstn : 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 => "10",
  35. PERF_MD => "SPEED"
  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. cc_usr_rstn_inst : CC_USR_RSTN
  51. port map (
  52. USR_RSTN => s_usr_rstn
  53. );
  54. uart_rx : entity work.uart_rx
  55. generic map (
  56. CLK_DIV => 1040
  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. uart_ctrl : entity work.uart_ctrl
  70. port map (
  71. -- globals
  72. rst_n_i => s_rst_n,
  73. clk_i => s_pll_clk,
  74. -- uart rx interface
  75. tdata_i => s_uart_rx_tdata,
  76. tvalid_i => s_uart_rx_tvalid,
  77. tready_o => s_uart_rx_tready,
  78. -- uart tx interface
  79. tdata_o => s_uart_tx_tdata,
  80. tvalid_o => s_uart_tx_tvalid,
  81. tready_i => s_uart_tx_tready
  82. );
  83. uart_tx : entity work.uart_tx
  84. generic map (
  85. CLK_DIV => 1040
  86. )
  87. port map (
  88. -- globals
  89. rst_n_i => s_rst_n,
  90. clk_i => s_pll_clk,
  91. -- axis user interface
  92. tdata_i => s_uart_tx_tdata,
  93. tvalid_i => s_uart_tx_tvalid,
  94. tready_o => s_uart_tx_tready,
  95. -- uart interface
  96. tx_o => uart_tx_o
  97. );
  98. s_rst_n <= rst_n_i and s_pll_lock and s_usr_rstn;
  99. end architecture;