2015-05-23

FunCPU - Internal States and State Diagram



State
Encodedin binary
Explanation
init0000Initial, starting state. FunCPU remains in this state until it determines the lenght of the input expression
start0001Start phase is entered upon each reduction cycle. FunCPU decides if the expression is reduced, or the reduction process should continue.
copy0010In this state FunCPU copies one symbol after another from the source expression to the target.
inc0011Increment function is being executed.
dec0100Decrement function is being executed.
if-in0101if-then-else function is found. If the condition is constant, then the appropriate branch state is reached.
if-then0110Condition was true, the "then" part is selected.
if-skip-else0111Condition was true, the "else" part must be ignored.
if-else1000Condition was false, the "else" part must be selected.
if-skip-then1001Condition was false, the "then" part is ignored.
func-in1010User defined function entry. In this state the FunCPU checks, if all the arguments are available as constant, thus the function can be executed. Otherwise the function reduction is postponed.
func-copy1011FunCPU is unfolding the function definition and performing argument binding.
err-iin1100Some unexpected condition is encountered, most probably due to some hardware error or error in micro-program. Program execution is aborted.
err-arg1101Function with less argument is found, than expected. Program execution is aborted.
err-empty1110Empty expression or function definition is found. Program execution is aborted.
stop1111Input expression has been succesfully calculated. The processor will idle its final state and the result value is observable by looking at the data LEDs.