Professional Documents
Culture Documents
/24), where
DNSK2
Consider the following state machine description that is very similar to
the room control state machine from the practice exam for midterm 2
(changes have been made apparent):
A room has a capacity of four people. It has an exit door and an entry
door. Two outputs indicate whether the door is open (1) or closed (0) for
each of the doors. There is an additional output that will turn on/off the
lights. No one can enter at the exit door or leave through the entry door.
The entry door will lock itself if there are already four people in the room
and remain unlocked otherwise. The exit door will lock itself if there is no
person inside the room. The lights will turn on when there is at least one
person and turn off if there is no person. Only one person can enter or
leave at the same time. At each time step, a person may
attempt to enter or not, and a person may leave, or not.
rst=1b1;
#4
rst=1b0;
#512
$stop;
end
reg [3:0] lfsr4;
always@(posedge clk)
if(rst)
lfsr4<=4b0001;
else
begin
lfsr4[3]<=lfsr4[2];
lfsr4[2]<=lfsr4[1];
lfsr4[1]<=lfsr4[0]^lfsr4[3];
lfsr4[0]<=lfsr4[3];
end
entryControl NQ(clk, rst, (lfsr4[3]|lfsr4[2])&(enL), (lfsr4[1]|lfsr4[0])&lit,
enL, exL, lit);
endmodule
DNSK4
Exit
Exit
DNSK5
Exit