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.

151 lines
7.4 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 neorv32;
  38. use neorv32.neorv32_package.all;
  39. library gatemate;
  40. use gatemate.components.all;
  41. entity neorv32_aes is
  42. port (
  43. -- Clock and Reset inputs
  44. clk_i : in std_logic; -- 10 MHz clock
  45. rst_n_i : in std_logic; -- SW3 button
  46. -- LED outputs
  47. led_n_o : out std_logic_vector(7 downto 0)
  48. -- UART0
  49. -- uart_rx_i : in std_logic; -- PMODA IO
  50. -- uart_tx_o : out std_logic -- PMODA IO
  51. );
  52. end entity;
  53. architecture rtl of neorv32_aes is
  54. -- configuration --
  55. constant f_clock_c : natural := 10_000_000; -- clock frequency in Hz
  56. -- Globals
  57. signal s_pll_lock : std_logic;
  58. signal s_pll_clk : std_logic;
  59. signal s_cfg_end : std_logic;
  60. signal s_rst_n : std_logic;
  61. signal s_con_gpio : std_ulogic_vector(63 downto 0);
  62. begin
  63. PLL : CC_PLL
  64. generic map (
  65. REF_CLK => "10",
  66. OUT_CLK => "10",
  67. PERF_MD => "SPEED"
  68. )
  69. port map (
  70. CLK_REF => clk_i,
  71. USR_CLK_REF => '0',
  72. CLK_FEEDBACK => '0',
  73. USR_LOCKED_STDY_RST => '0',
  74. USR_PLL_LOCKED_STDY => open,
  75. USR_PLL_LOCKED => s_pll_lock,
  76. CLK0 => s_pll_clk,
  77. CLK90 => open,
  78. CLK180 => open,
  79. CLK270 => open,
  80. CLK_REF_OUT => open
  81. );
  82. cfg_end : CC_CFG_END
  83. port map (
  84. CFG_END => s_cfg_end
  85. );
  86. s_rst_n <= s_pll_lock and s_cfg_end and rst_n_i;
  87. -- The core of the problem ----------------------------------------------------------------
  88. -- -------------------------------------------------------------------------------------------
  89. neorv32_inst: entity neorv32.neorv32_top
  90. generic map (
  91. CLOCK_FREQUENCY => f_clock_c, -- clock frequency of s_pll_clk in Hz
  92. INT_BOOTLOADER_EN => false, -- boot configuration: true = boot explicit bootloader; false = boot from int/ext (I)MEM
  93. -- RISC-V CPU Extensions --
  94. CPU_EXTENSION_RISCV_C => true, -- implement compressed extension?
  95. CPU_EXTENSION_RISCV_M => true, -- implement mul/div extension?
  96. CPU_EXTENSION_RISCV_Zicsr => true, -- implement CSR system?
  97. CPU_EXTENSION_RISCV_Zicntr => true, -- implement base counters?
  98. -- Tuning Options --
  99. FAST_MUL_EN => false,
  100. FAST_SHIFT_EN => false,
  101. -- Internal Instruction memory --
  102. MEM_INT_IMEM_EN => true, -- implement processor-internal instruction memory
  103. MEM_INT_IMEM_SIZE => 16*1024, -- size of processor-internal instruction memory in bytes
  104. -- Internal Data memory --
  105. MEM_INT_DMEM_EN => true, -- implement processor-internal data memory
  106. MEM_INT_DMEM_SIZE => 8*1024, -- size of processor-internal data memory in bytes
  107. -- Processor peripherals --
  108. IO_GPIO_EN => true, -- implement general purpose input/output port unit (GPIO)?
  109. IO_MTIME_EN => true, -- implement machine system timer (MTIME)?
  110. IO_UART0_EN => false, -- implement primary universal asynchronous receiver/transmitter (UART0)?
  111. IO_CFS_EN => false, -- implement custom functions subsystem (CFS)?
  112. IO_AES_EN => true -- implement AES(128) custom function?
  113. )
  114. port map (
  115. -- Global control --
  116. clk_i => std_ulogic(s_pll_clk),
  117. rstn_i => std_ulogic(s_rst_n),
  118. -- GPIO
  119. gpio_o => s_con_gpio,
  120. -- primary UART0
  121. uart0_txd_o => open,
  122. uart0_rxd_i => '0'
  123. );
  124. -- p_r ERROR when connecting uart_rx_i & yosys option -retime (with both Yosys inferred & instantiated CC_BRAM_40K or CC_BRAM_40K memory)
  125. -- FATAL ERROR: RAM 4070 Output DOA[6] not used but Input DIA[6] used!
  126. -- program finished with exit code: 2
  127. -- p_r ERROR with FAST_MUL_EN (fix with suggested p_r option switched off)
  128. -- FATAL ERROR: CP-lines in Multiplier cannot be used for CLK; please switch off using CP-lines for CLK (-cCP)
  129. -- IO Connection --------------------------------------------------------------------------
  130. led_n_o <= not std_logic_vector(s_con_gpio(7 downto 0));
  131. end architecture;