| 1 |
63 |
zero_gravi |
-- #################################################################################################
|
| 2 |
|
|
-- # << NEORV32 - Test Setup using the UART-Bootloader to upload and run executables >> #
|
| 3 |
|
|
-- # ********************************************************************************************* #
|
| 4 |
|
|
-- # BSD 3-Clause License #
|
| 5 |
|
|
-- # #
|
| 6 |
|
|
-- # Copyright (c) 2021, Stephan Nolting. 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 RISC-V Processor - https://github.com/stnolting/neorv32 #
|
| 33 |
|
|
-- #################################################################################################
|
| 34 |
|
|
|
| 35 |
|
|
library ieee;
|
| 36 |
|
|
use ieee.std_logic_1164.all;
|
| 37 |
|
|
use ieee.numeric_std.all;
|
| 38 |
|
|
|
| 39 |
|
|
library neorv32;
|
| 40 |
|
|
use neorv32.neorv32_package.all;
|
| 41 |
|
|
|
| 42 |
|
|
entity neorv32_test_setup_bootloader is
|
| 43 |
|
|
generic (
|
| 44 |
|
|
-- adapt these for your setup --
|
| 45 |
|
|
CLOCK_FREQUENCY : natural := 100000000; -- clock frequency of clk_i in Hz
|
| 46 |
|
|
MEM_INT_IMEM_SIZE : natural := 16*1024; -- size of processor-internal instruction memory in bytes
|
| 47 |
|
|
MEM_INT_DMEM_SIZE : natural := 8*1024 -- size of processor-internal data memory in bytes
|
| 48 |
|
|
);
|
| 49 |
|
|
port (
|
| 50 |
|
|
-- Global control --
|
| 51 |
|
|
clk_i : in std_ulogic; -- global clock, rising edge
|
| 52 |
|
|
rstn_i : in std_ulogic; -- global reset, low-active, async
|
| 53 |
|
|
-- GPIO --
|
| 54 |
|
|
gpio_o : out std_ulogic_vector(7 downto 0); -- parallel output
|
| 55 |
|
|
-- UART0 --
|
| 56 |
|
|
uart0_txd_o : out std_ulogic; -- UART0 send data
|
| 57 |
|
|
uart0_rxd_i : in std_ulogic -- UART0 receive data
|
| 58 |
|
|
);
|
| 59 |
|
|
end entity;
|
| 60 |
|
|
|
| 61 |
|
|
architecture neorv32_test_setup_bootloader_rtl of neorv32_test_setup_bootloader is
|
| 62 |
|
|
|
| 63 |
|
|
signal con_gpio_o : std_ulogic_vector(63 downto 0);
|
| 64 |
|
|
|
| 65 |
|
|
begin
|
| 66 |
|
|
|
| 67 |
|
|
-- The Core Of The Problem ----------------------------------------------------------------
|
| 68 |
|
|
-- -------------------------------------------------------------------------------------------
|
| 69 |
|
|
neorv32_top_inst: neorv32_top
|
| 70 |
|
|
generic map (
|
| 71 |
|
|
-- General --
|
| 72 |
|
|
CLOCK_FREQUENCY => CLOCK_FREQUENCY, -- clock frequency of clk_i in Hz
|
| 73 |
|
|
INT_BOOTLOADER_EN => true, -- boot configuration: true = boot explicit bootloader; false = boot from int/ext (I)MEM
|
| 74 |
|
|
-- RISC-V CPU Extensions --
|
| 75 |
|
|
CPU_EXTENSION_RISCV_C => true, -- implement compressed extension?
|
| 76 |
|
|
CPU_EXTENSION_RISCV_M => true, -- implement mul/div extension?
|
| 77 |
|
|
CPU_EXTENSION_RISCV_Zicsr => true, -- implement CSR system?
|
| 78 |
|
|
-- Internal Instruction memory --
|
| 79 |
|
|
MEM_INT_IMEM_EN => true, -- implement processor-internal instruction memory
|
| 80 |
|
|
MEM_INT_IMEM_SIZE => MEM_INT_IMEM_SIZE, -- size of processor-internal instruction memory in bytes
|
| 81 |
|
|
-- Internal Data memory --
|
| 82 |
|
|
MEM_INT_DMEM_EN => true, -- implement processor-internal data memory
|
| 83 |
|
|
MEM_INT_DMEM_SIZE => MEM_INT_DMEM_SIZE, -- size of processor-internal data memory in bytes
|
| 84 |
|
|
-- Processor peripherals --
|
| 85 |
|
|
IO_GPIO_EN => true, -- implement general purpose input/output port unit (GPIO)?
|
| 86 |
|
|
IO_MTIME_EN => true, -- implement machine system timer (MTIME)?
|
| 87 |
|
|
IO_UART0_EN => true -- implement primary universal asynchronous receiver/transmitter (UART0)?
|
| 88 |
|
|
)
|
| 89 |
|
|
port map (
|
| 90 |
|
|
-- Global control --
|
| 91 |
|
|
clk_i => clk_i, -- global clock, rising edge
|
| 92 |
|
|
rstn_i => rstn_i, -- global reset, low-active, async
|
| 93 |
|
|
-- GPIO (available if IO_GPIO_EN = true) --
|
| 94 |
|
|
gpio_o => con_gpio_o, -- parallel output
|
| 95 |
|
|
-- primary UART0 (available if IO_UART0_EN = true) --
|
| 96 |
|
|
uart0_txd_o => uart0_txd_o, -- UART0 send data
|
| 97 |
|
|
uart0_rxd_i => uart0_rxd_i -- UART0 receive data
|
| 98 |
|
|
);
|
| 99 |
|
|
|
| 100 |
|
|
-- GPIO output --
|
| 101 |
|
|
gpio_o <= con_gpio_o(7 downto 0);
|
| 102 |
|
|
|
| 103 |
|
|
|
| 104 |
|
|
end architecture;
|