NEORV32 - Software Framework Documentation
Loading...
Searching...
No Matches
Functions
neorv32_cpu.c File Reference

CPU Core Functions HW driver source file. More...

#include "neorv32.h"
#include "neorv32_cpu.h"

Functions

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)
 
void neorv32_cpu_delay_ms (uint32_t time_ms)
 
uint32_t neorv32_cpu_get_clk_from_prsc (int prsc)
 
uint32_t neorv32_cpu_pmp_get_num_regions (void)
 
uint32_t neorv32_cpu_pmp_get_granularity (void)
 
int neorv32_cpu_pmp_configure_region (int index, uint32_t addr, uint8_t config)
 
uint32_t neorv32_cpu_hpm_get_num_counters (void)
 
uint32_t neorv32_cpu_hpm_get_size (void)
 
void neorv32_cpu_goto_user_mode (void)
 

Detailed Description

CPU Core Functions HW driver source file.

Function Documentation

◆ neorv32_cpu_delay_ms()

void neorv32_cpu_delay_ms ( uint32_t time_ms)

Delay function using busy wait.

Note
This function uses the cycle CPU counter if available. Otherwise the MTIME system timer is used if available. A simple loop is used as alternative fall-back (imprecise!).
Parameters
[in]time_msTime in ms to wait (unsigned 32-bit).

◆ neorv32_cpu_get_clk_from_prsc()

uint32_t neorv32_cpu_get_clk_from_prsc ( int prsc)

Get actual clocking frequency from prescaler select NEORV32_CLOCK_PRSC_enum

Parameters
[in]prscPrescaler select NEORV32_CLOCK_PRSC_enum. return Actual raw clock frequency in Hz.

◆ neorv32_cpu_get_cycle()

uint64_t neorv32_cpu_get_cycle ( void )

Unavailable extensions warnings. Get cycle counter from cycle[h].

Returns
Current cycle counter (64 bit).

◆ neorv32_cpu_get_instret()

uint64_t neorv32_cpu_get_instret ( void )

Get retired instructions counter from instret[h].

Returns
Current instructions counter (64 bit).

◆ neorv32_cpu_goto_user_mode()

void neorv32_cpu_goto_user_mode ( void )

Switch from privilege mode MACHINE to privilege mode USER.

◆ neorv32_cpu_hpm_get_num_counters()

uint32_t neorv32_cpu_hpm_get_num_counters ( void )

Hardware performance monitors (HPM): Get number of available HPM counters.

Returns
Returns number of available HPM counters.

◆ neorv32_cpu_hpm_get_size()

uint32_t neorv32_cpu_hpm_get_size ( void )

Hardware performance monitors (HPM): Get total counter width

Warning
This function overrides the mhpmcounter3[h] CSRs.
Returns
Size of HPM counters (1-64, 0 if not implemented at all).

◆ neorv32_cpu_pmp_configure_region()

int neorv32_cpu_pmp_configure_region ( int index,
uint32_t addr,
uint8_t config )

Physical memory protection (PMP): Configure region.

Note
This function requires the PMP CPU extension.
Warning
This function expects a WORD address!
Parameters
[in]indexRegion number (index, 0..PMP_NUM_REGIONS-1).
[in]addrRegion address (word address!).
[in]configRegion configuration byte (see NEORV32_PMPCFG_ATTRIBUTES_enum).
Returns
Returns 0 on success, !=0 on failure.

◆ neorv32_cpu_pmp_get_granularity()

uint32_t neorv32_cpu_pmp_get_granularity ( void )

Physical memory protection (PMP): Get minimal region size (granularity).

Warning
This function overrides PMPCFG0[0] and PMPADDR0 CSRs!
Note
This function requires the PMP CPU extension.
Returns
Returns minimal region size in bytes. Returns zero on error.

◆ neorv32_cpu_pmp_get_num_regions()

uint32_t neorv32_cpu_pmp_get_num_regions ( void )

Physical memory protection (PMP): Get number of available regions.

Warning
This function overrides all available PMPCFG* CSRs!
Note
This function requires the PMP CPU extension.
Returns
Returns number of available PMP regions.

◆ neorv32_cpu_set_mcycle()

void neorv32_cpu_set_mcycle ( uint64_t value)

Set machine cycle counter mcycle[h].

Parameters
[in]valueNew value for mcycle[h] CSR (64-bit).

◆ neorv32_cpu_set_minstret()

void neorv32_cpu_set_minstret ( uint64_t value)

Set machine retired instructions counter minstret[h].

Parameters
[in]valueNew value for mcycle[h] CSR (64-bit).