Initial commit
This commit is contained in:
55
Libs/RiscV/NEORV32/sw/README.md
Normal file
55
Libs/RiscV/NEORV32/sw/README.md
Normal file
@ -0,0 +1,55 @@
|
||||
# NEORV32 Software Framework
|
||||
|
||||
This folder provides the core of the NEORV32 software framework.
|
||||
This is a short description of the main folders.
|
||||
|
||||
|
||||
## [bootloader](bootloader)
|
||||
|
||||
Source(s) of the default NEORV32 bootloader.
|
||||
A pre-built image is already installed into the rtl design via the `rtl/core/neorv32_bootloader_image.vhd` file.
|
||||
|
||||
|
||||
## [common](common)
|
||||
|
||||
NEORV32-specific common files for all bootloader and application programs:
|
||||
linker script for executable generation and processor start-up code.
|
||||
|
||||
|
||||
## [example](example)
|
||||
|
||||
Several example programs for testing and for getting started.
|
||||
|
||||
|
||||
## [image_gen](image_gen)
|
||||
|
||||
This folder contains a simple program that is used to create NEORV32 executables (for upload via bootloader) and VHDL
|
||||
memory initialization files (for memory-persistent applications and for the bootloader).
|
||||
This program is automatically compiled using the native GCC when invoking one of the application compilation makefiles.
|
||||
|
||||
|
||||
## [isa-test](isa-test)
|
||||
|
||||
NEORV32 RISC-V Architecture Test Framework.
|
||||
See [sim/README](../sim/README.md).
|
||||
|
||||
|
||||
## [lib](lib)
|
||||
|
||||
Core libraries (sources and header files) and helper functions for using the processor peripherals and the CPU itself.
|
||||
|
||||
|
||||
## [ocd-firmware](ocd-firmware)
|
||||
|
||||
Firmware (debugger "park loop") for the on-chip debugger. This folder is just for documenting the source code.
|
||||
Modifying the sources is not recommended as this could break the on-chip debugger.
|
||||
|
||||
|
||||
## [openocd](openocd)
|
||||
|
||||
Configuration file for openOCD to connect to the NEORV32 on-chip debugger via JTAG.
|
||||
|
||||
|
||||
## [svd](svd)
|
||||
|
||||
Contains a CMSIS-SVD compatible system view description file including _all_ peripherals.
|
40
Libs/RiscV/NEORV32/sw/bootloader/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/bootloader/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
368
Libs/RiscV/NEORV32/sw/common/common.mk
Normal file
368
Libs/RiscV/NEORV32/sw/common/common.mk
Normal file
@ -0,0 +1,368 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# USER CONFIGURATION
|
||||
# -----------------------------------------------------------------------------
|
||||
# User's application sources (*.c, *.cpp, *.s, *.S); add additional files here
|
||||
APP_SRC ?= $(wildcard ./*.c) $(wildcard ./*.s) $(wildcard ./*.cpp) $(wildcard ./*.S)
|
||||
|
||||
# User's application include folders (don't forget the '-I' before each entry)
|
||||
APP_INC ?= -I .
|
||||
# User's application include folders - for assembly files only (don't forget the '-I' before each entry)
|
||||
ASM_INC ?= -I .
|
||||
|
||||
# Optimization
|
||||
EFFORT ?= -Os
|
||||
|
||||
# Compiler toolchain
|
||||
RISCV_PREFIX ?= riscv32-unknown-elf-
|
||||
|
||||
# CPU architecture and ABI
|
||||
MARCH ?= rv32i
|
||||
MABI ?= ilp32
|
||||
|
||||
# User flags for additional configuration (will be added to compiler flags)
|
||||
USER_FLAGS ?=
|
||||
|
||||
# Relative or absolute path to the NEORV32 home folder
|
||||
NEORV32_HOME ?= ../../..
|
||||
NEORV32_LOCAL_RTL ?= $(NEORV32_HOME)/rtl
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# NEORV32 framework
|
||||
# -----------------------------------------------------------------------------
|
||||
# Path to NEORV32 linker script and startup file
|
||||
NEORV32_COM_PATH = $(NEORV32_HOME)/sw/common
|
||||
# Path to main NEORV32 library include files
|
||||
NEORV32_INC_PATH = $(NEORV32_HOME)/sw/lib/include
|
||||
# Path to main NEORV32 library source files
|
||||
NEORV32_SRC_PATH = $(NEORV32_HOME)/sw/lib/source
|
||||
# Path to NEORV32 executable generator
|
||||
NEORV32_EXG_PATH = $(NEORV32_HOME)/sw/image_gen
|
||||
# Path to NEORV32 core rtl folder
|
||||
NEORV32_RTL_PATH = $(NEORV32_LOCAL_RTL)/core
|
||||
# Path to NEORV32 sim folder
|
||||
NEORV32_SIM_PATH = $(NEORV32_HOME)/sim
|
||||
# Marker file to check for NEORV32 home folder
|
||||
NEORV32_HOME_MARKER = $(NEORV32_INC_PATH)/neorv32.h
|
||||
|
||||
# Core libraries (peripheral and CPU drivers)
|
||||
CORE_SRC = $(wildcard $(NEORV32_SRC_PATH)/*.c)
|
||||
# Application start-up code
|
||||
CORE_SRC += $(NEORV32_COM_PATH)/crt0.S
|
||||
|
||||
# Linker script
|
||||
LD_SCRIPT = $(NEORV32_COM_PATH)/neorv32.ld
|
||||
|
||||
# Main output files
|
||||
APP_EXE = neorv32_exe.bin
|
||||
APP_HEX = neorv32_exe.hex
|
||||
APP_ASM = main.asm
|
||||
APP_IMG = neorv32_application_image.vhd
|
||||
BOOT_IMG = neorv32_bootloader_image.vhd
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Sources and objects
|
||||
# -----------------------------------------------------------------------------
|
||||
# Define all sources
|
||||
SRC = $(APP_SRC)
|
||||
SRC += $(CORE_SRC)
|
||||
|
||||
# Define all object files
|
||||
OBJ = $(SRC:%=%.o)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Tools and flags
|
||||
# -----------------------------------------------------------------------------
|
||||
# Compiler tools
|
||||
CC = $(RISCV_PREFIX)gcc
|
||||
OBJDUMP = $(RISCV_PREFIX)objdump
|
||||
OBJCOPY = $(RISCV_PREFIX)objcopy
|
||||
SIZE = $(RISCV_PREFIX)size
|
||||
|
||||
# Host native compiler
|
||||
CC_X86 = g++ -Wall -O -g
|
||||
|
||||
# NEORV32 executable image generator
|
||||
IMAGE_GEN = $(NEORV32_EXG_PATH)/image_gen
|
||||
|
||||
# Compiler & linker flags
|
||||
CC_OPTS = -march=$(MARCH) -mabi=$(MABI) $(EFFORT) -Wall -ffunction-sections -fdata-sections -nostartfiles -mno-fdiv
|
||||
CC_OPTS += -Wl,--gc-sections -lm -lc -lgcc -lc
|
||||
# This accelerates instruction fetch after branches when C extension is enabled (irrelevant when C extension is disabled)
|
||||
CC_OPTS += -falign-functions=4 -falign-labels=4 -falign-loops=4 -falign-jumps=4
|
||||
CC_OPTS += $(USER_FLAGS)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Application output definitions
|
||||
# -----------------------------------------------------------------------------
|
||||
.PHONY: check info help elf_info clean clean_all bootloader
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
# 'compile' is still here for compatibility
|
||||
exe: $(APP_ASM) $(APP_EXE)
|
||||
hex: $(APP_ASM) $(APP_HEX)
|
||||
compile: $(APP_ASM) $(APP_EXE)
|
||||
image: $(APP_ASM) $(APP_IMG)
|
||||
install: image install-$(APP_IMG)
|
||||
all: $(APP_ASM) $(APP_EXE) $(APP_IMG) $(APP_HEX) install
|
||||
|
||||
# Check if making bootloader
|
||||
# Use different base address and length for instruction memory/"rom" (BOOTROM instead of IMEM)
|
||||
# Also define "make_bootloader" symbol for crt0.S
|
||||
target bootloader: CC_OPTS += -Wl,--defsym=make_bootloader=1 -Dmake_bootloader
|
||||
target bl_image: CC_OPTS += -Wl,--defsym=make_bootloader=1 -Dmake_bootloader
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Image generator targets
|
||||
# -----------------------------------------------------------------------------
|
||||
# install/compile tools
|
||||
$(IMAGE_GEN): $(NEORV32_EXG_PATH)/image_gen.c
|
||||
@echo Compiling $(IMAGE_GEN)
|
||||
@$(CC_X86) $< -o $(IMAGE_GEN)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# General targets: Assemble, compile, link, dump
|
||||
# -----------------------------------------------------------------------------
|
||||
# Compile app *.s sources (assembly)
|
||||
%.s.o: %.s
|
||||
@$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(ASM_INC) $< -o $@
|
||||
|
||||
# Compile app *.S sources (assembly + C pre-processor)
|
||||
%.S.o: %.S
|
||||
@$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(ASM_INC) $< -o $@
|
||||
|
||||
# Compile app *.c sources
|
||||
%.c.o: %.c
|
||||
@$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(APP_INC) $< -o $@
|
||||
|
||||
# Compile app *.cpp sources
|
||||
%.cpp.o: %.cpp
|
||||
@$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(APP_INC) $< -o $@
|
||||
|
||||
# Link object files and show memory utilization
|
||||
main.elf: $(OBJ)
|
||||
@$(CC) $(CC_OPTS) -T $(LD_SCRIPT) $(OBJ) -o $@ -lm
|
||||
@echo "Memory utilization:"
|
||||
@$(SIZE) main.elf
|
||||
|
||||
# Assembly listing file (for debugging)
|
||||
$(APP_ASM): main.elf
|
||||
@$(OBJDUMP) -d -S -z $< > $@
|
||||
|
||||
# Generate final executable from .text + .rodata + .data (in THIS order!)
|
||||
main.bin: main.elf $(APP_ASM)
|
||||
@$(OBJCOPY) -I elf32-little $< -j .text -O binary text.bin
|
||||
@$(OBJCOPY) -I elf32-little $< -j .rodata -O binary rodata.bin
|
||||
@$(OBJCOPY) -I elf32-little $< -j .data -O binary data.bin
|
||||
@cat text.bin rodata.bin data.bin > $@
|
||||
@rm -f text.bin rodata.bin data.bin
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Application targets: Generate binary executable, install (as VHDL file)
|
||||
# -----------------------------------------------------------------------------
|
||||
# Generate NEORV32 executable image for upload via bootloader
|
||||
$(APP_EXE): main.bin $(IMAGE_GEN)
|
||||
@set -e
|
||||
@$(IMAGE_GEN) -app_bin $< $@ $(shell basename $(CURDIR))
|
||||
@echo "Executable ($(APP_EXE)) size in bytes:"
|
||||
@wc -c < $(APP_EXE)
|
||||
|
||||
# Generate NEORV32 executable VHDL boot image
|
||||
$(APP_IMG): main.bin $(IMAGE_GEN)
|
||||
@set -e
|
||||
@$(IMAGE_GEN) -app_img $< $@ $(shell basename $(CURDIR))
|
||||
|
||||
install-$(APP_IMG): $(APP_IMG)
|
||||
@set -e
|
||||
@echo "Installing application image to $(NEORV32_RTL_PATH)/$(APP_IMG)"
|
||||
@cp $(APP_IMG) $(NEORV32_RTL_PATH)/.
|
||||
|
||||
# Generate NEORV32 executable image in plain hex format
|
||||
$(APP_HEX): main.bin $(IMAGE_GEN)
|
||||
@set -e
|
||||
@$(IMAGE_GEN) -app_hex $< $@ $(shell basename $(CURDIR))
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Bootloader targets
|
||||
# -----------------------------------------------------------------------------
|
||||
# Create and install bootloader VHDL init image
|
||||
$(BOOT_IMG): main.bin $(IMAGE_GEN)
|
||||
@set -e
|
||||
@$(IMAGE_GEN) -bld_img $< $(BOOT_IMG) $(shell basename $(CURDIR))
|
||||
|
||||
install-$(BOOT_IMG): $(BOOT_IMG)
|
||||
@set -e
|
||||
@echo "Installing bootloader image to $(NEORV32_RTL_PATH)/$(BOOT_IMG)"
|
||||
@cp $(BOOT_IMG) $(NEORV32_RTL_PATH)/.
|
||||
|
||||
# Just an alias
|
||||
bl_image: $(BOOT_IMG)
|
||||
bootloader: bl_image install-$(BOOT_IMG)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Check toolchain
|
||||
# -----------------------------------------------------------------------------
|
||||
check: $(IMAGE_GEN)
|
||||
@echo "---------------- Check: NEORV32_HOME folder ----------------"
|
||||
ifneq ($(shell [ -e $(NEORV32_HOME_MARKER) ] && echo 1 || echo 0 ), 1)
|
||||
$(error NEORV32_HOME folder not found!)
|
||||
endif
|
||||
@echo "NEORV32_HOME: $(NEORV32_HOME)"
|
||||
@echo "---------------- Check: $(CC) ----------------"
|
||||
@$(CC) -v
|
||||
@echo "---------------- Check: $(OBJDUMP) ----------------"
|
||||
@$(OBJDUMP) -V
|
||||
@echo "---------------- Check: $(OBJCOPY) ----------------"
|
||||
@$(OBJCOPY) -V
|
||||
@echo "---------------- Check: $(SIZE) ----------------"
|
||||
@$(SIZE) -V
|
||||
@echo "---------------- Check: NEORV32 image_gen ----------------"
|
||||
@$(IMAGE_GEN) -help
|
||||
@echo "---------------- Check: Native GCC ----------------"
|
||||
@$(CC_X86) -v
|
||||
@echo
|
||||
@echo "Toolchain check OK"
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Show configuration
|
||||
# -----------------------------------------------------------------------------
|
||||
info:
|
||||
@echo "---------------- Info: Project ----------------"
|
||||
@echo "Project folder: $(shell basename $(CURDIR))"
|
||||
@echo "Source files: $(APP_SRC)"
|
||||
@echo "Include folder(s): $(APP_INC)"
|
||||
@echo "ASM include folder(s): $(ASM_INC)"
|
||||
@echo "---------------- Info: NEORV32 ----------------"
|
||||
@echo "NEORV32 home folder (NEORV32_HOME): $(NEORV32_HOME)"
|
||||
@echo "IMAGE_GEN: $(IMAGE_GEN)"
|
||||
@echo "Core source files:"
|
||||
@echo "$(CORE_SRC)"
|
||||
@echo "Core include folder:"
|
||||
@echo "$(NEORV32_INC_PATH)"
|
||||
@echo "---------------- Info: Objects ----------------"
|
||||
@echo "Project object files:"
|
||||
@echo "$(OBJ)"
|
||||
@echo "---------------- Info: RISC-V CPU ----------------"
|
||||
@echo "MARCH: $(MARCH)"
|
||||
@echo "MABI: $(MABI)"
|
||||
@echo "---------------- Info: Toolchain ----------------"
|
||||
@echo "Toolchain: $(RISCV_TOLLCHAIN)"
|
||||
@echo "CC: $(CC)"
|
||||
@echo "OBJDUMP: $(OBJDUMP)"
|
||||
@echo "OBJCOPY: $(OBJCOPY)"
|
||||
@echo "SIZE: $(SIZE)"
|
||||
@echo "---------------- Info: Compiler Configuration ----------------"
|
||||
@$(CC) -v
|
||||
@echo "---------------- Info: Compiler Libraries ----------------"
|
||||
@echo "LIBGCC:"
|
||||
@$(CC) -print-libgcc-file-name
|
||||
@echo "SEARCH-DIRS:"
|
||||
@$(CC) -print-search-dirs
|
||||
@echo "---------------- Info: Flags ----------------"
|
||||
@echo "USER_FLAGS: $(USER_FLAGS)"
|
||||
@echo "CC_OPTS: $(CC_OPTS)"
|
||||
@echo "---------------- Info: Host Native GCC Flags ----------------"
|
||||
@echo "CC_X86: $(CC_X86)"
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# In-console simulation using default/simple testbench and GHDL
|
||||
# -----------------------------------------------------------------------------
|
||||
sim: $(APP_IMG) install
|
||||
@echo "Simulating $(APP_IMG)..."
|
||||
@sh $(NEORV32_SIM_PATH)/simple/ghdl.sh
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Show final ELF details (just for debugging)
|
||||
# -----------------------------------------------------------------------------
|
||||
elf_info: main.elf
|
||||
@$(OBJDUMP) -x main.elf
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Help
|
||||
# -----------------------------------------------------------------------------
|
||||
help:
|
||||
@echo "<<< NEORV32 SW Application Makefile >>>"
|
||||
@echo "Make sure to add the bin folder of RISC-V GCC to your PATH variable."
|
||||
@echo ""
|
||||
@echo "== Targets =="
|
||||
@echo " help - show this text"
|
||||
@echo " check - check toolchain"
|
||||
@echo " info - show makefile/toolchain configuration"
|
||||
@echo " exe - compile and generate <neorv32_exe.bin> executable for upload via bootloader"
|
||||
@echo " hex - compile and generate <neorv32_exe.hex> executable raw file"
|
||||
@echo " image - compile and generate VHDL IMEM boot image (for application) in local folder"
|
||||
@echo " install - compile, generate and install VHDL IMEM boot image (for application)"
|
||||
@echo " sim - in-console simulation using default/simple testbench and GHDL"
|
||||
@echo " all - exe + hex + install"
|
||||
@echo " elf_info - show ELF layout info"
|
||||
@echo " clean - clean up project"
|
||||
@echo " clean_all - clean up project, core libraries and image generator"
|
||||
@echo " bl_image - compile and generate VHDL BOOTROM boot image (for bootloader only!) in local folder"
|
||||
@echo " bootloader - compile, generate and install VHDL BOOTROM boot image (for bootloader only!)"
|
||||
@echo ""
|
||||
@echo "== Variables =="
|
||||
@echo " USER_FLAGS - Custom toolchain flags [append only], default \"$(USER_FLAGS)\""
|
||||
@echo " EFFORT - Optimization level, default \"$(EFFORT)\""
|
||||
@echo " MARCH - Machine architecture, default \"$(MARCH)\""
|
||||
@echo " MABI - Machine binary interface, default \"$(MABI)\""
|
||||
@echo " APP_INC - C include folder(s) [append only], default \"$(APP_INC)\""
|
||||
@echo " ASM_INC - ASM include folder(s) [append only], default \"$(ASM_INC)\""
|
||||
@echo " RISCV_PREFIX - Toolchain prefix, default \"$(RISCV_PREFIX)\""
|
||||
@echo " NEORV32_HOME - NEORV32 home folder, default \"$(NEORV32_HOME)\""
|
||||
@echo ""
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Clean up
|
||||
# -----------------------------------------------------------------------------
|
||||
clean:
|
||||
@rm -f *.elf *.o *.bin *.out *.asm *.vhd *.hex
|
||||
|
||||
clean_all: clean
|
||||
@rm -f $(OBJ) $(IMAGE_GEN)
|
261
Libs/RiscV/NEORV32/sw/common/crt0.S
Normal file
261
Libs/RiscV/NEORV32/sw/common/crt0.S
Normal file
@ -0,0 +1,261 @@
|
||||
/* ################################################################################################# */
|
||||
/* # << NEORV32 - crt0.S - Start-Up Code >> # */
|
||||
/* # ********************************************************************************************* # */
|
||||
/* # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting # */
|
||||
/* ################################################################################################# */
|
||||
|
||||
.file "crt0.S"
|
||||
.section .text.boot
|
||||
.balign 4
|
||||
.global _start
|
||||
|
||||
|
||||
_start:
|
||||
.cfi_startproc
|
||||
.cfi_undefined ra
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// This is the very first instruction that is executed after hardware reset. It ensures that x0 is
|
||||
// written at least once - the CPU HW will ensure it is always set to zero on any write access.
|
||||
// ************************************************************************************************
|
||||
lui zero, 0 // "dummy" instruction that uses no reg-file input operands at all
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// Setup pointers using linker script symbols
|
||||
// ************************************************************************************************
|
||||
__crt0_pointer_init:
|
||||
.option push
|
||||
.option norelax
|
||||
|
||||
la sp, __crt0_stack_begin // stack pointer
|
||||
la gp, __global_pointer$ // global pointer
|
||||
|
||||
.option pop
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// Setup CPU core CSRs (some of them DO NOT have a dedicated
|
||||
// reset and need to be explicitly initialized)
|
||||
// ************************************************************************************************
|
||||
__crt0_cpu_csr_init:
|
||||
|
||||
la x10, __crt0_dummy_trap_handler // configure early trap handler
|
||||
csrw mtvec, x10
|
||||
csrw mepc, x10 // just to init mepc
|
||||
|
||||
csrw mstatus, zero // disable global IRQ
|
||||
|
||||
csrw mie, zero // absolutely no interrupts sources, thanks
|
||||
|
||||
csrw mcounteren, zero // no access from less-privileged modes to counter CSRs
|
||||
|
||||
li x11, ~5 // stop all counters except for [m]cycle[h] and [m]instret[h]
|
||||
csrw 0x320, x11 // = mcountinhibit (literal address for lagacy toolchain compatibility)
|
||||
|
||||
csrw mcycle, zero // reset cycle counters
|
||||
csrw mcycleh, zero
|
||||
csrw minstret, zero // reset instruction counters
|
||||
csrw minstreth, zero
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// Initialize integer register file (lower half)
|
||||
// ************************************************************************************************
|
||||
__crt0_reg_file_clear:
|
||||
//addi x0, x0, 0 // hardwired to zero
|
||||
addi x1, x0, 0
|
||||
//addi x2, x0, 0 // stack pointer sp
|
||||
//addi x3, x0, 0 // global pointer gp
|
||||
addi x4, x0, 0
|
||||
addi x5, x0, 0
|
||||
addi x6, x0, 0
|
||||
addi x7, x0, 0
|
||||
//addi x8, x0, 0 // implicitly initialized within crt0
|
||||
//addi x9, x0, 0 // implicitly initialized within crt0
|
||||
//addi x10, x0, 0 // implicitly initialized within crt0
|
||||
//addi x11, x0, 0 // implicitly initialized within crt0
|
||||
//addi x12, x0, 0 // implicitly initialized within crt0
|
||||
//addi x13, x0, 0 // implicitly initialized within crt0
|
||||
addi x14, x0, 0
|
||||
addi x15, x0, 0
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// Initialize integer register file (upper half, if no E extension)
|
||||
// ************************************************************************************************
|
||||
#ifndef __riscv_32e
|
||||
// do not do this if compiling bootloader (to save some program space)
|
||||
#ifndef make_bootloader
|
||||
addi x16, x0, 0
|
||||
addi x17, x0, 0
|
||||
addi x18, x0, 0
|
||||
addi x19, x0, 0
|
||||
addi x20, x0, 0
|
||||
addi x21, x0, 0
|
||||
addi x22, x0, 0
|
||||
addi x23, x0, 0
|
||||
addi x24, x0, 0
|
||||
addi x25, x0, 0
|
||||
addi x26, x0, 0
|
||||
addi x27, x0, 0
|
||||
addi x28, x0, 0
|
||||
addi x29, x0, 0
|
||||
addi x30, x0, 0
|
||||
addi x31, x0, 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// Reset/deactivate IO/peripheral devices
|
||||
// Devices, that are not implemented, will cause a store bus access fault
|
||||
// which is captured (but actually ignored) by the dummy trap handler.
|
||||
// ************************************************************************************************
|
||||
__crt0_reset_io:
|
||||
la x8, __ctr0_io_space_begin // start of processor-internal IO region
|
||||
la x9, __ctr0_io_space_end // end of processor-internal IO region
|
||||
|
||||
__crt0_reset_io_loop:
|
||||
sw zero, 0(x8)
|
||||
addi x8, x8, 4
|
||||
bne x8, x9, __crt0_reset_io_loop
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// Clear .bss section (byte-wise) using linker script symbols
|
||||
// ************************************************************************************************
|
||||
__crt0_clear_bss:
|
||||
la x11, __crt0_bss_start
|
||||
la x12, __crt0_bss_end
|
||||
|
||||
__crt0_clear_bss_loop:
|
||||
bge x11, x12, __crt0_clear_bss_loop_end
|
||||
sb zero, 0(x11)
|
||||
addi x11, x11, 1
|
||||
j __crt0_clear_bss_loop
|
||||
|
||||
__crt0_clear_bss_loop_end:
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// Copy initialized .data section from ROM to RAM (byte-wise) using linker script symbols
|
||||
// ************************************************************************************************
|
||||
__crt0_copy_data:
|
||||
la x11, __crt0_copy_data_src_begin // start of data area (copy source)
|
||||
la x12, __crt0_copy_data_dst_begin // start of data area (copy destination)
|
||||
la x13, __crt0_copy_data_dst_end // last address of destination data area
|
||||
|
||||
__crt0_copy_data_loop:
|
||||
bge x12, x13, __crt0_copy_data_loop_end
|
||||
lb x14, 0(x11)
|
||||
sb x14, 0(x12)
|
||||
addi x11, x11, 1
|
||||
addi x12, x12, 1
|
||||
j __crt0_copy_data_loop
|
||||
|
||||
__crt0_copy_data_loop_end:
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// Setup arguments and call main function
|
||||
// ************************************************************************************************
|
||||
__crt0_main_entry:
|
||||
addi x10, zero, 0 // a0 = argc = 0
|
||||
addi x11, zero, 0 // a1 = argv = 0
|
||||
jal ra, main // call actual app's main function, this "should" not return
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// call "after main" handler (if there is any) if main really returns
|
||||
// ************************************************************************************************
|
||||
__crt0_main_aftermath:
|
||||
csrw mscratch, a0 // copy main's return code in mscratch for debugger
|
||||
|
||||
#ifndef make_bootloader // after_main handler not supported for bootloader
|
||||
.weak __neorv32_crt0_after_main
|
||||
la ra, __neorv32_crt0_after_main
|
||||
beqz ra, __crt0_main_aftermath_end // check if an aftermath handler has been specified
|
||||
jalr ra // execute handler, main's return code in a0
|
||||
#endif
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// go to endless sleep mode
|
||||
// ************************************************************************************************
|
||||
__crt0_main_aftermath_end:
|
||||
csrci mstatus, 8 // mstatus: disable global IRQs (mstatus.mie)
|
||||
__crt0_main_aftermath_end_loop:
|
||||
wfi // try to go to sleep mode
|
||||
j __crt0_main_aftermath_end_loop // endless loop
|
||||
|
||||
|
||||
// ************************************************************************************************
|
||||
// dummy trap handler (for exceptions & IRQs during very early boot stage)
|
||||
// does nothing but tries to move on to next instruction
|
||||
// ************************************************************************************************
|
||||
.balign 4
|
||||
__crt0_dummy_trap_handler:
|
||||
|
||||
addi sp, sp, -8
|
||||
sw x8, 0(sp)
|
||||
sw x9, 4(sp)
|
||||
|
||||
csrr x8, mcause
|
||||
blt x8, zero, __crt0_dummy_trap_handler_irq // skip mepc modification if interrupt
|
||||
|
||||
csrr x8, mepc
|
||||
|
||||
__crt0_dummy_trap_handler_exc_c_check: // is compressed instruction?
|
||||
lh x9, 0(x8) // get compressed instruction or lower 16 bits of uncompressed instruction that caused exception
|
||||
andi x9, x9, 3 // mask: isolate lowest 2 opcode bits (= 11 for uncompressed instructions)
|
||||
|
||||
addi x8, x8, +2 // only this for compressed instructions
|
||||
csrw mepc, x8 // set return address when compressed instruction
|
||||
|
||||
addi x8, zero, 3
|
||||
bne x8, x9, __crt0_dummy_trap_handler_irq // jump if compressed instruction
|
||||
|
||||
__crt0_dummy_trap_handler_exc_uncrompressed: // is uncompressed instruction!
|
||||
csrr x8, mepc
|
||||
addi x8, x8, +2 // add another 2 (making +4) for uncompressed instructions
|
||||
csrw mepc, x8
|
||||
|
||||
__crt0_dummy_trap_handler_irq:
|
||||
lw x8, 0(sp)
|
||||
lw x9, 4(sp)
|
||||
addi sp, sp, +8
|
||||
|
||||
mret
|
||||
|
||||
.cfi_endproc
|
||||
.end
|
309
Libs/RiscV/NEORV32/sw/common/neorv32.ld
Normal file
309
Libs/RiscV/NEORV32/sw/common/neorv32.ld
Normal file
@ -0,0 +1,309 @@
|
||||
/* ################################################################################################# */
|
||||
/* # << NEORV32 - RISC-V GCC Linker Script >> # */
|
||||
/* # ********************************************************************************************* # */
|
||||
/* # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting # */
|
||||
/* ################################################################################################# */
|
||||
|
||||
/* Default linker script, for normal executables */
|
||||
/* Copyright (C) 2014-2020 Free Software Foundation, Inc.
|
||||
Copying and distribution of this script, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. */
|
||||
|
||||
/* modified for the NEORV32 processor by Stephan Nolting */
|
||||
|
||||
|
||||
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
|
||||
OUTPUT_ARCH(riscv)
|
||||
ENTRY(_start)
|
||||
SEARCH_DIR("/opt/riscv/riscv32-unknown-elf/lib"); SEARCH_DIR("=/opt/riscv/riscv64-unknown-linux-gnu/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* NEORV32 memory section configuration. */
|
||||
/* ************************************************************************** */
|
||||
/* "ram" : data memory (int/ext DMEM) - make sure this is sync with the HW! */
|
||||
/* "rom" : instruction memory (int/ext IMEM or bootloader ROM) */
|
||||
/* "iodev" : peripheral/IO devices */
|
||||
/* ************************************************************************** */
|
||||
MEMORY
|
||||
{
|
||||
/* section base addresses and sizes have to be a multiple of 4 bytes */
|
||||
/* ram section: first value of LENGTH => data memory used by bootloader (fixed!); second value of LENGTH => *physical* size of data memory */
|
||||
/* adapt the right-most value to match the *total physical data memory size* of your setup */
|
||||
|
||||
ram (rwx) : ORIGIN = 0x80000000, LENGTH = DEFINED(make_bootloader) ? 512 : 8*1024
|
||||
|
||||
/* rom and iodev sections should NOT be modified by the user at all! */
|
||||
/* rom section: first value of ORIGIN/LENGTH => bootloader ROM; second value of ORIGIN/LENGTH => maximum *logical* size of instruction memory */
|
||||
|
||||
rom (rx) : ORIGIN = DEFINED(make_bootloader) ? 0xFFFF0000 : 0x00000000, LENGTH = DEFINED(make_bootloader) ? 32K : 2048M
|
||||
iodev (rw) : ORIGIN = 0xFFFFFE00, LENGTH = 512
|
||||
|
||||
}
|
||||
/* ************************************************************************* */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* start section on WORD boundary */
|
||||
. = ALIGN(4);
|
||||
|
||||
|
||||
/* Actual instructions */
|
||||
.text :
|
||||
{
|
||||
PROVIDE(__text_start = .);
|
||||
PROVIDE(__textstart = .);
|
||||
|
||||
PROVIDE_HIDDEN (__rela_iplt_start = .);
|
||||
*(.rela.iplt)
|
||||
PROVIDE_HIDDEN (__rela_iplt_end = .);
|
||||
|
||||
*(.rela.plt)
|
||||
|
||||
KEEP(*(.text.boot)); /* keep start-up code at the beginning of rom */
|
||||
|
||||
KEEP (*(SORT_NONE(.init)))
|
||||
|
||||
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
|
||||
*(.text.exit .text.exit.*)
|
||||
*(.text.startup .text.startup.*)
|
||||
*(.text.hot .text.hot.*)
|
||||
*(SORT(.text.sorted.*))
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
/* .gnu.warning sections are handled specially by elf.em. */
|
||||
*(.gnu.warning)
|
||||
|
||||
KEEP (*(SORT_NONE(.fini)))
|
||||
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*crtbegin?.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*crtbegin?.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
|
||||
/* finish section on WORD boundary */
|
||||
. = ALIGN(4);
|
||||
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
} > rom
|
||||
|
||||
|
||||
/* read-only data, appended to .text */
|
||||
.rodata :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
*(.rodata1)
|
||||
|
||||
/* finish section on WORD boundary */
|
||||
. = ALIGN(4);
|
||||
} > rom
|
||||
|
||||
|
||||
/* initialized read/write data, accessed in RAM, placed in ROM, copied during boot */
|
||||
.data :
|
||||
{
|
||||
__DATA_BEGIN__ = .;
|
||||
__SDATA_BEGIN__ = .;
|
||||
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
|
||||
*(.data1)
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
SORT(CONSTRUCTORS)
|
||||
|
||||
*(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*)
|
||||
*(.dynamic)
|
||||
|
||||
/* We want the small data sections together, so single-instruction offsets
|
||||
can access them all, and initialized data all before uninitialized, so
|
||||
we can shorten the on-disk segment size. */
|
||||
|
||||
*(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
||||
|
||||
PROVIDE_HIDDEN (__tdata_start = .);
|
||||
*(.tdata .tdata.* .gnu.linkonce.td.*)
|
||||
|
||||
|
||||
/* finish section on WORD boundary */
|
||||
. = ALIGN(4);
|
||||
|
||||
_edata = .; PROVIDE (edata = .);
|
||||
. = .;
|
||||
|
||||
} > ram AT > rom
|
||||
|
||||
|
||||
/* zero/non-initialized read/write data placed in RAM */
|
||||
.bss (NOLOAD):
|
||||
{
|
||||
__bss_start = .;
|
||||
*(.dynsbss)
|
||||
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||
*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
|
||||
*(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon)
|
||||
*(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
*(COMMON)
|
||||
/* Align here to ensure that the .bss section occupies space up to
|
||||
_end. Align after .bss to ensure correct alignment even if the
|
||||
.bss section disappears because there are no input sections.
|
||||
FIXME: Why do we need it? When there is no .bss section, we do not
|
||||
pad the .data section. */
|
||||
. = ALIGN(. != 0 ? 32 / 8 : 1);
|
||||
|
||||
. = ALIGN(32 / 8);
|
||||
__BSS_END__ = .;
|
||||
__global_pointer$ = MIN(__SDATA_BEGIN__ + 0x800, MAX(__DATA_BEGIN__ + 0x800, __BSS_END__ - 0x800));
|
||||
_end = .; PROVIDE (end = .);
|
||||
} > ram
|
||||
|
||||
|
||||
/* Yet unused */
|
||||
.jcr : { KEEP (*(.jcr)) }
|
||||
.got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } .interp : { *(.interp) }
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
.hash : { *(.hash) }
|
||||
.gnu.hash : { *(.gnu.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.gnu.version : { *(.gnu.version) }
|
||||
.gnu.version_d : { *(.gnu.version_d) }
|
||||
.gnu.version_r : { *(.gnu.version_r) }
|
||||
.rela.init : { *(.rela.init) }
|
||||
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
|
||||
.rela.fini : { *(.rela.fini) }
|
||||
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
|
||||
.rela.data.rel.ro : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
|
||||
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
|
||||
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
|
||||
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
|
||||
.rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
|
||||
.rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
|
||||
.rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
|
||||
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
|
||||
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
.gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
|
||||
/* DWARF debug sections.
|
||||
Symbols in the DWARF debugging sections are relative to the beginning
|
||||
of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/* DWARF 3 */
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
/* DWARF Extension. */
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
.debug_addr 0 : { *(.debug_addr) }
|
||||
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
|
||||
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
|
||||
|
||||
|
||||
/* Provide symbols for neorv32 crt0 start-up code */
|
||||
PROVIDE(__ctr0_imem_begin = ORIGIN(rom));
|
||||
PROVIDE(__ctr0_dmem_begin = ORIGIN(ram));
|
||||
PROVIDE(__crt0_stack_begin = (ORIGIN(ram) + LENGTH(ram)) - 4);
|
||||
PROVIDE(__crt0_bss_start = __bss_start);
|
||||
PROVIDE(__crt0_bss_end = __BSS_END__);
|
||||
PROVIDE(__crt0_copy_data_src_begin = __etext + SIZEOF(.rodata));
|
||||
PROVIDE(__crt0_copy_data_dst_begin = __DATA_BEGIN__);
|
||||
PROVIDE(__crt0_copy_data_dst_end = __DATA_BEGIN__ + SIZEOF(.data));
|
||||
PROVIDE(__ctr0_io_space_begin = ORIGIN(iodev));
|
||||
PROVIDE(__ctr0_io_space_end = ORIGIN(iodev) + LENGTH(iodev));
|
||||
}
|
13
Libs/RiscV/NEORV32/sw/example/bitmanip_test/README.md
Normal file
13
Libs/RiscV/NEORV32/sw/example/bitmanip_test/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# NEORV32 Bit-Manipulation `B` Extension
|
||||
|
||||
:warning: The RISC-V bit-manipulation extension is frozen but not yet officially ratified.
|
||||
|
||||
:warning: The NEORV32 bit manipulation extensions `B` only supports the `Zbb` and `Zba` sub-extension
|
||||
(basic bit-manipulation operation) yet.
|
||||
|
||||
The provided test program `main.c` verifies all currently implemented instruction by checking the results against a pure-software emulation model.
|
||||
The emulation functions as well as the available **intrinsics** for the sub-extension are located in `neorv32_b_extension_intrinsics.h`.
|
||||
|
||||
:information_source: More information regarding the RISC-V bit manipulation extension can be found in the officail GitHub repo:
|
||||
[github.com/riscv/riscv-bitmanip](https://github.com/riscv/riscv-bitmanip).
|
||||
The specification of the bit-manipulation spec supported by the NEORV32 can be found in `docs/references/bitmanip-draft.pdf`.
|
40
Libs/RiscV/NEORV32/sw/example/bitmanip_test/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/bitmanip_test/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
@ -0,0 +1,903 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32 - Intrinsics + Emulation Functions for the CPU B extension >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # The intrinsics provided by this library allow to use the hardware bit manipulation unit of #
|
||||
// # the RISC-V B CPU extension without the need for support by the compiler. #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file bitmanip_test/neorv32_b_extension_intrinsics.h
|
||||
* @author Stephan Nolting
|
||||
* @brief "Intrinsic" library for the NEORV32 bit manipulation B extension.
|
||||
* Also provides emulation functions for all intrinsics (functionality re-built in pure software).
|
||||
*
|
||||
* @warning This library is just a temporary fall-back until the B extension is supported by the upstream RISC-V GCC port.
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_b_extension_intrinsics_h
|
||||
#define neorv32_b_extension_intrinsics_h
|
||||
|
||||
|
||||
// ################################################################################################
|
||||
// "Intrinsics"
|
||||
// ################################################################################################
|
||||
|
||||
|
||||
// ================================================================================================
|
||||
// Zbb - Base instructions
|
||||
// ================================================================================================
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation CLZ (count leading zeros) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Number of leading zeros in source operand.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_clz(uint32_t rs1) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a));
|
||||
|
||||
// clz a0, a0
|
||||
CUSTOM_INSTR_R1_TYPE(0b0110000, 0b00000, a0, 0b001, a0, 0b0010011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation CTZ (count trailing zeros) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Number of trailing zeros in source operand.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_ctz(uint32_t rs1) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a));
|
||||
|
||||
// ctz a0, a0
|
||||
CUSTOM_INSTR_R1_TYPE(0b0110000, 0b00001, a0, 0b001, a0, 0b0010011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation CPOP (count set bits) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Number of set bits in source operand.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_cpop(uint32_t rs1) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a));
|
||||
|
||||
// cpop a0, a0
|
||||
CUSTOM_INSTR_R1_TYPE(0b0110000, 0b00010, a0, 0b001, a0, 0b0010011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation SEXT.B (sign-extend byte) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Sign extended byte (operand(7:0)).
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_sextb(uint32_t rs1) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a));
|
||||
|
||||
// sext.b a0, a0
|
||||
CUSTOM_INSTR_R1_TYPE(0b0110000, 0b00100, a0, 0b001, a0, 0b0010011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation SEXT.H (sign-extend half-word) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Sign-extended half-word (operand(15:0)).
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_sexth(uint32_t rs1) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a));
|
||||
|
||||
// sext.h a0, a0
|
||||
CUSTOM_INSTR_R1_TYPE(0b0110000, 0b00101, a0, 0b001, a0, 0b0010011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ZEXT.H (zero-extend half-word) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Zero-extended half-word (operand(15:0)).
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_zexth(uint32_t rs1) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a));
|
||||
|
||||
// sext.h a0, a0
|
||||
CUSTOM_INSTR_R1_TYPE(0b0000100, 0b00000, a0, 0b100, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation MIN (select signed minimum) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Signed minimum.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_min(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// min a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0000101, a1, a0, 0b100, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation MINU (select unsigned minimum) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Unsigned minimum.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_minu(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// minu a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0000101, a1, a0, 0b101, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation MAX (select signed maximum) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Signed maximum.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_max(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// max a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0000101, a1, a0, 0b110, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation MAXU (select unsigned maximum) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Unsigned maximum.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_maxu(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// maxu a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0000101, a1, a0, 0b111, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ANDN (logical and-negate) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Operand 1 AND NOT operand 2.
|
||||
**************************************************************************/
|
||||
inline inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_andn(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// andn a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0100000, a1, a0, 0b111, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ORN (logical or-negate) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Operand 1 OR NOT operand 2.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_orn(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// orn a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0100000, a1, a0, 0b110, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation XNOR (logical xor-negate) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Operand 1 XOR NOT operand 2.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_xnor(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// xnor a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0100000, a1, a0, 0b100, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ROL (rotate-left) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Operand 1 rotated left by operand_2(4:0) positions.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_rol(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// rol a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0110000, a1, a0, 0b001, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ROR (rotate-right) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Operand 1 rotated right by operand_2(4:0) positions.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_ror(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// ror a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0110000, a1, a0, 0b101, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation RORI (rotate-right) by 20 positions. [B.Zbb]
|
||||
* @warning Fixed shift amount (20) for now.
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Operand 1 rotated right by 20 positions.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_rori20(uint32_t rs1) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a));
|
||||
|
||||
// rori a0, a0, 20
|
||||
CUSTOM_INSTR_R1_TYPE(0b0110000, 0b10100, a0, 0b101, a0, 0b0010011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ORC.B (or-combine byte) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return OR-combined bytes of operand 1.
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_orcb(uint32_t rs1) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a));
|
||||
|
||||
// gorci a0, a0, 7 (pseudo-instruction: orc.b a0, a0)
|
||||
CUSTOM_INSTR_R1_TYPE(0b0010100, 0b00111, a0, 0b101, a0, 0b0010011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation REV8 (byte-swap) [B.Zbb]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Byte swap of operand 1
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_rev8(uint32_t rs1) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a));
|
||||
|
||||
// grevi a0, a0, -8 (pseudo-instruction: rev8 a0, a0)
|
||||
CUSTOM_INSTR_R1_TYPE(0b0110100, 0b11000, a0, 0b101, a0, 0b0010011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// ================================================================================================
|
||||
// Zbb - Base instructions
|
||||
// ================================================================================================
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Address generation instructions SH1ADD (add with logical-1-shift) [B.Zba]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Operand 2 + (Operand 1 << 1)
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_sh1add(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// sh1add a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0010000, a1, a0, 0b010, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Address generation instructions SH2ADD (add with logical-2-shift) [B.Zba]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Operand 2 + (Operand 1 << 2)
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_sh2add(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// sh2add a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0010000, a1, a0, 0b100, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Address generation instructions SH1ADD (add with logical-3-shift) [B.Zba]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 2 (a0).
|
||||
* @return Operand 2 + (Operand 1 << 3)
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) riscv_intrinsic_sh3add(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
register uint32_t result __asm__ ("a0");
|
||||
register uint32_t tmp_a __asm__ ("a0") = rs1;
|
||||
register uint32_t tmp_b __asm__ ("a1") = rs2;
|
||||
|
||||
// dummy instruction to prevent GCC "constprop" optimization
|
||||
asm volatile ("" : [output] "=r" (result) : [input_i] "r" (tmp_a), [input_j] "r" (tmp_b));
|
||||
|
||||
// sh3add a0, a0, a1
|
||||
CUSTOM_INSTR_R2_TYPE(0b0010000, a1, a0, 0b110, a0, 0b0110011);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ################################################################################################
|
||||
// Emulation functions
|
||||
// ################################################################################################
|
||||
|
||||
|
||||
// ================================================================================================
|
||||
// Zbb - Base instructions
|
||||
// ================================================================================================
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation CLZ (count leading zeros) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Number of leading zeros in source operand.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_clz(uint32_t rs1) {
|
||||
|
||||
uint32_t sreg = rs1;
|
||||
uint32_t cnt = 0;
|
||||
|
||||
while(1) {
|
||||
if (sreg & 0x80000000UL) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
sreg <<= 1;
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation CTZ (count trailing zeros) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Number of trailing zeros in source operand.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_ctz(uint32_t rs1) {
|
||||
|
||||
uint32_t sreg = rs1;
|
||||
uint32_t cnt = 0;
|
||||
|
||||
while(1) {
|
||||
if (sreg & 1) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
sreg >>= 1;
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation CPOP (population count) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Number of set bits in source operand.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_cpop(uint32_t rs1) {
|
||||
|
||||
uint32_t sreg = rs1;
|
||||
uint32_t cnt = 0;
|
||||
int i;
|
||||
|
||||
for (i=0; i<32; i++) {
|
||||
if (sreg & 1) {
|
||||
cnt++;
|
||||
}
|
||||
sreg >>= 1;
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation SEXT.B (sign-extend byte) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Sign-extended byte (operand(7:0)).
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_sextb(uint32_t rs1) {
|
||||
|
||||
uint32_t tmp = rs1 & 0xff;
|
||||
|
||||
if (tmp & 0x80) {
|
||||
tmp |= 0xFFFFFF00UL;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation SEXT.H (sign-extend half-word) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Sign-extended half-word (operand(15:0)).
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_sexth(uint32_t rs1) {
|
||||
|
||||
uint32_t tmp = rs1 & 0xffff;
|
||||
|
||||
if (tmp & 0x8000) {
|
||||
tmp |= 0xFFFF0000UL;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ZEXT.H (zero-extend half-word) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Zero-extended half-word (operand(15:0)).
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_zexth(uint32_t rs1) {
|
||||
|
||||
return rs1 & 0x0000FFFFUL;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation MIN (select signed minimum) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Signed minimum.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_min(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
int32_t s_opa = (int32_t)rs1;
|
||||
int32_t s_opb = (int32_t)rs2;
|
||||
|
||||
if (s_opa < s_opb) {
|
||||
return rs1;
|
||||
}
|
||||
else {
|
||||
return rs2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation MINU (select unsigned minimum) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Unsigned minimum.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_minu(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
if (rs1 < rs2) {
|
||||
return rs1;
|
||||
}
|
||||
else {
|
||||
return rs2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation MAX (select signed maximum) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Signed maximum.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_max(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
int32_t s_opa = (int32_t)rs1;
|
||||
int32_t s_opb = (int32_t)rs2;
|
||||
|
||||
if (s_opa < s_opb) {
|
||||
return rs2;
|
||||
}
|
||||
else {
|
||||
return rs1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation MAXU (select unsigned maximum) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Unsigned maximum.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_maxu(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
if (rs1 < rs2) {
|
||||
return rs2;
|
||||
}
|
||||
else {
|
||||
return rs1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ANDN (logical and-negate) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Operand 1 AND NOT operand 2.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_andn(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
return rs1 & (~rs2);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ORN (logical or-negate) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Operand 1 OR NOT operand 2.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_orn(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
return rs1 | (~rs2);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation XNOR (logical xor-negate) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Operand 1 XOR NOT operand 2.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_xnor(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
return rs1 ^ (~rs2);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ROL (rotate-left) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Operand 1 rotated left by operand_2(4:0) positions.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_rol(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
uint32_t shamt = rs2 & 0x1f;
|
||||
|
||||
uint32_t tmp_a = rs1 << shamt;
|
||||
uint32_t tmp_b = rs1 >> (32-shamt);
|
||||
|
||||
return tmp_a | tmp_b;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ROR (rotate-right) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Operand 1 rotated right by operand_2(4:0) positions.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_ror(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
uint32_t shamt = rs2 & 0x1f;
|
||||
|
||||
uint32_t tmp_a = rs1 >> shamt;
|
||||
uint32_t tmp_b = rs1 << (32-shamt);
|
||||
|
||||
return tmp_a | tmp_b;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation REV8 (byte swap) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return Operand 1 byte swapped.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_rev8(uint32_t rs1) {
|
||||
|
||||
uint32_t tmp_a = (rs1 & 0x000000ffUL) << 24;
|
||||
uint32_t tmp_b = (rs1 & 0x0000ff00UL) << 8;
|
||||
uint32_t tmp_c = (rs1 & 0x00ff0000UL) >> 8;
|
||||
uint32_t tmp_d = (rs1 & 0xff000000UL) >> 24;
|
||||
|
||||
return tmp_a | tmp_b | tmp_c | tmp_d;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Bit manipulation ORCB (or-combine bytes) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @return OR-combined bytes of operand 1.
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_orcb(uint32_t rs1) {
|
||||
|
||||
uint32_t tmp = 0;
|
||||
|
||||
if (rs1 & 0x000000ffUL) {
|
||||
tmp |= 0x000000ffUL;
|
||||
}
|
||||
if (rs1 & 0x0000ff00UL) {
|
||||
tmp |= 0x0000ff00UL;
|
||||
}
|
||||
if (rs1 & 0x00ff0000UL) {
|
||||
tmp |= 0x00ff0000UL;
|
||||
}
|
||||
if (rs1 & 0xff000000UL) {
|
||||
tmp |= 0xff000000UL;
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
// ================================================================================================
|
||||
// Zba - Address generation instructions
|
||||
// ================================================================================================
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Address generation instructions SH1ADD (add with logical-1-shift) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Operand 2 + (Operand 1 << 1)
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_sh1add(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
return rs2 + (rs1 << 1);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Address generation instructions SH2ADD (add with logical-2-shift) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Operand 2 + (Operand 1 << 2)
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_sh2add(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
return rs2 + (rs1 << 2);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Intrinsic: Address generation instructions SH3ADD (add with logical-3-shift) [emulation]
|
||||
*
|
||||
* @param[in] rs1 Source operand 1 (a0).
|
||||
* @param[in] rs2 Source operand 1 (a0).
|
||||
* @return Operand 2 + (Operand 1 << 3)
|
||||
**************************************************************************/
|
||||
uint32_t riscv_emulate_sh3add(uint32_t rs1, uint32_t rs2) {
|
||||
|
||||
return rs2 + (rs1 << 3);
|
||||
}
|
||||
|
||||
|
||||
#endif // neorv32_b_extension_intrinsics_h
|
37
Libs/RiscV/NEORV32/sw/example/blink_led/blink_led_in_asm.S
Normal file
37
Libs/RiscV/NEORV32/sw/example/blink_led/blink_led_in_asm.S
Normal file
@ -0,0 +1,37 @@
|
||||
.file "blink_led_in_asm.S"
|
||||
.section .text
|
||||
.balign 4
|
||||
.global blink_led_asm
|
||||
|
||||
blink_led_asm:
|
||||
|
||||
/* base address of GPIO controller's output port is passed as argument (in a0)*/
|
||||
sw zero, 0(a0) /* clear output port */
|
||||
|
||||
li t1, 0 /* initialize counter */
|
||||
|
||||
|
||||
blink_loop:
|
||||
andi t1, t1, 255 /* apply 8-bit mask */
|
||||
sw t1, 0(a0) /* output current counter value */
|
||||
addi t1, t1, 1 /* increment counter */
|
||||
|
||||
jal ra, blink_delay /* call delay function */
|
||||
|
||||
j blink_loop
|
||||
|
||||
|
||||
blink_delay:
|
||||
li t2, 0xfffff /* delay time */
|
||||
|
||||
blink_delay_loop:
|
||||
beq t2, zero, blink_delay_end
|
||||
addi t2, t2, -1
|
||||
nop
|
||||
nop
|
||||
j blink_delay_loop
|
||||
|
||||
blink_delay_end:
|
||||
ret
|
||||
|
||||
.end
|
40
Libs/RiscV/NEORV32/sw/example/blink_led/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/blink_led/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/bus_explorer/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/bus_explorer/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
100
Libs/RiscV/NEORV32/sw/example/coremark/LICENSE.md
Normal file
100
Libs/RiscV/NEORV32/sw/example/coremark/LICENSE.md
Normal file
@ -0,0 +1,100 @@
|
||||
# COREMARK® ACCEPTABLE USE AGREEMENT
|
||||
|
||||
This ACCEPTABLE USE AGREEMENT (this “Agreement”) is offered by Embedded Microprocessor Benchmark Consortium, a California nonprofit corporation (“Licensor”), to users of its CoreMark® software (“Licensee”) exclusively on the following terms.
|
||||
|
||||
Licensor offers benchmarking software (“Software”) pursuant to an open source license, but carefully controls use of its benchmarks and their associated goodwill. Licensor has registered its trademark in one of the benchmarks available through the Software, COREMARK, Ser. No. 85/487,290; Reg. No. 4,179,307 (the “Trademark”), and promotes the use of a standard metric as a benchmark for assessing the performance of embedded systems. Solely on the terms described herein, Licensee may use and display the Trademark in connection with the generation of data regarding measurement and analysis of computer and embedded system benchmarking via the Software (the “Licensed Use”).
|
||||
|
||||
## Article 1 – License Grant.
|
||||
1.1. License. Subject to the terms and conditions of this Agreement, Licensor hereby grants to Licensee, and Licensee hereby accepts from Licensor, a personal, non-exclusive, royalty-free, revocable right and license to use and display the Trademark during the term of this Agreement (the “Term”), solely and exclusively in connection with the Licensed Use. During the Term, Licensee (i) shall not modify or otherwise create derivative works of the Trademark, and (ii) may use the Trademark only to the extent permitted under this License. Neither Licensee nor any affiliate or agent thereof shall otherwise use the Trademark without the prior express written consent of Licensor, which may be withheld in its sole and absolute discretion. All rights not expressly granted to Licensee hereunder shall remain the exclusive property of Licensor.
|
||||
|
||||
1.2. Modifications to the Software. Licensee shall not use the Trademark in connection with any use of a modified, derivative, or otherwise altered copy of the Software.
|
||||
|
||||
1.3. Licensor’s Use. Nothing in this Agreement shall preclude Licensor or any of its successors or assigns from using or permitting other entities to use the Trademark, whether or not such entity directly or indirectly competes or conflicts with Licensee’s Licensed Use in any manner.
|
||||
|
||||
1.4. Term and Termination. This Agreement is perpetual unless terminated by either of the parties. Licensee may terminate this Agreement for convenience, without cause or liability, for any reason or for no reason whatsoever, upon ten (10) business days written notice. Licensor may terminate this Agreement effective immediately upon notice of breach. Upon termination, Licensee shall immediately remove all implementations of the Trademark from the Licensed Use, and delete all digitals files and records of all materials related to the Trademark.
|
||||
|
||||
## Article 2 – Ownership.
|
||||
2.1. Ownership. Licensee acknowledges and agrees that Licensor is the owner of all right, title, and interest in and to the Trademark, and all such right, title, and interest shall remain with Licensor. Licensee shall not contest, dispute, challenge, oppose, or seek to cancel Licensor’s right, title, and interest in and to the Trademark. Licensee shall not prosecute any application for registration of the Trademark. Licensee shall display appropriate notices regarding ownership of the Trademark in connection with the Licensed Use.
|
||||
|
||||
2.2. Goodwill. Licensee acknowledges that Licensee shall not acquire any right, title, or interest in the Trademark by virtue of this Agreement other than the license granted hereunder, and disclaims any such right, title, interest, or ownership. All goodwill and reputation generated by Licensee’s use of the Trademark shall inure to the exclusive benefit of Licensor. Licensee shall not by any act or omission use the Trademark in any manner that disparages or reflects adversely on Licensor or its Licensed Use or reputation. Licensee shall not take any action that would interfere with or prejudice Licensor’s ownership or registration of the Trademark, the validity of the Trademark or the validity of the license granted by this Agreement. If Licensor determines and notifies Licensee that any act taken in connection with the Licensed Use (i) is inaccurate, unlawful or offensive to good taste; (ii) fails to provide for proper trademark notices, or (iii) otherwise violates Licensee’s obligations under this Agreement, the license granted under this Agreement shall terminate.
|
||||
|
||||
## Article 3 – Indemnification.
|
||||
3.1. Indemnification Generally. Licensee agrees to indemnify, defend, and hold harmless (collectively “indemnify” or “indemnification”) Licensor, including Licensor’s members, managers, officers, and employees (collectively “Related Persons”), from and against, and pay or reimburse Licensor and such Related Persons for, any and all third-party actions, claims, demands, proceedings, investigations, inquiries (collectively, “Claims”), and any and all liabilities, obligations, fines, deficiencies, costs, expenses, royalties, losses, and damages (including reasonable outside counsel fees and expenses) associated with such Claims, to the extent that such Claim arises out of (i) Licensee’s material breach of this Agreement, or (ii) any allegation(s) that Licensee’s actions infringe or violate any third-party intellectual property right, including without limitation, any U.S. copyright, patent, or trademark, or are otherwise found to be tortious or criminal (whether or not such indemnified person is a named party in a legal proceeding).
|
||||
|
||||
3.2. Notice and Defense of Claims. Licensor shall promptly notify Licensee of any Claim for which indemnification is sought, following actual knowledge of such Claim, provided however that the failure to give such notice shall not relieve Licensee of its obligations hereunder except to the extent that Licensee is materially prejudiced by such failure. In the event that any third-party Claim is brought, Licensee shall have the right and option to undertake and control the defense of such action with counsel of its choice, provided however that (i) Licensor at its own expense may participate and appear on an equal footing with Licensee in the defense of any such Claim, (ii) Licensor may undertake and control such defense in the event of the material failure of Licensee to undertake and control the same; and (iii) the defense of any Claim relating to the intellectual property rights of Licensor or its licensors and any related counterclaims shall be solely controlled by Licensor with counsel of its choice. Licensee shall not consent to judgment or concede or settle or compromise any Claim without the prior written approval of Licensor (whose approval shall not be unreasonably withheld), unless such concession or settlement or compromise includes a full and unconditional release of Licensor and any applicable Related Persons from all liabilities in respect of such Claim.
|
||||
|
||||
## Article 4 – Miscellaneous.
|
||||
4.1. Relationship of the Parties. This Agreement does not create a partnership, franchise, joint venture, agency, fiduciary, or employment relationship between the parties.
|
||||
|
||||
4.2. No Third-Party Beneficiaries. Except for the rights of Related Persons under Article 3 (Indemnification), there are no third-party beneficiaries to this Agreement.
|
||||
|
||||
4.3. Assignment. Licensee’s rights hereunder are non-assignable, and may not be sublicensed.
|
||||
|
||||
4.4. Equitable Relief. Licensee acknowledges that the remedies available at law for any breach of this Agreement will, by their nature, be inadequate. Accordingly, Licensor may obtain injunctive relief or other equitable relief to restrain a breach or threatened breach of this Agreement or to specifically enforce this Agreement, without proving that any monetary damages have been sustained, and without the requirement of posting of a bond prior to obtaining such equitable relief.
|
||||
|
||||
4.5. Governing Law. This Agreement will be interpreted, construed, and enforced in all respects in accordance with the laws of the State of California, without reference to its conflict of law principles.
|
||||
|
||||
4.6. Attorneys’ Fees. If any legal action, arbitration or other proceeding is brought for the enforcement of this Agreement, or because of an alleged dispute, breach, default, or misrepresentation in connection with any of the provisions of this Agreement, the successful or prevailing party shall be entitled to recover its reasonable attorneys’ fees and other reasonable costs incurred in that action or proceeding, in addition to any other relief to which it may be entitled.
|
||||
|
||||
4.7. Amendment; Waiver. This Agreement may not be amended, nor may any rights under it be waived, except in writing by Licensor.
|
||||
|
||||
4.8. Severability. If any provision of this Agreement is held by a court of competent jurisdiction to be contrary to law, the provision shall be modified by the court and interpreted so as best to accomplish the objectives of the original provision to the fullest extent
|
||||
permitted by law, and the remaining provisions of this Agreement shall remain in effect.
|
||||
|
||||
4.9. Entire Agreement. This Agreement constitutes the entire agreement between the parties and supersedes all prior and contemporaneous agreements, proposals or representations, written or oral, concerning its subject matter.
|
||||
|
||||
|
||||
# Apache License
|
||||
|
||||
Version 2.0, January 2004
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
## TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
78
Libs/RiscV/NEORV32/sw/example/coremark/README.md
Normal file
78
Libs/RiscV/NEORV32/sw/example/coremark/README.md
Normal file
@ -0,0 +1,78 @@
|
||||
|
||||
# Introduction
|
||||
|
||||
CoreMark's primary goals are simplicity and providing a method for testing only a processor's core features. For more information about EEMBC's comprehensive embedded benchmark suites, please see www.eembc.org.
|
||||
|
||||
For a more compute-intensive version of CoreMark that uses larger datasets and execution loops taken from common applications, please check out EEMBC's [CoreMark-PRO](https://www.github.com/eembc/coremark-pro) benchmark, also on GitHub.
|
||||
|
||||
This project folder is a port of CoreMark (from the official [GitHub repository](https://github.com/eembc/coremark)) for the NEORV32 processor.
|
||||
|
||||
# Building
|
||||
|
||||
To build the executable (`neorv32_exe.bin`) of the benchmark, type:
|
||||
|
||||
`> make USER_FLAGS+=-DRUN_COREMARK clean_all exe`
|
||||
|
||||
Make sure to define `RUN_COREMARK` *when invoking* `make` (via `USER_FLAGS+=-DRUN_COREMARK`).
|
||||
|
||||
To build the executable for a certain CPU configuration and a certain optimization level of the benchmark, type (`rv32imc` and `O3` in this example):
|
||||
|
||||
`> make USER_FLAGS+=-DRUN_COREMARK MARCH=rv32imc EFFORT=-O3 clean_all exe`
|
||||
|
||||
|
||||
# Running
|
||||
|
||||
Upload the generated executable `neorv32_exe.bin` via the bootloader ('u' command) and execute it ('e' command):
|
||||
|
||||
```
|
||||
<< NEORV32 Bootloader >>
|
||||
|
||||
BLDV: Nov 7 2020
|
||||
HWV: 0x01040700
|
||||
CLK: 0x05F5E100 Hz
|
||||
USER: 0x10000DE0
|
||||
MISA: 0x40901104
|
||||
PROC: 0x007F0015
|
||||
IMEM: 0x00008000 bytes @ 0x00000000
|
||||
DMEM: 0x00008000 bytes @ 0x80000000
|
||||
|
||||
Autoboot in 8s. Press key to abort.
|
||||
Aborted.
|
||||
|
||||
Available CMDs:
|
||||
h: Help
|
||||
r: Restart
|
||||
u: Upload
|
||||
s: Store to flash
|
||||
l: Load from flash
|
||||
e: Execute
|
||||
CMD:> u
|
||||
Awaiting neorv32_exe.bin... OK
|
||||
CMD:> e
|
||||
Booting...
|
||||
|
||||
NEORV32: Processor running at 100000000 Hz
|
||||
NEORV32: Executing coremark (2000 iterations). This may take some time...
|
||||
|
||||
2K performance run parameters for coremark.
|
||||
CoreMark Size : 666
|
||||
Total ticks : 3036959876
|
||||
Total time (secs): 30
|
||||
Iterations/Sec : 66
|
||||
Iterations : 2000
|
||||
Compiler version : GCC10.1.0
|
||||
Compiler flags : -> default, see makefile
|
||||
Memory location : STACK
|
||||
seedcrc : 0xe9f5
|
||||
[0]crclist : 0xe714
|
||||
[0]crcmatrix : 0x1fd7
|
||||
[0]crcstate : 0x8e3a
|
||||
[0]crcfinal : 0x4983
|
||||
Correct operation validated. See README.md for run and reporting rules.
|
||||
|
||||
NEORV32: All reported numbers only show the integer results.
|
||||
|
||||
NEORV32: Executed instructions 0x00000000_24b8576e
|
||||
NEORV32: CoreMark core clock cycles 0x00000000_b5045484
|
||||
NEORV32: Average CPI (integer part only): 4 cycles/instruction
|
||||
```
|
232
Libs/RiscV/NEORV32/sw/example/coremark/core_portme.h
Normal file
232
Libs/RiscV/NEORV32/sw/example/coremark/core_portme.h
Normal file
@ -0,0 +1,232 @@
|
||||
/*
|
||||
Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Original Author: Shay Gal-on
|
||||
*/
|
||||
|
||||
/* Modified for the NEORV32 Processor - by Stephan Nolting */
|
||||
|
||||
/* Topic : Description
|
||||
This file contains configuration constants required to execute on
|
||||
different platforms
|
||||
*/
|
||||
#ifndef CORE_PORTME_H
|
||||
#define CORE_PORTME_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <neorv32.h>
|
||||
|
||||
/************************/
|
||||
/* NEORV32-specific */
|
||||
/************************/
|
||||
#define BAUD_RATE (19200)
|
||||
#define ITERATIONS (2000)
|
||||
#define FLAGS_STR "-> default, see makefile" // compiler optimization
|
||||
|
||||
/************************/
|
||||
/* Data types and settings */
|
||||
/************************/
|
||||
/* Configuration : HAS_FLOAT
|
||||
Define to 1 if the platform supports floating point.
|
||||
*/
|
||||
#ifndef HAS_FLOAT
|
||||
#define HAS_FLOAT 0
|
||||
#endif
|
||||
/* Configuration : HAS_TIME_H
|
||||
Define to 1 if platform has the time.h header file,
|
||||
and implementation of functions thereof.
|
||||
*/
|
||||
#ifndef HAS_TIME_H
|
||||
#define HAS_TIME_H 0
|
||||
#endif
|
||||
/* Configuration : USE_CLOCK
|
||||
Define to 1 if platform has the time.h header file,
|
||||
and implementation of functions thereof.
|
||||
*/
|
||||
#ifndef USE_CLOCK
|
||||
#define USE_CLOCK 0
|
||||
#endif
|
||||
/* Configuration : HAS_STDIO
|
||||
Define to 1 if the platform has stdio.h.
|
||||
*/
|
||||
#ifndef HAS_STDIO
|
||||
#define HAS_STDIO 0
|
||||
#endif
|
||||
/* Configuration : HAS_PRINTF
|
||||
Define to 1 if the platform has stdio.h and implements the printf
|
||||
function.
|
||||
*/
|
||||
#ifndef HAS_PRINTF
|
||||
#define HAS_PRINTF 0
|
||||
#endif
|
||||
|
||||
/* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
|
||||
Initialize these strings per platform
|
||||
*/
|
||||
#ifndef COMPILER_VERSION
|
||||
#ifdef __GNUC__
|
||||
#define COMPILER_VERSION "GCC"__VERSION__
|
||||
#else
|
||||
#define COMPILER_VERSION "Please put compiler version here (e.g. gcc 4.1)"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef COMPILER_FLAGS
|
||||
#define COMPILER_FLAGS \
|
||||
FLAGS_STR /* "Please put compiler flags here (e.g. -o3)" */
|
||||
#endif
|
||||
#ifndef MEM_LOCATION
|
||||
#define MEM_LOCATION "STATIC"
|
||||
#endif
|
||||
|
||||
/* Data Types :
|
||||
To avoid compiler issues, define the data types that need ot be used for
|
||||
8b, 16b and 32b in <core_portme.h>.
|
||||
|
||||
*Imprtant* :
|
||||
ee_ptr_int needs to be the data type used to hold pointers, otherwise
|
||||
coremark may fail!!!
|
||||
*/
|
||||
typedef int16_t ee_s16;
|
||||
typedef uint16_t ee_u16;
|
||||
typedef int32_t ee_s32;
|
||||
typedef double ee_f32;
|
||||
typedef unsigned char ee_u8;
|
||||
typedef uint32_t ee_u32;
|
||||
typedef uint64_t ee_u64;
|
||||
typedef ee_u32 ee_ptr_int;
|
||||
typedef size_t ee_size_t;
|
||||
#define NULL ((void *)0)
|
||||
/* align_mem :
|
||||
This macro is used to align an offset to point to a 32b value. It is
|
||||
used in the Matrix algorithm to initialize the input memory blocks.
|
||||
*/
|
||||
#define align_mem(x) (void *)(4 + (((ee_ptr_int)(x)-1) & ~3))
|
||||
|
||||
/* Configuration : CORE_TICKS
|
||||
Define type of return from the timing functions.
|
||||
*/
|
||||
#define CORETIMETYPE ee_u64
|
||||
typedef ee_u64 CORE_TICKS;
|
||||
|
||||
/* Configuration : SEED_METHOD
|
||||
Defines method to get seed values that cannot be computed at compile
|
||||
time.
|
||||
|
||||
Valid values :
|
||||
SEED_ARG - from command line.
|
||||
SEED_FUNC - from a system function.
|
||||
SEED_VOLATILE - from volatile variables.
|
||||
*/
|
||||
#ifndef SEED_METHOD
|
||||
#define SEED_METHOD SEED_VOLATILE
|
||||
#endif
|
||||
|
||||
/* Configuration : MEM_METHOD
|
||||
Defines method to get a block of memry.
|
||||
|
||||
Valid values :
|
||||
MEM_MALLOC - for platforms that implement malloc and have malloc.h.
|
||||
MEM_STATIC - to use a static memory array.
|
||||
MEM_STACK - to allocate the data block on the stack (NYI).
|
||||
*/
|
||||
#ifndef MEM_METHOD
|
||||
#define MEM_METHOD MEM_STATIC
|
||||
#endif
|
||||
|
||||
/* Configuration : MULTITHREAD
|
||||
Define for parallel execution
|
||||
|
||||
Valid values :
|
||||
1 - only one context (default).
|
||||
N>1 - will execute N copies in parallel.
|
||||
|
||||
Note :
|
||||
If this flag is defined to more then 1, an implementation for launching
|
||||
parallel contexts must be defined.
|
||||
|
||||
Two sample implementations are provided. Use <USE_PTHREAD> or <USE_FORK>
|
||||
to enable them.
|
||||
|
||||
It is valid to have a different implementation of <core_start_parallel>
|
||||
and <core_end_parallel> in <core_portme.c>, to fit a particular architecture.
|
||||
*/
|
||||
#ifndef MULTITHREAD
|
||||
#define MULTITHREAD 1
|
||||
#define USE_PTHREAD 0
|
||||
#define USE_FORK 0
|
||||
#define USE_SOCKET 0
|
||||
#endif
|
||||
|
||||
/* Configuration : MAIN_HAS_NOARGC
|
||||
Needed if platform does not support getting arguments to main.
|
||||
|
||||
Valid values :
|
||||
0 - argc/argv to main is supported
|
||||
1 - argc/argv to main is not supported
|
||||
|
||||
Note :
|
||||
This flag only matters if MULTITHREAD has been defined to a value
|
||||
greater then 1.
|
||||
*/
|
||||
#ifndef MAIN_HAS_NOARGC
|
||||
#define MAIN_HAS_NOARGC 0
|
||||
#endif
|
||||
|
||||
/* Configuration : MAIN_HAS_NORETURN
|
||||
Needed if platform does not support returning a value from main.
|
||||
|
||||
Valid values :
|
||||
0 - main returns an int, and return value will be 0.
|
||||
1 - platform does not support returning a value from main
|
||||
*/
|
||||
#ifndef MAIN_HAS_NORETURN
|
||||
#define MAIN_HAS_NORETURN 0
|
||||
#endif
|
||||
|
||||
/* Variable : default_num_contexts
|
||||
Not used for this simple port, must cintain the value 1.
|
||||
*/
|
||||
extern ee_u32 default_num_contexts;
|
||||
|
||||
typedef struct CORE_PORTABLE_S
|
||||
{
|
||||
ee_u8 portable_id;
|
||||
} core_portable;
|
||||
|
||||
/* target specific init/fini */
|
||||
#ifndef RUN_COREMARK
|
||||
void
|
||||
__attribute__((__noreturn__))
|
||||
portable_init(core_portable *p, int *argc, char *argv[]);
|
||||
#else
|
||||
void
|
||||
portable_init(core_portable *p, int *argc, char *argv[]);
|
||||
#endif
|
||||
void portable_fini(core_portable *p);
|
||||
|
||||
#if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN) \
|
||||
&& !defined(VALIDATION_RUN)
|
||||
#if (TOTAL_DATA_SIZE == 1200)
|
||||
#define PROFILE_RUN 1
|
||||
#elif (TOTAL_DATA_SIZE == 2000)
|
||||
#define PERFORMANCE_RUN 1
|
||||
#else
|
||||
#define VALIDATION_RUN 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int ee_printf(const char *fmt, ...);
|
||||
|
||||
#endif /* CORE_PORTME_H */
|
183
Libs/RiscV/NEORV32/sw/example/coremark/coremark.h
Normal file
183
Libs/RiscV/NEORV32/sw/example/coremark/coremark.h
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Original Author: Shay Gal-on
|
||||
*/
|
||||
|
||||
/* Topic: Description
|
||||
This file contains declarations of the various benchmark functions.
|
||||
*/
|
||||
|
||||
/* Configuration: TOTAL_DATA_SIZE
|
||||
Define total size for data algorithms will operate on
|
||||
*/
|
||||
#ifndef TOTAL_DATA_SIZE
|
||||
#define TOTAL_DATA_SIZE 2 * 1000
|
||||
#endif
|
||||
|
||||
#define SEED_ARG 0
|
||||
#define SEED_FUNC 1
|
||||
#define SEED_VOLATILE 2
|
||||
|
||||
#define MEM_STATIC 0
|
||||
#define MEM_MALLOC 1
|
||||
#define MEM_STACK 2
|
||||
|
||||
#include "core_portme.h"
|
||||
|
||||
#if HAS_STDIO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#if HAS_PRINTF
|
||||
#define ee_printf printf
|
||||
#endif
|
||||
|
||||
/* Actual benchmark execution in iterate */
|
||||
void *iterate(void *pres);
|
||||
|
||||
/* Typedef: secs_ret
|
||||
For machines that have floating point support, get number of seconds as
|
||||
a double. Otherwise an unsigned int.
|
||||
*/
|
||||
#if HAS_FLOAT
|
||||
typedef double secs_ret;
|
||||
#else
|
||||
typedef ee_u32 secs_ret;
|
||||
#endif
|
||||
|
||||
#if MAIN_HAS_NORETURN
|
||||
#define MAIN_RETURN_VAL
|
||||
#define MAIN_RETURN_TYPE void
|
||||
#else
|
||||
#define MAIN_RETURN_VAL 0
|
||||
#define MAIN_RETURN_TYPE int
|
||||
#endif
|
||||
|
||||
void start_time(void);
|
||||
void stop_time(void);
|
||||
CORE_TICKS get_time(void);
|
||||
secs_ret time_in_secs(CORE_TICKS ticks);
|
||||
|
||||
/* Misc useful functions */
|
||||
ee_u16 crcu8(ee_u8 data, ee_u16 crc);
|
||||
ee_u16 crc16(ee_s16 newval, ee_u16 crc);
|
||||
ee_u16 crcu16(ee_u16 newval, ee_u16 crc);
|
||||
ee_u16 crcu32(ee_u32 newval, ee_u16 crc);
|
||||
ee_u8 check_data_types(void);
|
||||
void * portable_malloc(ee_size_t size);
|
||||
void portable_free(void *p);
|
||||
ee_s32 parseval(char *valstring);
|
||||
|
||||
/* Algorithm IDS */
|
||||
#define ID_LIST (1 << 0)
|
||||
#define ID_MATRIX (1 << 1)
|
||||
#define ID_STATE (1 << 2)
|
||||
#define ALL_ALGORITHMS_MASK (ID_LIST | ID_MATRIX | ID_STATE)
|
||||
#define NUM_ALGORITHMS 3
|
||||
|
||||
/* list data structures */
|
||||
typedef struct list_data_s
|
||||
{
|
||||
ee_s16 data16;
|
||||
ee_s16 idx;
|
||||
} list_data;
|
||||
|
||||
typedef struct list_head_s
|
||||
{
|
||||
struct list_head_s *next;
|
||||
struct list_data_s *info;
|
||||
} list_head;
|
||||
|
||||
/*matrix benchmark related stuff */
|
||||
#define MATDAT_INT 1
|
||||
#if MATDAT_INT
|
||||
typedef ee_s16 MATDAT;
|
||||
typedef ee_s32 MATRES;
|
||||
#else
|
||||
typedef ee_f16 MATDAT;
|
||||
typedef ee_f32 MATRES;
|
||||
#endif
|
||||
|
||||
typedef struct MAT_PARAMS_S
|
||||
{
|
||||
int N;
|
||||
MATDAT *A;
|
||||
MATDAT *B;
|
||||
MATRES *C;
|
||||
} mat_params;
|
||||
|
||||
/* state machine related stuff */
|
||||
/* List of all the possible states for the FSM */
|
||||
typedef enum CORE_STATE
|
||||
{
|
||||
CORE_START = 0,
|
||||
CORE_INVALID,
|
||||
CORE_S1,
|
||||
CORE_S2,
|
||||
CORE_INT,
|
||||
CORE_FLOAT,
|
||||
CORE_EXPONENT,
|
||||
CORE_SCIENTIFIC,
|
||||
NUM_CORE_STATES
|
||||
} core_state_e;
|
||||
|
||||
/* Helper structure to hold results */
|
||||
typedef struct RESULTS_S
|
||||
{
|
||||
/* inputs */
|
||||
ee_s16 seed1; /* Initializing seed */
|
||||
ee_s16 seed2; /* Initializing seed */
|
||||
ee_s16 seed3; /* Initializing seed */
|
||||
void * memblock[4]; /* Pointer to safe memory location */
|
||||
ee_u32 size; /* Size of the data */
|
||||
ee_u32 iterations; /* Number of iterations to execute */
|
||||
ee_u32 execs; /* Bitmask of operations to execute */
|
||||
struct list_head_s *list;
|
||||
mat_params mat;
|
||||
/* outputs */
|
||||
ee_u16 crc;
|
||||
ee_u16 crclist;
|
||||
ee_u16 crcmatrix;
|
||||
ee_u16 crcstate;
|
||||
ee_s16 err;
|
||||
/* ultithread specific */
|
||||
core_portable port;
|
||||
} core_results;
|
||||
|
||||
/* Multicore execution handling */
|
||||
#if (MULTITHREAD > 1)
|
||||
ee_u8 core_start_parallel(core_results *res);
|
||||
ee_u8 core_stop_parallel(core_results *res);
|
||||
#endif
|
||||
|
||||
/* list benchmark functions */
|
||||
list_head *core_list_init(ee_u32 blksize, list_head *memblock, ee_s16 seed);
|
||||
ee_u16 core_bench_list(core_results *res, ee_s16 finder_idx);
|
||||
|
||||
/* state benchmark functions */
|
||||
void core_init_state(ee_u32 size, ee_s16 seed, ee_u8 *p);
|
||||
ee_u16 core_bench_state(ee_u32 blksize,
|
||||
ee_u8 *memblock,
|
||||
ee_s16 seed1,
|
||||
ee_s16 seed2,
|
||||
ee_s16 step,
|
||||
ee_u16 crc);
|
||||
|
||||
/* matrix benchmark functions */
|
||||
ee_u32 core_init_matrix(ee_u32 blksize,
|
||||
void * memblk,
|
||||
ee_s32 seed,
|
||||
mat_params *p);
|
||||
ee_u16 core_bench_matrix(mat_params *p, ee_s16 seed, ee_u16 crc);
|
40
Libs/RiscV/NEORV32/sw/example/coremark/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/coremark/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
152
Libs/RiscV/NEORV32/sw/example/demo_freeRTOS/FreeRTOSConfig.h
Normal file
152
Libs/RiscV/NEORV32/sw/example/demo_freeRTOS/FreeRTOSConfig.h
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.
|
||||
All rights reserved
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
|
||||
|
||||
***************************************************************************
|
||||
>>! NOTE: The modification to the GPL is included to allow you to !<<
|
||||
>>! distribute a combined work that includes FreeRTOS without being !<<
|
||||
>>! obliged to provide the source code for proprietary components !<<
|
||||
>>! outside of the FreeRTOS kernel. !<<
|
||||
***************************************************************************
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available on the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that is more than just the market leader, it *
|
||||
* is the industry's de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly while simultaneously helping *
|
||||
* to support the FreeRTOS project by purchasing a FreeRTOS *
|
||||
* tutorial book, reference manual, or both: *
|
||||
* http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
|
||||
the FAQ page "My application does not run, what could be wrong?". Have you
|
||||
defined configASSERT()?
|
||||
|
||||
http://www.FreeRTOS.org/support - In return for receiving this top quality
|
||||
embedded software for free we request you assist our global community by
|
||||
participating in the support forum.
|
||||
|
||||
http://www.FreeRTOS.org/training - Investing in training allows your team to
|
||||
be as productive as possible as early as possible. Now you can receive
|
||||
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
|
||||
Ltd, and the world's leading authority on the world's leading RTOS.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
|
||||
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
|
||||
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and commercial middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
//#include "clock_config.h"
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
* These definitions should be adjusted for your particular hardware and
|
||||
* application requirements.
|
||||
*
|
||||
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
|
||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||
*
|
||||
* See http://www.freertos.org/a00110.html.
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/* See https://www.freertos.org/Using-FreeRTOS-on-RISC-V.html */
|
||||
#define configMTIME_BASE_ADDRESS ( 0xFFFFFF90UL )
|
||||
#define configMTIMECMP_BASE_ADDRESS ( 0xFFFFFF98UL )
|
||||
|
||||
#define configISR_STACK_SIZE_WORDS ( 128 )
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 1
|
||||
#define configUSE_TICK_HOOK 1
|
||||
#define configCPU_CLOCK_HZ 100000000
|
||||
#define configTICK_RATE_HZ ( ( TickType_t ) 100 )
|
||||
#define configMAX_PRIORITIES ( 5 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 128 ) /* Can be as low as 60 but some of the demo tasks that use this constant require it to be higher. */
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 7 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
#define configIDLE_SHOULD_YIELD 0
|
||||
#define configUSE_MUTEXES 1
|
||||
#define configQUEUE_REGISTRY_SIZE 8
|
||||
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||
#define configUSE_RECURSIVE_MUTEXES 1
|
||||
#define configUSE_MALLOC_FAILED_HOOK 1
|
||||
#define configUSE_APPLICATION_TASK_TAG 0
|
||||
#define configUSE_COUNTING_SEMAPHORES 1
|
||||
#define configGENERATE_RUN_TIME_STATS 0
|
||||
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 4
|
||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||
|
||||
/* Co-routine definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* Software timer definitions. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
#define configTIMER_QUEUE_LENGTH 4
|
||||
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )
|
||||
|
||||
/* Task priorities. Allow these to be overridden. */
|
||||
#ifndef uartPRIMARY_PRIORITY
|
||||
#define uartPRIMARY_PRIORITY ( configMAX_PRIORITIES - 3 )
|
||||
#endif
|
||||
|
||||
/* Set the following definitions to 1 to include the API function, or zero
|
||||
to exclude the API function. */
|
||||
#define INCLUDE_vTaskPrioritySet 1
|
||||
#define INCLUDE_uxTaskPriorityGet 1
|
||||
#define INCLUDE_vTaskDelete 1
|
||||
#define INCLUDE_vTaskCleanUpResources 1
|
||||
#define INCLUDE_vTaskSuspend 1
|
||||
#define INCLUDE_vTaskDelayUntil 1
|
||||
#define INCLUDE_vTaskDelay 1
|
||||
#define INCLUDE_eTaskGetState 1
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
#define INCLUDE_xTaskAbortDelay 1
|
||||
#define INCLUDE_xTaskGetHandle 1
|
||||
#define INCLUDE_xSemaphoreGetMutexHolder 1
|
||||
|
||||
/* Normal assert() semantics without relying on the provision of an assert.h
|
||||
header file. */
|
||||
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); __asm volatile( "ebreak" ); for( ;; ); }
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
71
Libs/RiscV/NEORV32/sw/example/demo_freeRTOS/README.md
Normal file
71
Libs/RiscV/NEORV32/sw/example/demo_freeRTOS/README.md
Normal file
@ -0,0 +1,71 @@
|
||||
# FreeRTOS Demo for the NEORV32 Processor
|
||||
|
||||
This example shows how to run [FreeRTOS](https://www.freertos.org/) on the NEORV32 processor. It features the default
|
||||
"blinky_demo" and the more sophisticated "full_demo" demo applications. See the comments in `main.c` and the according
|
||||
source files for more information.
|
||||
|
||||
The chip-specific extensions folder (`chip_specific_extensions/neorv32`) should be in `$(FREERTOS_HOME)/Source/portable/GCC/RISC-V/chip_specific_extensions`,
|
||||
but is placed in this source directory for simplicity.
|
||||
|
||||
|
||||
## Hardware Requirements
|
||||
|
||||
* DMEM/IMEM requriements depend on the actual application (for example: 8kB DMEM and 16kB IMEM for *blinky_demo*)
|
||||
* MTIME (machine timer) + UART + GPIO
|
||||
* `Zicsr` CPU extension
|
||||
|
||||
|
||||
## Instructions
|
||||
|
||||
Download FreeRTOS from the [official GitHub repository](https://github.com/FreeRTOS/FreeRTOS) or from the its official homepage.
|
||||
|
||||
$ git clone https://github.com/FreeRTOS/FreeRTOS.git
|
||||
|
||||
Open the makefile from this example folder and configure the `FREERTOS_HOME` variable to point to your FreeRTOS home folder.
|
||||
|
||||
FREERTOS_HOME ?= /mnt/n/Projects/FreeRTOSv10.4.1
|
||||
|
||||
Compile the NEORV32 executable. Do not forget the `RUN_FREERTOS_DEMO` switch.
|
||||
|
||||
$ make USER_FLAGS+=-DRUN_FREERTOS_DEMO clean_all exe
|
||||
|
||||
Note: The *.c sources and the FreeRTOS-specific part of the makefile have (include) guards that test if `RUN_FREERTOS_DEMO` is defined.
|
||||
This has no pratical usage for the user - it is just a work-around for the NEORV32 CI environment.
|
||||
|
||||
Upload the executable (`neorv32_exe.bin`) to the processor via the bootloader and execute it.
|
||||
|
||||
```
|
||||
Awaiting neorv32_exe.bin... OK
|
||||
CMD:> e
|
||||
Booting...
|
||||
|
||||
FreeRTOS V10.4.1
|
||||
Blink
|
||||
Blink
|
||||
Blink
|
||||
```
|
||||
|
||||
## FreeRTOS Plus
|
||||
|
||||
To automatically add source and include files from FreeRTOS plus extensions add one (or more) of the following arguments when invoking `make`:
|
||||
|
||||
* FreeRTOS-Plus-CLI: `USER_FLAGS+=-FREERTOS_PLUS_CLI`
|
||||
* FreeRTOS-Plus-TCP: `USER_FLAGS+=-FREERTOS_PLUS_TCP`
|
||||
|
||||
Example:
|
||||
|
||||
$ make USER_FLAGS+=-DRUN_FREERTOS_DEMO USER_FLAGS+=-FREERTOS_PLUS_TCP clean_all exe
|
||||
|
||||
|
||||
## Notes
|
||||
|
||||
The onfiguration of the FreeRTOS home folder (via `FREERTOS_HOME`) is corrupted if the compiler shows the following error:
|
||||
|
||||
```
|
||||
main.c:36:10: fatal error: FreeRTOS.h: No such file or directory
|
||||
36 | #include <FreeRTOS.h>
|
||||
| ^~~~~~~~~~~~
|
||||
compilation terminated.
|
||||
make: *** [makefile:203: main.c.o] Error 1
|
||||
```
|
||||
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.1
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/*
|
||||
* The FreeRTOS kernel's RISC-V port is split between the the code that is
|
||||
* common across all currently supported RISC-V chips (implementations of the
|
||||
* RISC-V ISA), and code that tailors the port to a specific RISC-V chip:
|
||||
*
|
||||
* + FreeRTOS\Source\portable\GCC\RISC-V-RV32\portASM.S contains the code that
|
||||
* is common to all currently supported RISC-V chips. There is only one
|
||||
* portASM.S file because the same file is built for all RISC-V target chips.
|
||||
*
|
||||
* + Header files called freertos_risc_v_chip_specific_extensions.h contain the
|
||||
* code that tailors the FreeRTOS kernel's RISC-V port to a specific RISC-V
|
||||
* chip. There are multiple freertos_risc_v_chip_specific_extensions.h files
|
||||
* as there are multiple RISC-V chip implementations.
|
||||
*
|
||||
* !!!NOTE!!!
|
||||
* TAKE CARE TO INCLUDE THE CORRECT freertos_risc_v_chip_specific_extensions.h
|
||||
* HEADER FILE FOR THE CHIP IN USE. This is done using the assembler's (not the
|
||||
* compiler's!) include path. For example, if the chip in use includes a core
|
||||
* local interrupter (CLINT) and does not include any chip specific register
|
||||
* extensions then add the path below to the assembler's include path:
|
||||
* FreeRTOS\Source\portable\GCC\RISC-V-RV32\chip_specific_extensions\RV32I_CLINT_no_extensions
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* NEORV32 chip specific extensions
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __FREERTOS_RISC_V_EXTENSIONS_H__
|
||||
#define __FREERTOS_RISC_V_EXTENSIONS_H__
|
||||
|
||||
#define portasmHAS_SIFIVE_CLINT 0
|
||||
#define portasmHAS_MTIME 1
|
||||
#define portasmADDITIONAL_CONTEXT_SIZE 0 /* Must be even number on 32-bit cores. */
|
||||
|
||||
.macro portasmSAVE_ADDITIONAL_REGISTERS
|
||||
/* No additional registers to save, so this macro does nothing. */
|
||||
.endm
|
||||
|
||||
.macro portasmRESTORE_ADDITIONAL_REGISTERS
|
||||
/* No additional registers to restore, so this macro does nothing. */
|
||||
.endm
|
||||
|
||||
#endif /* __FREERTOS_RISC_V_EXTENSIONS_H__ */
|
266
Libs/RiscV/NEORV32/sw/example/demo_freeRTOS/full_demo/RegTest.s
Normal file
266
Libs/RiscV/NEORV32/sw/example/demo_freeRTOS/full_demo/RegTest.s
Normal file
@ -0,0 +1,266 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
.extern ulRegTest1LoopCounter
|
||||
.extern ulRegTest2LoopCounter
|
||||
|
||||
.global vRegTest1Implementation
|
||||
.global vRegTest2Implementation
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* The register check tasks are described in the comments at the top of
|
||||
* main_full.c.
|
||||
*/
|
||||
|
||||
.align( 4 )
|
||||
vRegTest1Implementation:
|
||||
|
||||
/* Fill the core registers with known values. */
|
||||
li x5, 0x5
|
||||
li x6, 0x6
|
||||
li x7, 0x7
|
||||
li x8, 0x8
|
||||
li x9, 0x9
|
||||
li x10, 0xa
|
||||
li x11, 0xb
|
||||
li x12, 0xc
|
||||
li x13, 0xd
|
||||
li x14, 0xe
|
||||
li x15, 0xf
|
||||
li x16, 0x10
|
||||
li x17, 0x11
|
||||
li x18, 0x12
|
||||
li x19, 0x13
|
||||
li x20, 0x14
|
||||
li x21, 0x15
|
||||
li x22, 0x16
|
||||
li x23, 0x17
|
||||
li x24, 0x18
|
||||
li x25, 0x19
|
||||
li x26, 0x1a
|
||||
li x27, 0x1b
|
||||
li x28, 0x1c
|
||||
li x29, 0x1d
|
||||
li x30, 0x1e
|
||||
|
||||
reg1_loop:
|
||||
|
||||
/* Check each register still contains the expected known value.
|
||||
vRegTest1Implementation uses x31 as the temporary, vRegTest2Implementation
|
||||
uses x5 as the temporary. */
|
||||
li x31, 0x5
|
||||
bne x31, x5, reg1_error_loop
|
||||
li x31, 0x6
|
||||
bne x31, x6, reg1_error_loop
|
||||
li x31, 0x7
|
||||
bne x31, x7, reg1_error_loop
|
||||
li x31, 0x8
|
||||
bne x31, x8, reg1_error_loop
|
||||
li x31, 0x9
|
||||
bne x31, x9, reg1_error_loop
|
||||
li x31, 0xa
|
||||
bne x31, x10, reg1_error_loop
|
||||
li x31, 0xb
|
||||
bne x31, x11, reg1_error_loop
|
||||
li x31, 0xc
|
||||
bne x31, x12, reg1_error_loop
|
||||
li x31, 0xd
|
||||
bne x31, x13, reg1_error_loop
|
||||
li x31, 0xe
|
||||
bne x31, x14, reg1_error_loop
|
||||
li x31, 0xf
|
||||
bne x31, x15, reg1_error_loop
|
||||
li x31, 0x10
|
||||
bne x31, x16, reg1_error_loop
|
||||
li x31, 0x11
|
||||
bne x31, x17, reg1_error_loop
|
||||
li x31, 0x12
|
||||
bne x31, x18, reg1_error_loop
|
||||
li x31, 0x13
|
||||
bne x31, x19, reg1_error_loop
|
||||
li x31, 0x14
|
||||
bne x31, x20, reg1_error_loop
|
||||
li x31, 0x15
|
||||
bne x31, x21, reg1_error_loop
|
||||
li x31, 0x16
|
||||
bne x31, x22, reg1_error_loop
|
||||
li x31, 0x17
|
||||
bne x31, x23, reg1_error_loop
|
||||
li x31, 0x18
|
||||
bne x31, x24, reg1_error_loop
|
||||
li x31, 0x19
|
||||
bne x31, x25, reg1_error_loop
|
||||
li x31, 0x1a
|
||||
bne x31, x26, reg1_error_loop
|
||||
li x31, 0x1b
|
||||
bne x31, x27, reg1_error_loop
|
||||
li x31, 0x1c
|
||||
bne x31, x28, reg1_error_loop
|
||||
li x31, 0x1d
|
||||
bne x31, x29, reg1_error_loop
|
||||
li x31, 0x1e
|
||||
bne x31, x30, reg1_error_loop
|
||||
|
||||
/* Everything passed, increment the loop counter. */
|
||||
lw x31, ulRegTest1LoopCounterConst
|
||||
lw x30, 0(x31)
|
||||
addi x30, x30, 1
|
||||
sw x30, 0(x31)
|
||||
|
||||
/* Restore clobbered register reading for next loop. */
|
||||
li x30, 0x1e
|
||||
|
||||
/* Yield to increase code coverage. */
|
||||
ecall
|
||||
|
||||
/* Start again. */
|
||||
jal reg1_loop
|
||||
|
||||
reg1_error_loop:
|
||||
/* Jump here if a register contains an uxpected value. This stops the loop
|
||||
counter being incremented so the check task knows an error was found. */
|
||||
ebreak
|
||||
jal reg1_error_loop
|
||||
|
||||
.align( 4 )
|
||||
ulRegTest1LoopCounterConst: .word ulRegTest1LoopCounter
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
.align( 4 )
|
||||
vRegTest2Implementation:
|
||||
|
||||
/* Fill the core registers with known values. */
|
||||
li x6, 0x61
|
||||
li x7, 0x71
|
||||
li x8, 0x81
|
||||
li x9, 0x91
|
||||
li x10, 0xa1
|
||||
li x11, 0xb1
|
||||
li x12, 0xc1
|
||||
li x13, 0xd1
|
||||
li x14, 0xe1
|
||||
li x15, 0xf1
|
||||
li x16, 0x20
|
||||
li x17, 0x21
|
||||
li x18, 0x22
|
||||
li x19, 0x23
|
||||
li x20, 0x24
|
||||
li x21, 0x25
|
||||
li x22, 0x26
|
||||
li x23, 0x27
|
||||
li x24, 0x28
|
||||
li x25, 0x29
|
||||
li x26, 0x2a
|
||||
li x27, 0x2b
|
||||
li x28, 0x2c
|
||||
li x29, 0x2d
|
||||
li x30, 0x2e
|
||||
li x31, 0x2f
|
||||
|
||||
Reg2_loop:
|
||||
|
||||
/* Check each register still contains the expected known value.
|
||||
vRegTest2Implementation uses x5 as the temporary, vRegTest1Implementation
|
||||
uses x31 as the temporary. */
|
||||
li x5, 0x61
|
||||
bne x5, x6, reg2_error_loop
|
||||
li x5, 0x71
|
||||
bne x5, x7, reg2_error_loop
|
||||
li x5, 0x81
|
||||
bne x5, x8, reg2_error_loop
|
||||
li x5, 0x91
|
||||
bne x5, x9, reg2_error_loop
|
||||
li x5, 0xa1
|
||||
bne x5, x10, reg2_error_loop
|
||||
li x5, 0xb1
|
||||
bne x5, x11, reg2_error_loop
|
||||
li x5, 0xc1
|
||||
bne x5, x12, reg2_error_loop
|
||||
li x5, 0xd1
|
||||
bne x5, x13, reg2_error_loop
|
||||
li x5, 0xe1
|
||||
bne x5, x14, reg2_error_loop
|
||||
li x5, 0xf1
|
||||
bne x5, x15, reg2_error_loop
|
||||
li x5, 0x20
|
||||
bne x5, x16, reg2_error_loop
|
||||
li x5, 0x21
|
||||
bne x5, x17, reg2_error_loop
|
||||
li x5, 0x22
|
||||
bne x5, x18, reg2_error_loop
|
||||
li x5, 0x23
|
||||
bne x5, x19, reg2_error_loop
|
||||
li x5, 0x24
|
||||
bne x5, x20, reg2_error_loop
|
||||
li x5, 0x25
|
||||
bne x5, x21, reg2_error_loop
|
||||
li x5, 0x26
|
||||
bne x5, x22, reg2_error_loop
|
||||
li x5, 0x27
|
||||
bne x5, x23, reg2_error_loop
|
||||
li x5, 0x28
|
||||
bne x5, x24, reg2_error_loop
|
||||
li x5, 0x29
|
||||
bne x5, x25, reg2_error_loop
|
||||
li x5, 0x2a
|
||||
bne x5, x26, reg2_error_loop
|
||||
li x5, 0x2b
|
||||
bne x5, x27, reg2_error_loop
|
||||
li x5, 0x2c
|
||||
bne x5, x28, reg2_error_loop
|
||||
li x5, 0x2d
|
||||
bne x5, x29, reg2_error_loop
|
||||
li x5, 0x2e
|
||||
bne x5, x30, reg2_error_loop
|
||||
li x5, 0x2f
|
||||
bne x5, x31, reg2_error_loop
|
||||
|
||||
/* Everything passed, increment the loop counter. */
|
||||
lw x5, ulRegTest2LoopCounterConst
|
||||
lw x6, 0(x5)
|
||||
addi x6, x6, 1
|
||||
sw x6, 0(x5)
|
||||
|
||||
/* Restore clobbered register reading for next loop. */
|
||||
li x6, 0x61
|
||||
|
||||
/* Start again. */
|
||||
jal Reg2_loop
|
||||
|
||||
reg2_error_loop:
|
||||
/* Jump here if a register contains an uxpected value. This stops the loop
|
||||
counter being incremented so the check task knows an error was found. */
|
||||
ebreak
|
||||
jal reg2_error_loop
|
||||
|
||||
.align( 4 )
|
||||
ulRegTest2LoopCounterConst: .word ulRegTest2LoopCounter
|
||||
|
||||
|
144
Libs/RiscV/NEORV32/sw/example/demo_freeRTOS/makefile
Normal file
144
Libs/RiscV/NEORV32/sw/example/demo_freeRTOS/makefile
Normal file
@ -0,0 +1,144 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
|
||||
# *****************************************************************************
|
||||
# USER CONFIGURATION
|
||||
# *****************************************************************************
|
||||
# User's application sources (*.c, *.cpp, *.s, *.S); add additional files here
|
||||
APP_SRC ?= $(wildcard ./*.c) $(wildcard ./*.s) $(wildcard ./*.cpp) $(wildcard ./*.S)
|
||||
|
||||
# User's application include folders (don't forget the '-I' before each entry)
|
||||
APP_INC ?= -I .
|
||||
# User's application include folders - for assembly files only (don't forget the '-I' before each entry)
|
||||
ASM_INC ?= -I .
|
||||
|
||||
# Optimization
|
||||
EFFORT ?= -Os
|
||||
|
||||
# Compiler toolchain
|
||||
RISCV_PREFIX ?= riscv32-unknown-elf-
|
||||
|
||||
# CPU architecture and ABI
|
||||
MARCH ?= rv32i
|
||||
MABI ?= ilp32
|
||||
|
||||
# User flags for additional configuration (will be added to compiler flags)
|
||||
USER_FLAGS ?=
|
||||
|
||||
# Relative or absolute path to the NEORV32 home folder
|
||||
NEORV32_HOME ?= ../../..
|
||||
# *****************************************************************************
|
||||
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# FreeRTOS
|
||||
# -----------------------------------------------------------------------------
|
||||
ifneq (,$(findstring RUN_FREERTOS_DEMO,$(USER_FLAGS)))
|
||||
# FreeRTOS home folder (adapt this!)
|
||||
FREERTOS_HOME ?= /mnt/n/Projects/FreeRTOSv10.4.1
|
||||
|
||||
# FreeRTOS RISC-V specific
|
||||
APP_SRC += $(wildcard $(FREERTOS_HOME)/FreeRTOS/Source/portable/GCC/RISC-V/*.c)
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS/Source/portable/GCC/RISC-V/portASM.S
|
||||
|
||||
APP_INC += -I $(FREERTOS_HOME)/FreeRTOS/Source/portable/GCC/RISC-V
|
||||
|
||||
# FreeRTOS core
|
||||
APP_SRC += $(wildcard $(FREERTOS_HOME)/FreeRTOS/Source/*.c)
|
||||
APP_SRC += $(wildcard $(FREERTOS_HOME)/FreeRTOS/Source/portable/MemMang/heap_4.c)
|
||||
|
||||
APP_INC += -I $(FREERTOS_HOME)/FreeRTOS/Source/include
|
||||
|
||||
# FreeRTOS sources for the full_demo
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS/Demo/Common/Minimal/blocktim.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS/Demo/Common/Minimal/dynamic.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS/Demo/Common/Minimal/GenQTest.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS/Demo/Common/Minimal/recmutex.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS/Demo/Common/Minimal/TaskNotify.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS/Demo/Common/Minimal/TaskNotifyArray.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS/Demo/Common/Minimal/TimerDemo.c
|
||||
|
||||
APP_INC += -I $(FREERTOS_HOME)/FreeRTOS/Demo/Common/include
|
||||
|
||||
# NEORV32 specific
|
||||
ASM_INC += -DportasmHANDLE_INTERRUPT=SystemIrqHandler
|
||||
|
||||
APP_INC += -I chip_specific_extensions/neorv32
|
||||
|
||||
ASM_INC += -I chip_specific_extensions/neorv32
|
||||
|
||||
# Demo application
|
||||
APP_SRC += blinky_demo/main_blinky.c
|
||||
APP_SRC += full_demo/main_full.c
|
||||
APP_SRC += full_demo/RegTest.s
|
||||
endif
|
||||
|
||||
# -----------------
|
||||
# FreeRTOS-Plus-CLI
|
||||
# -----------------
|
||||
ifneq (,$(findstring FREERTOS_PLUS_CLI,$(USER_FLAGS)))
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/FreeRTOS_CLI.c
|
||||
|
||||
APP_INC += -I $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI
|
||||
endif
|
||||
|
||||
# -----------------
|
||||
# FreeRTOS-Plus-TCP
|
||||
# -----------------
|
||||
ifneq (,$(findstring FREERTOS_PLUS_TCP,$(USER_FLAGS)))
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DHCP.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_DNS.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_IP.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Sockets.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Stream_Buffer.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_IP.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_WIN.c
|
||||
APP_SRC += $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_UDP_IP.c
|
||||
|
||||
APP_INC += -I $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include
|
||||
APP_INC += -I $(FREERTOS_HOME)/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/portable/Compiler/GCC
|
||||
endif
|
||||
|
||||
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/demo_gptmr/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/demo_gptmr/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/demo_neopixel/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/demo_neopixel/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/demo_pwm/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/demo_pwm/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/demo_slink/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/demo_slink/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/demo_spi/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/demo_spi/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/demo_trng/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/demo_trng/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/demo_twi/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/demo_twi/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/demo_wdt/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/demo_wdt/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/demo_xirq/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/demo_xirq/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
9
Libs/RiscV/NEORV32/sw/example/dhrystone/LICENSE
Normal file
9
Libs/RiscV/NEORV32/sw/example/dhrystone/LICENSE
Normal file
@ -0,0 +1,9 @@
|
||||
Original LICENSE from https://github.com/sifive/benchmark-dhrystone
|
||||
|
||||
Dhrystone
|
||||
------------------------------------------------------------------------------
|
||||
There is no explicit license defined. They were originally
|
||||
written in ADA by Reinhold P. Weicker and translated to C by Rick Richardson .
|
||||
|
||||
The source obtained from the following site:
|
||||
https://fossies.org/linux/privat/old/dhrystone-2.1.tar.gz
|
98
Libs/RiscV/NEORV32/sw/example/dhrystone/README.md
Normal file
98
Libs/RiscV/NEORV32/sw/example/dhrystone/README.md
Normal file
@ -0,0 +1,98 @@
|
||||
# Dhrystone Benchmark
|
||||
|
||||
:copyright: Original sources from [https://github.com/sifive/benchmark-dhrystone](https://github.com/sifive/benchmark-dhrystone) (also, see `LICENSE`).
|
||||
The source code has been modified for the NEORV32 processor.
|
||||
|
||||
To compile the NEORV32 executable:
|
||||
```
|
||||
neorv32/sw/example/dhrystone$ sh dhrystone.sh
|
||||
```
|
||||
|
||||
The default number of iterations is 2000000. You can modify this by changing `USER_FLAGS+=-DDHRY_ITERS=2000000` in `dhrystone.sh`.
|
||||
The default optimization level (EFFORT) is `O3`.
|
||||
|
||||
:warning: Dhrystone will require an IMEM size of 16kB and a DMEM size of 16kB. The MTIME machine timer is used for timing evaluation.
|
||||
|
||||
:construction: Porting Dhrystone is still work-in-progress. Performance results might be incorrect and not optimized.
|
||||
All results only show the integer parts.
|
||||
|
||||
### Exemplary Output
|
||||
|
||||
Output generated for processor HW version [v1.5.9.1](https://github.com/stnolting/neorv32/blob/master/CHANGELOG.md)
|
||||
using performance-optimized configuration options.
|
||||
|
||||
```
|
||||
NEORV32: Processor running at 100000000 Hz
|
||||
NEORV32: Executing Dhrystone (2000000 iterations). This may take some time...
|
||||
|
||||
|
||||
Dhrystone Benchmark, Version 2.1 (Language: C)
|
||||
|
||||
Program compiled without 'register' attribute
|
||||
|
||||
Execution starts, 2000000 runs through Dhrystone
|
||||
Execution ends
|
||||
|
||||
Final values of the variables used in the benchmark:
|
||||
|
||||
Int_Glob: 5
|
||||
should be: 5
|
||||
Bool_Glob: 1
|
||||
should be: 1
|
||||
Ch_1_Glob: A
|
||||
should be: A
|
||||
Ch_2_Glob: B
|
||||
should be: B
|
||||
Arr_1_Glob[8]: 7
|
||||
should be: 7
|
||||
Arr_2_Glob[8][7]: 2000010
|
||||
should be: Number_Of_Runs + 10
|
||||
Ptr_Glob->
|
||||
Ptr_Comp: -2147467428
|
||||
should be: (implementation-dependent)
|
||||
Discr: 0
|
||||
should be: 0
|
||||
Enum_Comp: 2
|
||||
should be: 2
|
||||
Int_Comp: 17
|
||||
should be: 17
|
||||
Str_Comp: DHRYSTONE PROGRAM, SOME STRING
|
||||
should be: DHRYSTONE PROGRAM, SOME STRING
|
||||
Next_Ptr_Glob->
|
||||
Ptr_Comp: -2147467428
|
||||
should be: (implementation-dependent), same as above
|
||||
Discr: 0
|
||||
should be: 0
|
||||
Enum_Comp: 1
|
||||
should be: 1
|
||||
Int_Comp: 18
|
||||
should be: 18
|
||||
Str_Comp: DHRYSTONE PROGRAM, SOME STRING
|
||||
should be: DHRYSTONE PROGRAM, SOME STRING
|
||||
Int_1_Loc: 5
|
||||
should be: 5
|
||||
Int_2_Loc: 13
|
||||
should be: 13
|
||||
Int_3_Loc: 7
|
||||
should be: 7
|
||||
Enum_Loc: 1
|
||||
should be: 1
|
||||
Str_1_Loc: DHRYSTONE PROGRAM, 1'ST STRING
|
||||
should be: DHRYSTONE PROGRAM, 1'ST STRING
|
||||
Str_2_Loc: DHRYSTONE PROGRAM, 2'ND STRING
|
||||
should be: DHRYSTONE PROGRAM, 2'ND STRING
|
||||
|
||||
Microseconds for one run through Dhrystone: 13
|
||||
Dhrystones per Second: 76923
|
||||
|
||||
NEORV32: << DETAILED RESULTS (integer parts only) >>
|
||||
NEORV32: Total cycles: 2662000187
|
||||
NEORV32: Cycles per second: 100000000
|
||||
NEORV32: Total runs: 2000000
|
||||
|
||||
NEORV32: DMIPS/s: 76923
|
||||
NEORV32: DMIPS/MHz: 769
|
||||
|
||||
NEORV32: VAX DMIPS/s: 43
|
||||
NEORV32: VAX DMIPS/MHz: 43/100
|
||||
```
|
451
Libs/RiscV/NEORV32/sw/example/dhrystone/dhry.h
Normal file
451
Libs/RiscV/NEORV32/sw/example/dhrystone/dhry.h
Normal file
@ -0,0 +1,451 @@
|
||||
/*
|
||||
****************************************************************************
|
||||
*
|
||||
* "DHRYSTONE" Benchmark Program
|
||||
* -----------------------------
|
||||
*
|
||||
* Version: C, Version 2.1
|
||||
*
|
||||
* File: dhry.h (part 1 of 3)
|
||||
*
|
||||
* Date: May 25, 1988
|
||||
*
|
||||
* Author: Reinhold P. Weicker
|
||||
* Siemens AG, E STE 35
|
||||
* Postfach 3240
|
||||
* 8520 Erlangen
|
||||
* Germany (West)
|
||||
* Phone: [xxx-49]-9131-7-20330
|
||||
* (8-17 Central European Time)
|
||||
* Usenet: ..!mcvax!unido!estevax!weicker
|
||||
*
|
||||
* Original Version (in Ada) published in
|
||||
* "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
|
||||
* pp. 1013 - 1030, together with the statistics
|
||||
* on which the distribution of statements etc. is based.
|
||||
*
|
||||
* In this C version, the following C library functions are used:
|
||||
* - strcpy, strcmp (inside the measurement loop)
|
||||
* - printf, scanf (outside the measurement loop)
|
||||
* In addition, Berkeley UNIX system calls "times ()" or "time ()"
|
||||
* are used for execution time measurement. For measurements
|
||||
* on other systems, these calls have to be changed.
|
||||
*
|
||||
* Collection of Results:
|
||||
* Reinhold Weicker (address see above) and
|
||||
*
|
||||
* Rick Richardson
|
||||
* PC Research. Inc.
|
||||
* 94 Apple Orchard Drive
|
||||
* Tinton Falls, NJ 07724
|
||||
* Phone: (201) 389-8963 (9-17 EST)
|
||||
* Usenet: ...!uunet!pcrat!rick
|
||||
*
|
||||
* Please send results to Rick Richardson and/or Reinhold Weicker.
|
||||
* Complete information should be given on hardware and software used.
|
||||
* Hardware information includes: Machine type, CPU, type and size
|
||||
* of caches; for microprocessors: clock frequency, memory speed
|
||||
* (number of wait states).
|
||||
* Software information includes: Compiler (and runtime library)
|
||||
* manufacturer and version, compilation switches, OS version.
|
||||
* The Operating System version may give an indication about the
|
||||
* compiler; Dhrystone itself performs no OS calls in the measurement loop.
|
||||
*
|
||||
* The complete output generated by the program should be mailed
|
||||
* such that at least some checks for correctness can be made.
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* History: This version C/2.1 has been made for two reasons:
|
||||
*
|
||||
* 1) There is an obvious need for a common C version of
|
||||
* Dhrystone, since C is at present the most popular system
|
||||
* programming language for the class of processors
|
||||
* (microcomputers, minicomputers) where Dhrystone is used most.
|
||||
* There should be, as far as possible, only one C version of
|
||||
* Dhrystone such that results can be compared without
|
||||
* restrictions. In the past, the C versions distributed
|
||||
* by Rick Richardson (Version 1.1) and by Reinhold Weicker
|
||||
* had small (though not significant) differences.
|
||||
*
|
||||
* 2) As far as it is possible without changes to the Dhrystone
|
||||
* statistics, optimizing compilers should be prevented from
|
||||
* removing significant statements.
|
||||
*
|
||||
* This C version has been developed in cooperation with
|
||||
* Rick Richardson (Tinton Falls, NJ), it incorporates many
|
||||
* ideas from the "Version 1.1" distributed previously by
|
||||
* him over the UNIX network Usenet.
|
||||
* I also thank Chaim Benedelac (National Semiconductor),
|
||||
* David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
|
||||
* Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
|
||||
* for their help with comments on earlier versions of the
|
||||
* benchmark.
|
||||
*
|
||||
* Changes: In the initialization part, this version follows mostly
|
||||
* Rick Richardson's version distributed via Usenet, not the
|
||||
* version distributed earlier via floppy disk by Reinhold Weicker.
|
||||
* As a concession to older compilers, names have been made
|
||||
* unique within the first 8 characters.
|
||||
* Inside the measurement loop, this version follows the
|
||||
* version previously distributed by Reinhold Weicker.
|
||||
*
|
||||
* At several places in the benchmark, code has been added,
|
||||
* but within the measurement loop only in branches that
|
||||
* are not executed. The intention is that optimizing compilers
|
||||
* should be prevented from moving code out of the measurement
|
||||
* loop, or from removing code altogether. Since the statements
|
||||
* that are executed within the measurement loop have NOT been
|
||||
* changed, the numbers defining the "Dhrystone distribution"
|
||||
* (distribution of statements, operand types and locality)
|
||||
* still hold. Except for sophisticated optimizing compilers,
|
||||
* execution times for this version should be the same as
|
||||
* for previous versions.
|
||||
*
|
||||
* Since it has proven difficult to subtract the time for the
|
||||
* measurement loop overhead in a correct way, the loop check
|
||||
* has been made a part of the benchmark. This does have
|
||||
* an impact - though a very minor one - on the distribution
|
||||
* statistics which have been updated for this version.
|
||||
*
|
||||
* All changes within the measurement loop are described
|
||||
* and discussed in the companion paper "Rationale for
|
||||
* Dhrystone version 2".
|
||||
*
|
||||
* Because of the self-imposed limitation that the order and
|
||||
* distribution of the executed statements should not be
|
||||
* changed, there are still cases where optimizing compilers
|
||||
* may not generate code for some statements. To a certain
|
||||
* degree, this is unavoidable for small synthetic benchmarks.
|
||||
* Users of the benchmark are advised to check code listings
|
||||
* whether code is generated for all statements of Dhrystone.
|
||||
*
|
||||
* Version 2.1 is identical to version 2.0 distributed via
|
||||
* the UNIX network Usenet in March 1988 except that it corrects
|
||||
* some minor deficiencies that were found by users of version 2.0.
|
||||
* The only change within the measurement loop is that a
|
||||
* non-executed "else" part was added to the "if" statement in
|
||||
* Func_3, and a non-executed "else" part removed from Proc_3.
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Defines: The following "Defines" are possible:
|
||||
* -DREG=register (default: Not defined)
|
||||
* As an approximation to what an average C programmer
|
||||
* might do, the "register" storage class is applied
|
||||
* (if enabled by -DREG=register)
|
||||
* - for local variables, if they are used (dynamically)
|
||||
* five or more times
|
||||
* - for parameters if they are used (dynamically)
|
||||
* six or more times
|
||||
* Note that an optimal "register" strategy is
|
||||
* compiler-dependent, and that "register" declarations
|
||||
* do not necessarily lead to faster execution.
|
||||
* -DNOSTRUCTASSIGN (default: Not defined)
|
||||
* Define if the C compiler does not support
|
||||
* assignment of structures.
|
||||
* -DNOENUMS (default: Not defined)
|
||||
* Define if the C compiler does not support
|
||||
* enumeration types.
|
||||
* -DTIMES (default)
|
||||
* -DTIME
|
||||
* The "times" function of UNIX (returning process times)
|
||||
* or the "time" function (returning wallclock time)
|
||||
* is used for measurement.
|
||||
* For single user machines, "time ()" is adequate. For
|
||||
* multi-user machines where you cannot get single-user
|
||||
* access, use the "times ()" function. If you have
|
||||
* neither, use a stopwatch in the dead of night.
|
||||
* "printf"s are provided marking the points "Start Timer"
|
||||
* and "Stop Timer". DO NOT use the UNIX "time(1)"
|
||||
* command, as this will measure the total time to
|
||||
* run this program, which will (erroneously) include
|
||||
* the time to allocate storage (malloc) and to perform
|
||||
* the initialization.
|
||||
* -DHZ=nnn
|
||||
* In Berkeley UNIX, the function "times" returns process
|
||||
* time in 1/HZ seconds, with HZ = 60 for most systems.
|
||||
* CHECK YOUR SYSTEM DESCRIPTION BEFORE YOU JUST APPLY
|
||||
* A VALUE.
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Compilation model and measurement (IMPORTANT):
|
||||
*
|
||||
* This C version of Dhrystone consists of three files:
|
||||
* - dhry.h (this file, containing global definitions and comments)
|
||||
* - dhry_1.c (containing the code corresponding to Ada package Pack_1)
|
||||
* - dhry_2.c (containing the code corresponding to Ada package Pack_2)
|
||||
*
|
||||
* The following "ground rules" apply for measurements:
|
||||
* - Separate compilation
|
||||
* - No procedure merging
|
||||
* - Otherwise, compiler optimizations are allowed but should be indicated
|
||||
* - Default results are those without register declarations
|
||||
* See the companion paper "Rationale for Dhrystone Version 2" for a more
|
||||
* detailed discussion of these ground rules.
|
||||
*
|
||||
* For 16-Bit processors (e.g. 80186, 80286), times for all compilation
|
||||
* models ("small", "medium", "large" etc.) should be given if possible,
|
||||
* together with a definition of these models for the compiler system used.
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
* Dhrystone (C version) statistics:
|
||||
*
|
||||
* [Comment from the first distribution, updated for version 2.
|
||||
* Note that because of language differences, the numbers are slightly
|
||||
* different from the Ada version.]
|
||||
*
|
||||
* The following program contains statements of a high level programming
|
||||
* language (here: C) in a distribution considered representative:
|
||||
*
|
||||
* assignments 52 (51.0 %)
|
||||
* control statements 33 (32.4 %)
|
||||
* procedure, function calls 17 (16.7 %)
|
||||
*
|
||||
* 103 statements are dynamically executed. The program is balanced with
|
||||
* respect to the three aspects:
|
||||
*
|
||||
* - statement type
|
||||
* - operand type
|
||||
* - operand locality
|
||||
* operand global, local, parameter, or constant.
|
||||
*
|
||||
* The combination of these three aspects is balanced only approximately.
|
||||
*
|
||||
* 1. Statement Type:
|
||||
* ----------------- number
|
||||
*
|
||||
* V1 = V2 9
|
||||
* (incl. V1 = F(..)
|
||||
* V = Constant 12
|
||||
* Assignment, 7
|
||||
* with array element
|
||||
* Assignment, 6
|
||||
* with record component
|
||||
* --
|
||||
* 34 34
|
||||
*
|
||||
* X = Y +|-|"&&"|"|" Z 5
|
||||
* X = Y +|-|"==" Constant 6
|
||||
* X = X +|- 1 3
|
||||
* X = Y *|/ Z 2
|
||||
* X = Expression, 1
|
||||
* two operators
|
||||
* X = Expression, 1
|
||||
* three operators
|
||||
* --
|
||||
* 18 18
|
||||
*
|
||||
* if .... 14
|
||||
* with "else" 7
|
||||
* without "else" 7
|
||||
* executed 3
|
||||
* not executed 4
|
||||
* for ... 7 | counted every time
|
||||
* while ... 4 | the loop condition
|
||||
* do ... while 1 | is evaluated
|
||||
* switch ... 1
|
||||
* break 1
|
||||
* declaration with 1
|
||||
* initialization
|
||||
* --
|
||||
* 34 34
|
||||
*
|
||||
* P (...) procedure call 11
|
||||
* user procedure 10
|
||||
* library procedure 1
|
||||
* X = F (...)
|
||||
* function call 6
|
||||
* user function 5
|
||||
* library function 1
|
||||
* --
|
||||
* 17 17
|
||||
* ---
|
||||
* 103
|
||||
*
|
||||
* The average number of parameters in procedure or function calls
|
||||
* is 1.82 (not counting the function values aX *
|
||||
*
|
||||
* 2. Operators
|
||||
* ------------
|
||||
* number approximate
|
||||
* percentage
|
||||
*
|
||||
* Arithmetic 32 50.8
|
||||
*
|
||||
* + 21 33.3
|
||||
* - 7 11.1
|
||||
* * 3 4.8
|
||||
* / (int div) 1 1.6
|
||||
*
|
||||
* Comparison 27 42.8
|
||||
*
|
||||
* == 9 14.3
|
||||
* /= 4 6.3
|
||||
* > 1 1.6
|
||||
* < 3 4.8
|
||||
* >= 1 1.6
|
||||
* <= 9 14.3
|
||||
*
|
||||
* Logic 4 6.3
|
||||
*
|
||||
* && (AND-THEN) 1 1.6
|
||||
* | (OR) 1 1.6
|
||||
* ! (NOT) 2 3.2
|
||||
*
|
||||
* -- -----
|
||||
* 63 100.1
|
||||
*
|
||||
*
|
||||
* 3. Operand Type (counted once per operand reference):
|
||||
* ---------------
|
||||
* number approximate
|
||||
* percentage
|
||||
*
|
||||
* Integer 175 72.3 %
|
||||
* Character 45 18.6 %
|
||||
* Pointer 12 5.0 %
|
||||
* String30 6 2.5 %
|
||||
* Array 2 0.8 %
|
||||
* Record 2 0.8 %
|
||||
* --- -------
|
||||
* 242 100.0 %
|
||||
*
|
||||
* When there is an access path leading to the final operand (e.g. a record
|
||||
* component), only the final data type on the access path is counted.
|
||||
*
|
||||
*
|
||||
* 4. Operand Locality:
|
||||
* -------------------
|
||||
* number approximate
|
||||
* percentage
|
||||
*
|
||||
* local variable 114 47.1 %
|
||||
* global variable 22 9.1 %
|
||||
* parameter 45 18.6 %
|
||||
* value 23 9.5 %
|
||||
* reference 22 9.1 %
|
||||
* function result 6 2.5 %
|
||||
* constant 55 22.7 %
|
||||
* --- -------
|
||||
* 242 100.0 %
|
||||
*
|
||||
*
|
||||
* The program does not compute anything meaningful, but it is syntactically
|
||||
* and semantically correct. All variables have a value assigned to them
|
||||
* before they are used as a source operand.
|
||||
*
|
||||
* There has been no explicit effort to account for the effects of a
|
||||
* cache, or to balance the use of long or short displacements for code or
|
||||
* data.
|
||||
*
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef dhrystone_h
|
||||
#define dhrystone_h
|
||||
|
||||
/* Compiler and system dependent definitions: */
|
||||
|
||||
#ifndef TIME
|
||||
#undef TIMES
|
||||
#define TIMES
|
||||
#endif
|
||||
/* Use times(2) time function unless */
|
||||
/* explicitly defined otherwise */
|
||||
|
||||
//#ifdef MSC_CLOCK
|
||||
//#undef HZ
|
||||
//#undef TIMES
|
||||
//#include <time.h>
|
||||
//#define HZ CLK_TCK
|
||||
//#endif
|
||||
// /* Use Microsoft C hi-res clock */
|
||||
|
||||
#define HZ SYSINFO_CLK
|
||||
|
||||
#ifdef TIMES
|
||||
#include <sys/types.h>
|
||||
#include <sys/times.h>
|
||||
/* for "times" */
|
||||
#endif
|
||||
|
||||
#define Mic_secs_Per_Second 1000000
|
||||
/* Berkeley UNIX C returns process times in seconds/HZ */
|
||||
|
||||
#ifdef NOSTRUCTASSIGN
|
||||
#define structassign(d, s) memcpy(&(d), &(s), sizeof(d))
|
||||
#else
|
||||
#define structassign(d, s) d = s
|
||||
#endif
|
||||
|
||||
#ifdef NOENUM
|
||||
#define Ident_1 0
|
||||
#define Ident_2 1
|
||||
#define Ident_3 2
|
||||
#define Ident_4 3
|
||||
#define Ident_5 4
|
||||
typedef int Enumeration;
|
||||
#else
|
||||
typedef enum {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
|
||||
Enumeration;
|
||||
#endif
|
||||
/* for boolean and enumeration types in Ada, Pascal */
|
||||
|
||||
/* General definitions: */
|
||||
|
||||
#include <stdio.h>
|
||||
/* for strcpy, strcmp */
|
||||
|
||||
#define Null 0
|
||||
/* Value of a Null pointer */
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
typedef int One_Thirty;
|
||||
typedef int One_Fifty;
|
||||
typedef char Capital_Letter;
|
||||
typedef int Boolean;
|
||||
typedef char Str_30 [31];
|
||||
typedef int Arr_1_Dim [50];
|
||||
typedef int Arr_2_Dim [50] [50];
|
||||
|
||||
typedef struct record
|
||||
{
|
||||
struct record *Ptr_Comp;
|
||||
Enumeration Discr;
|
||||
union {
|
||||
struct {
|
||||
Enumeration Enum_Comp;
|
||||
int Int_Comp;
|
||||
char Str_Comp [31];
|
||||
} var_1;
|
||||
struct {
|
||||
Enumeration E_Comp_2;
|
||||
char Str_2_Comp [31];
|
||||
} var_2;
|
||||
struct {
|
||||
char Ch_1_Comp;
|
||||
char Ch_2_Comp;
|
||||
} var_3;
|
||||
} variant;
|
||||
} Rec_Type, *Rec_Pointer;
|
||||
|
||||
|
||||
// function prototypes
|
||||
Enumeration Func_1 (Ch_1_Par_Val, Ch_2_Par_Val);
|
||||
Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref);
|
||||
Boolean Func_3 (Enum_Par_Val);
|
||||
void Proc_1 (Ptr_Val_Par);
|
||||
void Proc_2 (Int_Par_Ref);
|
||||
void Proc_3 (Ptr_Ref_Par);
|
||||
void Proc_4 (void);
|
||||
void Proc_5 (void);
|
||||
void Proc_6 (Enum_Val_Par, Enum_Ref_Par);
|
||||
void Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref);
|
||||
void Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val);
|
||||
int strcmp(const char *p1, const char *p2);
|
||||
|
||||
#endif // dhrystone_h
|
1
Libs/RiscV/NEORV32/sw/example/dhrystone/dhrystone.sh
Normal file
1
Libs/RiscV/NEORV32/sw/example/dhrystone/dhrystone.sh
Normal file
@ -0,0 +1 @@
|
||||
make USER_FLAGS+=-DRUN_DHRYSTONE USER_FLAGS+=-DDHRY_ITERS=2000000 USER_FLAGS+=-DNOENUM MARCH=rv32imc EFFORT=-O3 clean_all exe
|
40
Libs/RiscV/NEORV32/sw/example/dhrystone/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/dhrystone/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
52
Libs/RiscV/NEORV32/sw/example/floating_point_test/README.md
Normal file
52
Libs/RiscV/NEORV32/sw/example/floating_point_test/README.md
Normal file
@ -0,0 +1,52 @@
|
||||
# NEORV32 `Zfinx` Floating-Point Extension
|
||||
|
||||
The NEORV32 floating-point unit (FPU) implements the `Zfinx` RISC-V extension. The extensions can be enabled via the `CPU_EXTENSION_RISCV_Zfinx` top configuration generic.
|
||||
|
||||
The RISC-V `Zfinx` single-precision floating-point extensions uses the integer register file `x` instead of the dedicated floating-point `f` register file (which is
|
||||
defined by the RISC-V `F` single-precision floating-point extension). Hence, the standard data transfer instructions from the `F` extension are **not** available in `Zfinx`:
|
||||
|
||||
* floating-point load/store operations (`FLW`, `FSW`) and their compressed versions
|
||||
* integer register file `x` <-> floating point register file `f` move operations (`FMV.W.X`, `FMV.X.W`)
|
||||
|
||||
:information_source: More information regarding the RISC-V `Zfinx` single-precision floating-point extension can be found in the official GitHub repo:
|
||||
[`github.com/riscv/riscv-zfinx`](https://github.com/riscv/riscv-zfinx).
|
||||
|
||||
:warning: The RISC-V `Zfinx` extension is not officially ratified yet, but it is assumed to remain unchanged. Hence, it is not supported by the upstream RISC-V GCC port.
|
||||
Make sure you **do not** use the `f` ISA attribute when compiling applications that use floating-point arithmetic (`MARCH=rv32i*f*` is **NOT ALLOWED!**).
|
||||
|
||||
|
||||
### :warning: FPU Limitations
|
||||
|
||||
* The FPU **does not support subnormal numbers** yet. Subnormal FPU inputs and subnormal FPU results are always *flushed to zero*. The *classify* instruction `FCLASS` will never set the "subnormal" mask bits.
|
||||
* Rounding mode `ob100` "round to nearest, ties to max magnitude" is not supported yet (this and all invalid rounding mode configurations behave as "round towards zero" (truncation)).
|
||||
|
||||
|
||||
## Intrinsic Library
|
||||
|
||||
The NEORV32 `Zfinx` floating-point extension can still be used using the provided **intrinsic library**. This library uses "custom" inline assmbly instructions
|
||||
wrapped within normal C-language functions. Each original instruction of the extension can be utilized using an according intrinsic function.
|
||||
|
||||
For example, the floating-point addition instruction `FADD.S` can be invoked using the according intrinsic function:
|
||||
|
||||
```c
|
||||
float riscv_intrinsic_fadds(float rs1, float rs2)
|
||||
```
|
||||
|
||||
The pure-software emulation instruction, which uses the standard built-in functions to execute all floating-point operations, is available via wrapper function. The
|
||||
emulation function for the `FADD.S` instruction is:
|
||||
|
||||
```c
|
||||
float riscv_emulate_fadds(float rs1, float rs2)
|
||||
```
|
||||
|
||||
The emulation functions as well as the available intrinsics for the `Zfinx` extension are located in `neorv32_zfinx_extension_intrinsics.h`.
|
||||
|
||||
The provided test program `main.c` verifies all currently implemented `Zfinx` instructions by checking the functionality against the pure software-based emulation model
|
||||
(GCC soft-float library).
|
||||
|
||||
|
||||
## Resources
|
||||
|
||||
* Great page with online calculators for floating-point arithmetic: [http://www.ecs.umass.edu/ece/koren/arith/simulator/](http://www.ecs.umass.edu/ece/koren/arith/simulator/)
|
||||
* A handy tool for visualizing floating-point numbers in their binary representation: [https://www.h-schmidt.net/FloatConverter/IEEE754.html](https://www.h-schmidt.net/FloatConverter/IEEE754.html)
|
||||
* This helped me to understand what results the different FPU operation generate when having "special" inputs like NaN: [https://techdocs.altium.com/display/FPGA/IEEE+754+Standard+-+Overview](https://techdocs.altium.com/display/FPGA/IEEE+754+Standard+-+Overview)
|
40
Libs/RiscV/NEORV32/sw/example/floating_point_test/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/floating_point_test/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
File diff suppressed because it is too large
Load Diff
40
Libs/RiscV/NEORV32/sw/example/game_of_life/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/game_of_life/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
40
Libs/RiscV/NEORV32/sw/example/hello_world/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/hello_world/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
71
Libs/RiscV/NEORV32/sw/example/makefile
Normal file
71
Libs/RiscV/NEORV32/sw/example/makefile
Normal file
@ -0,0 +1,71 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - All-Projects Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the riscv GCC compiler's bin folder to your PATH variable. #
|
||||
# ********************************************************************************************* #
|
||||
# BSD 3-Clause License #
|
||||
# #
|
||||
# Copyright (c) 2020, 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Make defaults and targets
|
||||
#-------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
TOPTARGETS := exe clean_all check info all
|
||||
|
||||
SUBDIRS := $(wildcard */.)
|
||||
# ignore dummy folders (starting with '~')
|
||||
DUMMYDIRS := $(wildcard ~*/.)
|
||||
SUBDIRS := $(filter-out $(DUMMYDIRS), $(SUBDIRS))
|
||||
|
||||
$(TOPTARGETS): $(SUBDIRS)
|
||||
$(SUBDIRS):
|
||||
@set -e
|
||||
@$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||
|
||||
.PHONY: $(TOPTARGETS) $(SUBDIRS)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Help
|
||||
#-------------------------------------------------------------------------------
|
||||
help:
|
||||
@echo "Build / clean up all projects"
|
||||
@echo "Targets:"
|
||||
@echo " help - show this text"
|
||||
@echo " check - check toolchain"
|
||||
@echo " info - show makefile configuration"
|
||||
@echo " exe - create executables from all projects"
|
||||
@echo " all - create executables and boot images from all projects"
|
||||
@echo " clean_all - clean up everything"
|
||||
|
40
Libs/RiscV/NEORV32/sw/example/processor_check/makefile
Normal file
40
Libs/RiscV/NEORV32/sw/example/processor_check/makefile
Normal file
@ -0,0 +1,40 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
|
||||
NEORV32_HOME ?= ../../..
|
||||
|
||||
include $(NEORV32_HOME)/sw/common/common.mk
|
58
Libs/RiscV/NEORV32/sw/image_gen/uart_upload.sh
Normal file
58
Libs/RiscV/NEORV32/sw/image_gen/uart_upload.sh
Normal file
@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# Simple script to upload executable to bootloader
|
||||
|
||||
if [ $# -ne 2 ]
|
||||
then
|
||||
echo "Upload image via serial port (UART) to the NEORV32 bootloader."
|
||||
echo "Reset processor before starting the upload."
|
||||
echo "Usage: [sudo] sh uart_upload.sh <port> <NEORV32 executable>"
|
||||
echo "Example: sh uart_upload.sh /dev/ttyS6 neorv32_exe.bin"
|
||||
exit
|
||||
fi
|
||||
|
||||
# configure serial port
|
||||
stty -F "$1" 19200 -hup raw -echo -echoe -echok -echoctl -echoke -crtscts cs8 -cstopb noflsh clocal cread
|
||||
|
||||
# trigger fast upload mode and get response
|
||||
exec 3<$1 # redirect serial output to fd 3
|
||||
cat <&3 > uart_upload.response.dat & # redirect serial output to file
|
||||
PID=$! # save pid to kill cat
|
||||
printf "u" > $1 # send upload command to serial port
|
||||
sleep 0.5s # wait for bootloader response
|
||||
kill $PID # kill cat process
|
||||
|
||||
exec 3<&- # free fd 3
|
||||
|
||||
# check response
|
||||
if ! grep -Fq "Awaiting neorv32_exe.bin" uart_upload.response.dat;
|
||||
then
|
||||
echo "Bootloader response error."
|
||||
echo "Reset processor before starting the upload."
|
||||
rm -f uart_upload.response.dat
|
||||
exit
|
||||
fi
|
||||
|
||||
# send executable and get repsonse
|
||||
echo -n "Uploading... "
|
||||
exec 3<$1 # redirect serial output to fd 3
|
||||
cat <&3 > uart_upload.response.dat & # redirect serial output to file
|
||||
PID=$! # save pid to kill cat
|
||||
cat "$2" > "$1" # send executable to serial port
|
||||
sleep 3s # wait for bootloader response
|
||||
kill $PID # kill cat process
|
||||
|
||||
exec 3<&- # free fd 3
|
||||
|
||||
# check response
|
||||
if ! grep -Fq "OK" uart_upload.response.dat;
|
||||
then
|
||||
echo "Upload error."
|
||||
rm -f uart_upload.response.dat
|
||||
exit
|
||||
fi
|
||||
|
||||
rm -f uart_upload.response.dat
|
||||
echo "Done."
|
74
Libs/RiscV/NEORV32/sw/isa-test/common.mk
Normal file
74
Libs/RiscV/NEORV32/sw/isa-test/common.mk
Normal file
@ -0,0 +1,74 @@
|
||||
ifndef NEORV32_ROOT
|
||||
$(error NEORV32_ROOT is undefined)
|
||||
endif
|
||||
|
||||
NEORV32_LOCAL_RTL ?= $(NEORV32_ROOT)/sim/work
|
||||
|
||||
TARGET_SIM ?= ghdl
|
||||
TARGET_FLAGS ?= $(RISCV_TARGET_FLAGS)
|
||||
|
||||
ifeq ($(shell command -v $(TARGET_SIM) 2> /dev/null),)
|
||||
$(error Target simulator executable '$(TARGET_SIM)` not found)
|
||||
endif
|
||||
|
||||
NEORV32_MARCH ?= rv32i
|
||||
NEORV32_MABI ?= ilp32
|
||||
|
||||
RISCV_PREFIX ?= riscv32-unknown-elf-
|
||||
RISCV_GCC ?= $(RISCV_PREFIX)gcc
|
||||
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump
|
||||
RISCV_OBJCOPY ?= $(RISCV_PREFIX)objcopy
|
||||
RISCV_READELF ?= $(RISCV_PREFIX)readelf
|
||||
RISCV_GCC_OPTS ?= -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -march=$(NEORV32_MARCH) -mabi=$(NEORV32_MABI)
|
||||
|
||||
NEORV32_LINK ?= link.imem_rom.ld
|
||||
|
||||
COMPILE_TARGET ?= \
|
||||
$$(RISCV_GCC) $(1) $$(RISCV_GCC_OPTS) \
|
||||
$$(RISCV_TARGET_FLAGS) \
|
||||
-I$(ROOTDIR)/riscv-test-suite/env/ \
|
||||
-I$(TARGETDIR)/$(RISCV_TARGET)/ \
|
||||
-T$(TARGETDIR)/$(RISCV_TARGET)/$(NEORV32_LINK) \
|
||||
$$(<) -o $$@
|
||||
|
||||
NEORV32_CPU_EXTENSION_RISCV_C ?= false
|
||||
NEORV32_CPU_EXTENSION_RISCV_E ?= false
|
||||
NEORV32_CPU_EXTENSION_RISCV_M ?= false
|
||||
NEORV32_CPU_EXTENSION_RISCV_ZIFENCEI ?= false
|
||||
NEORV32_MEM_INT_IMEM_SIZE ?= '2097152'
|
||||
|
||||
NEORV32_SOFTWARE_EXAMPLE ?= $(NEORV32_ROOT)/sw/example/blink_led
|
||||
|
||||
ifeq ($(NEORV32_CPU_EXTENSION_RISCV_ZIFENCEI), true)
|
||||
RUN_TARGET ?= \
|
||||
echo "copying/using SIM-only IMEM (pre-initialized RAM!)"; \
|
||||
rm -f $(NEORV32_LOCAL_RTL)/core/mem/neorv32_imem.default.vhd; \
|
||||
cp -f $(NEORV32_ROOT)/sim/simple/neorv32_imem.iram.simple.vhd $(NEORV32_LOCAL_RTL)/core/mem/neorv32_imem.default.vhd;
|
||||
else
|
||||
RUN_TARGET ?= \
|
||||
echo "copying/using SIM-only IMEM (pre-initialized ROM!)"; \
|
||||
rm -f $(NEORV32_LOCAL_RTL)/core/mem/neorv32_imem.default.vhd; \
|
||||
cp -f $(NEORV32_ROOT)/sim/simple/neorv32_imem.simple.vhd $(NEORV32_LOCAL_RTL)/core/mem/neorv32_imem.default.vhd;
|
||||
endif
|
||||
|
||||
RUN_TARGET += \
|
||||
cd $(work_dir_isa); \
|
||||
echo ">"; \
|
||||
rm -f $(NEORV32_ROOT)/sim/*.out; \
|
||||
make -C $(NEORV32_SOFTWARE_EXAMPLE) main.elf; \
|
||||
cp -f $< $(NEORV32_SOFTWARE_EXAMPLE)/main.elf; \
|
||||
make -C $(NEORV32_SOFTWARE_EXAMPLE) main.bin install; \
|
||||
touch $(NEORV32_ROOT)/sim/simple/neorv32.uart0.sim_mode.data.out; \
|
||||
GHDL_DEVNULL=true $(shell which time) -v $(NEORV32_ROOT)/sim/simple/ghdl.run.sh \
|
||||
--stop-time=$(SIM_TIME) \
|
||||
-gCPU_EXTENSION_RISCV_A=false \
|
||||
-gCPU_EXTENSION_RISCV_C=$(NEORV32_CPU_EXTENSION_RISCV_C) \
|
||||
-gCPU_EXTENSION_RISCV_E=$(NEORV32_CPU_EXTENSION_RISCV_E) \
|
||||
-gCPU_EXTENSION_RISCV_M=$(NEORV32_CPU_EXTENSION_RISCV_M) \
|
||||
-gCPU_EXTENSION_RISCV_U=false \
|
||||
-gCPU_EXTENSION_RISCV_Zicsr=true \
|
||||
-gCPU_EXTENSION_RISCV_Zifencei=true \
|
||||
-gEXT_IMEM_C=false \
|
||||
-gMEM_INT_IMEM_SIZE=$(NEORV32_MEM_INT_IMEM_SIZE); \
|
||||
cp $(NEORV32_ROOT)/sim/simple/neorv32.uart0.sim_mode.data.out $(*).signature.output; \
|
||||
echo "<";
|
28
Libs/RiscV/NEORV32/sw/isa-test/port-neorv32/README.md
Normal file
28
Libs/RiscV/NEORV32/sw/isa-test/port-neorv32/README.md
Normal file
@ -0,0 +1,28 @@
|
||||
# NEORV32 Port for running the RISC-V Architecture Tests
|
||||
|
||||
|
||||
The following tasks are executed by the device makefiles:
|
||||
|
||||
* replace the original processor's IMEM rtl file by a simulation-optimized IMEM (ROM!)
|
||||
* `sed` command is used to modify the default testbench (`neorv32/sim/neorv32_tb.simple.vhd`):
|
||||
* enable/disable the required `CPU_EXTENSION_RISCV_xxx` VHDL configuration generics in the testbench (`neorv32/sim/neorv32_tb.simple.vhd`)
|
||||
* set the processor memory configuration
|
||||
* compile test code and install application image to processor's `rtl/core` folder
|
||||
* compilation uses the `link.imem_rom.ld` linker script as default; code (the test code) is executed from simulation-optimized IMEM (which is read-only); data including signature is stored to DMEM
|
||||
* certain areas in the DMEM are initialized using port code in `model_test.h` (`RVTEST` = 0xbabecafe and `SIGNATURE` = 0xdeadbeef); can be disabled using `RISCV_TARGET_FLAGS=-DNEORV32_NO_DATA_INIT`
|
||||
* the processor is simulated using the default testbench
|
||||
* the results are dumped via the SIM_MODE feature of UART0
|
||||
* the according code can be found in the `RVMODEL_HALT` macro in `model_test.h`
|
||||
* data output (the "signature") is zero-padded to be always a multiple of 16 bytes
|
||||
|
||||
|
||||
**Notes**
|
||||
|
||||
:warning: The `Zifencei` test requires the r/w/e capabilities of the original IMEM rtl file.
|
||||
Hence, the original file is restored for this test. Also, this test uses `link.imem_ram.ld` as linker script since the
|
||||
IMEM is used as RAM to allow self-modifying code.
|
||||
|
||||
:information_source: The `RVMODEL_BOOT` macro in `model_test.h` provides a simple "dummy trap handler" that just advances
|
||||
to the next instruction. This trap handler is required for some `C` tests as the NEORV32 will raise an illegal instruction
|
||||
exception for **all** unimplemented instructions. The trap handler can be overriden (by changing `mtval` CSR) if a test
|
||||
uses the defualt trap handler of the test framework.
|
@ -0,0 +1,6 @@
|
||||
NEORV32_MARCH ?= rv32ec
|
||||
NEORV32_MABI ?= ilp32e
|
||||
NEORV32_CPU_EXTENSION_RISCV_C ?= true
|
||||
NEORV32_CPU_EXTENSION_RISCV_E ?= true
|
||||
|
||||
include $(NEORV32_ROOT)/sw/isa-test/common.mk
|
@ -0,0 +1,5 @@
|
||||
NEORV32_MARCH ?= rv32e
|
||||
NEORV32_MABI ?= ilp32e
|
||||
NEORV32_CPU_EXTENSION_RISCV_E ?= true
|
||||
|
||||
include $(NEORV32_ROOT)/sw/isa-test/common.mk
|
@ -0,0 +1,6 @@
|
||||
NEORV32_MARCH ?= rv32em
|
||||
NEORV32_MABI ?= ilp32e
|
||||
NEORV32_CPU_EXTENSION_RISCV_E ?= true
|
||||
NEORV32_CPU_EXTENSION_RISCV_M ?= true
|
||||
|
||||
include $(NEORV32_ROOT)/sw/isa-test/common.mk
|
@ -0,0 +1,4 @@
|
||||
NEORV32_MARCH ?= rv32ic
|
||||
NEORV32_CPU_EXTENSION_RISCV_C ?= true
|
||||
|
||||
include $(NEORV32_ROOT)/sw/isa-test/common.mk
|
@ -0,0 +1 @@
|
||||
include $(NEORV32_ROOT)/sw/isa-test/common.mk
|
@ -0,0 +1,4 @@
|
||||
NEORV32_MARCH ?= rv32im
|
||||
NEORV32_CPU_EXTENSION_RISCV_M ?= true
|
||||
|
||||
include $(NEORV32_ROOT)/sw/isa-test/common.mk
|
@ -0,0 +1,6 @@
|
||||
NEORV32_MARCH ?= rv32im
|
||||
NEORV32_LINK ?= link.imem_ram.ld
|
||||
NEORV32_MEM_INT_IMEM_SIZE ?= '16384'
|
||||
NEORV32_CPU_EXTENSION_RISCV_ZIFENCEI ?= true
|
||||
|
||||
include $(NEORV32_ROOT)/sw/isa-test/common.mk
|
@ -0,0 +1,3 @@
|
||||
NEORV32_CPU_EXTENSION_RISCV_C ?= true
|
||||
|
||||
include $(NEORV32_ROOT)/sw/isa-test/common.mk
|
22
Libs/RiscV/NEORV32/sw/isa-test/port-neorv32/link.imem_ram.ld
Normal file
22
Libs/RiscV/NEORV32/sw/isa-test/port-neorv32/link.imem_ram.ld
Normal file
@ -0,0 +1,22 @@
|
||||
OUTPUT_ARCH( "riscv" )
|
||||
ENTRY(rvtest_entry_point)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x00000000;
|
||||
.text :
|
||||
{
|
||||
*(.text.init)
|
||||
. = ALIGN(0x1000);
|
||||
*(.text)
|
||||
. = ALIGN(0x1000);
|
||||
*(.tohost)
|
||||
*(.data)
|
||||
*(.data.string)
|
||||
*(.bss)
|
||||
. = ALIGN(0x1000);
|
||||
|
||||
_end = .;
|
||||
}
|
||||
}
|
||||
|
26
Libs/RiscV/NEORV32/sw/isa-test/port-neorv32/link.imem_rom.ld
Normal file
26
Libs/RiscV/NEORV32/sw/isa-test/port-neorv32/link.imem_rom.ld
Normal file
@ -0,0 +1,26 @@
|
||||
OUTPUT_ARCH( "riscv" )
|
||||
ENTRY(rvtest_entry_point)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x00000000;
|
||||
.text :
|
||||
{
|
||||
*(.text.init)
|
||||
. = ALIGN(0x1000);
|
||||
*(.text)
|
||||
. = ALIGN(0x1000);
|
||||
_end = .;
|
||||
}
|
||||
|
||||
. = 0x80000000;
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(0x1000);
|
||||
*(.tohost)
|
||||
*(.data)
|
||||
*(.data.string)
|
||||
*(.bss)
|
||||
}
|
||||
}
|
||||
|
212
Libs/RiscV/NEORV32/sw/isa-test/port-neorv32/model_test.h
Normal file
212
Libs/RiscV/NEORV32/sw/isa-test/port-neorv32/model_test.h
Normal file
@ -0,0 +1,212 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Modified by Stephan Nolting for the NEORV32 Processor
|
||||
|
||||
#ifndef _COMPLIANCE_MODEL_H
|
||||
#define _COMPLIANCE_MODEL_H
|
||||
|
||||
#define RVMODEL_DATA_SECTION \
|
||||
.pushsection .tohost,"aw",@progbits; \
|
||||
.align 8; .global tohost; tohost: .dword 0; \
|
||||
.align 8; .global fromhost; fromhost: .dword 0; \
|
||||
.popsection; \
|
||||
.align 8; .global begin_regstate; begin_regstate: \
|
||||
.word 128; \
|
||||
.align 8; .global end_regstate; end_regstate: \
|
||||
.word 4;
|
||||
|
||||
//RV_COMPLIANCE_HALT
|
||||
// neorv32: this will dump the results via the UART0_SIM_MODE data file output
|
||||
// neorv32: due to the modifications on "end_signature" (not 4-aligned) we need to make sure we output a 4-aligned number of data here
|
||||
// neorv32: -> for zero-padding of the rest of the SIGNATURE section
|
||||
#define RVMODEL_HALT \
|
||||
signature_dump: \
|
||||
la a0, begin_signature; \
|
||||
la a1, end_signature; \
|
||||
li a2, 0xFFFFFFA4; \
|
||||
signature_dump_loop: \
|
||||
beq a0, a1, signature_dump_padding; \
|
||||
lw t0, 0(a0); \
|
||||
sw t0, 0(a2); \
|
||||
addi a0, a0, 4; \
|
||||
j signature_dump_loop; \
|
||||
nop; \
|
||||
nop; \
|
||||
signature_dump_padding: \
|
||||
andi a0, a1, 0x0000000C; \
|
||||
beq a0, zero, signature_dump_end; \
|
||||
li t0, 16; \
|
||||
sub a0, t0, a0; \
|
||||
signature_dump_padding_loop: \
|
||||
beq a0, zero, signature_dump_end; \
|
||||
sw zero, 0(a2); \
|
||||
addi a0, a0, -4; \
|
||||
j signature_dump_padding_loop; \
|
||||
signature_dump_end: \
|
||||
j signature_dump_end
|
||||
|
||||
//TODO: declare the start of your signature region here. Nothing else to be used here.
|
||||
// The .align 4 ensures that the signature ends at a 16-byte boundary
|
||||
#define RVMODEL_DATA_BEGIN \
|
||||
.align 4; .global begin_signature; begin_signature:
|
||||
|
||||
//TODO: declare the end of the signature region here. Add other target specific contents here.
|
||||
//neorv32: DO NOT use align_4 here! end_signature is used to indicate the actual "number" of signature words
|
||||
#define RVMODEL_DATA_END \
|
||||
.global end_signature; end_signature: \
|
||||
RVMODEL_DATA_SECTION
|
||||
|
||||
//RVMODEL_BOOT
|
||||
// neorv32: enable UART0 (ctrl(28)) and enable UART0_SIM_MODE (ctrl(12))
|
||||
// neorv32: initialize the complete RVTEST_DATA section in data RAM (DMEM) with 0xBABECAFE
|
||||
// neorv32: initialize the complete SIGNATURE section (that is a multiple of four 32-bit entries) in data RAM (DMEM) with 0xDEADBEEF
|
||||
// neorv32: this code also provides a dummy trap handler that just moves on to the next instruction
|
||||
// neorv32: -> this trap handler can be overridden by the compliance-suite by modifying mtval
|
||||
// neorv32: -> the dummy trap handler is required to deal with the neorv32 X extension (-> all illegal/undefined instruction trigger an exception)
|
||||
#ifdef NEORV32_NO_DATA_INIT
|
||||
// ------------------------- WITHOUT DATA INIT -------------------------
|
||||
#define RVMODEL_BOOT \
|
||||
core_init: \
|
||||
la x1, core_dummy_trap_handler; \
|
||||
csrw mtvec, x1; \
|
||||
csrw mie, x0; \
|
||||
j uart0_sim_mode_init; \
|
||||
nop; \
|
||||
nop; \
|
||||
.balign 4; \
|
||||
core_dummy_trap_handler: \
|
||||
csrw mscratch, sp; \
|
||||
la sp, end_signature; \
|
||||
addi sp, sp, 32; \
|
||||
sw x8, 0(sp); \
|
||||
sw x9, 4(sp); \
|
||||
csrr x8, mcause; \
|
||||
blt x8, zero, core_dummy_trap_handler_irq; \
|
||||
csrr x8, mepc; \
|
||||
core_dummy_trap_handler_exc_c_check: \
|
||||
lh x9, 0(x8); \
|
||||
andi x9, x9, 3; \
|
||||
addi x8, x8, +2; \
|
||||
csrw mepc, x8; \
|
||||
addi x8, zero, 3; \
|
||||
bne x8, x9, core_dummy_trap_handler_irq; \
|
||||
core_dummy_trap_handler_exc_uncrompressed: \
|
||||
csrr x8, mepc; \
|
||||
addi x8, x8, +2; \
|
||||
csrw mepc, x8; \
|
||||
core_dummy_trap_handler_irq: \
|
||||
lw x9, 0(sp); \
|
||||
lw x8, 4(sp); \
|
||||
csrr sp, mscratch; \
|
||||
mret; \
|
||||
nop; \
|
||||
nop; \
|
||||
uart0_sim_mode_init: \
|
||||
li a0, 0xFFFFFFA0; \
|
||||
sw zero, 0(a0); \
|
||||
li a1, 1 << 28; \
|
||||
li a2, 1 << 12; \
|
||||
or a1, a1, a2; \
|
||||
sw a1, 0(a0);
|
||||
|
||||
#else
|
||||
|
||||
// ------------------------- WITH DATA INIT -------------------------
|
||||
#define RVMODEL_BOOT \
|
||||
core_init: \
|
||||
la x1, core_dummy_trap_handler; \
|
||||
csrw mtvec, x1; \
|
||||
csrw mie, x0; \
|
||||
nop; \
|
||||
nop; \
|
||||
init_rvtest_data: \
|
||||
la a0, rvtest_data_begin; \
|
||||
la a1, rvtest_data_end; \
|
||||
li a2, 0xBABECAFE; \
|
||||
init_rvtest_data_loop: \
|
||||
beq a0, a1, init_rvtest_data_loop_end; \
|
||||
sw a2, 0(a0); \
|
||||
addi a0, a0, 4; \
|
||||
j init_rvtest_data_loop; \
|
||||
init_rvtest_data_loop_end: \
|
||||
nop; \
|
||||
nop; \
|
||||
init_signature: \
|
||||
la a0, begin_signature; \
|
||||
la a1, end_signature; \
|
||||
li a2, 0xDEADBEEF; \
|
||||
init_signature_loop: \
|
||||
beq a0, a1, init_signature_loop_end; \
|
||||
sw a2, 0(a0); \
|
||||
addi a0, a0, 4; \
|
||||
j init_signature_loop; \
|
||||
init_signature_loop_end: \
|
||||
j uart0_sim_mode_init; \
|
||||
nop; \
|
||||
nop; \
|
||||
.balign 4; \
|
||||
core_dummy_trap_handler: \
|
||||
csrw mscratch, sp; \
|
||||
la sp, end_signature; \
|
||||
addi sp, sp, 32; \
|
||||
sw x8, 0(sp); \
|
||||
sw x9, 4(sp); \
|
||||
csrr x8, mcause; \
|
||||
blt x8, zero, core_dummy_trap_handler_irq; \
|
||||
csrr x8, mepc; \
|
||||
core_dummy_trap_handler_exc_c_check: \
|
||||
lh x9, 0(x8); \
|
||||
andi x9, x9, 3; \
|
||||
addi x8, x8, +2; \
|
||||
csrw mepc, x8; \
|
||||
addi x8, zero, 3; \
|
||||
bne x8, x9, core_dummy_trap_handler_irq; \
|
||||
core_dummy_trap_handler_exc_uncrompressed: \
|
||||
csrr x8, mepc; \
|
||||
addi x8, x8, +2; \
|
||||
csrw mepc, x8; \
|
||||
core_dummy_trap_handler_irq: \
|
||||
lw x9, 0(sp); \
|
||||
lw x8, 4(sp); \
|
||||
csrr sp, mscratch; \
|
||||
mret; \
|
||||
nop; \
|
||||
nop; \
|
||||
uart0_sim_mode_init: \
|
||||
li a0, 0xFFFFFFA0; \
|
||||
sw zero, 0(a0); \
|
||||
li a1, 1 << 28; \
|
||||
li a2, 1 << 12; \
|
||||
or a1, a1, a2; \
|
||||
sw a1, 0(a0);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//RVTEST_IO_INIT
|
||||
#define RVMODEL_IO_INIT
|
||||
//RVTEST_IO_WRITE_STR
|
||||
#define RVMODEL_IO_WRITE_STR(_R, _STR)
|
||||
//RVTEST_IO_CHECK
|
||||
#define RVMODEL_IO_CHECK()
|
||||
|
||||
//RVTEST_IO_ASSERT_GPR_EQ
|
||||
#define RVMODEL_IO_ASSERT_GPR_EQ(_S, _R, _I)
|
||||
//RVTEST_IO_ASSERT_SFPR_EQ
|
||||
#define RVMODEL_IO_ASSERT_SFPR_EQ(_F, _R, _I)
|
||||
//RVTEST_IO_ASSERT_DFPR_EQ
|
||||
#define RVMODEL_IO_ASSERT_DFPR_EQ(_D, _R, _I)
|
||||
|
||||
// TODO: specify the routine for setting machine software interrupt
|
||||
#define RVMODEL_SET_MSW_INT
|
||||
|
||||
// TODO: specify the routine for clearing machine software interrupt
|
||||
#define RVMODEL_CLEAR_MSW_INT
|
||||
|
||||
// TODO: specify the routine for clearing machine timer interrupt
|
||||
#define RVMODEL_CLEAR_MTIMER_INT
|
||||
|
||||
// TODO: specify the routine for clearing machine external interrupt
|
||||
#define RVMODEL_CLEAR_MEXT_INT
|
||||
|
||||
#endif // _COMPLIANCE_MODEL_H
|
6
Libs/RiscV/NEORV32/sw/lib/README.md
Normal file
6
Libs/RiscV/NEORV32/sw/lib/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
## NEORV32 Core Library
|
||||
|
||||
This folder provides the hardware abstraction layer (HAL) libraries for the CPU itself and the individual processor modules (peripheral/IO devices).
|
||||
|
||||
The `source` folder contains the actual C-code hardware driver functions (*.c*) while the `include` folder provides the according header files (*.h).
|
||||
Application programs should only include the *main NEORV32 define file* `include/neorv32.h`. This file automatically includes all other provided header files.
|
1311
Libs/RiscV/NEORV32/sw/lib/include/neorv32.h
Normal file
1311
Libs/RiscV/NEORV32/sw/lib/include/neorv32.h
Normal file
File diff suppressed because it is too large
Load Diff
53
Libs/RiscV/NEORV32/sw/lib/include/neorv32_cfs.h
Normal file
53
Libs/RiscV/NEORV32/sw/lib/include/neorv32_cfs.h
Normal file
@ -0,0 +1,53 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_cfs.h - Custom Functions Subsystem (CFS)) HW Driver (stub) >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_cfs.h
|
||||
* @author Stephan Nolting
|
||||
* @brief Custom Functions Subsystem (CFS)) HW driver header file.
|
||||
*
|
||||
* @warning There are no "real" CFS driver functions available here, because these functions are defined by the actual hardware.
|
||||
* @warning Hence, the CFS designer has to provide the actual driver functions.
|
||||
*
|
||||
* @note These functions should only be used if the CFS was synthesized (IO_CFS_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_cfs_h
|
||||
#define neorv32_cfs_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_cfs_available(void);
|
||||
|
||||
#endif // neorv32_cfs_h
|
306
Libs/RiscV/NEORV32/sw/lib/include/neorv32_cpu.h
Normal file
306
Libs/RiscV/NEORV32/sw/lib/include/neorv32_cpu.h
Normal file
@ -0,0 +1,306 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_cpu.h - CPU Core Functions HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_cpu.h
|
||||
* @author Stephan Nolting
|
||||
* @brief CPU Core Functions HW driver header file.
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_cpu_h
|
||||
#define neorv32_cpu_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_cpu_irq_enable(uint8_t irq_sel);
|
||||
int neorv32_cpu_irq_disable(uint8_t irq_sel);
|
||||
uint64_t neorv32_cpu_get_cycle(void);
|
||||
void neorv32_cpu_set_mcycle(uint64_t value);
|
||||
uint64_t neorv32_cpu_get_instret(void);
|
||||
void neorv32_cpu_set_minstret(uint64_t value);
|
||||
uint64_t neorv32_cpu_get_systime(void);
|
||||
void neorv32_cpu_delay_ms(uint32_t time_ms);
|
||||
void __attribute__((naked)) neorv32_cpu_goto_user_mode(void);
|
||||
uint32_t neorv32_cpu_pmp_get_num_regions(void);
|
||||
uint32_t neorv32_cpu_pmp_get_granularity(void);
|
||||
int neorv32_cpu_pmp_configure_region(uint32_t index, uint32_t base, uint32_t size, uint8_t config);
|
||||
uint32_t neorv32_cpu_hpm_get_counters(void);
|
||||
uint32_t neorv32_cpu_hpm_get_size(void);
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Prototype for "after-main handler". This function is called if main() returns.
|
||||
*
|
||||
* @param[in] return_code Return value of main() function.
|
||||
* @return Return value is irrelevant (there is no one left to check for it...).
|
||||
**************************************************************************/
|
||||
extern int __neorv32_crt0_after_main(int32_t return_code) __attribute__ ((weak));
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Store unsigned word to address space if atomic access reservation is still valid.
|
||||
*
|
||||
* @note An unaligned access address will raise an alignment exception.
|
||||
*
|
||||
* @param[in] addr Address (32-bit).
|
||||
* @param[in] wdata Data word (32-bit) to store.
|
||||
* @return Operation status (32-bit, zero if success).
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) neorv32_cpu_store_conditional(uint32_t addr, uint32_t wdata) {
|
||||
|
||||
#if defined __riscv_atomic || defined __riscv_a
|
||||
register uint32_t reg_addr = addr;
|
||||
register uint32_t reg_data = wdata;
|
||||
register uint32_t reg_status;
|
||||
|
||||
asm volatile ("sc.w %[status], %[da], (%[ad])" : [status] "=r" (reg_status) : [da] "r" (reg_data), [ad] "r" (reg_addr));
|
||||
|
||||
return reg_status;
|
||||
#else
|
||||
return 1; // always failing
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Conditional store unsigned word to address space.
|
||||
*
|
||||
* @note An unaligned access address will raise an alignment exception.
|
||||
*
|
||||
* @param[in] addr Address (32-bit).
|
||||
* @param[in] wdata Data word (32-bit) to store.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_cpu_store_unsigned_word(uint32_t addr, uint32_t wdata) {
|
||||
|
||||
register uint32_t reg_addr = addr;
|
||||
register uint32_t reg_data = wdata;
|
||||
|
||||
asm volatile ("sw %[da], 0(%[ad])" : : [da] "r" (reg_data), [ad] "r" (reg_addr));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Store unsigned half-word to address space.
|
||||
*
|
||||
* @note An unaligned access address will raise an alignment exception.
|
||||
*
|
||||
* @param[in] addr Address (32-bit).
|
||||
* @param[in] wdata Data half-word (16-bit) to store.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_cpu_store_unsigned_half(uint32_t addr, uint16_t wdata) {
|
||||
|
||||
register uint32_t reg_addr = addr;
|
||||
register uint32_t reg_data = (uint32_t)wdata;
|
||||
|
||||
asm volatile ("sh %[da], 0(%[ad])" : : [da] "r" (reg_data), [ad] "r" (reg_addr));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Store unsigned byte to address space.
|
||||
*
|
||||
* @param[in] addr Address (32-bit).
|
||||
* @param[in] wdata Data byte (8-bit) to store.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_cpu_store_unsigned_byte(uint32_t addr, uint8_t wdata) {
|
||||
|
||||
register uint32_t reg_addr = addr;
|
||||
register uint32_t reg_data = (uint32_t)wdata;
|
||||
|
||||
asm volatile ("sb %[da], 0(%[ad])" : : [da] "r" (reg_data), [ad] "r" (reg_addr));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Load unsigned word from address space and make reservation for atomic access.
|
||||
*
|
||||
* @note An unaligned access address will raise an alignment exception.
|
||||
*
|
||||
* @param[in] addr Address (32-bit).
|
||||
* @return Read data word (32-bit).
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) neorv32_cpu_load_reservate_word(uint32_t addr) {
|
||||
|
||||
register uint32_t reg_addr = addr;
|
||||
register uint32_t reg_data;
|
||||
|
||||
#if defined __riscv_atomic || defined __riscv_a
|
||||
asm volatile ("lr.w %[da], 0(%[ad])" : [da] "=r" (reg_data) : [ad] "r" (reg_addr));
|
||||
#else
|
||||
asm volatile ("lw %[da], 0(%[ad])" : [da] "=r" (reg_data) : [ad] "r" (reg_addr));
|
||||
#endif
|
||||
|
||||
return (uint32_t)reg_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Load unsigned word from address space.
|
||||
*
|
||||
* @note An unaligned access address will raise an alignment exception.
|
||||
*
|
||||
* @param[in] addr Address (32-bit).
|
||||
* @return Read data word (32-bit).
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) neorv32_cpu_load_unsigned_word(uint32_t addr) {
|
||||
|
||||
register uint32_t reg_addr = addr;
|
||||
register uint32_t reg_data;
|
||||
|
||||
asm volatile ("lw %[da], 0(%[ad])" : [da] "=r" (reg_data) : [ad] "r" (reg_addr));
|
||||
|
||||
return (uint32_t)reg_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Load unsigned half-word from address space.
|
||||
*
|
||||
* @note An unaligned access address will raise an alignment exception.
|
||||
*
|
||||
* @param[in] addr Address (32-bit).
|
||||
* @return Read data half-word (16-bit).
|
||||
**************************************************************************/
|
||||
inline uint16_t __attribute__ ((always_inline)) neorv32_cpu_load_unsigned_half(uint32_t addr) {
|
||||
|
||||
register uint32_t reg_addr = addr;
|
||||
register uint32_t reg_data;
|
||||
|
||||
asm volatile ("lhu %[da], 0(%[ad])" : [da] "=r" (reg_data) : [ad] "r" (reg_addr));
|
||||
|
||||
return (uint16_t)reg_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Load unsigned byte from address space.
|
||||
*
|
||||
* @param[in] addr Address (32-bit).
|
||||
* @return Read data byte (8-bit).
|
||||
**************************************************************************/
|
||||
inline uint8_t __attribute__ ((always_inline)) neorv32_cpu_load_unsigned_byte(uint32_t addr) {
|
||||
|
||||
register uint32_t reg_addr = addr;
|
||||
register uint32_t reg_data;
|
||||
|
||||
asm volatile ("lbu %[da], 0(%[ad])" : [da] "=r" (reg_data) : [ad] "r" (reg_addr));
|
||||
|
||||
return (uint8_t)reg_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Read data from CPU configuration and status register (CSR).
|
||||
*
|
||||
* @param[in] csr_id ID of CSR to read. See #NEORV32_CSR_enum.
|
||||
* @return Read data (uint32_t).
|
||||
**************************************************************************/
|
||||
inline uint32_t __attribute__ ((always_inline)) neorv32_cpu_csr_read(const int csr_id) {
|
||||
|
||||
register uint32_t csr_data;
|
||||
|
||||
asm volatile ("csrr %[result], %[input_i]" : [result] "=r" (csr_data) : [input_i] "i" (csr_id));
|
||||
|
||||
return csr_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Write data to CPU configuration and status register (CSR).
|
||||
*
|
||||
* @param[in] csr_id ID of CSR to write. See #NEORV32_CSR_enum.
|
||||
* @param[in] data Data to write (uint32_t).
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_cpu_csr_write(const int csr_id, uint32_t data) {
|
||||
|
||||
register uint32_t csr_data = data;
|
||||
|
||||
asm volatile ("csrw %[input_i], %[input_j]" : : [input_i] "i" (csr_id), [input_j] "r" (csr_data));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Put CPU into "sleep" mode.
|
||||
*
|
||||
* @note This function executes the WFI instruction.
|
||||
* The WFI (wait for interrupt) instruction will make the CPU stall until
|
||||
* an interrupt request is detected. Interrupts have to be globally enabled
|
||||
* and at least one external source must be enabled (like the MTI machine
|
||||
* timer interrupt) to allow the CPU to wake up again. If 'Zicsr' CPU extension is disabled,
|
||||
* this will permanently stall the CPU.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_cpu_sleep(void) {
|
||||
|
||||
asm volatile ("wfi");
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Enable global CPU interrupts (via MIE flag in mstatus CSR).
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_cpu_eint(void) {
|
||||
|
||||
asm volatile ("csrrsi zero, mstatus, %0" : : "i" (1 << CSR_MSTATUS_MIE));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Disable global CPU interrupts (via MIE flag in mstatus CSR).
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_cpu_dint(void) {
|
||||
|
||||
asm volatile ("csrrci zero, mstatus, %0" : : "i" (1 << CSR_MSTATUS_MIE));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Trigger breakpoint exception (via EBREAK instruction).
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_cpu_breakpoint(void) {
|
||||
|
||||
asm volatile ("ebreak");
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Trigger "environment call" exception (via ECALL instruction).
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_cpu_env_call(void) {
|
||||
|
||||
asm volatile ("ecall");
|
||||
}
|
||||
|
||||
|
||||
#endif // neorv32_cpu_h
|
57
Libs/RiscV/NEORV32/sw/lib/include/neorv32_gpio.h
Normal file
57
Libs/RiscV/NEORV32/sw/lib/include/neorv32_gpio.h
Normal file
@ -0,0 +1,57 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_gpio.h - General Purpose Input/Output Port HW Driver (Header) >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_gpio.h
|
||||
* @author Stephan Nolting
|
||||
* @brief General purpose input/output port unit (GPIO) HW driver header file.
|
||||
*
|
||||
* @note These functions should only be used if the GPIO unit was synthesized (IO_GPIO_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_gpio_h
|
||||
#define neorv32_gpio_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_gpio_available(void);
|
||||
void neorv32_gpio_pin_set(int pin);
|
||||
void neorv32_gpio_pin_clr(int pin);
|
||||
void neorv32_gpio_pin_toggle(int pin);
|
||||
uint32_t neorv32_gpio_pin_get(int pin);
|
||||
|
||||
void neorv32_gpio_port_set(uint64_t d);
|
||||
uint64_t neorv32_gpio_port_get(void);
|
||||
|
||||
#endif // neorv32_gpio_h
|
54
Libs/RiscV/NEORV32/sw/lib/include/neorv32_gptmr.h
Normal file
54
Libs/RiscV/NEORV32/sw/lib/include/neorv32_gptmr.h
Normal file
@ -0,0 +1,54 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_gptmr.h - General Purpose Timer (GPTMR) HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_gptmr.h
|
||||
* @author Stephan Nolting
|
||||
* @brief General purpose timer (GPTMR) HW driver header file.
|
||||
*
|
||||
* @note These functions should only be used if the GPTMR unit was synthesized (IO_GPTMR_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_gptmr_h
|
||||
#define neorv32_gptmr_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_gptmr_available(void);
|
||||
void neorv32_gptmr_setup(uint8_t prsc, uint8_t mode, uint32_t threshold);
|
||||
void neorv32_gptmr_disable(void);
|
||||
void neorv32_gptmr_enable(void);
|
||||
void neorv32_gptmr_restart(void);
|
||||
|
||||
#endif // neorv32_gptmr_h
|
166
Libs/RiscV/NEORV32/sw/lib/include/neorv32_intrinsics.h
Normal file
166
Libs/RiscV/NEORV32/sw/lib/include/neorv32_intrinsics.h
Normal file
@ -0,0 +1,166 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_intrinsics.h - Helper functions/macros for (custom) "intrinsics" >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_intrinsics.h
|
||||
* @author Stephan Nolting
|
||||
* @brief Helper functions and macros for custom "intrinsics" / instructions.
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_intrinsics_h
|
||||
#define neorv32_intrinsics_h
|
||||
|
||||
/**********************************************************************//**
|
||||
* @name Custom instructions / intrinsics helper macros
|
||||
**************************************************************************/
|
||||
/**@{*/
|
||||
|
||||
//** Selection helper macro */
|
||||
#define STR1(x) #x
|
||||
//** Selection helper macro 2 */
|
||||
#define STR(x) STR1(x)
|
||||
|
||||
//** Register address converter */
|
||||
#define GET_REG_ADDR(x) REG_ADDR_##x
|
||||
|
||||
#define REG_ADDR_x0 0 /**< register 0 */
|
||||
#define REG_ADDR_x1 1 /**< register 1 */
|
||||
#define REG_ADDR_x2 2 /**< register 2 */
|
||||
#define REG_ADDR_x3 3 /**< register 3 */
|
||||
#define REG_ADDR_x4 4 /**< register 4 */
|
||||
#define REG_ADDR_x5 5 /**< register 5 */
|
||||
#define REG_ADDR_x6 6 /**< register 6 */
|
||||
#define REG_ADDR_x7 7 /**< register 7 */
|
||||
#define REG_ADDR_x8 8 /**< register 8 */
|
||||
#define REG_ADDR_x9 9 /**< register 9 */
|
||||
#define REG_ADDR_x10 10 /**< register 10 */
|
||||
#define REG_ADDR_x11 11 /**< register 11 */
|
||||
#define REG_ADDR_x12 12 /**< register 12 */
|
||||
#define REG_ADDR_x13 13 /**< register 13 */
|
||||
#define REG_ADDR_x14 14 /**< register 14 */
|
||||
#define REG_ADDR_x15 15 /**< register 15 */
|
||||
#define REG_ADDR_x16 16 /**< register 16 */
|
||||
#define REG_ADDR_x17 17 /**< register 17 */
|
||||
#define REG_ADDR_x18 18 /**< register 18 */
|
||||
#define REG_ADDR_x19 19 /**< register 19 */
|
||||
#define REG_ADDR_x20 20 /**< register 20 */
|
||||
#define REG_ADDR_x21 21 /**< register 21 */
|
||||
#define REG_ADDR_x22 22 /**< register 22 */
|
||||
#define REG_ADDR_x23 23 /**< register 23 */
|
||||
#define REG_ADDR_x24 24 /**< register 24 */
|
||||
#define REG_ADDR_x25 25 /**< register 25 */
|
||||
#define REG_ADDR_x26 26 /**< register 26 */
|
||||
#define REG_ADDR_x27 27 /**< register 27 */
|
||||
#define REG_ADDR_x28 28 /**< register 28 */
|
||||
#define REG_ADDR_x29 29 /**< register 29 */
|
||||
#define REG_ADDR_x30 30 /**< register 30 */
|
||||
#define REG_ADDR_x31 31 /**< register 31 */
|
||||
#define REG_ADDR_zero 0 /**< register 0 - according to calling convention */
|
||||
#define REG_ADDR_ra 1 /**< register 1 - according to calling convention */
|
||||
#define REG_ADDR_sp 2 /**< register 2 - according to calling convention */
|
||||
#define REG_ADDR_gp 3 /**< register 3 - according to calling convention */
|
||||
#define REG_ADDR_tp 4 /**< register 4 - according to calling convention */
|
||||
#define REG_ADDR_t0 5 /**< register 5 - according to calling convention */
|
||||
#define REG_ADDR_t1 6 /**< register 6 - according to calling convention */
|
||||
#define REG_ADDR_t2 7 /**< register 7 - according to calling convention */
|
||||
#define REG_ADDR_s0 8 /**< register 8 - according to calling convention */
|
||||
#define REG_ADDR_s1 9 /**< register 9 - according to calling convention */
|
||||
#define REG_ADDR_a0 10 /**< register 10 - according to calling convention */
|
||||
#define REG_ADDR_a1 11 /**< register 11 - according to calling convention */
|
||||
#define REG_ADDR_a2 12 /**< register 12 - according to calling convention */
|
||||
#define REG_ADDR_a3 13 /**< register 13 - according to calling convention */
|
||||
#define REG_ADDR_a4 14 /**< register 14 - according to calling convention */
|
||||
#define REG_ADDR_a5 15 /**< register 15 - according to calling convention */
|
||||
#define REG_ADDR_a6 16 /**< register 16 - according to calling convention */
|
||||
#define REG_ADDR_a7 17 /**< register 17 - according to calling convention */
|
||||
#define REG_ADDR_s2 18 /**< register 18 - according to calling convention */
|
||||
#define REG_ADDR_s3 19 /**< register 19 - according to calling convention */
|
||||
#define REG_ADDR_s4 20 /**< register 20 - according to calling convention */
|
||||
#define REG_ADDR_s5 21 /**< register 21 - according to calling convention */
|
||||
#define REG_ADDR_s6 22 /**< register 22 - according to calling convention */
|
||||
#define REG_ADDR_s7 23 /**< register 23 - according to calling convention */
|
||||
#define REG_ADDR_s8 24 /**< register 24 - according to calling convention */
|
||||
#define REG_ADDR_s9 25 /**< register 25 - according to calling convention */
|
||||
#define REG_ADDR_s10 26 /**< register 26 - according to calling convention */
|
||||
#define REG_ADDR_s11 27 /**< register 27 - according to calling convention */
|
||||
#define REG_ADDR_t3 28 /**< register 28 - according to calling convention */
|
||||
#define REG_ADDR_t4 29 /**< register 29 - according to calling convention */
|
||||
#define REG_ADDR_t5 30 /**< register 30 - according to calling convention */
|
||||
#define REG_ADDR_t6 31 /**< register 31 - according to calling convention */
|
||||
|
||||
//** Construct instruction word (32-bit) for R2-type instruction */
|
||||
#define CMD_WORD_R2_TYPE(funct7, rs2, rs1, funct3, rd, opcode) \
|
||||
( (opcode & 0x7f) << 0 ) + \
|
||||
( (rd & 0x1f) << 7 ) + \
|
||||
( (funct3 & 0x1f) << 12 ) + \
|
||||
( (rs1 & 0x1f) << 15 ) + \
|
||||
( (rs2 & 0x1f) << 20 ) + \
|
||||
( (funct7 & 0x7f) << 25 )
|
||||
|
||||
//** Construct instruction word (32-bit) for R3-type instruction */
|
||||
#define CMD_WORD_R3_TYPE(rs3, rs2, rs1, funct3, rd, opcode) \
|
||||
( (opcode & 0x7f) << 0 ) + \
|
||||
( (rd & 0x1f) << 7 ) + \
|
||||
( (funct3 & 0x1f) << 12 ) + \
|
||||
( (rs1 & 0x1f) << 15 ) + \
|
||||
( (rs2 & 0x1f) << 20 ) + \
|
||||
( (rs3 & 0x1f) << 27 )
|
||||
|
||||
//** Construct instruction word (32-bit) for I-type instruction */
|
||||
#define CMD_WORD_I_TYPE(imm12, rs1_f5, funct3, rd, opcode) \
|
||||
( (opcode & 0x7f) << 0 ) + \
|
||||
( (rd & 0x1f) << 7 ) + \
|
||||
( (funct3 & 0x1f) << 12 ) + \
|
||||
( (rs1_f5 & 0x1f) << 15 ) + \
|
||||
( (imm12 & 0xfff) << 20 )
|
||||
|
||||
//** Construct custom R3-type instruction (4 registers, funct3, opcode) */
|
||||
#define CUSTOM_INSTR_R3_TYPE(rs3, rs2, rs1, funct3, rd, opcode) \
|
||||
asm volatile (".word " STR(CMD_WORD_R3_TYPE(GET_REG_ADDR(rs3), GET_REG_ADDR(rs2), GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
|
||||
|
||||
//** Construct custom R2-type instruction (3 registers, funct3, funct7, opcode) */
|
||||
#define CUSTOM_INSTR_R2_TYPE(funct7, rs2, rs1, funct3, rd, opcode) \
|
||||
asm volatile (".word " STR(CMD_WORD_R2_TYPE(funct7, GET_REG_ADDR(rs2), GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
|
||||
|
||||
//** Construct custom R1-type instruction (2 registers, funct3, funct7, funct5, opcode) */
|
||||
#define CUSTOM_INSTR_R1_TYPE(funct7, funct5, rs1, funct3, rd, opcode) \
|
||||
asm volatile (".word " STR(CMD_WORD_R2_TYPE(funct7, funct5, GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
|
||||
|
||||
//** Construct custom I-type instruction (2 registers, funct3, imm12, opcode) */
|
||||
#define CUSTOM_INSTR_I_TYPE(imm12, rs1, funct3, rd, opcode) \
|
||||
asm volatile (".word " STR(CMD_WORD_I_TYPE(imm12, GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
|
||||
/**@}*/
|
||||
|
||||
#endif // neorv32_intrinsics_h
|
54
Libs/RiscV/NEORV32/sw/lib/include/neorv32_mtime.h
Normal file
54
Libs/RiscV/NEORV32/sw/lib/include/neorv32_mtime.h
Normal file
@ -0,0 +1,54 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_mtime.h - Machine System Timer (MTIME) HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_mtime.h
|
||||
* @author Stephan Nolting
|
||||
* @brief Machine System Timer (MTIME) HW driver header file.
|
||||
*
|
||||
* @note These functions should only be used if the MTIME unit was synthesized (IO_MTIME_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_mtime_h
|
||||
#define neorv32_mtime_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_mtime_available(void);
|
||||
void neorv32_mtime_set_time(uint64_t time);
|
||||
uint64_t neorv32_mtime_get_time(void);
|
||||
void neorv32_mtime_set_timecmp(uint64_t timecmp);
|
||||
uint64_t neorv32_mtime_get_timecmp(void);
|
||||
|
||||
#endif // neorv32_mtime_h
|
72
Libs/RiscV/NEORV32/sw/lib/include/neorv32_neoled.h
Normal file
72
Libs/RiscV/NEORV32/sw/lib/include/neorv32_neoled.h
Normal file
@ -0,0 +1,72 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_neoled.h - Smart LED Interface (NEOLED) HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_neoled.h
|
||||
* @author Stephan Nolting
|
||||
* @brief Smart LED Interface (NEOLED) HW driver header file.
|
||||
*
|
||||
* @note These functions should only be used if the NEOLED unit was synthesized (IO_NEOLED_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_neoled_h
|
||||
#define neorv32_neoled_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_neoled_available(void);
|
||||
void neorv32_neoled_setup(uint32_t prsc, uint32_t t_total, uint32_t t_high_zero, uint32_t t_high_one);
|
||||
void neorv32_neoled_setup_ws2812(void);
|
||||
void neorv32_neoled_set_mode(uint32_t mode);
|
||||
void neorv32_neoled_strobe_blocking(void);
|
||||
void neorv32_neoled_strobe_nonblocking(void);
|
||||
void neorv32_neoled_enable(void);
|
||||
void neorv32_neoled_disable(void);
|
||||
void neorv32_neoled_write_blocking(uint32_t data);
|
||||
uint32_t neorv32_neoled_get_buffer_size(void);
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Send single RGB(W) data word to NEOLED module (non-blocking).
|
||||
*
|
||||
* @warning This function uses NO busy/flag checks at all!
|
||||
*
|
||||
* @param[in] data LSB-aligned 24-bit RGB or 32-bit RGBW data
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_neoled_write_nonblocking(uint32_t data) {
|
||||
|
||||
NEORV32_NEOLED.DATA = data; // send new LED data
|
||||
}
|
||||
|
||||
#endif // neorv32_neoled_h
|
56
Libs/RiscV/NEORV32/sw/lib/include/neorv32_pwm.h
Normal file
56
Libs/RiscV/NEORV32/sw/lib/include/neorv32_pwm.h
Normal file
@ -0,0 +1,56 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_pwm.h - Pulse Width Modulation Controller (PWM) HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_pwm.h
|
||||
* @author Stephan Nolting
|
||||
* @brief Pulse-Width Modulation Controller (PWM) HW driver header file.
|
||||
*
|
||||
* @note These functions should only be used if the PWM unit was synthesized (IO_PWM_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_pwm_h
|
||||
#define neorv32_pwm_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_pwm_available(void);
|
||||
void neorv32_pwm_setup(uint8_t prsc);
|
||||
void neorv32_pwm_disable(void);
|
||||
void neorv32_pwm_enable(void);
|
||||
int neorv32_pmw_get_num_channels(void);
|
||||
void neorv32_pwm_set(uint8_t channel, uint8_t duty);
|
||||
uint8_t neorv32_pwm_get(uint8_t channel);
|
||||
|
||||
#endif // neorv32_pwm_h
|
101
Libs/RiscV/NEORV32/sw/lib/include/neorv32_rte.h
Normal file
101
Libs/RiscV/NEORV32/sw/lib/include/neorv32_rte.h
Normal file
@ -0,0 +1,101 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_rte.h - NEORV32 Runtime Environment >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_rte.h
|
||||
* @author Stephan Nolting
|
||||
* @brief NEORV32 Runtime Environment.
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_rte_h
|
||||
#define neorv32_rte_h
|
||||
|
||||
/**********************************************************************//**
|
||||
* NEORV32 runtime environment trap IDs.
|
||||
**************************************************************************/
|
||||
enum NEORV32_RTE_TRAP_enum {
|
||||
RTE_TRAP_I_MISALIGNED = 0, /**< Instruction address misaligned */
|
||||
RTE_TRAP_I_ACCESS = 1, /**< Instruction (bus) access fault */
|
||||
RTE_TRAP_I_ILLEGAL = 2, /**< Illegal instruction */
|
||||
RTE_TRAP_BREAKPOINT = 3, /**< Breakpoint (EBREAK instruction) */
|
||||
RTE_TRAP_L_MISALIGNED = 4, /**< Load address misaligned */
|
||||
RTE_TRAP_L_ACCESS = 5, /**< Load (bus) access fault */
|
||||
RTE_TRAP_S_MISALIGNED = 6, /**< Store address misaligned */
|
||||
RTE_TRAP_S_ACCESS = 7, /**< Store (bus) access fault */
|
||||
RTE_TRAP_UENV_CALL = 8, /**< Environment call from user mode (ECALL instruction) */
|
||||
RTE_TRAP_MENV_CALL = 9, /**< Environment call from machine mode (ECALL instruction) */
|
||||
RTE_TRAP_MSI = 10, /**< Machine software interrupt */
|
||||
RTE_TRAP_MTI = 11, /**< Machine timer interrupt */
|
||||
RTE_TRAP_MEI = 12, /**< Machine external interrupt */
|
||||
RTE_TRAP_FIRQ_0 = 13, /**< Fast interrupt channel 0 */
|
||||
RTE_TRAP_FIRQ_1 = 14, /**< Fast interrupt channel 1 */
|
||||
RTE_TRAP_FIRQ_2 = 15, /**< Fast interrupt channel 2 */
|
||||
RTE_TRAP_FIRQ_3 = 16, /**< Fast interrupt channel 3 */
|
||||
RTE_TRAP_FIRQ_4 = 17, /**< Fast interrupt channel 4 */
|
||||
RTE_TRAP_FIRQ_5 = 18, /**< Fast interrupt channel 5 */
|
||||
RTE_TRAP_FIRQ_6 = 19, /**< Fast interrupt channel 6 */
|
||||
RTE_TRAP_FIRQ_7 = 20, /**< Fast interrupt channel 7 */
|
||||
RTE_TRAP_FIRQ_8 = 21, /**< Fast interrupt channel 8 */
|
||||
RTE_TRAP_FIRQ_9 = 22, /**< Fast interrupt channel 9 */
|
||||
RTE_TRAP_FIRQ_10 = 23, /**< Fast interrupt channel 10 */
|
||||
RTE_TRAP_FIRQ_11 = 24, /**< Fast interrupt channel 11 */
|
||||
RTE_TRAP_FIRQ_12 = 25, /**< Fast interrupt channel 12 */
|
||||
RTE_TRAP_FIRQ_13 = 26, /**< Fast interrupt channel 13 */
|
||||
RTE_TRAP_FIRQ_14 = 27, /**< Fast interrupt channel 14 */
|
||||
RTE_TRAP_FIRQ_15 = 28 /**< Fast interrupt channel 15 */
|
||||
};
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* NEORV32 runtime environment: Number of available traps.
|
||||
**************************************************************************/
|
||||
#define NEORV32_RTE_NUM_TRAPS 29
|
||||
|
||||
|
||||
// prototypes
|
||||
void neorv32_rte_setup(void);
|
||||
int neorv32_rte_exception_install(uint8_t id, void (*handler)(void));
|
||||
int neorv32_rte_exception_uninstall(uint8_t id);
|
||||
|
||||
void neorv32_rte_print_hw_config(void);
|
||||
void neorv32_rte_print_hw_version(void);
|
||||
void neorv32_rte_print_credits(void);
|
||||
void neorv32_rte_print_logo(void);
|
||||
void neorv32_rte_print_license(void);
|
||||
|
||||
uint32_t neorv32_rte_get_compiler_isa(void);
|
||||
int neorv32_rte_check_isa(int silent);
|
||||
|
||||
#endif // neorv32_rte_h
|
269
Libs/RiscV/NEORV32/sw/lib/include/neorv32_slink.h
Normal file
269
Libs/RiscV/NEORV32/sw/lib/include/neorv32_slink.h
Normal file
@ -0,0 +1,269 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_slink.h - Stream Link Interface HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_slink.h
|
||||
* @author Stephan Nolting
|
||||
* @brief Stream Link Interface HW driver header file.
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_slink_h
|
||||
#define neorv32_slink_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_slink_available(void);
|
||||
void neorv32_slink_enable(void);
|
||||
void neorv32_slink_disable(void);
|
||||
void neorv32_slink_rx_irq_config(int link_id, int irq_en, int irq_type);
|
||||
void neorv32_slink_tx_irq_config(int link_id, int irq_en, int irq_type);
|
||||
int neorv32_slink_get_rx_num(void);
|
||||
int neorv32_slink_get_tx_num(void);
|
||||
int neorv32_slink_get_rx_depth(void);
|
||||
int neorv32_slink_get_tx_depth(void);
|
||||
int neorv32_slink_check_rx_half_full(int link_id);
|
||||
int neorv32_slink_check_tx_half_full(int link_id);
|
||||
// non-blocking transmit
|
||||
int neorv32_slink_tx0_nonblocking(uint32_t tx_data);
|
||||
int neorv32_slink_tx1_nonblocking(uint32_t tx_data);
|
||||
int neorv32_slink_tx2_nonblocking(uint32_t tx_data);
|
||||
int neorv32_slink_tx3_nonblocking(uint32_t tx_data);
|
||||
int neorv32_slink_tx4_nonblocking(uint32_t tx_data);
|
||||
int neorv32_slink_tx5_nonblocking(uint32_t tx_data);
|
||||
int neorv32_slink_tx6_nonblocking(uint32_t tx_data);
|
||||
int neorv32_slink_tx7_nonblocking(uint32_t tx_data);
|
||||
// non-blocking receive
|
||||
int neorv32_slink_rx0_nonblocking(uint32_t *rx_data);
|
||||
int neorv32_slink_rx1_nonblocking(uint32_t *rx_data);
|
||||
int neorv32_slink_rx2_nonblocking(uint32_t *rx_data);
|
||||
int neorv32_slink_rx3_nonblocking(uint32_t *rx_data);
|
||||
int neorv32_slink_rx4_nonblocking(uint32_t *rx_data);
|
||||
int neorv32_slink_rx5_nonblocking(uint32_t *rx_data);
|
||||
int neorv32_slink_rx6_nonblocking(uint32_t *rx_data);
|
||||
int neorv32_slink_rx7_nonblocking(uint32_t *rx_data);
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Write data to TX stream link 0 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in] tx_data Data to send to link.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_tx0_blocking(uint32_t tx_data) {
|
||||
NEORV32_SLINK.DATA[0] = tx_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Write data to TX stream link 1 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in] tx_data Data to send to link.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_tx1_blocking(uint32_t tx_data) {
|
||||
NEORV32_SLINK.DATA[1] = tx_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Write data to TX stream link 2 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in] tx_data Data to send to link.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_tx2_blocking(uint32_t tx_data) {
|
||||
NEORV32_SLINK.DATA[2] = tx_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Write data to TX stream link 3 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in] tx_data Data to send to link.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_tx3_blocking(uint32_t tx_data) {
|
||||
NEORV32_SLINK.DATA[3] = tx_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Write data to TX stream link 4 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in] tx_data Data to send to link.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_tx4_blocking(uint32_t tx_data) {
|
||||
NEORV32_SLINK.DATA[4] = tx_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Write data to TX stream link 5 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in] tx_data Data to send to link.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_tx5_blocking(uint32_t tx_data) {
|
||||
NEORV32_SLINK.DATA[5] = tx_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Write data to TX stream link 6 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in] tx_data Data to send to link.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_tx6_blocking(uint32_t tx_data) {
|
||||
NEORV32_SLINK.DATA[6] = tx_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Write data to TX stream link 7 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in] tx_data Data to send to link.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_tx7_blocking(uint32_t tx_data) {
|
||||
NEORV32_SLINK.DATA[7] = tx_data;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Read data from RX stream link 0 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in,out] rx_data Pointer to return read data.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_rx0_blocking(uint32_t *rx_data) {
|
||||
*rx_data = NEORV32_SLINK.DATA[0];
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Read data from RX stream link 1 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in,out] rx_data Pointer to return read data.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_rx1_blocking(uint32_t *rx_data) {
|
||||
*rx_data = NEORV32_SLINK.DATA[1];
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Read data from RX stream link 2 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in,out] rx_data Pointer to return read data.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_rx2_blocking(uint32_t *rx_data) {
|
||||
*rx_data = NEORV32_SLINK.DATA[2];
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Read data from RX stream link 3 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in,out] rx_data Pointer to return read data.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_rx3_blocking(uint32_t *rx_data) {
|
||||
*rx_data = NEORV32_SLINK.DATA[3];
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Read data from RX stream link 4 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in,out] rx_data Pointer to return read data.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_rx4_blocking(uint32_t *rx_data) {
|
||||
*rx_data = NEORV32_SLINK.DATA[4];
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Read data from RX stream link 5 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in,out] rx_data Pointer to return read data.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_rx5_blocking(uint32_t *rx_data) {
|
||||
*rx_data = NEORV32_SLINK.DATA[5];
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Read data from RX stream link 6 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in,out] rx_data Pointer to return read data.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_rx6_blocking(uint32_t *rx_data) {
|
||||
*rx_data = NEORV32_SLINK.DATA[6];
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Read data from RX stream link 7 (blocking!)
|
||||
*
|
||||
* @warning This function will raise an exception when the bus access times out!
|
||||
*
|
||||
* @param[in,out] rx_data Pointer to return read data.
|
||||
**************************************************************************/
|
||||
inline void __attribute__ ((always_inline)) neorv32_slink_rx7_blocking(uint32_t *rx_data) {
|
||||
*rx_data = NEORV32_SLINK.DATA[7];
|
||||
}
|
||||
|
||||
|
||||
#endif // neorv32_slink_h
|
59
Libs/RiscV/NEORV32/sw/lib/include/neorv32_spi.h
Normal file
59
Libs/RiscV/NEORV32/sw/lib/include/neorv32_spi.h
Normal file
@ -0,0 +1,59 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_spi.h - Serial Peripheral Interface Controller (SPI) HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_spi.h
|
||||
* @author Stephan Nolting
|
||||
* @brief Serial peripheral interface controller (SPI) HW driver header file.
|
||||
*
|
||||
* @note These functions should only be used if the SPI unit was synthesized (IO_SPI_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_spi_h
|
||||
#define neorv32_spi_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_spi_available(void);
|
||||
void neorv32_spi_setup(uint8_t prsc, uint8_t clk_phase, uint8_t clk_polarity, uint8_t data_size);
|
||||
void neorv32_spi_disable(void);
|
||||
void neorv32_spi_enable(void);
|
||||
void neorv32_spi_cs_en(uint8_t cs);
|
||||
void neorv32_spi_cs_dis(uint8_t cs);
|
||||
uint32_t neorv32_spi_trans(uint32_t tx_data);
|
||||
void neorv32_spi_put_nonblocking(uint32_t tx_data);
|
||||
uint32_t neorv32_spi_get_nonblocking(void);
|
||||
int neorv32_spi_busy(void);
|
||||
|
||||
#endif // neorv32_spi_h
|
53
Libs/RiscV/NEORV32/sw/lib/include/neorv32_trng.h
Normal file
53
Libs/RiscV/NEORV32/sw/lib/include/neorv32_trng.h
Normal file
@ -0,0 +1,53 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_trng.h - True Random Number Generator (TRNG) HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_trng.h
|
||||
* @author Stephan Nolting
|
||||
* @brief True Random Number Generator (TRNG) HW driver header file.
|
||||
*
|
||||
* @note These functions should only be used if the TRNG unit was synthesized (IO_TRNG_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_trng_h
|
||||
#define neorv32_trng_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_trng_available(void);
|
||||
void neorv32_trng_enable(void);
|
||||
void neorv32_trng_disable(void);
|
||||
int neorv32_trng_get(uint8_t *data);
|
||||
|
||||
#endif // neorv32_trng_h
|
61
Libs/RiscV/NEORV32/sw/lib/include/neorv32_twi.h
Normal file
61
Libs/RiscV/NEORV32/sw/lib/include/neorv32_twi.h
Normal file
@ -0,0 +1,61 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_twi.h - Two-Wire Interface Controller (TWI) HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_twi.h
|
||||
* @author Stephan Nolting
|
||||
* @brief Two-Wire Interface Controller (TWI) HW driver header file.
|
||||
*
|
||||
* @note These functions should only be used if the TWI unit was synthesized (IO_TWI_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_twi_h
|
||||
#define neorv32_twi_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_twi_available(void);
|
||||
void neorv32_twi_setup(uint8_t prsc);
|
||||
void neorv32_twi_disable(void);
|
||||
void neorv32_twi_enable(void);
|
||||
void neorv32_twi_mack_enable(void);
|
||||
void neorv32_twi_mack_disable(void);
|
||||
int neorv32_twi_busy(void);
|
||||
int neorv32_twi_start_trans(uint8_t a);
|
||||
int neorv32_twi_trans(uint8_t d);
|
||||
uint8_t neorv32_twi_get_data(void);
|
||||
void neorv32_twi_generate_stop(void);
|
||||
void neorv32_twi_generate_start(void);
|
||||
|
||||
#endif // neorv32_twi_h
|
82
Libs/RiscV/NEORV32/sw/lib/include/neorv32_uart.h
Normal file
82
Libs/RiscV/NEORV32/sw/lib/include/neorv32_uart.h
Normal file
@ -0,0 +1,82 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_uart.h - Universal Asynchronous Receiver/Transmitter (UART) HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_uart.h
|
||||
* @author Stephan Nolting
|
||||
* @brief Universal asynchronous receiver/transmitter (UART0/UART1) HW driver header file
|
||||
*
|
||||
* @warning UART0 (primary UART) is used as default user console interface for all NEORV32 software framework/library functions.
|
||||
*
|
||||
* @note These functions should only be used if the UART0/UART1 unit was synthesized (IO_UART0_EN = true / IO_UART1_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_uart_h
|
||||
#define neorv32_uart_h
|
||||
|
||||
// Libs required by functions
|
||||
#include <stdarg.h>
|
||||
|
||||
// prototypes for UART0 (primary UART)
|
||||
int neorv32_uart0_available(void);
|
||||
void neorv32_uart0_setup(uint32_t baudrate, uint8_t parity, uint8_t flow_con);
|
||||
void neorv32_uart0_disable(void);
|
||||
void neorv32_uart0_enable(void);
|
||||
void neorv32_uart0_putc(char c);
|
||||
int neorv32_uart0_tx_busy(void);
|
||||
char neorv32_uart0_getc(void);
|
||||
int neorv32_uart0_char_received(void);
|
||||
int neorv32_uart0_getc_safe(char *data);
|
||||
char neorv32_uart0_char_received_get(void);
|
||||
void neorv32_uart0_print(const char *s);
|
||||
void neorv32_uart0_printf(const char *format, ...);
|
||||
int neorv32_uart0_scan(char *buffer, int max_size, int echo);
|
||||
|
||||
// prototypes for UART1 (secondary UART)
|
||||
int neorv32_uart1_available(void);
|
||||
void neorv32_uart1_setup(uint32_t baudrate, uint8_t parity, uint8_t flow_con);
|
||||
void neorv32_uart1_disable(void);
|
||||
void neorv32_uart1_enable(void);
|
||||
void neorv32_uart1_putc(char c);
|
||||
int neorv32_uart1_tx_busy(void);
|
||||
char neorv32_uart1_getc(void);
|
||||
int neorv32_uart1_char_received(void);
|
||||
int neorv32_uart1_getc_safe(char *data);
|
||||
char neorv32_uart1_char_received_get(void);
|
||||
void neorv32_uart1_print(const char *s);
|
||||
void neorv32_uart1_printf(const char *format, ...);
|
||||
int neorv32_uart1_scan(char *buffer, int max_size, int echo);
|
||||
|
||||
#endif // neorv32_uart_h
|
55
Libs/RiscV/NEORV32/sw/lib/include/neorv32_wdt.h
Normal file
55
Libs/RiscV/NEORV32/sw/lib/include/neorv32_wdt.h
Normal file
@ -0,0 +1,55 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_wdt.h - Watchdog Timer (WDT) HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_wdt.h
|
||||
* @author Stephan Nolting
|
||||
* @brief Watchdog Timer (WDT) HW driver header file.
|
||||
*
|
||||
* @note These functions should only be used if the WDT unit was synthesized (IO_WDT_EN = true).
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_wdt_h
|
||||
#define neorv32_wdt_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_wdt_available(void);
|
||||
void neorv32_wdt_setup(uint8_t prsc, uint8_t mode, uint8_t lock);
|
||||
int neorv32_wdt_disable(void);
|
||||
void neorv32_wdt_reset(void);
|
||||
int neorv32_wdt_get_cause(void);
|
||||
void neorv32_wdt_force(void);
|
||||
|
||||
#endif // neorv32_wdt_h
|
59
Libs/RiscV/NEORV32/sw/lib/include/neorv32_xirq.h
Normal file
59
Libs/RiscV/NEORV32/sw/lib/include/neorv32_xirq.h
Normal file
@ -0,0 +1,59 @@
|
||||
// #################################################################################################
|
||||
// # << NEORV32: neorv32_xirq.h - External Interrupt controller HW Driver >> #
|
||||
// # ********************************************************************************************* #
|
||||
// # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
// #################################################################################################
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* @file neorv32_xirq.h
|
||||
* @author Stephan Nolting
|
||||
* @brief External Interrupt controller HW driver header file.
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef neorv32_xirq_h
|
||||
#define neorv32_xirq_h
|
||||
|
||||
// prototypes
|
||||
int neorv32_xirq_available(void);
|
||||
int neorv32_xirq_setup(void);
|
||||
void neorv32_xirq_global_enable(void);
|
||||
void neorv32_xirq_global_disable(void);
|
||||
int neorv32_xirq_get_num(void);
|
||||
void neorv32_xirq_clear_pending(uint8_t ch);
|
||||
void neorv32_xirq_channel_enable(uint8_t ch);
|
||||
void neorv32_xirq_channel_disable(uint8_t ch);
|
||||
|
||||
int neorv32_xirq_install(uint8_t ch, void (*handler)(void));
|
||||
int neorv32_xirq_uninstall(uint8_t ch);
|
||||
|
||||
|
||||
#endif // neorv32_xirq_h
|
1
Libs/RiscV/NEORV32/sw/ocd-firmware/.gitignore
vendored
Normal file
1
Libs/RiscV/NEORV32/sw/ocd-firmware/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.vhd
|
18
Libs/RiscV/NEORV32/sw/ocd-firmware/README.md
Normal file
18
Libs/RiscV/NEORV32/sw/ocd-firmware/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# NEORV32 On-Chip Debugger (OCD) - "Park Loop" Code
|
||||
|
||||
This folder contains the ASM sources for the *execution-based* debugger code ROM.
|
||||
`park_loop.S` contains the "park loop" that is executed when the CPU is in debug mode. This code is used to communicate
|
||||
with the *debug module (DM)* and is responsible for:
|
||||
|
||||
* acknowledging halt requests
|
||||
* processing and acknowledging resume requests
|
||||
* processing and acknowledging "execute program buffer" requests
|
||||
* executing the program buffer (provided by the DM)
|
||||
* catching exceptions while in debug mode
|
||||
|
||||
The park loop code is implemented as endless loop that polls the status register of the *debug memory (DBMEM)* module
|
||||
to check for requests from the DM and sets according flags in the status register to acknowledge these requests.
|
||||
|
||||
:warning: Executing `make clean_all all` will **NOT** update the actual debugger code ROM that will be synthesized.
|
||||
The interface with the DM will break if there are any bugs in this code. However, if you wish to update the code ROM,
|
||||
copy the array content from `neorv32_debug_mem.code.vhd` to the `code_rom_file` constant in `rtl/core/neorv32_debug_dbmem.vhd`.
|
67
Libs/RiscV/NEORV32/sw/ocd-firmware/debug_rom.ld
Normal file
67
Libs/RiscV/NEORV32/sw/ocd-firmware/debug_rom.ld
Normal file
@ -0,0 +1,67 @@
|
||||
/* ################################################################################################# */
|
||||
/* # << NEORV32 - RISC-V GCC Linker Script >> # */
|
||||
/* # ********************************************************************************************* # */
|
||||
/* # For the execution based on-chip debugger code memory (/ROM() - "park loop" code # */
|
||||
/* # ********************************************************************************************* # */
|
||||
/* # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting # */
|
||||
/* ################################################################################################# */
|
||||
|
||||
/* Default linker script, for normal executables */
|
||||
/* Copyright (C) 2014-2020 Free Software Foundation, Inc.
|
||||
Copying and distribution of this script, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. */
|
||||
|
||||
/* modified for the NEORV32 processor by Stephan Nolting */
|
||||
|
||||
|
||||
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
|
||||
OUTPUT_ARCH(riscv)
|
||||
ENTRY(_start)
|
||||
SEARCH_DIR("/opt/riscv/riscv32-unknown-elf/lib"); SEARCH_DIR("=/opt/riscv/riscv64-unknown-linux-gnu/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
|
||||
|
||||
MEMORY
|
||||
{
|
||||
debug_mem (rx) : ORIGIN = 0xFFFFF800, LENGTH = 128
|
||||
}
|
||||
/* ************************************************************************* */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
/* Actual instructions */
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.text));
|
||||
|
||||
} > debug_mem
|
||||
|
||||
}
|
294
Libs/RiscV/NEORV32/sw/ocd-firmware/makefile
Normal file
294
Libs/RiscV/NEORV32/sw/ocd-firmware/makefile
Normal file
@ -0,0 +1,294 @@
|
||||
#################################################################################################
|
||||
# << NEORV32 - Application Makefile >> #
|
||||
# ********************************************************************************************* #
|
||||
# Make sure to add the RISC-V GCC compiler's bin folder to your PATH environment variable. #
|
||||
# ********************************************************************************************* #
|
||||
# FOR DEBUGGER "PARK LOOP" CODE ONLY! #
|
||||
# ********************************************************************************************* #
|
||||
# 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
||||
#################################################################################################
|
||||
|
||||
|
||||
# *****************************************************************************
|
||||
# USER CONFIGURATION
|
||||
# *****************************************************************************
|
||||
# User's application sources (*.c, *.cpp, *.s, *.S); add additional files here
|
||||
APP_SRC ?= $(wildcard ./*.S)
|
||||
|
||||
# User's application include folders (don't forget the '-I' before each entry)
|
||||
APP_INC ?= -I .
|
||||
# User's application include folders - for assembly files only (don't forget the '-I' before each entry)
|
||||
ASM_INC ?= -I .
|
||||
|
||||
# Optimization
|
||||
EFFORT ?= -Os
|
||||
|
||||
# Compiler toolchain
|
||||
RISCV_PREFIX ?= riscv32-unknown-elf-
|
||||
|
||||
# CPU architecture and ABI
|
||||
MARCH = rv32i
|
||||
MABI = ilp32
|
||||
|
||||
# User flags for additional configuration (will be added to compiler flags)
|
||||
USER_FLAGS ?=
|
||||
|
||||
# Relative or absolute path to the NEORV32 home folder
|
||||
NEORV32_HOME ?= ../..
|
||||
# *****************************************************************************
|
||||
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# NEORV32 framework
|
||||
# -----------------------------------------------------------------------------
|
||||
# Path to NEORV32 linker script and startup file
|
||||
NEORV32_COM_PATH = $(NEORV32_HOME)/sw/common
|
||||
# Path to main NEORV32 library include files
|
||||
NEORV32_INC_PATH = $(NEORV32_HOME)/sw/lib/include
|
||||
# Path to main NEORV32 library source files
|
||||
NEORV32_SRC_PATH = $(NEORV32_HOME)/sw/lib/source
|
||||
# Path to NEORV32 executable generator
|
||||
NEORV32_EXG_PATH = $(NEORV32_HOME)/sw/image_gen
|
||||
# Path to NEORV32 core rtl folder
|
||||
NEORV32_RTL_PATH = $(NEORV32_HOME)/rtl/core
|
||||
# Marker file to check for NEORV32 home folder
|
||||
NEORV32_HOME_MARKER = $(NEORV32_INC_PATH)/neorv32.h
|
||||
|
||||
# Linker script
|
||||
LD_SCRIPT = ./debug_rom.ld
|
||||
|
||||
# Main output files
|
||||
APP_ASM = main.asm
|
||||
APP_IMG = neorv32_debug_mem.code.vhd
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Sources and objects
|
||||
# -----------------------------------------------------------------------------
|
||||
# Define all sources
|
||||
SRC = $(APP_SRC)
|
||||
|
||||
# Define all object files
|
||||
OBJ = $(SRC:%=%.o)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Tools and flags
|
||||
# -----------------------------------------------------------------------------
|
||||
# Compiler tools
|
||||
CC = $(RISCV_PREFIX)gcc
|
||||
OBJDUMP = $(RISCV_PREFIX)objdump
|
||||
OBJCOPY = $(RISCV_PREFIX)objcopy
|
||||
SIZE = $(RISCV_PREFIX)size
|
||||
|
||||
# Host native compiler
|
||||
CC_X86 = g++ -Wall -O -g
|
||||
|
||||
# NEORV32 executable image generator
|
||||
IMAGE_GEN = $(NEORV32_EXG_PATH)/image_gen
|
||||
|
||||
# Compiler & linker flags
|
||||
CC_OPTS = -march=$(MARCH) -mabi=$(MABI) $(EFFORT) -Wall -ffunction-sections -fdata-sections -nostartfiles -mno-fdiv
|
||||
CC_OPTS += -Wl,--gc-sections -lm -lc -lgcc -lc
|
||||
# This accelerates instruction fetch after branches when C extension is enabled (irrelevant when C extension is disabled)
|
||||
CC_OPTS += -falign-functions=4 -falign-labels=4 -falign-loops=4 -falign-jumps=4
|
||||
CC_OPTS += $(USER_FLAGS)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Application output definitions
|
||||
# -----------------------------------------------------------------------------
|
||||
.PHONY: check info help elf_info clean clean_all bootloader
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
# 'compile' is still here for compatibility
|
||||
compile: $(APP_ASM)
|
||||
install: $(APP_ASM) $(APP_IMG)
|
||||
all: $(APP_ASM) $(APP_IMG)
|
||||
|
||||
# Check if making bootloader
|
||||
# Use different base address and legth for instruction memory/"rom" (BOOTMEM instead of IMEM)
|
||||
# Also define "make_bootloader" for crt0.S
|
||||
target bootloader: CC_OPTS += -Wl,--defsym=make_bootloader=1 -Dmake_bootloader
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Image generator targets
|
||||
# -----------------------------------------------------------------------------
|
||||
# install/compile tools
|
||||
$(IMAGE_GEN): $(NEORV32_EXG_PATH)/image_gen.c
|
||||
@echo Compiling $(IMAGE_GEN)
|
||||
@$(CC_X86) $< -o $(IMAGE_GEN)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# General targets: Assemble, compile, link, dump
|
||||
# -----------------------------------------------------------------------------
|
||||
# Compile app *.s sources (assembly)
|
||||
%.s.o: %.s
|
||||
@$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(ASM_INC) $< -o $@
|
||||
|
||||
# Compile app *.S sources (assembly + C pre-processor)
|
||||
%.S.o: %.S
|
||||
@$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(ASM_INC) $< -o $@
|
||||
|
||||
# Compile app *.c sources
|
||||
%.c.o: %.c
|
||||
@$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(APP_INC) $< -o $@
|
||||
|
||||
# Compile app *.cpp sources
|
||||
%.cpp.o: %.cpp
|
||||
@$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(APP_INC) $< -o $@
|
||||
|
||||
# Link object files and show memory utilization
|
||||
main.elf: $(OBJ)
|
||||
@$(CC) $(CC_OPTS) -T $(LD_SCRIPT) $(OBJ) -o $@ -lm
|
||||
@echo "Memory utilization:"
|
||||
@$(SIZE) main.elf
|
||||
|
||||
# Assembly listing file (for debugging)
|
||||
$(APP_ASM): main.elf
|
||||
@$(OBJDUMP) -d -S -z $< > $@
|
||||
|
||||
# Generate final executable from .text only
|
||||
main.bin: main.elf $(APP_ASM)
|
||||
@$(OBJCOPY) -I elf32-little $< -j .text -O binary text.bin
|
||||
@cat text.bin > $@
|
||||
@rm -f text.bin
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Application targets: install (as VHDL file)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# Generate NEORV32 executable VHDL boot image
|
||||
$(APP_IMG): main.bin $(IMAGE_GEN)
|
||||
@set -e
|
||||
@$(IMAGE_GEN) -app_img $< $@ $(shell basename $(CURDIR))
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Check toolchain
|
||||
# -----------------------------------------------------------------------------
|
||||
check: $(IMAGE_GEN)
|
||||
@echo "---------------- Check: NEORV32_HOME folder ----------------"
|
||||
ifneq ($(shell [ -e $(NEORV32_HOME_MARKER) ] && echo 1 || echo 0 ), 1)
|
||||
$(error NEORV32_HOME folder not found!)
|
||||
endif
|
||||
@echo "NEORV32_HOME: $(NEORV32_HOME)"
|
||||
@echo "---------------- Check: $(CC) ----------------"
|
||||
@$(CC) -v
|
||||
@echo "---------------- Check: $(OBJDUMP) ----------------"
|
||||
@$(OBJDUMP) -V
|
||||
@echo "---------------- Check: $(OBJCOPY) ----------------"
|
||||
@$(OBJCOPY) -V
|
||||
@echo "---------------- Check: $(SIZE) ----------------"
|
||||
@$(SIZE) -V
|
||||
@echo "---------------- Check: NEORV32 image_gen ----------------"
|
||||
@$(IMAGE_GEN) -help
|
||||
@echo "---------------- Check: Native GCC ----------------"
|
||||
@$(CC_X86) -v
|
||||
@echo
|
||||
@echo "Toolchain check OK"
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Show configuration
|
||||
# -----------------------------------------------------------------------------
|
||||
info:
|
||||
@echo "---------------- Info: Project ----------------"
|
||||
@echo "Project folder: $(shell basename $(CURDIR))"
|
||||
@echo "Source files: $(APP_SRC)"
|
||||
@echo "Include folder(s): $(APP_INC)"
|
||||
@echo "ASM include folder(s): $(ASM_INC)"
|
||||
@echo "---------------- Info: NEORV32 ----------------"
|
||||
@echo "NEORV32 home folder (NEORV32_HOME): $(NEORV32_HOME)"
|
||||
@echo "IMAGE_GEN: $(IMAGE_GEN)"
|
||||
@echo "Core source files:"
|
||||
@echo "$(CORE_SRC)"
|
||||
@echo "Core include folder:"
|
||||
@echo "$(NEORV32_INC_PATH)"
|
||||
@echo "---------------- Info: Objects ----------------"
|
||||
@echo "Project object files:"
|
||||
@echo "$(OBJ)"
|
||||
@echo "---------------- Info: RISC-V CPU ----------------"
|
||||
@echo "MARCH: $(MARCH)"
|
||||
@echo "MABI: $(MABI)"
|
||||
@echo "---------------- Info: Toolchain ----------------"
|
||||
@echo "Toolchain: $(RISCV_TOLLCHAIN)"
|
||||
@echo "CC: $(CC)"
|
||||
@echo "OBJDUMP: $(OBJDUMP)"
|
||||
@echo "OBJCOPY: $(OBJCOPY)"
|
||||
@echo "SIZE: $(SIZE)"
|
||||
@echo "---------------- Info: Compiler Libraries ----------------"
|
||||
@echo "LIBGCC:"
|
||||
@$(CC) -print-libgcc-file-name
|
||||
@echo "SEARCH-DIRS:"
|
||||
@$(CC) -print-search-dirs
|
||||
@echo "---------------- Info: Flags ----------------"
|
||||
@echo "USER_FLAGS: $(USER_FLAGS)"
|
||||
@echo "CC_OPTS: $(CC_OPTS)"
|
||||
@echo "---------------- Info: Host Native GCC Flags ----------------"
|
||||
@echo "CC_X86: $(CC_X86)"
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Show final ELF details (just for debugging)
|
||||
# -----------------------------------------------------------------------------
|
||||
elf_info: main.elf
|
||||
@$(OBJDUMP) -x main.elf
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Help
|
||||
# -----------------------------------------------------------------------------
|
||||
help:
|
||||
@echo "<<< NEORV32 Application Makefile >>>"
|
||||
@echo "Make sure to add the bin folder of RISC-V GCC to your PATH variable."
|
||||
@echo "Targets:"
|
||||
@echo " help - show this text"
|
||||
@echo " check - check toolchain"
|
||||
@echo " info - show makefile/toolchain configuration"
|
||||
@echo " exe - compile and generate <neorv32_exe.bin> executable for upload via bootloader"
|
||||
@echo " all - compile and generate <neorv32_exe.bin> executable for upload via bootloader and generate and install VHDL IMEM boot image (for application)"
|
||||
@echo " clean - clean up project"
|
||||
@echo " clean_all - clean up project, core libraries and image generator"
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Clean up
|
||||
# -----------------------------------------------------------------------------
|
||||
clean:
|
||||
@rm -f *.elf *.o *.bin *.out *.asm *.vhd
|
||||
|
||||
clean_all: clean
|
||||
@rm -f $(OBJ) $(IMAGE_GEN)
|
103
Libs/RiscV/NEORV32/sw/ocd-firmware/park_loop.S
Normal file
103
Libs/RiscV/NEORV32/sw/ocd-firmware/park_loop.S
Normal file
@ -0,0 +1,103 @@
|
||||
/* ################################################################################################# */
|
||||
/* # << NEORV32 - park_loop.S - Execution-Based On-Chip Debugger - Park Loop Code >> # */
|
||||
/* # ********************************************************************************************* # */
|
||||
/* # 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 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting # */
|
||||
/* ################################################################################################# */
|
||||
|
||||
// debug memory address map
|
||||
.equ DBMEM_CODE_BASE, 0xfffff800 // base address of dbmem.code_memory
|
||||
.equ DBMEM_PBUF_BASE, 0xfffff880 // base address of dbmem.program_buffer
|
||||
.equ DBMEM_DBUF_BASE, 0xfffff900 // base address of dbmem.data_buffer
|
||||
.equ DBMEM_SREG_BASE, 0xfffff980 // base address of dbmem.status_register
|
||||
|
||||
// status register (SREG) bits
|
||||
.equ SREG_HALTED_ACK, (1<<0) // -/w: CPU is halted in debug mode and waits in park loop
|
||||
.equ SREG_RESUME_REQ, (1<<1) // r/-: DM requests CPU to resume
|
||||
.equ SREG_RESUME_ACK, (1<<2) // -/w: CPU starts resuming
|
||||
.equ SREG_EXECUTE_REQ, (1<<3) // r/-: DM requests to execute program buffer
|
||||
.equ SREG_EXECUTE_ACK, (1<<4) // -/w: CPU starts to execute program buffer
|
||||
.equ SREG_EXCEPTION_ACK, (1<<5) // -/w: CPU has detected an exception
|
||||
|
||||
.file "park_loop.S"
|
||||
.section .text
|
||||
.balign 4
|
||||
.option norvc
|
||||
.global _start
|
||||
.global entry_normal
|
||||
.global entry_exception
|
||||
|
||||
|
||||
_start:
|
||||
|
||||
// BASE + 0: entry for ebreak in debug-mode, halt request or return from single-stepped instruction
|
||||
entry_normal:
|
||||
jal zero, parking_loop_start
|
||||
|
||||
// BASE + 4: entry for exceptions - signal EXCEPTION to DM and restart parking loop
|
||||
entry_exception:
|
||||
csrw dscratch0, s0 // save s0 to dscratch0 so we have a general purpose register available
|
||||
addi s0, zero, SREG_EXCEPTION_ACK // mask exception acknowledge flag
|
||||
sw s0, DBMEM_SREG_BASE(zero) // trigger exception acknowledge to inform DM
|
||||
csrr s0, dscratch0 // restore s0 from dscratch0
|
||||
ebreak // restart parking loop
|
||||
|
||||
// "parking loop": endless loop that polls the status register to check if the DM
|
||||
// wants to execute code from the program buffer or to resume normal CPU/application operation
|
||||
parking_loop_start:
|
||||
csrw dscratch0, s0 // save s0 to dscratch0 so we have a general purpose register available
|
||||
addi s0, zero, SREG_HALTED_ACK
|
||||
sw s0, DBMEM_SREG_BASE(zero) // ACK that CPU has halted
|
||||
|
||||
parking_loop:
|
||||
lw s0, DBMEM_SREG_BASE(zero) // get status register
|
||||
andi s0, s0, SREG_EXECUTE_REQ // request to execute program buffer?
|
||||
bnez s0, execute_progbuf // execute program buffer
|
||||
|
||||
lw s0, DBMEM_SREG_BASE(zero) // get status register
|
||||
andi s0, s0, SREG_RESUME_REQ // request to resume?
|
||||
bnez s0, resume // resume normal operation
|
||||
|
||||
jal zero, parking_loop // restart parking loop polling
|
||||
|
||||
// resume normal operation
|
||||
resume:
|
||||
addi s0, zero, SREG_RESUME_ACK
|
||||
sw s0, DBMEM_SREG_BASE(zero) // ACK that CPU is about to resume
|
||||
csrr s0, dscratch0 // restore s0 from dscratch0
|
||||
dret // end debug mode
|
||||
|
||||
// execute program buffer
|
||||
execute_progbuf:
|
||||
addi s0, zero, SREG_EXECUTE_ACK
|
||||
sw s0, DBMEM_SREG_BASE(zero) // ACK that execution is about to start
|
||||
csrr s0, dscratch0 // restore s0 from dscratch0
|
||||
fence.i // synchronize i-cache & prefetch with memory (program buffer)
|
||||
jalr zero, zero, %lo(DBMEM_PBUF_BASE) // jump to beginning of program buffer
|
41
Libs/RiscV/NEORV32/sw/openocd/openocd_neorv32.cfg
Normal file
41
Libs/RiscV/NEORV32/sw/openocd/openocd_neorv32.cfg
Normal file
@ -0,0 +1,41 @@
|
||||
# openOCD configuration file for generic FT2232H-based USB-jtag interface
|
||||
# references: https://mcuoneclipse.com/2019/10/20/jtag-debugging-the-esp32-with-ft2232-and-openocd/
|
||||
|
||||
# ----------------------------------------------
|
||||
# Interface configuration
|
||||
# ----------------------------------------------
|
||||
|
||||
# FT2232H pinout:
|
||||
# TCK: D0
|
||||
# TDI: D1
|
||||
# TDO: D2
|
||||
# TMS: D3
|
||||
# TRST: D4 (low-active, optional - pull input pin high if not used)
|
||||
|
||||
adapter driver ftdi
|
||||
ftdi_vid_pid 0x0403 0x6010
|
||||
ftdi_channel 0
|
||||
ftdi_layout_init 0x0038 0x003b
|
||||
|
||||
adapter speed 1000
|
||||
ftdi_layout_signal nTRST -ndata 0x0010 -noe 0x0040
|
||||
transport select jtag
|
||||
|
||||
# ----------------------------------------------
|
||||
# Target configuration
|
||||
# ----------------------------------------------
|
||||
|
||||
set _CHIPNAME neorv32
|
||||
set _JTAGID 0x0cafe001
|
||||
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id $_JTAGID
|
||||
|
||||
set _TARGETNAME $_CHIPNAME.cpu
|
||||
|
||||
target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME
|
||||
|
||||
# ----------------------------------------------
|
||||
# Scratch pad RAM
|
||||
# ----------------------------------------------
|
||||
|
||||
# work area ("scratch pad RAM"): beginning of (internal) DMEM, 256 bytes, requires(!) backup
|
||||
$_TARGETNAME.0 configure -work-area-phys 0x80000000 -work-area-size 256 -work-area-backup 1
|
10
Libs/RiscV/NEORV32/sw/svd/README.md
Normal file
10
Libs/RiscV/NEORV32/sw/svd/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# NEORV32 System View Description (SVD) File
|
||||
|
||||
Manually created from `sw/lib/include/neorv32.h`.
|
||||
|
||||
* Format: CMSIS-SVD
|
||||
* Copyright by ARM Ltd, Apache-2.0 License
|
||||
* Documentation:
|
||||
* https://www.keil.com/pack/doc/CMSIS/SVD/html/index.html
|
||||
* https://github.com/ARM-software/CMSIS
|
||||
* https://github.com/ARM-software/CMSIS_5
|
1189
Libs/RiscV/NEORV32/sw/svd/neorv32.svd
Normal file
1189
Libs/RiscV/NEORV32/sw/svd/neorv32.svd
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user