#[machine_check::machine_description]
mod machine_module {
use ::machine_check::{Ext, Unsigned};
use ::std::{
clone::Clone,
cmp::{Eq, PartialEq},
fmt::Debug,
hash::Hash,
};
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Input {
choice: Unsigned<1>,
}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Param {}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct State {
index: Unsigned<2>,
p: Unsigned<1>,
}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct System {}
impl ::machine_check::Machine for System {
type Input = Input;
type State = State;
type Param = Param;
fn init(&self, _input: &Input, _param: &Param) -> State {
State {
index: Unsigned::<2>::new(0),
p: Unsigned::<1>::new(0),
}
}
fn next(&self, state: &State, input: &Input, _param: &Param) -> State {
let mut next_index = state.index;
if state.index == Unsigned::<2>::new(0) {
next_index = Ext::<2>::ext(input.choice);
}
if state.index == Unsigned::<2>::new(1) {
next_index = Unsigned::<2>::new(2);
}
if state.index == Unsigned::<2>::new(2) {
}
if state.index == Unsigned::<2>::new(3) {
::std::panic!("This state should not be reachable");
}
let mut p = Unsigned::<1>::new(0);
if (next_index == Unsigned::<2>::new(0)) | (next_index == Unsigned::<2>::new(2)) {
p = Unsigned::<1>::new(1);
}
State {
index: next_index,
p,
}
}
}
}
fn main() {
let system = machine_module::System {};
machine_check::run(system);
}