Initial commit
This commit is contained in:
		
							
								
								
									
										52
									
								
								Libs/RiscV/NEORV32/rtl/test_setups/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								Libs/RiscV/NEORV32/rtl/test_setups/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| # Test Setups | ||||
|  | ||||
| This folder contains very simple test setups that are intended for project beginners | ||||
| to setup a minimal NEORV32 SoC. These setups are used in the :books: | ||||
| [NEORV32 User Guide](https://stnolting.github.io/neorv32/ug/). | ||||
| Note that these setups provides a minimalistic configuration to keep | ||||
| things at a simple level at first. Additional CPU ISA extensions, performance options and | ||||
| optional peripheral modules can be enabled by specifying the according :book: | ||||
| [configuration generics](https://stnolting.github.io/neorv32/#_processor_top_entity_generics). | ||||
|  | ||||
|  | ||||
| ### Setup's Top Entity | ||||
|  | ||||
| #### Clocking and Reset | ||||
|  | ||||
| All test setups require an external clock (via `clk_i` signal) and an external | ||||
| low-active reset (via `rstn_i` signal). | ||||
|  | ||||
| #### Configuration Generics | ||||
|  | ||||
| Each setup provides three elementary generics that can/should be adapted to fit | ||||
| your FPGA/board. | ||||
|  | ||||
| * The clock speed in Hz **has to be specified** via the `CLOCK_SPEED` generic to fit your clock source. | ||||
| * The processor-internal instruction memory (IMEM) size _can be modified_ via the `MEM_INT_IMEM_SIZE` generic. | ||||
| * The processor-internal data memory (DMEM) size _can be modified_ via the `MEM_INT_DMEM_SIZE` generic. | ||||
| Note that this might require adaption of the NEORV32 linker script. | ||||
|  | ||||
|  | ||||
| ### [`neorv32_test_setup_approm.vhd`](https://github.com/stnolting/neorv32/blob/master/rtl/test_setups/neorv32_test_setup_approm.vhd) | ||||
|  | ||||
| This setup configures a `rv32imc_Zicsr` CPU with 16kB IMEM (as pre-initialized ROM), | ||||
| 8kB DMEM and includes the GPIO module to drive 8 external signals (`gpio_o`) | ||||
| and the MTIME module for generating timer interrupts. | ||||
| The setup uses the ["indirect boot"](https://stnolting.github.io/neorv32/#_indirect_boot) | ||||
| configuration, so software applications are "installed" directly into the | ||||
| processor-internal IMEM during synthesis. | ||||
|  | ||||
| :books: See User Guide section [_Installing an Executable Directly Into Memory_](https://stnolting.github.io/neorv32/ug/#_installing_an_executable_directly_into_memory). | ||||
|  | ||||
|  | ||||
| ### [`neorv32_test_setup_bootloader.vhd`](https://github.com/stnolting/neorv32/blob/master/rtl/test_setups/neorv32_test_setup_bootloader.vhd) | ||||
|  | ||||
| This setup configures a `rv32imc_Zicsr` CPU with 16kB IMEM (as RAM), 8kB DMEM | ||||
| and includes the GPIO module to drive 8 external signals (`gpio_o`), the MTIME | ||||
| module for generating timer interrupts and UART0 to interface with the bootloader | ||||
| (via `uart0_txd_o` and `uart0_rxd_i`) via a serial terminal. | ||||
| The setup uses the ["direct boot"](https://stnolting.github.io/neorv32/#_direct_boot) | ||||
| configuration, so software applications can be uploaded and run at any timer via a serial terminal. | ||||
|  | ||||
| :books: See User Guide section | ||||
| [_Uploading and Starting of a Binary Executable Image via UART_](https://stnolting.github.io/neorv32/ug/#_uploading_and_starting_of_a_binary_executable_image_via_uart). | ||||
| @@ -0,0 +1,98 @@ | ||||
| -- ################################################################################################# | ||||
| -- # << NEORV32 - Test Setup using the internal IMEM as ROM to run pre-installed executables >>    # | ||||
| -- # ********************************************************************************************* # | ||||
| -- # BSD 3-Clause License                                                                          # | ||||
| -- #                                                                                               # | ||||
| -- # Copyright (c) 2021, Stephan Nolting. All rights reserved.                                     # | ||||
| -- #                                                                                               # | ||||
| -- # Redistribution and use in source and binary forms, with or without modification, are          # | ||||
| -- # permitted provided that the following conditions are met:                                     # | ||||
| -- #                                                                                               # | ||||
| -- # 1. Redistributions of source code must retain the above copyright notice, this list of        # | ||||
| -- #    conditions and the following disclaimer.                                                   # | ||||
| -- #                                                                                               # | ||||
| -- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of     # | ||||
| -- #    conditions and the following disclaimer in the documentation and/or other materials        # | ||||
| -- #    provided with the distribution.                                                            # | ||||
| -- #                                                                                               # | ||||
| -- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to  # | ||||
| -- #    endorse or promote products derived from this software without specific prior written      # | ||||
| -- #    permission.                                                                                # | ||||
| -- #                                                                                               # | ||||
| -- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS   # | ||||
| -- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF               # | ||||
| -- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE    # | ||||
| -- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,     # | ||||
| -- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE # | ||||
| -- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED    # | ||||
| -- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     # | ||||
| -- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED  # | ||||
| -- # OF THE POSSIBILITY OF SUCH DAMAGE.                                                            # | ||||
| -- # ********************************************************************************************* # | ||||
| -- # The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32                           # | ||||
| -- ################################################################################################# | ||||
|  | ||||
| library ieee; | ||||
| use ieee.std_logic_1164.all; | ||||
| use ieee.numeric_std.all; | ||||
|  | ||||
| library neorv32; | ||||
| use neorv32.neorv32_package.all; | ||||
|  | ||||
| entity neorv32_test_setup_approm is | ||||
|   generic ( | ||||
|     -- adapt these for your setup -- | ||||
|     CLOCK_FREQUENCY   : natural := 100000000; -- clock frequency of clk_i in Hz | ||||
|     MEM_INT_IMEM_SIZE : natural := 16*1024;   -- size of processor-internal instruction memory in bytes | ||||
|     MEM_INT_DMEM_SIZE : natural := 8*1024     -- size of processor-internal data memory in bytes | ||||
|   ); | ||||
|   port ( | ||||
|     -- Global control -- | ||||
|     clk_i       : in  std_ulogic; -- global clock, rising edge | ||||
|     rstn_i      : in  std_ulogic; -- global reset, low-active, async | ||||
|     -- GPIO -- | ||||
|     gpio_o      : out std_ulogic_vector(7 downto 0) -- parallel output | ||||
|   ); | ||||
| end entity; | ||||
|  | ||||
| architecture neorv32_test_setup_approm_rtl of neorv32_test_setup_approm is | ||||
|  | ||||
|   signal con_gpio_o : std_ulogic_vector(63 downto 0); | ||||
|  | ||||
| begin | ||||
|  | ||||
|   -- The Core Of The Problem ---------------------------------------------------------------- | ||||
|   -- ------------------------------------------------------------------------------------------- | ||||
|   neorv32_top_inst: neorv32_top | ||||
|   generic map ( | ||||
|     -- General -- | ||||
|     CLOCK_FREQUENCY              => CLOCK_FREQUENCY,   -- clock frequency of clk_i in Hz | ||||
|     INT_BOOTLOADER_EN            => false,             -- boot configuration: true = boot explicit bootloader; false = boot from int/ext (I)MEM | ||||
|     -- RISC-V CPU Extensions -- | ||||
|     CPU_EXTENSION_RISCV_C        => true,              -- implement compressed extension? | ||||
|     CPU_EXTENSION_RISCV_M        => true,              -- implement mul/div extension? | ||||
|     CPU_EXTENSION_RISCV_Zicsr    => true,              -- implement CSR system? | ||||
|     CPU_EXTENSION_RISCV_Zicntr   => true,              -- implement base counters? | ||||
|     -- Internal Instruction memory -- | ||||
|     MEM_INT_IMEM_EN              => true,              -- implement processor-internal instruction memory | ||||
|     MEM_INT_IMEM_SIZE            => MEM_INT_IMEM_SIZE, -- size of processor-internal instruction memory in bytes | ||||
|     -- Internal Data memory -- | ||||
|     MEM_INT_DMEM_EN              => true,              -- implement processor-internal data memory | ||||
|     MEM_INT_DMEM_SIZE            => MEM_INT_DMEM_SIZE, -- size of processor-internal data memory in bytes | ||||
|     -- Processor peripherals -- | ||||
|     IO_GPIO_EN                   => true,              -- implement general purpose input/output port unit (GPIO)? | ||||
|     IO_MTIME_EN                  => true               -- implement machine system timer (MTIME)? | ||||
|   ) | ||||
|   port map ( | ||||
|     -- Global control -- | ||||
|     clk_i  => clk_i,     -- global clock, rising edge | ||||
|     rstn_i => rstn_i,    -- global reset, low-active, async | ||||
|     -- GPIO (available if IO_GPIO_EN = true) -- | ||||
|     gpio_o => con_gpio_o -- parallel output | ||||
|   ); | ||||
|  | ||||
|   -- GPIO output -- | ||||
|   gpio_o <= con_gpio_o(7 downto 0); | ||||
|  | ||||
|  | ||||
| end architecture; | ||||
| @@ -0,0 +1,105 @@ | ||||
| -- ################################################################################################# | ||||
| -- # << NEORV32 - Test Setup using the UART-Bootloader to upload and run executables >>            # | ||||
| -- # ********************************************************************************************* # | ||||
| -- # BSD 3-Clause License                                                                          # | ||||
| -- #                                                                                               # | ||||
| -- # Copyright (c) 2021, Stephan Nolting. All rights reserved.                                     # | ||||
| -- #                                                                                               # | ||||
| -- # Redistribution and use in source and binary forms, with or without modification, are          # | ||||
| -- # permitted provided that the following conditions are met:                                     # | ||||
| -- #                                                                                               # | ||||
| -- # 1. Redistributions of source code must retain the above copyright notice, this list of        # | ||||
| -- #    conditions and the following disclaimer.                                                   # | ||||
| -- #                                                                                               # | ||||
| -- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of     # | ||||
| -- #    conditions and the following disclaimer in the documentation and/or other materials        # | ||||
| -- #    provided with the distribution.                                                            # | ||||
| -- #                                                                                               # | ||||
| -- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to  # | ||||
| -- #    endorse or promote products derived from this software without specific prior written      # | ||||
| -- #    permission.                                                                                # | ||||
| -- #                                                                                               # | ||||
| -- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS   # | ||||
| -- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF               # | ||||
| -- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE    # | ||||
| -- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,     # | ||||
| -- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE # | ||||
| -- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED    # | ||||
| -- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     # | ||||
| -- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED  # | ||||
| -- # OF THE POSSIBILITY OF SUCH DAMAGE.                                                            # | ||||
| -- # ********************************************************************************************* # | ||||
| -- # The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32                           # | ||||
| -- ################################################################################################# | ||||
|  | ||||
| library ieee; | ||||
| use ieee.std_logic_1164.all; | ||||
| use ieee.numeric_std.all; | ||||
|  | ||||
| library neorv32; | ||||
| use neorv32.neorv32_package.all; | ||||
|  | ||||
| entity neorv32_test_setup_bootloader is | ||||
|   generic ( | ||||
|     -- adapt these for your setup -- | ||||
|     CLOCK_FREQUENCY   : natural := 100000000; -- clock frequency of clk_i in Hz | ||||
|     MEM_INT_IMEM_SIZE : natural := 16*1024;   -- size of processor-internal instruction memory in bytes | ||||
|     MEM_INT_DMEM_SIZE : natural := 8*1024     -- size of processor-internal data memory in bytes | ||||
|   ); | ||||
|   port ( | ||||
|     -- Global control -- | ||||
|     clk_i       : in  std_ulogic; -- global clock, rising edge | ||||
|     rstn_i      : in  std_ulogic; -- global reset, low-active, async | ||||
|     -- GPIO -- | ||||
|     gpio_o      : out std_ulogic_vector(7 downto 0); -- parallel output | ||||
|     -- UART0 -- | ||||
|     uart0_txd_o : out std_ulogic; -- UART0 send data | ||||
|     uart0_rxd_i : in  std_ulogic  -- UART0 receive data | ||||
|   ); | ||||
| end entity; | ||||
|  | ||||
| architecture neorv32_test_setup_bootloader_rtl of neorv32_test_setup_bootloader is | ||||
|  | ||||
|   signal con_gpio_o : std_ulogic_vector(63 downto 0); | ||||
|  | ||||
| begin | ||||
|  | ||||
|   -- The Core Of The Problem ---------------------------------------------------------------- | ||||
|   -- ------------------------------------------------------------------------------------------- | ||||
|   neorv32_top_inst: neorv32_top | ||||
|   generic map ( | ||||
|     -- General -- | ||||
|     CLOCK_FREQUENCY              => CLOCK_FREQUENCY,   -- clock frequency of clk_i in Hz | ||||
|     INT_BOOTLOADER_EN            => true,              -- boot configuration: true = boot explicit bootloader; false = boot from int/ext (I)MEM | ||||
|     -- RISC-V CPU Extensions -- | ||||
|     CPU_EXTENSION_RISCV_C        => true,              -- implement compressed extension? | ||||
|     CPU_EXTENSION_RISCV_M        => true,              -- implement mul/div extension? | ||||
|     CPU_EXTENSION_RISCV_Zicsr    => true,              -- implement CSR system? | ||||
|     CPU_EXTENSION_RISCV_Zicntr   => true,              -- implement base counters? | ||||
|     -- Internal Instruction memory -- | ||||
|     MEM_INT_IMEM_EN              => true,              -- implement processor-internal instruction memory | ||||
|     MEM_INT_IMEM_SIZE            => MEM_INT_IMEM_SIZE, -- size of processor-internal instruction memory in bytes | ||||
|     -- Internal Data memory -- | ||||
|     MEM_INT_DMEM_EN              => true,              -- implement processor-internal data memory | ||||
|     MEM_INT_DMEM_SIZE            => MEM_INT_DMEM_SIZE, -- size of processor-internal data memory in bytes | ||||
|     -- Processor peripherals -- | ||||
|     IO_GPIO_EN                   => true,              -- implement general purpose input/output port unit (GPIO)? | ||||
|     IO_MTIME_EN                  => true,              -- implement machine system timer (MTIME)? | ||||
|     IO_UART0_EN                  => true               -- implement primary universal asynchronous receiver/transmitter (UART0)? | ||||
|   ) | ||||
|   port map ( | ||||
|     -- Global control -- | ||||
|     clk_i       => clk_i,       -- global clock, rising edge | ||||
|     rstn_i      => rstn_i,      -- global reset, low-active, async | ||||
|     -- GPIO (available if IO_GPIO_EN = true) -- | ||||
|     gpio_o      => con_gpio_o,  -- parallel output | ||||
|     -- primary UART0 (available if IO_UART0_EN = true) -- | ||||
|     uart0_txd_o => uart0_txd_o, -- UART0 send data | ||||
|     uart0_rxd_i => uart0_rxd_i  -- UART0 receive data | ||||
|   ); | ||||
|  | ||||
|   -- GPIO output -- | ||||
|   gpio_o <= con_gpio_o(7 downto 0); | ||||
|  | ||||
|  | ||||
| end architecture; | ||||
		Reference in New Issue
	
	Block a user