11use std:: collections:: HashMap ;
22use std:: hint:: unreachable_unchecked;
3+ use log:: info;
34
45use super :: { status_registers:: * , MachineConfig } ;
56use crate :: abstractions:: csr_processor:: CustomCSRProcessor ;
@@ -142,7 +143,7 @@ pub fn output_opcode_stats() {
142143 keys. sort ( ) ;
143144 for key in keys. into_iter ( ) {
144145 let value = OPCODES_COUNTER . with_borrow ( |el| el[ key] ) ;
145- println ! ( "Opcode {}: used {} times" , key, value) ;
146+ info ! ( "Opcode {}: used {} times" , key, value) ;
146147 }
147148 }
148149}
@@ -584,7 +585,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
584585
585586 let current_privilege_mode = self . extra_flags . get_current_mode ( ) ;
586587 let mut pc = self . observable . pc ;
587- // println !("PC = 0x{:08x}", pc);
588+ // info !("PC = 0x{:08x}", pc);
588589 let mut ret_val: u32 = 0 ;
589590 let mut trap = TrapReason :: NoTrap ;
590591 let mut instr: u32 = 0 ;
@@ -746,7 +747,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
746747
747748 let virtual_address = rs1. wrapping_add ( imm) ;
748749
749- // println !("Load into x{:02} from 0x{:08x} at PC = 0x{:08x}", rd, virtual_address, pc);
750+ // info !("Load into x{:02} from 0x{:08x} at PC = 0x{:08x}", rd, virtual_address, pc);
750751
751752 // we formally access it once, but most likely full memory access
752753 // will be abstracted away into external interface hiding memory translation too
@@ -848,7 +849,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
848849 // it's S-type, that has no RD, so set it to x0
849850 rd = 0 ;
850851
851- // println !("Store of x{:02} = 0x{:08x} into 0x{:08x} at PC = 0x{:08x}", STypeOpcode::rs2(instr), rs2, virtual_address, pc);
852+ // info !("Store of x{:02} = 0x{:08x} into 0x{:08x} at PC = 0x{:08x}", STypeOpcode::rs2(instr), rs2, virtual_address, pc);
852853
853854 // store operand rs2
854855
@@ -1194,7 +1195,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
11941195 }
11951196 csr => {
11961197 assert ! ( Config :: ALLOWED_DELEGATION_CSRS . contains( & csr) , "Machine {:?} is not configured to support CSR number {} at pc 0x{:08x}" , Config :: default ( ) , csr, pc) ;
1197- // println !("Custom CSR = 0x{:04x} READ at cycle {}", csr_number, proc_cycle);
1198+ // info !("Custom CSR = 0x{:04x} READ at cycle {}", csr_number, proc_cycle);
11981199 csr_processor. process_read ( self , memory_source, non_determinism_source, tracer, mmu, csr_number, rs1, rs1_as_imm, & mut ret_val, & mut trap) ;
11991200 if trap. is_a_trap ( ) {
12001201 break ' cycle_block;
@@ -1250,7 +1251,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
12501251 assert ! ( Config :: ALLOWED_DELEGATION_CSRS . contains( & csr) , "Machine {:?} is not configured to support CSR number {}" , Config :: default ( ) , csr) ;
12511252 Self :: add_delegation ( csr) ;
12521253 // let t = CSR_COUNTER.fetch_add(1, std::sync::atomic::Ordering::AcqRel);
1253- // println !("Custom CSR = 0x{:04x} WRITE at cycle {}, total: {}", csr_number, proc_cycle, t + 1);
1254+ // info !("Custom CSR = 0x{:04x} WRITE at cycle {}, total: {}", csr_number, proc_cycle, t + 1);
12541255 csr_processor. process_write ( self , memory_source, non_determinism_source, tracer, mmu, csr_number, rs1, rs1_as_imm, & mut trap) ;
12551256 if trap. is_a_trap ( ) {
12561257 break ' cycle_block;
@@ -1304,7 +1305,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
13041305 }
13051306 csr => {
13061307 assert ! ( Config :: ALLOWED_DELEGATION_CSRS . contains( & csr) , "Machine {:?} is not configured to support CSR number {}" , Config :: default ( ) , csr) ;
1307- // println !("Custom CSR = 0x{:04x} READ at cycle {}", csr_number, proc_cycle);
1308+ // info !("Custom CSR = 0x{:04x} READ at cycle {}", csr_number, proc_cycle);
13081309 csr_processor. process_read ( self , memory_source, non_determinism_source, tracer, mmu, csr_number, rs1, rs1_as_imm, & mut ret_val, & mut trap) ;
13091310 if trap. is_a_trap ( ) {
13101311 break ' cycle_block;
@@ -1391,7 +1392,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
13911392 // rd = 0;
13921393 // // mainly we support WFI, MRET, ECALL and EBREAK
13931394 // if csr_number == 0x105 {
1394- // println !("WFI: proc_cycle: {:?}, pc = {}, opcode = 0x{:08x}", proc_cycle, pc, instr);
1395+ // info !("WFI: proc_cycle: {:?}, pc = {}, opcode = 0x{:08x}", proc_cycle, pc, instr);
13951396 // self.extra_flags.set_wait_for_interrupt_bit();
13961397 // self.pc = pc.wrapping_add(4u32);
13971398 // return;
@@ -1490,7 +1491,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
14901491
14911492 // If there was a trap, do NOT allow register writeback.
14921493 debug_assert_eq ! ( trap, TrapReason :: NoTrap ) ;
1493- // println !("Set x{:02} = 0x{:08x}", rd, ret_val);
1494+ // info !("Set x{:02} = 0x{:08x}", rd, ret_val);
14941495 self . set_register ( rd, ret_val, tracer) ;
14951496
14961497 // traps below will update PC themself, so it only happens if we have NO trap
@@ -1499,7 +1500,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
14991500
15001501 // Handle traps and interrupts.
15011502 if trap. is_a_trap ( ) {
1502- println ! ( "trap: {:?}, pc: {:08x}, instr: {:08x}" , trap, pc, instr) ;
1503+ info ! ( "trap: {:?}, pc: {:08x}, instr: {:08x}" , trap, pc, instr) ;
15031504
15041505 if Config :: HANDLE_EXCEPTIONS == false {
15051506 panic ! ( "Simulator encountered an exception" ) ;
@@ -1515,7 +1516,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
15151516 // TODO: here we have a freedom of what to put into tval. We place opcode value now, because PC will be placed into EPC below
15161517 self . machine_mode_trap_data . handling . tval = instr;
15171518 }
1518- // println !("Trapping at pc = 0x{:08x} into PC = 0x{:08x}. MECP is set to 0x{:08x}", pc, self.machine_mode_trap_data.setup.tvec, pc);
1519+ // info !("Trapping at pc = 0x{:08x} into PC = 0x{:08x}. MECP is set to 0x{:08x}", pc, self.machine_mode_trap_data.setup.tvec, pc);
15191520 // self.pretty_dump();
15201521 // self.stack_dump(memory, mmu);
15211522
@@ -1546,11 +1547,11 @@ impl<Config: MachineConfig> RiscV32State<Config> {
15461547 tracer. at_cycle_end ( & * self ) ;
15471548
15481549 //let trap = trap.as_register_value();
1549- //println !("end of cycle: PC = 0x{:08x}, trap = 0x{:08x}, interrupt = {:?}", self.pc, trap, trap & INTERRUPT_MASK != 0);
1550+ //info !("end of cycle: PC = 0x{:08x}, trap = 0x{:08x}, interrupt = {:?}", self.pc, trap, trap & INTERRUPT_MASK != 0);
15501551 }
15511552
15521553 pub fn pretty_dump ( & self ) {
1553- println ! (
1554+ info ! (
15541555 "PC = 0x{:08x}, RA = 0x{:08x}, SP = 0x{:08x}, GP = 0x{:08x}" ,
15551556 self . observable. pc,
15561557 self . observable. registers[ 1 ] ,
@@ -1567,7 +1568,7 @@ impl<Config: MachineConfig> RiscV32State<Config> {
15671568 for ( idx, reg) in chunk. iter ( ) {
15681569 print ! ( "x{:02} = 0x{:08x}, " , idx, reg) ;
15691570 }
1570- println ! ( "" ) ;
1571+ info ! ( "" ) ;
15711572 }
15721573 }
15731574}
0 commit comments