Verilog Code
Verilog Code
module bcd_3(out,bi,clk,rst);
output out;
input bi,clk,rst;
reg out;
if(rst==0)
pst<=s0;
else
pst<=nst;
begin
out=0;
case(pst)
s0:if(bi==0)
begin
nst=s1;
out=1;
end
else
nst=s2;
s1:if(bi==0)
begin
nst=s3;
out=1;
end
else
nst=s4;
s2:begin
nst=s4;
out=bi;
end
s3:begin
nst=s5;
out=bi;
end
s4:if(bi==0)
begin
nst=s5;
out=1;
end
else
nst=s6;
s5:begin
nst=s0;
out=1;
end
s6:begin
nst=s0;
out=1;
end
endcase
end
endmodule
output: