1use deepsize2::DeepSizeOf;
2use serde::{Deserialize, Serialize};
3
4use super::MemoryRecordEnum;
5use crate::events::PageProtRecord;
6use crate::{vm::results::TrapResult, Instruction, Opcode};
7
8#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, DeepSizeOf)]
12#[repr(C)]
13pub struct AluEvent {
14 pub clk: u64,
16 pub pc: u64,
18 pub opcode: Opcode,
20 pub a: u64,
22 pub b: u64,
24 pub c: u64,
26 pub op_a_0: bool,
28}
29
30impl AluEvent {
31 #[must_use]
33 #[allow(clippy::too_many_arguments)]
34 pub fn new(clk: u64, pc: u64, opcode: Opcode, a: u64, b: u64, c: u64, op_a_0: bool) -> Self {
35 Self { clk, pc, opcode, a, b, c, op_a_0 }
36 }
37}
38
39#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
43#[repr(C)]
44pub struct MemInstrEvent {
45 pub clk: u64,
47 pub pc: u64,
49 pub opcode: Opcode,
51 pub a: u64,
53 pub b: u64,
55 pub c: u64,
57 pub op_a_0: bool,
59 pub mem_access: MemoryRecordEnum,
61}
62
63impl MemInstrEvent {
64 #[must_use]
66 #[allow(clippy::too_many_arguments)]
67 pub fn new(
68 clk: u64,
69 pc: u64,
70 opcode: Opcode,
71 a: u64,
72 b: u64,
73 c: u64,
74 op_a_0: bool,
75 mem_access: MemoryRecordEnum,
76 ) -> Self {
77 Self { clk, pc, opcode, a, b, c, op_a_0, mem_access }
78 }
79}
80
81#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
85#[repr(C)]
86pub struct TrapMemInstrEvent {
87 pub clk: u64,
89 pub pc: u64,
91 pub opcode: Opcode,
93 pub a: u64,
95 pub b: u64,
97 pub c: u64,
99 pub op_a_0: bool,
101 pub page_prot_access: PageProtRecord,
103 pub trap_result: TrapResult,
105}
106
107#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
111#[repr(C)]
112pub struct BranchEvent {
113 pub clk: u64,
115 pub pc: u64,
117 pub next_pc: u64,
119 pub opcode: Opcode,
121 pub a: u64,
123 pub b: u64,
125 pub c: u64,
127 pub op_a_0: bool,
129}
130
131impl BranchEvent {
132 #[must_use]
134 #[allow(clippy::too_many_arguments)]
135 pub fn new(
136 clk: u64,
137 pc: u64,
138 next_pc: u64,
139 opcode: Opcode,
140 a: u64,
141 b: u64,
142 c: u64,
143 op_a_0: bool,
144 ) -> Self {
145 Self { clk, pc, next_pc, opcode, a, b, c, op_a_0 }
146 }
147}
148
149#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
153#[repr(C)]
154pub struct JumpEvent {
155 pub clk: u64,
157 pub pc: u64,
159 pub next_pc: u64,
161 pub opcode: Opcode,
163 pub a: u64,
165 pub b: u64,
167 pub c: u64,
169 pub op_a_0: bool,
171}
172
173impl JumpEvent {
174 #[must_use]
176 #[allow(clippy::too_many_arguments)]
177 pub fn new(
178 clk: u64,
179 pc: u64,
180 next_pc: u64,
181 opcode: Opcode,
182 a: u64,
183 b: u64,
184 c: u64,
185 op_a_0: bool,
186 ) -> Self {
187 Self { clk, pc, next_pc, opcode, a, b, c, op_a_0 }
188 }
189}
190#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
194#[repr(C)]
195pub struct UTypeEvent {
196 pub clk: u64,
198 pub pc: u64,
200 pub opcode: Opcode,
202 pub a: u64,
204 pub b: u64,
206 pub c: u64,
208 pub op_a_0: bool,
210}
211
212impl UTypeEvent {
213 #[must_use]
215 #[allow(clippy::too_many_arguments)]
216 pub fn new(clk: u64, pc: u64, opcode: Opcode, a: u64, b: u64, c: u64, op_a_0: bool) -> Self {
217 Self { clk, pc, opcode, a, b, c, op_a_0 }
218 }
219}
220
221#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
225#[repr(C)]
226pub struct TrapExecEvent {
227 pub clk: u64,
229 pub pc: u64,
231 pub trap_result: TrapResult,
233 pub page_prot_record: PageProtRecord,
235}
236
237#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
241#[repr(C)]
242pub struct InstructionFetchEvent {
243 pub clk: u64,
245 pub pc: u64,
247 pub instruction: Instruction,
249 pub encoded_instruction: u32,
251}
252
253impl InstructionFetchEvent {
254 #[must_use]
256 #[allow(clippy::too_many_arguments)]
257 pub fn new(clk: u64, pc: u64, instruction: Instruction, encoded_instruction: u32) -> Self {
258 Self { clk, pc, instruction, encoded_instruction }
259 }
260}
261
262#[derive(Debug, Clone, Copy, Serialize, Deserialize, DeepSizeOf)]
266#[repr(C)]
267pub struct InstructionDecodeEvent {
268 pub instruction: Instruction,
270 pub encoded_instruction: u32,
272 pub multiplicity: usize,
274}
275
276impl InstructionDecodeEvent {
277 #[must_use]
279 #[allow(clippy::too_many_arguments)]
280 pub fn new(instruction: Instruction, encoded_instruction: u32, multiplicity: usize) -> Self {
281 Self { instruction, encoded_instruction, multiplicity }
282 }
283}