	TITLE "ALU DROP";

PARAMETERS (
	WIDTH=16,
	MODE = "noMUL"
--	MODE = "MUL"
);

SUBDESIGN alu_6 (
	op1[WIDTH-1..0]	: input;
	op2[WIDTH-1..0]	: input;
	cmd[3..0]	: input;
	res[WIDTH-1..0]	: output;
)
VARIABLE
	logic[WIDTH-1..0]	: LCELL;
BEGIN
	CASE cmd[] IS
		WHEN 0 => logic[] = op2[]; -- drop
		WHEN 1 => logic[] = op1[] + op2[]; -- add
		WHEN 2 => logic[] = op2[] - op1[]; -- sub
		WHEN 3 => IF MODE == "noMUL" GENERATE logic[] = op2[] - op1[]; END GENERATE;
				  IF MODE == "MUL" GENERATE logic[] = op2[] * op1[]; END GENERATE;
		WHEN 4 => logic[] = op2[] and op1[]; -- and
		WHEN 5 => logic[] = op2[] or  op1[]; -- or
		WHEN 6 => logic[] = op2[] xor op1[]; -- xor
		WHEN 7 => logic[] = op1[]; -- nip
		WHEN 8,9,10,11,12,13,14,15 => logic[] = op2[]; -- drop
	END CASE;
	res[] = logic[];
--	res[] = H"00A6";
END;