1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use super::State;
pub mod gates;
pub mod generators;
pub mod memory;
pub mod cpu;
pub mod clocks;
use std::cell::RefCell;
use std::rc::Rc;

#[derive(Debug, PartialEq, Eq, Clone)]
pub enum PinType {
    Undefined,
    Input,
    Output,
    // Both can cause issues on Trace::communicate()
}

#[derive(Debug)]
pub struct Pin {
    pub number: u8,
    pub pin_type: PinType,
    pub state: State,
}
impl Pin {
    pub fn new(number: u8, pin_type: PinType) -> Pin {
        Pin {
            number,
            pin_type,
            state: State::Undefined
        }
    }
}

pub trait Chip: std::fmt::Debug {
    fn run(&mut self, elapsed_time: std::time::Duration);
    fn get_pin_qty(&self) -> u8;
    fn get_pin(&mut self, pin: u8) -> Result<Rc<RefCell<Pin>>, &str>;
    // fn set_pin(&mut self, pin: u8, state: &State);
}