











































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












































Patrick Schaumont
Patrick Schaumont
Patrick Schaumont
Patrick Schaumont
full-structural Verilog Model (design all gates)
Structural Verilog Model
Behavioral Verilog Model (with explicit state encoding)Behavioral Verilog Model (with automatic state assignment)
Patrick Schaumont
Patrick Schaumont
Patrick Schaumont
Patrick Schaumont
module
fsm(q,
i,
clk,
rst);
input
i,
clk,
rst;
output
q;
reg
q;
reg
[1:0]
state;
parameter
s
=
2'b00,
s
=
2'b01,
s
=
2'b10;
always
@(
posedge
clk
or
posedge
rst)
if
(rst)
begin
state
<=
s0;
q
<=
1'b0;
end
else
begin
Patrick Schaumont
Spring 2008
end
else
begin
case
(state)
s0:
if
(i
==
1'b1)
begin
state
<=
s1;
q
<=
1'b0;
end
else
begin
state
<=
s0;
q
<=
1'b0;
end
s1:
..
s2:
..
endcase
end
endmodule
reg
q;
reg
[1:0]
state;
parameter
s
=
2'b00,
s
=
2'b01,
s
=
2'b10;
always
@(
posedge
clk
or
posedge
rst)
if
(rst) state
<=
s0;
else
case
(state)
s0:
if
(i
==
1'b1)
state
<=
s1;
else
Patrick Schaumont
Spring 2008
else
state
<=
s0;
s1:
..
endcase
always
@
(state)
q
=
1'b0;
//
default
assignment
case
(state)
s0:
q
=
1'b0;
s1:
q
=
1'b0;
s2:
q
=
1'b1;
endcase
endmodule
Patrick Schaumont
next-state
function
state register
output function
Patrick Schaumont
next-state
function
state register
output function
Patrick Schaumont