pub struct BasicExecutionNode { /* private fields */ }Expand description
Executes TIS-100 assembly code. Once a Program has been set on the node, the node may be
executed using alternating calls of step and sync.
§Example
use tis_100::core::Port::*;
use tis_100::io::IoBus;
use tis_100::node::{Node, BasicExecutionNode};
use tis_100::parse::parse_program;
let src = "MOV UP ACC\nADD 1\nMOV ACC DOWN\n";
let prog = parse_program(src).unwrap();
let mut bus = IoBus::new();
let mut node = BasicExecutionNode::with_program(prog);
bus.connect_half(0, 1, DOWN)
.connect_half(1, 2, DOWN)
.view(0).write(DOWN, 1);
bus.commit();
for _ in 0..3 {
{
let mut view = bus.view(1);
node.step(&mut view);
node.sync(&mut view);
}
bus.commit();
}
assert_eq!(bus.view(2).read(UP), Some(2));Implementations§
Source§impl BasicExecutionNode
impl BasicExecutionNode
Sourcepub fn new() -> BasicExecutionNode
pub fn new() -> BasicExecutionNode
Construct a new, empty BasicExecutionNode.
Sourcepub fn with_program(program: Program) -> BasicExecutionNode
pub fn with_program(program: Program) -> BasicExecutionNode
Construct a new BasicExecutionNode and initialize it with the given program.
Sourcepub fn set_program(&mut self, program: Program)
pub fn set_program(&mut self, program: Program)
Set the program on a BasicExecutionNode.
pub fn get_mode(&self) -> &Mode
Trait Implementations§
Source§impl Debug for BasicExecutionNode
impl Debug for BasicExecutionNode
Source§impl Node for BasicExecutionNode
impl Node for BasicExecutionNode
Source§fn sync(&mut self, io: &mut IoBusView<'_>)
fn sync(&mut self, io: &mut IoBusView<'_>)
Synchronize this node with the IoBus. If the node was blocked on a write, and that value
was read during the previous cycle, then this will clear the block and allow the node to
proceed with execution.
Source§fn is_stalled(&self) -> bool
fn is_stalled(&self) -> bool
An execution node is stalled if it is waiting on an IO action or if it is not executing.
Auto Trait Implementations§
impl Freeze for BasicExecutionNode
impl RefUnwindSafe for BasicExecutionNode
impl Send for BasicExecutionNode
impl Sync for BasicExecutionNode
impl Unpin for BasicExecutionNode
impl UnwindSafe for BasicExecutionNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more