Final - Spring 2021 NS
Final - Spring 2021 NS
Faculty of Engineering
Departments of Electrical and Computer Engineering
Final Exam
Name:__________________________________________________________________
ID number:______________________________________________________________
This is a closed-book, closed-note exam. No calculators please. You have 1 hour and 40
minutes. Each question is marked with its number of points.
Clk
Z (MOORE)
a) (10 points) Draw the state diagram using MOORE machine.
b) (6 points) Write down the state table and generate the equations.
c) (4 points) Implement the design using D-type flip-flops and combinational logic.
2
This FSM is responsible for detecting the presence of a vehicle at the entry and is
waiting for the pulse from the password FSM. Assume that the password FSM is
already designed and is generating the “correct” pulse. The main job of this FSM is to
send commands to the motor control FSM to open or close the arm and the motor control
FSM will generate the actual signals for controlling the motor driving the arm (you are
asked to design the motor control FSM in Problem 3).
So, this FSM goes like this. There are two sensors installed: S1, S2. S1 is just before
the arm to detect the presence of the vehicle. S2 is installed right at the barrier arm to
detect the presence of any object under the arm so that the arm will not close on it.
Assume that both sensors are active-low. This means that when no car is
detected, S1, S2=11. When a car is detected on S1, then S1=0 (active-low). Similarly,
when a car is detected on S2 (a car is going in), S2=0.
In this simplified version, assuming a car is present at the gate and a correct
password was entered, only two scenarios are possible: The first scenario would be as
follows (remember sensors are active-low): S1, S2= 01 (car is on sensor S1), then 00 (car
is on both sensors), then 10 (car is on S2), and finally 11 when the car is fully inside. This
scenario represents a car at the entry, then keep moving forward until it is fully inside.
The second scenario is: S1, S2=01, then 11. In this case, this can be interpreted as a car
was present, entered a correct password, but then it decided to back up. In both scenarios,
after the correct password was entered, the arm would be given a command to open; then,
when S1, S2 become 11, this FSM should send a signal to close the arm. Only after S1,
S2 becomes 11, a new car can proceed to the gate (this is the simplification explained
above in bold). Also assume that a newly arrived car will never enter the parking
without a correct password even if the gate is not fully closed; therefore, there is no
need for “alarm” signal (of course, this is not realistic in the real world but we will
assume this simplification here).
The output of this FSM should be one bit, COM, which is input to the motor
control FSM that you are asked to design in Problem 3. The machine should operate as
follows. Whenever this FSM needs to open the arm, it generates COM = 1 for TWO
clock periods. If this machine needs to close the arm, it generates COM = 1 for ONE
clock period.
Draw the state diagram for this controller using Mealy machine.
3
GoF GoB Action
0 0 Arm is not moving
1 0 Arm is opening
0 1 Arm is closing
1 1 Not valid output
One additional input, COM, is needed to drive our FSM. Assume that COM is
generated by the master state machine designed in Problem 2 that controls our state
machine (i.e. output from master; inputs to our state machine). The machine should
operate as follows. Whenever the master machine needs to open the arm, it generates
COM = 1 for TWO clock periods. If the master machine needs to close the arm, it
generates COM = 1 for ONE clock period.
Draw a state diagram for the above problem using Moore machine.
Hint: The command to open or close the arm is controlled by the width of the pulse
on COM signal, instead of CF and CB signals used in the project. So, as soon as you
detect COM=1, you should go to a new state. From that state you should check COM
one more time and based on the new value of COM, you will detect if it is a closing
or opening command and act accordingly.