CSYE 7374: IoT Embedded Systems
Assignment 2
Due on 2/5/20
1) Given the following C update function, what does the FSM look like ? Assume push and
pop are input pure signals and the return value of the function is a pure output signal called
output. In addition write down the description of this FSM as a 5-tuple.
typedef enum
{
STATE_A = 0,
STATE_B,
STATE_C,
STATE_D
} state_t;
typedef enum
{
PRESENT = 0,
ABSENT
} signal_t;
signal_t update(state_t *state, signal_t push, signal_t pop)
{
if (push == PRESENT && pop == ABSENT && *state < STATE_D)
{
if (*state == STATE_A)
{
*state = STATE_B;
}
else if (*state == STATE_B)
{
*state = STATE_C;
}
else if (*state == STATE_C)
{
*state = STATE_D;
}
return PRESENT;
}
else if (*state == STATE_D && push == ABSENT && pop == PRESENT)
{
*state = STATE_A;
return PRESENT;
}
return ABSENT;
}
2) Given:
1
Formally write down the description of this FSM as a 5-tuple:
(States,Inputs, Outputs, update, initialState)
Then write a C update that describes the FSM. Note that the function will have two outputs
and a single input. This is exactly the opposite to the FSM shown in the previous exercise
(two inputs and one output).
3) Given:
Is this true or false ? Give supporting argument:
“The output will eventually be a constant 0, or it will eventually be a constant 1. That
is, for some n ∈ N, after the n
th reaction, either the output will be 0 in every subsequent
reaction, or it will be 1 in every subsequent reaction.”
如有需要,请加QQ:99515681 或邮箱:[email protected] 微信:codehelp
原文地址:https://www.cnblogs.com/lyapyth/p/12284176.html