@@ -80,32 +80,8 @@ fetch_csr (SIM_CPU *cpu, const char *name, int csr, unsigned_word *reg)
80
80
/* Allow certain registers only in respective modes. */
81
81
case CSR_CYCLEH :
82
82
case CSR_INSTRETH :
83
- RISCV_ASSERT_RV32 (cpu , "CSR: %s" , name );
84
- break ;
85
-
86
- /* Load time regs on demand. */
87
83
case CSR_TIMEH :
88
84
RISCV_ASSERT_RV32 (cpu , "CSR: %s" , name );
89
- case CSR_TIME :
90
- {
91
- struct timespec ts ;
92
-
93
- #if defined(CLOCK_BOOTTIME )
94
- if (clock_gettime (CLOCK_BOOTTIME , & ts ) == 0 )
95
- #else
96
- if (clock_gettime (CLOCK_MONOTONIC , & ts ) == 0 )
97
- #endif
98
-
99
- {
100
- uint64_t time = (uint64_t )ts .tv_sec * 1000 * 1000 + ts .tv_nsec ;
101
- * reg = (csr == CSR_TIME ) ? time : (time >> 32 );
102
- }
103
- else
104
- {
105
- /* This shouldn't error, but it's cheap to be semi-sane. */
106
- * reg += 1 ;
107
- }
108
- }
109
85
break ;
110
86
}
111
87
@@ -569,12 +545,12 @@ execute_i (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op)
569
545
break ;
570
546
case MATCH_RDTIME :
571
547
TRACE_INSN (cpu , "rdtime %s;" , rd_name );
572
- store_rd (cpu , rd , fetch_csr (cpu , "time" , CSR_TIME , & cpu -> csr .time ));
548
+ store_rd (cpu , rd , fetch_csr (cpu , "time" , CSR_TIME , & cpu -> csr .cycle ));
573
549
break ;
574
550
case MATCH_RDTIMEH :
575
551
TRACE_INSN (cpu , "rdtimeh %s;" , rd_name );
576
552
RISCV_ASSERT_RV32 (cpu , "insn: %s" , op -> name );
577
- store_rd (cpu , rd , fetch_csr (cpu , "timeh" , CSR_TIMEH , & cpu -> csr .timeh ));
553
+ store_rd (cpu , rd , fetch_csr (cpu , "timeh" , CSR_TIMEH , & cpu -> csr .cycleh ));
578
554
break ;
579
555
580
556
case MATCH_FENCE :
0 commit comments