Skip to content

Commit

Permalink
[ipemu] fix t1 emulator quit
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf committed Aug 16, 2024
1 parent 6fdeb87 commit 75c58cc
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions difftest/spike_rs/src/spike_event.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::HashMap;
use tracing::trace;
use tracing::{info, trace};
use Default;

use crate::clip;
Expand Down Expand Up @@ -95,6 +95,9 @@ pub struct SpikeEvent {
pub vd_write_record: VdWriteRecord,
pub mem_access_record: MemAccessRecord,
pub vrf_access_record: VrfAccessRecord,

// exit
pub is_exit: bool,
}

impl SpikeEvent {
Expand Down Expand Up @@ -143,6 +146,8 @@ impl SpikeEvent {
vd_write_record: Default::default(),
mem_access_record: Default::default(),
vrf_access_record: Default::default(),

is_exit: false,
}
}

Expand Down Expand Up @@ -223,10 +228,7 @@ impl SpikeEvent {
}

pub fn is_exit(&self) -> bool {
let is_csr_type = self.opcode() == 0b1110011 && ((self.width() & 0b011) != 0);
let is_csr_write = is_csr_type && (((self.width() & 0b100) | self.rs1()) != 0);

is_csr_write && self.csr() == 0x7cc
self.is_exit
}

pub fn is_vfence(&self) -> bool {
Expand Down Expand Up @@ -455,6 +457,13 @@ impl SpikeEvent {
});
});
trace!("SpikeMemWrite: addr={addr:x}, value={value:x}, size={size}");

if addr == 0x4000_0000 && value == 0xdead_beef {
info!("SpikeExit: exit by writing 0xdeadbeef to 0x40000000");
self.is_exit = true;

return;
}
});

Ok(())
Expand Down

0 comments on commit 75c58cc

Please sign in to comment.