% 6.111 Final Project - Fall 1996 - "PIC-Cam" %
% Kenneth B. Russell <kbrussel@mit.edu> %

% Independent FSM for implementing /CAS before /RAS-style (CBR) %
% DRAM refresh, with an input for disabling the refresh circuitry. %

SUBDESIGN dram_refresh
(
	disable		: INPUT;
	reset		: INPUT;
	clk			: INPUT;
	/cas, /ras	: OUTPUT;
)
VARIABLE
	mach : MACHINE WITH STATES(wait,
				   cas_enabled,
				   ras_enabled1,
				   ras_enabled2);
BEGIN
	mach.clk = clk;
	mach.reset = reset;
	
	CASE mach IS
		WHEN wait =>
			/cas = VCC;
			/ras = VCC;
			IF (!disable) THEN
				mach = cas_enabled;
			else
				mach = wait;
			END IF;
		WHEN cas_enabled =>
			/cas = GND;
			/ras = VCC;
			mach = ras_enabled1;
		WHEN ras_enabled1 =>
			/cas = GND;
			/ras = GND;
			mach = ras_enabled2;
		WHEN ras_enabled2 =>
			/cas = GND;
			/ras = GND;
			mach = wait;
	END CASE;
END;