SUBDESIGN mealy
(
	clk	: INPUT;
	reset	: INPUT;
	y		: INPUT;
	z		: OUTPUT;
)
VARIABLE
	ss: MACHINE WITH STATES (s0, s1, s2, s3);
BEGIN
	ss.clk = clk;
	ss.reset = reset;

	TABLE
	%	current	current	current	next  %
	%	state		input	output		state %
		ss,		y		=>	z,		ss;

		s0,		0		=>	0,		s0;
		s0,		1		=>	1,		s1;
		s1,		0		=>	1,		s1;
		s1,		1		=>	0,		s2;
		s2,		0		=>	0,		s2;
		s2,		1		=>	1,		s3;
		s3,		0		=>	0,		s3;
		s3,		1		=>	1,		s0;
	END TABLE;
END;
