OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [lib/] [include/] [neorv32_cpu.h] - Diff between revs 11 and 12

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 11 Rev 12
Line 43... Line 43...
#define neorv32_cpu_h
#define neorv32_cpu_h
 
 
// prototypes
// prototypes
int neorv32_cpu_irq_enable(uint8_t irq_sel);
int neorv32_cpu_irq_enable(uint8_t irq_sel);
int neorv32_cpu_irq_disable(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 neorv32_cpu_delay_ms(uint32_t time_ms);
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**
 * Read data from CPU configuration and status register (CSR).
 * Read data from CPU configuration and status register (CSR).
Line 111... Line 116...
  asm volatile ("csrrci zero, mstatus, %0" : : "i" (1 << CPU_MSTATUS_MIE));
  asm volatile ("csrrci zero, mstatus, %0" : : "i" (1 << CPU_MSTATUS_MIE));
}
}
 
 
 
 
/**********************************************************************//**
/**********************************************************************//**
 * Trigger machine software interrupt.
 
 *
 
 * @note The according IRQ has to be enabled via neorv32_cpu_irq_enable(uint8_t irq_sel) and
 
 * global interrupts must be enabled via neorv32_cpu_eint(void) to trigger an IRQ via software.
 
 * The MSI becomes active after 3 clock cycles.
 
 **************************************************************************/
 
inline void __attribute__ ((always_inline)) neorv32_cpu_sw_irq(void) {
 
 
 
  asm volatile ("csrrsi zero, mip, %0" : : "i" (1 << CPU_MIP_MSIP));
 
 
 
  // the MSI becomes active 3 clock cycles afters issueing
 
  asm volatile ("nop"); // these nops are not required, they just make sure the MSI becomes active
 
  asm volatile ("nop"); // before the "real" next operation is executed
 
}
 
 
 
 
 
/**********************************************************************//**
 
 * Trigger breakpoint exception (via EBREAK instruction).
 * Trigger breakpoint exception (via EBREAK instruction).
 **************************************************************************/
 **************************************************************************/
inline void __attribute__ ((always_inline)) neorv32_cpu_breakpoint(void) {
inline void __attribute__ ((always_inline)) neorv32_cpu_breakpoint(void) {
 
 
  asm volatile ("ebreak");
  asm volatile ("ebreak");

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.