Starting from:

$30

COE428 Lab 4: State Machine

COE428 Lab 4: State Machine
1. IMPORTANT: Two week lab
Note that you have two weeks to complete this lab. This lab must be submitted at least
48 hours before the beginning of your next lab period.

2. Prelab preparation
Before coming to the lab you should:
• Read the lab. Try to prepare any questions you may have about the lab.
• Refer to Lab Guide.
• Create your lab directory for lab4. (i.e. use mkdir lab4 within your coe428 directory.)
• Change to your coe428/lab4 and unzip the lab4.zip file with the command:
 unzip /home/courses/coe428/lab4/lab4.zip
• Ensure that you have downloaded properly by entering the command: make
No errors should be reported.
• Get a custom version of the State Machine you are supposed to implement with the
command /home/courses/coe428/bin/getLab4
Note
The command /home/courses/coe428/bin/getLab4 will execute properly only on a
Sun Workstation. If you are using a computer other than a Sun workstation, please ssh to
a Sun Workstation. (For example, ssh genesis.ee.ryerson.ca)

3. Requirements
The requirements to complete the lab are summarized below.
1. Draw a diagram of your state machine.
2. Create an executable program simState (based on C source code) that is able to respond to
the commands described below.
3. Your program will be presented with zero or more commands from stdin (each on a line by
itself) and must respond precisely as specified for each command as listed below.
No Commands:
Before any commands are issued to your program, it should print out the starting state.
One/Zero Commands:
These commands (a `0' or a `1' on a line by itself) must print to stdout the name of the next
state given the supplied input, and update the current state.
Change command:
The change command is invoked by the letter `c' followed by a `1' or a `0' followed by the
name of a state (i.e. a single letter in the range A–H). This command modifies the state
machine such that the `0' (or `1') command applied to the current state will cause the
machine to change to the named state and that this change is the state machine
configuration will continue. This command should produce no output.
Print command:
The print command is invoked with the single letter `p'. It should print to stdout the state
machine configuration as currently specified (i.e. including changes that may have been
made with change commands) in the same format that your state machine was specified
with.
Garbage Identify command:
This command is invoked with the single letter `g'. It should identify all states that are
reachable or unreachable from the current state. It always produces output to stdout.
If all states are reachable, it should output No garbage. Otherwise, it should output
Garbage: <unreachable states> where <unreachable states> is the list of the state
names that are no longer reachable.
Delete command:
This command is invoked with `d', optionally followed by the name of a state to delete.
When the ‘d’ command is invoked without the optional argument, it should delete (i.e.
mark as “deleted”) all un-deleted states that are unreachable. If there are no such
unreachable un-deleted states, it should print:
No states deleted.
Otherwise, it should print the message:
Deleted: <list of deleted states>
If the ‘d’ command is followed by an argument that it the valid name of a state, it should
print out either the message:
Deleted.
if
m
If
th
co
4. Exam
The desc
<StateN
The <Sta
if the inp
single up
For exam
A B C
B A A
C A D
D D C
 We can

f the state is
message:
Not
f a state is su
he print c
ommand.
mple
cription of a
ame> <Next
ateName> is
put is `0'; and
ppercase lette
mple, given th
draw a pictu
s not reacha
deleted.
uccessfully d
command an
state machin
tState0> <N
s the name o
d <NextState
ers.
he state mac
ure of the sta
Fig
able and no
deleted, it sh
nd it should
ne is given in
NextState1
of the state b
e1> is the na
chine descrip
ate machine a
ure 1 Stat
t already de
hould no long
d be disallow
n a text file w
1>
being define
ame of next
ption and the
as shown be
te Machin
eleted. Othe
ger appear in
wed as a fi
where each l
d, <NextSta
state if the i
e information
elow.
e Diagram
rwise, it sho
n the list of s
final argume
line has the f
ate0> is the n
nput is `1'. A
n that the ini
m
ould print o
states produ
ent to the c
following fo
name of nex
All state nam
itial state is
out the
ced by
change
ormat:
xt state
mes are
`C':
Sample input and output is:
Interface Comment: Input or Output
C Output
0 Input
A Output
0 Input
B Output
c 0 C Input
0 Input
C Output
p Input
A B C
B C A
C A D
D D C
Output
g Input
No Garbage Output
c 1 B Input
g Input
Garbage: D Output
d Input
Deleted: D Output
p Input
A B C
B C A
C A B
Output
Submit your lab
1. Go to your coe428 directory
2. Zip your lab4 directory by using the following command:
 zip -r lab4.zip lab4/
3. Submit the lab4.zip file using the following command:
 submit coe428 lab4 lab4.zip
by Ken Clowes, revised by Ivan Lee, revised by Olivia Das 

More products