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.

138 lines
6.2 KiB

  1. -- #################################################################################################
  2. -- # << NEORV32 - Example setup including the bootloader, for the Gatemate (c) Eval Board >> #
  3. -- # ********************************************************************************************* #
  4. -- # BSD 3-Clause License #
  5. -- # #
  6. -- # Copyright (c) 2022, Torsten Meissner. All rights reserved. #
  7. -- # #
  8. -- # Redistribution and use in source and binary forms, with or without modification, are #
  9. -- # permitted provided that the following conditions are met: #
  10. -- # #
  11. -- # 1. Redistributions of source code must retain the above copyright notice, this list of #
  12. -- # conditions and the following disclaimer. #
  13. -- # #
  14. -- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of #
  15. -- # conditions and the following disclaimer in the documentation and/or other materials #
  16. -- # provided with the distribution. #
  17. -- # #
  18. -- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to #
  19. -- # endorse or promote products derived from this software without specific prior written #
  20. -- # permission. #
  21. -- # #
  22. -- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS #
  23. -- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
  24. -- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE #
  25. -- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
  26. -- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
  27. -- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED #
  28. -- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
  29. -- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED #
  30. -- # OF THE POSSIBILITY OF SUCH DAMAGE. #
  31. -- # ********************************************************************************************* #
  32. -- # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
  33. -- #################################################################################################
  34. library ieee;
  35. use ieee.std_logic_1164.all;
  36. use ieee.numeric_std.all;
  37. library gatemate;
  38. use gatemate.components.all;
  39. entity neorv32_aes is
  40. port (
  41. -- Clock and Reset inputs
  42. clk_i : in std_logic; -- 10 MHz clock
  43. rst_n_i : in std_logic; -- SW3 button
  44. -- LED outputs
  45. led_n_o : out std_logic_vector(7 downto 0);
  46. -- UART0
  47. uart_rx_i : in std_logic; -- PMODA IO
  48. uart_tx_o : out std_logic -- PMODA IO
  49. );
  50. end entity;
  51. architecture rtl of neorv32_aes is
  52. -- configuration --
  53. constant f_clock_c : natural := 20_000_000; -- clock frequency in Hz
  54. -- Globals
  55. signal s_pll_lock : std_logic;
  56. signal s_pll_clk : std_logic;
  57. signal s_cfg_end : std_logic;
  58. signal s_rst_n : std_logic;
  59. signal s_con_gpio : std_logic_vector(3 downto 0);
  60. begin
  61. PLL : CC_PLL
  62. generic map (
  63. REF_CLK => "10",
  64. OUT_CLK => "20",
  65. PERF_MD => "SPEED"
  66. )
  67. port map (
  68. CLK_REF => clk_i,
  69. USR_CLK_REF => '0',
  70. CLK_FEEDBACK => '0',
  71. USR_LOCKED_STDY_RST => '0',
  72. USR_PLL_LOCKED_STDY => open,
  73. USR_PLL_LOCKED => s_pll_lock,
  74. CLK0 => s_pll_clk,
  75. CLK90 => open,
  76. CLK180 => open,
  77. CLK270 => open,
  78. CLK_REF_OUT => open
  79. );
  80. cfg_end : CC_CFG_END
  81. port map (
  82. CFG_END => s_cfg_end
  83. );
  84. s_rst_n <= s_pll_lock and s_cfg_end and rst_n_i;
  85. -- The core of the problem ----------------------------------------------------------------
  86. -- -------------------------------------------------------------------------------------------
  87. neorv32_inst: entity work.neorv32_top
  88. generic map (
  89. CLOCK_FREQUENCY => f_clock_c, -- clock frequency of s_pll_clk in Hz
  90. CPU_EXTENSION_RISCV_M => true,
  91. FAST_MUL_EN => false,
  92. FAST_SHIFT_EN => false,
  93. MEM_INT_IMEM_SIZE => 8*1024,
  94. MEM_INT_DMEM_SIZE => 16*1024,
  95. IO_MTIME_EN => false,
  96. IO_WDT_EN => false,
  97. IO_TRNG_EN => false,
  98. IO_CFS_EN => true
  99. )
  100. port map (
  101. -- Global control --
  102. clk_i => std_ulogic(s_pll_clk),
  103. rstn_i => std_ulogic(s_rst_n),
  104. -- GPIO
  105. gpio_o => s_con_gpio,
  106. -- primary UART0
  107. uart_txd_o => uart_tx_o,
  108. uart_rxd_i => uart_rx_i
  109. );
  110. -- p_r ERROR when connecting uart_rx_i & yosys option -retime (with both Yosys inferred & instantiated CC_BRAM_40K or CC_BRAM_40K memory)
  111. -- FATAL ERROR: RAM 4070 Output DOA[6] not used but Input DIA[6] used!
  112. -- program finished with exit code: 2
  113. -- p_r ERROR with FAST_MUL_EN (even with the suggested p_r option sitched off)
  114. -- FATAL ERROR: CP-lines in Multiplier cannot be used for CLK; please switch off using CP-lines for CLK (-cCP)
  115. -- IO Connection --------------------------------------------------------------------------
  116. -- -------------------------------------------------------------------------------------------
  117. led_n_o(3 downto 0) <= s_con_gpio;
  118. led_n_o(7 downto 4) <= (others => '1');
  119. -- uart_tx_o <= uart_rx_i;
  120. end architecture;