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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [lib/] [source/] [neorv32_cpu.c] - Diff between revs 65 and 66

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

Rev 65 Rev 66
Line 610... Line 610...
 * @return Returns number of available HPM counters (0..29).
 * @return Returns number of available HPM counters (0..29).
 **************************************************************************/
 **************************************************************************/
uint32_t neorv32_cpu_hpm_get_counters(void) {
uint32_t neorv32_cpu_hpm_get_counters(void) {
 
 
  // HPMs implemented at all?
  // HPMs implemented at all?
  if ((NEORV32_SYSINFO.CPU & (1<<SYSINFO_CPU_HPM)) == 0) {
  if ((NEORV32_SYSINFO.CPU & (1<<SYSINFO_CPU_ZIHPM)) == 0) {
    return 0;
    return 0;
  }
  }
 
 
  // inhibit all HPM counters
  // inhibit all HPM counters
  uint32_t tmp = neorv32_cpu_csr_read(CSR_MCOUNTINHIBIT);
  uint32_t tmp = neorv32_cpu_csr_read(CSR_MCOUNTINHIBIT);
Line 693... Line 693...
 * @return Size of HPM counter bits (1-64, 0 if not implemented at all).
 * @return Size of HPM counter bits (1-64, 0 if not implemented at all).
 **************************************************************************/
 **************************************************************************/
uint32_t neorv32_cpu_hpm_get_size(void) {
uint32_t neorv32_cpu_hpm_get_size(void) {
 
 
  // HPMs implemented at all?
  // HPMs implemented at all?
  if ((NEORV32_SYSINFO.CPU & (1<<SYSINFO_CPU_HPM)) == 0) {
  if ((NEORV32_SYSINFO.CPU & (1<<SYSINFO_CPU_ZIHPM)) == 0) {
    return 0;
    return 0;
  }
  }
 
 
  // inhibt auto-update
  // inhibt auto-update
  asm volatile ("csrwi %[addr], %[imm]" : : [addr] "i" (CSR_MCOUNTINHIBIT), [imm] "i" (1<<CSR_MCOUNTINHIBIT_HPM3));
  asm volatile ("csrwi %[addr], %[imm]" : : [addr] "i" (CSR_MCOUNTINHIBIT), [imm] "i" (1<<CSR_MCOUNTINHIBIT_HPM3));

powered by: WebSVN 2.1.0

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