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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [example/] [processor_check/] [main.c] - Diff between revs 61 and 62

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

Rev 61 Rev 62
Line 335... Line 335...
  tmp_a = neorv32_cpu_csr_read(CSR_MCOUNTEREN);
  tmp_a = neorv32_cpu_csr_read(CSR_MCOUNTEREN);
  tmp_a |= (1<<CSR_MCOUNTEREN_CY); // re-allow access right
  tmp_a |= (1<<CSR_MCOUNTEREN_CY); // re-allow access right
  neorv32_cpu_csr_write(CSR_MCOUNTEREN, tmp_a);
  neorv32_cpu_csr_write(CSR_MCOUNTEREN, tmp_a);
 
 
 
 
 
/*
 
  // ----------------------------------------------------------
 
  // Execute DRET in M-mode (has to trap!)
 
  // ----------------------------------------------------------
 
  neorv32_cpu_csr_write(CSR_MCAUSE, 0);
 
  PRINT_STANDARD("[%i] DRET in M-mode: ", cnt_test);
 
 
 
  // skip if U-mode is not implemented
 
  if (neorv32_cpu_csr_read(CSR_MISA) & (1<<CSR_MISA_U)) {
 
 
 
    cnt_test++;
 
 
 
    asm volatile("dret");
 
 
 
    if (neorv32_cpu_csr_read(CSR_MCAUSE) == TRAP_CODE_I_ILLEGAL) {
 
      test_ok();
 
    }
 
    else {
 
      test_fail();
 
    }
 
 
 
  }
 
  else {
 
    PRINT_STANDARD("skipped (n.a. without U-ext)\n");
 
  }
 
*/
 
 
 
 
 
/*
 
  // ----------------------------------------------------------
 
  // Execute MRET in U-mode (has to trap!)
 
  // ----------------------------------------------------------
 
  neorv32_cpu_csr_write(CSR_MCAUSE, 0);
 
  PRINT_STANDARD("[%i] MRET in U-mode: ", cnt_test);
 
 
 
  // skip if U-mode is not implemented
 
  if (neorv32_cpu_csr_read(CSR_MZEXT) & (1<<CSR_MZEXT_DEBUGMODE)) {
 
 
 
    cnt_test++;
 
 
 
    // switch to user mode (hart will be back in MACHINE mode when trap handler returns)
 
    neorv32_cpu_goto_user_mode();
 
    {
 
      asm volatile("mret");
 
    }
 
 
 
    if (neorv32_cpu_csr_read(CSR_MCAUSE) == TRAP_CODE_I_ILLEGAL) {
 
      test_ok();
 
    }
 
    else {
 
      test_fail();
 
    }
 
 
 
  }
 
  else {
 
    PRINT_STANDARD("skipped (n.a. without U-ext)\n");
 
  }
 
*/
 
 
 
 
  // ----------------------------------------------------------
  // ----------------------------------------------------------
  // Test performance counter: setup as many events and counter as feasible
  // Test performance counter: setup as many events and counter as feasible
  // ----------------------------------------------------------
  // ----------------------------------------------------------
  neorv32_cpu_csr_write(CSR_MCAUSE, 0);
  neorv32_cpu_csr_write(CSR_MCAUSE, 0);
  PRINT_STANDARD("[%i] Configuring HPM events: ", cnt_test);
  PRINT_STANDARD("[%i] Configuring HPM events: ", cnt_test);
Line 1289... Line 1349...
  cnt_test++;
  cnt_test++;
 
 
  // program wake-up timer
  // program wake-up timer
  neorv32_mtime_set_timecmp(neorv32_mtime_get_time() + 1000);
  neorv32_mtime_set_timecmp(neorv32_mtime_get_time() + 1000);
 
 
  // put CPU into sleep mode
  // clear timeout wait flag
  asm volatile ("wfi");
  tmp_a = neorv32_cpu_csr_read(CSR_MSTATUS);
 
  tmp_a &= ~(1 << CSR_MSTATUS_TW);
 
  neorv32_cpu_csr_write(CSR_MSTATUS, tmp_a);
 
 
 
  // switch to user mode (hart will be back in MACHINE mode when trap handler returns)
 
  neorv32_cpu_goto_user_mode();
 
  {
 
    // only when mstatus.TW = 0 executing WFI in user mode is allowed
 
    asm volatile ("wfi"); // put CPU into sleep mode
 
  }
 
 
  if (neorv32_cpu_csr_read(CSR_MCAUSE) != TRAP_CODE_MTI) {
  if (neorv32_cpu_csr_read(CSR_MCAUSE) != TRAP_CODE_MTI) {
    test_fail();
    test_fail();
  }
  }
  else {
  else {

powered by: WebSVN 2.1.0

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