Skip to content

Commit

Permalink
refactor log
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf committed May 2, 2024
1 parent 0450f54 commit 61dd3f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
28 changes: 12 additions & 16 deletions src/dut.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod top;
use top::Top;
use crate::emulator::DebugInfo;
use top::Top;
use tracing::info;

pub struct SramRequest {
Expand Down Expand Up @@ -64,29 +64,25 @@ impl Dut {

self.clocks += 1;

info!("==============================");
info!("clocks: {}", self.clocks);
info!("debug_commit: {}", self.top.debug_commit());
info!("debug_pc: 0x{:x}", self.top.debug_pc());
info!("debug_reg_wnum: {}", self.top.debug_reg_wnum());
info!("debug_wdata: 0x{:x}", self.top.debug_wdata());
info!(
"[dut] clocks: {} commit: {} pc: {:#010x} wnum: {} wdata: {:#018x}",
self.clocks,
self.top.debug_commit(),
self.top.debug_pc(),
self.top.debug_reg_wnum(),
self.top.debug_wdata()
);

Ok({
(
SramRequest::new(
self.top.inst_sram_en() != 0,
self.top.inst_sram_addr(),
),
SramRequest::new(
self.top.data_sram_en() != 0,
self.top.data_sram_addr(),
),
SramRequest::new(self.top.inst_sram_en() != 0, self.top.inst_sram_addr()),
SramRequest::new(self.top.data_sram_en() != 0, self.top.data_sram_addr()),
DebugInfo::new(
self.top.debug_commit() != 0,
self.top.debug_pc(),
self.top.debug_reg_wnum(),
self.top.debug_wdata(),
)
),
)
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/emulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ impl Emulator {
loop {
let pc = self.cpu.pc;
let trap = self.execute();
info!("pc: {:#x}, inst: {}", pc, self.cpu.inst);
info!("[cpu] pc: {:#x}, inst: {}", pc, self.cpu.inst);

match trap {
Trap::Fatal => {
info!("pc: {:#x}, trap {:#?}", self.cpu.pc, trap);
info!("[cpu] pc: {:#x}, trap {:#?}", self.cpu.pc, trap);
return;
}
_ => {}
Expand Down

0 comments on commit 61dd3f2

Please sign in to comment.