URL
https://opencores.org/ocsvn/neorv32/neorv32/trunk
Subversion Repositories neorv32
[/] [neorv32/] [trunk/] [docs/] [datasheet/] [soc.adoc] - Rev 61
Go to most recent revision | Compare with Previous | Blame | View Log
// ####################################################################################################################:sectnums:== NEORV32 Processor (SoC)The NEORV32 Processor is based on the NEORV32 CPU. Together with common peripheralinterfaces and embedded memories it provides a RISC-V-based full-scale microcontroller-like SoC platform.image::neorv32_processor.png[align=center]**Key Features*** _optional_ processor-internal data and instruction memories (<<_data_memory_dmem,**DMEM**>>/<<_instruction_memory_imem,**IMEM**>>) + cache (<<_processor_internal_instruction_cache_icache,**iCACHE**>>)* _optional_ internal bootloader (<<_bootloader_rom_bootrom,**BOOTROM**>>) with UART console & SPI flash boot option* _optional_ machine system timer (<<_machine_system_timer_mtime,**MTIME**>>), RISC-V-compatible* _optional_ two independent universal asynchronous receivers and transmitters (<<_primary_universal_asynchronous_receiver_and_transmitter_uart0,**UART0**>>, <<_secondary_universal_asynchronous_receiver_and_transmitter_uart1,**UART1**>>) with optional hardware flow control (RTS/CTS)* _optional_ 8/16/24/32-bit serial peripheral interface controller (<<_serial_peripheral_interface_controller_spi,**SPI**>>) with 8 dedicated CS lines* _optional_ two wire serial interface controller (<<_two_wire_serial_interface_controller_twi,**TWI**>>), compatible to the I²C standard* _optional_ general purpose parallel IO port (<<_general_purpose_input_and_output_port_gpio,**GPIO**>>), 64xOut, 64xIn* _optional_ 32-bit external bus interface, Wishbone b4 / AXI4-Lite compatible (<<_processor_external_memory_interface_wishbone_axi4_lite,**WISHBONE**>>)* _optional_ 32-bit stream link interface with up to 8 independent links, AXI4-Stream compatible (<<_stream_link_interface_slink,**SLINK**>>)* _optional_ watchdog timer (<<_watchdog_timer_wdt,**WDT**>>)* _optional_ PWM controller with up to 60 channels & 8-bit duty cycle resolution (<<_pulse_width_modulation_controller_pwm,**PWM**>>)* _optional_ ring-oscillator-based true random number generator (<<_true_random_number_generator_trng,**TRNG**>>)* _optional_ custom functions subsystem for custom co-processor extensions (<<_custom_functions_subsystem_cfs,**CFS**>>)* _optional_ NeoPixel(TM)/WS2812-compatible smart LED interface (<<_smart_led_interface_neoled,**NEOLED**>>)* _optional_ external interrupt controller with up to 32 channels (<<_external_interrupt_controller_xirq,**XIRQ**>>)* _optional_ on-chip debugger with JTAG TAP (<<_on_chip_debugger_ocd,**OCD**>>)* system configuration information memory to check HW configuration via software (<<_system_configuration_information_memory_sysinfo,**SYSINFO**>>)<<<// ####################################################################################################################:sectnums:=== Processor Top Entity - SignalsThe following table shows all interface ports of the processor top entity (`rtl/core/neorv32_top.vhd`).The type of all signals is _std_ulogic_ or _std_ulogic_vector_, respectively.[TIP]A wrapper for the NEORV32 Processor setup providing resolved port signals can be found in`rtl/templates/processor/neorv32_ProcessorTop_stdlogic.vhd`.[cols="<3,^2,^2,<11"][options="header",grid="rows"]|=======================| Signal | Width | Dir. | Function4+^| **Global Control**| `clk_i` | 1 | in | global clock line, all registers triggering on rising edge| `rstn_i` | 1 | in | global reset, asynchronous, **low-active**4+^| **JTAG Access Port for <<_on_chip_debugger_ocd>>**| `jtag_trst_i` | 1 | in | TAP reset, low-active (optionalfootnote:[Pull high if not used.])| `jtag_tck_i` | 1 | in | serial clock| `jtag_tdi_i` | 1 | in | serial data input| `jtag_tdo_o` | 1 | out | serial data outputfootnote:[If the on-chip debugger is not implemented (_ON_CHIP_DEBUGGER_EN_ = false) `jtag_tdi_i` is directly forwarded to `jtag_tdo_o` to maintain the JTAG chain.]| `jtag_tms_i` | 1 | in | mode select4+^| **External Bus Interface (<<_processor_external_memory_interface_wishbone_axi4_lite,WISHBONE>>)**| `wb_tag_o` | 3 | out | tag (access type identifier)| `wb_adr_o` | 32 | out | destination address| `wb_dat_i` | 32 | in | write data| `wb_dat_o` | 32 | out | read data| `wb_we_o` | 1 | out | write enable ('0' = read transfer)| `wb_sel_o` | 4 | out | byte enable| `wb_stb_o` | 1 | out | strobe| `wb_cyc_o` | 1 | out | valid cycle| `wb_lock_o`| 1 | out | exclusive access request| `wb_ack_i` | 1 | in | transfer acknowledge| `wb_err_i` | 1 | in | transfer error4+^| **Advanced Memory Control Signals**| `fence_o` | 1 | out | indicates an executed _fence_ instruction| `fencei_o` | 1 | out | indicates an executed _fencei_ instruction4+^| **Stream Link Interface (<<_stream_link_interface_slink,SLINK>>)**| `slink_tx_dat_o` | 8x32 | out | TX link _n_ data| `slink_tx_val_o` | 8 | out | TX link _n_ data valid| `slink_tx_rdy_i` | 8 | in | TX link _n_ allowed to send| `slink_rx_dat_i` | 8x32 | in | RX link _n_ data| `slink_rx_val_i` | 8 | in | RX link _n_ data valid| `slink_rx_rdy_o` | 8 | out | RX link _n_ ready to receive4+^| **General Purpose Inputs & Outputs (<<_general_purpose_input_and_output_port_gpio,GPIO>>)**| `gpio_o` | 64 | out | general purpose parallel output| `gpio_i` | 64 | in | general purpose parallel input4+^| **Primary Universal Asynchronous Receiver/Transmitter (<<_primary_universal_asynchronous_receiver_and_transmitter_uart0,UART0>>)**| `uart0_txd_o` | 1 | out | UART0 serial transmitter| `uart0_rxd_i` | 1 | in | UART0 serial receiver| `uart0_rts_o` | 1 | out | UART0 RX ready to receive new char| `uart0_cts_i` | 1 | in | UART0 TX allowed to start sending4+^| **Primary Universal Asynchronous Receiver/Transmitter (<<_secondary_universal_asynchronous_receiver_and_transmitter_uart1,UART1>>)**| `uart1_txd_o` | 1 | out | UART1 serial transmitter| `uart1_rxd_i` | 1 | in | UART1 serial receiver| `uart1_rts_o` | 1 | out | UART1 RX ready to receive new char| `uart1_cts_i` | 1 | in | UART1 TX allowed to start sending4+^| **Serial Peripheral Interface Controller (<<_serial_peripheral_interface_controller_spi,SPI>>)**| `spi_sck_o` | 1 | out | SPI controller clock line| `spi_sdo_o` | 1 | out | SPI serial data output| `spi_sdi_i` | 1 | in | SPI serial data input| `spi_csn_o` | 8 | out | SPI dedicated chip select (low-active)4+^| **Two-Wire Interface Controller (<<_two_wire_serial_interface_controller_twi,TWI>>)**| `twi_sda_io` | 1 | inout | TWI serial data line| `twi_scl_io` | 1 | inout | TWI serial clock line4+^| **Custom Functions Subsystem (<<_custom_functions_subsystem_cfs,CFS>>)**| `cfs_in_i` | 32 | in | custom CFS input signal conduit| `cfs_out_o` | 32 | out | custom CFS output signal conduit4+^| **Pulse-Width Modulation Channels (<<_pulse_width_modulation_controller_pwm,PWM>>)**| `pwm_o` | 4 | out | pulse-width modulated channels4+^| **Smart LED Interface - NeoPixel(TM) compatible (<<_smart_led_interface_neoled,NEOLED>>)**| `neoled_o` | 1 | out | asynchronous serial data output4+^| **System time (<<_machine_system_timer_mtime,MTIME>>)**| `mtime_i` | 64 | in | machine timer time (to `time[h]` CSRs) from _external MTIME_ unit if the processor-internal _MTIME_ unit is NOT implemented| `mtime_o` | 64 | out | machine timer time from _internal MTIME_ unit if processor-internal _MTIME_ unit IS implemented4+^| **<<_processor_interrupts, External Interrupts>>**| `xirq_i` | 32 | in | external interrupt requests (up to 32 channels)4+^| **<<_processor_interrupts, CPU Interrupts>>**| `nm_irq_i` | 1 | in | non-maskable interrupt| `mtime_irq_i` | 1 | in | machine timer interrupt13 (RISC-V)| `msw_irq_i` | 1 | in | machine software interrupt (RISC-V)| `mext_irq_i` | 1 | in | machine external interrupt (RISC-V)|=======================<<<// ####################################################################################################################:sectnums:=== Processor Top Entity - GenericsThis is a list of all configuration generics of the NEORV32 processor top entity rtl/neorv32_top.vhd.The generic name is shown in orange, followed by the type in printed in black and concluded by the defaultvalue printed in light gray.[TIP]The NEORV32 generics allow to configure the system according to your needs. The generics areused to control implementation of certain CPU extensions and peripheral modules and even allow tooptimize the system for certain design goals like minimal area or maximum performance.[TIP]Privileged software can determine the actual CPU and processor configuration via the `misa` and`mzext` (see <<_machine_trap_setup>> and <<_neorv32_specific_custom_csrs>>) CSRs and via the memory-mapped _SYSINFO_ module (see <<_system_configuration_information_memory_sysinfo>>),respectively.[TIP]If optional modules (like CPU extensions or peripheral devices) are *not enabled* the according circuitry **will not be synthesized at all**.Hence, the disabled modules do not increase area and power requirements and do not impact the timing.[TIP]Not all configuration combinations are valid. The processor RTL code provides sanity checks to inform the userduring synthesis/simulation if an invalid combination has been detected.**Generic Description**The description of each generic provides the following summary:.Generic description[cols="4,4,2"][frame="all",grid="none"]|======| _Generic name_ | _type_ | _default value_3+| _Description_|======<<<// ####################################################################################################################:sectnums:==== GeneralSee section <<_system_configuration_information_memory_sysinfo>> for more information.:sectnums!:===== _CLOCK_FREQUENCY_[cols="4,4,2"][frame="all",grid="none"]|======| **CLOCK_FREQUENCY** | _natural_ | 03+| The clock frequency of the processor's `clk_i` input port in Hertz (Hz).|======:sectnums!:===== _INT_BOOTLOADER_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **INT_BOOTLOADER_EN** | _boolean_ | true3+| Implement the processor-internal boot ROM, pre-initialized with the default bootloader image when _true_.This will also change the processor's boot address from the beginning of the instruction memory address space (default =0x00000000) to the base address of the boot ROM. See section <<_boot_configuration>> for more information.|======:sectnums!:===== _USER_CODE_[cols="4,4,2"][frame="all",grid="none"]|======| **USER_CODE** | _std_ulogic_vector(31 downto 0)_ | x"00000000"3+| Custom user code that can be read by software via the _SYSINFO_ module.|======:sectnums!:===== _HW_THREAD_ID_[cols="4,4,2"][frame="all",grid="none"]|======| **HW_THREAD_ID** | _natural_ | 03+| The hart ID of the CPU. Can be read via the `mhartid` CSR. Hart IDs must be unique within a system.|======:sectnums!:===== _ON_CHIP_DEBUGGER_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **ON_CHIP_DEBUGGER_EN** | _boolean_ | false3+| Implement on-chip debugger (OCD). See chapter <<_on_chip_debugger_ocd>>.|======// ####################################################################################################################:sectnums:==== RISC-V CPU ExtensionsSee section <<_instruction_sets_and_extensions>> for more information.:sectnums!:===== _CPU_EXTENSION_RISCV_A_[cols="4,4,2"][frame="all",grid="none"]|======| **CPU_EXTENSION_RISCV_A** | _boolean_ | false3+| Implement atomic memory access operations when _true_.See section <<_a_atomic_memory_access>>.|======:sectnums!:===== _CPU_EXTENSION_RISCV_C_[cols="4,4,2"][frame="all",grid="none"]|======| **CPU_EXTENSION_RISCV_C** | _boolean_ | false3+| Implement compressed instructions (16-bit) when _true_.See section <<_c_compressed_instructions>>.|======:sectnums!:===== _CPU_EXTENSION_RISCV_E_[cols="4,4,2"][frame="all",grid="none"]|======| **CPU_EXTENSION_RISCV_E** | _boolean_ | false3+| Implement the embedded CPU extension (only implement the first 16 data registers) when _true_.See section <<_e_embedded_cpu>>.|======:sectnums!:===== _CPU_EXTENSION_RISCV_M_[cols="4,4,2"][frame="all",grid="none"]|======| **CPU_EXTENSION_RISCV_M** | _boolean_ | false3+| Implement integer multiplication and division instructions when _true_.See section <<_m_integer_multiplication_and_division>>.|======:sectnums!:===== _CPU_EXTENSION_RISCV_U_[cols="4,4,2"][frame="all",grid="none"]|======| **CPU_EXTENSION_RISCV_U** | _boolean_ | false3+| Implement less-privileged user mode when _true_.See section <<_u_less_privileged_user_mode>>.|======:sectnums!:===== _CPU_EXTENSION_RISCV_Zfinx_[cols="4,4,2"][frame="all",grid="none"]|======| **CPU_EXTENSION_RISCV_Zfinx** | _boolean_ | false3+| Implement the 32-bit single-precision floating-point extension (using integer registers) when _true_.See section <<_zfinx_single_precision_floating_point_operations>>.|======:sectnums!:===== _CPU_EXTENSION_RISCV_Zicsr_[cols="4,4,2"][frame="all",grid="none"]|======| **CPU_EXTENSION_RISCV_Zicsr** | _boolean_ | true3+| Implement the control and status register (CSR) access instructions when true. Note: When this option isdisabled, the complete privileged architecture / trap system will be excluded from synthesis. Hence, no interrupts, no exceptions andno machine information will be available.See section <<_zicsr_control_and_status_register_access_privileged_architecture>>.|======:sectnums!:===== _CPU_EXTENSION_RISCV_Zifencei_[cols="4,4,2"][frame="all",grid="none"]|======| **CPU_EXTENSION_RISCV_Zifencei** | _boolean_ | false3+| Implement the instruction fetch synchronization instruction `fence.i`. For example, this option is requiredfor self-modifying code (and/or for i-cache flushes).See section <<_zifencei_instruction_stream_synchronization>>.|======:sectnums!:===== _CPU_EXTENSION_RISCV_Zmmul_[cols="4,4,2"][frame="all",grid="none"]|======| **CPU_EXTENSION_RISCV_Zmmul** | _boolean_ | false3+| Implement integer multiplication-only instructions when _true_. This is a sub-extensions of the `M` extension.See section <<_zmmul_integer_multiplication>>.|======// ####################################################################################################################:sectnums:==== Extension OptionsSee section <<_instruction_sets_and_extensions>> for more information.:sectnums!:===== _FAST_MUL_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **FAST_MUL_EN** | _boolean_ | false3+| When this generic is enabled, the multiplier of the `M` extension is realized using DSPs blocks instead of aniterative bit-serial approach. This generic is only relevant when the multiplier and divider CPU extension isenabled (<<_cpu_extension_riscv_m>> is _true_).|======:sectnums!:===== _FAST_SHIFT_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **FAST_SHIFT_EN** | _boolean_ | false3+| When this generic is set _true_ the shifter unit of the CPU's ALU is implemented as fast barrel shifter (requiringmore hardware resources). If it is set _false_ the CPU uses a serial shifter that only performs a single bit shift per cycle(small but slow).|======:sectnums!:===== _CPU_CNT_WIDTH_[cols="4,4,2"][frame="all",grid="none"]|======| **CPU_CNT_WIDTH** | _natural_ | 03+| This generic configures the total size of the CPU's `cycle` and `instret` CSRs (low word + high word).The maximum value is 64, the minimal is 0. Seesection <<_machine_counters_and_timers>> for more information. Note: Configurations with <<_cpu_cnt_width>>less than 64 are not RISC-V compliant.|======// ####################################################################################################################:sectnums:==== Physical Memory Protection (PMP)See section <<_pmp_physical_memory_protection>> for more information.:sectnums!:===== _PMP_NUM_REGIONS_[cols="4,4,2"][frame="all",grid="none"]|======| **PMP_NUM_REGIONS** | _natural_ | 03+| Total number of implemented protections regions (0..64). If this generics is zero no physical memoryprotection logic will be implemented at all. Setting <<_pmp_num_regions>>_ > 0 will set the _CSR_MZEXT_PMP_ flagin the <<_mzext>> CSR.|======:sectnums!:===== _PMP_MIN_GRANULARITY_[cols="4,4,2"][frame="all",grid="none"]|======| **PMP_MIN_GRANULARITY** | _natural_ | 64*10243+| Minimal region granularity in bytes. Has to be a power of two. Has to be at least 8 bytes.|======// ####################################################################################################################:sectnums:==== Hardware Performance Monitors (HPM)See section <<_hpm_hardware_performance_monitors>> for more information.:sectnums!:===== _HPM_NUM_CNTS_[cols="4,4,2"][frame="all",grid="none"]|======| **HPM_NUM_CNTS** | _natural_ | 03+| Total number of implemented hardware performance monitor counters (0..29). If this generics is zero nohardware performance monitor logic will be implemented at all. Setting <<_hpm_num_cnts>> > 0 will set the _CSR_MZEXT_HPM_ flagin the <<_mzext>> CSR.|======:sectnums!:===== _HPM_CNT_WIDTH_[cols="4,4,2"][frame="all",grid="none"]|======| **HPM_CNT_WIDTH** | _natural_ | 403+| This generic defines the total LSB-aligned size of each HPM counter (size(`[m]hpmcounter*h`) +size(`[m]hpmcounter*`)). The maximum value is 64, the minimal is 0. If the size is less than 64-bit, theunused MSB-aligned counter bits are hardwired to zero.|======// ####################################################################################################################:sectnums:==== Internal Instruction MemorySee sections <<_address_space>> and <<_instruction_memory_imem>> for more information.:sectnums!:===== _MEM_INT_IMEM_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **MEM_INT_IMEM_EN** | _boolean_ | true3+| Implement processor internal instruction memory (IMEM) when _true_.|======:sectnums!:===== _MEM_INT_IMEM_SIZE_[cols="4,4,2"][frame="all",grid="none"]|======| **MEM_INT_IMEM_SIZE** | _natural_ | 16*10243+| Size in bytes of the processor internal instruction memory (IMEM). Has no effect when _MEM_INT_IMEM_EN_ is _false_.|======// ####################################################################################################################:sectnums:==== Internal Data MemorySee sections <<_address_space>> and <<_data_memory_dmem>> for more information.:sectnums!:===== _MEM_INT_DMEM_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **MEM_INT_DMEM_EN** | _boolean_ | true3+| Implement processor internal data memory (DMEM) when _true_.|======:sectnums!:===== _MEM_INT_DMEM_SIZE_[cols="4,4,2"][frame="all",grid="none"]|======| **MEM_INT_DMEM_SIZE** | _natural_ | 8*10243+| Size in bytes of the processor-internal data memory (DMEM). Has no effect when _MEM_INT_DMEM_EN_ is _false_.|======// ####################################################################################################################:sectnums:==== Internal Cache MemorySee section <<_processor_internal_instruction_cache_icache>> for more information.:sectnums!:===== _ICACHE_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **ICACHE_EN** | _boolean_ | false3+| Implement processor internal instruction cache when _true_.|======:sectnums!:===== _ICACHE_NUM_BLOCK_[cols="4,4,2"][frame="all",grid="none"]|======| **ICACHE_NUM_BLOCKS** | _natural_ | 43+| Number of blocks (cache "pages" or "lines") in the instruction cache. Has to be a power of two. Has noeffect when _ICACHE_DMEM_EN_ is false.|======:sectnums!:===== _ICACHE_BLOCK_SIZE_[cols="4,4,2"][frame="all",grid="none"]|======| **ICACHE_BLOCK_SIZE** | _natural_ | 643+| Size in bytes of each block in the instruction cache. Has to be a power of two. Has no effect when_ICACHE_EN_ is _false_.|======:sectnums!:===== _ICACHE_ASSOCIATIVITY_[cols="4,4,2"][frame="all",grid="none"]|======| **ICACHE_ASSOCIATIVITY** | _natural_ | 13+| Associativity (= number of sets) of the instruction cache. Has to be a power of two. Allowed configurations:`1` = 1 set, direct mapped; `2` = 2-way set-associative. Has no effect when _ICACHE_EN_ is _false_.|======// ####################################################################################################################:sectnums:==== External Memory InterfaceSee sections <<_address_space>> and <<_processor_external_memory_interface_wishbone_axi4_lite>> for more information.:sectnums!:===== _MEM_EXT_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **MEM_EXT_EN** | _boolean_ | false3+| Implement external bus interface (WISHBONE) when _true_.|======:sectnums!:===== _MEM_EXT_TIMEOUT_[cols="4,4,2"][frame="all",grid="none"]|======| **MEM_EXT_TIMEOUT** | _natural_ | 2553+| Clock cycles after which a pending external bus access will auto-terminate and raise a bus fault exception. Set to 0 to disable auto-timeout.|======// ####################################################################################################################:sectnums:==== Stream Link InterfaceSee section <<_stream_link_interface_slink>> for more information.:sectnums!:===== _SLINK_NUM_TX_[cols="4,4,2"][frame="all",grid="none"]|======| **SLINK_NUM_TX** | _natural_ | 03+| Number of TX (send) links to implement. Valid values are 0..8.|======:sectnums!:===== _SLINK_NUM_RX_[cols="4,4,2"][frame="all",grid="none"]|======| **SLINK_NUM_RX** | _natural_ | 03+| Number of RX (receive) links to implement. Valid values are 0..8.|======:sectnums!:===== _SLINK_TX_FIFO_[cols="4,4,2"][frame="all",grid="none"]|======| **SLINK_TX_FIFO** | _natural_ | 13+| Internal FIFO depth for _all_ implemented TX links. Valid values are 1..32k and have to be a power of two.|======:sectnums!:===== _SLINK_RX_FIFO_[cols="4,4,2"][frame="all",grid="none"]|======| **SLINK_RX_FIFO** | _natural_ | 13+| Internal FIFO depth for _all_ implemented RX links. Valid values are 1..32k and have to be a power of two.|======// ####################################################################################################################:sectnums:==== External Interrupt ControllerSee section <<_external_interrupt_controller_xirq>> for more information.:sectnums!:===== _XIRQ_NUM_CH_[cols="4,4,2"][frame="all",grid="none"]|======| **XIRQ_NUM_CH** | _natural_ | 03+| Number of external interrupt channels o implement. Valid values are 0..32.|======:sectnums!:===== _XIRQ_TRIGGER_TYPE_[cols="4,4,2"][frame="all",grid="none"]|======| **XIRQ_TRIGGER_TYPE** | _std_ulogic_vector(31 downto 0)_ | 0xFFFFFFFF3+| Interrupt trigger type configuration (one bit for each IRQ channel): `0` = level-triggered, '1' = edge triggered._XIRQ_TRIGGER_POLARITY_ generic is used to specify the actual level (high/low) or edge (falling/rising).|======:sectnums!:===== _XIRQ_TRIGGER_POLARITY_[cols="4,4,2"][frame="all",grid="none"]|======| **XIRQ_TRIGGER_POLARITY** | _std_ulogic_vector(31 downto 0)_ | 0xFFFFFFFF3+| Interrupt trigger polarity configuration (one bit for each IRQ channel): `0` = low-level/falling-edge,'1' = high-level/rising-edge. _XIRQ_TRIGGER_TYPE_ generic is used to specify the actual type (level or edge).|======// ####################################################################################################################:sectnums:==== Processor Peripheral/IO ModulesSee section <<_processor_internal_modules>> for more information.:sectnums!:===== _IO_GPIO_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_GPIO_EN** | _boolean_ | true3+| Implement general purpose input/output port unit (GPIO) when _true_.See section <<_general_purpose_input_and_output_port_gpio>> for more information.|======:sectnums!:===== _IO_MTIME_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_MTIME_EN** | _boolean_ | true3+| Implement machine system timer (MTIME) when _true_.See section <<_machine_system_timer_mtime>> for more information.|======:sectnums!:===== _IO_UART0_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_UART0_EN** | _boolean_ | true3+| Implement primary universal asynchronous receiver/transmitter (UART0) when _true_.See section <<_primary_universal_asynchronous_receiver_and_transmitter_uart0>> formore information.|======:sectnums!:===== _IO_UART1_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_UART1_EN** | _boolean_ | true3+| Implement secondary universal asynchronous receiver/transmitter (UART1) when _true_.See section <<_secondary_universal_asynchronous_receiver_and_transmitter_uart1>> for more information.|======:sectnums!:===== _IO_SPI_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_SPI_EN** | _boolean_ | true3+| Implement serial peripheral interface controller (SPI) when _true_.See section <<_serial_peripheral_interface_controller_spi>> for more information.|======:sectnums!:===== _IO_TWI_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_TWI_EN** | _boolean_ | true3+| Implement two-wire interface controller (TWI) when _true_.See section <<_two_wire_serial_interface_controller_twi>> formore information.|======:sectnums!:===== _IO_PWM_NUM_CH_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_PWM_NUM_CH** | _natural_ | 43+| Number of pulse-width modulation (PWM) channels (0..60) to implement. The PWM controller is _not_ implemented if zero.See section <<_pulse_width_modulation_controller_pwm>> for more information.|======:sectnums!:===== _IO_WDT_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_WDT_EN** | _boolean_ | true3+| Implement watchdog timer (WDT) when _true_. See section <<_watchdog_timer_wdt>> for moreinformation.|======:sectnums!:===== _IO_TRNG_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_TRNG_EN** | _boolean_ | false3+| Implement true-random number generator (TRNG) when _true_. See section <<_true_random_number_generator_trng>> for more information.|======:sectnums!:===== _IO_CFS_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_CFS_EN** | _boolean_ | false3+| Implement custom functions subsystem (CFS) when _true_. See section <<_custom_functions_subsystem_cfs>> for more information.|======:sectnums!:===== _IO_CFS_CONFIG_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_CFS_CONFIG** | _std_ulogic_vector(31 downto 0)_ | 0x"00000000"3+| This is a "conduit" generic that can be used to pass user-defined CFS implementation flags to the customfunctions subsystem entity. See section <<_custom_functions_subsystem_cfs>> for more information.|======:sectnums!:===== _IO_CFS_IN_SIZE_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_CFS_IN_SIZE** | _positive_ | 323+| Defines the size of the CFS input signal conduit (`cfs_in_i`). See section <<_custom_functions_subsystem_cfs>> for more information.|======:sectnums!:===== _IO_CFS_OUT_SIZE_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_CFS_OUT_SIZE** | _positive_ | 323+| Defines the size of the CFS output signal conduit (`cfs_out_o`). See section <<_custom_functions_subsystem_cfs>> for more information.|======:sectnums!:===== _IO_NEOLED_EN_[cols="4,4,2"][frame="all",grid="none"]|======| **IO_NEOLED_EN** | _boolean_ | true3+| Implement smart LED interface (WS2812 / NeoPixel(TM)-compatible) (NEOLED) when _true_.See section <<_smart_led_interface_neoled>> for more information.|======<<<// ####################################################################################################################:sectnums:=== Processor InterruptsThe NEORV32 Processor provides several interrupt request signals (IRQs) for custom platform use.:sectnums:==== RISC-V Standard InterruptsThe processor setup features the standard RISC-V interrupt lines for "machine timer interrupt", "machinesoftware interrupt" and "machine external interrupt". Their usage is defined by the RISC-V privileged architecturespecifications. However, bare-metal system can also repurpose these interrupts. See CPU section<<_traps_exceptions_and_interrupts>> for more information.[cols="<3,^2,<11"][options="header",grid="rows"]|=======================| Top signal | Width | Description| `mtime_irq_i` | 1 | Machine timer interrupt from _processor-external_ MTIME unit. This IRQ is only available if the processor-internal MTIME unit is not used (<<_io_mtime_en>> = false).| `msw_irq_i` | 1 | Machine software interrupt. This interrupt is used for inter-processor interrupts in multi-core systems. However, it can also be used for any custom purpose.| `mext_irq_i` | 1 | Machine external interrupt. This interrupt is used for any processor-external interrupt source (like a platform interrupt controller).|=======================[NOTE]These IRQs trigger on high-level.:sectnums:==== Non-Maskable Interrupt[cols="<3,^2,<11"][options="header",grid="rows"]|=======================| Top signal | Width | Description| `nm_irq_i` | 1 | Non-maskable interrupt.|=======================The processor features a single non-maskable interrupt source via the `nm_irq_i` topentity signal that can be used to signal _critical system conditions_. This interrupt source _cannot_ be masked/disabled.See CPU section <<_traps_exceptions_and_interrupts>> for more information.[NOTE]This IRQ triggers on high-level.:sectnums:==== Platform External Interrupts[cols="<3,^2,<11"][options="header",grid="rows"]|=======================| Top signal | Width | Description| `xirq_i` | up to 32 | External platform interrupts (user-defined).|=======================The processor provides an optional interrupt controller for up to 32 user-defined external interrupts(see section <<_external_interrupt_controller_xirq>>). These external IRQs are mapped to a _single_ CPUfast interrupt request so a software handler is required to differentiate / prioritize these interrupts.[NOTE]The trigger for these interrupt can be defines via generics. See section<<_external_interrupt_controller_xirq>> for more information.:sectnums:==== NEORV32-Specific Fast Interrupt RequestsAs part of the custom/NEORV32-specific CPU extensions, the CPU features 16 fast interrupt request signals(`FIRQ0` – `FIRQ15`). These are used for _processor-internal_ modules only (for example for the communicationinterfaces to signal "available incoming data" or "ready to send new data").The mapping of the 16 FIRQ channels is shown in the following table (the channel number also corresponds tothe according FIRQ priority; 0 = highest, 15 = lowest):.NEORV32 fast interrupt channel mapping[cols="^1,<2,<7"][options="header",grid="rows"]|=======================| Channel | Source | Description| 0 | <<_watchdog_timer_wdt,WDT>> | watchdog timeout interrupt| 1 | <<_custom_functions_subsystem_cfs,CFS>> | custom functions subsystem (CFS) interrupt (user-defined)| 2 | <<_primary_universal_asynchronous_receiver_and_transmitter_uart0,UART0>> | UART0 data received interrupt (RX complete)| 3 | <<_primary_universal_asynchronous_receiver_and_transmitter_uart0,UART0>> | UART0 sending done interrupt (TX complete)| 4 | <<_secondary_universal_asynchronous_receiver_and_transmitter_uart1,UART1>> | UART1 data received interrupt (RX complete)| 5 | <<_secondary_universal_asynchronous_receiver_and_transmitter_uart1,UART1>> | UART1 sending done interrupt (TX complete)| 6 | <<_serial_peripheral_interface_controller_spi,SPI>> | SPI transmission done interrupt| 7 | <<_two_wire_serial_interface_controller_twi,TWI>> | TWI transmission done interrupt| 8 | <<_external_interrupt_controller_xirq,XIRQ>> | External interrupt controller interrupt| 9 | <<_smart_led_interface_neoled,NEOLED>> | NEOLED buffer TX empty / not full interrupt| 10 | <<_stream_link_interface_slink,SLINK>> | RX data received| 11 | <<_stream_link_interface_slink,SLINK>> | TX data send| 12:15 | - | _reserved_, cannot fire|=======================<<<// ####################################################################################################################:sectnums:=== Address SpaceThe NEORV32 Processor provides 32-bit physical addresses accessing up to 4GB of address space.By default, this address space is divided into four main regions:1. **Instruction address space** – for instructions (=code) and constants. A configurable section of this address space is used byinternal and/or external _instruction memory_ (IMEM).2. **Data address space** – for application runtime data (heap, stack, etc.). A configurable section of this address space is used byinternal and/or external _data memory_ (DMEM).3. **Bootloader address space**. A _fixed_ section of this address space is used byinternal _bootloader memory_ (BOOTLDROM).4. **IO/peripheral address space** – for the processor-internal IO/peripheral devices (e.g., UART).[TIP]These four memory regions are handled by the linker when compiling a NEORV32 executable.See section <<_executable_image_format>> for more information..NEORV32 processor - address space (default configuration)image::address_space.png[900]:sectnums:==== CPU Data and Instruction AccessThe CPU can access all of the 4GB address space from the instruction fetch interface (**I**) and also from thedata access interface (**D**). These two CPU interfaces are multiplexed by a simple bus switch(`rtl/core/neorv32_busswitch.vhd`) into a _single_ processor-internal bus. All processor-internalmemories, peripherals and also the external memory interface are connected to this bus. Hence, both CPUinterfaces (instruction fetch & data access) have access to the same (**identical**) address space making thesetup a modified von-Neumann architecture..Processor-internal bus architectureimage::neorv32_bus.png[1300][NOTE]The internal processor bus might appear as bottleneck. In order to reduce traffic jam on this bus(when instruction fetch and data interface access the bus at the same time) the instruction fetch ofthe CPU is equipped with a prefetch buffer. Instruction fetches can be further buffered using the i-cache.Furthermore, data accesses (loads and stores) have higher priority than instruction fetchaccesses.[IMPORTANT]Please note that all processor-internal components including the peripheral/IO devices can also beaccessed from programs running in less-privileged user mode. For example, if the system relies ona periodic interrupt from the _MTIME_ timer unit, user-level programs could alter the _MTIME_configuration corrupting this interrupt. This kind of security issues can be compensated using thePMP system (see <<_machine_physical_memory_protection>>).:sectnums:==== Address Space LayoutThe general address space layout consists of two main configuration constants: `ispace_base_c` definingthe base address of the _instruction memory address space_ and `dspace_base_c` defining the base address ofthe _data memory address space_. Both constants are defined in the NEORV32 VHDL package file`rtl/core/neorv32_package.vhd`:[source,vhdl]------ Architecture Configuration ------------------------------------------------------ ----------------------------------------------------------------------------------constant ispace_base_c : std_ulogic_vector(31 downto 0) := x"00000000";constant dspace_base_c : std_ulogic_vector(31 downto 0) := x"80000000";----The default configuration assumes the _instruction memory address space_ starting at address _0x00000000_and the _data memory address space_ starting at _0x80000000_. Both values can be modified for a specificsetup and the address space may overlap or can be completely identical. Make sure that both base addressesare _aligned_ to a 4-byte boundary.[NOTE]The base address of the internal bootloader (at _0xFFFF0000_) and the internal IO region (at _0xFFFFFE00_) forperipheral devices are also defined in the package and are fixed. These address regions cannot not be used for otherapplications – even if the bootloader or all IO devices are not implemented - without modifying the core'shardware sources.:sectnums:==== Physical Memory AttributesThe processor setup defines fixed attributes for the four processor-internal address space regions.Accessing a memory region in a way that violates any of these attributes will raise an accordingaccess exception..* `r` – read access (from CPU data access interface, e.g. via "load")* `w` – write access (from CPU data access interface, e.g. via "store")* `x` – execute access (from CPU instruction fetch interface)* `a` – atomic access (from CPU data access interface)* `8` – byte (8-bit)-accessible (when writing)* `16` – half-word (16-bit)-accessible (when writing)* `32` – word (32-bit)-accessible (when writing)[NOTE]Read accesses (i.e. loads) can always access data in word, half-word and byte quantities (requiring an accordingly aligned address).[cols="^1,^2,^2,^3,^2"][options="header",grid="rows"]|=======================| # | Region | Base address | Size | Attributes| 4 | IO/peripheral devices | 0xfffffe00 | 512 bytes | `r/w/a/32`| 3 | bootloader ROM | 0xffff0000 | up to 32kB| `r/x/a`| 2 | DMEM | 0x80000000 | up to 2GB (-64kB) | `r/w/x/a/8/16/32`| 1 | IMEM | 0x00000000 | up to 2GB | `r/w/x/a/8/16/32`|=======================[TIP]The following table shows the provided physical memory attributes of each region. Additional attributes (for examplecontrolling certain right for specific address space regions) can be provided using the RISC-V <<_machine_physical_memory_protection>> extension.:sectnums:==== Memory ConfigurationThe NEORV32 Processor was designed to provide maximum flexibility for the memory configuration.The processor can populate the _instruction address space_ and/or the _data address space_ with **internal memories**for instructions (IMEM) and data (DMEM). Processor **external memories** can be used as an _alternative_ or even _in combination_ withthe internal ones. The figure below show some exemplary memory configurations..Exemplary memory configurationsimage::neorv32_memory_configurations.png[800]:sectnums!:===== Internal MemoriesThe processor-internal memories (<<_instruction_memory_imem>> and <<_data_memory_dmem>>) are enabled (=implemented)via the <<_mem_int_imem_en>> and <<_mem_int_dmem_en>> generics. Their sizes are configures via the according<<_mem_int_imem_size>> and <<_mem_int_dmem_size>> generics.If the processor-internal IMEM is implemented, it is located right at the base address of the instructionaddress space (default `ispace_base_c` = _0x00000000_). Vice versa, the processor-internal data memory islocated right at the beginning of the data address space (default `dspace_base_c` = _0x80000000_) whenimplemented.[TIP]The default processor setup uses only _internal_ memories.[NOTE]If the IMEM (internal or external) is less than the (default) maximum size (2GB), there isa "dead address space" between it and the DMEM. This provides an additional safety featuresince data corrupting scenarios like stack overflow cannot directly corrupt the content of the IMEM:any access to the "dead address space" in between will raise an exception that can be caughtby the runtime environment.:sectnums!:===== External MemoriesIf external memories (or further IP modules) shall be connected via the _processor's external bus interface_,the interface has to be enabled via <<_mem_ext_en>> generic (=_true_). More information regarding this interface can befound in section <<_processor_external_memory_interface_wishbone_axi4_lite>>.Any CPU access (data or instructions), which does not fulfill _at least one_ of the following conditions, is forwardedvia the processor's bus interface to external components:* access to the processor-internal IMEM and processor-internal IMEM is implemented* access to the processor-internal DMEM and processor-internal DMEM is implemented* access to the bootloader ROM and beyond → addresses >= _BOOTROM_BASE_ (default 0xFFFF0000) will never be forwarded to the external memory interfaceIf no (or not all) processor-internal memories are implemented, the according base addresses are mapped to external memories.For example, if the processor-internal IMEM is not implemented (<<_mem_int_imem_en>> = _false_), the processor will forwardany access to the instruction address space (starting at `ispace_base_c`) via the external bus interface to the externalmemory system.[NOTE]If the external interface is deactivated, any access exceeding the internal memory address space (instruction, data, bootloader) orthe internal peripheral address space will trigger a bus access fault exception.:sectnums:==== Boot ConfigurationDue to the flexible memory configuration concept, the NEORV32 Processor provides several different boot concepts.The figure below shows the exemplary concepts for the two most common boot scenarios..NEORV32 boot configurationsimage::neorv32_boot_configurations.png[800][NOTE]The configuration of internal or external data memory (DMEM; <<_mem_int_dmem_en>> = _true_ / _false_) is not furtherrelevant for the boot configuration itself. Hence, it is not further illustrated here.There are two general boot scenarios: _Indirect Boot_ (1a and 1b) and _Direct Boot_ (2a and 2b) configured via the<<_int_bootloader_en>> generic If this generic is set **true** the _indirect_ boot scenario is used. This is also thedefault boot configuration of the processor. If <<_int_bootloader_en>> is set **false** the _direct_ boot scenario is used.[NOTE]Please note that the provided boot scenarios are just exemplary setups that (should) fit most common requirements.Much more sophisticated boot scenarios are possible by combining internal and external memories. For example, the defaultinternal bootloader could be used as first-level bootloader that loads (from extern SPI flash) a second-level bootloaderthat is placed and execute in internal IMEM. This second-level bootloader could then fetch the actual application andstore it to external _data_ memory and transfers CPU control to that.:sectnums!:===== Indirect BootThe _indirect_ boot scenarios **1a** and **1b** use the processor-internal <<_bootloader>>. This general setup is enabledby setting the <<_int_bootloader_en>> generic to true, which will implement the processor-internal <<_bootloader_rom_bootrom>>.This read-only memory is pre-initialized during synthesis with the default bootloader firmware.The bootloader provides several options to upload an executable (via UART or from external SPI flash) and store it tothe _instruction address space_ so the CPU can execute it. Boot scenario **1a** uses the processor-internal IMEM(<<_mem_int_imem_en>> = _true_). This scenario implements the internal <<_instruction_memory_imem>> as non-initializedRAM so the bootloader can write the actual executable to it.Boot scenario **1b** uses a processor-external IMEM (<<_mem_int_imem_en>> = _false_) that is connected via the processor'sbus interface. In this scenario the internal <<_instruction_memory_imem>> is not implemented at all and the bootloader willwrite the executable to the processor-external memory.:sectnums!:===== Direct BootThe _direct_ boot scenarios **2a** and **2b** do not use the processor-internal bootloader. Hence, the <<_int_bootloader_en>>generic is set _false_. In this configuration the <<_bootloader_rom_bootrom>> is not implemented at all and the CPU willdirectly begin executing code from the instruction address space after reset. A "pre-initialization mechanism is requiredin order to provide an executable _in_ memory.Boot scenario **2a** uses the processor-internal IMEM (<<_mem_int_imem_en>> = _true_) that is implemented as _read-only memory_in this scenario. It is pre-initialized (by the bitstream) with the actual application executable.In contrast, boot scenario **2b** uses a processor-external IMEM (<<_mem_int_imem_en>> = _false_). In this scenario thesystem designer is responsible for providing a initialized external memory that contains the actual application to be executed.<<<// ####################################################################################################################:sectnums:=== Processor-Internal ModulesBasically, the processor is a SoC consisting of the NEORV32 CPU, peripheral/IO devices, embeddedmemories, an external memory interface and a bus infrastructure to interconnect all units. Additionally, thesystem implements an internal reset generator and a global clock generator/divider.**Internal Reset Generator**Most processor-internal modules – except for the CPU and the watchdog timer – do not have a dedicatedreset signal. However, all devices can be reset by software by clearing the corresponding unit's controlregister. The automatically included application start-up code (`crt0.S`) will perform a software-reset of allmodules to ensure a clean system reset state.The hardware reset signal of the processor can either betriggered via the external reset pin (`rstn_i`, low-active) or by the internal watchdog timer (if implemented).Before the external reset signal is applied to the system, it is extended to have a minimal duration of eightclock cycles.**Internal Clock Divider**An internal clock divider generates 8 clock signals derived from the processor's main clock input `clk_i`.These derived clock signals are not actual _clock signals_. Instead, they are derived from a simple counter andare used as "clock enable" signal by the different processor modules. Thus, the whole design operates usingonly the main clock signal (single clock domain). Some of the processor peripherals like the Watchdog or theUARTs can select one of the derived clock enabled signals for their internal operation. If none of theconnected modules require a clock signal from the divider, it is automatically deactivated to reduce dynamicpower.The peripheral devices, which feature a time-based configuration, provide a three-bit prescaler select in theiraccording control register to select one out of the eight available clocks. The mapping of the prescaler selectbits to the actually obtained clock are shown in the table below. Here, f represents the processor main clockfrom the top entity's `clk_i` signal.[cols="<3,^1,^1,^1,^1,^1,^1,^1,^1"][grid="rows"]|=======================| Prescaler bits: | `0b000` | `0b001` | `0b010` | `0b011` | `0b100` | `0b101` | `0b110` | `0b111`| Resulting clock: | _f/2_ | _f/4_ | _f/8_ | _f/64_ | _f/128_ | _f/1024_| _f/2048_| _f/4096_|=======================**Peripheral / IO Devices**The processor-internal peripheral/IO devices are located at the end of the 32-bit address space at baseaddress _0xFFFFFE00_. A region of 512 bytes is reserved for this devices. Hence, all peripheral/IO devices areaccessed using a memory-mapped scheme. A special linker script as well as the NEORV32 core softwarelibrary abstract the specific memory layout for the user.[IMPORTANT]When accessing an IO device that hast not been implemented (via the according _IO_x_EN_ generic), aload/store access fault exception is triggered.[IMPORTANT]The peripheral/IO devices can only be written in full-word mode (i.e. 32-bit). Byte or half-word(8/16-bit) writes will trigger a store access fault exception. Read accesses are not size constrained.Processor-internal memories as well as modules connected to the external memory interface can stillbe written with a byte-wide granularity.[TIP]You should use the provided core software library to interact with the peripheral devices. Thisprevents incompatibilities with future versions, since the hardware driver functions handle all theregister and register bit accesses.[TIP]Most of the IO devices do not have a hardware reset. Instead, the devices are reset via software bywriting zero to the unit's control register. A general software-based reset of all devices is done by theapplication start-up code `crt0.S`.**Nomenclature for the Peripheral / IO Devices Listing**Each peripheral device chapter features a register map showing accessible control and data registers of theaccording device including the implemented control and status bits. You can directly interact with theseregisters/bits via the provided _C-code defines_. These defines are set in the main processor core libraryinclude file `sw/lib/include/neorv32.h`. The registers and/or register bits, which can be accesseddirectly using plain C-code, are marked with a "[C]".Not all registers or register bits can be arbitrarily read/written. The following read/write access types areavailable:* `r/w` registers / bits can be read and written* `r/-` registers / bits are read-only; any write access to them has no effect* `-/w` these registers / bits are write-only; they auto-clear in the next cycle and are always read as zero[TIP]Bits / registers that are not listed in the register map tables are not (yet) implemented. These registers/ bits are always read as zero. A write access to them has no effect, but user programs should onlywrite zero to them to keep compatible with future extension.[TIP]When writing to read-only registers, the access is nevertheless acknowledged, but no actual data iswritten. When reading data from a write-only register the result is undefined.include::soc_imem.adoc[]include::soc_dmem.adoc[]include::soc_bootrom.adoc[]include::soc_icache.adoc[]include::soc_wishbone.adoc[]include::soc_slink.adoc[]include::soc_gpio.adoc[]include::soc_wdt.adoc[]include::soc_mtime.adoc[]include::soc_uart.adoc[]include::soc_spi.adoc[]include::soc_twi.adoc[]include::soc_pwm.adoc[]include::soc_trng.adoc[]include::soc_cfs.adoc[]include::soc_neoled.adoc[]include::soc_xirq.adoc[]include::soc_sysinfo.adoc[]
Go to most recent revision | Compare with Previous | Blame | View Log
