Skip to content

Commit

Permalink
[tab] add trace
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf committed May 11, 2024
1 parent 6e96e92 commit f6beb33
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/tui/selected_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const INST_BUFFER_SIZE: usize = 10;
const CPU_BUFFER_SIZE: usize = 10;
const DUT_BUFFER_SIZE: usize = 10;
const DIFF_BUFFER_SIZE: usize = 5;
const MEMORY_BUFFER_SIZE: usize = 10;
const FUNCTION_BUFFER_SIZE: usize = 10;

#[derive(Clone)]
pub struct InfoBuffer {
Expand Down Expand Up @@ -42,23 +44,41 @@ impl fmt::Display for InfoBuffer {
}
}
#[derive(Clone)]
pub struct UIBuffer {
pub struct DiffBuffer {
pub inst: InfoBuffer,
pub cpu: InfoBuffer,
pub dut: InfoBuffer,
pub diff: InfoBuffer,
}

impl UIBuffer {
impl DiffBuffer {
pub fn new() -> Self {
UIBuffer {
DiffBuffer {
inst: InfoBuffer::new(INST_BUFFER_SIZE),
cpu: InfoBuffer::new(CPU_BUFFER_SIZE),
dut: InfoBuffer::new(DUT_BUFFER_SIZE),
diff: InfoBuffer::new(DIFF_BUFFER_SIZE),
}
}
}

#[derive(Clone)]
pub struct TraceBuffer {
pub itrace: InfoBuffer,
pub mtrace: InfoBuffer,
pub ftrace: InfoBuffer,
}

impl TraceBuffer {
pub fn new() -> Self {
TraceBuffer {
itrace: InfoBuffer::new(INST_BUFFER_SIZE),
mtrace: InfoBuffer::new(MEMORY_BUFFER_SIZE),
ftrace: InfoBuffer::new(FUNCTION_BUFFER_SIZE),
}
}
}

#[derive(Default, Clone, Copy, Display, FromRepr, EnumIter)]
pub enum SelectedTabEnum {
#[default]
Expand Down Expand Up @@ -103,14 +123,16 @@ impl SelectedTabEnum {

#[derive(Clone)]
pub struct SelectedTab {
pub diff_buffer: UIBuffer,
pub diff_buffer: DiffBuffer,
pub trace_buffer: TraceBuffer,
pub state: SelectedTabEnum,
}

impl SelectedTab {
pub fn new() -> Self {
SelectedTab {
diff_buffer: UIBuffer::new(),
diff_buffer: DiffBuffer::new(),
trace_buffer: TraceBuffer::new(),
state: SelectedTabEnum::default(),
}
}
Expand Down

0 comments on commit f6beb33

Please sign in to comment.