Skip to content

Commit

Permalink
[difftest] add [cycle] for check
Browse files Browse the repository at this point in the history
[difftest] fix wrong lane number in peek vrf
  • Loading branch information
Clo91eaf committed Jun 7, 2024
1 parent f4ee2c2 commit ca2a4a9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion difftest/t1-simulator/src/difftest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,15 @@ impl Difftest {
}
"inst" => {
let data = event.parameter.data.unwrap();
let cycle = event.parameter.cycle.unwrap();
// let vxsat = event.parameter.vxsat.unwrap();
// let rd_valid = event.parameter.rd_valid.unwrap();
// let rd = event.parameter.rd.unwrap();
// let mem = event.parameter.mem.unwrap();

let se = self.spike.to_rtl_queue.back().unwrap();
se.record_rd_write(data).unwrap();
se.check_is_ready_for_commit().unwrap();
se.check_is_ready_for_commit(cycle).unwrap();

self.spike.to_rtl_queue.pop_back();
}
Expand Down
6 changes: 3 additions & 3 deletions difftest/t1-simulator/src/difftest/spike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ impl SpikeHandle {
se.issue_idx = issue.idx as u8;

info!(
"[{}] SpikePeekIssue: idx={}, pc = {:#x}, inst = {}",
"[{}] SpikePeekIssue: idx={}, pc={:#x}, inst={}",
issue.cycle, issue.idx, se.pc, se.disasm
);

Expand Down Expand Up @@ -449,7 +449,7 @@ impl SpikeHandle {
pub fn peek_vrf_write_from_lsu(&mut self, vrf_write: VrfWriteEvent) -> anyhow::Result<()> {
let cycle = vrf_write.cycle;
let vlen_in_bytes = self.config.vlen / 8;
let lane_number = self.config.dlen / 8;
let lane_number = self.config.dlen / 32;
let record_idx_base = (vrf_write.vd * vlen_in_bytes
+ (vrf_write.idx + lane_number * vrf_write.offset) * 4) as usize;

Expand All @@ -474,7 +474,7 @@ impl SpikeHandle {
pub fn peek_vrf_write_from_lane(&mut self, vrf_write: VrfWriteEvent) -> anyhow::Result<()> {
let cycle = vrf_write.cycle;
let vlen_in_bytes = self.config.vlen / 8;
let lane_number = self.config.dlen / 8;
let lane_number = self.config.dlen / 32;
let record_idx_base = (vrf_write.vd * vlen_in_bytes
+ (vrf_write.idx + lane_number * vrf_write.offset) * 4) as usize;

Expand Down
8 changes: 4 additions & 4 deletions difftest/t1-simulator/src/difftest/spike/spike_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,27 +355,27 @@ impl SpikeEvent {
Ok(())
}

pub fn check_is_ready_for_commit(&self) -> anyhow::Result<()> {
pub fn check_is_ready_for_commit(&self, cycle: usize) -> anyhow::Result<()> {
for (addr, record) in &self.mem_access_record.all_writes {
assert_eq!(
record.num_completed_writes,
record.writes.len(),
"expect to write mem {addr:#x}, not executed when commit ({})",
"[{cycle}] expect to write mem {addr:#x}, not executed when commit ({})",
format!("pc={:#x}, inst={}", self.pc, self.disasm)
);
}
for (addr, record) in &self.mem_access_record.all_reads {
assert_eq!(
record.num_completed_reads,
record.reads.len(),
"expect to read mem {addr:#x}, not executed when commit ({})",
"[{cycle}] expect to read mem {addr:#x}, not executed when commit ({})",
format!("pc={:#x}, inst={}", self.pc, self.disasm)
);
}
for (idx, record) in &self.vrf_access_record.all_writes {
assert!(
record.executed,
"expect to write vrf {idx}, not executed when commit ({})",
"[{cycle}] expect to write vrf {idx}, not executed when commit ({})",
format!("pc={:#x}, inst={}", self.pc, self.disasm)
);
}
Expand Down

0 comments on commit ca2a4a9

Please sign in to comment.