#[machine_check::machine_description]
mod machine_module {
use ::machine_check::Unsigned;
use ::std::{
clone::Clone,
cmp::{Eq, PartialEq},
fmt::Debug,
hash::Hash,
};
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Input {
value: Unsigned<4>,
}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Param {
max_value: Unsigned<4>,
}
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct State {
value: Unsigned<4>,
max_value: Unsigned<4>,
}
#[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 {
max_value: param.max_value,
value: Unsigned::<4>::new(0),
}
}
fn next(&self, state: &State, input: &Input, _param: &Param) -> State {
let mut value = input.value;
if value >= state.max_value {
value = state.max_value;
}
State {
value,
max_value: state.max_value,
}
}
}
}
fn main() {
let system = machine_module::System {};
machine_check::run(system);
}