tis_100/node/
mod.rs

1//! Types of nodes used in the TIS-100.
2
3pub use self::exec::{BasicExecutionNode, DamagedExecutionNode};
4pub use self::stack::StackMemoryNode;
5pub use self::test::{TestInputNode, TestOutputNode, TestImageNode};
6
7mod exec;
8mod stack;
9mod test;
10
11use io::IoBusView;
12
13/// Interface for nodes in a TIS-100 system.
14pub trait Node {
15    /// Execute a single instruction cycle.
16    #[allow(unused)]
17    fn step(&mut self, io: &mut IoBusView) {
18
19    }
20
21    /// Synchronize reads and writes after the last instruction cycle.
22    #[allow(unused)]
23    fn sync(&mut self, io: &mut IoBusView) {
24
25    }
26
27    /// Determine if a node is executing assembly code or if it is stalled on a read or write.
28    /// For all nodes except nodes which can execute assembly, this should always be `true`.
29    fn is_stalled(&self) -> bool {
30        true
31    }
32}
33
34#[derive(Debug, PartialEq, Eq, Copy, Clone)]
35pub enum TestState {
36    Testing,
37    Passed,
38    Failed,
39}
40
41pub trait TestNode: Node {
42    fn state(&self) -> TestState;
43}