1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2pub struct InstructionTiming {
3 pub t_states_taken: u8,
4 pub t_states_not_taken: Option<u8>,
5 pub machine_cycles: Option<u8>,
6}
7
8impl InstructionTiming {
9 pub const fn fixed(t_states: u8) -> Self {
10 Self {
11 t_states_taken: t_states,
12 t_states_not_taken: None,
13 machine_cycles: None,
14 }
15 }
16
17 pub const fn conditional(taken: u8, not_taken: u8) -> Self {
18 Self {
19 t_states_taken: taken,
20 t_states_not_taken: Some(not_taken),
21 machine_cycles: None,
22 }
23 }
24
25 pub fn for_branch(self, taken: bool) -> u8 {
26 if taken {
27 self.t_states_taken
28 } else {
29 self.t_states_not_taken.unwrap_or(self.t_states_taken)
30 }
31 }
32}