bus.rsannotatedbus.rssource34 lines · 694 B · raw
1use bincode::{Decode, Encode};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Encode, Decode)]
4pub struct InterruptLines {
5    pub irq1: bool,
6    pub irq2: bool,
7    pub tiq: bool,
8}
9
10impl InterruptLines {
11    #[must_use]
12    pub fn any(self) -> bool {
13        self.irq1 || self.irq2 || self.tiq
14    }
15}
16
17#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Encode, Decode)]
18pub enum ClockSpeed {
19    #[default]
20    Low,
21    High,
22}
23
24pub trait BusInterface {
25    fn read(&mut self, address: u32) -> u8;
26
27    fn write(&mut self, address: u32, value: u8);
28
29    fn idle(&mut self);
30
31    fn interrupt_lines(&self) -> InterruptLines;
32
33    fn set_clock_speed(&mut self, speed: ClockSpeed);
34}