Skip to content

Commit

Permalink
[difftest] add t1_cosim_refresh dpi to support refresh the last com…
Browse files Browse the repository at this point in the history
…mit cycle controled by rtl
  • Loading branch information
Clo91eaf committed Nov 9, 2024
1 parent 2efd2a2 commit 138a024
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
7 changes: 7 additions & 0 deletions difftest/dpi_t1emu/src/dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ unsafe extern "C" fn t1_cosim_watchdog() -> u8 {
TARGET.with(|driver| driver.watchdog())
}

#[no_mangle]
unsafe extern "C" fn t1_cosim_refresh() {
TARGET.with(|driver| {
driver.last_commit_cycle = crate::get_t();
})
}

/// evaluate at instruction queue is not empty
/// arg issue will be type cast from a struct to svBitVecVal*(uint32_t*)
#[no_mangle]
Expand Down
3 changes: 2 additions & 1 deletion difftest/dpi_t1emu/src/drive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub(crate) struct Driver {
max_commit_interval: u64,

// driver state
last_commit_cycle: u64,
pub(crate) last_commit_cycle: u64,
issued: u64,
vector_lsu_count: u8,

Expand Down Expand Up @@ -325,6 +325,7 @@ impl Driver {
self.shadow_mem.apply_writes(&se.mem_access_record);

self.spike_runner.commit_queue.pop_back();
// TODO: use t1_cosim_refresh instead
self.last_commit_cycle = get_t();
}

Expand Down
8 changes: 8 additions & 0 deletions difftest/dpi_t1rocketemu/src/dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,14 @@ unsafe extern "C" fn t1_cosim_watchdog() -> u8 {
TARGET.with(|driver| driver.watchdog())
}

/// update last_commit_cycle to current cycle
#[no_mangle]
unsafe extern "C" fn t1_cosim_refresh() {
TARGET.with(|driver| {
driver.last_commit_cycle = crate::get_t();
})
}

#[no_mangle]
unsafe extern "C" fn get_resetvector(resetvector: *mut c_longlong) {
TARGET.with_optional(|driver| {
Expand Down
8 changes: 7 additions & 1 deletion difftest/dpi_t1rocketemu/src/drive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub(crate) struct Driver {
pub(crate) e_entry: u64,

max_commit_interval: u64,
last_commit_cycle: u64,
pub(crate) last_commit_cycle: u64,

shadow_bus: ShadowBus,

Expand Down Expand Up @@ -134,6 +134,7 @@ impl Driver {
let size = 1 << arsize;
let data = self.shadow_bus.read_mem_axi(addr, size, self.dlen / 8);
let data_hex = hex::encode(&data);
// TODO: use t1_cosim_refresh instead
self.last_commit_cycle = get_t();
trace!(
"[{}] axi_read_high_bandwidth (addr={addr:#x}, size={size}, data={data_hex})",
Expand All @@ -152,6 +153,7 @@ impl Driver {
let size = 1 << awsize;
self.shadow_bus.write_mem_axi(addr, size, self.dlen / 8, &strobe, data);
let data_hex = hex::encode(data);
// TODO: use t1_cosim_refresh instead
self.last_commit_cycle = get_t();
trace!(
"[{}] axi_write_high_bandwidth (addr={addr:#x}, size={size}, data={data_hex})",
Expand All @@ -164,6 +166,7 @@ impl Driver {
assert!(size <= 4);
let data = self.shadow_bus.read_mem_axi(addr, size, 4);
let data_hex = hex::encode(&data);
// TODO: use t1_cosim_refresh instead
self.last_commit_cycle = get_t();
trace!(
"[{}] axi_read_high_outstanding (addr={addr:#x}, size={size}, data={data_hex})",
Expand All @@ -182,6 +185,7 @@ impl Driver {
let size = 1 << awsize;
self.shadow_bus.write_mem_axi(addr, size, 4, strobe, data);
let data_hex = hex::encode(data);
// TODO: use t1_cosim_refresh instead
self.last_commit_cycle = get_t();
trace!(
"[{}] axi_write_high_outstanding (addr={addr:#x}, size={size}, data={data_hex})",
Expand All @@ -194,6 +198,7 @@ impl Driver {
let bus_size = if size == 32 { 32 } else { 4 };
let data = self.shadow_bus.read_mem_axi(addr, size, bus_size);
let data_hex = hex::encode(&data);
// TODO: use t1_cosim_refresh instead
self.last_commit_cycle = get_t();
trace!(
"[{}] axi_read_load_store (addr={addr:#x}, size={size}, data={data_hex})",
Expand All @@ -213,6 +218,7 @@ impl Driver {
let bus_size = if size == 32 { 32 } else { 4 };
self.shadow_bus.write_mem_axi(addr, size, bus_size, strobe, data);
let data_hex = hex::encode(data);
// TODO: use t1_cosim_refresh instead
self.last_commit_cycle = get_t();

trace!(
Expand Down

0 comments on commit 138a024

Please sign in to comment.