use deepsize2::DeepSizeOf;
use serde::{Deserialize, Serialize};
use crate::{Instruction, Opcode};
use super::MemoryRecordEnum;
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, DeepSizeOf)]
#[repr(C)]
pub struct AluEvent {
pub clk: u64,
pub pc: u64,
pub opcode: Opcode,
pub a: u64,
pub b: u64,
pub c: u64,
pub op_a_0: bool,
}
impl AluEvent {
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn new(clk: u64, pc: u64, opcode: Opcode, a: u64, b: u64, c: u64, op_a_0: bool) -> Self {
Self { clk, pc, opcode, a, b, c, op_a_0 }
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
#[repr(C)]
pub struct MemInstrEvent {
pub clk: u64,
pub pc: u64,
pub opcode: Opcode,
pub a: u64,
pub b: u64,
pub c: u64,
pub op_a_0: bool,
pub mem_access: MemoryRecordEnum,
}
impl MemInstrEvent {
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn new(
clk: u64,
pc: u64,
opcode: Opcode,
a: u64,
b: u64,
c: u64,
op_a_0: bool,
mem_access: MemoryRecordEnum,
) -> Self {
Self { clk, pc, opcode, a, b, c, op_a_0, mem_access }
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
#[repr(C)]
pub struct BranchEvent {
pub clk: u64,
pub pc: u64,
pub next_pc: u64,
pub opcode: Opcode,
pub a: u64,
pub b: u64,
pub c: u64,
pub op_a_0: bool,
}
impl BranchEvent {
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn new(
clk: u64,
pc: u64,
next_pc: u64,
opcode: Opcode,
a: u64,
b: u64,
c: u64,
op_a_0: bool,
) -> Self {
Self { clk, pc, next_pc, opcode, a, b, c, op_a_0 }
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
#[repr(C)]
pub struct JumpEvent {
pub clk: u64,
pub pc: u64,
pub next_pc: u64,
pub opcode: Opcode,
pub a: u64,
pub b: u64,
pub c: u64,
pub op_a_0: bool,
}
impl JumpEvent {
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn new(
clk: u64,
pc: u64,
next_pc: u64,
opcode: Opcode,
a: u64,
b: u64,
c: u64,
op_a_0: bool,
) -> Self {
Self { clk, pc, next_pc, opcode, a, b, c, op_a_0 }
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
#[repr(C)]
pub struct UTypeEvent {
pub clk: u64,
pub pc: u64,
pub opcode: Opcode,
pub a: u64,
pub b: u64,
pub c: u64,
pub op_a_0: bool,
}
impl UTypeEvent {
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn new(clk: u64, pc: u64, opcode: Opcode, a: u64, b: u64, c: u64, op_a_0: bool) -> Self {
Self { clk, pc, opcode, a, b, c, op_a_0 }
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
#[repr(C)]
pub struct InstructionFetchEvent {
pub clk: u64,
pub pc: u64,
pub instruction: Instruction,
pub encoded_instruction: u32,
}
impl InstructionFetchEvent {
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn new(clk: u64, pc: u64, instruction: Instruction, encoded_instruction: u32) -> Self {
Self { clk, pc, instruction, encoded_instruction }
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
#[repr(C)]
pub struct InstructionDecodeEvent {
pub instruction: Instruction,
pub encoded_instruction: u32,
pub multiplicity: usize,
}
impl InstructionDecodeEvent {
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn new(instruction: Instruction, encoded_instruction: u32, multiplicity: usize) -> Self {
Self { instruction, encoded_instruction, multiplicity }
}
}